using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using UUN;
using System.Data.SqlClient;
using System.IO;

public partial class Admin_LunTan_TieZhi_CheDiShanChu : System.Web.UI.Page
{
    private 访问 访问;
    protected void Page_Load(object sender, EventArgs e)
    {
        访问 = new 访问(this.Context);
        访问.开始处理("彻底删除贴子", "网站后台", "彻底删除贴子", new 访问.回调委托(ZhiXing));
        访问.关闭连接();
    }

    private void ZhiXing()
    {
        访问.验证管理员();
        访问.验证权限("34");

        String[] IDS = Request.QueryString["ID"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        for (int i = 0; i < IDS.Length; i++)
            删除贴子(Convert.ToInt32(IDS[i]));

        访问统计_管理记录 记录 = new 访问统计_管理记录(this.Context, 访问.连接);
        记录.记录("彻底删除贴子", 访问.用户["昵称"].ToString());

        Response.Redirect("TieZhi_HuiShou.aspx");
    }

    private void 删除贴子(int ID)
    {
        String 附件内容 = "";
        SqlCommand 语句 = new SqlCommand("SELECT [附件内容] FROM [" + 程序.数据表前缀 + "社区_论坛_贴子] WHERE [ID]=" + ID, 访问.连接);
        SqlDataReader 读取 = 语句.ExecuteReader();
        if (读取.Read())
            附件内容 = Convert.ToString(读取["附件内容"]);
        else
        {
            读取.Close();
            return;
        }
        读取.Close();

        File.Delete(Server.MapPath(程序.安装位置 + "Data/DT_TieZhi/" + (ID /500) + "/" + ID + ".txt"));
        String[] 附件数组 = 附件内容.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        for (int i = 0; i < 附件数组.Length; i++)
            if (File.Exists(Server.MapPath(附件数组[i])))
                File.Delete(Server.MapPath(附件数组[i]));
        语句 = new SqlCommand("DELETE FROM ["+程序.数据表前缀+"社区_论坛_贴子] WHERE [ID]=" + ID, 访问.连接);
        语句.ExecuteNonQuery();
    }
}
