コード例 #1
0
ファイル: ProductController.cs プロジェクト: qq550723504/zone
        public ActionResult EditProduct(EditProductModel model, int pid = -1)
        {
            ProductInfo productInfo = AdminProducts.AdminGetProductById(pid);
            if (productInfo == null)
                return PromptView("商品不存在");
            if (productInfo.StoreId != WorkContext.StoreId)
                return PromptView("不能操作其它店铺的商品");

            int pid2 = AdminProducts.AdminGetProductIdByName(model.ProductName);
            if (pid2 > 0 && pid2 != pid)
                ModelState.AddModelError("ProductName", "名称已经存在");

            if (ModelState.IsValid)
            {
                productInfo.PSN = model.PSN ?? "";
                productInfo.BrandId = model.BrandId;
                productInfo.StoreCid = model.StoreCid;
                productInfo.StoreSTid = model.StoreSTid;
                productInfo.Name = model.ProductName;
                productInfo.ShopPrice = model.ShopPrice;
                productInfo.MarketPrice = model.MarketPrice;
                productInfo.CostPrice = model.CostPrice;
                productInfo.State = model.State;
                productInfo.IsBest = model.IsBest == true ? 1 : 0;
                productInfo.IsHot = model.IsHot == true ? 1 : 0;
                productInfo.IsNew = model.IsNew == true ? 1 : 0;
                productInfo.DisplayOrder = model.DisplayOrder;
                productInfo.Weight = model.Weight;
                productInfo.Description = model.Description ?? "";

                AdminProducts.UpdateProduct(productInfo, model.StockNumber, model.StockLimit);
                AddStoreAdminLog("修改商品", "修改商品,商品ID为:" + pid);
                return PromptView("商品修改成功");
            }


            //商品属性列表
            List<ProductAttributeInfo> productAttributeList = Products.GetProductAttributeList(pid);

            //商品sku项列表
            DataTable productSKUItemList = AdminProducts.GetProductSKUItemList(productInfo.Pid);

            ViewData["pid"] = productInfo.Pid;
            ViewData["cateId"] = productInfo.CateId;
            ViewData["categoryName"] = AdminCategories.GetCategoryById(productInfo.CateId).Name;
            ViewData["productAttributeList"] = productAttributeList;
            ViewData["productSKUItemList"] = productSKUItemList;

            LoadStore();
            ViewData["referer"] = MallUtils.GetStoreAdminRefererCookie();
            return View(model);
        }
コード例 #2
0
ファイル: ProductController.cs プロジェクト: qq550723504/zone
        public ActionResult EditProduct(int pid = -1)
        {
            ProductInfo productInfo = AdminProducts.AdminGetProductById(pid);
            if (productInfo == null)
                return PromptView("商品不存在");
            if (productInfo.StoreId != WorkContext.StoreId)
                return PromptView("不能操作其它店铺的商品");

            EditProductModel model = new EditProductModel();

            model.PSN = productInfo.PSN;
            model.BrandId = productInfo.BrandId;
            model.StoreCid = productInfo.StoreCid;
            model.StoreSTid = productInfo.StoreSTid;
            model.ProductName = productInfo.Name;
            model.ShopPrice = productInfo.ShopPrice;
            model.MarketPrice = productInfo.MarketPrice;
            model.CostPrice = productInfo.CostPrice;
            model.State = productInfo.State;
            model.IsBest = productInfo.IsBest == 1 ? true : false;
            model.IsHot = productInfo.IsHot == 1 ? true : false;
            model.IsNew = productInfo.IsNew == 1 ? true : false;
            model.DisplayOrder = productInfo.DisplayOrder;
            model.Weight = productInfo.Weight;
            model.Description = productInfo.Description;

            model.BrandName = AdminBrands.GetBrandById(productInfo.BrandId).Name;


            //库存信息
            ProductStockInfo productStockInfo = AdminProducts.GetProductStockByPid(pid);
            model.StockNumber = productStockInfo.Number;
            model.StockLimit = productStockInfo.Limit;

            //商品属性列表
            List<ProductAttributeInfo> productAttributeList = Products.GetProductAttributeList(pid);

            //商品sku项列表
            DataTable productSKUItemList = AdminProducts.GetProductSKUItemList(productInfo.Pid);

            ViewData["pid"] = productInfo.Pid;
            ViewData["cateId"] = productInfo.CateId;
            ViewData["categoryName"] = AdminCategories.GetCategoryById(productInfo.CateId).Name;
            ViewData["productAttributeList"] = productAttributeList;
            ViewData["productSKUItemList"] = productSKUItemList;

            LoadStore();
            ViewData["referer"] = MallUtils.GetStoreAdminRefererCookie();
            return View(model);
        }