Ejemplo n.º 1
0
        public ActionResult SalePrice(int id, int? productId, FormCollection collection)
        {
            if (!UserInfo.CurUser.HasRight("业务管理-产品销售价格录入")) return Redirect("~/content/AccessDeny.htm");
            ProductSalePrice price = null;
            if (id != 0)
            {
                price = db.ProductSalePrices.Find(id);
            }
            else
            {
                price = new ProductSalePrice { ProductId = (int)productId, ActivateDate = DateTime.Today ,State=PriceState.Activate};
                db.ProductSalePrices.Add(price);
            }
            Product p = db.Products.Find(price.ProductId);
            TryUpdateModel(price, "", new string[] { }, new string[] { }, collection);

            if (ModelState.IsValid)
            {
                if(price.State==PriceState.Activate)p.SalePrice = price.SalePrice;
                if (id == 0)
                {
                    (from o in db.ProductSalePrices
                     where o.ProductId == price.ProductId && o.State == PriceState.Activate
                     select o).ToList().ForEach(o => o.State = PriceState.Old);
                }
                db.SaveChanges();
                if (id == 0)
                {
                    BLL.Utilities.AddLogAndSave(price.ProductId, Product.LogClass, "增加销售报价记录", price.SalePrice.ToString());

                }
                else
                {
                    BLL.Utilities.AddLogAndSave(price.ProductId, Product.LogClass, "修改销售报价记录", price.SalePrice.ToString());
                }
                return Redirect("~/content/close.htm");
            }

            ViewBag.Product = p;
            return View(price);
        }
Ejemplo n.º 2
0
 public ActionResult SalePrice(int id, int? productId)
 {
     if (!UserInfo.CurUser.HasRight("业务管理-产品采购价格录入")) return Redirect("~/content/AccessDeny.htm");
     ProductSalePrice price = null;
     if (id != 0)
     {
         price = db.ProductSalePrices.Find(id);
     }
     else
     {
         price = new ProductSalePrice { ProductId = (int)productId };
     }
     ViewBag.Product = db.Products.Find(price.ProductId);
     return View(price);
 }