CEL_Payroll/Payroll.Report/UI/fPreviousSalaryInformation.cs

189 lines
6.9 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Payroll.BO;
using Ease.CoreV35.Model;
using Payroll.Controls;
using Payroll.Report;
using System.Reflection;
namespace Payroll.Report
{
public partial class fPreviousSalaryInformation : Form
{
DataTable _dtEmp = null;
DataTable _TaxParameter = null;
DataTable _dtOldBonuses = null;
ObjectsTemplate<IncomeTax> _IncomeTaxs = null;
public fPreviousSalaryInformation()
{
InitializeComponent();
}
private string GetEmpID(string sEmpNo)
{
string sEmpID = "0";
foreach (DataRow dr in _dtEmp.Rows)
{
if (dr["EmployeeNo"].ToString() == sEmpNo)
{
sEmpID = dr["EmployeeID"].ToString();
break;
}
}
return sEmpID;
}
private DataRow GetEmp(string sEmpNo)
{
DataRow drEmp = null;
foreach (DataRow dr in _dtEmp.Rows)
{
if (dr["EmployeeNo"].ToString() == sEmpNo)
{
drEmp = dr;
break;
}
}
return drEmp;
}
private void LoadFiscalYearCbo()
{
cboFesicalYear.DataSource = _TaxParameter;
cboFesicalYear.ValueMember = "TAXPARAMID";
cboFesicalYear.DisplayMember = "FISCALYEAR";
}
private void LoadBonusCbo()
{
_dtOldBonuses = Bonus.GetOldBonus();
cboBonus.DataSource = _dtOldBonuses;
cboBonus.DisplayMember = "BonusName";
cboBonus.ValueMember = "BonusID";
}
private void btnPreview_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
Cursor.Current = Cursors.WaitCursor;
try
{
switch (lstList.SelectedIndex)
{
case 0:
//Payslip report function
string empID = GetEmpID(txtEmployeeID.Text.Trim());
if (empID != "0")
{
new PaySlip().ShowReportOld(dtpMonth.Value, empID);
}
else
{
MessageBox.Show("Employee not found", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
break;
case 1:
//Salary sheet report function
rptSalarySheet oRptSalarySheet = new rptSalarySheet();
oRptSalarySheet.ShowOldSalarySheetReport(dtpMonth.Value);
break;
case 2:
//Tax Card report function
string employeeID = GetEmpID(txtEmployeeID.Text.Trim());
DataRow employee = GetEmp(txtEmployeeID.Text.Trim());
if (employeeID.Equals("0"))
{
MessageBox.Show("Employee not found", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
}
else
{
rptIncomeTax oRptIncomeTax = new rptIncomeTax();
_IncomeTaxs = IncomeTax.GetOldIncomeTax(EnumIncomeTaxDataFrom.ProcessedData, ID.FromInteger(Convert.ToInt32(employeeID)), ID.FromInteger(Convert.ToInt32(cboFesicalYear.SelectedValue)));
if (_IncomeTaxs == null || _IncomeTaxs.Count <= 0)
{
MessageBox.Show("Income Tax not found", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
}
oRptIncomeTax.showOldTaxCard(_IncomeTaxs, employee, false);
}
break;
case 3:
//Bonus payslip report function
string emplID = GetEmpID(txtEmployeeID.Text.Trim());
if (emplID.Equals("0"))
{
MessageBox.Show("Employee not found", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
}
else
{
rptBonus oRptBonus = new rptBonus();
oRptBonus.OldBonusRegister(ID.FromInteger(Convert.ToInt32(cboBonus.SelectedValue.ToString())), dtpMonth.Value, emplID);
}
break;
default:
MessageBox.Show("Please select an item", "Select", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
}
}
catch (Exception exp)
{
MessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void fPreviousSalaryInformation_Load(object sender, EventArgs e)
{
_dtEmp = Employee.GetOldEmp();
_TaxParameter = TaxParameter.GetOldTaxCard(false);
LoadFiscalYearCbo();
LoadBonusCbo();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void lstList_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstList.SelectedItem.Equals("Tax Card"))
{
this.dtpMonth.Enabled = false;
this.cboFesicalYear.Enabled = true;
this.txtEmployeeID.Enabled = true;
this.cboBonus.Enabled = false;
}
else if (lstList.SelectedItem.Equals("Payslip"))
{
this.dtpMonth.Enabled = true;
this.cboFesicalYear.Enabled = false;
this.txtEmployeeID.Enabled = true;
this.cboBonus.Enabled = false;
}
else if (lstList.SelectedItem.Equals("Salary Sheet"))
{
this.dtpMonth.Enabled = true;
this.cboFesicalYear.Enabled = false;
this.txtEmployeeID.Enabled = false;
this.cboBonus.Enabled = false;
}
else if (lstList.SelectedItem.Equals("Bonus Register"))
{
this.dtpMonth.Enabled = true;
this.cboBonus.Enabled = true;
this.cboFesicalYear.Enabled = false;
this.txtEmployeeID.Enabled = true;
}
}
}
}