public ActionResult Edit(int id) { SetupPathoTestModel model = new SetupPathoTestModel(); model = pro.GetList().Where(x => x.TestId == id).FirstOrDefault(); return(View(model)); }
public ActionResult Index() { SetupPathoTestModel model = new SetupPathoTestModel(); model.PathoTestList = pro.GetList(); return(View(model)); }
public ActionResult SearchIndex(string TestName) { SetupPathoTestModel model = new SetupPathoTestModel(); string PathoTestName = string.Empty; if (!string.IsNullOrEmpty(TestName)) { TestName = TestName.ToLower(); model.PathoTestList = pro.GetList().Where(x => x.TestName.ToLower().StartsWith(TestName)).ToList(); } return(View("Index", model)); }
public int Update(SetupPathoTestModel model) { using (EHMSEntities ent = new EHMSEntities()) { var objToEdit = ent.SetupPathoTests.Where(x => x.TestId == model.TestId).FirstOrDefault(); decimal TaxTotal = Convert.ToDecimal((model.PayableGrandTotal * 5) / 100); decimal PathoTaxTotal = Convert.ToDecimal((model.PathologyCommAmt * 5) / 100); AutoMapper.Mapper.Map(model, objToEdit); objToEdit.PayableTaxTotal = TaxTotal; objToEdit.PathologyCommPer = PathoTaxTotal; ent.Entry(objToEdit).State = System.Data.EntityState.Modified; ent.SaveChanges(); } return(1); }
public ActionResult Edit(int id, SetupPathoTestModel model) { if (ModelState.IsValid) { int i = pro.Update(model); if (i == 1) { TempData["success"] = "Record Updated Successfully !"; } else { TempData["success"] = "Record Updation Failed !"; } return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create(SetupPathoTestModel model) { if (ModelState.IsValid) { //int i = pro.Insert(model); //if (i == 1) //{ // TempData["success"] = "Record Created Successfully !"; //} //else //{ // TempData["success"] = "Record Creation Failed !"; //} //return RedirectToAction("Index"); EHMSEntities ent = new EHMSEntities(); var data = ent.SetupPathoTests.Where(m => m.TestName == model.TestName).Select(m => m.TestId).ToList(); if (data.Count == 0) { int i = pro.Insert(model); if (i == 1) { TempData["success"] = HospitalManagementSystem.UtilityMessage.save; return(RedirectToAction("Index")); } else { TempData["success"] = HospitalManagementSystem.UtilityMessage.savefailed; return(RedirectToAction("Index")); } } else { TempData["success"] = "Test Name Already Exist !"; return(RedirectToAction("Index")); } } return(View(model)); }
public int Insert(SetupPathoTestModel model) { using (EHMSEntities ent = new EHMSEntities()) { var objToSave = AutoMapper.Mapper.Map <SetupPathoTestModel, SetupPathoTest>(model); objToSave.CreatedBy = 1; objToSave.CreatedDate = DateTime.Now; objToSave.Status = 1; decimal TaxTotal = Convert.ToDecimal((model.PayableGrandTotal * 5) / 100); objToSave.PayableTaxTotal = TaxTotal; decimal PathoTaxTotal = Convert.ToDecimal((model.PathologyCommAmt * 5) / 100); objToSave.PathologyCommPer = PathoTaxTotal; ent.SetupPathoTests.Add(objToSave); ent.SaveChanges(); int LastInsertedId = objToSave.TestId; //insert into Gl_accsub group coa if (model.SectionId == 24) { var GlAccSubgroup = new GL_AccSubGroups() { AccGroupID = 3, AccSubGroupName = model.TestName, ParentID = 423, HierarchyCode = "3.1.2.3.423", HeadLevel = 6, AccountCode = null, IsLeafLevel = true, Status = true, CreatedBy = Utility.GetCurrentLoginUserId(), CreatedDate = DateTime.Today, Remarks = "SpecialTest", BranchId = 1 }; ent.GL_AccSubGroups.Add(GlAccSubgroup); ent.SaveChanges(); int LastInsertedCoaId = GlAccSubgroup.AccSubGruupID; //Update setuppatho test SetupPathoTest PathoTest = (from x in ent.SetupPathoTests where x.TestId == LastInsertedId select x).First(); PathoTest.AccountHeadId = LastInsertedCoaId; try { ent.SaveChanges(); } catch (DbEntityValidationException ex) { StringBuilder sb = new StringBuilder(); foreach (var failure in ex.EntityValidationErrors) { sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType()); foreach (var error in failure.ValidationErrors) { sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage); sb.AppendLine(); } } throw new DbEntityValidationException( "Entity Validation Failed - errors follow:\n" + sb.ToString(), ex ); // Add the original exception as the innerException } } } return(1); }
public ActionResult Create() { SetupPathoTestModel model = new SetupPathoTestModel(); return(View(model)); }