EchoTex_Payroll/HRM.Report/Class/EmpLeaveLedger.cs

493 lines
29 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using HRM.BO;
using HRM.DA;
using Microsoft.Reporting.NETCore;
using Microsoft.Reporting.NETCore.Internal.Soap.ReportingServices2005.Execution;
using Microsoft.VisualBasic;
using NPOI.SS.Formula.Functions;
namespace HRM.Report
{
public class EmpLeaveLedger
{
public EmpLeaveLedger()
{
}
/*public static List<LeaveParameter> ApplicableParams(Employee oEmp, int payrollTypeId)
{
LeaveParameterService leaveParameterService = new LeaveParameterService();
List<int> leaveParamIds = SetupManager.ApplicableParameters(oEmp, EnumParameterSetup.Leave);
List<LeaveParameter> leaveParamss = leaveParameterService.Get(true, payrollTypeId);
List<LeaveParameter> leaveParams = new List<LeaveParameter>();
foreach (LeaveParameter lparam in leaveParamss)
{
if (lparam.Leave.ApplicableFor != (EnumGender)oEmp.Gender && lparam.Leave.ApplicableFor != EnumGender.Other && lparam.Leave.ApplicableFor != EnumGender.None)
{
continue;
}
bool found = false;
foreach (int id in leaveParamIds)
{
if (id == lparam.ID)
{
found = true;
break;
}
}
if (found)
{
switch (lparam.ApplicableFor)
{
case LeaveApplicableType.Probetionary:
if (!oEmp.IsConfirmed)
{
leaveParams.Add(lparam);
}
break;
case LeaveApplicableType.Confirmed:
if (oEmp.IsConfirmed)
{
leaveParams.Add(lparam);
}
break;
case LeaveApplicableType.Regardless:
leaveParams.Add(lparam);
break;
default:
break;
}
}
}
return leaveParams;
}*/
//#region New code for ShowReportNew 2023
public byte[] ShowReportNew(string sEmpIDs, int leaveYear, int payrollTypeId, string reportType)
{
//DateTime fromDate = DateTime.Now, toDate = DateTime.Now;
DataSet dsSub = null;
string caption = "Employee Leave Balance";
//string embeddedResource = "LeaveLedgerNmgt.rdlc";
string embeddedResource = "";
//SystemInformation systemInformation = new SystemInformationService().Get();
var companyNameObj = new SystemConfigarationService().GetconfigValue(EnumConfigurationType.Logic, "system", "company");
string companyName = Convert.ToString(companyNameObj);
//string[] sEmp = sEmpID.Split(new char[] { ',' });
List<EmpLeaveStatus> oCurrYearLeaveStatusEmployee = new LeaveProcessService().GetLeaveBalance(leaveYear, payrollTypeId, sEmpIDs);
//var employee = new EmployeeService().Get(int.Parse(sEmpIDs));
DataSet resultDataSet = new DataSet();
DataTable oBody = new PayrollDataSet.dsEmpLeaveLedger.EmpLeaveLedgerDataTable();
DataTable oBody2 = new PayrollDataSet.dsEmpLeaveLedger.EmpInformationDataTable();
DataTable oBody3 = new PayrollDataSet.dsEmpLeaveLedger.LeaveYearDataTable();
DataTable oBody4 = new PayrollDataSet.dsEmpLeaveLedger.LeaveBalanceDataTable();
List<Employee> employees = new EmployeeService().Get(sEmpIDs);
List<LeaveEntry> oLeaveEntrysEmployees = new List<LeaveEntry>();
oLeaveEntrysEmployees = new LeaveEntryService().GetEmployeeWiseLeaveDetailReport(sEmpIDs, leaveYear, 0);
foreach (Employee employee in employees)
{
employee.Department = employee.DepartmentID != null ? new DepartmentService().Get(employee.DepartmentID.Value) : null;
employee.Designation = employee.DesignationID != null ? new DesignationService().Get(employee.DesignationID.Value) : null;
List<LeaveEntry> oLeaveEntrys = new List<LeaveEntry>();
oLeaveEntrys = oLeaveEntrysEmployees.FindAll( x=> x.EmpID == employee.ID);
//oLeaveEntrys = new LeaveEntryService().GetEmployeeWiseLeaveDetailReport(sEmpIDs, fromDate, toDate, leaveType);
oLeaveEntrys = oLeaveEntrys.OrderBy(x => x.AppliedLeaveDate).ToList();
List<EnmSetupManagerTranType> setupTypes = new SetupDetailService().GetTypes(EnumParameterSetup.Leave);
//List<SetupDetail> setupDetails = new SetupDetailService().GetParameters(EnumParameterSetup.Leave);
//List<LeaveParameter> leaveParamss = new LeaveParameterService().GetAllByPayrollTypeID(payrollTypeId);
//List<LeaveParameter> lps = LeaveParameterService.ApplicableParams(employee, setupTypes, setupDetails, leaveParamss);
LeaveParameter lp = null;
List<Employee> oEmps = new List<Employee>();
List<Leave> leaves = new LeaveService().GetAll();
oLeaveEntrys.ForEach(leaveEntry => leaveEntry.Leave = (leaves.Find(x => x.ID == leaveEntry.LeaveID)));
oEmps.Add(employee);
//List<EmpLeaveStatus> oCurrYearStatus = new LeaveProcessService().CurrentYearStatus(oEmps, new LeaveYearService().GetCurrentYear(), payrollTypeId);
//List<EmpLeaveStatus> oCurrYearStatus = new LeaveProcessService().GetLeaveBalance(oEmps, new LeaveYearService().GetCurrentYear(payrollTypeId), payrollTypeId);
List<EmpLeaveStatus> oCurrYearStatus = oCurrYearLeaveStatusEmployee.FindAll(x => x.EmpId == employee.ID);
//List<EmpLeaveStatus> GetLeaveBalance(leaveYear, payrollTypeId, EmpIDsIn, empID = null);
foreach (EmpLeaveStatus oItem in oCurrYearStatus)
{
oItem.Leave = leaves.Find(x => x.ID == oItem.LeaveId);
////lp = lps.FirstOrDefault(o => o.LeaveId == oItem.LeaveId);
//if (lp != null && (lp.CalculationType == EnumLeaveCalculationType.Hourly || lp.CalculationType == EnumLeaveCalculationType.Hourly_Prorated))
//{
// if (lp.MaxAccumulatedDays > 0)
// oBody4.Rows.Add(oItem.Leave.Description, Math.Round(oItem.OpeningBalance / 8, 2).ToString(), Math.Round(oItem.LeaveAvailed / 8, 2).ToString(), Math.Round(oItem.ClosingBalance / 8).ToString(),
// employee.EmployeeNo, "", "", "", "", "", oItem.OpeningBalance.ToString(), oItem.LeaveAvailed.ToString(), oItem.ClosingBalance.ToString(), Math.Round(lp.MaxAccumulatedDays / 8, 2), lp.MaxAccumulatedDays);
//}
//else if (lp != null)
//{
// if (lp.MaxAccumulatedDays > 0)
// oBody4.Rows.Add(oItem.Leave.Description, oItem.OpeningBalance.ToString(), oItem.LeaveAvailed.ToString(), oItem.ClosingBalance.ToString(),
// employee.EmployeeNo, "", "", "", "", "", (oItem.OpeningBalance * 8).ToString(), (oItem.LeaveAvailed * 8).ToString(), (oItem.ClosingBalance * 8).ToString(), lp.MaxAccumulatedDays, lp.MaxAccumulatedDays * 8);
//}
oBody4.Rows.Add(oItem.Leave.Description, oItem.OpeningBalance.ToString(), oItem.LeaveAvailed.ToString(), oItem.ClosingBalance.ToString(),
employee.EmployeeNo, "", "", "", "", "", "", "", "", 0, 0);
}
try
{
List<EmployeeWorkPlanSetup> empWPGroups = new EmployeeWorkPlanSetupService().Get();
EmployeeWorkPlanSetup oEmployeeWorkPlanSetup = null;
List<WorkPlanGroup> workPGroups = new WorkPlanGroupService().GetAll();
WorkPlanGroup oWorkPlanGroup = null;
string shift = "";
oEmployeeWorkPlanSetup = empWPGroups.Where(o => o.EmployeeID == employee.ID).FirstOrDefault();
if (oEmployeeWorkPlanSetup != null)
{
oWorkPlanGroup = workPGroups.Where(o => o.ID == oEmployeeWorkPlanSetup.WorkPlanGroupID).FirstOrDefault();
//oMonthlyWorkPlan = monthlyWorkPlans.Where(o => o.WorkPlanGroupID == oWorkPlanGroup.ID && o.WorkDate == DateTime.Today).FirstOrDefault();
shift = oWorkPlanGroup == null ? "" : oWorkPlanGroup.Name;
}
oBody2.Rows.Add(employee.EmployeeNo, employee.Name, employee.Department != null ? employee.Department.Name : string.Empty, employee.Designation != null ? employee.Designation.Name : string.Empty, employee.JoiningDate.ToString("dd MMM yyyy"), shift);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
List<ReportDataSource> dataSource = new List<ReportDataSource>();
if (oLeaveEntrys != null)
{
foreach (LeaveEntry le in oLeaveEntrys)
{
if (le.Leave != null)
{
oBody.Rows.Add(employee.EmployeeNo, le.Leave.Description, le.ApprovedFromDate.ToString("dd MMM yyyy"), le.ApprovedToDate.ToString("dd MMM yyyy"), le.ApprovedTotalDays, le.Remarks, le.AppliedLeaveDate.ToString("MMM, yyyy"));
}
else
{
oBody.Rows.Add(employee.EmployeeNo, le.Leave.Description, le.ApprovedFromDate.ToString("dd MMM yyyy"), le.ApprovedToDate.ToString("dd MMM yyyy"), le.ApprovedTotalDays, le.Remarks, le.AppliedLeaveDate.ToString("MMM, yyyy"));
}
}
//dataSource.Add(new ReportDataSource("dsEmpLeaveLedger_EmpLeaveLedger", oBody));
}
//dataSource.Add(new ReportDataSource("dsEmpLeaveLedger_EmpInformation", oBody2));
//dataSource.Add(new ReportDataSource("dsEmpLeaveLedger_LeaveBalance", oBody4));
//string RDLCName = "HRM.Report.RDLC.LeaveLedgerNmgt.rdlc";
}
DataSet subDataSet = new DataSet();
List<Microsoft.Reporting.NETCore.ReportParameter> reportParameters = new List<Microsoft.Reporting.NETCore.ReportParameter>();
string RDLCName;
if (companyName == "SGS Bangladesh Limited")
{
RDLCName = "HRM.Report.RDLC.LeaveLedgerSGS.rdlc";
subDataSet = null;
embeddedResource = "LeaveLedgerSGS.rdlc";
oBody.TableName = "dsEmpLeaveLedger_EmpLeaveLedger";
resultDataSet.Tables.Add(oBody);
oBody2.TableName = "dsEmpLeaveLedger_EmpInformation";
resultDataSet.Tables.Add(oBody2);
oBody3.TableName = "dsEmpLeaveLedger_LeaveYear";
resultDataSet.Tables.Add(oBody3);
oBody4.TableName = "dsEmpLeaveLedger_LeaveBalance";
resultDataSet.Tables.Add(oBody4);
//reportParameters = null;
}
else
{
RDLCName = "HRM.Report.RDLC.LeaveLedgerNmgtMultiple.rdlc";
embeddedResource = "LeaveLedgerNmgtMultiple.rdlc";
oBody2.TableName = "dsEmpLeaveLedger_EmpInformation";
resultDataSet.Tables.Add(oBody2);
oBody4.TableName = "dsEmpLeaveLedger_LeaveBalance";
subDataSet.Tables.Add(oBody4);
oBody.TableName = "dsEmpLeaveLedger_EmpLeaveLedger";
subDataSet.Tables.Add(oBody);
}
string leavePeriod = "";
if (leaveYear != 0)
{
leavePeriod = new LeaveYearService().Get(leaveYear).Name;
}
Microsoft.Reporting.NETCore.ReportParameter rParam = new Microsoft.Reporting.NETCore.ReportParameter("Period", leavePeriod);
reportParameters.Add(rParam);
ReportProcessor reportProcessor = new ReportProcessor();
// return reportProcessor.ShowLeaveBalanceNew(dataSource, embeddedResource, caption, payrollTypeId, reportType);
return reportProcessor.CommonReportView(null, RDLCName, resultDataSet, subDataSet, reportParameters, true, payrollTypeId, reportType);
}
//#endregion
#region previous code for ShowReportNew
//public byte[] ShowReportNew(string sEmpIDs, DateTime fromDate, DateTime toDate, int leaveType, int payrollTypeId,
// string reportType)
//{
// DataSet dsSub = null;
// string caption = "Employee Leave Balance";
// //string embeddedResource = "LeaveLedgerNmgt.rdlc";
// string embeddedResource = "LeaveLedgerSGS.rdlc";
// //string[] sEmp = sEmpID.Split(new char[] { ',' });
// var employee = new EmployeeService().Get(int.Parse(sEmpIDs));
// //List<Employee> employee = new EmployeeService().Get(sEmpIDs);
// employee.Department = employee.DepartmentID != null ? new DepartmentService().Get(employee.DepartmentID.Value) : null;
// employee.Designation = employee.DesignationID != null ? new DesignationService().Get(employee.DesignationID.Value) : null;
// List<LeaveEntry> oLeaveEntrys = new List<LeaveEntry>();
// DataTable oBody = new PayrollDataSet.dsEmpLeaveLedger.EmpLeaveLedgerDataTable();
// DataTable oBody2 = new PayrollDataSet.dsEmpLeaveLedger.EmpInformationDataTable();
// DataTable oBody3 = new PayrollDataSet.dsEmpLeaveLedger.LeaveYearDataTable();
// DataTable oBody4 = new PayrollDataSet.dsEmpLeaveLedger.LeaveBalanceDataTable();
// oLeaveEntrys = new LeaveEntryService().GetEmployeeWiseLeaveDetailReport(sEmpIDs, fromDate, toDate, leaveType);
// oLeaveEntrys = oLeaveEntrys.OrderBy(x => x.AppliedLeaveDate).ToList();
// List<EnmSetupManagerTranType> setupTypes = new SetupDetailService().GetTypes(EnumParameterSetup.Leave);
// List<SetupDetail> setupDetails = new SetupDetailService().GetParameters(EnumParameterSetup.Leave);
// List<LeaveParameter> leaveParamss = new LeaveParameterService().GetAllByPayrollTypeID(payrollTypeId);
// List<LeaveParameter> lps = LeaveParameterService.ApplicableParams(employee, setupTypes, setupDetails, leaveParamss);
// LeaveParameter lp = null;
// List<Employee> oEmps = new List<Employee>();
// List<Leave> leaves = new LeaveService().GetAll();
// oLeaveEntrys.ForEach(leaveEntry => leaveEntry.Leave = (leaves.Find(x => x.ID == leaveEntry.LeaveID)));
// oEmps.Add(employee);
// //List<EmpLeaveStatus> oCurrYearStatus = new LeaveProcessService().CurrentYearStatus(oEmps, new LeaveYearService().GetCurrentYear(), payrollTypeId);
// List<EmpLeaveStatus> oCurrYearStatus = new LeaveProcessService().GetLeaveBalance(oEmps, new LeaveYearService().GetCurrentYear(payrollTypeId), payrollTypeId);
// foreach (EmpLeaveStatus oItem in oCurrYearStatus)
// {
// oItem.Leave = leaves.Find(x => x.ID == oItem.LeaveId);
// lp = lps.FirstOrDefault(o => o.LeaveId == oItem.LeaveId);
// if (lp != null && (lp.CalculationType == EnumLeaveCalculationType.Hourly || lp.CalculationType == EnumLeaveCalculationType.Hourly_Prorated))
// {
// if (lp.MaxAccumulatedDays > 0)
// oBody4.Rows.Add(oItem.Leave.Description, Math.Round(oItem.OpeningBalance / 8, 2).ToString(), Math.Round(oItem.LeaveAvailed / 8, 2).ToString(), Math.Round(oItem.ClosingBalance / 8).ToString(),
// "", "", "", "", "", "", oItem.OpeningBalance.ToString(), oItem.LeaveAvailed.ToString(), oItem.ClosingBalance.ToString(), Math.Round(lp.MaxAccumulatedDays / 8, 2), lp.MaxAccumulatedDays);
// }
// else if (lp != null)
// {
// if (lp.MaxAccumulatedDays > 0)
// oBody4.Rows.Add(oItem.Leave.Description, oItem.OpeningBalance.ToString(), oItem.LeaveAvailed.ToString(), oItem.ClosingBalance.ToString(),
// "", "", "", "", "", "", (oItem.OpeningBalance * 8).ToString(), (oItem.LeaveAvailed * 8).ToString(), (oItem.ClosingBalance * 8).ToString(), lp.MaxAccumulatedDays, lp.MaxAccumulatedDays * 8);
// }
// }
// try
// {
// List<EmployeeWorkPlanSetup> empWPGroups = new EmployeeWorkPlanSetupService().Get();
// EmployeeWorkPlanSetup oEmployeeWorkPlanSetup = null;
// List<WorkPlanGroup> workPGroups = new WorkPlanGroupService().GetAll();
// WorkPlanGroup oWorkPlanGroup = null;
// string shift = "";
// oEmployeeWorkPlanSetup = empWPGroups.Where(o => o.EmployeeID == employee.ID).FirstOrDefault();
// if (oEmployeeWorkPlanSetup != null)
// {
// oWorkPlanGroup = workPGroups.Where(o => o.ID == oEmployeeWorkPlanSetup.WorkPlanGroupID).FirstOrDefault();
// //oMonthlyWorkPlan = monthlyWorkPlans.Where(o => o.WorkPlanGroupID == oWorkPlanGroup.ID && o.WorkDate == DateTime.Today).FirstOrDefault();
// shift = oWorkPlanGroup == null ? "" : oWorkPlanGroup.Name;
// }
// oBody2.Rows.Add(employee.EmployeeNo, employee.Name, employee.Department != null ? employee.Department.Name : string.Empty, employee.Designation != null ? employee.Designation.Name : string.Empty, employee.JoiningDate.ToString("dd MMM yyyy"), shift);
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
// List<ReportDataSource> dataSource = new List<ReportDataSource>();
// if (oLeaveEntrys != null)
// {
// foreach (LeaveEntry le in oLeaveEntrys)
// {
// if (le.Leave != null)
// {
// oBody.Rows.Add("", le.Leave.Description, le.ApprovedFromDate.ToString("dd MMM yyyy"), le.ApprovedToDate.ToString("dd MMM yyyy"), le.ApprovedTotalDays, le.Remarks, le.AppliedLeaveDate.ToString("MMM, yyyy"));
// }
// else
// {
// oBody.Rows.Add("", le.Leave.Description, le.ApprovedFromDate.ToString("dd MMM yyyy"), le.ApprovedToDate.ToString("dd MMM yyyy"), le.ApprovedTotalDays, le.Remarks, le.AppliedLeaveDate.ToString("MMM, yyyy"));
// }
// }
// dataSource.Add(new ReportDataSource("dsEmpLeaveLedger_EmpLeaveLedger", oBody));
// }
// dataSource.Add(new ReportDataSource("dsEmpLeaveLedger_EmpInformation", oBody2));
// dataSource.Add(new ReportDataSource("dsEmpLeaveLedger_LeaveBalance", oBody4));
// //string RDLCName = "HRM.Report.RDLC.LeaveLedgerNmgt.rdlc";
// string RDLCName = "HRM.Report.RDLC.LeaveLedgerSGS.rdlc";
// DataSet resultDataSet = new DataSet();
// oBody.TableName = "dsEmpLeaveLedger_EmpLeaveLedger";
// resultDataSet.Tables.Add(oBody);
// oBody2.TableName = "dsEmpLeaveLedger_EmpInformation";
// resultDataSet.Tables.Add(oBody2);
// oBody3.TableName = "dsEmpLeaveLedger_LeaveYear";
// resultDataSet.Tables.Add(oBody3);
// oBody4.TableName = "dsEmpLeaveLedger_LeaveBalance";
// resultDataSet.Tables.Add(oBody4);
// ReportProcessor reportProcessor = new ReportProcessor();
// // return reportProcessor.ShowLeaveBalanceNew(dataSource, embeddedResource, caption, payrollTypeId, reportType);
// return reportProcessor.CommonReportView(null, RDLCName, resultDataSet, null, null, true, payrollTypeId, reportType);
//}
#endregion
public byte[] ShowReport(string sEmpIDs, DateTime fromDate, DateTime toDate, int leaveType, int payrollTypeId, string reportType)
{
LeaveEntryService leaveEntryService = new LeaveEntryService();
LeaveParameterService leaveParameterService = new LeaveParameterService();
LeaveProcessService leaveProcessService = new LeaveProcessService();
LeaveYearService leaveYearService = new LeaveYearService();
EmployeeWorkPlanSetupService workPlanSetupService = new EmployeeWorkPlanSetupService();
WorkPlanGroupService workPlanGroupService = new WorkPlanGroupService();
EmployeeService employeeService = new EmployeeService();
DepartmentService departmentService = new DepartmentService();
DesignationService designationService = new DesignationService();
DataSet dsSub = null;
List<ReportDataSource> dataSource = new List<ReportDataSource>();
string embeddedResource = "MultipleLeaveLedger.rdlc";
string caption = "Employee Leave Ledger";
List<LeaveEntry> oLeaveEntrys = new List<LeaveEntry>();
List<LeaveEntry> oLeaveEntrysIndividual = new List<LeaveEntry>();
List<Leave> leaves = new LeaveService().Get(EnumStatus.Active, payrollTypeId);
List<EmployeeWorkPlanSetup> empWPGroups = new EmployeeWorkPlanSetupService().Get();
List<WorkPlanGroup> workPGroups = new WorkPlanGroupService().GetAll();
List<Employee> employees = new List<Employee>();
List<Department> departments = new List<Department>();
List<Designation> designations = new List<Designation>();
DataTable oBody = new PayrollDataSet.dsEmpLeaveLedger.EmpLeaveLedgerDataTable();
DataTable oBody2 = new PayrollDataSet.dsEmpLeaveLedger.EmpInformationDataTable();
DataTable oBody3 = new PayrollDataSet.dsEmpLeaveLedger.LeaveYearDataTable();
DataTable oBody4 = new PayrollDataSet.dsEmpLeaveLedger.LeaveBalanceDataTable();
oLeaveEntrys = leaveEntryService.GetEmployeeWiseLeaveDetailReport(sEmpIDs, fromDate, toDate, leaveType);
foreach (var leaveEntry in oLeaveEntrys)
{
leaveEntry.Leave = leaves.Find(x => x.ID == leaveEntry.LeaveID);
}
//oLeaveEntrys = oLeaveEntrys.OrderBy(x => x.AppliedLeaveDate).ToObjectsTemplate();
employees = employeeService.GetByEmpIDs(sEmpIDs);
var arrDeptId= employees.Select(x => Convert.ToString(x.DepartmentID.GetValueOrDefault())).Distinct().ToArray();
var arrDesignationId= employees.Select(x => Convert.ToString(x.DesignationID.GetValueOrDefault())).Distinct().ToArray();
string deptIds = Strings.Join(arrDeptId, ",");
string designationIds = Strings.Join(arrDesignationId, ",");
departments = departmentService.GetByDeptIDs(deptIds);
designations = designationService.GetByDesignationIDs(designationIds);
foreach (Employee emp in employees)
{
emp.Department = departments.Find(x => x.ID == emp.DepartmentID);
emp.Designation = designations.Find(x => x.ID == emp.DesignationID);
List<Employee> oEmps = new List<Employee>();
oEmps.Add(emp);
List<EmpLeaveStatus> oCurrYearStatus = leaveProcessService.CurrentYearStatus(oEmps, leaveYearService.GetCurrentYear(payrollTypeId), payrollTypeId);
foreach (EmpLeaveStatus oItem in oCurrYearStatus)
{
// lp = lps.FirstOrDefault(o => o.LeaveId == oItem.LeaveId);
// if (lp != null && lp.CalculationType == EnumLeaveCalculationType.Hourly || lp.CalculationType == EnumLeaveCalculationType.Hourly_Prorated)
// {
// if (lp.MaxAccumulatedDays > 0)
// oBody4.Rows.Add(oItem.Leave.Description, Math.Round(oItem.OpeningBalance / 8, 2).ToString(), Math.Round(oItem.LeaveAvailed / 8, 2).ToString(), Math.Round(oItem.ClosingBalance / 8).ToString(),
// emp.EmployeeNo, "", "", "", "", "", oItem.OpeningBalance.ToString(), oItem.LeaveAvailed.ToString(), (oItem.ClosingBalance - oItem.LateLeaveAdjustmentConsumed).ToString(), Math.Round(lp.MaxAccumulatedDays / 8, 2), lp.MaxAccumulatedDays, oItem.LateLeaveAdjustmentConsumed.ToString());
// }
// else if (lp != null)
// {
// if (lp.MaxAccumulatedDays > 0)
oBody4.Rows.Add(oItem.Leave.Description, Math.Round(oItem.OpeningBalance, MidpointRounding.AwayFromZero).ToString(), Math.Round(oItem.LeaveAvailed, MidpointRounding.AwayFromZero).ToString(), Math.Round(oItem.ClosingBalance, MidpointRounding.AwayFromZero).ToString(),
emp.EmployeeNo, "", "", "", "", "", (oItem.OpeningBalance * 8).ToString(), (oItem.LeaveAvailed * 8).ToString(), (oItem.ClosingBalance * 8).ToString(), "", "", oItem.LateLeaveAdjustmentConsumed.ToString());
//if (lp.MaxAccumulatedDays > 0)
//oBody4.Rows.Add(oItem.Leave.Description, oItem.OpeningBalance.ToString(), oItem.LeaveAvailed.ToString(), oItem.ClosingBalance.ToString(),
// "", "", "", "", "", "", (oItem.OpeningBalance * 8).ToString(), (oItem.LeaveAvailed * 8).ToString(), (oItem.ClosingBalance * 8).ToString(), lp.MaxAccumulatedDays, lp.MaxAccumulatedDays * 8, oItem.LateLeaveAdjustmentConsumed.ToString());
//}
}
try
{
EmployeeWorkPlanSetup oEmployeeWorkPlanSetup = null;
WorkPlanGroup oWorkPlanGroup = null;
string shift = "";
oEmployeeWorkPlanSetup = empWPGroups.Where(o => o.EmployeeID == emp.ID).FirstOrDefault();
if (oEmployeeWorkPlanSetup != null)
{
oWorkPlanGroup = workPGroups.Where(o => o.ID == oEmployeeWorkPlanSetup.WorkPlanGroupID).FirstOrDefault();
//oMonthlyWorkPlan = monthlyWorkPlans.Where(o => o.WorkPlanGroupID == oWorkPlanGroup.ID && o.WorkDate == DateTime.Today).FirstOrDefault();
shift = oWorkPlanGroup == null ? "" : oWorkPlanGroup.Name;
}
oBody2.Rows.Add(emp.EmployeeNo, emp.Name, emp.Department != null ? emp.Department.Name : string.Empty, emp.Designation != null ? emp.Designation.Name : string.Empty, emp.JoiningDate.ToString("dd MMM yyyy"), shift);
}
catch (Exception exp)
{
}
}
if (oLeaveEntrys != null)
{
foreach (LeaveEntry le in oLeaveEntrys)
{
Employee tempEmp = employees.Find(item => item.ID == le.EmpID);
if (le.Leave != null)
{
oBody.Rows.Add(tempEmp.EmployeeNo, le.Leave.Description, le.ApprovedFromDate.ToString("dd MMM yyyy"), le.ApprovedToDate.ToString("dd MMM yyyy"), le.ApprovedTotalDays, le.Remarks, le.AppliedLeaveDate.ToString("MMM, yyyy"));
}
else
{
oBody.Rows.Add(tempEmp.EmployeeNo, "", le.ApprovedFromDate.ToString("dd MMM yyyy"), le.ApprovedToDate.ToString("dd MMM yyyy"), le.ApprovedTotalDays, le.Remarks, le.AppliedLeaveDate.ToString("MMM, yyyy"));
}
}
}
dsSub = new DataSet();
oBody4.TableName = "dsEmpLeaveLedger_LeaveBalance";
dsSub.Tables.Add(oBody4);
oBody.TableName = "dsEmpLeaveLedger_EmpLeaveLedger";
dsSub.Tables.Add(oBody);
DataSet resultDataSet = new DataSet();
oBody2.TableName = "dsEmpLeaveLedger_EmpInformation";
resultDataSet.Tables.Add(oBody2);
oBody3.TableName = "dsEmpLeaveLedger_LeaveYear";
dsSub.Tables.Add(oBody3);
string RDLCName = "HRM.Report.RDLC.MultipleLeaveLedger.rdlc";
ReportProcessor reportProcessor = new ReportProcessor();
//return reportProcessor.ShowLeaveLedger(oBody2,dsSub, embeddedResource, caption, payrollTypeId, reportType);
return reportProcessor.CommonReportView(null, RDLCName, resultDataSet, dsSub, null, true, payrollTypeId, reportType);
}
}
}