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_updaterkfs : 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 Storagename,Date,State  from tabG_Storage where Storageid = '" + Convert.ToInt32(strnumber) + "'";
            SqlCommand com = new SqlCommand(strSQL, sqlcon);

            sqlcon.Open();

            SqlDataReader dr = com.ExecuteReader();
            while (dr.Read())
            {
                Texname.Text = ConvertHelper.GetString(dr["Storagename"]);
                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_Storage set Storagename='" + strname + "',State ='" + intstate + "'where Storageid ='" + Convert.ToInt32(labid.Text) + "'";
                SqlCommand sqlcmd = new SqlCommand(strsq, sqlcon);

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

                Response.Redirect("Rkfs.aspx");

            }
        }

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