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 System.Data.SqlClient;

public partial class WTOSYSadmin_vipmag_viewsedit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Session["WtoRightName"] == null)
        {
            Response.Redirect("~/SYSADMIN/main/error.aspx?err=非法登陆!或系统超时，请刷新后重新登录");
        }
        if (!IsPostBack)
        {
            SqlConnection conn = CDatabase.wtoconn();
            conn.Open();
            SqlCommand smd = new SqlCommand("select * from Comments where id=" + Request.QueryString["id"], conn);
            SqlDataReader sdr = smd.ExecuteReader();
            sdr.Read();
            if (sdr.GetString(12) == "y")
            {
                this.Image1.Visible = true;
                this.Label1.Visible = true;
            }
            this.username.Text = sdr.GetString(1);
            this.Content.Text = sdr.GetString(3);
            this.ip.Text = sdr.GetString(4);
            if (sdr.GetString(2) == "y")
            {
                this.y.Checked = true;
            }
            else
            {
                this.n.Checked = true;
            }
            if (sdr.GetString(6) != "n" && sdr.GetString(7) != "n")
            {
                this.shefen.Text = sdr.GetString(6);
                this.reContent.Text = sdr.GetString(7);
            }
            sdr.Close();

            
            conn.Close();

        }
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        string isfp, content, shenfen, recontent;
        if (this.y.Checked == true)
        {
            isfp = "y";
        }
        else
        {
            isfp = "n";
        }
        content = Request["Content"].ToString();
        shenfen = Request["shefen"].ToString();
        recontent = Request["reContent"].ToString();
        string sql = "update Comments set isfp='"+isfp+"',Content='"+content+"',shefen='"+shenfen+"',reContent='"+recontent+"' where id="+Request.QueryString["id"];
        if (Doadmin.Exec(sql))
        {
            Response.Write("<script>alert('修改成功!');location.href='views2.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('此次操作失败!')</script>");
        }

    }
}
