public void GetProductVariableValueByProductVariableID(int ProductVariableID, string username, string password) { var rs = new ResponseClass(); if (Login(username, password)) { var ProductVariableValue = ProductVariableValueController.GetByProductVariableID(ProductVariableID); if (ProductVariableValue.Count > 0) { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.SUCCESS); rs.Status = APIUtils.ResponseMessage.Success.ToString(); rs.ProductVariableValue = ProductVariableValue; } else { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.NotFound); rs.Status = APIUtils.ResponseMessage.Error.ToString(); rs.Message = APIUtils.OBJ_DNTEXIST; } } else { rs.Code = APIUtils.GetResponseCode(APIUtils.ResponseCode.FAILED); rs.Status = APIUtils.ResponseMessage.Fail.ToString(); } Context.Response.ContentType = "application/json"; Context.Response.Write(JsonConvert.SerializeObject(rs, Formatting.Indented)); Context.Response.Flush(); Context.Response.End(); }
public void pagingall(List <tbl_ProductVariable> acs) { int PageSize = 30; StringBuilder html = new StringBuilder(); html.Append("<div class='row'>"); if (acs.Count > 0) { int TotalItems = acs.Count; if (TotalItems % PageSize == 0) { PageCount = TotalItems / PageSize; } else { PageCount = TotalItems / PageSize + 1; } Int32 Page = GetIntFromQueryString("Page"); if (Page == -1) { Page = 1; } int FromRow = (Page - 1) * PageSize; int ToRow = Page * PageSize - 1; if (ToRow >= TotalItems) { ToRow = TotalItems - 1; } for (int i = FromRow; i < ToRow + 1; i++) { var item = acs[i]; html.Append("<div class='col-md-3 product-item'>"); html.Append(" <div><img src='" + Thumbnail.getURL(item.Image, Thumbnail.Size.Large) + "'></div>"); if (!string.IsNullOrEmpty(item.Image)) { html.Append(" <div><a href='" + Thumbnail.getURL(item.Image, Thumbnail.Size.Source) + "' download class='btn download-btn h45-btn'><i class='fa fa-cloud-download'></i> Tải hình này</a></div>"); } var value = ProductVariableValueController.GetByProductVariableID(item.ID); if (value != null) { foreach (var temp in value) { html.Append("<h3>" + temp.VariableName + ": " + temp.VariableValue + "</h3>"); } } html.Append(" <p>Mã: " + item.SKU + "</p>"); html.Append(" <p>Giá sỉ: " + string.Format("{0:N0}", item.Regular_Price) + "</p>"); html.Append(" <p>Kho: " + PJUtils.StockStatusBySKU(1, item.SKU) + " (" + PJUtils.TotalProductQuantityInstock(1, item.SKU) + " cái)</p>"); html.Append("</div>"); } } ltrList.Text = html.ToString(); }
protected void btnDelete_Click(object sender, EventArgs e) { try { RefundGoodDetailController.DeleteByRefundGoodsID(_refundGood.RefundGoodsID); RefundGoodController.DeleteByID(_refundGood.RefundGoodsID); int OrderSaleID = OrderController.DeleteOrderRefund(_refundGood.RefundGoodsID); if (OrderSaleID > 0) { _refundGood.OrderSaleID = OrderSaleID; } foreach (var product in _refundGood.RefundDetails) { if (!string.IsNullOrEmpty(product.ChildSKU)) { var ProductVariable = ProductVariableValueController.GetByProductVariableSKU(product.ChildSKU); string VariableValue = ""; if (ProductVariable.Count > 0) { foreach (var v in ProductVariable) { VariableValue += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "|"; } } product.VariableValue = VariableValue; } if (product.ChangeType != 3) // Change product error { StockManagerController.Insert(new tbl_StockManager() { AgentID = 1, ProductID = product.ProductStyle == 1 ? product.ProductID : 0, ProductVariableID = product.ProductVariableID, Quantity = product.QuantityRefund, QuantityCurrent = 0, Type = 1, NoteID = "Xuất kho do làm lại đơn hàng đổi trả", OrderID = product.OrderID, Status = 11, SKU = product.ProductStyle == 1 ? product.ParentSKU : product.ChildSKU, CreatedDate = DateTime.Now, CreatedBy = _refundGood.CreateBy, MoveProID = 0, ParentID = product.ProductID, }); } } HttpContext.Current.Items.Add("xem-don-hang-doi-tra", JsonConvert.SerializeObject(_refundGood)); Server.Transfer("tao-don-hang-doi-tra.aspx"); } catch (Exception) { throw; } }
private static List <ProductGetOut> _getProductVariation(List <tbl_ProductVariable> variations, tbl_Product product = null) { var result = new List <ProductGetOut>(); if (variations == null || variations.Count() == 0) { return(result); } if (product == null) { product = ProductController.GetBySKU(variations.FirstOrDefault().ParentSKU); } foreach (var variation in variations) { var attributes = ProductVariableValueController.GetByProductVariableSKU(variation.SKU); if (attributes.Count == 0) { continue; } var variable = String.Empty; var variablename = String.Empty; var variablevalue = String.Empty; foreach (var attribute in attributes) { variable += attribute.VariableName.Trim() + ": " + attribute.VariableValue.Trim() + "|"; variablename += attribute.VariableName.Trim() + "|"; variablevalue += attribute.VariableValue.Trim() + "|"; } var quantity = StockManagerController.getQuantityStock2BySKU(variation.SKU); var item = new ProductGetOut() { ID = variation.ID, ProductName = product.ProductTitle, ProductVariable = variable, ProductVariableName = variablename, ProductVariableValue = variablevalue, ProductStyle = 2, ProductImage = Thumbnail.getURL(variation.Image, Thumbnail.Size.Normal), ProductImageOrigin = Thumbnail.getURL(variation.Image, Thumbnail.Size.Source), SKU = variation.SKU.Trim().ToUpper(), SupplierID = product.SupplierID.HasValue ? product.SupplierID.Value : 0, SupplierName = String.IsNullOrEmpty(product.SupplierName) ? String.Empty : product.SupplierName, WarehouseQuantity = string.Format("{0:N0}", quantity), ParentID = product.ID, ParentSKU = product.ProductSKU }; result.Add(item); } return(result); }
protected void btnLogin_Click(object sender, EventArgs e) { DateTime currentDate = DateTime.Now; string username = Request.Cookies["userLoginSystem"].Value; int productvariableid = ViewState["productvariableid"].ToString().ToInt(0); string SKU = ViewState["ProductvariableSKU"].ToString(); int VariableValueID = ddlVariableValue.SelectedValue.ToInt(); string VariableName = ddlVariable.SelectedItem.ToString(); string VariableValue = ddlVariableValue.SelectedItem.ToString(); bool isHidden = chkIsHidden.Checked; ProductVariableValueController.Insert(productvariableid, SKU, VariableValueID, VariableName, VariableValue, isHidden, currentDate, username); PJUtils.ShowMessageBoxSwAlert("Thêm giá trị thành công", "s", true, Page); }
public void UpdateProductID() { DateTime currentDate = DateTime.Now; var product = ProductVariableController.GetAll(""); foreach (var p in product) { var pr = ProductController.GetBySKU(p.ParentSKU); if (pr != null) { ProductVariableController.UpdateProductID(p.ID, pr.ID); } string color = ""; string size = ""; if (!string.IsNullOrEmpty(p.color)) { color = p.color; } if (!string.IsNullOrEmpty(p.size)) { size = p.size; } if (!string.IsNullOrEmpty(color)) { var vcolor = VariableValueController.GetByVariableID(1); foreach (var c in vcolor) { if (color == c.VariableValueText) { ProductVariableValueController.Insert(p.ID, p.SKU, c.ID, c.VariableName, c.VariableValue, false, currentDate, "admin"); } } } if (!string.IsNullOrEmpty(size)) { var vsize = VariableValueController.GetByVariableID(2); foreach (var s in vsize) { if (size == s.VariableValueText) { ProductVariableValueController.Insert(p.ID, p.SKU, s.ID, s.VariableName, s.VariableValue, false, currentDate, "admin"); } } } } }
public void LoadData() { List <tbl_ProductVariableValue> a = new List <tbl_ProductVariableValue>(); int productvariableid = Request.QueryString["productvariableid"].ToInt(0); if (productvariableid > 0) { var pv = ProductVariableController.GetByID(productvariableid); if (pv != null) { ltrBack.Text = "<a href=\"/thuoc-tinh-san-pham?id=" + pv.ProductID + "\" class=\"btn primary-btn h45-btn\">Trở về</a>"; lblCategoryName.Text = "Giá trị thuộc tính sản phẩm"; ltrAddnew.Text = "<a href=\"/them-gia-tri-thuoc-tinh?productvariableid=" + productvariableid + "\" class=\"h45-btn btn\" style=\"background-color: #ff3f4c\">Thêm mới</a>"; } a = ProductVariableValueController.GetByProductVariableID(productvariableid); pagingall(a); } }
public void LoadData() { int id = Request.QueryString["id"].ToInt(0); if (id > 0) { var pvv = ProductVariableValueController.GetByID(id); if (pvv != null) { ViewState["ID"] = id; int productvariableid = Convert.ToInt32(pvv.ProductVariableID); if (productvariableid > 0) { int variableID = 0; var variablevalue = VariableValueController.GetByID(Convert.ToInt32(pvv.VariableValueID)); if (variablevalue != null) { variableID = Convert.ToInt32(variablevalue.VariableID); } ddlVariable.SelectedValue = variableID.ToString(); var vv = VariableValueController.GetByVariableIDIsHidden(Convert.ToInt32(variableID), false); ddlVariableValue.Items.Clear(); ddlVariableValue.Items.Insert(0, new ListItem("-- Chọn --", "0")); ddlVariableValue.DataSource = vv; ddlVariableValue.DataBind(); ddlVariableValue.SelectedValue = pvv.VariableValueID.ToString(); chkIsHidden.Checked = Convert.ToBoolean(pvv.IsHidden); var pv = ProductVariableController.GetByID(productvariableid); if (pv != null) { ViewState["productvariableid"] = productvariableid; ViewState["ProductvariableSKU"] = pv.SKU; ltrBack.Text = "<a href=\"/gia-tri-thuoc-tinh-san-pham?productvariableid=" + productvariableid + "\" class=\"btn primary-btn fw-btn not-fullwidth\">Trở về</a>"; } } } } }
public void _createVariationValue(VariationValueUpdateModel variationValue) { var variationValueIDList = variationValue.variationValueID.Split('|').Where(x => !String.IsNullOrEmpty(x)).ToList(); var variationNameList = variationValue.variationName.Split('|').Where(x => !String.IsNullOrEmpty(x)).ToList(); var variationValueNameList = variationValue.variationValueName.Split('|').Where(x => !String.IsNullOrEmpty(x)).ToList(); for (int index = 0; index < variationValueIDList.Count; index++) { var variableValueID = variationValueIDList[index].ToInt(); string variableName = variationNameList[index]; string variableValueName = variationValueNameList[index]; ProductVariableValueController.Insert( ProductVariableID: variationValue.productVariationID, ProductvariableSKU: variationValue.productVariationSKU, VariableValueID: variableValueID, VariableName: variableName, VariableValue: variableValueName, IsHidden: variationValue.isHidden, CreatedDate: variationValue.createdDate, CreatedBy: variationValue.createdBy ); } }
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 void LoadData() { int n; if (String.IsNullOrEmpty(Request.QueryString["id"]) || !int.TryParse(Request.QueryString["id"], out n)) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng", "e", true, "/danh-sach-don-tra-hang", Page); } string username = Request.Cookies["usernameLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { int AgentID = Convert.ToInt32(acc.AgentID); int ID = Request.QueryString["id"].ToInt(0); if (ID > 0) { ViewState["ID"] = ID; var r = RefundGoodController.GetByIDAndAgentID(ID, AgentID); if (r == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng " + ID, "e", true, "/danh-sach-don-tra-hang", Page); } else { if (acc.RoleID != 0) { // Kiểm tra nếu đơn hàng này không "chính chủ" if (r.CreatedBy != acc.Username) { // Kiểm tra đơn hàng này có đang được tạo giúp bởi nhân viên khác không? var usernameRequest = HttpContext.Current.Request["username"]; if (!String.IsNullOrEmpty(usernameRequest)) { var userRequest = AccountController.GetByUsername(usernameRequest); if (userRequest == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy nhân viên " + usernameRequest, "e", true, "/danh-sach-don-tra-hang", Page); } else { if (usernameRequest != r.CreatedBy) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của " + usernameRequest, "e", true, "/danh-sach-don-tra-hang", Page); } else { if (r.UserHelp != acc.Username) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải do bạn tạo giúp", "e", true, "/danh-sach-don-tra-hang", Page); } else { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này do bạn tạo giúp. Nhấn OK để tiếp tục xử lý!", "i", false, "", Page); } } } } else { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của bạn", "e", true, "/danh-sach-don-tra-hang", Page); } } } ltrCreateBy.Text = r.CreatedBy; ltrCreateDate.Text = r.CreatedDate.ToString(); ltrOrderStatus.Text = PJUtils.RefundStatus(Convert.ToInt32(r.Status)); if (r.OrderSaleID > 0) { ltrOrderSaleID.Text = "<td><a class='customer-name-link' target='_blank' title='Bấm vào xem đơn hàng trừ tiền' href='/thong-tin-don-hang?id=" + r.OrderSaleID + "'>" + r.OrderSaleID + " (Xem đơn)</a>"; } else { ltrOrderSaleID.Text = ""; } ltrOrderQuantity.Text = r.TotalQuantity.ToString(); ltrOrderTotalPrice.Text = string.Format("{0:N0}", (Convert.ToDouble(r.TotalPrice))); ltrTotalRefundFee.Text = string.Format("{0:N0}", (Convert.ToDouble(r.TotalRefundFee))); ltrRefundNote.Text = r.RefundNote; int cusID = 0; string zalo = ""; string nick = ""; string address = ""; string facebook = ""; var cus = CustomerController.GetByID(r.CustomerID.Value); if (cus != null) { cusID = cus.ID; zalo = cus.Zalo; nick = cus.Nick; address = cus.CustomerAddress; facebook = cus.Facebook; hdfCustomerPhone.Value = cus.CustomerPhone; } // Title this.Title = String.Format("{0} - Đổi trả", string.IsNullOrEmpty(nick) ? nick.ToTitleCase() : r.CustomerName.ToTitleCase()); ltrHeading.Text = "Đơn đổi trả " + ID.ToString() + " - " + (string.IsNullOrEmpty(nick) ? nick.ToTitleCase() : r.CustomerName.ToTitleCase()) + (!string.IsNullOrEmpty(r.UserHelp) ? " (được tạo giúp bởi " + r.UserHelp + ")" : ""); ltrInfo.Text += "<div class='row'>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Họ tên</label>"; ltrInfo.Text += " <span class='form-control input-disabled'>" + r.CustomerName + "</span>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Điện thoại</label>"; ltrInfo.Text += " <span class='form-control input-disabled'>" + r.CustomerPhone + "</span>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Nick đặt hàng</label>"; ltrInfo.Text += " <span class='form-control input-disabled'>" + nick + "</span>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Facebook</label>"; ltrInfo.Text += " <span class='form-control input-disabled'>" + facebook + "</span>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += "</div> "; ltrInfo.Text += "<div class='row'>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Tỉnh thành</label>"; ltrInfo.Text += " <select id='_ddlProvince' class='form-control' disable='true' readonly='readonly'></select>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Quận huyện</label>"; ltrInfo.Text += " <select id='_ddlDistrict' class='form-control' disable='true' readonly='readonly'></select>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Phường xã</label>"; ltrInfo.Text += " <select id='_ddlWard' class='form-control' disable='true' readonly='readonly'></select>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " <div class='col-md-3'>"; ltrInfo.Text += " <div class='form-group'>"; ltrInfo.Text += " <label>Địa chỉ</label>"; ltrInfo.Text += " <span class='form-control input-disabled'>" + address + "</span>"; ltrInfo.Text += " </div>"; ltrInfo.Text += " </div>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "<div class='form-row view-detail'>"; ltrInfo.Text += " <a href='javascript:;' class='btn primary-btn fw-btn not-fullwidth' onclick='viewCustomerDetail(`" + cusID + "`)'><i class='fa fa-address-card-o' aria-hidden='true'></i> Xem</a>"; ltrInfo.Text += "</div>"; #region Thông tin phí đổi tra double feeRefundDefault = 0; var discount = DiscountCustomerController.getbyCustID(cusID).FirstOrDefault(); if (discount != null) { feeRefundDefault = discount.FeeRefund; ltrInfo.Text += "<div class='form-row discount-info'>"; ltrInfo.Text += String.Format(" <strong>* Chiết khấu của khách: {0:0,0}/cái. (đơn từ {1:N0} cái)</strong>", discount.DiscountAmount, discount.QuantityProduct); ltrInfo.Text += "</div>"; } else { var config = ConfigController.GetByTop1(); feeRefundDefault = config.FeeChangeProduct.Value; } var refundPromotion = RefundGoodController.getPromotion(cusID); if (refundPromotion.IsPromotion) { feeRefundDefault = (feeRefundDefault - refundPromotion.DecreasePrice) < 0 ? 0 : feeRefundDefault - refundPromotion.DecreasePrice; } ltrInfo.Text += "<div class='form-row refund-info'>"; if (feeRefundDefault == 0) { ltrInfo.Text += " <strong>* Miễn phí đổi hàng</strong>"; } else { ltrInfo.Text += String.Format(" <strong>* Phí đổi trả hàng: {0:0,0}/cái.</strong>", feeRefundDefault); } ltrInfo.Text += "</div>"; if (UserController.checkExists(cusID)) { ltrInfo.Text += "<div class='form-row refund-info'>"; ltrInfo.Text += " <strong class='font-green'>Đã đăng ký App</strong>"; ltrInfo.Text += "</div>"; } else { ltrInfo.Text += "<div class='form-row refund-info'>"; ltrInfo.Text += " <strong class='font-red'>Chưa đăng ký App</strong>"; ltrInfo.Text += "</div>"; } #endregion ltrTotal.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalPrice)); ltrQuantity.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalQuantity)); ltrRefund.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalRefundFee)); // get info tranfor page tao-don-hang-doi-tra.aspx _refundGood.RefundGoodsID = ID; _refundGood.CustomerID = r.CustomerID.Value; _refundGood.CustomerName = r.CustomerName; _refundGood.CustomerPhone = r.CustomerPhone; _refundGood.CustomerNick = cus != null ? cus.Nick : String.Empty; _refundGood.CustomerAddress = cus != null ? cus.CustomerAddress : String.Empty; _refundGood.CustomerZalo = cus != null ? cus.Zalo : String.Empty; _refundGood.CustomerFacebook = cus != null ? cus.Facebook : String.Empty; _refundGood.RefundDetails = RefundGoodDetailController.GetInfoShowRefundDetail(ID, feeRefundDefault); _refundGood.TotalPrice = Convert.ToDouble(r.TotalPrice); _refundGood.TotalQuantity = Convert.ToDouble(r.TotalQuantity); _refundGood.TotalFreeRefund = Convert.ToDouble(r.TotalRefundFee); _refundGood.Status = r.Status.Value; _refundGood.Note = txtRefundsNote.Text; _refundGood.CreateBy = r.CreatedBy; var rds = RefundGoodDetailController.GetByRefundGoodsID(ID); var product = _refundGood.RefundDetails .Join( rds, p1 => new { RefundGoodsID = p1.RefundGoodsID, RefundDetailID = p1.RefundDetailID }, p2 => new { RefundGoodsID = p2.RefundGoodsID.Value, RefundDetailID = p2.ID }, (p1, p2) => new { p1, p2 }) .Select(x => new { SKU = x.p2.SKU, OrderID = x.p2.OrderID, ProductName = x.p2.ProductName, ProductType = x.p2.ProductType, GiavonPerProduct = x.p2.GiavonPerProduct, SoldPricePerProduct = x.p2.SoldPricePerProduct, DiscountPricePerProduct = x.p2.DiscountPricePerProduct, Quantity = x.p2.Quantity, QuantityMax = x.p2.QuantityMax, RefundType = x.p2.RefundType, RefundFeePerProduct = x.p2.RefundFeePerProduct, TotalPriceRow = x.p2.TotalPriceRow, ProductImage = x.p1.ProductImage }) .ToList(); if (product.Count > 0) { string html = ""; int t = 0; foreach (var item in product) { var variables = ProductVariableValueController.GetByProductVariableSKU(item.SKU); string variable = ""; if (variables.Count > 0) { variable += "<br><br>"; foreach (var v in variables) { variable += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "<br>"; } } t++; html += "<tr ondblclick='clickrow($(this))' class='product-result' data-sku='" + item.SKU + "' data-orderID='" + item.OrderID + "' data-ProductName='" + item.ProductName + "' data-ProductType='" + item.ProductType + "' data-Giagoc='" + item.GiavonPerProduct + "' data-Giadaban='" + item.SoldPricePerProduct + "' data-TienGiam='" + item.DiscountPricePerProduct + "' data-Soluongtoida='" + item.QuantityMax + "' data-RefundFee='" + item.RefundFeePerProduct + "'>"; html += " <td>" + t + "</td>"; html += " <td class='image-item'><img src='" + Thumbnail.getURL(item.ProductImage, Thumbnail.Size.Small) + "'></td>"; html += " <td class='name-item'><a href='/xem-san-pham?sku=" + item.SKU + "' target='_blank'>" + item.ProductName + "</a>" + variable + "</td>"; html += " <td class='sku-item'>" + item.SKU + "</td>"; html += " <td class='price-item giagoc' data-giagoc='" + item.GiavonPerProduct + "'>" + string.Format("{0:N0}", Convert.ToDouble(item.GiavonPerProduct)) + "</td>"; html += " <td class='giadaban' data-giadaban='" + item.SoldPricePerProduct + "'><strong>" + string.Format("{0:N0}", Convert.ToDouble(item.SoldPricePerProduct)) + "</strong><br>(CK: " + string.Format("{0:N0}", Convert.ToDouble(item.DiscountPricePerProduct)) + ")</td>"; html += " <td class='slcandoi'>" + item.Quantity + "</td>"; html += " <td>"; int refundType = Convert.ToInt32(item.RefundType); string refuntTypeName = ""; if (item.RefundType == 1) { refuntTypeName = "Đổi size"; } else if (item.RefundType == 2) { refuntTypeName = "Đổi sản phẩm khác"; } else if (item.RefundType == 4) { refuntTypeName = "Đổi sản phẩm khác (miễn phí)"; } else { refuntTypeName = "Đổi hàng lỗi"; } html += refuntTypeName; html += " </td>"; html += " <td class='phidoihang'>" + string.Format("{0:N0}", Convert.ToDouble(item.RefundFeePerProduct)) + "</td>"; html += " <td class='thanhtien'>" + string.Format("{0:N0}", Convert.ToDouble(item.TotalPriceRow)) + "</td>"; html += "</tr>"; } ddlRefundStatus.SelectedValue = r.Status.ToString(); txtRefundsNote.Text = r.RefundNote; ltrList.Text = html; } ltrPrint.Text = "<a href='/print-invoice-return?id=" + ID + "' target='_blank' class='btn primary-btn fw-btn not-fullwidth'><i class='fa fa-print' aria-hidden='true'></i> In hóa đơn</a>"; ltrPrint.Text += "<a href='/print-return-order-image?id=" + ID + "' target='_blank' class='btn primary-btn btn-blue fw-btn not-fullwidth print-invoice-merged'><i class='fa fa-picture-o' aria-hidden='true'></i> Lấy ảnh đơn hàng</a>"; } } } }
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 static string copyProductInfo(int id) { var product = ProductController.GetByID(id); StringBuilder html = new StringBuilder(); if (product != null) { html.Append("<p>" + product.ProductSKU + " - Sỉ " + (product.Regular_Price / 1000).ToString() + "k - " + product.ProductTitle + "</p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>📌 Giá sỉ: " + (product.Regular_Price / 1000).ToString() + "k</p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>📌 Giá lẻ: " + ((product.Retail_Price + 25000) / 1000).ToString() + "k</p>\r\n"); html.Append("<p></p>\r\n"); if (!string.IsNullOrEmpty(product.Materials)) { html.Append("<p>🔖 Chất liệu: " + product.Materials + "</p>\r\n"); html.Append("<p></p>\r\n"); } if (!string.IsNullOrEmpty(product.ProductContent)) { html.Append("<p>🔖 Mô tả: " + product.ProductContent + "</p>\r\n"); html.Append("<p></p>\r\n"); } // liệt kê thuộc tính sản phẩm List<ProductVariable> variableTemp = new List<ProductVariable>(); List<tbl_ProductVariable> v = new List<tbl_ProductVariable>(); v = ProductVariableController.SearchProductID(id, ""); string Variable = ""; if (v.Count > 0) { for (int i = 0; i < v.Count; i++) { var item = v[i]; var value = ProductVariableValueController.GetByProductVariableIDSortByName(item.ID); if (value != null) { for (int j = 0; j < value.Count; j++) { variableTemp.Add(new ProductVariable() { VariableName = value[j].VariableName, VariableValue = value[j].VariableValue }); } } } var vari = variableTemp.GroupBy(x => new { x.VariableName, x.VariableValue }).Select(x => new { VariableName = x.Key.VariableName, VariableValue = x.Key.VariableValue }).OrderBy(x => x.VariableName).ToList(); string stringVariable = vari[0].VariableName; Variable = "<p><strong>📚 " + vari[0].VariableName + "</strong>: "; for (int y = 0; y < vari.Count; y++) { if (stringVariable == vari[y].VariableName) { Variable += vari[y].VariableValue + "; "; } else { Variable += "</p>\r\n"; Variable += "<p></p>\r\n"; Variable += "<p><strong>📐 " + vari[y].VariableName + "</strong>: " + vari[y].VariableValue + "; "; stringVariable = vari[y].VariableName; } } html.Append(Variable); } // thông tin liên hệ html.Append("<p></p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>-----------------------------------------------------------</p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>⚡⚡ Hàng có sẵn tại KHO HÀNG SỈ ANN ⚡⚡</p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>🏭 68 Đường C12, P.13, Tân Bình, TP.HCM</p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>⭐ Web: ANN.COM.VN</p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>⭐ Zalo đặt hàng: 0936786404 - 0913268406 - 0918567409</p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>⭐ Facebook: https://facebook.com/bosiquanao.net </p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>⭐ Zalo xem Quần Áo Nam: 0977399405 (Zalo này không trả lời tin nhắn)</p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>⭐ Zalo xem Đồ Bộ Nữ: 0975442402 (Zalo này không trả lời tin nhắn)</p>\r\n"); html.Append("<p></p>\r\n"); html.Append("<p>⭐ Zalo xem Váy Đầm - Áo Nữ - Quần Nữ: 0987409403 (Zalo này không trả lời tin nhắn)</p>\r\n"); html.Append("<p></p>\r\n"); } return html.ToString(); }
public static string getOrder(int ID) { JavaScriptSerializer serializer = new JavaScriptSerializer(); string username = HttpContext.Current.Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { int AgentID = Convert.ToInt32(acc.AgentID); var agent = AgentController.GetByID(AgentID); if (agent != null) { } //List<GetOutOrder> go = new List<GetOutOrder>(); GetOutRefundOrder getOrder = new GetOutRefundOrder(); var refund = RefundGoodController.GetByID(ID); if (refund != null) { var refunddetail = RefundGoodDetailController.GetByRefundGoodsID(refund.ID); if (refunddetail != null) { //table 1 getOrder.ID = refund.ID; getOrder.CustomerName = refund.CustomerName; getOrder.CustomerPhone = refund.CustomerPhone; if (refund.Status == 1) { getOrder.Status = "Chưa trừ tiền"; } if (refund.Status == 2) { getOrder.Status = "Đã trừ tiền"; } getOrder.CreatedBy = refund.CreatedBy; getOrder.CreateDate = string.Format("{0:dd/MM/yyyy}", refund.CreatedDate); getOrder.ListAgent += agent.AgentAddress + "|"; getOrder.ListAgent += agent.AgentPhone; for (int j = 0; j < refunddetail.Count(); j++) { getOrder.ListProduct += refunddetail[j].SKU + ";" + refunddetail[j].ProductName + ";"; var productvalue = ProductVariableValueController.GetByProductVariableSKU(refunddetail[j].SKU); string value = ""; if (productvalue != null) { foreach (var item in productvalue) { value += item.VariableName + ":" + item.VariableValue + "|"; } } getOrder.ListProduct += value + ";" + refunddetail[j].Quantity + ";" + refunddetail[j].SoldPricePerProduct + ";" + refunddetail[j].RefundFeePerProduct + ";" + refunddetail[j].TotalPriceRow + "*"; } getOrder.TotalQuantity = Convert.ToInt32(refund.TotalQuantity); getOrder.TotalPrice = Convert.ToInt32(refund.TotalPrice); getOrder.TotalRefundPrice = Convert.ToInt32(refund.TotalRefundFee); } } return(serializer.Serialize(getOrder)); } return(serializer.Serialize(null)); }
public static string copyProductInfo(int id) { var product = ProductController.GetByID(id); StringBuilder html = new StringBuilder(); if (product != null) { html.AppendLine("<p>" + product.ProductSKU + " - " + product.ProductTitle + "</p>\r\n"); html.AppendLine("<p>📌 Sỉ: " + (product.Regular_Price / 1000).ToString() + "k</p>\r\n"); html.AppendLine("<p>📌 Lẻ: " + (product.Retail_Price / 1000).ToString() + "k</p>\r\n"); if (!string.IsNullOrEmpty(product.Materials)) { html.AppendLine("<p>🔖 " + (product.CategoryID == 44 ? "" : "Chất liệu: ") + product.Materials + "</p>\r\n"); } if (!string.IsNullOrEmpty(product.ProductContent)) { string content = Regex.Replace(product.ProductContent, @"<img\s[^>]*>(?:\s*?</img>)?", "").ToString(); html.AppendLine("<p>🔖 " + content + "</p>\r\n"); } // liệt kê thuộc tính sản phẩm List <ProductVariable> variableTemp = new List <ProductVariable>(); List <tbl_ProductVariable> v = new List <tbl_ProductVariable>(); v = ProductVariableController.SearchProductID(id, ""); string Variable = ""; if (v.Count > 0) { for (int i = 0; i < v.Count; i++) { var item = v[i]; var value = ProductVariableValueController.GetByProductVariableIDSortByName(item.ID); if (value != null) { for (int j = 0; j < value.Count; j++) { variableTemp.Add(new ProductVariable() { VariableName = value[j].VariableName, VariableValue = value[j].VariableValue }); } } } var vari = variableTemp .GroupBy(x => new { x.VariableName, x.VariableValue }) .Select(x => new { VariableName = x.Key.VariableName, VariableValue = x.Key.VariableValue }) .OrderBy(x => x.VariableName) .ToList(); string stringVariable = vari[0].VariableName; Variable = "<p><strong>📚 " + vari[0].VariableName + "</strong>: "; int count = 0; for (int y = 0; y < vari.Count; y++) { if (stringVariable == vari[y].VariableName) { if (vari[y].VariableValue.IndexOf("Mẫu") >= 0) { count = count + 1; if (y == (vari.Count - 1)) { Variable += count.ToString() + " mẫu khác nhau"; } } else { Variable += vari[y].VariableValue + "; "; } } else { if (count > 0) { Variable += count.ToString() + " mẫu khác nhau"; } Variable += "</p>\r\n"; Variable += "<p><strong>📐 " + vari[y].VariableName + "</strong>: " + vari[y].VariableValue + "; "; stringVariable = vari[y].VariableName; } } html.AppendLine(Variable); } html.AppendLine("<p></p>\r\n"); } return(html.ToString()); }
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)); }
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 LoadData() { string username = Request.Cookies["userLoginSystem"].Value; var acc = AccountController.GetByUsername(username); if (acc != null) { int AgentID = Convert.ToInt32(acc.AgentID); int ID = Request.QueryString["id"].ToInt(0); if (ID > 0) { ViewState["ID"] = ID; var r = RefundGoodController.GetByIDAndAgentID(ID, AgentID); if (r == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy đơn hàng " + ID, "e", true, "/danh-sach-don-tra-hang", Page); } else { if (acc.RoleID != 0) { if (r.CreatedBy != acc.Username) { PJUtils.ShowMessageBoxSwAlertError("Đơn hàng này không phải của bạn", "e", true, "/danh-sach-don-tra-hang", Page); } } ltrOrderID.Text = ID.ToString(); ltrCreateBy.Text = r.CreatedBy; ltrCreateDate.Text = r.CreatedDate.ToString(); ltrOrderStatus.Text = PJUtils.RefundStatus(Convert.ToInt32(r.Status)); if (r.OrderSaleID > 0) { ltrOrderSaleID.Text = "<td><a class=\"customer-name-link\" target=\"_blank\" title=\"Bấm vào xem đơn hàng trừ tiền\" href=\"/thong-tin-don-hang?id=" + r.OrderSaleID + "\">" + r.OrderSaleID + " (Xem đơn)</a>"; } else { ltrOrderSaleID.Text = ""; } ltrOrderQuantity.Text = r.TotalQuantity.ToString(); ltrOrderTotalPrice.Text = string.Format("{0:N0}", (Convert.ToDouble(r.TotalPrice))); ltrTotalRefundFee.Text = string.Format("{0:N0}", (Convert.ToDouble(r.TotalRefundFee))); ltrRefundNote.Text = r.RefundNote; ltrInfo.Text += "<div class=\"row\">"; ltrInfo.Text += "<div class=\"col-md-6\">"; ltrInfo.Text += "<div class=\"form-group\">"; ltrInfo.Text += "<label>Họ tên</label>"; ltrInfo.Text += "<span class=\"form-control input-disabled\">" + r.CustomerName + "</span>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "<div class=\"col-md-6\">"; ltrInfo.Text += "<div class=\"form-group\">"; ltrInfo.Text += "<label>Điện thoại</label>"; ltrInfo.Text += "<span class=\"form-control input-disabled\">" + r.CustomerPhone + "</span>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "</div>"; var cus = CustomerController.GetByID(r.CustomerID.Value); if (cus != null) { ltrInfo.Text += "<div class=\"row\">"; ltrInfo.Text += "<div class=\"col-md-6\">"; ltrInfo.Text += "<div class=\"form-group\">"; ltrInfo.Text += "<label>Nick đặt hàng</label>"; ltrInfo.Text += "<span class=\"form-control input-disabled\">" + cus.Nick + "</span>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "<div class=\"col-md-6\">"; ltrInfo.Text += "<div class=\"form-group\">"; ltrInfo.Text += "<label>Địa chỉ</label>"; ltrInfo.Text += "<span class=\"form-control input-disabled\">" + cus.CustomerAddress + "</span>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "<div class=\"row\">"; ltrInfo.Text += "<div class=\"col-md-6\">"; ltrInfo.Text += "<div class=\"form-group\">"; ltrInfo.Text += "<label>Zalo</label>"; ltrInfo.Text += "<span class=\"form-control input-disabled\">" + cus.Zalo + "</span>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "<div class=\"col-md-6\">"; ltrInfo.Text += "<div class=\"form-group\">"; ltrInfo.Text += "<label>Facebook</label>"; ltrInfo.Text += "<span class=\"form-control input-disabled\">" + cus.Facebook + "</span>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "</div>"; ltrInfo.Text += "<div class=\"row\">"; ltrInfo.Text += " <div class=\"col-md-12 view-detail\">"; ltrInfo.Text += " <a href=\"javascript:;\" class=\"btn primary-btn fw-btn not-fullwidth\" onclick=\"viewCustomerDetail('"+ cus.ID + "')\"><i class=\"fa fa-address-card-o\" aria-hidden=\"true\"></i> Xem chi tiết</a>"; ltrInfo.Text += " </div>"; ltrInfo.Text += "</div>"; } ltrTotal.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalPrice)); ltrQuantity.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalQuantity)); ltrRefund.Text = string.Format("{0:N0}", Convert.ToDouble(r.TotalRefundFee)); // get info tranfor page tao-don-hang-doi-tra.aspx _refundGood.RefundGoodsID = ID; _refundGood.CustomerName = r.CustomerName; _refundGood.CustomerPhone = r.CustomerPhone; _refundGood.CustomerNick = cus != null? cus.Nick : String.Empty; _refundGood.CustomerAddress = cus != null ? cus.CustomerAddress : String.Empty; _refundGood.CustomerZalo = cus != null ? cus.Zalo : String.Empty; _refundGood.CustomerFacebook = cus != null ? cus.Facebook : String.Empty; _refundGood.RefundDetails = RefundGoodDetailController.GetInfoShowRefundDetail(ID); _refundGood.TotalPrice = Convert.ToDouble(r.TotalPrice); _refundGood.TotalQuantity = Convert.ToDouble(r.TotalQuantity); _refundGood.TotalFreeRefund = Convert.ToDouble(r.TotalRefundFee); _refundGood.Status = r.Status.Value; _refundGood.Note = txtRefundsNote.Text; _refundGood.CreateBy = r.CreatedBy; var rds = RefundGoodDetailController.GetByRefundGoodsID(ID); var product = _refundGood.RefundDetails .Join( rds, p1 => new { RefundGoodsID = p1.RefundGoodsID, RefundDetailID = p1.RefundDetailID }, p2 => new { RefundGoodsID = p2.RefundGoodsID.Value, RefundDetailID = p2.ID }, (p1, p2) => new { p1, p2 }) .Select(x => new { SKU = x.p2.SKU, OrderID = x.p2.OrderID, ProductName = x.p2.ProductName, ProductType = x.p2.ProductType, GiavonPerProduct = x.p2.GiavonPerProduct, SoldPricePerProduct = x.p2.SoldPricePerProduct, DiscountPricePerProduct = x.p2.DiscountPricePerProduct, Quantity = x.p2.Quantity, QuantityMax = x.p2.QuantityMax, RefundType = x.p2.RefundType, RefundFeePerProduct = x.p2.RefundFeePerProduct, TotalPriceRow = x.p2.TotalPriceRow, ProductImage = x.p1.ProductImage }) .ToList(); if (product.Count > 0) { string html = ""; int t = 0; foreach (var item in product) { var variables = ProductVariableValueController.GetByProductVariableSKU(item.SKU); string variable = ""; if (variables.Count > 0) { variable += "<br><br>"; foreach (var v in variables) { variable += v.VariableName.Trim() + ": " + v.VariableValue.Trim() + "<br>"; } } t++; html += "<tr ondblclick=\"clickrow($(this))\" class=\"product-result\" data-sku=\"" + item.SKU + "\" data-orderID=\"" + item.OrderID + "\" data-ProductName=\"" + item.ProductName + "\" data-ProductType=\"" + item.ProductType + "\" data-Giagoc=\"" + item.GiavonPerProduct + "\" data-Giadaban=\"" + item.SoldPricePerProduct + "\" data-TienGiam=\"" + item.DiscountPricePerProduct + "\" data-Soluongtoida=\"" + item.QuantityMax + "\" data-RefundFee=\"" + item.RefundFeePerProduct + "\" >"; html += " <td>" + t + "</td>"; html += " <td><img src='" + item.ProductImage + "'></td>"; html += " <td>" + item.ProductName + variable + "</td>"; html += " <td>" + item.SKU + "</td>"; html += " <td class=\"giagoc\" data-giagoc=\"" + item.GiavonPerProduct + "\">" + string.Format("{0:N0}", Convert.ToDouble(item.GiavonPerProduct)) + "</td>"; html += " <td class=\"giadaban\" data-giadaban=\"" + item.SoldPricePerProduct + "\"><strong>" + string.Format("{0:N0}", Convert.ToDouble(item.SoldPricePerProduct)) + "</strong><br>(CK: " + string.Format("{0:N0}", Convert.ToDouble(item.DiscountPricePerProduct)) + ")</td>"; html += " <td class=\"slcandoi\">" + item.Quantity + "</td>"; html += " <td>"; int refundType = Convert.ToInt32(item.RefundType); string refuntTypeName = ""; if (item.RefundType == 1) { refuntTypeName = "Đổi size"; } else if (item.RefundType == 2) { refuntTypeName = "Đổi sản phẩm khác"; } else { refuntTypeName = "Đổi hàng lỗi"; } html += refuntTypeName; html += " </td>"; html += " <td class=\"phidoihang\">" + string.Format("{0:N0}", Convert.ToDouble(item.RefundFeePerProduct)) + "</td>"; html += " <td class=\"thanhtien\">" + string.Format("{0:N0}", Convert.ToDouble(item.TotalPriceRow)) + "</td>"; html += "</tr>"; } ddlRefundStatus.SelectedValue = r.Status.ToString(); txtRefundsNote.Text = r.RefundNote; ltrList.Text = html; } ltrPrint.Text = "<a href=\"/print-invoice-return?id=" + ID + "\" target=\"_blank\" class=\"btn primary-btn fw-btn not-fullwidth\"><i class=\"fa fa-print\" aria-hidden=\"true\"></i> In hóa đơn</a>"; ltrPrint.Text += "<a href=\"/print-return-order-image?id=" + ID + "\" target=\"_blank\" class=\"btn primary-btn fw-btn not-fullwidth print-invoice-merged\"><i class=\"fa fa-picture-o\" aria-hidden=\"true\"></i> Lấy ảnh đơn hàng</a>"; } } } }
public static string getProduct(string textsearch) { 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); var products = ProductController.GetBySKU(textsearch.Trim().ToUpper()); if (products != null) { var productvariable = ProductVariableController.GetByParentSKU(products.ProductSKU); if (productvariable.Count > 0) { foreach (var pv in productvariable) { var variables = ProductVariableValueController.GetByProductVariableSKU(pv.SKU); 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 onclick='openImage($(this))' src='" + Thumbnail.getURL(pv.Image, Thumbnail.Size.Normal) + "'>"; p.ProductImageOrigin = Thumbnail.getURL(pv.Image, Thumbnail.Size.Source); p.SKU = pv.SKU.Trim().ToUpper(); 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; double total = PJUtils.TotalProductQuantityInstock(AgentID, pv.SKU); p.WarehouseQuantity = string.Format("{0:N0}", total); ps.Add(p); } } } else { 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; p.ProductImage = "<img onclick='openImage($(this))' src='" + Thumbnail.getURL(products.ProductImage, Thumbnail.Size.Normal) + "'>"; p.ProductImageOrigin = Thumbnail.getURL(products.ProductImage, Thumbnail.Size.Source); p.SKU = products.ProductSKU.Trim().ToUpper(); 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; double total = PJUtils.TotalProductQuantityInstock(AgentID, products.ProductSKU); p.WarehouseQuantity = string.Format("{0:N0}", total); ps.Add(p); } } else { var productvariable = ProductVariableController.GetAllBySKU(textsearch.Trim().ToUpper()); if (productvariable != null) { foreach (var value in productvariable) { var variables = ProductVariableValueController.GetByProductVariableSKU(value.SKU); 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 = value.ID; var product = ProductController.GetBySKU(value.ParentSKU); if (product != null) { p.ProductName = product.ProductTitle; } p.ProductVariable = variable; p.ProductVariableName = variablename; p.ProductVariableValue = variablevalue; p.ProductType = 2; p.ProductImage = "<img onclick='openImage($(this))' src='" + Thumbnail.getURL(value.Image, Thumbnail.Size.Normal) + "'>"; p.ProductImageOrigin = Thumbnail.getURL(value.Image, Thumbnail.Size.Source); p.SKU = value.SKU.Trim().ToUpper(); int supplierID = 0; if (value.SupplierID != null) { supplierID = value.SupplierID.ToString().ToInt(0); } p.SupplierID = supplierID; string supplierName = ""; if (!string.IsNullOrEmpty(value.SupplierName)) { supplierName = value.SupplierName; } p.SupplierName = supplierName; double total = PJUtils.TotalProductQuantityInstock(AgentID, value.SKU); p.WarehouseQuantity = string.Format("{0:N0}", total); ps.Add(p); } } } } } JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(ps)); }
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)); }
public void pagingall(List <tbl_ProductVariable> acs) { string productname = ViewState["ProductName"].ToString(); int PageSize = 15; StringBuilder html = new StringBuilder(); if (acs.Count > 0) { int TotalItems = acs.Count; if (TotalItems % PageSize == 0) { PageCount = TotalItems / PageSize; } else { PageCount = TotalItems / PageSize + 1; } Int32 Page = GetIntFromQueryString("Page"); if (Page == -1) { Page = 1; } int FromRow = (Page - 1) * PageSize; int ToRow = Page * PageSize - 1; if (ToRow >= TotalItems) { ToRow = TotalItems - 1; } for (int i = FromRow; i < ToRow + 1; i++) { var item = acs[i]; html.Append("<tr>"); if (!string.IsNullOrEmpty(item.Image)) { html.Append(" <td><img src=\"" + item.Image + "\"/></td>"); } else { html.Append(" <td><img src=\"/App_Themes/Ann/image/placeholder.png\"/></td>"); } string date = string.Format("{0:dd/MM/yyyy}", item.CreatedDate); string ishidden = ""; if (item.IsHidden != null) { bool IsHidden = Convert.ToBoolean(item.IsHidden); ishidden = PJUtils.IsHiddenStatus(IsHidden); } else { ishidden = PJUtils.IsHiddenStatus(false); } var value = ProductVariableValueController.GetByProductVariableID(item.ID); if (value != null) { html.Append(" <td>"); string list = ""; foreach (var temp in value) { html.Append("" + temp.VariableName + ": " + temp.VariableValue + "</br>" + ""); list += temp.VariableName + "|"; } html.Append("</td>"); hdfSearch.Value = list; } html.Append(" <td>" + item.SKU + "</td>"); html.Append(" <td>" + string.Format("{0:N0}", item.Regular_Price) + "</td>"); int k = Convert.ToInt32(ViewState["role"]); if (k == 0) { html.Append(" <td>" + string.Format("{0:N0}", item.CostOfGood) + "</td>"); } html.Append(" <td>" + string.Format("{0:N0}", item.RetailPrice) + "</td>"); html.Append(" <td>" + PJUtils.TotalProductQuantityInstock(1, item.SKU) + "</td>"); html.Append(" <td>" + PJUtils.StockStatusBySKU(1, item.SKU) + "</td>"); html.Append(" <td>" + date + "</td>"); html.Append(" <td>" + ishidden + "</td>"); html.Append(" <td>"); html.Append(" <a href=\"/thong-tin-thuoc-tinh-san-pham.aspx?id=" + item.ID + "\" title=\"Xem chi tiết\" class=\"btn primary-btn h45-btn\"><i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>"); html.Append(" <a href=\"/gia-tri-thuoc-tinh-san-pham.aspx?productvariableid=" + item.ID + "\" title=\"Xem thuộc tính\" class=\"btn primary-btn h45-btn\"><i class=\"fa fa-file-text-o\" aria-hidden=\"true\"></i></a>"); html.Append(" </td>"); html.Append("</tr>"); } } ltrList.Text = html.ToString(); }
public void pagingall(List <tbl_ProductVariable> acs, int userRole) { int PageSize = 40; StringBuilder html = new StringBuilder(); if (acs.Count > 0) { int TotalItems = acs.Count; if (TotalItems % PageSize == 0) { PageCount = TotalItems / PageSize; } else { PageCount = TotalItems / PageSize + 1; } Int32 Page = GetIntFromQueryString("Page"); if (Page == -1) { Page = 1; } int FromRow = (Page - 1) * PageSize; int ToRow = Page * PageSize - 1; if (ToRow >= TotalItems) { ToRow = TotalItems - 1; } html.Append("<tr>"); html.Append(" <th class='image-column'>Ảnh</th>"); html.Append(" <th class='variable-column'>Thuộc tính</th>"); html.Append(" <th class='sku-column'>Mã</th>"); html.Append(" <th class='wholesale-price-column'>Giá sỉ</th>"); if (userRole == 0) { html.Append(" <th class='cost-price-column'>Giá vốn</th>"); } html.Append(" <th class='retail-price-column'>Giá lẻ</th>"); html.Append(" <th class='stock-column'>Kho</th>"); html.Append(" <th class='stock-status-column'>Trạng thái</th>"); html.Append(" <th class='date-column'>Ngày tạo</th>"); html.Append(" <th class='hide-column'>Ẩn</th>"); html.Append(" <th class='action-column'>Thao tác</th>"); html.Append("</tr>"); for (int i = FromRow; i < ToRow + 1; i++) { var item = acs[i]; var stock2 = StockManagerController.getQuantityStock2BySKU(item.SKU); html.Append("<tr>"); html.Append(" <td><img src='" + Thumbnail.getURL(item.Image, Thumbnail.Size.Small) + "'></td>"); string date = string.Format("{0:dd/MM/yyyy}", item.CreatedDate); string ishidden = ""; if (item.IsHidden != null) { bool IsHidden = Convert.ToBoolean(item.IsHidden); ishidden = PJUtils.IsHiddenStatus(IsHidden); } else { ishidden = PJUtils.IsHiddenStatus(false); } var value = ProductVariableValueController.GetByProductVariableID(item.ID); if (value != null) { html.Append(" <td>"); string list = ""; foreach (var temp in value) { html.Append("" + temp.VariableName + ": " + temp.VariableValue + "</br>" + ""); list += temp.VariableName + "|"; } html.Append("</td>"); } html.Append(" <td>" + item.SKU + "</td>"); html.Append(" <td>" + string.Format("{0:N0}", item.Regular_Price) + "</td>"); if (userRole == 0) { html.Append(" <td>" + string.Format("{0:N0}", item.CostOfGood) + "</td>"); } html.Append(" <td>" + string.Format("{0:N0}", item.RetailPrice) + "</td>"); if (stock2.HasValue) { html.Append(String.Format(" <td>{0:N0}<br>(Kho 2: {1:N0})</td>", PJUtils.TotalProductQuantityInstock(1, item.SKU), stock2.Value)); } else { html.Append(" <td>" + PJUtils.TotalProductQuantityInstock(1, item.SKU) + "</td>"); } html.Append(" <td>" + PJUtils.StockStatusBySKU(1, item.SKU) + "</td>"); html.Append(" <td>" + date + "</td>"); html.Append(" <td>" + ishidden + "</td>"); html.Append(" <td>"); html.Append(" <a href=\"/thong-tin-thuoc-tinh-san-pham?id=" + item.ID + "\" title=\"Xem chi tiết\" class=\"btn primary-btn h45-btn\"><i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>"); html.Append(" <a href=\"/gia-tri-thuoc-tinh-san-pham?productvariableid=" + item.ID + "\" title=\"Xem thuộc tính\" class=\"btn primary-btn h45-btn\"><i class=\"fa fa-file-text-o\" aria-hidden=\"true\"></i></a>"); html.Append(" </td>"); html.Append("</tr>"); } } ltrList.Text = html.ToString(); }
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 LoadData() { int id = Request.QueryString["id"].ToInt(0); if (id > 0) { var p = ProductController.GetByID(id); if (p == null) { PJUtils.ShowMessageBoxSwAlertError("Không tìm thấy sản phẩm " + id, "e", true, "/tat-ca-san-pham", Page); } else { ViewState["ID"] = id; ViewState["cateID"] = p.CategoryID; ViewState["SKU"] = p.ProductSKU; hdfParentID.Value = p.CategoryID.ToString(); hdfsetStyle.Value = p.ProductStyle.ToString(); ltrBack.Text = "<a href=\"/xem-san-pham?id=" + p.ID + "\" class=\"btn primary-btn fw-btn not-fullwidth\">Trở về</a>"; txtProductTitle.Text = p.ProductTitle; pContent.Content = p.ProductContent; txtProductSKU.Text = p.ProductSKU; pRegular_Price.Text = p.Regular_Price.ToString(); pCostOfGood.Text = p.CostOfGood.ToString(); pRetailPrice.Text = p.Retail_Price.ToString(); chkIsHidden.Checked = Convert.ToBoolean(p.IsHidden); ddlSupplier.SelectedValue = p.SupplierID.ToString(); ddlCategory.SelectedValue = p.CategoryID.ToString(); txtMaterials.Text = p.Materials; pMinimumInventoryLevel.Text = p.MinimumInventoryLevel.ToString(); pMaximumInventoryLevel.Text = p.MaximumInventoryLevel.ToString(); if (p.ProductImage != null) { ListProductThumbnail.Value = p.ProductImage; ProductThumbnail.ImageUrl = p.ProductImage; } var image = ProductImageController.GetByProductID(id); imageGallery.Text = "<ul class=\"image-gallery\">"; if (image != null) { foreach (var img in image) { imageGallery.Text += "<li><img src='" + img.ProductImage + "' /><a href='javascript:;' data-image-id='" + img.ID + "' onclick='deleteImageGallery($(this))' class='btn-delete'><i class=\"fa fa-times\" aria-hidden=\"true\"></i> Xóa hình</a></li>"; } } imageGallery.Text += "</ul>"; // Lấy tất cả biến thể ra List <tbl_ProductVariable> a = new List <tbl_ProductVariable>(); a = ProductVariableController.GetProductID(p.ID); if (a.Count > 0) { StringBuilder html = new StringBuilder(); int t = 1; foreach (var item in a) { string VariableSKU = item.SKU; double RegularPrice = Convert.ToDouble(item.Regular_Price); double RetailPrice = Convert.ToDouble(item.RetailPrice); double CostOfGood = Convert.ToDouble(item.CostOfGood); int MinimumInventoryLevel = Convert.ToInt32(item.MinimumInventoryLevel); int MaximumInventoryLevel = Convert.ToInt32(item.MaximumInventoryLevel); string VariableImage = "/App_Themes/Ann/image/placeholder.png"; string deleteVariableImage = "<a href='javascript:;' onclick='deleteImageVariable($(this))' class='btn-delete hide'><i class=\"fa fa-times\" aria-hidden=\"true\"></i> Xóa hình</a>"; if (!string.IsNullOrEmpty(item.Image)) { VariableImage = item.Image; deleteVariableImage = "<a href='javascript:;' onclick='deleteImageVariable($(this))' class='btn-delete'><i class=\"fa fa-times\" aria-hidden=\"true\"></i> Xóa hình</a>"; } var value = ProductVariableValueController.GetByProductVariableID(item.ID); string selectVariable = ""; string variableID = ""; string variableName = ""; string variableValueID = ""; string variableValueName = ""; string dataVariableValue = ""; string labelVariableValue = ""; if (value != null) { foreach (var temp in value) { selectVariable += "<div class='row margin-bottom-15'><div class='col-md-5'>" + temp.VariableName + "</div><div class='col-md-7'>" + getSelectVariable(temp.VariableName, temp.VariableValue) + "</div></div>"; variableID += VariableController.GetByName(temp.VariableName.ToString()).ID.ToString() + "|"; variableName += temp.VariableName.ToString() + "|"; variableValueID += temp.VariableValueID.ToString() + "|"; variableValueName += temp.VariableValue.ToString() + "|"; dataVariableValue += VariableController.GetByName(temp.VariableName.ToString()).ID.ToString() + ":" + temp.VariableValueID.ToString() + "|"; labelVariableValue += temp.VariableName.ToString() + ": " + temp.VariableValue.ToString() + " - "; } } html.AppendLine(String.Format("<div class='item-var-gen' data-name-id='{0}' data-value-id='{1}' data-name-text='{2}' data-value-text='{3}' data-name-value='{4}'>", variableID, variableValueID, variableName, variableValueName, dataVariableValue)); html.AppendLine(String.Format(" <div class='col-md-12 variable-label' onclick='showVariableContent($(this))'>")); html.AppendLine(String.Format(" <strong>#{0}</strong> - {1} {2}", t, labelVariableValue, VariableSKU)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='col-md-12 variable-content'>")); html.AppendLine(String.Format(" <div class='row'>")); html.AppendLine(String.Format(" <div class='col-md-2'>")); html.AppendLine(String.Format(" <input type='file' class='productVariableImage upload-btn' onchange='imagepreview(this,$(this));' name='{0}'><img class='imgpreview' onclick='openUploadImage($(this))' data-file-name='{1}' src='{1}'>{2}", dataVariableValue, VariableImage, deleteVariableImage)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='col-md-5'>")); html.AppendLine(String.Format(" {0}", selectVariable)); html.AppendLine(String.Format(" <div class='row margin-bottom-15'>")); html.AppendLine(String.Format(" <div class='col-md-5'>Mã sản phẩm</div>")); html.AppendLine(String.Format(" <div class='col-md-7'><input type='text' disabled class='form-control productvariablesku sku-input' value='{0}'></div>", VariableSKU)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='col-md-5'>")); html.AppendLine(String.Format(" <div class='row margin-bottom-15'>")); html.AppendLine(String.Format(" <div class='col-md-5'>Giá sỉ</div>")); html.AppendLine(String.Format(" <div class='col-md-7'><input class='form-control regularprice' type='text' value='{0}'> </div>", RegularPrice)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='row margin-bottom-15 cost-of-goods'>")); html.AppendLine(String.Format(" <div class='col-md-5'>Giá vốn</div>")); html.AppendLine(String.Format(" <div class='col-md-7'><input class='form-control costofgood cost-price' type='text' value='{0}'></div>", CostOfGood)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='row margin-bottom-15'>")); html.AppendLine(String.Format(" <div class='col-md-5'>Giá bán lẻ</div>")); html.AppendLine(String.Format(" <div class='col-md-7'><input class='form-control retailprice' type='text' value='{0}'></div>", RetailPrice)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='row margin-bottom-15'>")); html.AppendLine(String.Format(" <div class='col-md-5'>Tồn kho ít nhất</div>")); html.AppendLine(String.Format(" <div class='col-md-7'><input class='form-control minimum' type='text' value='{0}'></div>", MinimumInventoryLevel)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='row margin-bottom-15'>")); html.AppendLine(String.Format(" <div class='col-md-5'>Tồn kho nhiều nhất</div>")); html.AppendLine(String.Format(" <div class='col-md-7'><input class='form-control maximum' type='text' value='{0}'></div>", MaximumInventoryLevel)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format("</div>")); t++; } ltrVariables.Text = html.ToString(); } } } }
/// <summary> /// Tải thông tin của biến thể /// </summary> /// <param name="productID"></param> private void _loadProductVariationInfo(int productID) { var html = new StringBuilder(); var variations = ProductVariableController .GetProductID(productID) .OrderByDescending(o => o.ID); var index = variations.Count(); foreach (var item in variations) { string VariableSKU = item.SKU; double RegularPrice = Convert.ToDouble(item.Regular_Price); double RetailPrice = Convert.ToDouble(item.RetailPrice); double CostOfGood = Convert.ToDouble(item.CostOfGood); int MinimumInventoryLevel = Convert.ToInt32(item.MinimumInventoryLevel); int MaximumInventoryLevel = Convert.ToInt32(item.MaximumInventoryLevel); string VariableImage = Thumbnail.getURL(item.Image, Thumbnail.Size.Source); string deleteVariableImage = "<a href='javascript:;' onclick='deleteImageVariable($(this))' class='btn-delete hide'><i class='fa fa-times' aria-hidden='true'></i> Xóa hình</a>"; if (!string.IsNullOrEmpty(item.Image)) { deleteVariableImage = "<a href='javascript:;' onclick='deleteImageVariable($(this))' class='btn-delete'><i class='fa fa-times' aria-hidden='true'></i> Xóa hình</a>"; } var value = ProductVariableValueController.GetByProductVariableID(item.ID); string selectVariable = ""; string variableID = ""; string variableName = ""; string variableValueID = ""; string variableValueName = ""; string dataVariableValue = ""; string labelVariableValue = ""; if (value != null) { foreach (var temp in value) { selectVariable += "<div class='row margin-bottom-15'><div class='col-md-5'>" + temp.VariableName + "</div><div class='col-md-7'>" + _getSelectVariable(temp.VariableName, temp.VariableValue) + "</div></div>"; variableID += VariableController.GetByName(temp.VariableName.ToString()).ID.ToString() + "|"; variableName += temp.VariableName.ToString() + "|"; variableValueID += temp.VariableValueID.ToString() + "|"; variableValueName += temp.VariableValue.ToString() + "|"; dataVariableValue += VariableController.GetByName(temp.VariableName.ToString()).ID.ToString() + ":" + temp.VariableValueID.ToString() + "|"; labelVariableValue += temp.VariableName.ToString() + ": " + temp.VariableValue.ToString() + " - "; } } html.AppendLine(String.Format("<div class='item-var-gen'")); html.AppendLine(String.Format(" data-index='{0}'", index)); html.AppendLine(String.Format(" data-product-variation-id='{0}'", item.ID)); html.AppendLine(String.Format(" data-name-id='{0}'", variableID)); html.AppendLine(String.Format(" data-value-id='{0}'", variableValueID)); html.AppendLine(String.Format(" data-name-text='{0}'", variableName)); html.AppendLine(String.Format(" data-value-text='{0}'", variableValueName)); html.AppendLine(String.Format(" data-name-value='{0}'", dataVariableValue)); html.AppendLine(String.Format(">")); html.AppendLine(String.Format(" <div class='col-md-12'>")); html.AppendLine(String.Format(" <div class='col-md-10 variable-label' onclick='showVariableContent($(this))'>")); html.AppendLine(String.Format(" <strong>#{0}</strong> - {1} {2}", index, labelVariableValue, VariableSKU)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='col-md-2 variable-removal'>")); html.AppendLine(String.Format(" <a href='javascript:;' onclick='deleteVariableItem($(this))' class='btn primary-btn fw-btn not-fullwidth'>")); html.AppendLine(String.Format(" <i class='fa fa-times' aria-hidden='true'></i>")); html.AppendLine(String.Format(" </a>")); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='col-md-12 variable-content'>")); html.AppendLine(String.Format(" <div class='row'>")); html.AppendLine(String.Format(" <div class='col-md-2'>")); html.AppendLine(String.Format(" <input type='file' class='productVariableImage upload-btn' onchange='onChangeVariationImage(this,$(this));' name='{0}'><img class='imgpreview' onclick='openUploadImage($(this))' data-file-name='{1}' src='{1}'>{2}", VariableSKU, VariableImage, deleteVariableImage)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='col-md-5'>")); html.AppendLine(String.Format(" {0}", selectVariable)); html.AppendLine(String.Format(" <div class='row margin-bottom-15'>")); html.AppendLine(String.Format(" <div class='col-md-5'>Mã sản phẩm</div>")); html.AppendLine(String.Format(" <div class='col-md-7'><input type='text' disabled class='form-control productvariablesku sku-input' value='{0}' disabled='disabled' readonly></div>", VariableSKU)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='col-md-5'>")); html.AppendLine(String.Format(" <div class='row margin-bottom-15'>")); html.AppendLine(String.Format(" <div class='col-md-5'>Giá sỉ</div>")); html.AppendLine(String.Format(" <div class='col-md-7'><input class='form-control regularprice' type='number' value='{0}'> </div>", RegularPrice)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='row margin-bottom-15 cost-of-goods'>")); html.AppendLine(String.Format(" <div class='col-md-5'>Giá vốn</div>")); html.AppendLine(String.Format(" <div class='col-md-7'><input class='form-control costofgood cost-price' type='number' value='{0}'></div>", CostOfGood)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" <div class='row margin-bottom-15'>")); html.AppendLine(String.Format(" <div class='col-md-5'>Giá bán lẻ</div>")); html.AppendLine(String.Format(" <div class='col-md-7'><input class='form-control retailprice' type='number' value='{0}'></div>", RetailPrice)); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format(" </div>")); html.AppendLine(String.Format("</div>")); index--; } if (variations.Count() > 0) { ltrVariables.Text = html.ToString(); } }
private void _updateProductVariation(tbl_Account acc) { if (String.IsNullOrEmpty(hdfVariableListInsert.Value)) { var strFunction = ""; strFunction = "HoldOn.close();"; strFunction = "swal({title: 'Lỗi', text: 'Quá trình cập nhật biến thể đã xảy ra lỗi', type: 'error'});"; JavaScript.BeforePageLoad(Page).ExecuteCustomScript(strFunction); return; } var productID = ViewState["ID"].ToString().ToInt(0); var productSKU = ViewState["SKU"].ToString(); var uploadPath = "/uploads/images/"; var imageDefault = "/App_Themes/Ann/image/placeholder.png"; #region Xóa biến thể var variationRemovalList = JsonConvert.DeserializeObject <List <string> >(hdfVariationRemovalList.Value); foreach (var sku in variationRemovalList) { ProductVariableController.removeByVariationSKU(sku); } #endregion #region Cập nhật biến thể var productVariationUpdateList = JsonConvert.DeserializeObject <List <ProductVariationUpdateModel> >(hdfVariableListInsert.Value); if (uploadVariationImage.HasFiles) { foreach (var file in uploadVariationImage.PostedFiles) { var fileName = file.FileName; var imageName = _uploadImage(productID, file); productVariationUpdateList .Where(x => x.image == uploadPath + fileName) .Select(x => { x.image = uploadPath + imageName; return(x); }); } } foreach (var item in productVariationUpdateList) { var now = DateTime.Now; // Kiểm tra sản phẩm biến thể có tồn tại hay không để thực hiện insert hoặc update var productVariation = ProductVariableController.GetByID(item.productVariationID); var image = String.Empty; if (item.image != imageDefault) { image = item.image.Replace(uploadPath, String.Empty); } if (productVariation != null) { // Thực hiện update biến thể var productVariationID = ProductVariableController.Update( ID: productVariation.ID, ProductID: productID, ParentSKU: productSKU, SKU: item.sku, Stock: Convert.ToDouble(productVariation.Stock), StockStatus: Convert.ToInt32(productVariation.StockStatus), Regular_Price: item.regularPrice, CostOfGood: item.costOfGood, RetailPrice: item.retailPrice, Image: image, ManageStock: true, IsHidden: false, ModifiedDate: now, ModifiedBy: acc.Username, SupplierID: Convert.ToInt32(productVariation.SupplierID), SupplierName: productVariation.SupplierName, MinimumInventoryLevel: item.minimumInventoryLevel, MaximumInventoryLevel: item.maximumInventoryLevel ); // Xóa tất cả giá trị của biến thể để cập nhật lại ProductVariableValueController.DeleteByProductVariableID(productVariation.ID); // Khởi tạo biến thể cho sản phẩm con _createVariationValue(new VariationValueUpdateModel() { productVariationID = Convert.ToInt32(productVariationID), productVariationSKU = item.sku, variationValueID = item.variationValueID, variationName = item.variationName, variationValueName = item.variationValueName, isHidden = false, createdDate = now, createdBy = acc.Username }); } else { // Tạo sản phẩm biến thể mới var productVariationID = ProductVariableController.Insert( ProductID: productID, ParentSKU: productSKU, SKU: item.sku, Stock: 0, StockStatus: item.stockStatus, Regular_Price: item.regularPrice, CostOfGood: item.costOfGood, RetailPrice: item.retailPrice, Image: image, ManageStock: true, IsHidden: false, CreatedDate: now, CreatedBy: acc.Username, SupplierID: ddlSupplier.SelectedValue.ToInt(0), SupplierName: ddlSupplier.SelectedItem.ToString(), MinimumInventoryLevel: item.minimumInventoryLevel, MaximumInventoryLevel: item.maximumInventoryLevel); // Khởi tạo biến thể cho sản phẩm con _createVariationValue(new VariationValueUpdateModel() { productVariationID = Convert.ToInt32(productVariationID), productVariationSKU = item.sku, variationValueID = item.variationValueID, variationName = item.variationName, variationValueName = item.variationValueName, isHidden = false, createdDate = now, createdBy = acc.Username }); } } #endregion }
public static string getProduct(string textsearch) { 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 products = ProductController.GetBySKU(textsearch.Trim().ToUpper()); if (products != null) { var productvariable = ProductVariableController.GetByParentSKU(products.ProductSKU); 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.GetByProductVariableSKU(pv.SKU); 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; var product = ProductController.GetBySKU(pv.ParentSKU); 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 = ""; } 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 (!string.IsNullOrEmpty(products.ProductImage)) { p.ProductImage = "<img src=\"" + products.ProductImage + "\" />"; p.ProductImageOrigin = products.ProductImage; } else if (img != null) { p.ProductImage = "<img src=\"" + img.ProductImage + "\" />"; p.ProductImageOrigin = img.ProductImage; } else { p.ProductImage = "<img src=\"/App_Themes/Ann/image/placeholder.png\" />"; 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.GetAllBySKU(textsearch.Trim().ToUpper()); if (productvariable != null) { foreach (var value in productvariable) { string SKU = value.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.GetByProductVariableSKU(value.SKU); 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 = value.ID; var product = ProductController.GetBySKU(value.ParentSKU); if (product != null) { p.ProductName = product.ProductTitle; } p.ProductVariable = variable; p.ProductVariableName = variablename; p.ProductVariableValue = variablevalue; p.ProductType = 2; if (!string.IsNullOrEmpty(value.Image)) { p.ProductImage = "<img src=\"" + value.Image + "\" />"; p.ProductImageOrigin = value.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 = ""; } p.SKU = value.SKU.Trim().ToUpper(); p.QuantityInstock = total; p.QuantityInstockString = string.Format("{0:N0}", total); int supplierID = 0; if (value.SupplierID != null) { supplierID = value.SupplierID.ToString().ToInt(0); } p.SupplierID = supplierID; string supplierName = ""; if (!string.IsNullOrEmpty(value.SupplierName)) { supplierName = value.SupplierName; } p.SupplierName = supplierName; ps.Add(p); } } } } } } } JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(ps)); }
public void pagingall(List <tbl_ProductVariable> acs) { int PageSize = 40; StringBuilder html = new StringBuilder(); if (acs.Count > 0) { int TotalItems = acs.Count; if (TotalItems % PageSize == 0) { PageCount = TotalItems / PageSize; } else { PageCount = TotalItems / PageSize + 1; } Int32 Page = GetIntFromQueryString("Page"); if (Page == -1) { Page = 1; } int FromRow = (Page - 1) * PageSize; int ToRow = Page * PageSize - 1; if (ToRow >= TotalItems) { ToRow = TotalItems - 1; } html.Append("<tr>"); html.Append(" <th class='image-column'>Ảnh</th>"); html.Append(" <th class='variable-column'>Thuộc tính</th>"); html.Append(" <th class='wholesale-price-column'>Giá sỉ</th>"); html.Append(" <th class='stock-column'>Kho</th>"); html.Append("</tr>"); for (int i = FromRow; i < ToRow + 1; i++) { var item = acs[i]; html.Append("<tr>"); html.Append(" <td><img src='" + Thumbnail.getURL(item.Image, Thumbnail.Size.Small) + "'></td>"); html.Append("<td>"); html.Append("<strong>" + item.SKU + "</strong><br><br>"); var value = ProductVariableValueController.GetByProductVariableID(item.ID); if (value != null) { string list = ""; foreach (var temp in value) { html.Append("" + temp.VariableName + ": " + temp.VariableValue + "</br>" + ""); list += temp.VariableName + "|"; } html.Append("<br>" + PJUtils.StockStatusBySKU(1, item.SKU)); } html.Append("</td>"); html.Append(" <td>" + string.Format("{0:N0}", item.Regular_Price) + "</td>"); html.Append(" <td>" + PJUtils.TotalProductQuantityInstock(1, item.SKU) + "</td>"); html.Append("</tr>"); } } ltrList.Text = html.ToString(); }