📄 ordersform.aspx.cs
字号:
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// dsCustomers1
//
this.dsCustomers1.DataSetName = "dsCustomers";
this.dsCustomers1.Locale = new System.Globalization.CultureInfo("en-US");
this.dsCustomers1.Namespace = "http://www.tempuri.org/dsCustomers.xsd";
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.dsCustomers1)).EndInit();
}
#endregion
private void btnOrder_Click(object sender, System.EventArgs e)
{
DTService.Service1 srv = new DTService.Service1();
string strDate, strStatus, strOrderBy;
strDate = Convert.ToString(DateTime.Today);
strStatus="Pending";
strOrderBy="Bookers Paradise";
string result;
result = srv.AcceptDetails(txtISBN.Text,
strDate,
txtName.Text,
txtAddr1.Text,
txtAddr2.Text,
txtCity.Text,
txtState.Text,
strOrderBy,
strStatus,
lstCardType.SelectedItem.Text,
txtCardNumber.Text );
string orderno;
orderno = srv.GenerateOrder();
if (result == "Record Inserted!!")
{
string custid;
custid = InsertBookersDB(orderno);
TextBox1.Text = "Dear " + txtName.Text + "!! \n" +
"Thanks for visiting Bookers Paradise. \n" +
"Your Customer ID is " + custid + ".\n" +
"Your order (Number " + orderno + ") will be shipped by " + DateTime.Today.AddDays(15).Date + ".";
}
else
{
TextBox1.Text = "Dear " + txtName.Text + "!! \n" +
"Thanks for visiting Bookers Paradise \n" +
"Your request could not be processed due to some internal error. \n"+
"Please visit later.";
}
}
public string InsertBookersDB(string order)
{
//Code To Generate Customer ID
string SelStr;
SelStr = "Select Count(*) From BookerCustDetails";
SqlCommand SelCom;
SelCom = new SqlCommand(SelStr, sqlConnection1);
sqlConnection1.Open();
sqlDataAdapter1.SelectCommand = SelCom;
sqlDataAdapter1.Fill(dsCustomers1,"Customer");
sqlConnection1.Close();
string str;
str = dsCustomers1.Tables["Customer"].Rows[0][0].ToString ();
int val;
val = Convert.ToInt32(str);
val= val+1;
if(val>0 & val<=9)
{
str = "C000" + Convert.ToString(val);
}
else if(val>9 & val<=99)
{
str ="C00" + Convert.ToString (val);
}
else if(val>99 & val <=999)
{
str = "C0" + Convert.ToString (val);
}
else
{
str = "C" + Convert.ToString (val);
}
//Store customer details
string InsStr;
InsStr = "Insert Into BookerCustDetails Values(@CID, @CN, @BA1, @BA2, @BC, @BS)";
SqlCommand InsCom;
InsCom = new SqlCommand(InsStr, sqlConnection1);
sqlDataAdapter1.InsertCommand = InsCom;
sqlDataAdapter1.InsertCommand.Parameters.Add("@CID", SqlDbType.Char,6).Value = str;
sqlDataAdapter1.InsertCommand.Parameters.Add("@CN", SqlDbType.VarChar,50).Value = txtName.Text;
sqlDataAdapter1.InsertCommand.Parameters.Add("@BA1", SqlDbType.VarChar ,50).Value= txtAddr1.Text ;
sqlDataAdapter1.InsertCommand.Parameters.Add("@BA2", SqlDbType.VarChar,50).Value= txtAddr2.Text ;
sqlDataAdapter1.InsertCommand.Parameters.Add("@BC",SqlDbType.VarChar,20).Value = txtCity.Text ;
sqlDataAdapter1.InsertCommand.Parameters.Add("@BS", SqlDbType.VarChar ,10).Value = txtState.Text ;
if(sqlConnection1.State== ConnectionState.Closed )
{
sqlConnection1.Open ();
}
sqlDataAdapter1.InsertCommand.ExecuteNonQuery();
sqlConnection1.Close();
//Store Order Details
string InsStr1;
InsStr1 = "Insert Into BookersOrders Values(@ON, @CID, @ISBN)";
SqlCommand InsCom1;
InsCom1 = new SqlCommand(InsStr1, sqlConnection1);
sqlDataAdapter1.InsertCommand = InsCom1;
sqlDataAdapter1.InsertCommand.Parameters.Add("@ON", SqlDbType.Char,10).Value = order;
sqlDataAdapter1.InsertCommand.Parameters.Add("@CID", SqlDbType.Char,6).Value = str;
sqlDataAdapter1.InsertCommand.Parameters.Add("@ISBN", SqlDbType.Char,10).Value = txtISBN.Text;
if(sqlConnection1.State== ConnectionState.Closed )
{
sqlConnection1.Open ();
}
sqlDataAdapter1.InsertCommand.ExecuteNonQuery();
sqlConnection1.Close();
return str;
}
private void btnClear_Click(object sender, System.EventArgs e)
{
txtISBN.Text="";
txtTitle.Text ="";
txtAuthor.Text ="";
txtName.Text="";
txtAddr1.Text="";
txtAddr2.Text="";
txtCity.Text="";
txtState.Text="";
TextBox1.Text ="";
txtCardNumber.Text ="";
lstCardType.SelectedIndex =0;
}
private void btnHome_Click(object sender, System.EventArgs e)
{
Response.Redirect ("Mainform.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -