public ActionResult confirmprocesspayroll(PayslipBatchHeader payslipbatchheader) { using (var dbcntx = new HrDataContext()) { var salaryprocesslist = dbcntx.SalaryStructureHeaders .Join(dbcntx.SalaryStructureDetails, a => a.StructureID, b => b.StructureID, (a, b) => new { A = a, B = b }). Where(x => x.A.BranchId.Value == BRANCHID && x.A.EffectiveDate.Value.Month == payslipbatchheader.Month && x.A.EffectiveDate.Value.Year == payslipbatchheader.Year && x.A.IsActive == true). Select(x => new ProcessTable { EmployeeId = x.A.EmployeeId.Value, RegisterCode = x.B.PaymentType, ContributionCode = x.B.Code, Amount = x.B.Amount, }).ToList(); var payslipheader = new PayslipBatchHeader() { BatchNo = payslipbatchheader.BatchNo, BranchId = BRANCHID, Month = payslipbatchheader.Month, Year = payslipbatchheader.Year, ProcessDate = payslipbatchheader.ProcessDate, TotalSalary = payslipbatchheader.TotalSalary, }; //if (payrollvm.payslipBatchHeader == null) // payrollvm.payslipBatchHeader = new PayslipBatchHeader(); PayslipbatchheaderBo.Add(payslipheader); if (salaryprocesslist != null && salaryprocesslist.Count != 0) { for (var i = 0; i < salaryprocesslist.Count; i++) { var payslipbatchdetail = new PayslipBatchDetail() { BatchHeaderId = payslipheader.BatchHeaderId, BatchNo = payslipheader.BatchNo, BranchId = payslipheader.BranchId, EmployeeId = salaryprocesslist[i].EmployeeId, RegisterCode = salaryprocesslist[i].RegisterCode, ContributionCode = salaryprocesslist[i].ContributionCode, Amount = salaryprocesslist[i].Amount, }; payslipbatchdetailBo.Add(payslipbatchdetail); } } } return(RedirectToAction("ProcessPayroll")); }
public void Delete(PayslipBatchHeader entity) { try { PayslipBatchHeaderRepository.Delete(entity); } catch (Exception ex) { throw ex; } }
public void Add(PayslipBatchHeader input) { try { input.CreateBy = sessionObj.USERID; input.CreatedOn = UTILITY.SINGAPORETIME; PayslipBatchHeaderRepository.Add(input); } catch (Exception ex) { throw ex; } }
public ActionResult DeleteProcessedPayroll(int month, int year) { bool success = false; string message = ""; int Currentmonth = DateTime.Now.Month; int Currentyear = DateTime.Now.Year; var checkpreviousmonths = PayslipbatchheaderBo.GetListByProperty(x => x.BranchId == BRANCHID && x.Month > month && x.Year == year).ToList(); if (checkpreviousmonths.Count() > 0) { success = true; message = "Please delete the next months Payroll first."; } else { PayslipBatchHeader DeletePayrollObjheader = PayslipbatchheaderBo.GetByProperty(x => x.BranchId == BRANCHID && x.Month == month && x.Year == year); if (DeletePayrollObjheader != null) { List <PayslipBatchDetail> DeletePayrollObjdetail = payslipbatchdetailBo.GetListByProperty(x => x.BatchHeaderId == DeletePayrollObjheader.BatchHeaderId).ToList(); if (DeletePayrollObjheader != null) { PayslipbatchheaderBo.Delete(DeletePayrollObjheader); foreach (var item in DeletePayrollObjdetail) { payslipbatchdetailBo.Delete(item); } success = false; message = ""; } } else { success = true; message = "Deletion Is Not Possible Because Payroll is not generated yet For this Month.Please check."; //ViewData["message"] = "Payroll is not generated yet For this Month.Please check."; } } return(Json(new { success, message }, JsonRequestBehavior.AllowGet)); }