01.
void
Page_Load(
object
sender,EventArgs e)
02.
{
03.
04.
}
05.
06.
void
btnSave_Click(Object sender , EventArgs e)
07.
{
08.
SqlConnection objConn =
new
SqlConnection();
09.
SqlCommand objCmd =
new
SqlCommand();
10.
String strConnString,strSQL;
11.
12.
strConnString =
"Server=WALAILAK-4A0863\\SQLEXPRESS;UID=stock;PASSWORD=1234;database=CEC_StockDB;Max Pool Size=400;Connect Timeout=600;"
;
13.
14.
strSQL =
"INSERT INTO Witdform(WitdID,ProjName,InvenName,WitdQuantity,WitdDate,WitdName,Issuer,Endorsee) "
+
15.
" VALUES "
+
16.
" ('"
+
this
.txtWitdID.Text +
"','"
+
this
.txtProjName.Text +
"','"
+
this
.txtWitdQuantity.Text +
"','"
+
this
.txtWitdDate.Text +
"','"
+
this
.txtWitdName.Text +
"','"
+
this
.txtIssuer.Text +
"','"
+
this
.txtEndorsee.Text +
"')"
;
17.
objConn.ConnectionString = strConnString;
18.
objConn.Open();
19.
objCmd.Connection = objConn;
20.
objCmd.CommandText = strSQL;
21.
objCmd.CommandType = CommandType.Text;
22.
23.
24.
this
.pnlAdd.Visible =
false
;
25.
26.
try
27.
{
28.
objCmd.ExecuteNonQuery();
29.
this
.lblStatus.Text =
"บันทึกข้อมูลสำเร็จ"
;
30.
this
.lblStatus.Visible =
true
;
31.
}
32.
catch
(Exception ex)
33.
{
34.
this
.lblStatus.Visible =
true
;
35.
this
.lblStatus.Text =
"ไม่สามารถบันทึกข้อมูลได้ ("
+ ex.Message +
")"
;
36.
}
37.
38.
objConn.Close();
39.
objConn =
null
;
40.
41.
}