using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class goods_updateClassification : System.Web.UI.Page
{
    SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["constring"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            string strnumber;
            int intstate;
            strnumber = Request.QueryString["name"];
            labid.Text = strnumber;
            string strSQL = "select Classificationname,Date,State  from tabG_Classification where Classificationid = '" + Convert.ToInt32(strnumber) + "'";
            SqlCommand com = new SqlCommand(strSQL, sqlcon);

            sqlcon.Open();

            SqlDataReader dr = com.ExecuteReader();
            while (dr.Read())
            {
                Texname.Text = ConvertHelper.GetString(dr["Classificationname"]);
                intstate = ConvertHelper.GetInteger(dr["State"]);

                if (intstate == 0)
                {
                    Radio1.Checked = true;
                }
                else
                {
                    Radio2.Checked = true;
                }
            }
            sqlcon.Close();

        }
    }
    protected void Btnok_Click(object sender, EventArgs e)
    {
        if (CheckBox1.Checked == true)
        {
            if (Texname.Text == "")
            {
                Response.Write("<script>alert('物品名称不能为空！')</script>");
                return;
            }
            else
            {
                string strname;
                int intstate;
                strname = Texname.Text;

                if (Radio1.Checked == true)
                {
                    intstate = 0;
                }
                else
                {
                    intstate = 1;
                }

                string strsq;
                strsq = "update tabG_Classification set Classificationname='" + strname + "',State ='" + intstate + "'where Classificationid ='" + Convert.ToInt32(labid.Text) + "'";
                SqlCommand sqlcmd = new SqlCommand(strsq, sqlcon);

                sqlcon.Open();
                sqlcmd.ExecuteScalar();
                sqlcon.Close();

                Response.Redirect("goodsClassification.aspx");

            }
        }

    }
    protected void btncz_Click(object sender, EventArgs e)
    {
        Response.Redirect("goodsClassification.aspx");
    }
}
