protected void Page_Load(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { decimal cartTotal = 0; cartTotal = usersShoppingCart.GetTotal(); if (cartTotal > 0) { // Display total lblTotal.Text = String.Format("{0:c}", cartTotal); } else { LabelTotalText.Text = ""; lblTotal.Text = ""; ShoppingCartTitle.InnerText = "Shopping Cart is Empty"; UpdateBtn.Visible = false; } } }
public List<CartItem> UpdateCartItems( ) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { String cartId = usersShoppingCart.GetCartId(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i =0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowValues = new OrderedDictionary(); rowValues = GetValues(CartList.Rows[i] ); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"] ); CheckBox cbRemove = new CheckBox(); cbRemove = (CheckBox) CartList.Rows[i].FindControl( "Remove" ); cartUpdates[i].RemoveItem = cbRemove.Checked; TextBox quantityTextBox = new TextBox(); quantityTextBox =(TextBox) CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity =Convert.ToInt16(quantityTextBox.Text.ToString()); } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartList.DataBind(); lblTotal.Text =String.Format("{0:c}", usersShoppingCart.GetTotal()); return usersShoppingCart.GetCartItems(); } }
public List <Models.CartItem> UpdateCartItems() { using (Logic.ShoppingCartActions usersShoppingCart = new Logic.ShoppingCartActions()) { string cartId = usersShoppingCart.GetCartId(); Logic.ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new Logic.ShoppingCartActions.ShoppingCartUpdates[CartGrid.Rows.Count]; for (int i = 0; i < CartGrid.Rows.Count; i++) { //IOrderedDictionary rowValues = new OrderedDictionary(); IOrderedDictionary rowValues = GetValues(CartGrid.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); //CheckBox cbRemove = new CheckBox(); CheckBox cbRemove = (CheckBox)CartGrid.Rows[i].FindControl("Remove"); cartUpdates[i].RemoveItem = cbRemove.Checked; //TextBox quantityTextBox = new TextBox(); TextBox quantityTextBox = (TextBox)CartGrid.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString()); } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); CartGrid.DataBind(); lblTotal.Text = string.Format("{0:c}", usersShoppingCart.GetTotal()); return(usersShoppingCart.GetCartItems()); } }
protected void CheckoutBtn_Click(object sender, ImageClickEventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["payment amt"] = usersShoppingCart.GetTotal(); } Response.Redirect( "Checkout/CheckoutStart.aspx" ); }
protected void Page_Load(object sender, EventArgs e) { using (Logic.ShoppingCartActions usersShoopingCart = new Logic.ShoppingCartActions()) { decimal cartTotal = usersShoopingCart.GetTotal(); if (cartTotal > 0) { lblTotal.Text = string.Format("{0:c}", cartTotal); } else { LabelTotalText.Text = ""; lblTotal.Text = ""; ShoppingCartTitle.InnerText = "Shopping Cart is Empty"; UpdateBtn.Visible = false; } } }
public List<CartItem> UpdateCartItems() { using (ShoppingCartActions sca = new ShoppingCartActions()) { String cartID = sca.GetCartID(); ShoppingCartActions.ShoppingCartUpdates[] cartUpdts = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count]; for (int i = 0; i < CartList.Rows.Count; i++) { IOrderedDictionary rowVals = new OrderedDictionary(); rowVals = GetValues(CartList.Rows[i]); cartUpdts[i].ProductID = Convert.ToInt32(rowVals["ProductID"]); CheckBox cbRemv = (CheckBox)CartList.Rows[i].FindControl("Remove"); cartUpdts[i].RemoveItem = cbRemv.Checked; TextBox txtQty = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdts[i].PurchaseQty = Convert.ToInt32(txtQty.Text); } sca.UpdateShoppingCartDatabase(cartID, cartUpdts); CartList.DataBind(); lblTotal.Text = String.Format("{0:c}", sca.GetTotal()); return sca.GetCartItems(); } }
protected void Page_Load(object sender, EventArgs e) { using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { decimal cartTotal = 0; cartTotal = usersShoppingCart.GetTotal(); if (cartTotal > 0) { // Display Total. lblTotal.Text = String.Format("{0:c}", cartTotal); } else { LabelTotalText.Text = ""; lblTotal.Text = ""; ShoppingCartTitle.InnerText = "Корзина пуста"; UpdateBtn.Visible = false; CheckoutBtn.Visible = false; ResultAndADate.Visible = false; } } { int day = DateTime.Now.Day; int month = DateTime.Now.Month; int indexDate = DropDownListDate.SelectedIndex; DropDownListDate.Items.Clear(); for (int i = 0; i < 7; ++i) { DropDownListDate.Items.Add((day + i) + " / " + month); } DropDownListDate.SelectedIndex = indexDate; int indexTime = DropDownListTime.SelectedIndex; DropDownListTime.Items.Clear(); for (int i = 0; i < 6; ++i) { DropDownListTime.Items.Add("c " + (4 * i) + " по " + (4 * i + 4)); } DropDownListTime.SelectedIndex = indexTime; } }
protected void CheckoutBtn_Click(object sender, EventArgs e) { Good[] itemIDAndCount = null; using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions()) { Session["payment_amt"] = usersShoppingCart.GetTotal(); List<CartItem> items = usersShoppingCart.GetCartItems(); int count = items.Count; itemIDAndCount = new Good[count]; for (int i = 0; i < count; ++i) { itemIDAndCount[i].ItemID = items[i].ProductId; itemIDAndCount[i].Count = items[i].Quantity; } } int indexDate = DropDownListDate.SelectedIndex; int indexTime = DropDownListTime.SelectedIndex; DateTime now = DateTime.Now; DateTime time = new DateTime(now.Year, now.Month, now.Day + indexDate, 4 * indexTime, 0, 0); bool allRight = false; try { createRequest(itemIDAndCount, time); allRight = true; //Response.Redirect("http://localhost:24019/Checkout/CheckoutReview.aspx"); } catch (ExceptionSupplierSystemOff) { LabelError.Text = "Поставщики не отвечают."; LabelError.Visible = true; } catch (ExceptionSupplierSystemNotGood) { LabelError.Text = "Запрос не может быть удовлетворён."; LabelError.Visible = true; } catch (ExceptionSupplierSystemConfirmFail) { LabelError.Text = "Проблема связи с поставщиками."; LabelError.Visible = true; } catch (ExceptionDeliveryServiceOff) { LabelError.Text = "Службы доставки не отвечают."; LabelError.Visible = true; } catch (ExceptionDeliveryServiceWrongTime) { LabelError.Text = "Запрос на доставку не может быть удовлетворён."; LabelError.Visible = true; } catch (ExceptionDeliveryServiceConfirmFail) { LabelError.Text = "Проблема связи со службой доставки."; LabelError.Visible = true; } catch (Exception exception) { Console.WriteLine("Exception: {0}", exception); Response.Redirect("http://localhost:24019/Checkout/CheckoutCancel.aspx"); } // //Response.Redirect("Checkout/CheckoutStart.aspx"); if (allRight) { Response.Redirect("Checkout/CheckoutInformation.aspx"); } }