911 lines
35 KiB
C#
911 lines
35 KiB
C#
|
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
|
|||
|
{
|
|||
|
#region FReportSearch
|
|||
|
public partial class fReportSearch :Form
|
|||
|
{
|
|||
|
#region Declarations
|
|||
|
|
|||
|
private ObjectsTemplate<SearchEmployee> _SelectedEmps = null;
|
|||
|
private ObjectsTemplate<Bank> _banks = null;
|
|||
|
private ObjectsTemplate<Bonus> _bonuses = null;
|
|||
|
private ObjectsTemplate<BonusProcess> _bonusProcess = null;
|
|||
|
private ObjectsTemplate<JVSetupDetail> _jvSetupDetails = null;
|
|||
|
private ReportSetup _selectedParameter;
|
|||
|
private ObjectsTemplate<OpiItem> _opiItems = null;
|
|||
|
private ObjectsTemplate<Branch> _branches = null;
|
|||
|
private ObjectsTemplate<TaxParameter> _taxParameter = null;
|
|||
|
private EnumReportType _reportType = EnumReportType.None;
|
|||
|
private EnumReportType _ReportID = EnumReportType.None;
|
|||
|
List<JVSetupDetail> allItems = new List<JVSetupDetail>();
|
|||
|
private ReportItem _reportitem = null;
|
|||
|
private AttendanceReport _attnReport = null;
|
|||
|
private ReportSetup _reportSetup;
|
|||
|
private string sEmpID = "";
|
|||
|
private string Scode = "";
|
|||
|
ObjectsTemplate<SalaryProcess> _oSaProcess = new ObjectsTemplate<SalaryProcess>();
|
|||
|
int nKeyNumber = 0;
|
|||
|
private ColumnHeader SortingColumn = null;
|
|||
|
public EnumReportType ReportID
|
|||
|
{
|
|||
|
set
|
|||
|
{
|
|||
|
_ReportID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
|
|||
|
public fReportSearch()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
public void ShowDlg()
|
|||
|
{
|
|||
|
this.ShowDialog();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
private void LoadBank()
|
|||
|
{
|
|||
|
cboBank.DataSource = null;
|
|||
|
_banks = Bank.Get();
|
|||
|
cboBank.DataSource = _banks;
|
|||
|
cboBank.DisplayMember = "Name";
|
|||
|
cboBank.ValueMember = "ID";
|
|||
|
if (cboBank.Items.Count > 0)
|
|||
|
cboBank.SelectedIndex = -1;
|
|||
|
}
|
|||
|
|
|||
|
private void LoadBonus()
|
|||
|
{
|
|||
|
cboItem.DataSource = null;
|
|||
|
_bonuses = Bonus.Get(EnumStatus.Active);
|
|||
|
cboItem.DataSource = _bonuses;
|
|||
|
cboItem.DisplayMember = "Name";
|
|||
|
cboItem.ValueMember = "ID";
|
|||
|
if (cboItem.Items.Count > 0)
|
|||
|
cboItem.SelectedIndex = -1;
|
|||
|
}
|
|||
|
|
|||
|
private void LoadIT()
|
|||
|
{
|
|||
|
cboItem.DataSource = null;
|
|||
|
_taxParameter = TaxParameter.Get();
|
|||
|
cboItem.DataSource = _taxParameter;
|
|||
|
cboItem.DisplayMember = "FiscalYear";
|
|||
|
cboItem.ValueMember = "ID";
|
|||
|
if (cboItem.Items.Count > 0)
|
|||
|
cboItem.SelectedIndex = -1;
|
|||
|
}
|
|||
|
|
|||
|
private void LoadOPI()
|
|||
|
{
|
|||
|
cboItem.DataSource = null;
|
|||
|
_opiItems = OpiItem.Get();
|
|||
|
cboItem.DataSource = _opiItems;
|
|||
|
cboItem.DisplayMember = "Name";
|
|||
|
cboItem.ValueMember = "ID";
|
|||
|
if (cboItem.Items.Count > 0)
|
|||
|
cboItem.SelectedIndex = -1;
|
|||
|
}
|
|||
|
|
|||
|
private void LoadSalaryItem()
|
|||
|
{
|
|||
|
allItems = JVSetupDetail.ConstantItemsForSalary();
|
|||
|
_jvSetupDetails = new ObjectsTemplate<JVSetupDetail>();
|
|||
|
|
|||
|
foreach (JVSetupDetail oDetail in allItems)
|
|||
|
{
|
|||
|
cboItem.Items.Add(oDetail);
|
|||
|
_jvSetupDetails.Add(oDetail);
|
|||
|
}
|
|||
|
cboItem.DisplayMember = "Name";
|
|||
|
cboItem.ValueMember = "ItemID";
|
|||
|
if (cboItem.Items.Count > 0)
|
|||
|
cboItem.SelectedIndex = -1;
|
|||
|
}
|
|||
|
|
|||
|
private void RefreshList()
|
|||
|
{
|
|||
|
lsvEmployee.Items.Clear();
|
|||
|
if (_SelectedEmps == null) return;
|
|||
|
|
|||
|
ListViewItem[] listViewItems = new ListViewItem[_SelectedEmps.Count];
|
|||
|
|
|||
|
int index = 0;
|
|||
|
ListViewItem item = null;
|
|||
|
foreach (SearchEmployee emp in _SelectedEmps)
|
|||
|
{
|
|||
|
item = new ListViewItem(new[]{ emp.Name,emp.EmployeeNo });
|
|||
|
item.Tag = emp;
|
|||
|
listViewItems[index++] = item;
|
|||
|
|
|||
|
}
|
|||
|
lsvEmployee.Items.AddRange(listViewItems);
|
|||
|
lblTotal.Text = index.ToString();
|
|||
|
}
|
|||
|
|
|||
|
private void LoadDesignation()
|
|||
|
{
|
|||
|
//ObjectsTemplate<Designation> allDesignations = Designation.Get(EnumStatus.Active);
|
|||
|
//cmboDesignation.DataSource = allDesignations;
|
|||
|
//cmboDesignation.DisplayMember = "Name";
|
|||
|
//cmboDesignation.ValueMember = "ID";
|
|||
|
//if (allDesignations.Count > 0) cmboDesignation.SelectedIndex = -1;
|
|||
|
//lblDesignation.Visible = true;
|
|||
|
//cmboDesignation.Visible = true;
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Events
|
|||
|
private void btnPrint_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void DesignForm()
|
|||
|
{
|
|||
|
cboItem.Visible = !(_reportitem.ItemType == EnumReportItemType.NotNeeded);
|
|||
|
lblItem.Visible = !(_reportitem.ItemType == EnumReportItemType.NotNeeded);
|
|||
|
switch (_reportitem.Chronology)
|
|||
|
{
|
|||
|
case EnumChronology.Month:
|
|||
|
lblFromDate.Text = "Month";
|
|||
|
lblFromDate.Visible = true;
|
|||
|
dtpfromDate.Visible = true;
|
|||
|
dtpfromDate.Format = DateTimePickerFormat.Custom;
|
|||
|
dtpfromDate.CustomFormat = "MMM yyyy";
|
|||
|
dtpfromDate.Value = GlobalFunctions.FirstDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate);
|
|||
|
dtpfromDate.ShowUpDown = true;
|
|||
|
|
|||
|
break;
|
|||
|
case EnumChronology.MonthRange:
|
|||
|
lblFromDate.Text = "Month";
|
|||
|
lblFromDate.Visible = true;
|
|||
|
dtpfromDate.Visible = true;
|
|||
|
dtpfromDate.Format = DateTimePickerFormat.Custom;
|
|||
|
dtpfromDate.CustomFormat = "MMM yyyy";
|
|||
|
dtpfromDate.Value = GlobalFunctions.FirstDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate);
|
|||
|
dtpfromDate.ShowUpDown = true;
|
|||
|
|
|||
|
lblTodate.Text = "Month";
|
|||
|
lblTodate.Visible = true;
|
|||
|
dtpTodate.Visible = true;
|
|||
|
dtpTodate.Format = DateTimePickerFormat.Custom;
|
|||
|
dtpTodate.CustomFormat = "MMM yyyy";
|
|||
|
dtpTodate.Value = GlobalFunctions.FirstDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate);
|
|||
|
dtpTodate.ShowUpDown = true;
|
|||
|
break;
|
|||
|
case EnumChronology.Date:
|
|||
|
lblFromDate.Text = "Date";
|
|||
|
lblFromDate.Visible = true;
|
|||
|
dtpfromDate.Visible = true;
|
|||
|
dtpfromDate.Value = GlobalFunctions.FirstDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate);
|
|||
|
|
|||
|
break;
|
|||
|
case EnumChronology.DateRange:
|
|||
|
lblFromDate.Visible = true;
|
|||
|
dtpfromDate.Visible = true;
|
|||
|
lblTodate.Visible = true;
|
|||
|
dtpTodate.Visible = true;
|
|||
|
dtpfromDate.Value = GlobalFunctions.FirstDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate);
|
|||
|
dtpTodate.Value = GlobalFunctions.LastDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate);
|
|||
|
|
|||
|
break;
|
|||
|
case EnumChronology.Year:
|
|||
|
lblFromDate.Text = "Month";
|
|||
|
lblFromDate.Visible = true;
|
|||
|
dtpfromDate.Visible = true;
|
|||
|
dtpfromDate.Format = DateTimePickerFormat.Custom;
|
|||
|
dtpfromDate.CustomFormat = "yyyy";
|
|||
|
dtpfromDate.Value = GlobalFunctions.FirstDateOfMonth(Payroll.BO.SystemInformation.CurrentSysInfo.NextPayProcessDate);
|
|||
|
dtpfromDate.ShowUpDown = true;
|
|||
|
break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void CollectObjects()
|
|||
|
{
|
|||
|
_reportSetup = new ReportSetup();
|
|||
|
if (dtpfromDate.Visible == true) _reportSetup.FromDate = dtpfromDate.Value;
|
|||
|
if (dtpTodate.Visible == true) _reportSetup.ToDate = dtpTodate.Value;
|
|||
|
|
|||
|
if (ctlGrade.SearchParam != null)
|
|||
|
_reportSetup.Grades = ctlGrade.GetSelectedObjects<Grade>();
|
|||
|
|
|||
|
if (ctlLocation.SearchParam != null)
|
|||
|
_reportSetup.Locations = ctlLocation.GetSelectedObjects<Location>();
|
|||
|
|
|||
|
if (ctlDepartment.SearchParam != null)
|
|||
|
_reportSetup.Departments = ctlDepartment.GetSelectedObjects<Department>();
|
|||
|
|
|||
|
if (ctlReligion.SearchParam != null)
|
|||
|
_reportSetup.Religions = ctlReligion.GetSelectedObjects<Religion>();
|
|||
|
|
|||
|
if (cboBank.SelectedIndex >= 0)
|
|||
|
{
|
|||
|
_reportSetup.Banks.Add((Bank)cboBank.SelectedItem);
|
|||
|
}
|
|||
|
if (cboItem.SelectedIndex >= 0)
|
|||
|
{
|
|||
|
if (_reportitem.ItemType == EnumReportItemType.Bonus)
|
|||
|
{
|
|||
|
_reportSetup.Bonuses = new ObjectsTemplate<Bonus>();
|
|||
|
_reportSetup.Bonuses.Add((Bonus)cboItem.SelectedItem);
|
|||
|
}
|
|||
|
else if (_reportitem.ItemType == EnumReportItemType.OPI)
|
|||
|
{
|
|||
|
_reportSetup.OpiItems = new ObjectsTemplate<OpiItem>();
|
|||
|
_reportSetup.OpiItems.Add((OpiItem)cboItem.SelectedItem);
|
|||
|
}
|
|||
|
else if(_reportitem.ItemType==EnumReportItemType.IncomeTax)
|
|||
|
{
|
|||
|
_reportSetup.TaxParameters = new ObjectsTemplate<TaxParameter>();
|
|||
|
_reportSetup.TaxParameters.Add((TaxParameter)cboItem.SelectedItem);
|
|||
|
}
|
|||
|
else if(_reportitem.ItemType == EnumReportItemType.SalaryItem)
|
|||
|
{
|
|||
|
_reportSetup.SalaryItems = new ObjectsTemplate<JVSetupDetail>();
|
|||
|
_reportSetup.SalaryItems.Add((JVSetupDetail)cboItem.SelectedItem);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//manager.Parameter.Add(EnumSearchParameter.BonusId, ((Bonus)cboItem.SelectedItem).ID.Integer);
|
|||
|
|
|||
|
//_reportSetup.Bonuses = _bonuses;
|
|||
|
_reportSetup.SelectedEmployees = _SelectedEmps;
|
|||
|
_reportSetup.ReportItem.INSQL = sEmpID;
|
|||
|
|
|||
|
_reportSetup.ReportItem.ReportID = _reportitem.ReportID;
|
|||
|
}
|
|||
|
|
|||
|
private void CallReport()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
this.CollectObjects();
|
|||
|
Type ty = null;
|
|||
|
ConfigurationManager omanager = new ConfigurationManager();
|
|||
|
if (_reportitem.ObjectName == "") throw new ServiceException("Object Name not found in the Report Setup.");
|
|||
|
if (_reportitem.FunctionName == "") throw new ServiceException("Function: " + _reportitem.FunctionName + " not found in the Report Setup.");
|
|||
|
|
|||
|
ty = System.Reflection.Assembly.GetCallingAssembly().GetType("Payroll.Report." + _reportitem.ObjectName.Trim());
|
|||
|
|
|||
|
object ofrm = System.Activator.CreateInstance(ty);
|
|||
|
if (ofrm == null) throw new ServiceException("unable to create object instance from object name:" + _reportitem.ObjectName + ". please check availability of the object in the Payroll.Report assembly.");
|
|||
|
|
|||
|
object PropertyValue = _reportSetup;
|
|||
|
System.Reflection.PropertyInfo property = ofrm.GetType().GetProperty("SelectedParameter");
|
|||
|
property.SetValue(ofrm, PropertyValue, null);
|
|||
|
|
|||
|
System.Reflection.MethodInfo methodInfoDel = (ofrm.GetType()).GetMethod(_reportitem.FunctionName, new Type[0]);
|
|||
|
object[] Invparam = new object[0];
|
|||
|
if (methodInfoDel != null)
|
|||
|
methodInfoDel.Invoke(ofrm, Invparam);
|
|||
|
else throw new ServiceException("function:" + _reportitem.FunctionName + " is not exist in the object:" + _reportitem.ObjectName);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
MessageBox.Show(ex.InnerException.Message , "failed to prepare report", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnPreview_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
if (Payroll.BO.SystemInformation.CurrentSysInfo.Code == "004")
|
|||
|
{
|
|||
|
if (cboItem.Visible == true && _opiItems != null)
|
|||
|
{
|
|||
|
if (cboItem.SelectedItem == null )
|
|||
|
{
|
|||
|
MessageBox.Show("Select an OPI Item first", "OPI", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
int nEmpCount = 0;
|
|||
|
if (_SelectedEmps == null)
|
|||
|
_SelectedEmps = new ObjectsTemplate<SearchEmployee>();
|
|||
|
foreach (SearchEmployee item in _SelectedEmps)
|
|||
|
item.Selected = false;
|
|||
|
sEmpID = string.Empty;
|
|||
|
if (txtEmpNo.Text != "")
|
|||
|
{
|
|||
|
string sIDs = txtEmpNo.Text.Trim(',');
|
|||
|
Employee.GetByEmpIDs(sIDs);
|
|||
|
string[] values = sIDs.Split(',');
|
|||
|
for (int i = 0; i < values.Length; i++)
|
|||
|
{
|
|||
|
Employee oEmp =Employee.Get(values[i].Trim());
|
|||
|
if (oEmp != null)
|
|||
|
{
|
|||
|
if (sEmpID == "")
|
|||
|
{
|
|||
|
sEmpID = sEmpID + oEmp.ID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sEmpID = sEmpID + "," + oEmp.ID;
|
|||
|
}
|
|||
|
nEmpCount = nEmpCount + 1;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else if (ctlEmployee.SelectedEmployee == null)
|
|||
|
{
|
|||
|
foreach (ListViewItem oItem in lsvEmployee.CheckedItems)
|
|||
|
{
|
|||
|
_SelectedEmps.GetItem(((SearchEmployee)oItem.Tag).ID).Selected = true;
|
|||
|
if (sEmpID == "")
|
|||
|
{
|
|||
|
sEmpID = sEmpID + ((SearchEmployee)oItem.Tag).EmployeeID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sEmpID = sEmpID + "," + ((SearchEmployee)oItem.Tag).EmployeeID;
|
|||
|
}
|
|||
|
nEmpCount = nEmpCount + 1;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sEmpID = sEmpID + ctlEmployee.SelectedEmployee.EmployeeID.Integer.ToString();
|
|||
|
}
|
|||
|
|
|||
|
if (sEmpID == "")
|
|||
|
{
|
|||
|
MessageBox.Show("Please at first select Employee.", "Employee", MessageBoxButtons.OK);
|
|||
|
return;
|
|||
|
}
|
|||
|
this.CallReport();
|
|||
|
}
|
|||
|
|
|||
|
private void btnExport_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void btnSearch_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
SearchManager manager = new SearchManager(EnumSearchFrom.Employee);
|
|||
|
manager.Parameter.Add(ctlCategory.SearchParam);
|
|||
|
manager.Parameter.Add(ctlDepartment.SearchParam);
|
|||
|
manager.Parameter.Add(ctlReligion.SearchParam);
|
|||
|
manager.Parameter.Add(ctlLocation.SearchParam);
|
|||
|
manager.Parameter.Add(ctlGrade.SearchParam);
|
|||
|
manager.Parameter.Add(ctlCostCenter.SearchParam);
|
|||
|
manager.Parameter.Add(ctlDesignation.SearchParam);
|
|||
|
|
|||
|
if(_reportitem.SearchFrom == EnumSearchFrom.Employee)
|
|||
|
manager.Parameter.Add(EnumSearchParameter.Status, (int)EnumEmployeeStatus.Live);
|
|||
|
|
|||
|
//manager.Parameter.Add(EnumSearchParameter.Status, EnumSQLOperator.EqualTo, EnumSearchObjDataType.Number,(int) EnumEmployeeStatus.Live);
|
|||
|
|
|||
|
if (cboGender.SelectedIndex > 0)
|
|||
|
manager.Parameter.Add(EnumSearchParameter.Gender, cboGender.SelectedIndex);
|
|||
|
if (cboBank.SelectedIndex >= 0)
|
|||
|
{
|
|||
|
manager.Parameter.Add(EnumSearchParameter.BankID, ((Bank)cboBank.SelectedItem).ID.Integer);
|
|||
|
if (cboBranch.SelectedIndex >= 0)
|
|||
|
{
|
|||
|
manager.Parameter.Add(EnumSearchParameter.BranchID, ((Branch)cboBranch.SelectedItem).ID.Integer);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
string branchID = "";
|
|||
|
int i = 0;
|
|||
|
foreach (Branch oItem in _branches)
|
|||
|
{
|
|||
|
if (oItem.BankID.Integer == ((Bank)cboBank.SelectedItem).ID.Integer)
|
|||
|
{
|
|||
|
if(i==_branches.Count-1)
|
|||
|
branchID = branchID + oItem.ID.Integer;
|
|||
|
else
|
|||
|
branchID = branchID + oItem.ID.Integer + ",";
|
|||
|
|
|||
|
i = i + 1;
|
|||
|
}
|
|||
|
}
|
|||
|
manager.Parameter.Add(EnumSearchParameter.BranchID, EnumSQLOperator.In, EnumSearchObjDataType.String, branchID);
|
|||
|
}
|
|||
|
}
|
|||
|
if (cboItem.SelectedIndex >= 0)
|
|||
|
{
|
|||
|
if (_reportitem.ItemType == EnumReportItemType.Bonus)
|
|||
|
manager.Parameter.Add(EnumSearchParameter.BonusId, ((Bonus)cboItem.SelectedItem).ID.Integer);
|
|||
|
|
|||
|
if (Scode == "011")
|
|||
|
{
|
|||
|
if (_reportitem.ItemType == EnumReportItemType.Bonus)
|
|||
|
manager.Parameter.Add(EnumSearchParameter.BonusProcessID, ((BonusProcess)cboBonus.SelectedItem).ID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
//else if(_reportitem.ItemType==EnumReportItemType.IncomeTax)
|
|||
|
// manager.Parameter.Add(EnumSearchParameter., ((OpiItem)cboItem.SelectedItem).ID.Integer);
|
|||
|
else if (_reportitem.ItemType == EnumReportItemType.OPI)
|
|||
|
manager.Parameter.Add(EnumSearchParameter.OPIID, ((OpiItem)cboItem.SelectedItem).ID.Integer);
|
|||
|
else if (_reportitem.ItemType == EnumReportItemType.IncomeTax)
|
|||
|
{
|
|||
|
TaxParameter oparameter = _taxParameter[cboItem.SelectedIndex];
|
|||
|
manager.Parameter.Add(EnumSearchParameter.TaxParameterID, ((TaxParameter)cboItem.SelectedItem).ID.Integer);
|
|||
|
manager.Parameter.Add(EnumSearchParameter.FromDate, oparameter.FiscalyearDatefrom);
|
|||
|
manager.Parameter.Add(EnumSearchParameter.ToDate, oparameter.FiscalyearDateTo);
|
|||
|
}
|
|||
|
}
|
|||
|
if (dtpfromDate.Visible == true) manager.Parameter.Add(EnumSearchParameter.FromDate, GlobalFunctions.LastDateOfMonth(dtpfromDate.Value));
|
|||
|
if (cboProcessID.SelectedIndex >= 0)
|
|||
|
manager.Parameter.Add(EnumSearchParameter.SalaryProcessCode,_oSaProcess[cboProcessID.SelectedIndex].ID.Integer);
|
|||
|
|
|||
|
if (dtpTodate.Visible == true) manager.Parameter.Add(EnumSearchParameter.ToDate, GlobalFunctions.LastDateOfMonth(dtpTodate.Value));
|
|||
|
|
|||
|
//if (_reportitem != null) manager.Parameter.Add(EnumSearchParameter.ReportID, _reportitem.ReportID.Integer);
|
|||
|
manager.SearchFrom = _reportitem.SearchFrom;
|
|||
|
_SelectedEmps = manager.Find();
|
|||
|
RefreshList();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
MessageBox.Show(ex.Message, "Error occured during search specific employee");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnCLose_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.Close();
|
|||
|
}
|
|||
|
|
|||
|
private void cboBank_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
cboBranch.DataSource = null;
|
|||
|
if (cboBank.SelectedItem != null)
|
|||
|
{
|
|||
|
_branches = Branch.GetChild(((Bank)cboBank.SelectedItem).ID);
|
|||
|
cboBranch.DataSource = _branches;
|
|||
|
cboBranch.DisplayMember = "Name";
|
|||
|
cboBranch.ValueMember = "ID";
|
|||
|
if (cboBranch.Items.Count > 0)
|
|||
|
cboBranch.SelectedIndex = -1;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnSelectAll_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
bool bSelected = false;
|
|||
|
if (btnSelectAll.Text.Equals("&Select All"))
|
|||
|
{
|
|||
|
bSelected = true;
|
|||
|
btnSelectAll.Text = "&Unselect All";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
btnSelectAll.Text = "&Select All";
|
|||
|
}
|
|||
|
|
|||
|
foreach (ListViewItem item in lsvEmployee.Items)
|
|||
|
{
|
|||
|
item.Checked = bSelected;
|
|||
|
}
|
|||
|
if (bSelected == false)
|
|||
|
lblSelected.Text = "0";
|
|||
|
}
|
|||
|
|
|||
|
private void fReportSearch_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Scode = ConfigurationManager.GetStringValue("system", "companycode", EnumConfigurationType.Logic);
|
|||
|
this._reportType = _ReportID;
|
|||
|
cboBonus.Visible = false;
|
|||
|
_reportitem = ReportItem.Get(ID.FromInteger(Convert.ToInt32(_ReportID)));
|
|||
|
|
|||
|
if (_reportitem == null)
|
|||
|
{
|
|||
|
MessageBox.Show("No setup found with reportid : " + (int)_ReportID, "Setup not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
btnSearch.Enabled = false;
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (_reportitem != null)
|
|||
|
{
|
|||
|
if (Scode == "011" && _reportitem.ItemType == EnumReportItemType.Bonus)
|
|||
|
{
|
|||
|
cboBonus.Visible = true;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
LoadBank();
|
|||
|
if (_reportitem.ItemType == EnumReportItemType.OPI)
|
|||
|
{
|
|||
|
LoadOPI();
|
|||
|
}
|
|||
|
else if (_reportitem.ItemType == EnumReportItemType.Bonus)
|
|||
|
{
|
|||
|
LoadBonus();
|
|||
|
}
|
|||
|
else if (_reportitem.ItemType == EnumReportItemType.IncomeTax)
|
|||
|
{
|
|||
|
LoadIT();
|
|||
|
}
|
|||
|
|
|||
|
DesignForm();
|
|||
|
if (_reportitem.ItemType == EnumReportItemType.BankAdviceSalary)
|
|||
|
{
|
|||
|
//cboItem.Visible = false;
|
|||
|
//lblItem.Visible = false;
|
|||
|
//LoadDesignation();
|
|||
|
}
|
|||
|
else if (_reportitem.ItemType == EnumReportItemType.EmployeeBasicAndDetails)
|
|||
|
{
|
|||
|
//LoadDesignation();
|
|||
|
//lblItem.Visible = false;
|
|||
|
//cboItem.Visible = false;
|
|||
|
//lblCostCenters.Visible = true;
|
|||
|
//ctlCostCenter.Visible = true;
|
|||
|
}
|
|||
|
else if(_reportitem.ItemType == EnumReportItemType.SalaryItem)
|
|||
|
{
|
|||
|
LoadSalaryItem();
|
|||
|
}
|
|||
|
if (_reportitem.ID.Integer == 26 || _reportitem.ID.Integer == 24 || _reportitem.ID.Integer == 18
|
|||
|
|| _reportitem.ID.Integer == 19 || _reportitem.ID.Integer == 21)
|
|||
|
{
|
|||
|
btnExport.Visible = true;
|
|||
|
}
|
|||
|
else
|
|||
|
btnExport.Visible = false;
|
|||
|
}
|
|||
|
|
|||
|
private void cboItem_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if(Scode=="011")
|
|||
|
{
|
|||
|
if (_reportitem.ItemType == EnumReportItemType.Bonus)
|
|||
|
{
|
|||
|
cboBonus.DataSource = null;
|
|||
|
if (cboItem.SelectedItem != null)
|
|||
|
{
|
|||
|
_bonusProcess = BonusProcess.GetProcess(((Bonus)cboItem.SelectedItem).ID, dtpfromDate.Value);
|
|||
|
|
|||
|
cboBonus.DataSource = _bonusProcess;
|
|||
|
cboBonus.DisplayMember = "BatchNo";
|
|||
|
cboBonus.ValueMember = "ID";
|
|||
|
if (cboBonus.Items.Count > 0)
|
|||
|
cboBonus.SelectedIndex = -1;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnExport_Click_1(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Cursor.Current = Cursors.WaitCursor;
|
|||
|
if (Payroll.BO.SystemInformation.CurrentSysInfo.Code == "004")
|
|||
|
{
|
|||
|
if (cboItem.Visible == true && _opiItems != null)
|
|||
|
{
|
|||
|
if (cboItem.SelectedItem == null)
|
|||
|
{
|
|||
|
Cursor.Current = Cursors.Default;
|
|||
|
MessageBox.Show("Select an OPI Item first", "OPI", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
int nEmpCount = 0;
|
|||
|
if (_SelectedEmps == null)
|
|||
|
_SelectedEmps = new ObjectsTemplate<SearchEmployee>();
|
|||
|
foreach (SearchEmployee item in _SelectedEmps)
|
|||
|
item.Selected = false;
|
|||
|
sEmpID = string.Empty;
|
|||
|
if (txtEmpNo.Text != "")
|
|||
|
{
|
|||
|
string sIDs = txtEmpNo.Text.Trim(',');
|
|||
|
Employee.GetByEmpIDs(sIDs);
|
|||
|
string[] values = sIDs.Split(',');
|
|||
|
for (int i = 0; i < values.Length; i++)
|
|||
|
{
|
|||
|
Employee oEmp = Employee.Get(values[i].Trim());
|
|||
|
if (sEmpID == "")
|
|||
|
{
|
|||
|
sEmpID = sEmpID + oEmp.ID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sEmpID = sEmpID + "," + oEmp.ID;
|
|||
|
}
|
|||
|
nEmpCount = nEmpCount + 1;
|
|||
|
}
|
|||
|
}
|
|||
|
else if (ctlEmployee.SelectedEmployee == null)
|
|||
|
{
|
|||
|
foreach (ListViewItem oItem in lsvEmployee.CheckedItems)
|
|||
|
{
|
|||
|
_SelectedEmps.GetItem(((SearchEmployee)oItem.Tag).ID).Selected = true;
|
|||
|
if (sEmpID == "")
|
|||
|
{
|
|||
|
sEmpID = sEmpID + ((SearchEmployee)oItem.Tag).EmployeeID;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sEmpID = sEmpID + "," + ((SearchEmployee)oItem.Tag).EmployeeID;
|
|||
|
}
|
|||
|
nEmpCount = nEmpCount + 1;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sEmpID = sEmpID + ctlEmployee.SelectedEmployee.EmployeeID.Integer.ToString();
|
|||
|
}
|
|||
|
|
|||
|
if (sEmpID == "")
|
|||
|
{
|
|||
|
Cursor.Current = Cursors.Default;
|
|||
|
MessageBox.Show("Please at first select Employee.", "Employee", MessageBoxButtons.OK);
|
|||
|
return;
|
|||
|
}
|
|||
|
this.CollectObjects();
|
|||
|
SaveFileDialog savefile = new SaveFileDialog();
|
|||
|
// set a default file name
|
|||
|
|
|||
|
// set filters - this can be done in properties as well
|
|||
|
savefile.Filter = "Excel files (*.xlsx)|*.xlsx";
|
|||
|
|
|||
|
if (_reportitem.ID.Integer == 26 || _reportitem.ID.Integer == 24 || _reportitem.ID.Integer == 18
|
|||
|
|| _reportitem.ID.Integer == 19 || _reportitem.ID.Integer == 21)
|
|||
|
{
|
|||
|
OTReport oTrpt=new OTReport ();
|
|||
|
rptEmployee rptEmp = new rptEmployee();
|
|||
|
rptBonus rptBonus = new rptBonus();
|
|||
|
if (_reportitem.ID.Integer == 26)
|
|||
|
{
|
|||
|
savefile.FileName = "Employee Details";
|
|||
|
}
|
|||
|
else if (_reportitem.ID.Integer == 24)
|
|||
|
{
|
|||
|
savefile.FileName = "Salary Sheet";
|
|||
|
}
|
|||
|
else if (_reportitem.ID.Integer == 18)
|
|||
|
{
|
|||
|
savefile.FileName = "OT Sheet";
|
|||
|
}
|
|||
|
else if (_reportitem.ID.Integer == 19)
|
|||
|
{
|
|||
|
savefile.FileName = "Bonus Sheet";
|
|||
|
}
|
|||
|
else if (_reportitem.ID.Integer == 21)
|
|||
|
{
|
|||
|
savefile.FileName = "Bank Advice";
|
|||
|
}
|
|||
|
|
|||
|
if (savefile.ShowDialog() == DialogResult.OK)
|
|||
|
{
|
|||
|
if (_reportitem.ID.Integer == 26)
|
|||
|
{
|
|||
|
GlobalFunctions.ExportToExcel(rptEmp.GetEmpDetails2(sEmpID).Tables[0], savefile.FileName, "Employee Details");
|
|||
|
}
|
|||
|
else if (_reportitem.ID.Integer == 24)
|
|||
|
{
|
|||
|
GlobalFunctions.ExportToExcel(new rptSalarySheet().ExportSalarySheet(_reportSetup.FromDate.Value, _reportitem.ReportID, sEmpID), savefile.FileName, "Salary Sheet");
|
|||
|
}
|
|||
|
else if (_reportitem.ID.Integer == 18)
|
|||
|
{
|
|||
|
GlobalFunctions.ExportToExcel(oTrpt.OTMonthlySheetForExcel(_reportSetup.FromDate.Value, sEmpID).Tables[0], savefile.FileName, "OT Sheet");
|
|||
|
}
|
|||
|
else if (_reportitem.ID.Integer == 19)
|
|||
|
{
|
|||
|
GlobalFunctions.ExportToExcel(rptBonus.BonusRegisterForExcel(_reportSetup.FromDate.Value, sEmpID, ((Bonus)cboItem.SelectedItem).ID).Tables[0], savefile.FileName, "Bonus Sheet");
|
|||
|
}
|
|||
|
else if (_reportitem.ID.Integer == 21)
|
|||
|
{
|
|||
|
GlobalFunctions.ExportToExcel(new rptBankAdvice().ExportBankAdvice(_reportSetup.FromDate.Value, _reportitem.ReportID, sEmpID, _reportSetup.Banks), savefile.FileName, "Bank Advice");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
Cursor.Current = Cursors.Default;
|
|||
|
MessageBox.Show("Excel created at " + savefile.FileName);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void dtpfromDate_ValueChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
if(nKeyNumber==1)
|
|||
|
{
|
|||
|
if (dtpfromDate.Value.Month == 1)
|
|||
|
{
|
|||
|
nKeyNumber = 3;
|
|||
|
dtpfromDate.Value = new DateTime(dtpfromDate.Value.Year + 1, dtpfromDate.Value.Month, 5);
|
|||
|
}
|
|||
|
}
|
|||
|
else if (nKeyNumber == 2)
|
|||
|
{
|
|||
|
if (dtpfromDate.Value.Month == 12)
|
|||
|
{
|
|||
|
nKeyNumber = 3;
|
|||
|
dtpfromDate.Value = new DateTime(dtpfromDate.Value.Year - 1, dtpfromDate.Value.Month, 5);
|
|||
|
}
|
|||
|
}
|
|||
|
DateTime salaryMonth = dtpfromDate.Value;
|
|||
|
cboProcessID.DataSource = null; ;
|
|||
|
|
|||
|
_oSaProcess = SalaryProcess.Get(GlobalFunctions.LastDateOfMonth(salaryMonth));
|
|||
|
cboProcessID.DataSource = _oSaProcess;
|
|||
|
cboProcessID.DisplayMember = "ProcessCode";
|
|||
|
cboProcessID.ValueMember = "ID";
|
|||
|
if (cboProcessID.Items.Count > 0)
|
|||
|
cboProcessID.SelectedIndex = -1;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void btnProcessCodeClear_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
cboProcessID.SelectedIndex = -1;
|
|||
|
}
|
|||
|
|
|||
|
private void fReportSearch_KeyDown(object sender, KeyEventArgs e)
|
|||
|
{
|
|||
|
if (e.KeyCode == Keys.F5)
|
|||
|
{
|
|||
|
btnPreview_Click(null, null);
|
|||
|
}
|
|||
|
else if (e.KeyCode == Keys.F6)
|
|||
|
{
|
|||
|
btnExport_Click_1(null, null);
|
|||
|
}
|
|||
|
else if (e.KeyCode == Keys.F3)
|
|||
|
{
|
|||
|
btnSearch_Click(null, null);
|
|||
|
}
|
|||
|
else if (e.KeyCode == Keys.F4)
|
|||
|
{
|
|||
|
btnSelectAll_Click(null, null);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void fReportSearch_KeyPress(object sender, KeyPressEventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void dtpfromDate_KeyDown(object sender, KeyEventArgs e)
|
|||
|
{
|
|||
|
if (e.KeyCode == Keys.Up)
|
|||
|
{
|
|||
|
nKeyNumber = 1;
|
|||
|
}
|
|||
|
else if (e.KeyCode == Keys.Down)
|
|||
|
{
|
|||
|
nKeyNumber = 2;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
nKeyNumber = 3;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void dtpfromDate_KeyUp(object sender, KeyEventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void dtpTodate_ValueChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (nKeyNumber == 1)
|
|||
|
{
|
|||
|
if (dtpTodate.Value.Month == 1)
|
|||
|
{
|
|||
|
nKeyNumber = 3;
|
|||
|
dtpTodate.Value = new DateTime(dtpTodate.Value.Year + 1, dtpTodate.Value.Month, 5);
|
|||
|
}
|
|||
|
}
|
|||
|
else if (nKeyNumber == 2)
|
|||
|
{
|
|||
|
if (dtpTodate.Value.Month == 12)
|
|||
|
{
|
|||
|
nKeyNumber = 3;
|
|||
|
dtpTodate.Value = new DateTime(dtpTodate.Value.Year - 1, dtpTodate.Value.Month, 5);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void lsvEmployee_ColumnClick(object sender, ColumnClickEventArgs e)
|
|||
|
{
|
|||
|
// Get the new sorting column.
|
|||
|
ColumnHeader new_sorting_column = lsvEmployee.Columns[e.Column];
|
|||
|
|
|||
|
// Figure out the new sorting order.
|
|||
|
System.Windows.Forms.SortOrder sort_order;
|
|||
|
if (SortingColumn == null)
|
|||
|
{
|
|||
|
// New column. Sort ascending.
|
|||
|
sort_order = SortOrder.Ascending;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// See if this is the same column.
|
|||
|
if (new_sorting_column == SortingColumn)
|
|||
|
{
|
|||
|
// Same column. Switch the sort order.
|
|||
|
if (SortingColumn.Text.StartsWith("> "))
|
|||
|
{
|
|||
|
sort_order = SortOrder.Descending;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sort_order = SortOrder.Ascending;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// New column. Sort ascending.
|
|||
|
sort_order = SortOrder.Ascending;
|
|||
|
}
|
|||
|
|
|||
|
// Remove the old sort indicator.
|
|||
|
SortingColumn.Text = SortingColumn.Text.Substring(2);
|
|||
|
}
|
|||
|
|
|||
|
// Display the new sort order.
|
|||
|
SortingColumn = new_sorting_column;
|
|||
|
if (sort_order == SortOrder.Ascending)
|
|||
|
{
|
|||
|
SortingColumn.Text = "> " + SortingColumn.Text;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
SortingColumn.Text = "< " + SortingColumn.Text;
|
|||
|
}
|
|||
|
|
|||
|
// Create a comparer.
|
|||
|
lsvEmployee.ListViewItemSorter =
|
|||
|
new ListViewComparer(e.Column, sort_order);
|
|||
|
|
|||
|
// Sort.
|
|||
|
lsvEmployee.Sort();
|
|||
|
}
|
|||
|
|
|||
|
//private void lsvEmployee_ColumnClick(object sender, ColumnClickEventArgs e)
|
|||
|
//{
|
|||
|
// this.Cursor = Cursors.WaitCursor;
|
|||
|
|
|||
|
// SortOrder order = SortOrder.Ascending;
|
|||
|
// if (order == lsvEmployee.Sorting)
|
|||
|
// order = SortOrder.Descending;
|
|||
|
// else
|
|||
|
// order = SortOrder.Ascending;
|
|||
|
|
|||
|
// lsvEmployee.ListViewItemSorter = new Global.ItemSorter(e.Column, order);
|
|||
|
// lsvEmployee.Sorting = order;
|
|||
|
|
|||
|
// this.Cursor = Cursors.Default;
|
|||
|
//}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|