Accessservices.aspx
This is used as a page which consumes the webservice defined in the .asmx field extension.The webmethods defined in the asmx file are exposed to the application.What I am doing is just consuming the methods.
private void
cmdSubmit_Click(object sender, System.EventArgs
e)
{
try
{
//Instantiate the object of webservices class and call the
check status method which takes two parameters ie emailaddress and orderid
given by the system to the customer
ShoppingServices
shopserv = new ShoppingServices();
DataTable tab =
shopserv.CheckStatus(txtEmailAddress.Text,Convert.ToInt32(txtOrderId.Text));
lblPay.Visible
= true;
foreach(DataRow dr in
tab.Rows)
{
sm =dr["modelname"].ToString();// Assign the model name for checking and validation
purposes
}
if(sm==null)
{
lblPay.Text="You
dont have a valid email id or you dont have a valid orderid";
}
else
{
//Gets the total for the orders for personalization
purposes
string s = gettotal(txtOrderId.Text);
if(s=="")
{
lblPay.Text="Not
a valid order id";
dgForServices.Visible
= false;
}
else
{
lblPay.Text
="Grand Total Rs" +
String.Format( "{0:c}",s);
dgForServices.Visible
= true;
dgForServices.DataSource=tab;
// Binds the datatable to the datagrid.
dgForServices.DataBind();
}
}
}
catch(Exception emx)
{
Console.WriteLine(emx.Message);
lblPay.Visible=
true;
lblPay.Text
="No a valid email id";
}
}
public string
gettotal(string getcartidfortotal)
{
string fin="";
SqlConnection
objcon = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
string sql="select finalamount = SUM(unitcost *
quantity)from orderdetails sc where
orderid='"+getcartidfortotal+"'";
SqlCommand
objcom = new SqlCommand(sql,objcon);
objcon.Open();
SqlDataReader
dr =objcom.ExecuteReader();
while(dr.Read())
{
fin
=dr["finalamount"].ToString();
}
return fin;
}