public ActionResult Create(RetailProductEditModel model)
        {
            if (!ModelState.IsValid)
            {
                model.ToCompanyList = CompanySvc.LoadCompanyByType((short)CompanyType.RetailCompany);
                ModelState.AddModelError(string.Empty, "请输入正确信息!");
                return View(model);
            }

            IIdentity id = HttpContext.User.Identity;
            var product = WholeSaleProductSvc.LoadById(model.WholeSaleProductId);

            model.InsertUserName = id.Name;
            model.ProductStatus = ProductStatus.Retail;
            model.InsertDate = DateTime.Now;

            int productId = RetailProductSvc.Insert(model.ToRetailProduct());

            if (productId > 0)
            {
                product.ProductStatus = ProductStatus.WholeSold;

                WholeSaleProductSvc.Update(product);
            }

            return RedirectToAction("WholeSold");
        }
        public ActionResult Create(int wholeSaleId)
        {
            var wholeSaleProduct = WholeSaleProductSvc.LoadById(wholeSaleId);
            var model = new RetailProductEditModel
            {
                AgriculturalProductId = wholeSaleProduct.AgriculturalProductId,
                AgriculturalProductName = wholeSaleProduct.AgriculturalProductName,
                WholeSaleProductId = wholeSaleId,
                WholeSaleProductName = wholeSaleProduct.ProductName,
                ToCompanyList = CompanySvc.LoadCompanyByType((short)CompanyType.RetailCompany)
            };

            return View(model);
        }
 public ActionResult Cut(int parentId)
 {
     var product = RetailProductSvc.LoadById(parentId);
     var model = new RetailProductEditModel
     {
         ParentId = parentId,
         AgriculturalProductId = product.AgriculturalProductId,
         AgriculturalProductName = product.AgriculturalProductName,
         WholeSaleProductId = product.WholeSaleProductId,
         WholeSaleProductName = product.WholeSaleProductName,
         ToCompanyId = product.ToCompany.Id
     };
     return View(model);
 }
        public ActionResult Retail(int id)
        {
            var product = RetailProductSvc.LoadById(id);
            var model = new RetailProductEditModel(product);

            return View(model);
        }
        public ActionResult Cut(RetailProductEditModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError(string.Empty, "请输入正确信息");
                return View(model);
            }

            IIdentity id = HttpContext.User.Identity;
            var product = RetailProductSvc.LoadById(model.ParentId);

            model.AgriculturalProductId = product.AgriculturalProductId;
            model.AgriculturalProductName = product.AgriculturalProductName;
            model.WholeSaleProductId = product.WholeSaleProductId;
            model.WholeSaleProductName = product.WholeSaleProductName;
            model.InsertUserName = id.Name;
            model.ProductStatus = ProductStatus.CanRetail;
            model.InsertDate = DateTime.Now;

            int productId = RetailProductSvc.Insert(model.ToRetailProduct());
            if (productId > 0)
            {
                product.ProductStatus = ProductStatus.CutRetailProduct;
                RetailProductSvc.Update(product);
            }

            return RedirectToAction("CutProduct");
        }