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

509 lines
22 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Payroll.BO;
using Ease.CoreV35.Model;
using Microsoft.Reporting.WinForms;
namespace Payroll.Report
{
public class rptBonus
{
private ReportSetup _selectedParameter;
public rptBonus()
{
}
public ReportSetup SelectedParameter
{
set
{
_selectedParameter = value;
}
}
public void BonusRegisterBankAdviceCarFuel()
{
fReportViewer form = new fReportViewer();
// ID nBonusID = _selectedParameter.Bonuses[0].ID;
// Bonus oBonus = Bonus.Get(nBonusID);
DateTime dBonusMonth = _selectedParameter.FromDate.Value;
string sEmpID = _selectedParameter.ReportItem.INSQL;
int count = 1;
DataRow oDR = null;
//Bank oBank;
DataSet oBonusRegister = null;
//if (_selectedParameter.Banks.Count > 0)
// oBank = _selectedParameter.Banks[0];
//else throw new ServiceException("please select a bank");
oBonusRegister = BonusProcess.GetBonusRegisterCarFuel(GlobalFunctions.LastDateOfMonth(dBonusMonth), sEmpID);
PayrollDataSet.PayrollDataSet.BonusRegisterDataTable dBonusRegData = new Payroll.Report.PayrollDataSet.PayrollDataSet.BonusRegisterDataTable();
foreach (DataRow oDRow in oBonusRegister.Tables[0].Rows)
{
oDR = dBonusRegData.NewRow();
oDR["EmpNo"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["Basic"] = oDRow["BasicSalary"];
oDR["BonusAmount"] = oDRow["ChangeNetAmount"];
oDR["TaxAmount"] = oDRow["TaxAmount"];
oDR["Gross"] = oDRow["GROSSSALARY"];
oDR["JoiningDate"] = oDRow["JOININGDATE"];
oDR["BonusMonth"] = dBonusMonth;
//oDR["NetBonus"]=oDRow[""];
oDR["SLNo"] = count;
dBonusRegData.Rows.Add(oDR);
count++;
}
form.ShowDlgForBonusRegister(_selectedParameter.ReportItem, dBonusRegData);
}
public DataSet BonusRegisterForExcel(DateTime Month, string sEmpID, ID nBonusID)
{
// ID nBonusID = _selectedParameter.Bonuses[0].ID;
Bonus oBonus = Bonus.Get(nBonusID);
int count = 1;
DataRow oDR = null;
DataSet oBonusRegister = null;
oBonusRegister = BonusProcess.GetBonusRegister(nBonusID, GlobalFunctions.FirstDateOfMonth(Month), sEmpID);
PayrollDataSet.PayrollDataSet.BonusRegisterExcelDataTable dBonusRegData = new Payroll.Report.PayrollDataSet.PayrollDataSet.BonusRegisterExcelDataTable();
foreach (DataRow oDRow in oBonusRegister.Tables[0].Rows)
{
oDR = dBonusRegData.NewRow();
oDR["SLNo"] = count;
oDR["EmpNo"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["JoiningDate"] = oDRow["JOININGDATE"];
oDR["BonusMonth"] = oDRow["BONUSMONTH"];
oDR["Basic"] = oDRow["BasicSalary"];
oDR["BonusAmount"] = oDRow["ChangeBonusAmount"];
oDR["TaxAmount"] = oDRow["ChangeTaxAmount"];
oDR["NetBonus"] = oDRow["ChangeBonusAmount"];
dBonusRegData.Rows.Add(oDR);
count++;
}
DataSet dSet = new DataSet();
dBonusRegData.TableName = "PayrollDataSet_BonusRegisterExcel";
dSet.Tables.Add(dBonusRegData);
return dSet;
}
public void BonusRegister()
{
fReportViewer form = new fReportViewer();
ID nBonusID = _selectedParameter.Bonuses[0].ID;
Bonus oBonus = Bonus.Get(nBonusID);
DateTime dBonusMonth = _selectedParameter.FromDate.Value;
string sEmpID = _selectedParameter.ReportItem.INSQL;
int count = 1;
DataRow oDR = null;
DataSet oBonusRegister = null;
oBonusRegister = BonusProcess.GetBonusRegister(nBonusID, GlobalFunctions.FirstDateOfMonth(dBonusMonth), sEmpID);
PayrollDataSet.PayrollDataSet.BonusRegisterDataTable dBonusRegData = new Payroll.Report.PayrollDataSet.PayrollDataSet.BonusRegisterDataTable();
foreach (DataRow oDRow in oBonusRegister.Tables[0].Rows)
{
oDR = dBonusRegData.NewRow();
oDR["EmpNo"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["Basic"] = oDRow["BasicSalary"];
oDR["BonusAmount"] = oDRow["ChangeBonusAmount"];
oDR["TaxAmount"] = oDRow["ChangeTaxAmount"];
oDR["Gross"] = oDRow["GROSSSALARY"];
oDR["JoiningDate"] = oDRow["JOININGDATE"];
oDR["BonusMonth"] = dBonusMonth;
//oDR["NetBonus"]=oDRow[""];
oDR["SLNo"] = count;
dBonusRegData.Rows.Add(oDR);
count++;
}
form.ShowDlgForBonusRegister(_selectedParameter.ReportItem, dBonusRegData);
}
//public void BonusRegisterForSGS()
//{
// fReportViewer form = new fReportViewer();
// ID nBonusID = _selectedParameter.Bonuses[0].ID;
// Bonus oBonus = Bonus.Get(nBonusID);
// DateTime dBonusMonth = _selectedParameter.FromDate.Value;
// string sEmpID = _selectedParameter.ReportItem.INSQL;
// int count = 1;
// DataRow oDR = null;
// DataSet oBonusRegister = null;
// oBonusRegister = BonusProcess.GetBonusRegister(nBonusID, GlobalFunctions.FirstDateOfMonth(dBonusMonth), sEmpID);
// PayrollDataSet.PayrollDataSet.BonusRegisterDataTable dBonusRegData = new Payroll.Report.PayrollDataSet.PayrollDataSet.BonusRegisterDataTable();
// foreach (DataRow oDRow in oBonusRegister.Tables[0].Rows)
// {
// oDR = dBonusRegData.NewRow();
// oDR["EmpNo"] = oDRow["EMPLOYEENO"];
// oDR["Name"] = oDRow["NAME"];
// oDR["Basic"] = oDRow["BasicSalary"];
// oDR["BonusAmount"] = oDRow["BonusAmount"];
// oDR["TaxAmount"] = oDRow["TaxAmount"];
// oDR["Gross"] = oDRow["GROSSSALARY"];
// oDR["JoiningDate"] = oDRow["JOININGDATE"];
// oDR["BonusMonth"] = dBonusMonth;
// //oDR["NetBonus"]=oDRow[""];
// oDR["SLNo"] = count;
// dBonusRegData.Rows.Add(oDR);
// count++;
// }
// form.ShowDlgForBonusRegisterForSGS(_selectedParameter.ReportItem, dBonusRegData, oBonus.Name);
//}
public void BonusBankAdvice()
{
fReportViewer form = new fReportViewer();
ID nBonusID = _selectedParameter.Bonuses[0].ID;
DateTime dBonusMonth = _selectedParameter.FromDate.Value;
string sEmpID = _selectedParameter.ReportItem.INSQL;
int count = 1;
DataRow oDR = null;
//Bank oBank;
//string month = salaryMonth.ToString("MMMM-yyyy");
string takaInWord = string.Empty;
//if (_selectedParameter.Banks.Count > 0)
// oBank = _selectedParameter.Banks[0];
//else throw new ServiceException("please select a bank");
DataSet oBonusBankAdvice = null;
oBonusBankAdvice = BonusProcess.GetBonusBankAdvice(nBonusID, GlobalFunctions.LastDateOfMonth(dBonusMonth), sEmpID);
PayrollDataSet.dsCompany.BonusBankAdviceDataTable dBonusBankData = new Payroll.Report.PayrollDataSet.dsCompany.BonusBankAdviceDataTable();
double nTotal = 0.0;
foreach (DataRow oDRow in oBonusBankAdvice.Tables[0].Rows)
{
oDR = dBonusBankData.NewRow();
oDR["EmpNo"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["BonusAmount"] = oDRow["Amount"];
oDR["AccountNo"] = oDRow["ACCOUNTNO"];
oDR["EmailAddress"] = oDRow["EMAILADDRESS"];
oDR["BonusMonth"] = dBonusMonth;
oDR["CostCenter"] = oDRow["CostCenter"];
oDR["SLNo"] = count;
dBonusBankData.Rows.Add(oDR);
nTotal += Convert.ToDouble(oDR["BonusAmount"]);
count++;
}
takaInWord = Ease.CoreV35.Utility.Global.NumericFunctions.TakaWords(nTotal);
DataSet ds = new DataSet();
dBonusBankData.TableName = "dsCompany_BonusBankAdvice";
ds.Tables.Add(dBonusBankData);
List<ReportAuthorization> oAuthorizations = ReportAuthorization.GetByReportID(_selectedParameter.ReportItem.ReportID);
List<AuthorizedPerson> oPersons = AuthorizedPerson.Get();
List<ReportParameter> _parameters = new List<ReportParameter>();
int nCount = 1;
foreach (ReportAuthorization item in oAuthorizations)
{
AuthorizedPerson person = oPersons.Find(x => x.ID == item.AuthorizePersionId);
if (person != null)
{
if (nCount == 1)
{
_parameters.Add(new ReportParameter("Person1", person.Name));
_parameters.Add(new ReportParameter("Designation1", person.Designation));
}
if (nCount == 2)
{
_parameters.Add(new ReportParameter("Person2", person.Name));
_parameters.Add(new ReportParameter("Designation2", person.Designation));
}
}
nCount++;
}
_parameters.Add(new ReportParameter("Person3", "na"));
_parameters.Add(new ReportParameter("Designation3", "na"));
_parameters.Add(new ReportParameter("SalaryMonth", dBonusMonth.ToString("MMMM-yyyy")));
_parameters.Add(new ReportParameter("Month", dBonusMonth.ToString("MMM-yyyy")));
_parameters.Add(new ReportParameter("TakaInWord", takaInWord));
_parameters.Add(new ReportParameter("BankName", "IFIC"));
form.CommonReportView(_selectedParameter.ReportItem, ds, "Payroll.Report.RDLC.BonusBankAdviceNew.rdlc", _parameters);
//form.ShowDlgForBankRegister(_selectedParameter.ReportItem, dBonusBankData);
}
public void BonusPaySlip()
{
fReportViewer form = new fReportViewer();
List<Branch> oBranches = new List<Branch>();
oBranches = Branch.Get(EnumStatus.Active);
ID nBonusID = _selectedParameter.Bonuses[0].ID;
DateTime dBonusMonth = _selectedParameter.FromDate.Value;
string sEmpID = _selectedParameter.ReportItem.INSQL;
int count = 1;
DataRow oDR = null;
DataSet oBonusPaySlip = null;
oBonusPaySlip = BonusProcess.GetBonusPaySlip(nBonusID, GlobalFunctions.FirstDateOfMonth(dBonusMonth), sEmpID);
PayrollDataSet.PayrollDataSet.BonusPaySlipDataTable dBonusPaySlipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.BonusPaySlipDataTable();
foreach (DataRow oDRow in oBonusPaySlip.Tables[0].Rows)
{
oDR = dBonusPaySlipData.NewRow();
oDR["EmpNo"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["Basic"] = oDRow["BasicSalary"];
oDR["BonusAmount"] = oDRow["BonusAmount"];
oDR["TaxAmount"] = oDRow["TaxAmount"];
oDR["Department"] = oDRow["Department"];
oDR["Designation"] = oDRow["Designation"];
oDR["BonusMonth"] = dBonusMonth;
//oDR["NetBonus"]=oDRow["PAYMENTMODE"];
StringBuilder sb = new StringBuilder();
if (oDRow["PAYMENTMODE"].ToString() == "1")
{
sb.Append("CashPayment");
}
else if (oDRow["PAYMENTMODE"].ToString() == "2")
{
sb.Append("BankTransfer");
}
else if (oDRow["PAYMENTMODE"].ToString() == "3")
{
sb.Append("Provision");
}
Branch oBranch = oBranches.Find(delegate(Branch dr) { return dr.ID.Integer.ToString() == oDRow["branchid"].ToString(); });
if (oBranch != null)
{
sb.Append(Environment.NewLine);
sb.Append(oBranch.Bank.Name + " " + oBranch.Name);
}
oDR["PAYMENTMODE"] = sb.ToString();
oDR["AC"] = oDRow["accountno"].ToString();
//oDR["SLNo"] = count;
dBonusPaySlipData.Rows.Add(oDR);
count++;
}
form.ShowDlgForBonusPaySlip(_selectedParameter.ReportItem, dBonusPaySlipData);
}
public void OldBonusPaySlip(ID bonusID, DateTime bonusMonth, string empID)
{
fReportViewer form = new fReportViewer();
int count = 1;
DataRow oDR = null;
DataSet oldBonusPaySlip = null;
oldBonusPaySlip = BonusProcess.GetOldBonusPaySlip(bonusID, GlobalFunctions.FirstDateOfMonth(bonusMonth), empID);
PayrollDataSet.PayrollDataSet.BonusPaySlipDataTable dBonusPaySlipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.BonusPaySlipDataTable();
foreach (DataRow oDRow in oldBonusPaySlip.Tables[0].Rows)
{
oDR = dBonusPaySlipData.NewRow();
oDR["EmpNo"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["Basic"] = oDRow["BasicSalary"];
oDR["BonusAmount"] = oDRow["BonusAmount"];
oDR["TaxAmount"] = oDRow["TaxAmount"];
oDR["Department"] = oDRow["Department"];
oDR["Designation"] = oDRow["Designation"];
oDR["BonusMonth"] = bonusMonth;
//oDR["NetBonus"]=oDRow["PAYMENTMODE"];
StringBuilder sb = new StringBuilder();
if (oDRow["PAYMENTMODE"].ToString() == "1")
{
sb.Append("CashPayment");
}
else if (oDRow["PAYMENTMODE"].ToString() == "2")
{
sb.Append("BankTransfer");
}
else if (oDRow["PAYMENTMODE"].ToString() == "3")
{
sb.Append("Provision");
}
Branch oBranch = Branch.GetOldBranchByID(ID.FromInteger(Convert.ToInt32(oDRow["branchid"])));
if (oBranch != null)
{
sb.Append(Environment.NewLine);
sb.Append(oBranch.Bank.Name + " " + oBranch.Name);
}
oDR["PAYMENTMODE"] = sb.ToString();
oDR["AC"] = oDRow["accountno"].ToString();
//oDR["SLNo"] = count;
dBonusPaySlipData.Rows.Add(oDR);
count++;
}
form.ShowDlgForBonusPaySlip(_selectedParameter.ReportItem, dBonusPaySlipData);
}
public void OldBonusRegister(ID bonusID, DateTime bonusMonth, string empID)
{
fReportViewer form = new fReportViewer();
int count = 1;
DataRow oDR = null;
DataSet oBonusRegister = null;
oBonusRegister = BonusProcess.GetOldBonusRegister(bonusID, GlobalFunctions.FirstDateOfMonth(bonusMonth), empID);
PayrollDataSet.PayrollDataSet.BonusRegisterDataTable dBonusRegData = new Payroll.Report.PayrollDataSet.PayrollDataSet.BonusRegisterDataTable();
foreach (DataRow oDRow in oBonusRegister.Tables[0].Rows)
{
oDR = dBonusRegData.NewRow();
oDR["EmpNo"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["Basic"] = oDRow["EMPBASIC"];
oDR["BonusAmount"] = oDRow["AMOUNT"];
oDR["TaxAmount"] = oDRow["TAXAMOUNT"];
oDR["Gross"] = 0;
oDR["JoiningDate"] = oDRow["JOININGDATE"];
oDR["BonusMonth"] = bonusMonth;
oDR["SLNo"] = count;
dBonusRegData.Rows.Add(oDR);
count++;
}
form.ShowDlgForOldBonusRegister(dBonusRegData);
}
public void MonthlyProdBonus(DateTime dBonusMonth)
{
fReportViewer form = new fReportViewer();
int count = 1;
DataRow oDR = null;
DataSet oProdBonusProcessEmp = ProdBonusProcess.GetMontlyProdBonus(dBonusMonth);
PayrollDataSet.PayrollDataSet.dtMonthlyProdBonusDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.dtMonthlyProdBonusDataTable();
if (oProdBonusProcessEmp.Tables[0].Rows.Count > 0)
{
GlobalFunctions.bDataFound = true;
}
else
{
return;
}
foreach (DataRow oDRow in oProdBonusProcessEmp.Tables[0].Rows)
{
oDR = dTable.NewRow();
oDR["EMPLOYEENO"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["Designation"] = oDRow["Designation"];
oDR["DepartmentID"] = oDRow["DepartmentID"];
oDR["Department"] = oDRow["Department"];
oDR["Amount"] = Convert.ToDouble(oDRow["Amount"]).ToString("0.00");
dTable.Rows.Add(oDR);
count++;
}
DataSet dSet = new DataSet();
dTable.TableName = "PayrollDataSet_dtMonthlyProdBonus";
dSet.Tables.Add(dTable);
string RDLC = "Payroll.Report.RDLC.rptMontlyProdBonus.rdlc";
ReportParameter rParam;
List<ReportParameter> _reportParameters = new List<ReportParameter>();
rParam = new ReportParameter("Month", dBonusMonth.ToString("MMM yyyy"));
_reportParameters.Add(rParam);
form.CommonReportViewer(null, RDLC, dSet, _reportParameters, true);
}
public void EmpDesignWiseProdBonus(DateTime dBonusMonth)
{
fReportViewer form = new fReportViewer();
int count = 1;
DataRow oDR = null;
DataSet oProdBonus = ProdBonusProcess.EmpDesignWiseProdBonus(dBonusMonth);
if (oProdBonus.Tables[0].Rows.Count > 0)
{
GlobalFunctions.bDataFound = true;
}
else
{
return;
}
//ObjectsTemplate<ProdBonusProcessEmp> oProdBonusProcessEmp = ProdBonusProcessEmp;
PayrollDataSet.PayrollDataSet.dtEmpDesWiseProdBonusDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.dtEmpDesWiseProdBonusDataTable();
foreach (DataRow oDRow in oProdBonus.Tables[0].Rows)
{
oDR = dTable.NewRow();
oDR["EMPLOYEENO"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["Designation"] = oDRow["Designation"];
oDR["Amount"] = Convert.ToDouble(oDRow["Amount"]).ToString("0.00");
oDR["WorkingHour"] = Convert.ToDouble(oDRow["WorkingHour"]).ToString("0.00");
oDR["ScheduledHour"] = Convert.ToDouble(oDRow["ScheduledHour"]).ToString("0.00");
oDR["OTHour"] = Convert.ToDouble(oDRow["OTHour"]).ToString("0.00");
oDR["DesignNo"] = oDRow["DesignNo"];
oDR["StartDate"] = Convert.ToDateTime(oDRow["StartDate"]).ToString("dd MMM yyy");
oDR["EndDate"] = Convert.ToDateTime(oDRow["EndDate"]).ToString("dd MMM yyy");
dTable.Rows.Add(oDR);
count++;
}
DataSet dSet = new DataSet();
dTable.TableName = "PayrollDataSet_dtEmpDesWiseProdBonus";
dSet.Tables.Add(dTable);
string RDLC = "Payroll.Report.RDLC.rptEmpDesignWiseProdBonus.rdlc";
ReportParameter rParam;
List<ReportParameter> _reportParameters = new List<ReportParameter>();
rParam = new ReportParameter("Month", dBonusMonth.ToString("MMM yyyy"));
_reportParameters.Add(rParam);
form.CommonReportViewer(null, RDLC, dSet, _reportParameters, true);
}
public void ProdBonusDetail(ProductionBonusSetup design)
{
fReportViewer form = new fReportViewer();
int count = 1;
DataRow oDR = null;
DataSet oProdBonusDetail = ProdBonusProcess.GetProdBonusDetail(design.ID.Integer);
if (oProdBonusDetail.Tables[0].Rows.Count > 0)
{
GlobalFunctions.bDataFound = true;
}
PayrollDataSet.PayrollDataSet.dtProdBonusDetailDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.dtProdBonusDetailDataTable();
foreach (DataRow oDRow in oProdBonusDetail.Tables[0].Rows)
{
oDR = dTable.NewRow();
oDR["EMPLOYEENO"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["NAME"];
oDR["Designation"] = oDRow["Designation"];
oDR["Amount"] = Convert.ToDouble(oDRow["Amount"]).ToString("0.00");
oDR["WorkingHour"] = oDRow["WorkingHour"];
oDR["ScheduledHour"] = oDRow["ScheduledHour"];
oDR["OTHour"] = Convert.ToDouble(oDRow["OTHour"]).ToString("0.00");
dTable.Rows.Add(oDR);
count++;
}
DataSet dSet = new DataSet();
dTable.TableName = "PayrollDataSet_dtProdBonusDetail";
dSet.Tables.Add(dTable);
string RDLC = "Payroll.Report.RDLC.rptProdBonusDetail.rdlc";
ReportParameter rParam;
List<ReportParameter> _reportParameters = new List<ReportParameter>();
rParam = new ReportParameter("DesignNo", design.DesignNo);
_reportParameters.Add(rParam);
form.CommonReportViewer(null, RDLC, dSet, _reportParameters, true);
}
}
}