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;

public partial class Updateshow : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Button2.Enabled = false;
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["id"] != null)
            {
                string connectionString = "Data Source=zf;Initial Catalog=SQL_Data;Integrated Security=True";
                DataClassesDataContext db = new DataClassesDataContext(connectionString);
                var result = from r in db.仓库
                             where r.仓库号 == Request.QueryString["id"].ToString()
                             select r;
                TextBox1.Text = result.First().城市.ToString();
                TextBox2.Text = result.First().面积.ToString();
                TextBox3.Text = result.First().创建时间.ToString();
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string connectionString = "Data Source=zf;Initial Catalog=SQL_Data;Integrated Security=True";
        DataClassesDataContext db = new DataClassesDataContext(connectionString);
        var result = from r in db.仓库
                     where r.仓库号 == Request.QueryString["id"].ToString()
                     select r;
        result.First().城市 = TextBox1.Text;
        result.First().面积 = Convert.ToInt32(TextBox2.Text);
        result.First().创建时间 = Convert.ToDateTime(TextBox3.Text);
        db.SubmitChanges();
        Response.Write("<script language=javascript>alert('成功修改了数据库表中一条记录！')</script>");
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
        Button1.Enabled = false;
        Button2.Enabled = true;

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