public ActionResult Create(PayrollTransactionJournalSetup model, int Type) { try { ViewBag.salaryitem = dbcontext.salary_code.ToList().Select(m => new { Code = m.SalaryCodeID + "-[" + m.SalaryCodeDesc + ']', ID = m.ID }); if (ModelState.IsValid) { PayrollTransactionJournalSetup record = new PayrollTransactionJournalSetup(); record.JournalName_BatchCode = model.JournalName_BatchCode; record.JournalDesc = model.JournalDesc; record.JournalAltDesc = model.JournalAltDesc; record.JournalType = Type; record.SalaryCodeID = model.SalaryCodeID; dbcontext.PayrollTransactionJournalSetup.Add(record); dbcontext.SaveChanges(); return(RedirectToAction("Index")); } else { return(View(model)); } } catch (DbUpdateException) { TempData["Message"] = HR.Resource.Basic.thiscodeIsalreadyexists; return(View(model)); } catch (Exception e) { return(View(model)); } }
public ActionResult Create() { ////// ViewBag.salaryitem = dbcontext.salary_code.ToList().Select(m => new { Code = m.SalaryCodeID + "-[" + m.SalaryCodeDesc + ']', ID = m.ID }); var modell = new PayrollTransactionJournalSetup(); var stru = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Payroll).Structure_Code; var model = dbcontext.PayrollTransactionJournalSetup.ToList(); if (model.Count() == 0) { modell.JournalName_BatchCode = stru + "1"; } else { modell.JournalName_BatchCode = stru + (model.LastOrDefault().ID + 1).ToString(); } ///// return(View(modell)); }
public ActionResult Edit(PayrollTransactionJournalSetup model, int Type) { try { ViewBag.salaryitem = dbcontext.salary_code.ToList().Select(m => new { Code = m.SalaryCodeID + "-[" + m.SalaryCodeDesc + ']', ID = m.ID }); var record = dbcontext.PayrollTransactionJournalSetup.FirstOrDefault(m => m.ID == model.ID); record.JournalName_BatchCode = model.JournalName_BatchCode; record.JournalDesc = model.JournalDesc; record.JournalAltDesc = model.JournalAltDesc; record.JournalType = Type; record.SalaryCodeID = model.SalaryCodeID; dbcontext.SaveChanges(); return(RedirectToAction("index")); } catch (DbUpdateException) { TempData["Message"] = HR.Resource.Basic.thiscodeIsalreadyexists; return(View(model)); } catch (Exception e) { return(View(model)); } }