private void SaveNewStock() { List <StoreSKUInfo> list = new List <StoreSKUInfo>(); List <StoreStockLogInfo> list2 = new List <StoreStockLogInfo>(); List <int> list3 = new List <int>(); int storeId = HiContext.Current.Manager.StoreId; StoresInfo storeById = StoresHelper.GetStoreById(storeId); if (this.grdSelectedProducts.Items.Count > 0) { foreach (RepeaterItem item in this.grdSelectedProducts.Items) { int num = 0; int num2 = 0; decimal num3 = default(decimal); TextBox textBox = item.FindControl("txtStock") as TextBox; TextBox textBox2 = item.FindControl("txtWarningStock") as TextBox; HiddenField hiddenField = item.FindControl("hidSKUContent") as HiddenField; int.TryParse(textBox.Text, out num); if (storeById.IsModifyPrice) { TextBox textBox3 = item.FindControl("txtStoreSalePrice") as TextBox; decimal.TryParse(textBox3.Text, out num3); if (num3 <= decimal.Zero) { this.ShowMsg("价格必须大于0!", false); return; } } if (num <= 0) { this.ShowMsg("库存必须设置大于0的数字!", false); return; } if (num2 < 0) { this.ShowMsg("警戒库存必须不能为负数!", false); return; } HiddenField hiddenField2 = item.FindControl("HidSkuId") as HiddenField; HiddenField hiddenField3 = item.FindControl("HidProductId") as HiddenField; string value = hiddenField2.Value; int num4 = hiddenField3.Value.ToInt(0); StoreSKUInfo storeSKUInfo = new StoreSKUInfo(); storeSKUInfo.ProductID = num4; storeSKUInfo.SkuId = value; storeSKUInfo.Stock = num; storeSKUInfo.StoreId = storeId; storeSKUInfo.WarningStock = textBox2.Text.ToInt(0); storeSKUInfo.FreezeStock = 0; if (storeById.IsModifyPrice) { storeSKUInfo.StoreSalePrice = num3; HiddenField hiddenField4 = item.FindControl("hidSalePrice") as HiddenField; decimal num5 = hiddenField4.Value.ToDecimal(0); decimal? minPriceRate = storeById.MinPriceRate; if (minPriceRate.GetValueOrDefault() > default(decimal) && minPriceRate.HasValue) { decimal d = num3; decimal value2 = num5; decimal?minPriceRate2 = storeById.MinPriceRate; minPriceRate = (decimal?)value2 * minPriceRate2; if (d < minPriceRate.GetValueOrDefault() && minPriceRate.HasValue) { this.ShowMsg(hiddenField.Value + "门店价格不能小于平台价格的" + storeById.MinPriceRate.Value.F2ToString("f2") + "倍!", false); return; } } minPriceRate = storeById.MaxPriceRate; if (minPriceRate.GetValueOrDefault() > default(decimal) && minPriceRate.HasValue) { decimal d2 = num3; decimal value2 = num5; decimal?minPriceRate2 = storeById.MaxPriceRate; minPriceRate = (decimal?)value2 * minPriceRate2; if (d2 > minPriceRate.GetValueOrDefault() && minPriceRate.HasValue) { this.ShowMsg(hiddenField.Value + "门店价格不能大于平台价格的" + storeById.MaxPriceRate.Value.F2ToString("f2") + "倍!", false); return; } } } else { storeSKUInfo.StoreSalePrice = decimal.Zero; } list.Add(storeSKUInfo); StoreStockLogInfo storeStockLogInfo = new StoreStockLogInfo(); storeStockLogInfo.ProductId = num4; storeStockLogInfo.Remark = "从平台商品移入"; storeStockLogInfo.SkuId = value; storeStockLogInfo.Operator = HiContext.Current.Manager.UserName; storeStockLogInfo.StoreId = storeId; storeStockLogInfo.ChangeTime = DateTime.Now; storeStockLogInfo.Content = hiddenField.Value + "库存由【0】变成【" + num + "】"; StoreStockLogInfo storeStockLogInfo2 = storeStockLogInfo; storeStockLogInfo2.Content = storeStockLogInfo2.Content + "警戒库存由【0】变成【" + storeSKUInfo.WarningStock + "】"; if (storeById.IsModifyPrice) { storeStockLogInfo2 = storeStockLogInfo; storeStockLogInfo2.Content = storeStockLogInfo2.Content + "门店售价由【0】变成【" + num3 + "】"; } list2.Add(storeStockLogInfo); if (!list3.Contains(num4)) { list3.Add(num4); } } if (list.Count > 0) { if (StoresHelper.AddStoreProduct(list, list2, list3)) { base.CloseWindow(null); } else { this.ShowMsg("保存失败!", false); } } this.BindProduct(); } }
protected void btnSaveStock_Click(object sender, EventArgs e) { List <StoreSKUInfo> list = new List <StoreSKUInfo>(); List <OperationLogEntry> list2 = new List <OperationLogEntry>(); List <int> list3 = new List <int>(); int num = 0; int num2 = 0; decimal num3 = default(decimal); if (this.grdSelectedProducts.Items.Count > 0) { StoresInfo storeById = DepotHelper.GetStoreById(this.hidStoreId.Value.ToInt(0)); foreach (RepeaterItem item in this.grdSelectedProducts.Items) { TextBox textBox = item.FindControl("txtStock") as TextBox; num = textBox.Text.Trim().ToInt(0); TextBox textBox2 = item.FindControl("txtStoreSalePrice") as TextBox; num3 = textBox2.Text.Trim().ToDecimal(0); TextBox textBox3 = item.FindControl("txtWarningStock") as TextBox; num2 = textBox3.Text.Trim().ToInt(0); if (num > 99999) { this.ShowMsg("允许输入的库存最大值为99999", false); return; } if (num2 > 99999) { this.ShowMsg("允许输入的警戒库存最大值为99999", false); return; } if (num >= 0 && num2 >= 0 && num3 >= decimal.Zero) { HiddenField hiddenField = item.FindControl("hidProductName") as HiddenField; HiddenField hiddenField2 = item.FindControl("hidSKU") as HiddenField; HiddenField hiddenField3 = item.FindControl("hidSKUContent") as HiddenField; HiddenField hiddenField4 = item.FindControl("HidSkuId") as HiddenField; HiddenField hiddenField5 = item.FindControl("HidProductId") as HiddenField; string value = hiddenField4.Value; int num4 = hiddenField5.Value.ToInt(0); if (!list3.Contains(num4)) { list3.Add(num4); } StoreSKUInfo storeSKUInfo = new StoreSKUInfo(); storeSKUInfo.ProductID = num4; storeSKUInfo.SkuId = value; storeSKUInfo.Stock = num; storeSKUInfo.StoreId = this.hidStoreId.Value.ToInt(0); storeSKUInfo.WarningStock = num2; storeSKUInfo.StoreSalePrice = num3; storeSKUInfo.FreezeStock = 0; list.Add(storeSKUInfo); OperationLogEntry operationLogEntry = new OperationLogEntry(); operationLogEntry.AddedTime = DateTime.Now; operationLogEntry.IPAddress = this.Page.Request.UserHostAddress; operationLogEntry.PageUrl = "AddStoreProduct.aspx"; operationLogEntry.UserName = HiContext.Current.Manager.UserName; operationLogEntry.Privilege = Privilege.AddStores; operationLogEntry.Description = operationLogEntry.UserName + " 给门店" + storeById.StoreName + "上架了商品 " + hiddenField2.Value + ((hiddenField3.Value.Length <= 0) ? "" : ("[" + hiddenField3.Value + "]")); OperationLogEntry operationLogEntry2 = operationLogEntry; operationLogEntry2.Description = operationLogEntry2.Description + " 门店库存设置为" + num + ";"; operationLogEntry2 = operationLogEntry; operationLogEntry2.Description = operationLogEntry2.Description + " 门店警戒库存设置为" + num2 + ";"; HiddenField hiddenField6 = item.FindControl("hidOldSalePrice") as HiddenField; decimal num5 = hiddenField6.Value.ToDecimal(0); decimal? minPriceRate = storeById.MinPriceRate; if (minPriceRate.GetValueOrDefault() > default(decimal) && minPriceRate.HasValue) { decimal d = num3; decimal value2 = num5; decimal?minPriceRate2 = storeById.MinPriceRate; minPriceRate = (decimal?)value2 * minPriceRate2; if (d < minPriceRate.GetValueOrDefault() && minPriceRate.HasValue) { this.ShowMsg(hiddenField.Value + "门店价格不能小于平台价格的" + storeById.MinPriceRate.Value.F2ToString("f2") + "倍!", false); return; } } minPriceRate = storeById.MaxPriceRate; if (minPriceRate.GetValueOrDefault() > default(decimal) && minPriceRate.HasValue) { decimal d2 = num3; decimal value2 = num5; decimal?minPriceRate2 = storeById.MaxPriceRate; minPriceRate = (decimal?)value2 * minPriceRate2; if (d2 > minPriceRate.GetValueOrDefault() && minPriceRate.HasValue) { this.ShowMsg(hiddenField.Value + "门店价格不能大于平台价格的" + storeById.MaxPriceRate.Value.F2ToString("f2") + "倍!", false); return; } } operationLogEntry2 = operationLogEntry; operationLogEntry2.Description = operationLogEntry2.Description + " 门店售价设置为" + num3 + ";"; list2.Add(operationLogEntry); } } if (list.Count > 0) { if (StoresHelper.AddStoreProduct(list, list2, list3)) { base.CloseWindow(null); this.ShowMsgCloseWindow("保存成功!", true); } else { this.ShowMsg("保存失败!", false); } } else { base.CloseWindow(null); } } }