public static int getCategory(string SKU, int ProductType) { int categoryID = 0; if (ProductType == 1) { var product = ProductController.GetBySKU(SKU); if (product != null) { categoryID = Convert.ToInt32(product.CategoryID); } } else { var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { var product1 = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID)); if (product1 != null) { categoryID = Convert.ToInt32(product1.CategoryID); } } } return(categoryID); }
public void GetStockVariable(string username, string password) { if (Login(username, password)) { var StockManager = StockManagerController.GetStockAll(); if (StockManager.Count > 0) { var dataToExportToCSV = StockManager.Select(x => { var quantityCurrent = 0D; if (x.Type == 1) { quantityCurrent = x.QuantityCurrent.Value + x.Quantity.Value; } else { quantityCurrent = x.QuantityCurrent.Value - x.Quantity.Value; } return(new StockManager() { SKU = x.SKU, Quantity = quantityCurrent, }); }).ToList(); string attachment = String.Format("attachment; filename={0}_stock-variable.csv", DateTime.Now.ToString("yyyyMMddHHmmss")); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.AddHeader("content-disposition", attachment); HttpContext.Current.Response.ContentType = "text/csv"; HttpContext.Current.Response.AddHeader("Pragma", "public"); HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8; var sb = new StringBuilder(); sb.AppendLine("parent_sku, sku, stock, stock_status, manage_stock"); foreach (var line in dataToExportToCSV) { var parentProduct = ProductVariableController.GetBySKU(line.SKU); string parentSKU = ""; if (parentProduct != null) { parentSKU = parentProduct.ParentSKU; sb.AppendLine(String.Format("{0}, {1}, {2}, {3}, {4}", parentSKU, line.SKU, line.Quantity, line.Quantity > 0 ? "instock" : "outofstock", "yes")); } } HttpContext.Current.Response.Write(sb.ToString()); } } }
public void printItemList(ref int ID, ref double TotalQuantity, ref double TotalOrder, ref string Print) { var orderdetails = RefundGoodDetailController.GetByRefundGoodsID(ID); if (orderdetails.Count > 0) { foreach (var item in orderdetails) { TotalQuantity += Convert.ToDouble(item.Quantity); int ProductType = Convert.ToInt32(item.ProductType); double ItemPrice = Convert.ToDouble(item.SoldPricePerProduct); string SKU = item.SKU; string ProductName = ""; int SubTotal = (Convert.ToInt32(ItemPrice) - Convert.ToInt32(item.RefundFeePerProduct)) * Convert.ToInt32(item.Quantity); Print += "<tr>"; if (ProductType == 1) { var product = ProductController.GetBySKU(SKU); if (product != null) { ProductName = product.ProductTitle; Print += "<td colspan='4'><strong>" + SKU + "</strong> - " + PJUtils.Truncate(ProductName, 27) + "</td>"; } } else { var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { var parent_product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID)); if (parent_product != null) { ProductName = parent_product.ProductTitle; } Print += "<td colspan='4'><strong>" + SKU + "</strong> - " + PJUtils.Truncate(ProductName, 27) + "</td>"; } } Print += "</tr>"; Print += "<tr>"; Print += "<td>" + item.Quantity + "</td>"; Print += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>"; Print += "<td>" + string.Format("{0:N0}", Convert.ToDouble(item.RefundFeePerProduct)) + "</td>"; Print += "<td>" + string.Format("{0:N0}", SubTotal) + "</td>"; Print += "</tr>"; TotalOrder += SubTotal; } } }
protected void btnSave_Click(object sender, EventArgs e) { DateTime currentDate = DateTime.Now; int AgentID = 0; string username = Request.Cookies["usernameLoginSystem"].Value; if (!string.IsNullOrEmpty(username)) { var a = AccountController.GetByUsername(username); if (a != null) { AgentID = Convert.ToInt32(a.AgentID); string phone = hdfPhone.Value; if (!string.IsNullOrEmpty(phone)) { var cust = CustomerController.GetByPhone(phone); if (cust != null) { #region Tạo đơn hàng đổi tra int custID = cust.ID; string totalprice = hdfTotalPrice.Value; string totalquantity = hdfTotalQuantity.Value; string totalrefund = hdfTotalRefund.Value; var agent = AgentController.GetByID(AgentID); string agentName = ""; if (agent != null) { agentName = agent.AgentName; } //insert ddlstatus, refundnote int status = ddlRefundStatus.SelectedValue.ToInt(); string RefundsNote = txtRefundsNote.Text; int rID = RefundGoodController.Insert(AgentID, totalprice, status, custID, Convert.ToInt32(totalquantity), totalrefund, agentName, cust.CustomerName, cust.CustomerPhone, currentDate, username, RefundsNote); #endregion if (rID > 0) { string listString = hdfListProduct.Value; string[] items = listString.Split('|'); if (items.Length - 1 > 0) { for (int i = 0; i < items.Length - 1; i++) { #region Tạo chi tiết đơn hàng đổi tra string[] element = items[i].Split(';'); var sku = element[0]; var orderID = element[1].ToInt(0); var orderDetailID = element[2]; var ProductName = element[3]; var GiavonPerProduct = Convert.ToDouble(element[5]); var SoldPricePerProduct = Convert.ToDouble(element[6]); var DiscountPricePerProduct = Convert.ToDouble(element[7]); var quantity = Convert.ToDouble(element[10]); var quantityMax = Convert.ToDouble(element[8]); var ProductType = element[4].ToInt(1); var RefundType = element[9].ToInt(1); var RefundFeePerProduct = Convert.ToDouble(element[11]); var TotalPriceRow = element[12]; var PriceNotFeeRefund = SoldPricePerProduct * quantity; var rdTotalRefundFee = RefundFeePerProduct * quantity; int rdID = RefundGoodDetailController.Insert(rID, AgentID, orderID, ProductName, custID, sku, quantity, quantityMax, PriceNotFeeRefund.ToString(), ProductType, true, RefundType, RefundFeePerProduct.ToString(), rdTotalRefundFee.ToString(), GiavonPerProduct.ToString(), DiscountPricePerProduct.ToString(), SoldPricePerProduct.ToString(), TotalPriceRow, currentDate, username); #endregion #region Cập nhật stock if (rdID > 0) { if (RefundType < 3) { int typeRe = 0; string note = ""; if (RefundType == 1) { note = "Đổi size"; typeRe = 8; } else if (RefundType == 2) { note = "Đổi sản phẩm"; typeRe = 9; } if (ProductType == 1) { var product = ProductController.GetBySKU(sku); if (product != null) { int productID = product.ID; string ProductImageOrigin = ""; var ProductImage = ProductImageController.GetFirstByProductID(product.ID); if (ProductImage != null) { ProductImageOrigin = ProductImage.ProductImage; } StockManagerController.Insert( new tbl_StockManager { AgentID = AgentID, ProductID = productID, ProductVariableID = 0, Quantity = quantity, QuantityCurrent = 0, Type = 1, NoteID = note, OrderID = orderID, Status = typeRe, SKU = sku, CreatedDate = currentDate, CreatedBy = username, MoveProID = 0, ParentID = productID, }); } } else { string ProductVariableName = ""; string ProductVariableValue = ""; string ProductVariable = ""; int parentID = 0; string parentSKU = ""; string ProductImageOrigin = ""; int ID = 0; var productvariable = ProductVariableController.GetBySKU(sku); if (productvariable != null) { ID = productvariable.ID; ProductImageOrigin = productvariable.Image; parentSKU = productvariable.ParentSKU; var variables = ProductVariableValueController.GetByProductVariableID(productvariable.ID); if (variables.Count > 0) { foreach (var v in variables) { ProductVariable += v.VariableName.Trim() + ":" + v.VariableValue.Trim() + "|"; ProductVariableName += v.VariableName + "|"; ProductVariableValue += v.VariableValue + "|"; } } } if (!string.IsNullOrEmpty(parentSKU)) { var product = ProductController.GetBySKU(parentSKU); if (product != null) { parentID = product.ID; } } StockManagerController.Insert( new tbl_StockManager { AgentID = AgentID, ProductID = 0, ProductVariableID = ID, Quantity = quantity, QuantityCurrent = 0, Type = 1, NoteID = note, OrderID = orderID, Status = typeRe, SKU = sku, CreatedDate = currentDate, CreatedBy = username, MoveProID = 0, ParentID = parentID, }); } } } #endregion } RefundGoodController.updateQuantityCOGS(rID); PJUtils.ShowMessageBoxSwAlertCallFunction("Tạo đơn hàng đổi trả thành công", "s", true, "redirectTo(" + rID + ")", Page); } } } } } } }
public void printItemList(ref int ID, ref double TotalQuantity, ref double TotalOrder, ref string Print) { var orderdetails = OrderDetailController.GetByOrderID(ID); if (orderdetails.Count > 0) { int t = 0; int print = 1; foreach (var item in orderdetails) { TotalQuantity += Convert.ToDouble(item.Quantity); int ProductType = Convert.ToInt32(item.ProductType); double ItemPrice = Convert.ToDouble(item.Price); string SKU = item.SKU; string ProductName = ""; string ProductImage = "/App_Themes/Ann/image/placeholder.png"; int SubTotal = Convert.ToInt32(ItemPrice) * Convert.ToInt32(item.Quantity); t++; Print += "<tr>"; Print += "<td>" + t + "</td>"; if (ProductType == 1) { var product = ProductController.GetBySKU(SKU); if (product != null) { ProductName = product.ProductTitle; if (!string.IsNullOrEmpty(product.ProductImage)) { ProductImage = product.ProductImage; } Print += "<td><image src=\"" + ProductImage + "\" /></td> "; Print += "<td><strong>" + SKU + "</strong> - " + PJUtils.Truncate(ProductName, 30) + "</td> "; } } else { var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { var parent_product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID)); if (parent_product != null) { ProductName = parent_product.ProductTitle; if (string.IsNullOrEmpty(productvariable.Image)) { ProductImage = parent_product.ProductImage; } else { ProductImage = productvariable.Image; } } Print += "<td><image src=\"" + ProductImage + "\" /></td>"; Print += "<td><p><strong>" + SKU + "</strong> - " + PJUtils.Truncate(ProductName, 30) + "</p><p class=\"variable\">" + item.ProductVariableDescrition.Replace("|", ". ") + "</p></td> "; } } Print += "<td>" + item.Quantity + "</td>"; Print += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>"; Print += "<td>" + string.Format("{0:N0}", SubTotal) + "</td>"; Print += "</tr>"; TotalOrder += SubTotal; if (t % 10 == 0) { if (t == print * 10) { continue; } Print += "</tbody>"; Print += "</table>"; Print += "</div>"; Print += "</div>"; Print += "</div>"; Print += "</div>"; Print += "<div class=\"print-order-image\">"; Print += "<div class=\"all print print-" + print + "\">"; Print += "<div class=\"body\">"; Print += "<div class=\"table-2\">"; Print += "<table>"; Print += "<colgroup>"; Print += "<col class=\"order-item\" />"; Print += "<col class=\"image\" />"; Print += "<col class=\"name\" />"; Print += "<col class=\"quantity\" />"; Print += "<col class=\"price\" />"; Print += "<col class=\"subtotal\"/>"; Print += "</colgroup>"; Print += "<thead>"; Print += "<th>#</th>"; Print += "<th>Hình ảnh</th>"; Print += "<th>Sản phẩm</th>"; Print += "<th>SL</th>"; Print += "<th>Giá</th>"; Print += "<th>Tổng</th>"; Print += "</thead>"; Print += "<tbody>"; print++; } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { DateTime currentDate = DateTime.Now; string username = Request.Cookies["userLoginSystem"].Value; bool check = true; string SKU = txtProductSKU.Text.Trim().ToUpper(); var productcheck = ProductController.GetBySKU(SKU); if (productcheck != null) { check = false; } else { var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { check = false; } } if (check == false) { PJUtils.ShowMessageBoxSwAlert("Trùng mã sản phẩm vui lòng kiểm tra lại", "e", false, Page); } else { int parentID = ViewState["productid"].ToString().ToInt(0); var parentProduct = ProductController.GetByID(parentID); bool isHidden = false; double Stock = 0; double Regular_Price = Convert.ToDouble(pRegular_Price.Text); double CostOfGood = Convert.ToDouble(pCostOfGood.Text); double RetailPrice = Convert.ToDouble(pRetailPrice.Text); int StockStatus = 1; bool ManageStock = true; //Phần thêm ảnh đại diện sản phẩm string path = "/uploads/images/"; string ProductImage = ""; if (ProductThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in ProductThumbnailImage.UploadedFiles) { var o = path + parentID.ToString() + '-' + convertToSlug(Path.GetFileName(f.FileName)); try { f.SaveAs(Server.MapPath(o)); ProductImage = o; } catch { } } } ProductVariableController.Insert(parentProduct.ID, parentProduct.ProductSKU, SKU, Stock, StockStatus, Regular_Price, CostOfGood, RetailPrice, ProductImage, ManageStock, isHidden, currentDate, username, Convert.ToInt32(parentProduct.SupplierID), parentProduct.SupplierName, Convert.ToDouble(pMinimumInventoryLevel.Text), Convert.ToDouble(pMaximumInventoryLevel.Text)); PJUtils.ShowMessageBoxSwAlert("Thêm biến thể sản phẩm thành công", "s", true, Page); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); DateTime currentDate = DateTime.Now; if (acc != null) { if (acc.RoleID == 0 || acc.RoleID == 1 || acc.Username == "nhom_zalo502") { int cateID = hdfParentID.Value.ToInt(); if (cateID > 0) { string ProductSKU = txtProductSKU.Text.Trim().ToUpper(); var check = true; var productcheck = ProductController.GetBySKU(ProductSKU); if (productcheck != null) { check = false; } else { var productvariable = ProductVariableController.GetBySKU(ProductSKU); if (productvariable != null) { check = false; } } if (check == false) { PJUtils.ShowMessageBoxSwAlert("Mã sản phẩm đã tồn tại, hãy kiểm tra lại", "e", false, Page); } else { string ProductTitle = Regex.Replace(txtProductTitle.Text.Trim(), @"\s*\,\s*|\s*\;\s*", " - "); string ProductContent = pContent.Content.ToString(); double ProductStock = 0; int StockStatus = 3; double Regular_Price = Convert.ToDouble(pRegular_Price.Text); double CostOfGood = Convert.ToDouble(pCostOfGood.Text); double Retail_Price = Convert.ToDouble(pRetailPrice.Text); int supplierID = ddlSupplier.SelectedValue.ToInt(0); string supplierName = ddlSupplier.SelectedItem.ToString(); string mainColor = ddlColor.SelectedValue.Trim(); int a = 1; var preOrder = ddlPreOrder.SelectedValue == "1" ? true : false; double Old_Price = String.IsNullOrEmpty(pOld_Price.Text) ? 0 : Convert.ToDouble(pOld_Price.Text); double MinimumInventoryLevel = pMinimumInventoryLevel.Text.ToInt(0); double MaximumInventoryLevel = pMaximumInventoryLevel.Text.ToInt(0); if (hdfsetStyle.Value == "2") { MinimumInventoryLevel = 0; MaximumInventoryLevel = 0; a = hdfsetStyle.Value.ToInt(); } int ShowHomePage = ddlShowHomePage.SelectedValue.ToInt(0); var prodNew = new tbl_Product() { CategoryID = cateID, ProductOldID = 0, ProductTitle = ProductTitle, ProductContent = ProductContent, ProductSKU = ProductSKU, ProductStock = ProductStock, StockStatus = StockStatus, ManageStock = true, Regular_Price = Regular_Price, CostOfGood = CostOfGood, Retail_Price = Retail_Price, ProductImage = String.Empty, ProductType = a, IsHidden = false, CreatedDate = currentDate, CreatedBy = username, SupplierID = supplierID, SupplierName = supplierName, Materials = txtMaterials.Text, MinimumInventoryLevel = MinimumInventoryLevel, MaximumInventoryLevel = MaximumInventoryLevel, ProductStyle = a, ShowHomePage = ShowHomePage, Color = mainColor, PreOrder = preOrder, Old_Price = Old_Price }; string kq = ProductController.Insert(prodNew); prodNew.ID = Convert.ToInt32(kq); if (!String.IsNullOrEmpty(hdfTags.Value)) { var tagList = JsonConvert.DeserializeObject <List <TagModel> >(hdfTags.Value); if (tagList.Count > 0) { // Get tag new var tagNew = TagController.insert(tagList, acc); var productTag = tagList .GroupJoin( tagNew, t => t.name.ToLower(), n => n.Name.ToLower(), (t, n) => new { t, n } ) .SelectMany( x => x.n.DefaultIfEmpty(), (parent, child) => new ProductTag { TagID = child != null ? child.ID : parent.t.id, ProductID = prodNew.ID, ProductVariableID = 0, SKU = prodNew.ProductSKU, CreatedBy = acc.ID, CreatedDate = currentDate } ) .ToList(); ProductTagController.insert(productTag); } } //Phần thêm ảnh đại diện sản phẩm string path = "/uploads/images/"; string ProductImage = ""; if (ProductThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in ProductThumbnailImage.UploadedFiles) { var o = path + kq + '-' + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true); if (!File.Exists(Server.MapPath(o))) { f.SaveAs(Server.MapPath(o)); // Thumbnail Thumbnail.create(Server.MapPath(o), 85, 113); Thumbnail.create(Server.MapPath(o), 159, 212); Thumbnail.create(Server.MapPath(o), 240, 320); Thumbnail.create(Server.MapPath(o), 350, 467); Thumbnail.create(Server.MapPath(o), 600, 0); } ProductImage = Path.GetFileName(Server.MapPath(o)); } } string updateImage = ProductController.UpdateImage(kq.ToInt(), ProductImage); //Phần thêm ảnh đại diện sản phẩm sạch không có đóng dấu string ProductImageClean = ""; if (ProductThumbnailImageClean.UploadedFiles.Count > 0) { foreach (UploadedFile f in ProductThumbnailImageClean.UploadedFiles) { var o = path + kq + "-clean-" + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true); if (!File.Exists(Server.MapPath(o))) { f.SaveAs(Server.MapPath(o)); // Thumbnail Thumbnail.create(Server.MapPath(o), 85, 113); Thumbnail.create(Server.MapPath(o), 159, 212); Thumbnail.create(Server.MapPath(o), 240, 320); Thumbnail.create(Server.MapPath(o), 350, 467); Thumbnail.create(Server.MapPath(o), 600, 0); } ProductImageClean = Path.GetFileName(Server.MapPath(o)); } } string updateImageClean = ProductController.UpdateImageClean(kq.ToInt(), ProductImageClean); //Phần thêm thư viện ảnh sản phẩm string IMG = ""; if (hinhDaiDien.UploadedFiles.Count > 0) { foreach (UploadedFile f in hinhDaiDien.UploadedFiles) { var o = path + kq + '-' + Slug.ConvertToSlug(Path.GetFileName(f.FileName), isFile: true); if (!File.Exists(Server.MapPath(o))) { f.SaveAs(Server.MapPath(o)); // Thumbnail Thumbnail.create(Server.MapPath(o), 85, 113); Thumbnail.create(Server.MapPath(o), 159, 212); Thumbnail.create(Server.MapPath(o), 240, 320); Thumbnail.create(Server.MapPath(o), 350, 467); Thumbnail.create(Server.MapPath(o), 600, 0); } IMG = Path.GetFileName(Server.MapPath(o)); ProductImageController.Insert(kq.ToInt(), IMG, false, currentDate, username); } } if (kq.ToInt(0) > 0) { int ProductID = kq.ToInt(0); string variable = hdfVariableListInsert.Value; if (!string.IsNullOrEmpty(variable)) { string[] items = variable.Split(','); for (int i = 0; i < items.Length - 1; i++) { string item = items[i]; string[] itemElement = item.Split(';'); string datanameid = itemElement[0]; string[] datavalueid = itemElement[1].Split('|'); string datanametext = itemElement[2]; string datavaluetext = itemElement[3]; string productvariablesku = itemElement[4].Trim().ToUpper(); string regularprice = itemElement[5]; string costofgood = itemElement[6]; string retailprice = itemElement[7]; string[] datanamevalue = itemElement[8].Split('|'); string imageUpload = itemElement[4]; int _MaximumInventoryLevel = itemElement[9].ToInt(0); int _MinimumInventoryLevel = itemElement[10].ToInt(0); int stockstatus = itemElement[11].ToInt(); HttpPostedFile postedFile = Request.Files["" + imageUpload + ""]; string image = ""; if (postedFile != null && postedFile.ContentLength > 0) { var o = path + kq + '-' + Slug.ConvertToSlug(Path.GetFileName(postedFile.FileName), isFile: true); if (!File.Exists(Server.MapPath(o))) { postedFile.SaveAs(Server.MapPath(o)); // Thumbnail Thumbnail.create(Server.MapPath(o), 85, 113); Thumbnail.create(Server.MapPath(o), 159, 212); Thumbnail.create(Server.MapPath(o), 240, 320); Thumbnail.create(Server.MapPath(o), 350, 467); Thumbnail.create(Server.MapPath(o), 600, 0); } image = Path.GetFileName(Server.MapPath(o)); } string kq1 = ProductVariableController.Insert(ProductID, ProductSKU, productvariablesku, 0, stockstatus, Convert.ToDouble(regularprice), Convert.ToDouble(costofgood), Convert.ToDouble(retailprice), image, true, false, currentDate, username, supplierID, supplierName, _MinimumInventoryLevel, _MaximumInventoryLevel); string color = ""; string size = ""; int ProductVariableID = 0; if (kq1.ToInt(0) > 0) { ProductVariableID = kq1.ToInt(0); color = datavalueid[0]; size = datavalueid[1]; string[] Data = datanametext.Split('|'); string[] DataValue = datavaluetext.Split('|'); for (int k = 0; k < Data.Length - 2; k++) { int variablevalueID = datavalueid[k].ToInt(); string variableName = Data[k]; string variableValueName = DataValue[k]; ProductVariableValueController.Insert(ProductVariableID, productvariablesku, variablevalueID, variableName, variableValueName, false, currentDate, username); } } ProductVariableController.UpdateColorSize(ProductVariableID, color, size); } } PJUtils.ShowMessageBoxSwAlertCallFunction("Tạo sản phẩm thành công", "s", true, "redirectTo(" + kq + ")", Page); } } } } } }
public void printItemList(ref int ID, ref double TotalQuantity, ref double TotalOrder, ref string Print, ref double TotalFee) { var orderdetails = RefundGoodDetailController.GetByRefundGoodsID(ID); if (orderdetails.Count > 0) { int t = 0; int print = 1; foreach (var item in orderdetails) { TotalQuantity += Convert.ToDouble(item.Quantity); int ProductType = Convert.ToInt32(item.ProductType); double ItemPrice = Convert.ToDouble(item.GiavonPerProduct); double SoldPrice = Convert.ToDouble(item.SoldPricePerProduct); double RefundFee = Convert.ToDouble(item.RefundFeePerProduct); string SKU = item.SKU; string ProductName = ""; string ProductImage = "/App_Themes/Ann/image/placeholder.png"; int SubTotal = (Convert.ToInt32(SoldPrice) - Convert.ToInt32(item.RefundFeePerProduct)) * Convert.ToInt32(item.Quantity); t++; Print += "<tr>"; Print += "<td>" + t + "</td>"; if (ProductType == 1) { var product = ProductController.GetBySKU(SKU); if (product != null) { ProductName = product.ProductTitle; if (!string.IsNullOrEmpty(product.ProductImage)) { ProductImage = product.ProductImage; } Print += "<td><image src=\"" + ProductImage + "\" /></td> "; Print += "<td><strong>" + SKU + "</strong> - " + ProductName + "</td> "; } } else { var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { var parent_product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID)); if (parent_product != null) { ProductName = parent_product.ProductTitle; if (string.IsNullOrEmpty(productvariable.Image)) { ProductImage = parent_product.ProductImage; } else { ProductImage = productvariable.Image; } } Print += "<td><image src=\"" + ProductImage + "\" /></td>"; Print += "<td><p><strong>" + SKU + "</strong> - " + ProductName + "</p></td> "; } } Print += "<td>" + item.Quantity + "</td>"; Print += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>"; Print += "<td>" + string.Format("{0:N0}", SoldPrice) + "</td>"; Print += "<td>" + string.Format("{0:N0}", RefundFee) + "</td>"; Print += "<td>" + string.Format("{0:N0}", SubTotal) + "</td>"; Print += "</tr>"; TotalFee += Convert.ToInt32(item.RefundFeePerProduct) * Convert.ToInt32(item.Quantity); TotalOrder += SubTotal; if (t % 10 == 0) { if (t == print * 10) { continue; } Print += "</tbody>"; Print += "</table>"; Print += "</div>"; Print += "</div>"; Print += "</div>"; Print += "</div>"; Print += "<div class=\"print-order-image\">"; Print += "<div class=\"all print print-" + print + "\">"; Print += "<div class=\"body\">"; Print += "<div class=\"table-2\">"; Print += "<table>"; Print += "<colgroup>"; Print += "<col class=\"order-item\" />"; Print += "<col class=\"image\" />"; Print += "<col class=\"name\" />"; Print += "<col class=\"quantity\" />"; Print += "<col class=\"price\" />"; Print += "<col class=\"sold-price\" />"; Print += "<col class=\"fee\" />"; Print += "<col class=\"subtotal\"/>"; Print += "</colgroup>"; Print += "<thead>"; Print += "<th>#</th>"; Print += "<th>Hình ảnh</th>"; Print += "<th>Sản phẩm</th>"; Print += "<th>SL</th>"; Print += "<th>Giá niêm yết</th>"; Print += "<th>Giá đã bán</th>"; Print += "<th>Phí đổi hàng</th>"; Print += "<th>Tổng</th>"; Print += "</thead>"; Print += "<tbody>"; print++; } } } }
public void printItemList(ref int ID, ref int mergeprint, ref double TotalQuantity, ref double TotalOrder, ref string Print) { var orderdetails = OrderDetailController.GetByOrderID(ID); if (orderdetails.Count > 0) { if (mergeprint == 0) { int t = 0; int print = 1; foreach (var item in orderdetails) { TotalQuantity += Convert.ToDouble(item.Quantity); int ProductType = Convert.ToInt32(item.ProductType); double ItemPrice = Convert.ToDouble(item.Price); string SKU = item.SKU; string ProductName = ""; string ProductImage = ""; int SubTotal = Convert.ToInt32(ItemPrice) * Convert.ToInt32(item.Quantity); t++; Print += "<tr>"; Print += "<td id='" + SKU + "'>" + t + "</td>"; if (ProductType == 1) { var product = ProductController.GetBySKU(SKU); if (product != null) { ProductName = product.ProductTitle; if (!string.IsNullOrEmpty(product.ProductImage)) { ProductImage = product.ProductImage; } Print += "<td><image src='" + Thumbnail.getURL(ProductImage, Thumbnail.Size.Large) + "' /></td> "; Print += "<td><strong>" + SKU + "</strong> - " + (product.Old_Price > 0 ? "<span class='sale-icon'>SALE</span> " : "") + PJUtils.Truncate(ProductName, 30) + "</td> "; } } else { var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { var parent_product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID)); if (parent_product != null) { ProductName = parent_product.ProductTitle; if (string.IsNullOrEmpty(productvariable.Image)) { ProductImage = parent_product.ProductImage; } else { ProductImage = productvariable.Image; } } Print += "<td id='" + parent_product.ProductSKU + "'><image src='" + Thumbnail.getURL(ProductImage, Thumbnail.Size.Large) + "' /></td>"; Print += "<td><p><strong>" + SKU + "</strong> - " + (parent_product.Old_Price > 0 ? "<span class='sale-icon'>SALE</span> " : "") + PJUtils.Truncate(ProductName, 30) + "</p><p class='variable'>" + item.ProductVariableDescrition.Replace("|", ". ") + "</p></td> "; } } Print += "<td>" + item.Quantity + "</td>"; Print += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>"; Print += "<td>" + string.Format("{0:N0}", SubTotal) + "</td>"; Print += "</tr>"; TotalOrder += SubTotal; if (t % 10 == 0) { if (t == print * 10) { continue; } Print += "</tbody>"; Print += "</table>"; Print += "</div>"; Print += "</div>"; Print += "</div>"; Print += "</div>"; Print += "<div class='print-order-image'>"; Print += "<div class='all print print-" + print + "'>"; Print += "<div class='body'>"; Print += "<div class='table-2'>"; Print += "<table>"; Print += "<colgroup>"; Print += "<col class='order-item' />"; Print += "<col class='image' />"; Print += "<col class='name' />"; Print += "<col class='quantity' />"; Print += "<col class='price' />"; Print += "<col class='subtotal' />"; Print += "</colgroup>"; Print += "<thead>"; Print += "<th>#</th>"; Print += "<th>Hình ảnh</th>"; Print += "<th>Sản phẩm</th>"; Print += "<th>SL</th>"; Print += "<th>Giá</th>"; Print += "<th>Tổng</th>"; Print += "</thead>"; Print += "<tbody>"; print++; } } } else { int t = 0; int print = 1; for (int i = 0; i < orderdetails.Count; i++) { if (orderdetails[i] != null) { t++; Print += "<tr>"; Print += "<td>" + t + "</td>"; double ItemPrice1 = Convert.ToDouble(orderdetails[i].Price); int categoryID1 = getCategory(orderdetails[i].SKU, Convert.ToInt32(orderdetails[i].ProductType)); int quantity = Convert.ToInt32(orderdetails[i].Quantity); for (int j = i + 1; j < orderdetails.Count; j++) { if (orderdetails[j] != null) { int categoryID2 = getCategory(orderdetails[j].SKU, Convert.ToInt32(orderdetails[j].ProductType)); double ItemPrice2 = Convert.ToDouble(orderdetails[j].Price); if (categoryID1 == categoryID2 && orderdetails[i].Price == orderdetails[j].Price) { quantity += Convert.ToInt32(orderdetails[j].Quantity); orderdetails[j] = null; } } } var category = CategoryController.GetByID(categoryID1); double SubTotal = ItemPrice1 * quantity; Print += "<td>" + category.CategoryName + " " + string.Format("{0:N0}", ItemPrice1) + "</td>"; Print += "<td>" + quantity + "</td>"; Print += "<td>" + string.Format("{0:N0}", ItemPrice1) + "</td>"; Print += "<td>" + string.Format("{0:N0}", SubTotal) + "</td>"; Print += "</tr>"; TotalOrder += SubTotal; TotalQuantity += quantity; } if (t % 20 == 0) { if (t == print * 20) { continue; } Print += "</tbody>"; Print += "</table>"; Print += "</div>"; Print += "</div>"; Print += "</div>"; Print += "</div>"; Print += "<div class=\"print-order-image\">"; Print += "<div class=\"all print print-" + print + "\">"; Print += "<div class=\"body\">"; Print += "<div class=\"table-2\">"; Print += "<table>"; Print += "<colgroup>"; Print += "<col class=\"order-item\" />"; Print += "<col class=\"name\" />"; Print += "<col class=\"quantity\" />"; Print += "<col class=\"price\" />"; Print += "<col class=\"subtotal\"/>"; Print += "</colgroup>"; Print += "<thead>"; Print += "<th>#</th>"; Print += "<th>Hình ảnh</th>"; Print += "<th>Sản phẩm</th>"; Print += "<th>SL</th>"; Print += "<th>Giá</th>"; Print += "<th>Tổng</th>"; Print += "</thead>"; Print += "<tbody>"; print++; } } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); int cateID = ViewState["cateID"].ToString().ToInt(0); int ProductID = ViewState["ID"].ToString().ToInt(0); if (cateID > 0) { string ProductTitle = txtProductTitle.Text; string ProductContent = pContent.Content; string ProductSKU = ViewState["SKU"].ToString(); double ProductStock = 0; int StockStatus = 0; bool ManageStock = true; double Regular_Price = Convert.ToDouble(pRegular_Price.Text); double CostOfGood = Convert.ToDouble(pCostOfGood.Text); double Retail_Price = Convert.ToDouble(pRetailPrice.Text); bool IsHidden = chkIsHidden.Checked; int CategoryID = hdfParentID.Value.ToInt(); double MinimumInventoryLevel = 0; if (pMinimumInventoryLevel.Text != "") { MinimumInventoryLevel = Convert.ToDouble(pMinimumInventoryLevel.Text); } double MaximumInventoryLevel = 0; if (pMaximumInventoryLevel.Text != "") { MaximumInventoryLevel = Convert.ToDouble(pMaximumInventoryLevel.Text); } //Phần thêm ảnh đại diện sản phẩm string path = "/uploads/images/"; string ProductImage = ListProductThumbnail.Value; if (ProductThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in ProductThumbnailImage.UploadedFiles) { var o = path + ProductID + '-' + convertToSlug(Path.GetFileName(f.FileName)); try { f.SaveAs(Server.MapPath(o)); ProductImage = o; } catch { } } } if (ProductImage != ListProductThumbnail.Value) { if (File.Exists(Server.MapPath(ListProductThumbnail.Value))) { File.Delete(Server.MapPath(ListProductThumbnail.Value)); } } // Delete Image Gallery string deleteImageGallery = hdfDeleteImageGallery.Value; if (deleteImageGallery != "") { string[] deletelist = deleteImageGallery.Split(','); for (int i = 0; i < deletelist.Length - 1; i++) { var img = ProductImageController.GetByID(Convert.ToInt32(deletelist[i])); if (img != null) { var product = ProductController.GetByID(ProductID); // Delete image if (!string.IsNullOrEmpty(img.ProductImage) && img.ProductImage != product.ProductImage) { string fileImage = Server.MapPath(img.ProductImage); File.Delete(fileImage); } string delete = ProductImageController.Delete(img.ID); } } } // Update product string kq = ProductController.Update(ProductID, CategoryID, 0, ProductTitle, ProductContent, ProductSKU, ProductStock, StockStatus, ManageStock, Regular_Price, CostOfGood, Retail_Price, ProductImage, 0, IsHidden, DateTime.Now, username, ddlSupplier.SelectedValue.ToInt(0), ddlSupplier.SelectedItem.ToString(), txtMaterials.Text, MinimumInventoryLevel, MaximumInventoryLevel); // Upload image gallery if (UploadImages.HasFiles) { foreach (HttpPostedFile uploadedFile in UploadImages.PostedFiles) { var o = path + ProductID + '-' + convertToSlug(Path.GetFileName(uploadedFile.FileName)); uploadedFile.SaveAs(Server.MapPath(o)); ProductImageController.Insert(ProductID, o, false, DateTime.Now, username); } } if (kq.ToInt(0) > 0) { // Update Variable if (hdfsetStyle.Value == "2") { string variable = hdfVariableListInsert.Value; if (!string.IsNullOrEmpty(variable)) { string[] items = variable.Split(','); for (int i = 0; i < items.Length - 1; i++) { string item = items[i]; string[] itemElement = item.Split(';'); string datanameid = itemElement[0]; string[] datavalueid = itemElement[1].Split('|'); string datanametext = itemElement[2]; string datavaluetext = itemElement[3]; string productvariablesku = itemElement[4].Trim().ToUpper(); string regularprice = itemElement[5]; string costofgood = itemElement[6]; string retailprice = itemElement[7]; string[] datanamevalue = itemElement[8].Split('|'); string imageUpload = itemElement[8]; int _MaximumInventoryLevel = itemElement[9].ToInt(0); int _MinimumInventoryLevel = itemElement[10].ToInt(0); int stockstatus = itemElement[11].ToInt(); string imageSrc = itemElement[13]; string kq1 = ""; // Check variable var Variable = ProductVariableController.GetBySKU(productvariablesku); if (Variable != null) { // Update image string image = Variable.Image; if (imageSrc == "/App_Themes/Ann/image/placeholder.png") { // Delete old image if (!string.IsNullOrEmpty(Variable.Image)) { string fileImage = Server.MapPath(Variable.Image); File.Delete(fileImage); image = ""; } } else { if (imageSrc != Variable.Image) { HttpPostedFile postedFile = Request.Files["" + imageUpload + ""]; if (postedFile != null && postedFile.ContentLength > 0) { // Upload image var o = path + ProductID + '-' + convertToSlug(Path.GetFileName(postedFile.FileName)); postedFile.SaveAs(Server.MapPath(o)); image = o; // Delete old image if (!string.IsNullOrEmpty(Variable.Image)) { string fileImage = Server.MapPath(Variable.Image); File.Delete(fileImage); } } else { // Delete old image if (!string.IsNullOrEmpty(Variable.Image)) { string fileImage = Server.MapPath(Variable.Image); File.Delete(fileImage); image = ""; } } } } // Update variable kq1 = ProductVariableController.Update(Variable.ID, ProductID, Variable.ParentSKU, productvariablesku, Convert.ToDouble(Variable.Stock), Convert.ToInt32(Variable.StockStatus), Convert.ToDouble(regularprice), Convert.ToDouble(costofgood), Convert.ToDouble(retailprice), image, true, false, DateTime.Now, username, Convert.ToInt32(Variable.SupplierID), Variable.SupplierName, _MinimumInventoryLevel, _MaximumInventoryLevel); // Delete all productVariableValue bool deleteVariableValue = ProductVariableValueController.DeleteByProductVariableID(Variable.ID); } else { string image = ""; HttpPostedFile postedFile = Request.Files["" + imageUpload + ""]; if (postedFile != null && postedFile.ContentLength > 0) { // Upload image var o = path + ProductID + '-' + convertToSlug(Path.GetFileName(postedFile.FileName)); postedFile.SaveAs(Server.MapPath(o)); image = o; } // Insert new variable kq1 = ProductVariableController.Insert(ProductID, ProductSKU, productvariablesku, 0, stockstatus, Convert.ToDouble(regularprice), Convert.ToDouble(costofgood), Convert.ToDouble(retailprice), image, true, false, DateTime.Now, username, ddlSupplier.SelectedValue.ToInt(0), ddlSupplier.SelectedItem.ToString(), _MinimumInventoryLevel, _MaximumInventoryLevel); } // Update ProductVariableValue if (kq1.ToInt(0) > 0) { string[] Data = datanametext.Split('|'); string[] DataValue = datavaluetext.Split('|'); for (int k = 0; k < Data.Length - 1; k++) { int variablevalueID = datavalueid[k].ToInt(); string variableName = Data[k]; string variableValueName = DataValue[k]; ProductVariableValueController.Insert(kq1.ToInt(), productvariablesku, variablevalueID, variableName, variableValueName, false, DateTime.Now, username); } } } } } PJUtils.ShowMessageBoxSwAlert("Cập nhật sản phẩm thành công", "s", true, Page); } } }
public void printItemList(ref int ID, ref int mergeprint, ref double TotalQuantity, ref double TotalOrder, ref string Print) { var orderdetails = OrderDetailController.GetByIDSortBySKU(ID); if (orderdetails.Count > 0) { if (mergeprint == 0) { int t = 0; foreach (var item in orderdetails) { TotalQuantity += Convert.ToDouble(item.Quantity); int ProductType = Convert.ToInt32(item.ProductType); double ItemPrice = Convert.ToDouble(item.Price); string SKU = item.SKU; string ProductName = ""; int SubTotal = Convert.ToInt32(ItemPrice) * Convert.ToInt32(item.Quantity); t++; Print += "<tr>"; Print += "<td>" + t + "</td>"; if (ProductType == 1) { var product = ProductController.GetBySKU(SKU); if (product != null) { ProductName = product.ProductTitle; Print += "<td><strong>" + SKU + "</strong> - " + PJUtils.Truncate(ProductName, 20) + "</td> "; } } else { var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { var parent_product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID)); if (parent_product != null) { ProductName = parent_product.ProductTitle; } Print += "<td><strong>" + SKU + "</strong> - " + PJUtils.Truncate(ProductName, 20) + " - " + item.ProductVariableDescrition.Replace("|", ". ") + "</td> "; } } Print += "<td>" + item.Quantity + "</td>"; Print += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>"; Print += "<td>" + string.Format("{0:N0}", SubTotal) + "</td>"; Print += "</tr>"; TotalOrder += SubTotal; } } else { int t = 0; for (int i = 0; i < orderdetails.Count; i++) { if (orderdetails[i] != null) { t++; Print += "<tr>"; Print += "<td>" + t + "</td>"; double ItemPrice1 = Convert.ToDouble(orderdetails[i].Price); int categoryID1 = getCategory(orderdetails[i].SKU, Convert.ToInt32(orderdetails[i].ProductType)); int quantity = Convert.ToInt32(orderdetails[i].Quantity); for (int j = i + 1; j < orderdetails.Count; j++) { if (orderdetails[j] != null) { int categoryID2 = getCategory(orderdetails[j].SKU, Convert.ToInt32(orderdetails[j].ProductType)); double ItemPrice2 = Convert.ToDouble(orderdetails[j].Price); if (categoryID1 == categoryID2 && orderdetails[i].Price == orderdetails[j].Price) { quantity += Convert.ToInt32(orderdetails[j].Quantity); orderdetails[j] = null; } } } var category = CategoryController.GetByID(categoryID1); double SubTotal = ItemPrice1 * quantity; Print += "<td>" + category.CategoryName + " " + string.Format("{0:N0}", ItemPrice1) + "</td>"; Print += "<td>" + quantity + "</td>"; Print += "<td>" + string.Format("{0:N0}", ItemPrice1) + "</td>"; Print += "<td>" + string.Format("{0:N0}", SubTotal) + "</td>"; Print += "</tr>"; TotalOrder += SubTotal; TotalQuantity += quantity; } } } } }
protected void btnOrder_Click(object sender, EventArgs e) { string barcodeValue = ""; string productPrint = ""; string barcodeImage = ""; string[] list = hdfListProduct.Value.Split(';'); if (list.Count() > 0) { var temps = new List <String>(); productPrint += "<div class='qcode {0}'>"; int[] categoryIDs = new int[] { 44 }; bool isCol4 = true; for (int i = 0; i < list.Length - 1; i++) { string[] list2 = list[i].Split(','); int quantity = list2[2].ToInt(); for (int j = 0; j < quantity; j++) { var variable = ProductVariableController.GetBySKU(list2[1]); if (variable != null) { var product = ProductController.GetByID(variable.ProductID.Value); isCol4 = categoryIDs.Contains(product.CategoryID.Value); } else { var product = ProductController.GetBySKU(list2[1]); isCol4 = categoryIDs.Contains(product.CategoryID.Value); } barcodeValue = list2[1]; var imageName = String.Format("{0}{1}.png", DateTime.UtcNow.ToString("yyyyMMddHHmmss"), Guid.NewGuid()); barcodeImage = "/uploads/barcodes/" + imageName; System.Drawing.Image barCode = PJUtils.MakeBarcodeImage(barcodeValue, 2, true); barCode.Save(HttpContext.Current.Server.MapPath("" + barcodeImage + ""), ImageFormat.Png); productPrint += "<div class='item'>"; productPrint += "<div class='img'><img src='data:image/png;base64, " + Convert.ToBase64String(File.ReadAllBytes(Server.MapPath("" + barcodeImage + ""))) + "'></div>"; productPrint += "<div><h1>" + barcodeValue + "</h1></div>"; productPrint += "</div>"; temps.Add(imageName); } } productPrint += "</div>"; productPrint = String.Format(productPrint, isCol4 ? "col-4" : ""); string html = ""; html += productPrint; ltrprint.Text = html; // Delete barcode image after print string[] filePaths = Directory.GetFiles(Server.MapPath("/uploads/barcodes/")); foreach (string filePath in filePaths) { foreach (var item in temps) { if (filePath.EndsWith(item)) { File.Delete(filePath); } } } ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "$(function () { printBarcode() });", true); } }
public void LoadData() { int ID = Request.QueryString["id"].ToInt(0); if (ID > 0) { string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { int agentIDReceive = Convert.ToInt32(acc.AgentID); var mp = MoveProController.GetByIDAndAgentIDReceive(ID, agentIDReceive); if (mp != null) { ViewState["ID"] = ID; int agentIDSend = Convert.ToInt32(mp.AgentIDSend); string agentSendname = ""; string agentReceivename = ""; var agentSend = AgentController.GetByID(agentIDSend); if (agentSend != null) { agentSendname = agentSend.AgentName; } var agentReceive = AgentController.GetByID(agentIDReceive); if (agentReceive != null) { agentReceivename = agentReceive.AgentName; } ltrAgentReceive.Text = agentReceivename; ltrAgentSend.Text = agentSendname; int mpStatus = Convert.ToInt32(mp.Status); ltrNote.Text = mp.Note; if (mpStatus < 3) { ltrbutton1.Text = "<a href=\"javascript:;\" class=\"btn primary-btn fw-btn not-fullwidth\" onclick=\"inProduct()\">Cập nhật</a>"; ltrbutton2.Text = "<div class=\"float-right\"><a href=\"javascript:;\" class=\"btn primary-btn fw-btn not-fullwidth\" onclick=\"inProduct()\">Cập nhật</a></div>"; } #region LoadDDL //Lấy trạng thái StringBuilder htmlStatus = new StringBuilder(); htmlStatus.Append("<select id=\"moveProStatus\" class=\"form-control\" style=\"width: 20%; display: inline-block\">"); if (mpStatus == 2) { htmlStatus.Append("<option value=\"2\" selected>Đã chuyển</option>"); htmlStatus.Append("<option value=\"3\">Đã hoàn tất</option>"); } else if (mpStatus == 3) { htmlStatus.Append("<option value=\"2\">Đã chuyển</option>"); htmlStatus.Append("<option value=\"3\" selected>Đã hoàn tất</option>"); } htmlStatus.Append("</select>"); ltrMoProStatus.Text = htmlStatus.ToString(); //Lấy nhà cung cấp //var supplier = SupplierController.GetAllWithIsHidden(false); //StringBuilder htmlSupplier = new StringBuilder(); //htmlSupplier.Append("<select id=\"supplierList\" class=\"form-control\" style=\"width: 20%; float: left; margin-right: 10px\">"); //htmlSupplier.Append("<option value=\"0\">Tất cả nhà cung cấp</option>"); //if (supplier.Count > 0) //{ // foreach (var s in supplier) // { // htmlSupplier.Append("<option value=\"" + s.ID + "\">" + s.SupplierName + "</option>"); // } //} //htmlSupplier.Append("</select>"); //ltrSupplier.Text = htmlSupplier.ToString(); #endregion #region Lấy danh sách sản phẩm var mpDetail = MoveProDetailController.GetByMoveProID(ID); string html = ""; if (mpDetail.Count > 0) { string listSKU = ""; foreach (var item in mpDetail) { listSKU += item.SKU + "|"; int ProductType = Convert.ToInt32(item.ProductType); int ProductID = Convert.ToInt32(item.ProductID); int ProductVariableID = Convert.ToInt32(item.ProductVariableID); string SKU = item.SKU; double QuantityInstock = 0; string ProductImageOrigin = ""; string ProductVariable = ""; string ProductName = ""; int PID = 0; string ProductVariableName = ""; string ProductVariableValue = ""; string ProductVariableSave = ""; double QuantityMainInstock = 0; string ProductImage = ""; string QuantityMainInstockString = ""; string QuantityInstockString = ""; string productVariableDescription = item.ProductVariableDescription; string SupplierName = item.SupplierName; if (ProductType == 1) { PID = ProductID; var product = ProductController.GetBySKU(SKU); if (product != null) { double total = PJUtils.TotalProductQuantityInstock(agentIDSend, SKU); string variablename = ""; string variablevalue = ""; string variable = ""; double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU); QuantityInstock = total; QuantityInstockString = string.Format("{0:N0}", total); var img = ProductImageController.GetFirstByProductID(product.ID); if (img != null) { ProductImage = "<img src=\"" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Small) + "\" alt=\"\" style=\"width: 50px\" />"; ProductImageOrigin = Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Small); } else { ProductImage = ""; ProductImageOrigin = ""; } ProductVariable = variable; ProductName = product.ProductTitle; QuantityMainInstock = mainstock; QuantityMainInstockString = string.Format("{0:N0}", mainstock); ProductVariableSave = item.ProductVariableDescription; ProductVariableName = variablename; ProductVariableValue = variablevalue; } } else { PID = ProductVariableID; var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { SKU = productvariable.SKU.Trim().ToUpper(); double total = PJUtils.TotalProductQuantityInstock(agentIDSend, SKU); string variablename = ""; string variablevalue = ""; string variable = ""; string[] vs = productVariableDescription.Split('|'); if (vs.Length - 1 > 0) { for (int i = 0; i < vs.Length - 1; i++) { string[] items = vs[i].Split(':'); variable += items[0] + ":" + items[1] + "<br/>"; variablename += items[0] + "|"; variablevalue += items[1] + "|"; } } double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU); QuantityInstock = total; QuantityInstockString = string.Format("{0:N0}", total); ProductImage = "<img src=\"" + Thumbnail.getURL(productvariable.Image, Thumbnail.Size.Small) + "\" alt=\"\" style=\"width:50px;\" />"; ProductImageOrigin = Thumbnail.getURL(productvariable.Image, Thumbnail.Size.Small); ProductVariable = variable; var product1 = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID)); if (product1 != null) { ProductName = product1.ProductTitle; } QuantityMainInstock = mainstock; QuantityMainInstockString = string.Format("{0:N0}", mainstock); ProductVariableSave = item.ProductVariableDescription; ProductVariableName = variablename; ProductVariableValue = variablevalue; } } html += "<tr class=\"product-result\" data-mpdid=\"" + item.ID + "\" data-quantityinstock=\"" + QuantityInstock + "\" data-productimageorigin=\"" + ProductImageOrigin + "\" data-productvariable=\"" + ProductVariableSave + "\" data-productname=\"" + ProductName + "\" data-sku=\"" + SKU + "\" data-producttype=\"" + ProductType + "\" data-id=\"" + item.ID + "\" data-productnariablename=\"" + ProductVariableName + "\" data-productvariablevalue =\"" + ProductVariableValue + "\">"; html += " <td>" + ProductImage + ""; html += " <td>" + ProductName + "</td>"; html += " <td>" + SKU + "</td>"; html += " <td>" + SupplierName + "</td>"; html += " <td>" + ProductVariable + "</td>"; html += " <td>" + item.QuantiySend + "</td>"; html += " <td style=\"width:20%;\"><input type=\"text\" min=\"0\" class=\"form-control in-quanlity\" style=\"width: 40%;margin: 0 auto;\" value=\"" + item.QuantityReceive + "\" onkeyup=\"checkQuantiy($(this))\" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/></td>"; //html += " <td><a href=\"javascript:;\" onclick=\"deleteRow($(this))\">Xóa</a></td>"; //html += " <td></td>"; html += "</tr>"; } ltrProducts.Text = html; hdfListProductSend.Value = listSKU; } #endregion } } } }
public static string getProduct(string textsearch, int typeinout) { List <ProductGetOut> ps = new List <ProductGetOut>(); string username = HttpContext.Current.Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { int AgentID = Convert.ToInt32(acc.AgentID); if (typeinout == 1) { var products = ProductController.GetByTextSearchIsHidden(textsearch.Trim(), false); if (products.Count > 0) { foreach (var item in products) { var productvariable = ProductVariableController.GetProductID(item.ID); if (productvariable.Count > 0) { foreach (var pv in productvariable) { string SKU = pv.SKU.Trim().ToUpper(); var check = StockManagerController.GetBySKU(AgentID, SKU); if (check.Count > 0) { double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU); if (total > 0) { var variables = ProductVariableValueController.GetByProductVariableID(pv.ID); if (variables.Count > 0) { string variablename = ""; string variablevalue = ""; string variable = ""; foreach (var v in variables) { variable += v.VariableName.Trim() + ":" + v.VariableValue.Trim() + "|"; variablename += v.VariableName.Trim() + "|"; variablevalue += v.VariableValue.Trim() + "|"; } ProductGetOut p = new ProductGetOut(); p.ID = pv.ID; p.ProductName = item.ProductTitle; p.ProductVariable = variable; p.ProductVariableName = variablename; p.ProductVariableValue = variablevalue; p.ProductType = 2; p.ProductImage = "<img src=\"" + Thumbnail.getURL(pv.Image, Thumbnail.Size.Small) + "\" alt=\"\" style=\"width: 50px\" />"; p.ProductImageOrigin = Thumbnail.getURL(pv.Image, Thumbnail.Size.Small); p.QuantityInstock = total; p.QuantityInstockString = string.Format("{0:N0}", total); p.SKU = SKU; int supplierID = 0; if (pv.SupplierID != null) { supplierID = pv.SupplierID.ToString().ToInt(0); } p.SupplierID = supplierID; string supplierName = ""; if (!string.IsNullOrEmpty(pv.SupplierName)) { supplierName = pv.SupplierName; } p.SupplierName = supplierName; ps.Add(p); } } } } } else { string SKU = item.ProductSKU.Trim().ToUpper(); var check = StockManagerController.GetBySKU(AgentID, SKU); if (check.Count > 0) { double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU); if (total > 0) { string variablename = ""; string variablevalue = ""; string variable = ""; ProductGetOut p = new ProductGetOut(); p.ID = item.ID; p.ProductName = item.ProductTitle; p.ProductVariable = variable; p.ProductVariableName = variablename; p.ProductVariableValue = variablevalue; p.ProductType = 1; var img = ProductImageController.GetFirstByProductID(item.ID); if (img != null) { p.ProductImage = "<img src=\"" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Small) + "\" alt=\"\" style=\"width: 50px\" />"; p.ProductImageOrigin = Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Small); } else { p.ProductImage = ""; p.ProductImageOrigin = ""; } p.QuantityInstock = total; p.QuantityInstockString = string.Format("{0:N0}", total); p.SKU = SKU; int supplierID = 0; if (item.SupplierID != null) { supplierID = item.SupplierID.ToString().ToInt(0); } p.SupplierID = supplierID; string supplierName = ""; if (!string.IsNullOrEmpty(item.SupplierName)) { supplierName = item.SupplierName; } p.SupplierName = supplierName; ps.Add(p); } } } } } } else { var products = ProductController.GetBySKU(textsearch); if (products != null) { var productvariable = ProductVariableController.GetProductID(products.ID); if (productvariable.Count > 0) { foreach (var pv in productvariable) { string SKU = pv.SKU.Trim().ToUpper(); var check = StockManagerController.GetBySKU(AgentID, SKU); if (check.Count > 0) { double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU); if (total > 0) { var variables = ProductVariableValueController.GetByProductVariableID(pv.ID); if (variables.Count > 0) { string variablename = ""; string variablevalue = ""; string variable = ""; foreach (var v in variables) { variable += v.VariableName.Trim() + ":" + v.VariableValue.Trim() + "|"; variablename += v.VariableName.Trim() + "|"; variablevalue += v.VariableValue.Trim() + "|"; } ProductGetOut p = new ProductGetOut(); p.ID = pv.ID; p.ProductName = products.ProductTitle; p.ProductVariable = variable; p.ProductVariableName = variablename; p.ProductVariableValue = variablevalue; p.ProductType = 2; p.ProductImage = "<img src=\"" + Thumbnail.getURL(pv.Image, Thumbnail.Size.Small) + "\" alt=\"\" style=\"width: 50px\" />"; p.ProductImageOrigin = Thumbnail.getURL(pv.Image, Thumbnail.Size.Small); p.QuantityInstock = total; p.QuantityInstockString = string.Format("{0:N0}", total); p.SKU = SKU; int supplierID = 0; if (pv.SupplierID != null) { supplierID = pv.SupplierID.ToString().ToInt(0); } p.SupplierID = supplierID; string supplierName = ""; if (!string.IsNullOrEmpty(pv.SupplierName)) { supplierName = pv.SupplierName; } p.SupplierName = supplierName; ps.Add(p); } } } } } else { string SKU = products.ProductSKU.Trim().ToUpper(); var check = StockManagerController.GetBySKU(AgentID, SKU); if (check.Count > 0) { double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU); if (total > 0) { string variablename = ""; string variablevalue = ""; string variable = ""; ProductGetOut p = new ProductGetOut(); p.ID = products.ID; p.ProductName = products.ProductTitle; p.ProductVariable = variable; p.ProductVariableName = variablename; p.ProductVariableValue = variablevalue; p.ProductType = 1; var img = ProductImageController.GetFirstByProductID(products.ID); if (img != null) { p.ProductImage = "<img src=\"" + Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Small) + "\" alt=\"\" style=\"width: 50px\" />"; p.ProductImageOrigin = Thumbnail.getURL(img.ProductImage, Thumbnail.Size.Small); } else { p.ProductImage = ""; p.ProductImageOrigin = ""; } p.SKU = SKU; p.QuantityInstock = total; p.QuantityInstockString = string.Format("{0:N0}", total); int supplierID = 0; if (products.SupplierID != null) { supplierID = products.SupplierID.ToString().ToInt(0); } p.SupplierID = supplierID; string supplierName = ""; if (!string.IsNullOrEmpty(products.SupplierName)) { supplierName = products.SupplierName; } p.SupplierName = supplierName; ps.Add(p); } } } } else { var productvariable = ProductVariableController.GetBySKU(textsearch); if (productvariable != null) { string SKU = productvariable.SKU.Trim().ToUpper(); var check = StockManagerController.GetBySKU(AgentID, SKU); if (check.Count > 0) { double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU); if (total > 0) { var variables = ProductVariableValueController.GetByProductVariableID(productvariable.ID); if (variables.Count > 0) { string variablename = ""; string variablevalue = ""; string variable = ""; foreach (var v in variables) { variable += v.VariableName + ":" + v.VariableValue + "|"; variablename += v.VariableName + "|"; variablevalue += v.VariableValue + "|"; } ProductGetOut p = new ProductGetOut(); p.ID = productvariable.ID; var product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID)); if (product != null) { p.ProductName = product.ProductTitle; } p.ProductVariable = variable; p.ProductVariableName = variablename; p.ProductVariableValue = variablevalue; p.ProductType = 2; p.ProductImage = "<img src=\"" + Thumbnail.getURL(productvariable.Image, Thumbnail.Size.Small) + "\" alt=\"\" style=\"width:50px;\" />"; p.ProductImageOrigin = Thumbnail.getURL(productvariable.Image, Thumbnail.Size.Small); p.SKU = productvariable.SKU.Trim().ToUpper(); p.QuantityInstock = total; p.QuantityInstockString = string.Format("{0:N0}", total); int supplierID = 0; if (productvariable.SupplierID != null) { supplierID = productvariable.SupplierID.ToString().ToInt(0); } p.SupplierID = supplierID; string supplierName = ""; if (!string.IsNullOrEmpty(productvariable.SupplierName)) { supplierName = productvariable.SupplierName; } p.SupplierName = supplierName; ps.Add(p); } } } } } } } JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(ps)); }
public void LoadData() { int ID = Request.QueryString["id"].ToInt(0); if (ID > 0) { var order = OrderController.GetByID(ID); if (order == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng " + ID, "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } else { hdfOrderID.Value = order.ID.ToString(); string username = HttpContext.Current.Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); // check order condition if (acc.RoleID != 0) { if (order.ExcuteStatus == 4) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã chuyển hoàn", "w", false, "", Page); } else { if (order.CreatedBy != acc.Username) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của bạn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } if (order.ExcuteStatus == 1) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này chưa hoàn tất nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } if (order.ExcuteStatus == 3) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã hủy nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } if (order.ShippingType == 1) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này lấy trực tiếp nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } } } else { if (order.ExcuteStatus == 4) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã chuyển hoàn", "w", false, "", Page); } else { if (order.ExcuteStatus == 1) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này chưa hoàn tất nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } if (order.ExcuteStatus == 3) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này đã hủy nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } if (order.ShippingType == 1) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này lấy trực tiếp nên không thể chuyển hoàn", "e", true, "/danh-sach-don-hang-chuyen-hoan", Page); } } } ViewState["ID"] = ID; Response.Cookies["odid"].Value = ID.ToString(); int AgentID = Convert.ToInt32(order.AgentID); txtPhone.Text = order.CustomerPhone; txtFullname.Text = order.CustomerName; txtAddress.Text = order.CustomerAddress; var cus = CustomerController.GetByID(order.CustomerID.Value); if (cus != null) { txtNick.Text = cus.Nick; txtZalo.Text = cus.Zalo; txtFacebook.Text = cus.Facebook; if (!string.IsNullOrEmpty(cus.Facebook)) { ltrFb.Text += "<a href =\"" + cus.Facebook + "\" class=\"btn primary-btn fw-btn not-fullwidth\" target=\"_blank\">Xem</a>"; } } int customerID = Convert.ToInt32(order.CustomerID); ltrViewDetail.Text = "<a href=\"javascript:;\" class=\"btn primary-btn fw-btn not-fullwidth\" onclick=\"viewCustomerDetail('" + customerID + "')\"><i class=\"fa fa-address-card-o\" aria-hidden=\"true\"></i> Xem chi tiết</a>"; ltrViewDetail.Text += "<a href=\"chi-tiet-khach-hang?id=" + customerID + "\" class=\"btn primary-btn fw-btn not-fullwidth edit-customer-btn\" target=\"_blank\"><i class=\"fa fa-pencil-square-o\" aria-hidden=\"true\"></i> Chỉnh sửa</a>"; var d = DiscountCustomerController.getbyCustID(customerID); if (d.Count > 0) { var da = d[0].DiscountAmount; hdfIsDiscount.Value = "1"; hdfDiscountAmount.Value = da.ToString(); ltrDiscountInfo.Text = "<strong>Khách hàng được chiết khấu: " + string.Format("{0:N0}", Convert.ToDouble(da)) + " vnđ/sản phẩm.</strong>"; } else { hdfIsDiscount.Value = "0"; hdfDiscountAmount.Value = "0"; } int customerType = Convert.ToInt32(order.OrderType); ltrCustomerType.Text = ""; ltrCustomerType.Text += "<select disabled class=\"form-control customer-type\" onchange=\"getProductPrice($(this))\">"; if (customerType == 1) { ltrCustomerType.Text += "<option value=\"2\">Khách mua sỉ</option>"; ltrCustomerType.Text += "<option value=\"1\" selected>Khách mua lẻ</option>"; } else { ltrCustomerType.Text += "<option value=\"2\" selected>Khách mua sỉ</option>"; ltrCustomerType.Text += "<option value=\"1\">Khách mua lẻ</option>"; } ltrCustomerType.Text += "</select>"; double ProductQuantity = 0; double totalPrice = Convert.ToDouble(order.TotalPrice); double totalPriceNotDiscount = Convert.ToDouble(order.TotalPriceNotDiscount); hdfcheckR.Value = ""; int totalrefund = 0; if (order.RefundsGoodsID > 0) { var re = RefundGoodController.GetByID(order.RefundsGoodsID.Value); if (re != null) { totalrefund = Convert.ToInt32(re.TotalPrice); hdfcheckR.Value = order.RefundsGoodsID.ToString() + "," + re.TotalPrice; } ltrtotalpricedetail.Text = string.Format("{0:N0}", totalPrice - totalrefund); ltrTotalPriceRefund.Text = string.Format("{0:N0}", totalrefund); } hdfDiscountInOrder.Value = ""; if (order.DiscountPerProduct > 0) { hdfDiscountInOrder.Value = order.DiscountPerProduct.ToString(); } int paymentStatus = Convert.ToInt32(order.PaymentStatus); int excuteStatus = Convert.ToInt32(order.ExcuteStatus); int shipping = Convert.ToInt32(order.ShippingType); int TransportCompanyID = Convert.ToInt32(order.TransportCompanyID); int TransportCompanySubID = Convert.ToInt32(order.TransportCompanySubID); int PostalDeliveryType = Convert.ToInt32(order.PostalDeliveryType); int paymenttype = Convert.ToInt32(order.PaymentType); #region Lấy danh sách sản phẩm var orderdetails = OrderDetailController.GetByOrderID(ID); string html = ""; string Print = ""; if (orderdetails.Count > 0) { int t = 0; int orderitem = 0; foreach (var item in orderdetails) { ProductQuantity += Convert.ToDouble(item.Quantity); int ProductType = Convert.ToInt32(item.ProductType); int ProductID = Convert.ToInt32(item.ProductID); int ProductVariableID = Convert.ToInt32(item.ProductVariableID); double ItemPrice = Convert.ToDouble(item.Price); string SKU = item.SKU; double Giabansi = 0; double Giabanle = 0; string stringGiabansi = ""; string stringGiabanle = ""; double QuantityInstock = 0; string ProductImageOrigin = ""; string ProductVariable = ""; string ProductName = ""; int PID = 0; string ProductVariableName = ""; string ProductVariableValue = ""; string ProductVariableSave = ""; double QuantityMainInstock = 0; string ProductImage = ""; string QuantityMainInstockString = ""; string QuantityInstockString = ""; string productVariableDescription = item.ProductVariableDescrition; if (ProductType == 1) { PID = ProductID; var product = ProductController.GetBySKU(SKU); if (product != null) { double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU); if (customerType == 1) { Giabansi = Convert.ToDouble(product.Regular_Price); Giabanle = ItemPrice; } else { Giabansi = ItemPrice; Giabanle = Convert.ToDouble(product.Retail_Price); } stringGiabansi = string.Format("{0:N0}", Giabansi); stringGiabanle = string.Format("{0:N0}", Giabanle); string variablename = ""; string variablevalue = ""; string variable = ""; QuantityInstock = mainstock; QuantityInstockString = string.Format("{0:N0}", mainstock); var img = ProductImageController.GetFirstByProductID(product.ID); if (!string.IsNullOrEmpty(product.ProductImage)) { ProductImage = "<img src=\"" + product.ProductImage + "\" />"; ProductImageOrigin = product.ProductImage; } else if (img != null) { ProductImage = "<img src=\"" + img.ProductImage + "\" />"; ProductImageOrigin = img.ProductImage; } else { ProductImage = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />"; ProductImageOrigin = ""; } ProductVariable = variable; ProductName = product.ProductTitle; QuantityMainInstock = mainstock; QuantityMainInstockString = string.Format("{0:N0}", mainstock); ProductVariableSave = item.ProductVariableDescrition; ProductVariableName = variablename; ProductVariableValue = variablevalue; } } else { PID = ProductVariableID; var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { SKU = productvariable.SKU.Trim().ToUpper(); double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU); if (customerType == 1) { Giabansi = Convert.ToDouble(productvariable.Regular_Price); Giabanle = ItemPrice; } else { Giabansi = ItemPrice; Giabanle = Convert.ToDouble(productvariable.RetailPrice); } stringGiabansi = string.Format("{0:N0}", Giabansi); stringGiabanle = string.Format("{0:N0}", Giabanle); string variablename = ""; string variablevalue = ""; string variable = ""; string[] vs = productVariableDescription.Split('|'); if (vs.Length - 1 > 0) { for (int i = 0; i < vs.Length - 1; i++) { string[] items = vs[i].Split(':'); variable += items[0] + ":" + items[1] + "<br/>"; variablename += items[0] + "|"; variablevalue += items[1] + "|"; } } QuantityInstock = mainstock; QuantityInstockString = string.Format("{0:N0}", mainstock); var _product = ProductController.GetByID(Convert.ToInt32(productvariable.ProductID)); if (!string.IsNullOrEmpty(productvariable.Image)) { ProductImage = "<img src=\"" + productvariable.Image + "\" />"; ProductImageOrigin = productvariable.Image; } else if (_product != null && !string.IsNullOrEmpty(_product.ProductImage)) { ProductImage = "<img src=\"" + _product.ProductImage + "\" />"; ProductImageOrigin = _product.ProductImage; } else { ProductImage = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />"; ProductImageOrigin = ""; } ProductVariable = variable; if (_product != null) { ProductName = _product.ProductTitle; } QuantityMainInstock = mainstock; QuantityMainInstockString = string.Format("{0:N0}", mainstock); ProductVariableSave = item.ProductVariableDescrition; ProductVariableName = variablename; ProductVariableValue = variablevalue; } } orderitem++; html += "<tr class=\"product-result\" data-orderdetailid=\"" + item.ID + "\" data-giabansi=\"" + Giabansi + "\" data-giabanle=\"" + Giabanle + "\" " + "data-quantityinstock=\"" + QuantityInstock + "\" data-productimageorigin=\"" + ProductImageOrigin + "\" " + "data-productvariable=\"" + ProductVariable + "\" data-productname=\"" + ProductName + "\" " + "data-sku=\"" + SKU + "\" data-producttype=\"" + ProductType + "\" data-id=\"" + PID + "\" " + "data-productnariablename=\"" + ProductVariableName + "\" " + "data-productvariablevalue =\"" + ProductVariableValue + "\" " + "data-productvariablesave =\"" + ProductVariableSave + "\" " + "data-quantitymaininstock=\"" + QuantityMainInstock + "\">"; html += " <td class=\"order-item\">" + orderitem + ""; html += " <td class=\"image-item\">" + ProductImage + ""; html += " <td class=\"name-item\">" + ProductName + "</td>"; html += " <td class=\"sku-item\">" + SKU + "</td>"; html += " <td class=\"variable-item\">" + ProductVariable + "</td>"; html += " <td class=\"price-item gia-san-pham\" data-price=\"" + ItemPrice + "\">" + string.Format("{0:N0}", ItemPrice) + "</td>"; html += " <td class=\"quantity-item soluong\">" + QuantityInstockString + "</td>"; html += " <td class=\"quantity-item\"><input disabled data-quantity=\"" + item.Quantity + "\" value=\"" + item.Quantity + "\" type=\"text\" class=\"form-control in-quanlity\" value=\"1\" onblur=\"checkQuantiy($(this))\" onkeypress='return event.charCode >= 48 && event.charCode <= 57'/></td>"; int k = Convert.ToInt32(ItemPrice) * Convert.ToInt32(item.Quantity); html += "<td class=\"total-item totalprice-view\">" + string.Format("{0:N0}", k) + "</td>"; html += " <td class=\"trash-item\"><a href=\"javascript:;\" class=\"link-btn\"><i class=\"fa fa-trash\"></i></a> </td>"; html += "</tr>"; Print += " <tr>"; t++; Print += "<td>" + t + "</td>"; Print += "<td>" + SKU + " - " + ProductName + " - " + ProductVariableSave.Replace("|", ", ") + "</td> "; Print += "<td>" + item.Quantity + "</td>"; Print += "<td>" + string.Format("{0:N0}", ItemPrice) + "</td>"; Print += "<td> " + string.Format("{0:N0}", k) + "</td>"; Print += "</tr>"; } ltrProducts.Text = html; } #endregion ddlPaymentStatus.SelectedValue = paymentStatus.ToString(); ddlExcuteStatus.SelectedValue = excuteStatus.ToString(); ddlPaymentType.SelectedValue = paymenttype.ToString(); ddlShippingType.SelectedValue = shipping.ToString(); ddlPostalDeliveryType.SelectedValue = PostalDeliveryType.ToString(); LoadTransportCompanySubID(TransportCompanyID); ddlTransportCompanyID.SelectedValue = TransportCompanyID.ToString(); ddlTransportCompanySubID.SelectedValue = TransportCompanySubID.ToString(); txtShippingCode.Text = order.ShippingCode; txtOrderNote.Text = order.OrderNote; ltrProductQuantity.Text = string.Format("{0:N0}", ProductQuantity) + " sản phẩm"; ltrTotalNotDiscount.Text = string.Format("{0:N0}", Convert.ToDouble(order.TotalPriceNotDiscount)); ltrTotalprice.Text = string.Format("{0:N0}", Convert.ToDouble(order.TotalPrice)); pDiscount.Value = order.DiscountPerProduct; pFeeShip.Value = Convert.ToDouble(order.FeeShipping); ltrOtherFeeName.Text = order.OtherFeeName; txtOtherFeeName.Text = order.OtherFeeName; pOtherFee.Value = Convert.ToDouble(order.OtherFeeValue); ltrTotalAfterCK.Text = string.Format("{0:N0}", (Convert.ToDouble(order.TotalPriceNotDiscount) - Convert.ToDouble(order.TotalDiscount))); ltrOrderID.Text = ID.ToString(); ltrCreateBy.Text = order.CreatedBy; ltrCreateDate.Text = order.CreatedDate.ToString(); ltrDateDone.Text = "Chưa hoàn tất"; if (order.DateDone != null) { ltrDateDone.Text = order.DateDone.ToString(); } ltrOrderNote.Text = order.OrderNote; ltrOrderQuantity.Text = ProductQuantity.ToString(); ltrOrderTotalPrice.Text = string.Format("{0:N0}", Convert.ToDouble(order.TotalPrice)); ltrOrderStatus.Text = PJUtils.OrderExcuteStatus(Convert.ToInt32(order.ExcuteStatus)); ltrOrderType.Text = PJUtils.OrderType(Convert.ToInt32(order.OrderType)); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); DateTime currentDate = DateTime.Now; if (acc != null) { if (acc.RoleID == 0 || acc.RoleID == 1) { int cateID = hdfParentID.Value.ToInt(); if (cateID > 0) { string ProductSKU = txtProductSKU.Text.Trim().ToUpper(); var check = true; var productcheck = ProductController.GetBySKU(ProductSKU); if (productcheck != null) { check = false; } else { var productvariable = ProductVariableController.GetBySKU(ProductSKU); if (productvariable != null) { check = false; } } if (check == false) { PJUtils.ShowMessageBoxSwAlert("Trùng mã sản phẩm vui lòng kiểm tra lại", "e", false, Page); } else { string ProductTitle = txtProductTitle.Text.ToString(); string ProductContent = pContent.Content.ToString(); double ProductStock = 0; int StockStatus = 3; double Regular_Price = Convert.ToDouble(pRegular_Price.Text); double CostOfGood = Convert.ToDouble(pCostOfGood.Text); double Retail_Price = Convert.ToDouble(pRetailPrice.Text); int supplierID = ddlSupplier.SelectedValue.ToInt(0); string supplierName = ddlSupplier.SelectedItem.ToString(); int a = 1; double MinimumInventoryLevel = pMinimumInventoryLevel.Text.ToInt(0); double MaximumInventoryLevel = pMaximumInventoryLevel.Text.ToInt(0); if (hdfsetStyle.Value == "2") { MinimumInventoryLevel = 0; MaximumInventoryLevel = 0; a = hdfsetStyle.Value.ToInt(); } int ShowHomePage = ddlShowHomePage.SelectedValue.ToInt(0); string kq = ProductController.Insert(cateID, 0, ProductTitle, ProductContent, ProductSKU, ProductStock, StockStatus, true, Regular_Price, CostOfGood, Retail_Price, "", 0, false, currentDate, username, supplierID, supplierName, txtMaterials.Text, MinimumInventoryLevel, MaximumInventoryLevel, a, ShowHomePage); //Phần thêm ảnh đại diện sản phẩm string path = "/uploads/images/"; string ProductImage = ""; if (ProductThumbnailImage.UploadedFiles.Count > 0) { foreach (UploadedFile f in ProductThumbnailImage.UploadedFiles) { var o = path + kq + '-' + Path.GetFileName(f.FileName); try { f.SaveAs(Server.MapPath(o)); ProductImage = o; } catch { } } } string updateImage = ProductController.UpdateImage(kq.ToInt(), ProductImage); //Phần thêm thư viện ảnh sản phẩm string IMG = ""; if (hinhDaiDien.UploadedFiles.Count > 0) { foreach (UploadedFile f in hinhDaiDien.UploadedFiles) { var o = path + kq + '-' + Path.GetFileName(f.FileName); try { f.SaveAs(Server.MapPath(o)); IMG = o; ProductImageController.Insert(kq.ToInt(), IMG, false, currentDate, username); } catch { } } } if (kq.ToInt(0) > 0) { int ProductID = kq.ToInt(0); string variable = hdfVariableListInsert.Value; if (!string.IsNullOrEmpty(variable)) { string[] items = variable.Split(','); for (int i = 0; i < items.Length - 1; i++) { string item = items[i]; string[] itemElement = item.Split(';'); string datanameid = itemElement[0]; string[] datavalueid = itemElement[1].Split('|'); string datanametext = itemElement[2]; string datavaluetext = itemElement[3]; string productvariablesku = itemElement[4].Trim().ToUpper(); string regularprice = itemElement[5]; string costofgood = itemElement[6]; string retailprice = itemElement[7]; string[] datanamevalue = itemElement[8].Split('|'); string imageUpload = itemElement[8]; int _MaximumInventoryLevel = itemElement[9].ToInt(0); int _MinimumInventoryLevel = itemElement[10].ToInt(0); int stockstatus = itemElement[11].ToInt(); HttpPostedFile postedFile = Request.Files["" + imageUpload + ""]; string image = ""; if (postedFile != null && postedFile.ContentLength > 0) { var o = path + kq + '-' + Path.GetFileName(postedFile.FileName); postedFile.SaveAs(Server.MapPath(o)); image = o; } string kq1 = ProductVariableController.Insert(ProductID, ProductSKU, productvariablesku, 0, stockstatus, Convert.ToDouble(regularprice), Convert.ToDouble(costofgood), Convert.ToDouble(retailprice), image, true, false, currentDate, username, supplierID, supplierName, _MinimumInventoryLevel, _MaximumInventoryLevel); string color = ""; string size = ""; int ProductVariableID = 0; if (kq1.ToInt(0) > 0) { ProductVariableID = kq1.ToInt(0); color = datavalueid[0]; size = datavalueid[1]; string[] Data = datanametext.Split('|'); string[] DataValue = datavaluetext.Split('|'); for (int k = 0; k < Data.Length - 2; k++) { int variablevalueID = datavalueid[k].ToInt(); string variableName = Data[k]; string variableValueName = DataValue[k]; ProductVariableValueController.Insert(ProductVariableID, productvariablesku, variablevalueID, variableName, variableValueName, false, currentDate, username); } } ProductVariableController.UpdateColorSize(ProductVariableID, color, size); } } PJUtils.ShowMessageBoxSwAlertCallFunction("Tạo sản phẩm thành công", "s", true, "redirectTo(" + kq + ")", Page); } } } } } }
public static string getProduct(string textsearch, int gettotal) { List <ProductGetOut> ps = new List <ProductGetOut>(); string username = HttpContext.Current.Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { int AgentID = Convert.ToInt32(acc.AgentID); var product = ProductController.GetBySKU(textsearch.Trim().ToUpper()); // Kiểm tra sản phẩm có trong table Product không? if (product != null) // Nếu sản phẩm có trong table Product thì... { var productvariable = ProductVariableController.GetByParentSKU(product.ProductSKU); // Kiểm tra sản phẩm cha là variable hay simple? if (productvariable.Count > 0) // Nếu sản phẩm cha là variable thì... { foreach (var pv in productvariable) { string SKU = pv.SKU.Trim().ToUpper(); var variables = ProductVariableValueController.GetByProductVariableSKU(pv.SKU); if (variables.Count > 0) { string variablename = ""; string variablevalue = ""; string variable = ""; string variablesave = ""; foreach (var v in variables) { variable += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "<br/>"; variablesave += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "|"; variablename += v.VariableName.Trim() + "|"; variablevalue += v.VariableValue.Trim() + "|"; } ProductGetOut p = new ProductGetOut(); p.ID = pv.ID; p.ProductName = product.ProductTitle; p.ProductVariable = variable; p.ProductVariableSave = variablesave; p.ProductVariableName = variablename; p.ProductVariableValue = variablevalue; p.ProductType = 2; if (!string.IsNullOrEmpty(pv.Image)) { p.ProductImage = "<img src=\"" + pv.Image + "\" />"; p.ProductImageOrigin = pv.Image; } else if (!string.IsNullOrEmpty(product.ProductImage)) { p.ProductImage = "<img src=\"" + product.ProductImage + "\" />"; p.ProductImageOrigin = product.ProductImage; } else { p.ProductImage = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />"; p.ProductImageOrigin = ""; } if (gettotal == 1) { double total = PJUtils.TotalProductQuantityInstock(AgentID, SKU); var mainstock = PJUtils.TotalProductQuantityInstock(1, SKU); p.QuantityMainInstock = mainstock; p.QuantityMainInstockString = string.Format("{0:N0}", mainstock); p.QuantityInstock = total; p.QuantityInstockString = string.Format("{0:N0}", total); } p.SKU = SKU; p.Giabansi = Convert.ToDouble(pv.Regular_Price); p.stringGiabansi = string.Format("{0:N0}", pv.Regular_Price); p.Giabanle = Convert.ToDouble(pv.RetailPrice); p.stringGiabanle = string.Format("{0:N0}", pv.RetailPrice); ps.Add(p); } } } else // Nếu sản phẩm cha là simple thì... { string SKU = product.ProductSKU.Trim().ToUpper(); double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU); ProductGetOut p = new ProductGetOut(); p.ID = product.ID; p.ProductName = product.ProductTitle; p.ProductVariable = ""; p.ProductVariableSave = ""; p.ProductVariableName = ""; p.ProductVariableValue = ""; p.ProductType = 1; if (!string.IsNullOrEmpty(product.ProductImage)) { p.ProductImage = "<img src=\"" + product.ProductImage + "\" />"; p.ProductImageOrigin = product.ProductImage; } else { p.ProductImage = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />"; p.ProductImageOrigin = ""; } p.SKU = SKU; p.QuantityMainInstock = mainstock; p.QuantityMainInstockString = string.Format("{0:N0}", mainstock); p.QuantityInstock = mainstock; p.QuantityInstockString = string.Format("{0:N0}", mainstock); p.Giabansi = Convert.ToDouble(product.Regular_Price); p.stringGiabansi = string.Format("{0:N0}", product.Regular_Price); p.Giabanle = Convert.ToDouble(product.Retail_Price); p.stringGiabanle = string.Format("{0:N0}", product.Retail_Price); ps.Add(p); } } else // Nếu không nằm trong table Product thì... { var productvariable = ProductVariableController.GetBySKU(textsearch.Trim().ToUpper()); // Nếu sản phẩm là con (nằm trong table ProductVariable) thì... if (productvariable != null) { string SKU = productvariable.SKU.Trim().ToUpper(); var variables = ProductVariableValueController.GetByProductVariableSKU(SKU); if (variables.Count > 0) { string variablename = ""; string variablevalue = ""; string variable = ""; string variablesave = ""; foreach (var v in variables) { variable += v.VariableName + ": " + v.VariableValue + "<br/>"; variablesave += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "|"; variablename += v.VariableName + "|"; variablevalue += v.VariableValue + "|"; } double mainstock = PJUtils.TotalProductQuantityInstock(1, SKU); ProductGetOut p = new ProductGetOut(); p.ID = productvariable.ID; var _product = ProductController.GetBySKU(productvariable.ParentSKU); if (_product != null) { p.ProductName = _product.ProductTitle; } p.ProductVariable = variable; p.ProductVariableSave = variablesave; p.ProductVariableName = variablename; p.ProductVariableValue = variablevalue; p.ProductType = 2; if (!string.IsNullOrEmpty(productvariable.Image)) { p.ProductImage = "<img src=\"" + productvariable.Image + "\" />"; p.ProductImageOrigin = productvariable.Image; } else if (_product != null && !string.IsNullOrEmpty(_product.ProductImage)) { p.ProductImage = "<img src=\"" + _product.ProductImage + "\" />"; p.ProductImageOrigin = _product.ProductImage; } else { p.ProductImage = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />"; p.ProductImageOrigin = ""; } p.SKU = SKU; p.QuantityMainInstock = mainstock; p.QuantityMainInstockString = string.Format("{0:N0}", mainstock); p.QuantityInstock = mainstock; p.QuantityInstockString = string.Format("{0:N0}", mainstock); p.Giabansi = Convert.ToDouble(productvariable.Regular_Price); p.stringGiabansi = string.Format("{0:N0}", productvariable.Regular_Price); p.Giabanle = Convert.ToDouble(productvariable.Regular_Price); p.stringGiabanle = string.Format("{0:N0}", productvariable.Regular_Price); ps.Add(p); } } } } JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(ps)); }
protected void btnImport_Click(object sender, EventArgs e) { DateTime currentDate = DateTime.Now; string username = Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { if (acc.RoleID == 0 || acc.RoleID == 1) { int AgentID = Convert.ToInt32(acc.AgentID); int AgentIDReceive = hdfAgentID.Value.ToInt(0); string agentSendname = ""; string agentReceivename = ""; var agentSend = AgentController.GetByID(AgentID); if (agentSend != null) { agentSendname = agentSend.AgentName; } var agentReceive = AgentController.GetByID(AgentIDReceive); if (agentReceive != null) { agentReceivename = agentReceive.AgentName; } string list = hdfvalue.Value; string note = hdfNote.Value; int moveProStatus = hdfStatus.Value.ToInt(0); string[] items = list.Split(';'); if (items.Length - 1 > 0) { string kq = MoveProController.Insert(AgentID, agentSendname, AgentIDReceive, agentReceivename, moveProStatus, note, false, currentDate, username); if (kq.ToInt(0) > 0) { int moveProID = kq.ToInt(0); for (int i = 0; i < items.Length - 1; i++) { var item = items[i]; string[] itemValue = item.Split(','); int ID = itemValue[0].ToInt(); string SKU = itemValue[1]; int producttype = itemValue[2].ToInt(); string ProductVariableName = itemValue[3]; string ProductVariableValue = itemValue[4]; double Quantity = Convert.ToDouble(itemValue[5]); string ProductName = itemValue[6]; string ProductImageOrigin = itemValue[7]; string ProductVariable = itemValue[8]; if (producttype == 1) { int supplierID = 0; string supplierName = ""; var product = ProductController.GetBySKU(SKU); if (product != null) { supplierID = Convert.ToInt32(product.SupplierID); supplierName = product.SupplierName; } if (moveProStatus == 2) { StockManagerController.Insert( new tbl_StockManager { AgentID = AgentID, ProductID = ID, ProductVariableID = 0, Quantity = Quantity, QuantityCurrent = 0, Type = 2, NoteID = note, OrderID = 0, Status = 5, SKU = SKU, CreatedDate = currentDate, CreatedBy = username, MoveProID = moveProID, ParentID = ID }); MoveProDetailController.Insert(moveProID, SKU, ID, 0, producttype, ProductVariable, Quantity, 0, "", supplierID, supplierName, "", "", ProductName, ProductImageOrigin, true, currentDate, username); } else { MoveProDetailController.Insert(moveProID, SKU, ID, 0, producttype, ProductVariable, Quantity, 0, "", supplierID, supplierName, "", "", ProductName, ProductImageOrigin, false, currentDate, username); } } else { int supplierID = 0; string supplierName = ""; int parentID = 0; string parentSKU = ""; var productvariable = ProductVariableController.GetBySKU(SKU); if (productvariable != null) { supplierID = Convert.ToInt32(productvariable.SupplierID); supplierName = productvariable.SupplierName; parentSKU = productvariable.ParentSKU; } if (!string.IsNullOrEmpty(parentSKU)) { var product = ProductController.GetBySKU(parentSKU); if (product != null) { parentID = product.ID; } } if (moveProStatus == 2) { StockManagerController.Insert( new tbl_StockManager { AgentID = AgentID, ProductID = 0, ProductVariableID = ID, Quantity = Quantity, QuantityCurrent = 0, Type = 2, NoteID = note, OrderID = 0, Status = 5, SKU = SKU, CreatedDate = currentDate, CreatedBy = username, MoveProID = moveProID, ParentID = parentID, }); MoveProDetailController.Insert(moveProID, SKU, 0, ID, producttype, ProductVariable, Quantity, 0, "", supplierID, supplierName, ProductVariableName, ProductVariableValue, ProductName, ProductImageOrigin, true, currentDate, username); } else { MoveProDetailController.Insert(moveProID, SKU, 0, ID, producttype, ProductVariable, Quantity, 0, "", supplierID, supplierName, ProductVariableName, ProductVariableValue, ProductName, ProductImageOrigin, false, currentDate, username); } } } PJUtils.ShowMessageBoxSwAlert("Tạo lệnh chuyển hàng thành công", "s", true, Page); } //int SessionInOutID = SessionInOutController.Insert(currentDate, note, AgentID, 2, currentDate, username).ToInt(0); //if (SessionInOutID > 0) //{ // for (int i = 0; i < items.Length - 1; i++) // { // //list += id + "," + sku + "," + producttype + "," + productnariablename + "," + productvariablevalue + "," + quantity + "|"; // var item = items[i]; // string[] itemValue = item.Split(','); // int ID = itemValue[0].ToInt(); // string SKU = itemValue[1]; // int producttype = itemValue[2].ToInt(); // string ProductVariableName = itemValue[3]; // string ProductVariableValue = itemValue[4]; // double Quantity = Convert.ToDouble(itemValue[5]); // string ProductName = itemValue[6]; // string ProductImageOrigin = itemValue[7]; // string ProductVariable = itemValue[8]; // if (producttype == 1) // { // StockManagerController.Insert(AgentID, ID, 0, "", "", Quantity, 0, 2, false, 1, note, 0, // SessionInOutID, 2, ProductName, SKU, ProductImageOrigin, ProductVariable, currentDate, username); // } // else // { // StockManagerController.Insert(AgentID, 0, ID, ProductVariableName, ProductVariableValue, Quantity, 0, 2, // false, 2, note, 0, SessionInOutID, 2, ProductName, SKU, ProductImageOrigin, ProductVariable, currentDate, username); // } // } // PJUtils.ShowMessageBoxSwAlert("Xuất hàng thành công", "s", true, Page); //} } } } }