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=非法登陆!或系统超时，请刷新后重新登录");
        }
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        string isfp = "",isvi="";
        if (isy.Checked)
        {
            isfp = "y";
        }
        else
        {
            isfp = "n";
        }
        if (RadioButton1.Checked)
        {
            isvi = "y";
        }
        else
        {
            isvi = "n";
        }
        string sqltxt = "insert into Vote(title,q1,q2,q3,q4,q5,d1,d2,d3,d4,d5,votoall,isfp,qtv) values ('" + this.title.Text + "','" + this.item1.Text + "','" + this.item2.Text + "','" + this.item3.Text + "','" + this.item4.Text + "','" + this.item5.Text + "',0,0,0,0,0,0,'" + isfp + "','"+isvi+"')";
        if (Doadmin.Exec(sqltxt))
        {
            if (isfp == "y")
            {
                SqlConnection conn = CDatabase.wtoconn();
                conn.Open();
                SqlCommand smd = new SqlCommand("select top 1 id from vote order by id desc", conn);
                int id = Convert.ToInt32(smd.ExecuteScalar());
                Doadmin.Execsql("update vote set isfp='n' where id<>" + id);
                conn.Close();
            }
            Response.Write("<script>alert('添加成功');window.location.href='Votemag.aspx'</script>");

        }
        else
        {
            //Response.Write(sqltxt);
            Response.Write("<script>alert('添加失败');window.location.href='Voteadd.aspx'</script>");
        }
    }
}
