public JsonResult AddDrug(DrugTariff drugTariff, FormCollection form) { //Redirect to the creation page //get id from session int tariff = Convert.ToInt32(form["Tariffid"]); if (drugTariff != null) { TariffCategory lst = _tariffService.GetallTariffCategory().Where(x => x.Type == 0 && x.TariffId == tariff).FirstOrDefault(); if (lst == null) { TariffCategory category = new TariffCategory(); category.Type = 0; category.Name = "ALL"; category.TariffId = tariff; _tariffService.AddnewCategory(category); lst = category; } drugTariff.GroupId = lst.Id; drugTariff.Groupname = "ALL"; drugTariff.Price = Convert.ToDecimal(form["drugprice"]); _tariffService.AddnewDrugTariff(drugTariff); } return(Json("{result:1}", JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteDrug(DrugTariff tariff) { if (tariff.Id > 0) { bool response = _tariffService.DeleteDrug(tariff); } return(Json("{result:1}", JsonRequestBehavior.AllowGet)); }
public bool UpdateDrug(DrugTariff drugtariff) { if (drugtariff != null) { _session.Transact(session => session.Update(drugtariff)); return(true); } return(false); }
public bool DeleteDrug(DrugTariff drug) { if (drug != null) { _session.Transact(session => session.Delete(drug)); return(true); } return(false); }
public ActionResult EditDrug(int id) { int pageid = Convert.ToInt32(CurrentRequestData.CurrentContext.Request["id"]); DrugTariff tariff = _tariffService.GetDrug(id); // var lst = _tariffService.GetallTariffCategory().Where(x => x.Type == 0 && x.TariffId == pageid).ToList(); // ViewBag.drugGroup = lst; ViewBag.pricestr = Convert.ToString(tariff.Price); return(PartialView("EditDrugTariff", tariff)); }
public JsonResult EditDrug(DrugTariff drugTariff, FormCollection form) { if (drugTariff != null) { //var name = _tariffService.GetCategory(drugTariff.GroupId).Name; //drugTariff.Groupname = name.ToUpper(); drugTariff.Price = Convert.ToDecimal(form["drugprice"]); _tariffService.UpdateDrug(drugTariff); } return(Json("{result:1}", JsonRequestBehavior.AllowGet)); }
public bool AddnewDrugTariff(DrugTariff drug) { if (drug != null) { _session.Transact(session => session.Save(drug)); return(true); } else { return(false); } }
public ActionResult UploadService(FormCollection form) { if (CurrentRequestData.CurrentContext.Request.Files.Count > 0) { System.Web.HttpPostedFileBase file = CurrentRequestData.CurrentContext.Request.Files[0]; int mode = Convert.ToInt32(form["mode"]); int id = Convert.ToInt32(form["Tariffid"]); TariffCategory lst = _tariffService.GetallTariffCategory().Where(x => x.Type == 1 && x.TariffId == id && x.IsDeleted == false).FirstOrDefault(); if (lst == null) { TariffCategory category = new TariffCategory(); category.Type = 1; category.Name = "ALL"; category.TariffId = Convert.ToInt32(id); _tariffService.AddnewCategory(category); lst = category; } //the new reading using csv try { using (TextReader reader = new StreamReader(file.InputStream)) { CsvReader csv = new CsvReader(reader); List <UploadTariffCSV> records = csv.GetRecords <UploadTariffCSV>().ToList(); foreach (UploadTariffCSV item in records) { ServiceTariff servicetariff = new ServiceTariff(); servicetariff.GroupId = lst.Id; servicetariff.Name = item.itemname.ToUpper(); servicetariff.Description = item.itemname.ToUpper(); servicetariff.Unit = item.unit.ToUpper(); servicetariff.Price = item.price; servicetariff.Groupname = lst.Name.ToUpper(); servicetariff.Remark = item.remark; if (item.authorizationRequired.ToLower().Contains("y")) { servicetariff.PreauthorizationRequired = true; } else { servicetariff.PreauthorizationRequired = false; } if (mode > 0 && !string.IsNullOrEmpty(servicetariff.Name)) { _tariffService.AddnewServiceTariff(servicetariff); } else { //do for drug lst = _tariffService.GetallTariffCategory().Where(x => x.Type == 0 && x.TariffId == id).FirstOrDefault(); if (lst == null) { TariffCategory category = new TariffCategory(); category.Type = 0; category.Name = "ALL"; category.TariffId = Convert.ToInt32(id); _tariffService.AddnewCategory(category); lst = category; } DrugTariff drugariff = new DrugTariff(); drugariff.GroupId = lst.Id; drugariff.Name = item.itemname.ToUpper(); drugariff.Description = item.itemname.ToUpper(); drugariff.Unit = item.unit.ToUpper(); drugariff.Price = item.price; drugariff.Groupname = lst.Name.ToUpper(); drugariff.Remark = item.remark; if (item.authorizationRequired.ToLower().Contains("y")) { drugariff.PreauthorizationRequired = true; } else { drugariff.PreauthorizationRequired = false; } if (!string.IsNullOrEmpty(drugariff.Name)) { _tariffService.AddnewDrugTariff(drugariff); } } } } } catch (Exception ex) { _pageMessageSvc.SetErrormessage("There was an error reading the CSV uploaded,kindly check the format and try again."); return (Redirect( string.Format( _uniquePageService.GetUniquePage <TariffContentPage>().AbsoluteUrl + "?id={0}", id))); } } else { _pageMessageSvc.SetErrormessage("You have not uploaded any file."); return (Redirect(CurrentRequestData.CurrentContext.Request.UrlReferrer.AbsoluteUri)); } _pageMessageSvc.SetSuccessMessage("File Upload Complete."); return (Redirect(CurrentRequestData.CurrentContext.Request.UrlReferrer.AbsoluteUri)); }
public ActionResult DeleteDrug(int id) { DrugTariff item = _tariffService.GetDrug(id); return(PartialView("DeleteDrug", item)); }
public DrugTariff GetDrug(int id) { DrugTariff drugtariff = _session.QueryOver <DrugTariff>().Where(x => x.Id == id).SingleOrDefault(); return(drugtariff); }