using System;
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 _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Button3.Enabled = false;
    }
    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;
            string myx2 = TextBox2.Text;
            int myx3 = Convert.ToInt32(TextBox3.Text);
            DateTime myx4 = Convert.ToDateTime(TextBox4.Text);
            string sqlinsert = "insert into 仓库(仓库号,城市,面积,创建时间) values ( '" + myx1 + "','" + myx2 + "'," + myx3 + ",'" + myx4 + "')";
            SqlCommand com = new SqlCommand(sqlinsert, con);
            com.ExecuteNonQuery();
            Response.Write("<script language=javascript>alert('成功插入新记录信息！')</script>");
            con.Close();
            Button3.Enabled = true;
        }
        catch
        {
            Response.Write("<script language=javascript>alert('插入新记录信息失败！')</script>");
        }

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
        TextBox4.Text = "";
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("Showdata.aspx");
    }
}
