/// <summary> /// 显示规格列表并判断已选 /// </summary> /// <param name="attribute"></param> /// <returns></returns> protected string ShowStandardSelect(ProductTypeStandardRecordInfo standardInfo, int pType, int recordCount) { string bodyStr = "<tr>"; string[] valArr = standardInfo.ValueList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); int hidCount = 1; foreach (string valstr in valArr) { bodyStr += "<td>" + valstr + ""; if (hidCount == 1) { bodyStr += "<input type=\"hidden\" name=\"sValueList\" id=\"sValueList\" value=\"" + standardInfo.ValueList.Replace(',', '|') + "\">"; } bodyStr += "</td>"; hidCount++; } if (pType == 1) { bodyStr += "<td ><input type=\"text\" name=\"sSalePrice\" value=\"" + standardInfo.SalePrice + "\" onkeyup=\"clearNoNum(this)\" onafterpaste=\"clearNoNum(this)\" onblur=\"clearNoNum(this);setsSalePrice()\" maxlength=\"8\"></td><td ><input type=\"text\" name=\"sMarketPrice\" value=\"" + standardInfo.MarketPrice + "\" onkeyup=\"clearNoNum(this)\" onafterpaste=\"clearNoNum(this)\" onblur=\"clearNoNum(this);setsMarketPrice()\" maxlength=\"8\"></td><td ><input type=\"text\" name=\"sGroupPrice\" value=\"" + standardInfo.GroupPrice + "\" onkeyup=\"clearNoNum(this)\" onafterpaste=\"clearNoNum(this)\" onblur=\"clearNoNum(this);setsGroupPrice()\" maxlength=\"8\"></td><td ><input type=\"text\" name=\"sStorage\" onkeyup=\"value=value.replace(/[^\\d]/g,'')\" onafterpaste=\"value=value.replace(/[^\\d]/g,'')\" onblur=\"setTotalStorage(this)\" value=\"" + standardInfo.Storage + "\" maxlength=\"8\"></td><td height=\"30\" ><input type=\"text\" name=\"sProductNumber\" value=\"" + standardInfo.ProductCode + "\" ></td><td><img class=\"standPhoto\" id=\"img_sPhoto" + recordCount + "\" src=\"" + ShopCommon.ShowImage(standardInfo.Photo) + "\" width=\"20\" height=\"20\"><input type=\"hidden\" name=\"sPhoto\" id=\"ctl00_ContentPlaceHolder_sPhoto" + recordCount + "\" value=\"" + standardInfo.Photo + "\" ><div class=\"form-upload\"><iframe src=\"UploadStandardPhoto.aspx?Control=sPhoto" + recordCount + "&TableID=1&FilePath=ProductCoverPhoto/Original\" width=\"80px\" height=\"30px\" frameborder=\"0\" allowTransparency=\"true\" scrolling=\"no\" id=\"uploadIFrame\"></iframe></div></td></tr>"; } else { ProductInfo tempPro = ProductBLL.Read(standardInfo.ProductId); bodyStr += "<td ><input type=\"hidden\" id=\"Product" + recordCount + "\" name=\"Product\" value=\"" + tempPro.Id + "\" /><span id=\"ProductName" + recordCount + "\">" + (tempPro.Id > 0?StringHelper.Substring(tempPro.Name, 22):"暂无") + "</span> | <a href=\"javascript:loadProducts(" + recordCount + ");\">修改</a> | <a href=\"javascript:void(0)\" onclick=\"deleteStandard(this)\">删除</a></td>"; } return(bodyStr); }
/// <summary> /// 处理商品规格 /// </summary> /// <param name="product"></param> protected void HanderProductStandard(ProductInfo product) { string productIDList = string.Empty; if (product.StandardType == (int)ProductStandardType.Group) { productIDList = "," + RequestHelper.GetForm <string>("Product") + ","; productIDList = productIDList.Replace(",0,", "," + product.Id.ToString() + ","); productIDList = productIDList.Substring(1, productIDList.Length - 2); } ProductBLL.UpdateProductStandardType(productIDList, product.StandardType, product.Id); if (product.Id > 0) { ProductTypeStandardRecordBLL.DeleteByProductID(product.Id.ToString()); } if (RequestHelper.GetForm <string>("isOpenStandard") == "1") { string standardIDList = RequestHelper.GetForm <string>("StandardIDList"); if (standardIDList != string.Empty) { string[] productIDArray = productIDList.Split(','); string[] valueArr = RequestHelper.GetForm <string>("sValueList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] marketPriceArr = RequestHelper.GetForm <string>("sMarketPrice").Split(','); string[] salePriceArr = RequestHelper.GetForm <string>("sSalePrice").Split(','); string[] storageArr = RequestHelper.GetForm <string>("sStorage").Split(','); string[] productNumberArr = RequestHelper.GetForm <string>("sProductNumber").Split(','); for (int i = 0; i < valueArr.Length; i++) { ProductTypeStandardRecordInfo standardRecord = new ProductTypeStandardRecordInfo(); if (product.StandardType == (int)ProductStandardType.Group) { standardRecord.GroupTag = productIDList; standardRecord.ProductId = Convert.ToInt32(productIDArray[i]); standardRecord.SalePrice = 0; standardRecord.SalePrice = 0; standardRecord.Storage = 0; standardRecord.ProductCode = string.Empty; } else { standardRecord.ProductId = product.Id; standardRecord.MarketPrice = Convert.ToDecimal(marketPriceArr[i]); standardRecord.SalePrice = Convert.ToDecimal(salePriceArr[i]); standardRecord.Storage = Convert.ToInt32(storageArr[i]); standardRecord.ProductCode = productNumberArr[i]; } standardRecord.StandardIdList = standardIDList.Substring(0, standardIDList.Length - 1); standardRecord.ValueList = valueArr[i].Replace("|", ";"); ProductTypeStandardRecordBLL.Add(standardRecord); } } } }
/// <summary> /// 修改规格库存 /// </summary> /// <param name="entity"></param> public void UpdateStorage(ProductTypeStandardRecordInfo entity) { using (var conn = new SqlConnection(connectString)) { string sql = @"UPDATE ProductTypeStandardRecord SET Storage = @Storage where ProductId = @ProductId and ValueList = @ValueList"; conn.Execute(sql, entity); } }
public void Update(ProductTypeStandardRecordInfo entity) { using (var conn = new SqlConnection(connectString)) { string sql = @"UPDATE ProductTypeStandardRecord SET ProductId = @ProductId, StandardIdList = @StandardIdList, ValueList = @ValueList, MarketPrice = @MarketPrice, SalePrice = @SalePrice, Storage = @Storage, OrderCount=@OrderCount, SendCount=@SendCount, ProductCode = @ProductCode,GroupTag=@GroupTag,Photo=@Photo,[GroupPrice]=@GroupPrice where Id=@Id"; conn.Execute(sql, entity); } }
public void Add(ProductTypeStandardRecordInfo entity) { using (var conn = new SqlConnection(connectString)) { string sql = @"INSERT INTO ProductTypeStandardRecord( ProductId,StandardIdList,ValueList,MarketPrice,SalePrice,Storage,OrderCount,SendCount,ProductCode,GroupTag,Photo,[GroupPrice]) VALUES(@ProductId,@StandardIdList,@ValueList,@MarketPrice,@SalePrice,@Storage,@OrderCount,@SendCount,@ProductCode,@GroupTag,@Photo,@GroupPrice)"; conn.Execute(sql, entity); } }
/// <summary> /// 修改商品库存 /// </summary> protected void ModifyStorage() { string result = string.Empty; bool flag = true; int productId = RequestHelper.GetQueryString <int>("productId"); int totalStorage = RequestHelper.GetQueryString <int>("totalStorage"); string valueList = Server.UrlDecode(RequestHelper.GetQueryString <string>("valueList")); string standIdList = RequestHelper.GetQueryString <string>("standIdList"); string storageList = RequestHelper.GetQueryString <string>("storageList"); //无规格或产品组规格 修改一口价 if (totalStorage < 0) { flag = false; result = "总库存填写不规范"; } if (flag) { if (productId > 0) { var product = ProductBLL.Read(productId); if (product.StandardType == (int)ProductStandardType.Single) {//如果是单产品规格 string[] valueArr = valueList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] storageArr = storageList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < valueArr.Length; i++) { ProductTypeStandardRecordInfo standardRecord = new ProductTypeStandardRecordInfo(); standardRecord.ProductId = product.Id; standardRecord.ValueList = valueArr[i]; standardRecord.Storage = Convert.ToInt32(storageArr[i]); ProductTypeStandardRecordBLL.UpdateStorage(standardRecord); } product.TotalStorageCount = ProductTypeStandardRecordBLL.GetSumStorageByProduct(productId); ProductBLL.Update(product); result = product.TotalStorageCount.ToString(); } else { //无规格或产品组规格 修改总库存 product.TotalStorageCount = totalStorage; ProductBLL.Update(product); result = product.TotalStorageCount.ToString(); } } else { flag = false; result = "参数错误"; } } Response.Clear(); ResponseHelper.Write(JsonConvert.SerializeObject(new { flag = flag, msg = result })); Response.End(); }
/// <summary> /// 显示规格列表头部 /// </summary> /// <param name="attribute"></param> /// <returns></returns> protected string ShowStandardHead(ProductTypeStandardRecordInfo standardInfo, int pType) { string[] valArr = standardInfo.StandardIdList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); string headStr = "<thead><tr>"; foreach (string valstr in valArr) { if (!string.IsNullOrEmpty(valstr)) { headStr += "<td>" + ProductTypeStandardBLL.Read(Convert.ToInt32(valstr)).Name + "</td>"; } } if (pType == 1) { headStr += "<td width=\"10%\"><input type=\"hidden\" name=\"StandardIDList\" id=\"StandardIDList\" value=\"" + standardInfo.StandardIdList + ";\"> <span class=\"red\">*</span>本站价</td><td width=\"10%\"><span class=\"red\">*</span>市场价</td><td width=\"10%\"><span class=\"red\">*</span>团购价</td><td width=\"10%\"><span class=\"red\">*</span>库存</td><td width=\"15%\" height=\"40\">货号</td><td>图片</td></tr></thead>"; } else { headStr += "<td width=\"55%\"><input type=\"hidden\" name=\"StandardIDList\" id=\"StandardIDList\" value=\"" + standardInfo.StandardIdList + ";\"> 关联产品</td></tr></thead>"; } return(headStr); }
public static void UpdateStorage(ProductTypeStandardRecordInfo entity) { dal.UpdateStorage(entity); CacheHelper.Remove(cacheKey); }
public static void Add(ProductTypeStandardRecordInfo entity) { dal.Add(entity); CacheHelper.Remove(cacheKey); }
/// <summary> /// 修改商品价格 /// </summary> protected void ModifyPrice() { string result = string.Empty; bool flag = true; int productId = RequestHelper.GetQueryString <int>("productId"); decimal salePrice = RequestHelper.GetQueryString <decimal>("salePrice"); string valueList = Server.UrlDecode(RequestHelper.GetQueryString <string>("valueList")); string standIdList = RequestHelper.GetQueryString <string>("standIdList"); string priceList = RequestHelper.GetQueryString <string>("priceList"); //无规格或产品组规格 修改一口价 if (salePrice < 0) { flag = false; result = "一口价填写不规范"; } if (flag) { if (productId > 0) { var product = ProductBLL.Read(productId); if (product.StandardType == (int)ProductStandardType.Single) {//如果是单产品规格 string[] valueArr = valueList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] salePriceArr = priceList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); decimal[] standardPriceList = ProductTypeStandardRecordBLL.ReadListByProduct(productId, product.StandardType).Select(k => k.SalePrice).ToArray(); decimal[] arr = Array.ConvertAll <string, decimal>(salePriceArr, s => decimal.Parse(s)); ArrayList list = new ArrayList(arr); list.AddRange(standardPriceList); list.Sort(); decimal min = Convert.ToDecimal(list[0]); decimal max = Convert.ToDecimal(list[list.Count - 1]); if (salePrice > max || salePrice < min) { flag = false; result = "一口价必须在" + min + "-" + max + "之间"; } else { product.SalePrice = salePrice; ProductBLL.Update(product); result = product.SalePrice.ToString(); for (int i = 0; i < valueArr.Length; i++) { ProductTypeStandardRecordInfo standardRecord = new ProductTypeStandardRecordInfo(); standardRecord.ProductId = product.Id; standardRecord.ValueList = valueArr[i]; standardRecord.SalePrice = Convert.ToDecimal(salePriceArr[i]); ProductTypeStandardRecordBLL.UpdateSalePrice(standardRecord); } } } else { //无规格或产品组规格 修改一口价 product.SalePrice = salePrice; ProductBLL.Update(product); result = product.SalePrice.ToString(); } } else { flag = false; result = "参数错误"; } } Response.Clear(); ResponseHelper.Write(JsonConvert.SerializeObject(new { flag = flag, msg = result })); Response.End(); }