public ActionResult DeleteConfirmed(int id)
        {
            MedicineFactory medicineFactory = db.MedicineFactories.Find(id);

            db.MedicineFactories.Remove(medicineFactory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        private bool hasMadicineInStore(string medicine, string qty)
        {
            PharmacyDbContext db         = new PharmacyDbContext();
            string            medicineId = MedicineFactory.GetMedicineIdByName(medicine, db);
            int  totalPurchased          = db.PurchaseSub.Where(i => i.MedicinId == medicineId).ToList().Sum(o => o.Quantity);
            int  totalSale = db.SaleSub.Where(i => i.MedicinId == medicineId).ToList().Sum(o => o.Quantity);
            bool result    = totalPurchased > (totalSale + Convert.ToInt32(qty));

            return(result);
        }
 public ActionResult Edit([Bind(Include = "MedicineFactoryID,MedicineFactoryName")] MedicineFactory medicineFactory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(medicineFactory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(medicineFactory));
 }
        public ActionResult Create([Bind(Include = "MedicineFactoryID,MedicineFactoryName")] MedicineFactory medicineFactory)
        {
            if (ModelState.IsValid)
            {
                db.MedicineFactories.Add(medicineFactory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(medicineFactory));
        }
        // GET: MedicineFactories/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MedicineFactory medicineFactory = db.MedicineFactories.Find(id);

            if (medicineFactory == null)
            {
                return(HttpNotFound());
            }
            return(View(medicineFactory));
        }
예제 #6
0
 private void SaveSaleSub(PharmacyDbContext db, string purchaseMainId)
 {
     foreach (ListViewItem item in lvPurchaseMedicine.Items)
     {
         SaleSub sub = new SaleSub();
         sub.Id          = Guid.NewGuid().ToString();
         sub.MainId      = purchaseMainId;
         sub.MedicinId   = MedicineFactory.GetMedicineIdByName(item.SubItems[2].Text, db);
         sub.Quantity    = Convert.ToInt32(item.SubItems[3].Text);
         sub.UnitPrice   = Convert.ToDecimal(item.SubItems[4].Text);
         sub.Total       = Convert.ToDecimal(item.SubItems[5].Text);
         sub.CreatedBy   = currentUser;
         sub.CreatedDate = DateTime.Now;
         db.SaleSub.Add(sub);
     }
 }
예제 #7
0
 public static Medicine createMedicine(string name, string desc, int price, int stock)
 {
     return(MedicineFactory.createMedicine(name, desc, price, stock));
 }