CEL_Payroll/Payroll.Report/Class/OTReport.cs
2024-09-17 14:30:13 +06:00

255 lines
9.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Payroll.BO;
namespace Payroll.Report
{
public class OTReport
{
private ReportSetup _selectedParameter;
public OTReport()
{
}
public ReportSetup SelectedParameter
{
set
{
_selectedParameter = value;
}
}
public DataSet OTMonthlySheetForExcel(DateTime Month, string sEmpID)
{
fReportViewer form = new fReportViewer();
int count = 1;
DataRow oDR = null;
DataSet oOTMonthlySheets = null;
oOTMonthlySheets = OTProcess.GetOTProcessData(GlobalFunctions.LastDateOfMonth(Month), sEmpID);
PayrollDataSet.PayrollDataSet.OTMonthlySheetDataTable dTableOT = new Payroll.Report.PayrollDataSet.PayrollDataSet.OTMonthlySheetDataTable();
foreach (DataRow oDRow in oOTMonthlySheets.Tables[0].Rows)
{
oDR = dTableOT.NewRow();
oDR["EmoNo"] = oDRow["EmployeeNo"];
oDR["Name"] = oDRow["EmpName"];
oDR["OTDescription"] = oDRow["TermName"];
oDR["OTRate"] = oDRow["Hours"];
oDR["OTAmount"] = GlobalFunctions.Round(Convert.ToDouble(oDRow["Amount"])); // Math.Round(oDRow["Amount"]);
oDR["OTMonth"] = Convert.ToDateTime(oDRow["OTMonth"]).ToString("dd MMM yyyy");
oDR["Basic"] = oDRow["BasicSalary"];
oDR["SLNo"] = count;
dTableOT.Rows.Add(oDR);
count++;
}
//return dTableOT;
//form.ShowDlgForMonthlyOTSheet(_selectedParameter.ReportItem, dTableOT);
DataSet dSet = new DataSet();
dTableOT.TableName = "PayrollDataSet_OTMonthlySheet";
dSet.Tables.Add(dTableOT);
return dSet;
}
public void OTMonthlySheet()
{
fReportViewer form = new fReportViewer();
DateTime Month=_selectedParameter.FromDate.Value;
string sEmpID = _selectedParameter.ReportItem.INSQL;
int count = 0;
DataRow oDR = null;
DataSet oOTMonthlySheets = null;
string sEmpNo = "";
oOTMonthlySheets = OTProcess.GetOTProcessData(GlobalFunctions.LastDateOfMonth(Month),sEmpID);
PayrollDataSet.PayrollDataSet.OTMonthlySheetDataTable dTableOT = new Payroll.Report.PayrollDataSet.PayrollDataSet.OTMonthlySheetDataTable();
foreach(DataRow oDRow in oOTMonthlySheets.Tables[0].Rows)
{
oDR = dTableOT.NewRow();
if (sEmpNo != oDRow["EmployeeNo"].ToString())
{
sEmpNo = oDRow["EmployeeNo"].ToString();
count++;
}
oDR["EmoNo"]=oDRow["EmployeeNo"];
oDR["Name"]=oDRow["EmpName"];
oDR["OTDescription"]=oDRow["TermName"];
oDR["OTRate"]=oDRow["Hours"];
oDR["OTAmount"] =GlobalFunctions.Round(Convert.ToDouble(oDRow["Amount"])); // Math.Round(oDRow["Amount"]);
oDR["OTMonth"] = Convert.ToDateTime(oDRow["ProcessMonth"]).ToString("dd MMM yyyy");
oDR["Basic"] = oDRow["BasicSalary"];
oDR["SLNo"] = count;
dTableOT.Rows.Add(oDR);
}
//return dTableOT;
form.ShowDlgForMonthlyOTSheet(_selectedParameter.ReportItem, dTableOT);
}
public DataTable OTHourlySheet(DateTime Month,string sEmpID)
{
int count = 1;
DataRow oDR = null;
DataSet oOTHourlySheets = null;
oOTHourlySheets = OTProcess.GetOTProcessData(Month,sEmpID);
PayrollDataSet.PayrollDataSet.OTHourlySheetDataTable dTableOT = new Payroll.Report.PayrollDataSet.PayrollDataSet.OTHourlySheetDataTable();
foreach (DataRow oDRow in oOTHourlySheets.Tables[0].Rows)
{
oDR = dTableOT.NewRow();
oDR["EmpNo"] = oDRow["EmployeeNo"];
oDR["Name"] = oDRow["EmpName"];
oDR["OTDescription"] = oDRow["TermName"];
oDR["Hours"]=oDRow["Hours"];
oDR["OTMonth"] = Convert.ToDateTime(oDRow["OTMonth"]).ToString("dd MMM yyyy");
oDR["SLNo"] = count;
dTableOT.Rows.Add(oDR);
count++;
}
return dTableOT;
}
public DataTable OTMonthRange(DateTime FDate,DateTime TDate)
{
int count = 1;
DataRow oDR = null;
DataSet oOTMRangeSheets = null;
oOTMRangeSheets = OTProcess.GetOTMonthRangeData(FDate, TDate);
PayrollDataSet.PayrollDataSet.OTMonthRangeDataTable dTableOT = new Payroll.Report.PayrollDataSet.PayrollDataSet.OTMonthRangeDataTable();
foreach (DataRow oDRow in oOTMRangeSheets.Tables[0].Rows)
{
oDR = dTableOT.NewRow();
oDR["Division"] = oDRow["DESCRIPTION"];
oDR["EmpNo"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["Month"] = oDRow["OTMonth"];
oDR["Value"] = oDRow["Hours"];//Convert.ToDateTime(oDRow["OTMonth"]).ToString("dd MMM yyyy");
oDR["Branch"] = oDRow["Location"];
//oDR["SLNo"] = count;
dTableOT.Rows.Add(oDR);
count++;
}
return dTableOT;
}
public DataTable OTBranchWise(DateTime Month)
{
int count = 1;
DataRow oDR = null;
DataSet oOTBranchWSheets = null;
oOTBranchWSheets = OTProcess.GetBranchWiseOT(Month);
PayrollDataSet.PayrollDataSet.BranchWiseOTDataTable dTableOT = new Payroll.Report.PayrollDataSet.PayrollDataSet.BranchWiseOTDataTable();
foreach (DataRow oDRow in oOTBranchWSheets.Tables[0].Rows)
{
oDR = dTableOT.NewRow();
oDR["Branch"] = oDRow["Location"];
oDR["Division"] = oDRow["Department"];
oDR["Month"]=oDRow["Month"];
oDR["TotalOT"] = oDRow["OTHours"];
dTableOT.Rows.Add(oDR);
count++;
}
return dTableOT;
}
public DataTable OTLocationWise(DateTime FDate, DateTime TDate)
{
int count = 1;
DataRow oDR = null;
DataSet oOTLocationWSheets = null;
oOTLocationWSheets = OTProcess.GetLocationWiseOT(FDate, TDate);
PayrollDataSet.PayrollDataSet.DivisionWiseOTDataTable dTableOT = new Payroll.Report.PayrollDataSet.PayrollDataSet.DivisionWiseOTDataTable();
foreach (DataRow oDRow in oOTLocationWSheets.Tables[0].Rows)
{
oDR = dTableOT.NewRow();
oDR["Branch"] = oDRow["Location"];
oDR["Division"] = oDRow["Department"];
oDR["Month"] = oDRow["Month"];
oDR["Value"] = oDRow["OTHours"];
oDR["Year"] = oDRow["Year"];
//oDR["SLNo"] = count;
dTableOT.Rows.Add(oDR);
count++;
}
return dTableOT;
}
public void CostCenterWiseOT()
{
fReportViewer form = new fReportViewer();
DateTime dOTMonth = _selectedParameter.FromDate.Value;
string sEmpID = _selectedParameter.ReportItem.INSQL;
DataRow oDR = null;
DataSet dsOT = null;
dsOT = OTProcess.GetCostCenterWiseOT(GlobalFunctions.LastDateOfMonth(dOTMonth), sEmpID);
PayrollDataSet.dsCompany.DTOPIDataTable dtOT = new Payroll.Report.PayrollDataSet.dsCompany.DTOPIDataTable();
if (dsOT.Tables.Count > 0)
{
foreach (DataRow orr in dsOT.Tables[0].Rows)
{
oDR = dtOT.NewRow();
oDR["EmpNo"] = orr["EmployeeNo"].ToString();
oDR["Name"] = orr["EmpName"].ToString();
oDR["AccountNo"] = orr["ACCOUNTNO"].ToString();
oDR["Amount"] = Math.Round(Convert.ToDouble(orr["Amount"].ToString()),2);
oDR["Designation"] = orr["Designation"].ToString();
oDR["CostCenter"] = orr["CostCenter"].ToString();
dtOT.Rows.Add(oDR);
}
if (dtOT.Rows.Count > 0)
{
form.ShowCostCenterWiseOT(dtOT, dOTMonth);
}
}
}
public void OTBankDisbursement()
{
fReportViewer form = new fReportViewer();
DateTime dOTMonth = _selectedParameter.FromDate.Value;
string sEmpID = _selectedParameter.ReportItem.INSQL;
DataRow oDR = null;
DataSet dsOT = null;
dsOT = OTProcess.GetCostCenterWiseOT(GlobalFunctions.LastDateOfMonth(dOTMonth), sEmpID);
PayrollDataSet.dsCompany.DTOPIDataTable dtOT = new Payroll.Report.PayrollDataSet.dsCompany.DTOPIDataTable();
if (dsOT.Tables.Count > 0)
{
foreach (DataRow orr in dsOT.Tables[0].Rows)
{
oDR = dtOT.NewRow();
oDR["EmpNo"] = orr["EmployeeNo"].ToString();
oDR["Name"] = orr["EmpName"].ToString();
oDR["AccountNo"] = orr["ACCOUNTNO"].ToString();
oDR["Amount"] = Math.Round(Convert.ToDouble(orr["Amount"].ToString()), 2);
oDR["Designation"] = orr["Designation"].ToString();
oDR["CostCenter"] = orr["CostCenter"].ToString();
dtOT.Rows.Add(oDR);
}
if (dtOT.Rows.Count > 0)
{
form.OTBankDisbursement(dtOT, dOTMonth);
}
}
}
}
}