Пример #1
0
        public ActionResult Edit([Bind(Include = "ID,Name,DrugGenericNameID,ManufacturerID,Categeory,AlertQty,Description,LastUpdated")] Item item)
        {
            if (ModelState.IsValid)
            {
                var original = db.Item.Find(item.ID);

                if (original.Name != item.Name)
                {
                    int count = DuplicateCount(item);

                    if (count > 0)
                    {
                        ViewBag.DuplicateError = "Item already exists!!";
                        return(View(item));
                    }
                }

                db.Entry(original).CurrentValues.SetValues(item);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.DrugGenericNameID = new SelectList(db.DrugGenericName, "ID", "GenericName", item.DrugGenericNameID);
            ViewBag.ManufacturerID    = new SelectList(db.Manufacturer, "ID", "ManufacturerName", item.ManufacturerID);
            return(View(item));
        }
        public ActionResult Edit([Bind(Include = "ID,GenericName,Description")] DrugGenericName drugGenericName)
        {
            if (ModelState.IsValid)
            {
                //get old generic name
                var original = db.DrugGenericName.Find(drugGenericName.ID);

                //compare old name to new
                if (original.GenericName != drugGenericName.GenericName)
                {
                    //check for duplication
                    int count = DuplicateCount(drugGenericName);


                    if (count > 0)
                    {
                        //error message
                        ViewBag.DuplicateError = "Generic name already Exists!!";
                        return(View(drugGenericName));
                    }
                }

                db.Entry(original).CurrentValues.SetValues(drugGenericName);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(drugGenericName));
        }
Пример #3
0
 public ActionResult Edit([Bind(Include = "ID,Date,Amount,Discount,Tax,GrandTotal,UserID,Remarks")] pharmacy.Models.Sale sales)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sales).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sales));
 }
Пример #4
0
 public ActionResult Edit([Bind(Include = "ID,ItemID,BatchNo,Qty,CostPrice,SellingPrice,ManufacturedDate,ExpiryDate,InitialQty,ItemExpired,Stop_Notification,PurchaseID")] Stock stock)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stock).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ItemID = new SelectList(db.Item, "ID", "Name", stock.ItemID);
     return(View(stock));
 }
Пример #5
0
 public ActionResult Edit([Bind(Include = "ID,Date,SupplierID,Amount,Discount,Tax,GrandTotal,IsPaid,LastUpdated,Description")] pharmacy.Models.Purchase purchase)
 {
     if (ModelState.IsValid)
     {
         db.Entry(purchase).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SupplierID = new SelectList(db.Supplier, "ID", "Name", purchase.SupplierID);
     return(View(purchase));
 }
Пример #6
0
        public ActionResult Edit([Bind(Include = "ID,ManufacturerName,Description")] Manufacturer manufacturer)
        {
            if (ModelState.IsValid)
            {
                //Get old object
                var original = db.Manufacturer.Find(manufacturer.ID);

                //Compare old name with modified name
                if (original.ManufacturerName != manufacturer.ManufacturerName)
                {  //check if Dublicate exists
                    int count = repo.ManufacturerDuplicationCheck(manufacturer);
                    //if yes throw erorr
                    if (count > 0)
                    {
                        ViewBag.DuplicateError = "Already Exists!!";
                        return(View(manufacturer));
                    }
                }
                db.Entry(original).CurrentValues.SetValues(manufacturer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(manufacturer));
        }