CEL_Payroll/Payroll.Report/Class/rptLeave.cs

168 lines
6.5 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Payroll.BO;
using Ease.CoreV35;
using Ease.CoreV35.Model;
using Ease.CoreV35.Caching;
using Microsoft.Reporting.WinForms;
namespace Payroll.Report
{
public class rptLeave
{
string _sDivision = "";
string _sDepartment = "";
string _sUnit = "";
string _sBranch = "";
ObjectsTemplate<Department> _Departments = new ObjectsTemplate<Department>();
ObjectsTemplate<EmpLeaveStatus> oCurrYearStatus = null;
public rptLeave()
{
_Departments = Department.Get();
}
internal void ShowLeaveReport(ObjectsTemplate<Employee> _employees,LeaveYear lyy)
{
fReportViewer fViewer = new fReportViewer();
PayrollDataSet.dsEmpLeaveLedger.LeaveBalanceDataTable dTEmpLeave = new Payroll.Report.PayrollDataSet.dsEmpLeaveLedger.LeaveBalanceDataTable();
DataRow oRow = null;
//foreach(Employee oemp in _employees)
//{
oCurrYearStatus = EmpLeaveStatus.CurrentYearStatus(_employees,lyy,EnumLeaveStatus.Approved);
foreach (EmpLeaveStatus oItem in oCurrYearStatus)
{
oRow = dTEmpLeave.NewRow();
Employee oemp = _employees.Find(delegate(Employee ee) { return ee.ID.Integer == oItem.EmpId; });
if (oemp == null)
oemp = new Employee();
oRow["EmpNo"] = oemp.EmployeeNo;
oRow["Name"] = oemp.Name;
oRow["Designation"] = oemp.Designation.Name;
Department oDepartment = _Departments.Find(delegate(Department dep)
{
return
dep.ID == oemp.DepartmentID;
});
FindDivisionDeparmentUnit(oDepartment, _Departments);
oRow["Division"] = _sDivision;
oRow["Department"] = _sDepartment;
oRow["Unit"] = _sUnit;
oRow["Leave"] = oItem.Leave.Description;
oRow["Opening"] = oItem.OpeningBalance.ToString();
oRow["Availed"] = oItem.LeaveAvailed.ToString();
oRow["Balance"] = oItem.ClosingBalance.ToString();
dTEmpLeave.Rows.Add(oRow);
}
//}
if (dTEmpLeave.Rows.Count > 0)
{
fViewer.ShowLeaveReport(dTEmpLeave, lyy);
}
}
public void ShowShortLeaveReport(EmployeeShortLeave esl)
{
if (esl == null)
return;
DataSet dSet = new DataSet();
String RDLC = "Payroll.Report.RDLC.EmployeeShortLeave.rdlc";
Employee emp = Employee.Get(ID.FromInteger(esl.EmployeeID));
ReportParameter _parameter;
List<ReportParameter> parameters = new List<ReportParameter>();
_parameter = new ReportParameter("EmpNo", emp.EmployeeNo);
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpName", emp.Name);
parameters.Add(_parameter);
_parameter = new ReportParameter("LeaveType", esl.ShortLeaveType.ToString());
parameters.Add(_parameter);
_parameter = new ReportParameter("From", esl.FromDate.ToString("dd MMM yyyy HH:mm"));
parameters.Add(_parameter);
_parameter = new ReportParameter("To", esl.ToDate.ToString("dd MMM yyyy HH:mm"));
parameters.Add(_parameter);
_parameter = new ReportParameter("WillReturn", esl.WillReturn?"Yes":"No");
parameters.Add(_parameter);
_parameter = new ReportParameter("Description", esl.Description.ToString());
parameters.Add(_parameter);
fReportViewer form = new fReportViewer();
form.CommonReportViewer(null, RDLC, dSet, parameters);
//fReportViewer rViewer = new fReportViewer();
//DataRow oDR = null;
//DataSet dsShortLeave = null;
//PayrollDataSet.dsEmpLeaveLedger.ShortLeaveDataTable dTShortLeave = new Payroll.Report.PayrollDataSet.dsEmpLeaveLedger.ShortLeaveDataTable();
//dsShortLeave = EmployeeShortLeave.GetEmployeeWiseShortLeaveReport(empID);
//foreach (DataRow oDRow in dsShortLeave.Tables[0].Rows)
//{
// oDR = dTShortLeave.NewRow();
// oDR["EmployeeName"] = oDRow["EmployeeName"].ToString();
// oDR["EmployeeNo"] = oDRow["EmployeeNo"].ToString();
// oDR["Designation"] = oDRow["Designation"].ToString();
// oDR["ShortLeaveID"] = oDRow["ShortLeaveID"];
// oDR["EmployeeID"] = oDRow["EmployeeID"];
// oDR["Description"] = oDRow["Description"].ToString();
// oDR["FromDate"] = oDRow["FromDate"];
// oDR["ToDate"] = oDRow["ToDate"];
// oDR["ShortLeaveType"] = oDRow["ShortLeaveType"];
// oDR["WillReturn"] = oDRow["WillReturn"];
// dTShortLeave.Rows.Add(oDR);
//}
//if (dTShortLeave.Rows.Count > 0)
//{
// rViewer.ShowShortLeaveReport(dTShortLeave);
//}
}
private void FindDivisionDeparmentUnit(Department department, ObjectsTemplate<Department> oDepartments)
{
_sDivision = "";
_sDepartment = "";
_sUnit = "";
if (department != null)
{
Department oItem = new Department();
//if (department.Tier == 4)
//{
// _sUnit = department.Name;
// oItem = oDepartments.Find(delegate(Department dept) { return dept.ID == department.ParentID; });
// _sDepartment = oItem.Name;
// oItem = oDepartments.Find(delegate(Department dept) { return dept.ID == oItem.ParentID; });
// _sDivision = oItem.Name;
//}
//else
if (department.Tier == 2)
{
_sDepartment = department.Name;
oItem = oDepartments.Find(delegate(Department dept) { return dept.ID == department.ParentID; });
_sDivision = oItem.Name;
}
else if (department.Tier == 1)
{
_sDivision = department.Name;
}
}
}
}
}