public async Task <ActionResult> DeleteConfirmed(int id) { hr_EmpDedicationAllowance hr_EmpDedicationAllowance = await db.hr_EmpDedicationAllowance.FindAsync(id); db.hr_EmpDedicationAllowance.Remove(hr_EmpDedicationAllowance); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "EmpDedicationAllowanceID,DedicationAllowanceListID,EmployeeID,EmpBatchValue,EmpBatchDate")] hr_EmpDedicationAllowance hr_EmpDedicationAllowance) { if (ModelState.IsValid) { db.Entry(hr_EmpDedicationAllowance).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(hr_EmpDedicationAllowance)); }
public async Task <ActionResult> Create([Bind(Include = "EmpDedicationAllowanceID,DedicationAllowanceListID,EmployeeID,EmpBatchValue,EmpBatchDate")] hr_EmpDedicationAllowance hr_EmpDedicationAllowance) { if (ModelState.IsValid) { db.hr_EmpDedicationAllowance.Add(hr_EmpDedicationAllowance); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(hr_EmpDedicationAllowance)); }
// GET: EmpDedicationAllowance/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } hr_EmpDedicationAllowance hr_EmpDedicationAllowance = await db.hr_EmpDedicationAllowance.FindAsync(id); if (hr_EmpDedicationAllowance == null) { return(HttpNotFound()); } return(View(hr_EmpDedicationAllowance)); }
public ActionResult Save(hr_EmpDedicationAllowance Item) { int status = 0; // Start Validation cheack if (ModelState.IsValid) { var type = db.hr_DedicationAllowanceList.Find(Item.DedicationAllowanceListID).DeductionAllowanceID; //################### Edit Item ###################// if (Item.EmpDedicationAllowanceID > 0) { var v = db.hr_EmpDedicationAllowance.Where(I => I.EmpDedicationAllowanceID == Item.EmpDedicationAllowanceID).FirstOrDefault(); if (v != null) { updateSalary(Item.DedicationAllowanceListID, (int)v.EmpBatchValue, (int)Item.EmpBatchValue, Item.EmployeeID, type); v.EmpBatchValue = Item.EmpBatchValue; db.SaveChanges(); status = 1; // 1 for update /////////////////////////////// } status = 1; // 1 for update } //################### Edit Item //################### // Start Save New Item else { Item.EmpBatchDate = DateTime.Now; db.hr_EmpDedicationAllowance.Add(Item); db.SaveChanges(); ///////////////////////////////////////////// var salary = new hr_EmployeeSalary(); salary = db.hr_EmployeeSalary.Where(I => I.EmployeeID == Item.EmployeeID).FirstOrDefault(); if (type == 1) { salary.EmployeesSalaryAllownace = salary.EmployeesSalaryAllownace + (Double)Item.EmpBatchValue; } else { salary.EmployeesSalarydeducate = salary.EmployeesSalarydeducate + (Double)Item.EmpBatchValue; } db.SaveChanges(); status = 2; } //End Save New Item return(new JsonResult { Data = new { status = status } }); } // End Validation cheack // Start Send validation error else { var errorList = ModelState.Values.SelectMany(m => m.Errors) .Select(e => e.ErrorMessage) .ToList(); return(new JsonResult { Data = new { status = errorList } }); } // End Send validation error }