protected void lstProduct_ItemCommand(object sender, ListViewCommandEventArgs e) { var item = e.Item as ListViewDataItem; var cmd = e.CommandName; var ProductID = (item.FindControl("hdnProductID") as HiddenField).Value; var ProductName = (item.FindControl("lblProductName") as Label).Text; var ProductNameEn = (item.FindControl("lblProductNameEn") as Label).Text; var Description = (item.FindControl("lblDescription") as Label).Text; var ImageName = (item.FindControl("hdnImageName") as HiddenField).Value; var ProductCode = (item.FindControl("hdnProductCode") as HiddenField).Value; var Quantity = "1";//(item.FindControl("inQuantity") as TextBox).Text;//(item.FindControl("hdnQuantitySale") as HiddenField).Value; double Price = Convert.ToDouble((item.FindControl("hdnPrice") as HiddenField).Value); double SavePrice = 0; var oProductSizeColor = new ProductSizeColor(); if (cmd == "AddToCart") { var oShoppingCart = new ShoppingCart(); oShoppingCart.CreateCart(ProductID, ImageName, ProductName, ProductNameEn, ProductCode, "", Price, SavePrice, "", Quantity, Description ); } }
public async Task <int> SaveProductSizeColor(ProductSizeColor obj) { try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@ProductSizeId", obj.ProductSizeId); parameters.Add("@ProductSizeColorId", obj.ProductSizeColorId); parameters.Add("@ProductID", obj.ProductId); //int parameters.Add("@Qty", obj.Qty); //int parameters.Add("@Price", obj.Price); //decimal parameters.Add("@SalePrice", obj.SalePrice); //decimal parameters.Add("@AvailableSize", obj.AvailableSize); //bit parameters.Add("@AvailableColors", obj.AvailableColors); //bit //parameters.Add("@Size", obj.SizeId); //nvarchar commented on 5 aug 2020 parameters.Add("@Size", obj.Size); //nvarchar parameters.Add("@SetNo", obj.SetNo); parameters.Add("@LookupColorId", obj.LookupColorId); //nvarchar parameters.Add("@Discount", obj.Discount); //decimal parameters.Add("@DiscountAvailable", obj.DiscountAvailable); //bit parameters.Add("@CreatedBy", obj.CreatedBy); //int parameters.Add("@Modifiedby", obj.Modifiedby); //int var res = await SqlMapper.ExecuteAsync(con, "p_ProductSizeColor_ins", param : parameters, commandType : StoredProcedure); return(Convert.ToInt32(res)); } catch (Exception ex) { throw (ex); } }
public async Task <int> DeleteProductSizeColor([FromBody] ProductSizeColor obj) { try { var res = await this._IProductBAL.DeleteProductSizeColor(obj); if (res == -2) { if (obj.SetNo > 0) { _utilities.DeleteProductImagePath(obj.ProductId, ("productSetImage/" + obj.SetNo), webRootPath); } else { _utilities.DeleteProductImagePath(obj.ProductId, ("productColorImage/" + obj.ProductSizeColorId), webRootPath); } } return(res); } catch (Exception ex) { Logger.LogError($"Something went wrong inside ProductController DeleteProductSizeColor action: {ex.Message}"); return(-1); } }
public async Task <int> SaveProductSizeColorImages([FromBody] ProductSizeColor obj) { try { if (obj.ProductSizeColorId > 0) { if (obj.SetNo > 0) { _utilities.SaveImage(obj.ProductId, obj.ProductImg, ("productSetImage/" + obj.SetNo), webRootPath); } else { _utilities.SaveImage(obj.ProductId, obj.ProductImg, ("productColorImage/" + obj.ProductSizeColorId), webRootPath); } } return(await Task.Run(() => obj.ProductSizeColorId)); } catch (Exception ex) { ErrorLogger.Log($"Something went wrong inside ProductController SaveProductSizeColor action: {ex.Message}"); ErrorLogger.Log(ex.StackTrace); Logger.LogError($"Something went wrong inside ProductController SaveProductSizeColor action: {ex.Message}"); return(-1); } }
public async Task <int> SaveProductSizeColor([FromBody] ProductSizeColor obj) { try { int ProductSizeColorId = 0; if (obj.ArrayColor != null) { foreach (var itemColor in obj.ArrayColor) { foreach (var itemSize in obj.ArraySize) { obj.Size = itemSize; obj.LookupColorId = itemColor; ProductSizeColorId = await this._IProductBAL.SaveProductSizeColor(obj); } } } else { ProductSizeColorId = await this._IProductBAL.SaveProductSizeColor(obj); } return(ProductSizeColorId); } catch (Exception ex) { Logger.LogError($"Something went wrong inside ProductController SaveProductSizeColor action: {ex.Message}"); return(-1); } }
public async Task <List <ProductSizeColor> > GetProductSizeColorById([FromBody] ProductSizeColor obj) { try { List <ProductSizeColor> lst = this._IProductBAL.GetProductSizeColorById(obj).Result; foreach (var item in lst) { if (item.SetNo > 0) { //item.ProductImg = _utilities.ProductImagePath(item.ProductId, ("productSetImage/" + item.SetNo), webRootPath); item.ProductImg = _utilities.ProductImage(item.ProductId, "productSetImage", webRootPath, item.SetNo); } else { //item.ProductImg = _utilities.ProductImagePath(item.ProductId, ("productColorImage/" + item.ProductSizeColorId), webRootPath); item.ProductImg = _utilities.ProductImage(item.ProductId, "productColorImage", webRootPath, item.ProductSizeColorId); } } return(await Task.Run(() => new List <ProductSizeColor>(lst))); } catch (Exception ex) { Logger.LogError($"Something went wrong inside ProductController GetProductSizeColorById action: {ex.Message}"); return(null); } }
protected void AllSize_Transferred(object sender, RadListBoxTransferredEventArgs e) { var DestinationListBox = e.DestinationListBox; string ProductID; ProductID = Request.QueryString["pi"]; var oProductSizeColor = new ProductSizeColor(); IList <RadListBoxItem> rlbicProductColor = lstChoosedColor.SelectedItems; foreach (RadListBoxItem item in e.Items) { if (DestinationListBox.ID == "lstAllSize") { string ProSizeID; ProSizeID = item.Value.ToString(); //Update ProductFormSize Status var dv = oProductSizeColor.ProductSizeColorSelectOne(ProSizeID).DefaultView; if (dv.Table.Rows.Count > 0) { oProductSizeColor.ProductSizeColorDelete1(ProSizeID, "False"); } } else if (DestinationListBox.ID == "lstChoosedSize") { //Insert ProductFormSize var selectedItem = e.DestinationListBox.FindItemByValue(item.Value); string ProductSizeID = item.Value.ToString(); var dv = oProductSizeColor.ProductSizeColorSelectAll("", ProductSizeID, ProductID, "", "True", "", "").DefaultView; var lblName = (Label)selectedItem.FindControl("lblName"); var txtPriority = (RadNumericTextBox)selectedItem.FindControl("txtPriority"); if (dv.Table.Rows.Count > 0) { if (dv[0]["IsAvailable"].ToString() != "True") { oProductSizeColor.ProductSizeColorDelete1(ProductSizeID, "True"); } if (lblName != null) { lblName.Text = item.Text; } if (dv[0]["Priority"] != DBNull.Value) { txtPriority.Value = Convert.ToInt32(dv[0]["Priority"]); } } else { foreach (RadListBoxItem item1 in rlbicProductColor) { var ProductOptionCategoryID = item1.Value.ToString(); oProductSizeColor.ProductSizeColorInsert(ProductSizeID, ProductOptionCategoryID, ProductID, "True", "True", ""); } } } } DataBindListBoxSize(); }
public async Task <List <ProductSizeColor> > GetProductSizeColorByRowID([FromBody] ProductSizeColor obj) { try { List <ProductSizeColor> lst = this._IProductBAL.GetProductSizeColorByRowID(obj).Result; return(await Task.Run(() => new List <ProductSizeColor>(lst))); } catch (Exception ex) { Logger.LogError($"Something went wrong inside ProductController GetProductBybyRowID action: {ex.Message}"); return(null); } }
public async Task <List <ProductSizeColor> > GetProductSizeColorById(ProductSizeColor obj) { try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@ProductID", obj.ProductId); List <ProductSizeColor> lst = (await SqlMapper.QueryAsync <ProductSizeColor>(con, "p_ProductSizeColor_selByProdcutId", param: parameters, commandType: StoredProcedure)).ToList(); return(lst); } catch (Exception ex) { throw (ex); } }
public async Task <int> DeleteProductSizeColor(ProductSizeColor obj) { try { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@ProductId", obj.ProductId); parameters.Add("@ProductSizeColorId", obj.ProductSizeColorId); parameters.Add("@ProductSizeId", obj.ProductSizeId); parameters.Add("@SetNo", obj.SetNo); var res = await SqlMapper.ExecuteScalarAsync(con, "p_ProductSizeColor_del", param : parameters, commandType : StoredProcedure); return(Convert.ToInt32(res)); } catch (Exception ex) { throw (ex); } }
protected void btnUpdate_Click(object sender, EventArgs e) { string Priority, ProductSizeColorID, IsAvailable, Quantity, QuantitySale; var oProductSizeColor = new ProductSizeColor(); RadListBoxItemCollection choosesizes = lstChoosedSize.Items; foreach (RadListBoxItem item in choosesizes) { ProductSizeColorID = item.Value.ToString(); Priority = ((RadNumericTextBox)item.FindControl("txtPriority")).Text.Trim(); Quantity = ((RadNumericTextBox)item.FindControl("txtQuantity")).Text.Trim(); IsAvailable = ((CheckBox)item.FindControl("chkIsAvailable")).Checked.ToString(); //QuantitySale = "0"; oProductSizeColor.ProductSizeColorQuickUpdate( ProductSizeColorID, "True", IsAvailable, Priority, Quantity //QuantitySale ); } }
public Task <int> DeleteProductSizeColor(ProductSizeColor obj) { return(_IProductRepository.DeleteProductSizeColor(obj)); }
public Task <List <ProductSizeColor> > GetProductSizeColorById(ProductSizeColor obj) { return(_IProductRepository.GetProductSizeColorById(obj)); }
protected void lstProductDetails_ItemCommand(object sender, ListViewCommandEventArgs e) { var item = e.Item as ListViewDataItem; var cmd = e.CommandName; var ProductOptionCategoryID = (item.FindControl("hdnProductOptionCategoryID") as HiddenField).Value; var ProductID = (item.FindControl("hdnProductID") as HiddenField).Value; var ProductName = (item.FindControl("hdnProductName") as HiddenField).Value; var ProductLengthID = ""; //(item.FindControl("hdnProductLengthID") as HiddenField).Value; var ProductLengthName = ""; //(item.FindControl("hdnProductLengthName") as HiddenField).Value; var Quantity = "1"; double Price = Convert.ToDouble((item.FindControl("hdnPrice") as HiddenField).Value); string ProductSizeColorID1 = ""; string ImageColor = ""; string ImageName = ""; string QuantityList = ""; int SizeColorQuantity1 = 0; var oProductSizeColor = new ProductSizeColor(); var oProductOptionCategory = new ProductOptionCategory(); var oProductImage = new ProductImage(); var oShoppingCart = new ShoppingCart(); if (cmd == "AddToCart") { if (ProductID != "") { if (oShoppingCart.HasItem(ProductID) && oShoppingCart.HasColor(ProductOptionCategoryID)) { var dtCart = HttpContext.Current.Session["Cart"] as DataTable; string a = (from DataRow dr in dtCart.Rows where dr["ProductID"].ToString() == ProductID select dr).FirstOrDefault()["Quantity"].ToString(); oShoppingCart.UpdateQuantity(ProductID, ProductLengthID, ProductOptionCategoryID, (Convert.ToInt32(a) + Convert.ToInt32(1)).ToString()); } else { var dv = oProductSizeColor.ProductSizeColorSelectAll(ProductLengthID, ProductOptionCategoryID, ProductID, "True", "True", "", "True").DefaultView; var dv2 = oProductOptionCategory.ProductOptionCategorySelectOne(ProductOptionCategoryID).DefaultView; var dv3 = oProductImage.ProductImageSelectAll(ProductID, "True", "", "True").DefaultView; if (dv.Count != 0 || dv2.Count != 0) { ProductSizeColorID1 = dv[0]["ProductSizeColorID"].ToString(); ImageColor = dv2[0]["ImageName"].ToString(); SizeColorQuantity1 = Convert.ToInt32(dv[0]["Quantity"].ToString()) - Convert.ToInt32(dv[0]["QuantitySale"].ToString()); for (int i = 1; i <= SizeColorQuantity1; i++) { QuantityList = QuantityList + i + ","; } } else { ProductSizeColorID1 = ""; ImageColor = ""; SizeColorQuantity1 = 0; } if (dv3.Count != 0) { ImageName = dv3[0]["ImageName"].ToString(); } else { ImageName = ""; } oShoppingCart.CreateCart(ProductID, ImageName, ImageColor, ProductName, "", "", ProductOptionCategoryID, "", ProductLengthID, ProductLengthName, ProductSizeColorID1, Quantity, SizeColorQuantity1.ToString(), Price, false ); } } //ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "runtime", "myconfirmPopup('" + "<strong>" + ProductName + " - " + ProductCode + " - " + ProductOptionCategoryName + "</strong><br/> đã được thêm vào giỏ hàng" + "')", true); } }
protected void lstProductSame_ItemCommand(object sender, ListViewCommandEventArgs e) { var item = e.Item as ListViewDataItem; var lstPrice = item.FindControl("lstPrice"); var cmd = e.CommandName; var ProductOptionCategoryID = "";//(item.FindControl("hdnProductOptionCategoryID") as HiddenField).Value; var ProductID = (item.FindControl("hdnProductID") as HiddenField).Value; var ProductName = (item.FindControl("hdnProductName") as HiddenField).Value; var ProductCode = (item.FindControl("hdnProductCode") as HiddenField).Value; var ProductLengthID = ""; //(item.FindControl("hdnProductLengthID") as HiddenField).Value; var ProductLengthName = ""; //(item.FindControl("hdnProductLengthName") as HiddenField).Value; var Quantity = "1"; //double Price = Convert.ToDouble((item.FindControl("hdnPrice") as HiddenField).Value); string ProductSizeColorID1 = ""; string QuantityList = ""; int SizeColorQuantity1 = 0; var oProductSizeColor = new ProductSizeColor(); var dropList = item.FindControl("dropListSize") as DropDownList; var oShoppingCart = new ShoppingCart(); if (cmd == "AddToCart") { if (ProductID != "") { if (oShoppingCart.HasItem(ProductID)) { var dtCart = HttpContext.Current.Session["Cart"] as DataTable; string a = (from DataRow dr in dtCart.Rows where dr["ProductID"].ToString() == ProductID select dr).FirstOrDefault()["Quantity"].ToString(); oShoppingCart.UpdateQuantity(ProductID, ProductLengthID, ProductOptionCategoryID, (Convert.ToInt32(a) + Convert.ToInt32(1)).ToString()); } else { if (dropList.SelectedIndex == 0) { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "runtime", " $(document).ready(function () {alert('Vui lòng chọn kích thước !');});", true); } else { var oProductLength = new ProductLength(); var data = oProductLength.ProductLengthSelectOne(dropList.SelectedValue).DefaultView; double Price = Convert.ToDouble(data[0]["Price"].ToString()); ProductLengthName = data[0]["ProductLengthName"].ToString(); var dv = oProductSizeColor.ProductSizeColorSelectAll(ProductLengthID, ProductOptionCategoryID, ProductID, "True", "True", "", "True").DefaultView; ProductSizeColorID1 = ""; SizeColorQuantity1 = 0; //Convert.ToInt32(dv[0]["Quantity"].ToString()) - Convert.ToInt32(dv[0]["QuantitySale"].ToString()); for (int i = 1; i <= SizeColorQuantity1; i++) { QuantityList = QuantityList + i + ","; } oShoppingCart.CreateCart(ProductID, "", "", ProductName, "", ProductCode, ProductOptionCategoryID, "", ProductLengthID, ProductLengthName, ProductSizeColorID1, Quantity, SizeColorQuantity1.ToString(), Price, false ); } } } //ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "runtime", "myconfirmPopup('" + "<strong>" + ProductName + " - " + ProductCode + " - " + ProductOptionCategoryName + "</strong><br/> đã được thêm vào giỏ hàng" + "')", true); } }
public Task <int> SaveProductSizeColor(ProductSizeColor obj) { return(_IProductRepository.SaveProductSizeColor(obj)); }
protected void lstProductDetails_ItemCommand(object sender, ListViewCommandEventArgs e) { var item = e.Item as ListViewDataItem; var cmd = e.CommandName; var ProductOptionCategoryID = ""; //(item.FindControl("hdnProductOptionCategoryID") as HiddenField).Value; var ProductOptionCategoryName = ""; //(item.FindControl("hdnProductOptionCategoryName") as HiddenField).Value; var ProductID = (item.FindControl("hdnProductID") as HiddenField).Value; var ProductName = (item.FindControl("lblProductName") as Label).Text; var ProductNameEn = ""; //(item.FindControl("lblProductNameEn") as Label).Text; var ImageName = (item.FindControl("hdnImageName") as HiddenField).Value; var ProductCode = ""; //(item.FindControl("hdnProductCode") as HiddenField).Value; var ProductLengthID = ""; //(item.FindControl("hdnProductLengthID") as HiddenField).Value; var ProductLengthName = ""; //(item.FindControl("hdnProductLengthName") as HiddenField).Value; var Quantity = "1"; double Price = Convert.ToDouble((item.FindControl("hdnPrice") as HiddenField).Value); string ProductSizeColorID1 = ""; string QuantityList = ""; int SizeColorQuantity1 = 0; var oProductSizeColor = new ProductSizeColor(); var oShoppingCart = new ShoppingCart(); if (cmd == "AddToCart") { //try //{ // if (ProductID != "") // { // if (oShoppingCart.CartSelectOne(ProductID).DefaultView.Count > 0) // { // //var dv = oProductSizeColor.ProductSizeColorSelectAll(ProductLengthID, ProductOptionCategoryID, ProductID, "True", // // "True", "", "True").DefaultView; // //ProductSizeColorID1 = dv[0]["ProductSizeColorID"].ToString(); // //SizeColorQuantity1 = Convert.ToInt32(dv[0]["Quantity"].ToString()) - Convert.ToInt32(dv[0]["QuantitySale"].ToString()); // //for (int i = 1; i <= SizeColorQuantity1; i++) // //{ // // QuantityList = QuantityList + i + ","; // //} // var dv = oShoppingCart.CartSelectOne(ProductID).DefaultView; // int iQuantityAdd = Convert.ToInt32(dv[0]["Quantity"].ToString()) + 1; // oShoppingCart.UpdateQuantity(ProductID, ProductLengthID, ProductOptionCategoryID, // iQuantityAdd.ToString()); // } // else // { // oShoppingCart.CreateCart(ProductID, // ImageName, // ProductName, // ProductNameEn, // ProductCode, // ProductOptionCategoryID, // ProductOptionCategoryName, // ProductLengthID, // ProductLengthName, // ProductSizeColorID1, // Quantity, // SizeColorQuantity1.ToString(), // Price, // false // ); // } // } //} //catch (Exception ex) //{ //} oShoppingCart.CreateCart(ProductID, ImageName, ProductName, ProductNameEn, ProductCode, ProductOptionCategoryID, ProductOptionCategoryName, ProductLengthID, ProductLengthName, ProductSizeColorID1, Quantity, SizeColorQuantity1.ToString(), Price, false ); //ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "runtime", "myconfirmPopup('" + "<strong>" + ProductName + " - " + ProductCode + " - " + ProductOptionCategoryName + "</strong><br/> đã được thêm vào giỏ hàng" + "')", true); Response.Redirect("thong-tin-dat-hang.aspx"); } }