using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Data.SqlClient;
public partial class Updateshow : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["id"] != null)
            {
                SqlConnection con = new SqlConnection("server=(local);user id=myzf;pwd=123456;database=SQL_Data");
                con.Open();
                SqlDataAdapter ada = new SqlDataAdapter("select * from 仓库 where 仓库号 = '" + Request.QueryString["id"] + "'", con);
                DataSet ds = new DataSet();
                ada.Fill(ds, "仓库");
                DataRowView drv = ds.Tables["仓库"].DefaultView[0];
                TextBox1.Text = drv["城市"].ToString();
                TextBox2.Text = drv["面积"].ToString();
                TextBox3.Text = drv["创建时间"].ToString();
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
           try 
           {
            string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";
            SqlConnection con = new SqlConnection(ConStr);
            con.Open();
            string myx1 = TextBox1.Text;
            int myx2 = Convert.ToInt32(TextBox2.Text);
            DateTime myx3 = Convert.ToDateTime(TextBox3.Text);
            string  sqlupdate = " update 仓库 set 城市 = '" + myx1 + "', 面积 = " + myx2 + " , 创建时间 = '" + myx3 + "' where 仓库号 = '"  + Request.QueryString["id"] + "'" ;
            SqlCommand com = new SqlCommand(sqlupdate , con);
            com.ExecuteNonQuery();
            con.Close();
            Response.Write("<script language=javascript>alert('成功修改数据库表中的一条数据记录！')</script>");
        }
        catch
        {
            Response.Write("<script language=javascript>alert('修改数据库表中的数据记录失败！')</script>");
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect ("Default.aspx");
    }
}
