protected void btConfirm0_Click(object sender, EventArgs e) { Session["previous"] = "~/Paycard.aspx"; String user = Session["user"].ToString(); int count = dba.CountNoOfItems(user); Int32 nextmainorderno = dba.CountNoOfAllOrders() + 1; //next main orderno Int32 nextCustomerorderno = dba.CountNoOfOrdersOfaCustomer(Session["user"].ToString().ToLower()) + 1; //next customer order no double sum = 0; for (int i = 0; i < count; i++) { string priceOfaProduct = GridView1.Rows[i].Cells[2].Text; double ApriceOfaProduct = System.Convert.ToDouble(priceOfaProduct); string quantity = GridView1.Rows[i].Cells[3].Text; string pname = GridView1.Rows[i].Cells[1].Text; Int32 Aquantity = System.Convert.ToInt32(quantity); double Aprice = ApriceOfaProduct * Aquantity; dba.AddOrders(Session["user"].ToString().ToLower(), nextmainorderno, nextCustomerorderno, pname, Aquantity, Aprice, "Not Deleivered"); sum = sum + Aprice; } Int32 nextmainreceiptno = dba.CountNoOfAllReceipt() + 1; Int32 nextCustomerreceiptno = dba.CountNoReceiptsOfaCustomer(Session["user"].ToString().ToLower()) + 1; dba.AddReceipt(Session["user"].ToString().ToLower(), nextmainreceiptno, nextCustomerreceiptno, sum, "Card"); dba.ClearCart(Session["user"].ToString()); double percentage = dba.getBonusGivingpercentage("admin"); string total = Session["totalprice"].ToString(); double atotal = System.Convert.ToDouble(total); double givingbonus = atotal * (percentage / 100.0); string bonus = givingbonus.ToString(); lbllabel.Visible = true; lbllabel.Text = "Your Transaction complete." + "You have been awarded with " + bonus + " bonus Points."; btnHome.Visible = true; btConfirm0.Visible = false; txtCreditCno.Visible = false; txtCreditCno0.Visible = false; TextBox1.Visible = false; TextBox2.Visible = false; dba.updateAddBonusPointsOfAuser(Session["user"].ToString(), givingbonus); }
protected void btlogin_Click(object sender, EventArgs e) { bool status = dba.userverification(txtUserName.Text.ToLower(), txtPassword.Text);//error detected bool statusofavtive = dba.verifytheActivationOfUser(txtUserName.Text.ToLower(), txtPassword.Text); uname = txtUserName.Text.ToLower(); if (status && statusofavtive) { Session["user"] = txtUserName.Text; //store username in user session object string checkadmin = Session["user"].ToString().ToLower(); string redirecturl = Session["previous"].ToString(); //store previous page tempory if (checkadmin.Equals("admin")) { Session["previous"] = "~/Login.aspx"; Response.Redirect("~/home.aspx"); } else { Session["previous"] = "~/Login.aspx"; string user = Session["user"].ToString(); dba.ClearCart(user); if (redirecturl.Equals("~/SignUp.aspx")) //New editing { Response.Redirect("~/home.aspx"); // } else // { Response.Redirect(redirecturl); } } } else { if (!status && !statusofavtive) //error detected { lblLoginError.Text = " Invalid User name or Password ! "; } else if (status && !statusofavtive) { //txtUserName.Enabled = false; lblLoginError.Text = " Your account have deactivated !"; lblLabelSendActivate.Visible = true; lblLabelSendActivate0.Visible = true; btnRequestActivate.Visible = true; } } }
protected void btnpoints_Click(object sender, EventArgs e) { Session["previous"] = "~/Payment.aspx"; String user = Session["user"].ToString(); int count = dba.CountNoOfItems(user); Int32 nextmainorderno = dba.CountNoOfAllOrders() + 1; //next main orderno Int32 nextCustomerorderno = dba.CountNoOfOrdersOfaCustomer(Session["user"].ToString().ToLower()) + 1; //next customer order no double sum = 0; for (int i = 0; i < count; i++) { string priceOfaProduct = GridView1.Rows[i].Cells[2].Text; double ApriceOfaProduct = System.Convert.ToDouble(priceOfaProduct); string quantity = GridView1.Rows[i].Cells[3].Text; string pname = GridView1.Rows[i].Cells[1].Text; Int32 Aquantity = System.Convert.ToInt32(quantity); double Aprice = ApriceOfaProduct * Aquantity; dba.AddOrders(Session["user"].ToString().ToLower(), nextmainorderno, nextCustomerorderno, pname, Aquantity, Aprice, "Not Deleivered"); sum = sum + Aprice; } Int32 nextmainreceiptno = dba.CountNoOfAllReceipt() + 1; Int32 nextCustomerreceiptno = dba.CountNoReceiptsOfaCustomer(Session["user"].ToString().ToLower()) + 1; dba.AddReceipt(Session["user"].ToString().ToLower(), nextmainreceiptno, nextCustomerreceiptno, sum, "Bonus Points"); dba.ClearCart(Session["user"].ToString().ToLower()); dba.updateSubstractBonusPointsOfAuser(Session["user"].ToString().ToLower(), atotal); Label2.Visible = true; Label2.Text = "Your Transaction complete. " + Session["totalprice"].ToString() + " bonus Points reducted from your account."; btnHome.Visible = true; btCard.Enabled = false; btnpoints.Enabled = false; lblBpoints.Visible = false; Label1.Visible = false; }