public void BindShoppingCart() { BPShoppingCartDetails bpDetails = new BPShoppingCartDetails(); if (CustomerID != 0) { BPShoppingCarts bpCart = new BPShoppingCarts(); DSShoppingCarts = bpCart.SelectByCustomerID (CustomerID); DSShoppingCarts.Merge(bpDetails.SelectAllByCustomerID(CustomerID)); } else { DSShoppingCarts = bpDetails.SelectAllByCartID(CartID); } rptProductsList.DataBind (); }
public void Refresh(int customerID, int CartID) { BPShoppingCartDetails bp = new BPShoppingCartDetails(); if (customerID == 0) { lblNumberOfItems.Text = bp.GetCartItemCountByCartID(CartID).ToString(); }else { lblNumberOfItems.Text = bp.GetCartItemCountByCustomerID(customerID).ToString(); } if (lblNumberOfItems.Text == "0") { pnlQuickCart.Visible = false; } else { pnlQuickCart.Visible = true; } }
private void rptProductsList_ItemCommand(object source, RepeaterCommandEventArgs e) { int productID = Convert.ToInt32(((HtmlInputControl)e.Item.FindControl("hdnProductID")).Value); switch(e.CommandName) { case "btnAddToCart": // if (CheckAttributeSelection(e.Item)) DropDownList tmpDropDown = ((DropDownList)e.Item.FindControl("ddlAttributes")); if (tmpDropDown.SelectedValue != "0") { BPShoppingCartDetails bp = new BPShoppingCartDetails(); CartID = bp.FindShoppingCart(CustomerID,CartID); if (!IsNumeric(((TextBox)e.Item.FindControl("txtQuantity")).Text)) { ((TextBox)e.Item.FindControl("txtQuantity")).Text = "0"; } int quantity = Convert.ToInt32(((TextBox)e.Item.FindControl("txtQuantity")).Text); int selectedAttributeID = 0; if (tmpDropDown.SelectedValue != "") { selectedAttributeID = Convert.ToInt32(tmpDropDown.SelectedValue); } // if ((((Label)e.Item.FindControl("lblProductAttributeID")).Text) != "") // selectedAttributeID = Convert.ToInt32(((Label)e.Item.FindControl("lblProductAttributeID")).Text); bp.AddItemToCart(CustomerID,CartID,productID,selectedAttributeID,quantity); QuickCart1.Refresh(CustomerID,CartID); tmpDropDown.SelectedIndex = -1; ((Label)e.Item.FindControl("lblErrMsg")).Text = ""; ((TextBox)e.Item.FindControl("txtQuantity")).Text = "1"; // ((Label)e.Item.FindControl("lblProductAttributeName")).Text = ""; // ((Label)e.Item.FindControl("lblProductAttributeID")).Text = ""; // dgAttributes.SelectedIndex = -1; } else { ((Label)e.Item.FindControl("lblErrMsg")).Text = "Please choose a color first."; } break; case "ChooseAttribute": LoadAttributes(productID); CurrentProductRepeaterIndex = e.Item.ItemIndex; RegisterStartupScript("LoadPopup","<script>window.onLoad = openPopup('attributes_bg');</script>"); break; } }
public decimal GetShippingSurcharge(int cartID) { decimal surcharge = 0; BPShoppingCartDetails bp = new BPShoppingCartDetails(); BEShoppingCarts dsDetails = new BEShoppingCarts(); dsDetails = bp.SelectAllByCartID(cartID); foreach (BEShoppingCarts.tbl_ShoppingCartDetailsRow dr in dsDetails.tbl_ShoppingCartDetails.Rows) { if (!dr.IsProductShippingSurchargeNull()) surcharge += (dr.ProductShippingSurcharge * dr.ShoppingCartDetailQuantity); } return surcharge; }
private void rptProductsList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Remove") { BEShoppingCarts details = new BEShoppingCarts(); BPShoppingCartDetails bp = new BPShoppingCartDetails(); details = bp.SelectAllByCartIDAndProductID(CartID,Convert.ToInt32(((HtmlInputControl)e.Item.FindControl("hdnProductID")).Value)); details.tbl_ShoppingCartDetails.Rows[0].Delete(); bp.Update(details); } BindShoppingCart(); }
private void btnUpdate_Click(object sender, System.EventArgs e) { BEShoppingCarts details = new BEShoppingCarts(); BPShoppingCartDetails bp = new BPShoppingCartDetails(); if (CustomerID == 0) { details = bp.SelectAllByCartID(CartID); }else { details = bp.SelectAllByCustomerID(CustomerID); } int quantity; for (int i=0; i < rptProductsList.Items.Count; i++) { if (!IsNumeric(((TextBox)rptProductsList.Items[i].FindControl("txtShoppingCartDetailQuantity")).Text)) { ((TextBox)rptProductsList.Items[i].FindControl("txtShoppingCartDetailQuantity")).Text = "0"; } quantity = Convert.ToInt32(((TextBox)rptProductsList.Items[i].FindControl("txtShoppingCartDetailQuantity")).Text); if (quantity != details.tbl_ShoppingCartDetails[i].ShoppingCartDetailQuantity) { details.tbl_ShoppingCartDetails[i].ShoppingCartDetailQuantity = quantity; } } bp.Update(details); BindShoppingCart(); }
public void BindShoppingCart() { BPShoppingCartDetails bpDetails = new BPShoppingCartDetails(); if (CustomerID != 0) { int ShippingMethodID, ShippingRegionID; BPShoppingCarts bpCart = new BPShoppingCarts(); DSShoppingCarts = bpCart.SelectByCustomerID (CustomerID); if (DSShoppingCarts.tbl_ShoppingCarts.Count > 0) { ShippingMethodID = DSShoppingCarts.tbl_ShoppingCarts[0].ShippingMethodID; ShippingRegionID = DSShoppingCarts.tbl_ShoppingCarts[0].ShippingRegionID; ShippingCost = GetShippingCost(ShippingMethodID, ShippingRegionID); } DSShoppingCarts.Merge(bpDetails.SelectAllByCustomerID(CustomerID)); } else { DSShoppingCarts = bpDetails.SelectAllByCartID(CartID); } rptProductsList.DataBind (); }