CEL_Payroll/Payroll.Report/Class/rptOPI.cs

445 lines
20 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.Model;
using Ease.CoreV35.DataAccess;
namespace Payroll.Report
{
public class rptOPI
{
private ReportSetup _selectedParameter;
ObjectsTemplate<Department> _Departments = new ObjectsTemplate<Department>();
ObjectsTemplate<Designation> _Designations = new ObjectsTemplate<Designation>();
ObjectsTemplate<Branch> _Branches = new ObjectsTemplate<Branch>();
public rptOPI()
{
_Designations = Designation.Get(EnumStatus.Active);
_Branches = Branch.Get(EnumStatus.Active);
_Departments = Department.Get();
}
public ReportSetup SelectedParameter
{
set
{
_selectedParameter = value;
}
}
public void OPIRegister()
{
fReportViewer form = new fReportViewer();
//string sOPIItemID = _selectedParameter.OPIItems[0].ID;
DateTime dOPIMonth=_selectedParameter.FromDate.Value;
string sOPIMonth = dOPIMonth.ToString("MMM yyyy");
string sEmpID = _selectedParameter.ReportItem.INSQL;
int count = 1;
DataRow oDR = null;
DataSet oOPIRegister = null;
oOPIRegister = OPIProcess.GetOPIRegister("", dOPIMonth, sEmpID);
PayrollDataSet.PayrollDataSet.OPIRegisterDataTable ddOPIRegData = new Payroll.Report.PayrollDataSet.PayrollDataSet.OPIRegisterDataTable();
foreach (DataRow oDRow in oOPIRegister.Tables[0].Rows)
{
oDR = ddOPIRegData.NewRow();
string str = dOPIMonth.ToString("MMM yyyy");
oDR["OPIMonth"] = str;
oDR["EmployeeId"] = oDRow["EmployeeId"];
oDR["EmployeeNo"] = oDRow["EmployeeNo"];
oDR["EmpName"] = oDRow["EmpName"];
oDR["BASICSALARY"] = oDRow["BASICSALARY"];
oDR["OPIItemId"] = oDRow["OPIItemId"];
oDR["OPIItem"] = oDRow["OPIItem"];
oDR["Amount"] = GlobalFunctions.Round(Convert.ToDouble(oDRow["Amount"])).ToString();
oDR["SLNo"] = count;
ddOPIRegData.Rows.Add(oDR);
count++;
}
//IEnumerable<DataRow> rows = (DataRow[])ddOPIRegData.Select("true", "EmployeeNo").Clone();
//DataTable dtOPIReg = new Payroll.Report.PayrollDataSet.PayrollDataSet.OPIRegisterDataTable();
//if (rows != null)
// dtOPIReg = rows.CopyToDataTable<DataRow>();
form.ShowDlgForOPIRegister(_selectedParameter.ReportItem, ddOPIRegData, sOPIMonth);
}
public void OPITotalValueRegister()
{
fReportViewer form = new fReportViewer();
DateTime dFromOPIMonth = _selectedParameter.FromDate.Value;
DateTime dToOPIMonth = _selectedParameter.ToDate.Value;
string sFromOPIMonth = dFromOPIMonth.ToString("MMM yyyy");
string sToOPIMonth = dToOPIMonth.ToString("MMM yyyy");
string sEmpID = _selectedParameter.ReportItem.INSQL;
int opiItemID = _selectedParameter.OpiItems[0].ID.Integer;
int count = 1;
DataRow oDR = null;
DataSet oOPIRegister = null;
oOPIRegister = OPIProcess.GetOPITotalValueRegister(dFromOPIMonth, dToOPIMonth, opiItemID, sEmpID);
PayrollDataSet.PayrollDataSet.OPITotalValueRegisterDataTable ddOPIRegData = new Payroll.Report.PayrollDataSet.PayrollDataSet.OPITotalValueRegisterDataTable();
foreach (DataRow oDRow in oOPIRegister.Tables[0].Rows)
{
oDR = ddOPIRegData.NewRow();
oDR["OPIMonth"] = Convert.ToDateTime(oDRow["OPIMonth"]).ToString("MMM yyyy");
oDR["EmployeeId"] = oDRow["EmployeeId"];
oDR["EmployeeNo"] = oDRow["EmployeeNo"];
oDR["EmpName"] = oDRow["EmpName"];
oDR["Amount"] = (GlobalFunctions.Round(Convert.ToDouble(oDRow["Amount"]))).ToString();
oDR["SLNo"] = count;
ddOPIRegData.Rows.Add(oDR);
count++;
}
//IEnumerable<DataRow> rows = (DataRow[])ddOPIRegData.Select("true", "EmployeeNo").Clone();
//DataTable dtOPIReg = new Payroll.Report.PayrollDataSet.PayrollDataSet.OPITotalValueRegisterDataTable();
//if (rows != null)
// dtOPIReg = rows.CopyToDataTable<DataRow>();
form.ShowDlgForOPITotalValueRegister(_selectedParameter.ReportItem, ddOPIRegData, sFromOPIMonth, sToOPIMonth);
}
//public void DetailOtherPayrollItems()
//{
// fReportViewer form = new fReportViewer();
// DateTime dOPIMonth = _selectedParameter.FromDate.Value;
// string sOPIMonth = dOPIMonth.ToString("MMMM yyyy");
// string sEmpID = _selectedParameter.ReportItem.INSQL;
// string[] sEmp = sEmpID.Split(new char[] { ',' });
// int nTotalEmp = sEmp.Count();
// int count = 1;
// DataRow oDR = null;
// DataSet oOtherPayrollItems = null;
// oOtherPayrollItems = OPIProcess.GetDetailOtherPayrollItems("", dOPIMonth, sEmpID);
// PayrollDataSet.PayrollDataSet.DetailOtherPayrollItemsDataTable ddOtherPayrollItems = new Payroll.Report.PayrollDataSet.PayrollDataSet.DetailOtherPayrollItemsDataTable();
// PayrollDataSet.PayrollDataSet.DetailOtherPayrollItemsDataTable ddOtherSortedPayrollItems = new Payroll.Report.PayrollDataSet.PayrollDataSet.DetailOtherPayrollItemsDataTable();
// Department oDepartment = null;
// Designation oDesignation = null;
// Branch oBranch =null;
// foreach (DataRow oDRow in oOtherPayrollItems.Tables[0].Rows)
// {
// oDR = ddOtherPayrollItems.NewRow();
// string str = dOPIMonth.ToString("MMM yyyy");
// oDepartment = _Departments.Find(delegate(Department dd) { return dd.ID == Ease.CoreV35.Model.ID.FromInteger(Convert.ToInt32(oDRow["DEPARTMENTID"])); });
// oDesignation = _Designations.Find(delegate(Designation ods) { return ods.ID == Ease.CoreV35.Model.ID.FromInteger(Convert.ToInt32(oDRow["DESIGNATIONID"])); });
// string Cnull = oDRow["BRANCHID"].ToString();
// if (Cnull != "")
// {
// oBranch = _Branches.Find(delegate(Branch obr) { return obr.ID == Ease.CoreV35.Model.ID.FromInteger(Convert.ToInt32(oDRow["BRANCHID"])); });
// }
// oDR["OPIMonth"] = str;
// oDR["EmployeeId"] = oDRow["EmployeeId"];
// oDR["EmployeeNo"] = oDRow["EmployeeNo"];
// oDR["EmpName"] = oDRow["EmpName"];
// oDR["Designation"] = oDesignation.Name;
// oDR["DegCode"] = oDesignation.Code;
// oDR["RowSequence"] = oDRow["SequenceNo"];
// if (oBranch.ID.IsUnassigned == true || oBranch != null)
// {
// oDR["Branch"] = oBranch.Name;
// }
// else
// {
// oDR["Branch"] = "";
// }
// if (oDepartment.Tier == 1)
// {
// oDR["Division"] = "";
// oDR["Department"] = "";
// oDR["Unit"] = "";
// }
// else if (oDepartment.Tier == 2)
// {
// oDR["Division"] = oDepartment.Name;
// }
// else if (oDepartment.Tier == 3)
// {
// oDR["Division"] = oDepartment.Parent.Name;
// oDR["Department"] = oDepartment.Name;
// }
// else if (oDepartment.Tier == 4)
// {
// oDR["Division"] = oDepartment.Parent.Parent.Name;
// oDR["Department"] = oDepartment.Parent.Name;
// oDR["Unit"] = oDepartment.Name;
// }
// else
// {
// oDR["Division"] = "";
// oDR["Department"] = "";
// oDR["Unit"] = "";
// }
// oDR["OPIItemId"] = oDRow["OPIItemId"];
// oDR["OPIItem"] = oDRow["OPIItem"];
// oDR["Amount"] = GlobalFunctions.Round(Convert.ToDouble(oDRow["Amount"])).ToString();
// ddOtherPayrollItems.Rows.Add(oDR);
// count++;
// }
// var sortedData = from DataRow dr in ddOtherPayrollItems.Rows orderby dr["DegCode"] select dr;
// foreach (DataRow dr in sortedData)
// {
// DataRow nDr = ddOtherSortedPayrollItems.NewRow();
// nDr.ItemArray = dr.ItemArray;
// ddOtherSortedPayrollItems.Rows.Add(nDr);
// }
// form.ShowDlgForDetailOtherPayrollItems(_selectedParameter.ReportItem, ddOtherSortedPayrollItems, sOPIMonth, nTotalEmp);
//}
public void CostCenterWiseOPIDetails()
{
}
//public void IDLCOPIRegister()
//{
// fReportViewer form = new fReportViewer();
// DateTime dOPIMonth = _selectedParameter.FromDate.Value;
// string sEmpID = _selectedParameter.ReportItem.INSQL;
// int count = 1;
// DataRow oDR = null;
// Department oDivision = null;
// Bank oBank;
// if (_selectedParameter.Banks.Count > 0)
// oBank = _selectedParameter.Banks[0];
// else throw new ServiceException("please select a bank");
// DataSet IDLCOPIRegister = OPIProcess.GetIDLCOPIRegister(dOPIMonth, sEmpID);
// PayrollDataSet.PayrollDataSet.BankAdviceDataTable bankAdvice = new Payroll.Report.PayrollDataSet.PayrollDataSet.BankAdviceDataTable();
// PayrollDataSet.PayrollDataSet.BankAdviceLetterDataTable bankAdviceLetter = new Payroll.Report.PayrollDataSet.PayrollDataSet.BankAdviceLetterDataTable();
// double nTotal = 0.0;
// foreach (DataRow oDRow in IDLCOPIRegister.Tables[0].Rows)
// {
// oDR = bankAdvice.NewRow();
// oDR["EmpNo"] = oDRow["EMPLOYEENO"];
// oDR["EmpName"] = oDRow["NAME"];
// oDR["AccountNo"] = oDRow["ACCOUNTNO"];
// oDR["Amount"] = oDRow["Amount"];
// oDR["Email"] = oDRow["EMAILADDRESS"];
// oDR["SalaryMonth"] = dOPIMonth.ToString("MMM yyyy");
// oDR["SLNo"] = count;
// bankAdvice.Rows.Add(oDR);
// nTotal += Convert.ToDouble(oDR["Amount"]);
// count++;
// }
// string[] sTempTaka = Payroll.BO.GlobalFunctions.TakaFormat(nTotal).ToString().Split('.');
// string sRefNo = "IDLC/TF/" + DateTime.Today.ToString("yyyy/") + "0" + dOPIMonth.Month;
// string sDateTaka = "" + Payroll.BO.GlobalFunctions.TakaFormat(nTotal) + " /- (" + Ease.CoreV35.Utility.Global.NumericFunctions.MillionFormat(nTotal) + ")";
// string sAccount = oBank.Accountingformat;
// string sCheckTk = Payroll.BO.GlobalFunctions.MillionToInWords(Convert.ToInt32(nTotal));
// string totalTaka = sCheckTk;
// string sTaka = "BDT " + sTempTaka[0] + " (" + sCheckTk + " taka only)";
// bankAdviceLetter.Rows.Add(sRefNo, sTaka, sAccount, "", DateTime.Today.ToString("MMMM dd, yyyy"), oBank.Name, Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate.ToString("MMMM dd, yyyy"), sTaka, oBank.Branchs[0].Address);
// form.ShowDlgForIDLCOPIRegister(_selectedParameter.ReportItem, bankAdvice, bankAdviceLetter, totalTaka);
//}
public void ItemWiseOPI()
{
fReportViewer form = new fReportViewer();
DateTime dFromOPIMonth = _selectedParameter.FromDate.Value;
string sEmpID = _selectedParameter.ReportItem.INSQL;
int opiItemID = _selectedParameter.OpiItems[0].ID.Integer;
string sOPIName = _selectedParameter.OpiItems[0].Name;
int count = 1;
DataRow oDR = null;
DataSet oOPIRegister = null;
oOPIRegister = OPIProcess.GetItemWiseOPI(dFromOPIMonth, opiItemID, sEmpID);
PayrollDataSet.dsCompany.DTOPIDataTable dtOPI = new Payroll.Report.PayrollDataSet.dsCompany.DTOPIDataTable();
if (oOPIRegister.Tables.Count > 0)
{
foreach (DataRow orr in oOPIRegister.Tables[0].Rows)
{
oDR = dtOPI.NewRow();
oDR["EmpNo"] = orr["EmployeeNo"].ToString();
oDR["Name"] = orr["EmpName"].ToString();
oDR["AccountNo"] = orr["ACCOUNTNO"].ToString();
oDR["Amount"] = Convert.ToDouble(orr["Amount"].ToString());
oDR["Designation"] = orr["Designation"].ToString();
oDR["CostCenter"] = orr["CostCenter"].ToString();
dtOPI.Rows.Add(oDR);
}
if(dtOPI.Rows.Count > 0)
{
form.ShowItemWiseOPI(dtOPI, dFromOPIMonth, sOPIName);
}
}
}
public void ManagersPTT()
{
fReportViewer oViewer = new fReportViewer();
DataSet dsPTT = new DataSet();
DataRow orow = null;
DateTime dOPIMonth=_selectedParameter.FromDate.Value;
DateTime dtFromOPI = new DateTime(dOPIMonth.Year, 1, 1);
DateTime dtToOPI = new DateTime(dOPIMonth.Year,12,31);
int opiItemID = _selectedParameter.OpiItems[0].ID.Integer;
string sOPIName = _selectedParameter.OpiItems[0].Name;
string sEmpID = _selectedParameter.ReportItem.INSQL;
string sEmpNo = string.Empty;
dsPTT = OPIProcess.GetManagersOPI(dtFromOPI, dtToOPI, opiItemID, sEmpID);
PayrollDataSet.dsCompany.ManagersPTTDataTable dtManagersPTT = new Payroll.Report.PayrollDataSet.dsCompany.ManagersPTTDataTable();
foreach (DataRow orr in dsPTT.Tables[0].Rows)
{
if (sEmpNo != orr["EMPLOYEENO"].ToString())
{
orow = dtManagersPTT.NewRow();
orow["EmpNo"] = orr["EMPLOYEENO"].ToString();
orow["Name"] = orr["Name"].ToString();
orow["Department"] = orr["Department"].ToString();
orow["Designation"] = orr["Designation"].ToString();
//orow["MonthlyLimit"] = Convert.ToDouble(0);
//orow["YearlyLimit"] = Convert.ToDouble(0);
//orow["Balance"] = Convert.ToDouble(0);
DateTime dtOPI = Convert.ToDateTime(orr["OPIMonth"].ToString());
switch (dtOPI.Month)
{
case (int)EnumMonths.January:
orow["Jan"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.February:
orow["Feb"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.March:
orow["Mar"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.April:
orow["Apr"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.May:
orow["May"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.June:
orow["June"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.July:
orow["July"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.August:
orow["Aug"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.September:
orow["Sep"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.October:
orow["Oct"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.November:
orow["Nov"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.December:
orow["Dec"] = Convert.ToDouble(orr["Amount"].ToString());
break;
default:
break;
}
orow["Remarks"] = "";
orow["WorkPlace"] = orr["Location"].ToString();
sEmpNo = orr["EMPLOYEENO"].ToString();
dtManagersPTT.Rows.Add(orow);
}
else if (sEmpNo == orr["EMPLOYEENO"].ToString())
{
DateTime dtOPI = Convert.ToDateTime(orr["OPIMonth"].ToString());
switch (dtOPI.Month)
{
case (int)EnumMonths.January:
orow["Jan"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.February:
orow["Feb"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.March:
orow["Mar"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.April:
orow["Apr"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.May:
orow["May"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.June:
orow["June"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.July:
orow["July"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.August:
orow["Aug"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.September:
orow["Sep"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.October:
orow["Oct"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.November:
orow["Nov"] = Convert.ToDouble(orr["Amount"].ToString());
break;
case (int)EnumMonths.December:
orow["Dec"] = Convert.ToDouble(orr["Amount"].ToString());
break;
default:
break;
}
//dtManagersPTT.Rows.Add(orow);
}
}
if (dtManagersPTT.Rows.Count > 0)
{
oViewer.ShowManagersOPI(dtManagersPTT, dOPIMonth, sOPIName);
}
}
//public void ManagersMedical()
//{
//}
}
}