Exemplo n.º 1
0
        public ActionResult SaveNew(int?id)
        {
            //ViewBag.hasMultPrice = true;
            //if (id.HasValue)
            //{
            //    var barMultPrice = BaseService<ProductRecord>.FindById(id).Barcode;
            //    var listMultPrice = ProductService.LoadMultPriceList(barMultPrice).ToJson();
            //    ViewBag.hasMultPrice = (listMultPrice.Count() > 2 ? true : false);
            //}
            ViewBag.omsurl = Pharos.Utility.Config.GetAppSettings("omsurl");
            LoadData();
            SelectListItem city = null;
            var            obj  = new ProductRecord()
            {
                ValidityWarning = 5, InventoryWarning = 5, InventoryWarningMax = 1000, ValuationType = 1, SaleRate = 17, StockRate = 17
            };

            obj.ProductImages = new List <ProductImage>();
            if (id.HasValue)
            {
                obj = ProductService.FindById(id);
                //var barcode = ProductService.FindById(id).Barcode;
                //var re= ProductService.getIsRelationship(barcode);
                if (obj != null)
                {
                    obj.IsRelationship = ProductService.IsRelationship(obj.Barcode);
                    if (obj.CityId > 0)
                    {
                        var area = BaseService <Area> .FindById(obj.CityId);

                        if (area != null)
                        {
                            var parentArea = BaseService <Area> .FindById(area.AreaPID);

                            var text = area.Title;
                            if (parentArea != null)
                            {
                                text = parentArea.Title + "/" + text;
                            }
                            city = new SelectListItem()
                            {
                                Value = obj.CityId.ToString(), Text = text, Selected = true
                            };
                        }
                    }
                    ViewBag.haschild  = ProductService.IsExist(o => o.OldBarcode == obj.Barcode && o.CompanyId == CommonService.CompanyId);
                    obj.ProductImages = BaseService <ProductImage> .FindList(o => o.CompanyId == obj.CompanyId && o.ProductCode == obj.ProductCode).OrderByDescending(o => o.CreateDT).ToList();
                }
            }
            ViewBag.provinces = ListToSelect(BaseService <Area> .FindList(o => o.Type == 2).OrderBy(o => o.OrderNum).Select(o => new SelectListItem()
            {
                Text = o.Title, Value = o.AreaID.ToString()
            }), emptyTitle: "请选择");
            ViewBag.city = city;
            for (int i = obj.ProductImages.Count; i < 5; i++)
            {
                obj.ProductImages.Add(new ProductImage());
            }
            return(View(obj.IsNullThrow()));
        }
Exemplo n.º 2
0
        public ActionResult SplitSave(int?id)
        {
            LoadData();
            var obj = new ProductRecord();

            if (id.HasValue)
            {
                obj              = ProductService.FindById(id);
                obj.OldBarcode   = obj.Barcode;
                obj.ProductCode2 = obj.ProductCode;
            }
            return(View("SplitSaveNew", obj.IsNullThrow()));
        }
Exemplo n.º 3
0
        public ActionResult GroupSaveNew(int?id, string barcodes)
        {
            LoadData();
            var obj = new ProductRecord()
            {
                Nature = 1, ValidityWarning = 5, InventoryWarning = 5, InventoryWarningMax = 1000
            };

            obj.ProductGroups = new List <ProductGroup>();
            ViewBag.promsg    = "";
            if (id.HasValue)
            {
                obj = ProductService.FindById(id);
                if (obj.Nature == 1)
                {
                    obj.ProductGroups = ProductService.GetGroups(obj.Barcode);
                }
                obj.IsRelationship = ProductService.IsRelationship(obj.Barcode);
            }
            if (!barcodes.IsNullOrEmpty())
            {
                var bars     = barcodes.TrimEnd(',').Split(',').Distinct().ToList();
                var products = BaseService <VwProduct> .FindList(o => bars.Contains(o.Barcode) && o.CompanyId == CommonService.CompanyId);

                obj.ProductGroups.RemoveAll(o => !bars.Contains(o.GroupBarcode));
                if (!id.HasValue && products.Any())
                {
                    //obj.ValuationType = products[0].ValuationType;
                    obj.GroupCount   = products.Min(o => o.StockNums);
                    obj.CategorySN   = products[0].CategorySN;
                    obj.SubUnitId    = products[0].SubUnitId;
                    obj.ProductCode2 = products[0].ProductCode;
                }
                obj.BuyPrice = products.Sum(o => o.BuyPrice);
                obj.SysPrice = products.Sum(o => o.SysPrice);
                foreach (var o in products)
                {
                    if (!obj.ProductGroups.Any(i => i.GroupBarcode == o.Barcode))
                    {
                        obj.ProductGroups.Add(new ProductGroup()
                        {
                            GroupBarcode = o.Barcode, Number = 1, Title = o.Title, BuyPrice = o.BuyPrice, SysPrice = o.SysPrice, ValuationType = o.ValuationType, Unit = o.SubUnit
                        });
                    }
                }
            }
            return(View(obj.IsNullThrow()));
        }
Exemplo n.º 4
0
        public ActionResult Save(int?id)
        {
            var obj = new ProductRecord()
            {
                Source = 1
            };

            if (id.HasValue)
            {
                obj = ProductService.GetOne(id);
            }
            ViewBag.subunits = ListToSelect(DictionaryService.GetSubUnitCategories().Select(o => new SelectListItem()
            {
                Value = o.DicSN.ToString(), Text = o.Title
            }), emptyTitle: "");
            ViewBag.brands = ListToSelect(BrandService.GetList().Select(o => new SelectListItem()
            {
                Value = o.BrandSN.ToString(), Text = o.Title
            }), emptyTitle: "");
            return(View(obj.IsNullThrow()));
        }