01.
cn =
new
SqlConnection(
"Data Source = sql5026.myasp.net; Initial Catalog = DB_A18CFE_trevorw7; Persist Security Info = True; User ID = DB_A18CFE_trevorw7_admin; Password = rU9g9f5GEQsZ;"
);
02.
cn.Open();
03.
try
04.
{
05.
string
sql =
"insert into tblhourly (Traffic_Est,Traffic_Act,Traffic_Total,Txn_Need,Txn_Act,Txn_Total,CR_Target,CR_Act,hdate,Traffic_Hour,BranchID) values ('"
+ TextBox1.Text +
"','"
+ TextBox2.Text +
"','"
+ Label1.Text +
"','"
+ Label2.Text +
"','"
+ TextBox3.Text +
"','"
+ Label3.Text +
"','"
+ TextBox4.Text +
"','"
+ Label4.Text.Replace(
"%"
,
""
) +
"','"
+ DateTime.Now.ToShortDateString() +
"','10','"
+Session[
"BranchID"
].ToString() +
"')"
;
06.
07.
SqlCommand cm =
new
SqlCommand(sql, cn);
08.
cm.CommandType = CommandType.Text;
09.
cm.CommandText = sql;
10.
cm.ExecuteNonQuery();
11.
}
12.
catch
13.
{
14.
string
sql =
"update tblhourly set Traffic_Est='"
+ TextBox1.Text +
"',Traffic_Act='"
+ TextBox2.Text +
"',Traffic_Total = '"
+ Label1.Text +
"',Txn_Need = '"
+ Label2.Text +
"',Txn_Act = '"
+ TextBox3.Text +
"',Txn_Total ='"
+ Label3.Text +
"' ,CR_Target = '"
+ TextBox4.Text +
"',CR_Act = '"
+ Label4.Text.Replace(
"%"
,
""
) +
"' where hdate = '"
+ DateTime.Now.ToString(
"yyyy-MM-dd"
) +
"' and Traffic_Hour = '10' and BranchID = '"
+Session[
"BranchID"
].ToString()+
"'"
;
15.
16.
SqlCommand cm =
new
SqlCommand(sql, cn);
17.
cm.CommandType = CommandType.Text;
18.
cm.CommandText = sql;
19.
cm.ExecuteNonQuery();
20.
}
21.
cn.close();