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;

public partial class CardManage_RevertCard : System.Web.UI.Page
{
    CardManage cardmanage = new CardManage();
    RevertManage revertmanage = new RevertManage();
    UserManage usermanage = new UserManage();
    HostManage hostmanage = new HostManage();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataSet ds = null;
            if (Session["Name"] == null)
            {
                Response.Redirect("../Common/LimitPop.aspx");
            }
            else
            {
                cardmanage.CardID = Page.Request.QueryString["CardID"].ToString();
                labCName.Text = cardmanage.FindCardByID(cardmanage, "tb_Card").Tables[0].Rows[0][1].ToString();
                string strName = Session["Name"].ToString();
                if (Session["Pop"].ToString() == "用户")
                {
                    usermanage.UserName = strName;
                    ds = usermanage.FindUserByName(usermanage, "tb_User");
                    labName.Text = strName;
                    labEmail.Text = ds.Tables[0].Rows[0][9].ToString();
                    labQQ.Text = ds.Tables[0].Rows[0][7].ToString();
                    labIndex.Text = ds.Tables[0].Rows[0][12].ToString();
                    imgPhoto.ImageUrl = ds.Tables[0].Rows[0][8].ToString();
                    return;
                }
                if (Session["Pop"].ToString() == "版主")
                {
                    hostmanage.HostName = strName;
                    ds = hostmanage.FindHostByName(hostmanage, "tb_Host");
                    labName.Text = strName;
                    labEmail.Text = ds.Tables[0].Rows[0][10].ToString();
                    labQQ.Text = ds.Tables[0].Rows[0][8].ToString();
                    labIndex.Text = ds.Tables[0].Rows[0][13].ToString();
                    imgPhoto.ImageUrl = ds.Tables[0].Rows[0][9].ToString();
                    return;
                }
                if (Session["Pop"].ToString() == "管理员")
                {
                    labName.Text = strName;
                    labEmail.Text = "无";
                    labQQ.Text = "无";
                    labIndex.Text = "无";
                    imgPhoto.ImageUrl = "../Images/Admin.jpg";
                    return;
                }
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (txtName.Text == string.Empty)
        {
            Response.Write("<script language=javascript>alert('回帖主题不能为空！')</script>");
            return;
        }
        revertmanage.RevertID = revertmanage.GetRCID();
        revertmanage.RevertName = txtName.Text;
        revertmanage.CardID = Page.Request.QueryString["CardID"].ToString();
        revertmanage.RevertContent = FreeTextBox1.Text;
        revertmanage.RevertTime = DateTime.Now;
        revertmanage.RevertPeople = Session["Name"].ToString();
        revertmanage.Pop = Session["Pop"].ToString();
        revertmanage.AddRevert(revertmanage);
        Response.Redirect("CardInfo.aspx?CardID=" + Page.Request.QueryString["CardID"].ToString() + "");
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        txtName.Text = FreeTextBox1.Text = string.Empty;
    }
}
