コード例 #1
0
        public ActionResult Create(BuyPrice buyprice)
        {
            if (ModelState.IsValid)
            {
                db.BuyPrices.Add(buyprice);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Code", buyprice.ProductId);
            ViewBag.CustomerTypeId = new SelectList(db.CustomerTypes, "CustomerTypeId", "Name", buyprice.CustomerTypeId);
            ViewBag.ProductUnitId = new SelectList(db.ProductUnits, "ProductUnitId", "Name", buyprice.ProductUnitId);
            return View(buyprice);
        }
コード例 #2
0
 public ActionResult Edit(BuyPrice buyprice)
 {
     if (ModelState.IsValid)
     {
         db.Entry(buyprice).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Code", buyprice.ProductId);
     ViewBag.CustomerTypeId = new SelectList(db.CustomerTypes, "CustomerTypeId", "Name", buyprice.CustomerTypeId);
     ViewBag.ProductUnitId = new SelectList(db.ProductUnits, "ProductUnitId", "Name", buyprice.ProductUnitId);
     return View(buyprice);
 }