314 lines
14 KiB
C#
314 lines
14 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 Ease.CoreV35;
|
|
using Ease.CoreV35.Utility;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.Model;
|
|
using Microsoft.Reporting.WinForms;
|
|
namespace Payroll.Report.UI
|
|
{
|
|
public partial class fMarketSurveyComparison : Form
|
|
{
|
|
ObjectsTemplate<Grade> allGrades = null;
|
|
List<ReportParameter> _parameters = null;
|
|
ReportItem _item = null;
|
|
ReportParameter rParam = null;
|
|
ObjectsTemplate<Employee> _oEmployees = null;
|
|
ObjectsTemplate<SalaryMonthly> _oSalaryMonthlys = null;
|
|
string _PATH = string.Empty;
|
|
string sSearchDate = "";
|
|
public fMarketSurveyComparison()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public ReportViewer ReportViewer
|
|
{
|
|
get { return rptViewer; }
|
|
}
|
|
private List<ReportParameter> reportParameters;
|
|
public List<ReportParameter> ReportParams
|
|
{
|
|
get { return reportParameters; }
|
|
set { reportParameters = value; }
|
|
}
|
|
private void FillCombos()
|
|
{
|
|
EnumItemCollection modeOfMarketSurvey = EnumFormatter.GetObjects(typeof(EnumSurveyOn));
|
|
cboSurveyOn.DataSource = modeOfMarketSurvey;
|
|
cboSurveyOn.DisplayMember = "friendlyName";
|
|
cboSurveyOn.ValueMember = "Value";
|
|
|
|
allGrades = new ObjectsTemplate<Grade>();
|
|
allGrades = Grade.Get(EnumStatus.Active);
|
|
cmbDesignation.Items.Add("All");
|
|
foreach (Grade oDesg in allGrades)
|
|
{
|
|
cmbDesignation.Items.Add(oDesg.Name);
|
|
}
|
|
if (allGrades.Count > 0)
|
|
cmbDesignation.SelectedIndex = 0;
|
|
}
|
|
|
|
private void fMarketSurveyComparison_Load(object sender, EventArgs e)
|
|
{
|
|
FillCombos();
|
|
dtpPayDate.Value = DateTime.Today.Year;
|
|
}
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void btnCompare_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
int nSurveyOn = (int)((EnumSurveyOn)(cboSurveyOn.SelectedValue));
|
|
int nGradeID = 0;
|
|
ObjectsTemplate<MarketSalarySurvey> oMSurveys = new ObjectsTemplate<MarketSalarySurvey>();
|
|
ObjectsTemplate<MarketSurveyCompany> oMSurveyCompanies = MarketSurveyCompany.Get(EnumStatus.Regardless);
|
|
List<SalaryMonthly> _oNewSalaryMonthlys = new List<SalaryMonthly>();
|
|
List<Employee> oNewEmployees = new List<Employee>();
|
|
List<Employee> oEmployees = Employee.GetForSuperUser();
|
|
string sItemName = "";
|
|
//_oSalaryMonthlys = SalaryMonthly.GetByDateRange(Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfYear(new DateTime((int)dtpPayDate.Value, 1, 1)), Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfYear(new DateTime((int)dtpPayDate.Value, 1, 1)));
|
|
if (cmbDesignation.SelectedIndex == 0)
|
|
{
|
|
oMSurveys = MarketSalarySurvey.Get(new DateTime((int)dtpPayDate.Value, 1, 1), nSurveyOn);
|
|
oNewEmployees = oEmployees;
|
|
}
|
|
else
|
|
{
|
|
nGradeID = allGrades[cmbDesignation.SelectedIndex - 1].ID.Integer;
|
|
oMSurveys = MarketSalarySurvey.Get(new DateTime((int)dtpPayDate.Value, 1, 1), nSurveyOn, nGradeID);
|
|
//_oNewSalaryMonthlys = _oSalaryMonthlys.FindAll(delegate(SalaryMonthly smItem) { return smItem.GradeID.Integer == nGradeID; });
|
|
oNewEmployees = oEmployees.FindAll(delegate(Employee smItem) { return smItem.GradeID.Integer == nGradeID; });
|
|
}
|
|
sItemName = cboSurveyOn.Text;
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("CompanyName", typeof(string));
|
|
dt.Columns.Add("SurveyYear", typeof(string));
|
|
dt.Columns.Add("SurveyOn", typeof(string));
|
|
dt.Columns.Add("GradeName", typeof(string));
|
|
dt.Columns.Add("Amount", typeof(double));
|
|
foreach (MarketSalarySurvey MS in oMSurveys)
|
|
{
|
|
MarketSurveyCompany com = oMSurveyCompanies.Find(delegate(MarketSurveyCompany item) { return item.ID == MS.CompanyID; });
|
|
Grade grd = allGrades.Find(delegate(Grade item) { return item.ID == MS.GradeID; });
|
|
if (grd.Name != "")
|
|
{
|
|
dt.Rows.Add(com == null ? "" : com.Name, MS.SurveyYear.ToString("yyyy"), sItemName, grd == null ? "" : grd.Name, MS.Amount);
|
|
}
|
|
}
|
|
//Get Data for own company
|
|
double nAmount = 0.0;
|
|
if (nGradeID > 0)
|
|
{
|
|
foreach (Employee emp in oNewEmployees)
|
|
{
|
|
if (cboSurveyOn.SelectedIndex == 0)
|
|
{
|
|
nAmount += emp.BasicSalary;
|
|
}
|
|
else if (cboSurveyOn.SelectedIndex == 1)
|
|
{
|
|
nAmount += emp.GrossSalary;
|
|
}
|
|
else if (cboSurveyOn.SelectedIndex == 3)
|
|
{
|
|
nAmount += emp.GrossSalary;
|
|
}
|
|
}
|
|
if(nAmount>0)
|
|
nAmount = nAmount / oNewEmployees.Count;
|
|
//foreach (SalaryMonthly sm in _oNewSalaryMonthlys)
|
|
//{
|
|
// foreach (SalaryMonthlyDetail smd in sm.Details)
|
|
// {
|
|
// if (cboSurveyOn.SelectedIndex == 0)
|
|
// {
|
|
// if (smd.ItemID == -101 && smd.ItemCode == EnumSalaryItemCode.Basic_Salary)
|
|
// nAmount += smd.CalculatedAmount;
|
|
// }
|
|
// else if (cboSurveyOn.SelectedIndex == 1)
|
|
// {
|
|
// if (smd.itemGroupCode == EnumSalaryGroup.Gross)
|
|
// nAmount += smd.CalculatedAmount;
|
|
// }
|
|
// else if (cboSurveyOn.SelectedIndex == 3)
|
|
// {
|
|
// if (smd.itemGroupCode == EnumSalaryGroup.Gross)
|
|
// nAmount += smd.CalculatedAmount;
|
|
// if (smd.ItemID == -107 && smd.ItemCode == EnumSalaryItemCode.Bonus)
|
|
// nAmount += smd.CalculatedAmount;
|
|
// if (smd.ItemID == -138 && smd.ItemCode == EnumSalaryItemCode.OPI)
|
|
// nAmount += smd.CalculatedAmount;
|
|
// }
|
|
|
|
// }
|
|
//}
|
|
Grade gd = allGrades[cmbDesignation.SelectedIndex - 1];
|
|
if (gd.Name != "")
|
|
{
|
|
dt.Rows.Add(Payroll.BO.SystemInformation.CurrentSysInfo.name, dtpPayDate.Value.ToString(), sItemName, gd.Name, nAmount);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double nAmount2 = 0;
|
|
foreach (Grade grd in allGrades)
|
|
{
|
|
nAmount2 = 0;
|
|
//_oNewSalaryMonthlys = _oSalaryMonthlys.FindAll(delegate(SalaryMonthly smItem) { return smItem.GradeID == grd.ID; });
|
|
oNewEmployees = oEmployees.FindAll(delegate(Employee smItem) { return smItem.GradeID == grd.ID; });
|
|
foreach (Employee emp in oNewEmployees)
|
|
{
|
|
if (cboSurveyOn.SelectedIndex == 0)
|
|
{
|
|
nAmount2 += emp.BasicSalary;
|
|
}
|
|
else if (cboSurveyOn.SelectedIndex == 1)
|
|
{
|
|
nAmount2 += emp.GrossSalary;
|
|
}
|
|
else if (cboSurveyOn.SelectedIndex == 3)
|
|
{
|
|
nAmount2 += emp.GrossSalary;
|
|
}
|
|
}
|
|
if (nAmount2 > 0)
|
|
{
|
|
nAmount2 = nAmount2 / oNewEmployees.Count;
|
|
}
|
|
//foreach (SalaryMonthly sm in _oNewSalaryMonthlys)
|
|
//{
|
|
// foreach (SalaryMonthlyDetail smd in sm.Details)
|
|
// {
|
|
// if (cboSurveyOn.SelectedIndex == 0)
|
|
// {
|
|
// if (smd.ItemID == -101 && smd.ItemCode == EnumSalaryItemCode.Basic_Salary)
|
|
// nAmount += smd.CalculatedAmount;
|
|
// }
|
|
// else if (cboSurveyOn.SelectedIndex == 1)
|
|
// {
|
|
// if (smd.itemGroupCode == EnumSalaryGroup.Gross)
|
|
// nAmount += smd.CalculatedAmount;
|
|
// }
|
|
// else if (cboSurveyOn.SelectedIndex == 3)
|
|
// {
|
|
// if (smd.itemGroupCode == EnumSalaryGroup.Gross)
|
|
// nAmount += smd.CalculatedAmount;
|
|
// if (smd.ItemID == -107 && smd.ItemCode == EnumSalaryItemCode.Bonus)
|
|
// nAmount += smd.CalculatedAmount;
|
|
// if (smd.ItemID == -138 && smd.ItemCode == EnumSalaryItemCode.OPI)
|
|
// nAmount += smd.CalculatedAmount;
|
|
// }
|
|
// }
|
|
//}
|
|
if (grd.Name != "")
|
|
{
|
|
dt.Rows.Add(Payroll.BO.SystemInformation.CurrentSysInfo.name, dtpPayDate.Value.ToString(), sItemName, grd.Name, nAmount2);
|
|
}
|
|
}
|
|
}
|
|
this.ShowDlgForMarketSurveyComparison(dt);
|
|
}
|
|
catch (Exception exp)
|
|
{
|
|
Cursor.Current = Cursors.Default;
|
|
throw new Exception(exp.Message);
|
|
}
|
|
Cursor.Current = Cursors.Default;
|
|
}
|
|
public void ShowDlgForMarketSurveyComparison(DataTable oFinalDT)
|
|
{
|
|
DataSet dSet = new DataSet();
|
|
string RDLC;
|
|
oFinalDT.TableName = "PayrollDataSet_MarketSurveyCom";
|
|
RDLC = "Payroll.Report.RDLC.CompareMarketSurvey.rdlc";
|
|
dSet.Tables.Add(oFinalDT);
|
|
|
|
_PATH = Application.StartupPath + @"\Logo.jpg";
|
|
ReportViewer.Refresh();
|
|
ReportViewer.LocalReport.DataSources.Clear();
|
|
ReportViewer.LocalReport.EnableExternalImages = true;
|
|
try
|
|
{
|
|
if (dSet != null && dSet.Tables.Count > 0)
|
|
{
|
|
foreach (DataTable table in dSet.Tables)
|
|
{
|
|
ReportViewer.LocalReport.DataSources.Add(new ReportDataSource(table.TableName, table));
|
|
//ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("", table));
|
|
}
|
|
ReportViewer.LocalReport.ReportEmbeddedResource = RDLC;
|
|
}
|
|
|
|
//ReportViewer.LocalReport.ReportEmbeddedResource = "Payroll.Report.RDLC.Payslip.rdlc";
|
|
GetParameters();
|
|
this.ReportParams = _parameters;
|
|
|
|
if (reportParameters != null)
|
|
ReportViewer.LocalReport.SetParameters(reportParameters);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message, ex);
|
|
}
|
|
ReportViewer.RefreshReport();
|
|
}
|
|
public void GetParameters()
|
|
{
|
|
Payroll.BO.SystemInformation _systemInfo = Payroll.BO.SystemInformation.Get();
|
|
_parameters = new List<ReportParameter>();
|
|
|
|
rParam = new ReportParameter("Logo", _PATH);
|
|
_parameters.Add(rParam);
|
|
|
|
rParam = new ReportParameter("CompanyInfo", _systemInfo.name.ToString());
|
|
_parameters.Add(rParam);
|
|
|
|
if (_item != null)
|
|
{
|
|
rParam = new ReportParameter("SearchCriteria", " ", _item.IsSearchCriteria);
|
|
_parameters.Add(rParam);
|
|
}
|
|
else
|
|
{
|
|
rParam = new ReportParameter("SearchCriteria", "", false);
|
|
_parameters.Add(rParam);
|
|
}
|
|
|
|
rParam = new ReportParameter("Address", _systemInfo.corporateAddress.ToString());
|
|
//rParam = new ReportParameter("Address", "6th-9th Floors ,Noor Tower,110, Bir Uttam C.R Dattta Road, Dhaka-1205");
|
|
_parameters.Add(rParam);
|
|
|
|
rParam = new ReportParameter("Phone", _systemInfo.TelephoneNo.ToString());
|
|
//rParam = new ReportParameter("Phone", "0124232323");
|
|
_parameters.Add(rParam);
|
|
|
|
//rParam = new ReportParameter("Fax", "++03423232323");
|
|
//_parameters.Add(rParam);
|
|
|
|
//rParam = new ReportParameter("Email", _systemInfo.webAddress);
|
|
//_parameters.Add(rParam);
|
|
}
|
|
|
|
private void fMarketSurveyComparison_Resize(object sender, EventArgs e)
|
|
{
|
|
panel1.Width = this.Width - 10;
|
|
rptViewer.Width = this.Width - 10;
|
|
}
|
|
|
|
|
|
}
|
|
}
|