protected void Page_Load(object sender, EventArgs e) { if (Request.IsSecureConnection) { // Page only accessible by admin if (Session["LoginStatus"].Equals("Admin")) { if (!IsPostBack) { lsvPostage.DataSource = BLShipping.getShippingTable(); lsvPostage.DataBind(); } } else { Response.Redirect("~/UL/ErrorPage/5"); } } else { // Make connection secure if it isn't already string url = ConfigurationManager.AppSettings["SecurePath"] + "AdminPostageOptions"; Response.Redirect(url); } }
protected void cbxActive_CheckedChanged(object sender, EventArgs e) { ListViewItem item = (sender as CheckBox).NamingContainer as ListViewItem; int index = Convert.ToInt32((item.FindControl("lblShipID") as Label).Text); BLShipping.toggleActive(index); lsvPostage.DataSource = BLShipping.getShippingTable(); lsvPostage.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { // Check for secure connection if (Request.IsSecureConnection) { // Page only available to logged in user if (Session["LoginStatus"].Equals("User")) { // Check if items are still in the cart - otherwise; wrong state BLShoppingCart cart = Session["Cart"] as BLShoppingCart; if (!cart.isEmpty()) { if (!IsPostBack) { double amount = Convert.ToDouble((Session["Cart"] as BLShoppingCart).Amount); lblAmount.Text = string.Format("{0:C}", amount); ddlShipping.DataSource = BLShipping.getShippingMethods(); ddlShipping.DataBind(); BLUser user = Session["CurrentUser"] as BLUser; lblFirst.Text = user.userFirstName; lblLast.Text = user.userLastName; lblBillStreet.Text = user.billAddress.addStreet; lblBillSuburb.Text = user.billAddress.addSuburb; lblBillState.Text = user.billAddress.addState; lblBillZip.Text = user.billAddress.addZip.ToString(); lblPostStreet.Text = user.postAddress.addStreet; lblPostSuburb.Text = user.postAddress.addSuburb; lblPostState.Text = user.postAddress.addState; lblPostZip.Text = user.postAddress.addZip.ToString(); } } else { Response.Redirect("~/UL/ErrorPage/7"); } } else { Response.Redirect("~/UL/ErrorPage/0"); } } else { // Make connection secure if it isn't already string url = ConfigurationManager.AppSettings["SecurePath"] + "Payment"; Response.Redirect(url); } }
protected void Page_Load(object sender, EventArgs e) { // Check for secure connection if (Request.IsSecureConnection) { // Page only accessible to a logged in user if (Session["LoginStatus"].Equals("User")) { // Check if items are still in the cart - otherwise; wrong state BLShoppingCart cart = Session["Cart"] as BLShoppingCart; if (!cart.isEmpty()) { // Send confirmation of order to account email address BLShipping shipping = Session["Shipping"] as BLShipping; string mailbody = BLPurchase.generateOrderSummary(Session["Name"].ToString(), cart, shipping); try { BLEmail.SendEmail(Session["UserName"].ToString(), "Order Receipt - JerseySure", mailbody); } catch (Exception ex) { Response.Redirect("~/UL/ErrorPage/1"); } // Remove cart from session Session.Remove("Cart"); Session["Cart"] = new BLShoppingCart(); } else { Response.Redirect("~/UL/ErrorPage/7"); } } else { Response.Redirect("~/UL/ErrorPage/0"); } } else { // Make connection secure if it isn't already string url = ConfigurationManager.AppSettings["SecurePath"] + "PaymentConfirmation"; Response.Redirect(url); } }
protected void ddlShipping_SelectedIndexChanged(object sender, EventArgs e) { BLShipping shipping = new BLShipping(); double amount; if (ddlShipping.SelectedValue != "") { shipping = shipping.getShipping(Convert.ToInt32(ddlShipping.SelectedValue)); Session["Shipping"] = shipping; amount = Convert.ToDouble((Session["Cart"] as BLShoppingCart).Amount) + shipping.Cost; } else { amount = Convert.ToDouble((Session["Cart"] as BLShoppingCart).Amount); } lblAmount.Text = string.Format("{0:C}", amount); }
// Adds postage option to currently available options protected void btnSubmit_Click(object sender, EventArgs e) { if (IsValid) { //postageList.Add(tbxMethodName.Text + ", " + tbxDescription.Text + ", " + tbxAvgTime.Text + ", " + "$" + tbxPrice.Text); BLShipping shipping = new BLShipping { Method = tbxMethodName.Text, Description = tbxDescription.Text, Cost = Convert.ToDouble(tbxPrice.Text), Wait = Convert.ToInt32(tbxAvgTime.Text) }; BLShipping.addShipping(shipping); // Redirect to updated postage options Response.Redirect("~/UL/AdminPostageOptions"); } }
/// <summary> /// Inserts a new postage option /// </summary> /// <param name="option"></param> /// <returns></returns> public int addPostageOption(BLShipping option) { string cs = ConfigurationManager.ConnectionStrings["JerseySure"].ConnectionString; int rows; using (SqlConnection connection = new SqlConnection(cs)) { SqlCommand command = new SqlCommand("usp_addShipping", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@type", option.Method); command.Parameters.AddWithValue("@description", option.Description); command.Parameters.AddWithValue("@days", option.Wait); command.Parameters.AddWithValue("@cost", option.Cost); connection.Open(); rows = command.ExecuteNonQuery(); } return(rows); }