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 SYSadmin_Vote_Votemag : 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)
        {
            databind();
        }
    }
    protected void databind()
    {
        SqlConnection conn = CDatabase.wtoconn();
        conn.Open();
        SqlCommand smd = new SqlCommand("select * from productmoban where id=" + Request.QueryString["id"], conn);
        SqlDataReader sdr = smd.ExecuteReader();
        sdr.Read();
        this.title.Text = sdr["mobantitle"].ToString();
        this.Content.Text = Server.HtmlDecode(sdr["mobantext"].ToString());
        if (sdr["defaultmoban"].ToString().Trim() == "y")
        {
            isy.Checked = true;
        }
        else
        {
            isn.Checked = true;
        }
        sdr.Close();
        conn.Close();
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        string isfp = "";
        if (isy.Checked)
        {
            isfp = "y";
        }
        else
        {
            isfp = "n";
        }
        string sqltxt = "update productmoban set mobantitle='" + this.title.Text + "',mobantext='" + Server.HtmlEncode(this.Content.Text) + "',defaultmoban='" + isfp + "',addtime='"+DateTime.Now.ToString()+"'  where id=" + Request.QueryString["id"]; ;
        if (Doadmin.Exec(sqltxt))
        {
            if (isfp == "y")
            {
                Doadmin.Execsql("update productmoban set defaultmoban='n' where id<>" + Request.QueryString["id"]);
            }
            Response.Write("<script>alert('提交成功');window.location.href='moban.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('添加失败');window.location.href='moban.aspx'</script>");
        }
    }
}
