示例#1
0
        private void SaveNewStock(bool isbatch)
        {
            List <StoreSKUInfo> list = new List <StoreSKUInfo>();
            int storeId = HiContext.Current.Manager.StoreId;
            List <StoreStockLogInfo> list2 = new List <StoreStockLogInfo>();
            int num = 0;

            if (this.grdSelectedProducts.Items.Count > 0)
            {
                foreach (RepeaterItem item in this.grdSelectedProducts.Items)
                {
                    TextBox textBox = item.FindControl("txtStock") as TextBox;
                    num = (isbatch ? this.txtTagetStock.Text.Trim().ToInt(0) : textBox.Text.Trim().ToInt(0));
                    if (num >= 0)
                    {
                        HiddenField hiddenField  = item.FindControl("txtOldStock") as HiddenField;
                        HiddenField hiddenField2 = item.FindControl("hidSKUContent") as HiddenField;
                        TextBox     textBox2     = item.FindControl("txtRemark") as TextBox;
                        int         num2         = hiddenField.Value.Trim().ToInt(0);
                        if (num != num2)
                        {
                            HiddenField  hiddenField3 = item.FindControl("HidSkuId") as HiddenField;
                            HiddenField  hiddenField4 = item.FindControl("HidProductId") as HiddenField;
                            string       value        = hiddenField3.Value;
                            int          num3         = hiddenField4.Value.ToInt(0);
                            StoreSKUInfo storeSKUInfo = new StoreSKUInfo();
                            storeSKUInfo.ProductID = num3;
                            storeSKUInfo.SkuId     = value;
                            storeSKUInfo.Stock     = num;
                            storeSKUInfo.StoreId   = storeId;
                            list.Add(storeSKUInfo);
                            StoreStockLogInfo storeStockLogInfo = new StoreStockLogInfo();
                            storeStockLogInfo.ProductId  = num3;
                            storeStockLogInfo.Remark     = DataHelper.CleanSearchString(string.IsNullOrEmpty(textBox2.Text.Trim()) ? this.txtComment.Text.Trim() : textBox2.Text.Trim());
                            storeStockLogInfo.SkuId      = value;
                            storeStockLogInfo.Operator   = HiContext.Current.Manager.UserName;
                            storeStockLogInfo.StoreId    = storeId;
                            storeStockLogInfo.ChangeTime = DateTime.Now;
                            storeStockLogInfo.Content    = hiddenField2.Value + "库存由【" + num2 + "】修改为【" + num + "】";
                            list2.Add(storeStockLogInfo);
                        }
                    }
                }
                if (list.Count > 0)
                {
                    if (StoresHelper.SaveStoreStock(list, list2, 1))
                    {
                        base.CloseWindow(null);
                        this.BindProduct();
                    }
                    else
                    {
                        this.ShowMsg("保存失败!", false);
                    }
                }
                else
                {
                    base.CloseWindow(null);
                }
            }
        }
示例#2
0
        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();
            }
        }
示例#3
0
        private void SaveNewStock()
        {
            List <StoreSKUInfo> list = new List <StoreSKUInfo>();
            int storeId = HiContext.Current.Manager.StoreId;
            List <StoreStockLogInfo> list2 = new List <StoreStockLogInfo>();
            decimal num = default(decimal);

            if (this.grdSelectedProducts.Items.Count > 0)
            {
                StoresInfo storeById = DepotHelper.GetStoreById(HiContext.Current.Manager.StoreId);
                foreach (RepeaterItem item in this.grdSelectedProducts.Items)
                {
                    TextBox textBox = item.FindControl("txtStoreSalePrice") as TextBox;
                    num = textBox.Text.Trim().ToDecimal(0);
                    if (num >= decimal.Zero)
                    {
                        HiddenField hiddenField = item.FindControl("txtOldStoreSalePrice") as HiddenField;
                        if (num != hiddenField.Value.ToDecimal(0))
                        {
                            HiddenField  hiddenField2 = item.FindControl("hidSKUContent") as HiddenField;
                            TextBox      textBox2     = item.FindControl("txtRemark") as TextBox;
                            HiddenField  hiddenField3 = item.FindControl("HidSkuId") as HiddenField;
                            HiddenField  hiddenField4 = item.FindControl("HidProductId") as HiddenField;
                            string       value        = hiddenField3.Value;
                            int          num2         = hiddenField4.Value.ToInt(0);
                            StoreSKUInfo storeSKUInfo = new StoreSKUInfo();
                            storeSKUInfo.ProductID      = num2;
                            storeSKUInfo.SkuId          = value;
                            storeSKUInfo.StoreId        = storeId;
                            storeSKUInfo.StoreSalePrice = num;
                            list.Add(storeSKUInfo);
                            HiddenField hiddenField5 = item.FindControl("hidOldSalePrice") as HiddenField;
                            decimal     num3         = hiddenField5.Value.ToDecimal(0);
                            decimal?    minPriceRate = storeById.MinPriceRate;
                            if (minPriceRate.GetValueOrDefault() > default(decimal) && minPriceRate.HasValue)
                            {
                                decimal d             = num;
                                decimal value2        = num3;
                                decimal?minPriceRate2 = storeById.MinPriceRate;
                                minPriceRate = (decimal?)value2 * minPriceRate2;
                                if (d < minPriceRate.GetValueOrDefault() && minPriceRate.HasValue)
                                {
                                    this.ShowMsg("门店价格不能小于平台价格的" + storeById.MinPriceRate.Value.F2ToString("f2") + "倍!", false);
                                    return;
                                }
                            }
                            minPriceRate = storeById.MaxPriceRate;
                            if (minPriceRate.GetValueOrDefault() > default(decimal) && minPriceRate.HasValue)
                            {
                                decimal d2            = num;
                                decimal value2        = num3;
                                decimal?minPriceRate2 = storeById.MaxPriceRate;
                                minPriceRate = (decimal?)value2 * minPriceRate2;
                                if (d2 > minPriceRate.GetValueOrDefault() && minPriceRate.HasValue)
                                {
                                    this.ShowMsg("门店价格不能大于平台价格的" + storeById.MaxPriceRate.Value.F2ToString("f2") + "倍!", false);
                                    return;
                                }
                            }
                            StoreStockLogInfo storeStockLogInfo = new StoreStockLogInfo();
                            storeStockLogInfo.ProductId  = num2;
                            storeStockLogInfo.Remark     = DataHelper.CleanSearchString(string.IsNullOrEmpty(textBox2.Text.Trim()) ? this.txtComment.Text.Trim() : textBox2.Text.Trim());
                            storeStockLogInfo.SkuId      = value;
                            storeStockLogInfo.Operator   = HiContext.Current.Manager.UserName;
                            storeStockLogInfo.StoreId    = storeId;
                            storeStockLogInfo.ChangeTime = DateTime.Now;
                            storeStockLogInfo.Content    = hiddenField2.Value + "售价由【" + hiddenField.Value.ToDecimal(0).F2ToString("f2") + "】修改为【" + num.F2ToString("f2") + "】";
                            list2.Add(storeStockLogInfo);
                        }
                    }
                }
                if (list.Count > 0)
                {
                    if (StoresHelper.SaveStoreStock(list, list2, 3))
                    {
                        base.CloseWindow(null);
                        this.BindProduct();
                    }
                    else
                    {
                        this.ShowMsg("保存失败!", false);
                    }
                }
                else
                {
                    base.CloseWindow(null);
                }
            }
        }