Beispiel #1
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            MedicineInventory newItem = new MedicineInventory()
            {
                GenericName   = tbx_gen.Text,
                BrandName     = tbx_brd.Text,
                Dosage        = tbx_dsg.Text,
                StocksLeft    = int.Parse(tbx_amt.Text),
                TimeLastAdded = DateTime.Now
            };

            ContentDialogButtonClickDeferral deferral = args.GetDeferral();

            try
            {
                var result = await AddMedicineViaDataServiceAsync(newItem);

                NewMedicine = result;
                Result      = AddMedicineResult.Success;
            }
            catch (Exception)
            {
                Result = AddMedicineResult.AddFailed;
            }
            deferral.Complete();
        }
Beispiel #2
0
 private void UpdateMedicineInventory(List <PurchaseOrder> poItems)
 {
     using (HISDBEntities hs = new HISDBEntities())
     {
         foreach (PurchaseOrder po in poItems)
         {
             var minventory = hs.MedicineInventories.Where(mi => mi.MedicineID == po.MedicineID).ToList();
             if (minventory != null && minventory.Count() > 0)
             {
                 var m = minventory[0];
                 m.AvailableQty    = m.AvailableQty + po.OrderedQty;
                 m.PricePerItem    = po.PricePerItem;
                 hs.Entry(m).State = EntityState.Modified;
             }
             else
             {
                 MedicineInventory newM = new MedicineInventory();
                 newM.MedicineID   = po.MedicineID;
                 newM.AvailableQty = po.OrderedQty;
                 hs.MedicineInventories.Add(newM);
             }
         }
         hs.SaveChanges();
     }
 }
 public ActionResult AddModify(MedicineMaster mm)
 {
     using (HISDBEntities db = new HISDBEntities())
     {
         if (mm.MMID == 0)
         {
             //AddSupplierCategories(mm);
             db.MedicineMasters.Add(mm);
             MedicineInventory mi = new MedicineInventory();
             mi.MedicineID   = mm.MMID;
             mi.AvailableQty = 0;
             db.MedicineInventories.Add(mi);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             //AddSupplierCategories(mm);
             var mi = db.MedicineInventories.Where(m => m.MedicineID == mm.MMID).FirstOrDefault();
             if (mi != null)
             {
                 mi.PricePerItem = mm.ItemPrice;
                 mi.AvailableQty = mm.AvailableQuantity;
             }
             db.Entry(mi).State = EntityState.Modified;
             db.Entry(mm).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Beispiel #4
0
        private async Task <MedicineInventory> AddMedicineViaDataServiceAsync(MedicineInventory newItem)
        {
            try
            {
                ImsDataService imsSvc = new ImsDataService(App.ApiSettings);
                var            result = await imsSvc.AddNewMedicineInventoryAsync(newItem);

                return(result);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task <MedicineInventory> UpdateMedicineInventoryAsync(MedicineInventory item)
        {
            try
            {
                string data_raw = JsonConvert.SerializeObject(item);

                string updatedItem = await _imsApi.PutMedicineInventoryAsync(item.ID, data_raw);

                MedicineInventory returnObj = JsonConvert.DeserializeObject <MedicineInventory>(updatedItem);
                return(returnObj);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task <MedicineInventory> AddNewMedicineInventoryAsync(MedicineInventory item)
        {
            try
            {
                string data_raw = JsonConvert.SerializeObject(item);

                string receivedItem = await _imsApi.PostMedicineInventoryAsync(data_raw);

                MedicineInventory returnObj = JsonConvert.DeserializeObject <MedicineInventory>(receivedItem);
                return(returnObj);
            }
            catch (Exception)
            {
                throw;
            }
        }