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

600 lines
31 KiB
C#

using System;
using System;
using System;
using System;
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.Utility;
using Payroll.BO;
using Ease.CoreV35.Model;
using Ease.CoreV35;
using Microsoft.Reporting.WinForms;
using Ease.CoreV35.DataAccess;
using System.Data;
namespace Payroll.Report
{
public partial class frmBudgetReport : Form
{
ObjectsTemplate<BudgetProcessMonthlyDetail> _BudgetProcessMonthlieDetails1 = null;
ObjectsTemplate<BudgetProcessMonthlyDetail> _BudgetProcessMonthlieDetails2 = null;
ObjectsTemplate<BudgetProcessMonthlyDetail> _BudgetProcessMonthlieDetails3 = null;
ObjectsTemplate<BudgetMaster> _BudgetMasters = null;
ObjectsTemplate<GrossDefination> grossDefinations = new ObjectsTemplate<GrossDefination>();
public frmBudgetReport()
{
InitializeComponent();
}
private void btnClose_Click(object sender, EventArgs e)
{
Close();
}
private void btnPreview_Click(object sender, EventArgs e)
{
if (lsvBudget.SelectedItems.Count > 0)
{
if (lsvBudget.SelectedItems[0].Text == "Employee Wise Forecasting Report")
EmployeeWiseBudgetReport();
else
BudgetComparison();
//else if (lsvBudget.SelectedItems[0].Index == 1)
// CCWiseBudgetReport();
//else if (lsvBudget.SelectedItems[0].Index == 2)
// BudgetComparison();
//else if (lsvBudget.SelectedItems[0].Index == 3)
// BudgetComparison39();
}
else
MessageBox.Show("Please select a report.");
}
private void frmBudgetReport_Load(object sender, EventArgs e)
{
grossDefinations = GrossDefination.Get();
lsvBudget.Items.Clear();
ListViewItem li = null;
li = new ListViewItem();
li.Text = "Employee Wise Forecasting Report";
lsvBudget.Items.Add(li);
//li = new ListViewItem();
//li.Text = "Cost-Center Wise Budget Report";
//lsvBudget.Items.Add(li);
//li = new ListViewItem();
//li.Text = "Forecasting Comparison Report";
//lsvBudget.Items.Add(li);
//li = new ListViewItem();
//li.Text = "Budget VS 3+9 Report";
//lsvBudget.Items.Add(li);
_BudgetMasters = new ObjectsTemplate<BudgetMaster>();
_BudgetMasters = BudgetMaster.Get();
foreach (BudgetMaster bm in _BudgetMasters)
{
cmbBudget.Items.Add(bm.Name);
comboBox1.Items.Add(bm.Name);
comboBox2.Items.Add(bm.Name);
cmbBud3.Items.Add(bm.Name);
cmbBud9.Items.Add(bm.Name);
cmbBud39.Items.Add(bm.Name);
}
//cmbBudget.SelectedIndex = 0;
//comboBox1.SelectedIndex = 0;
//comboBox2.SelectedIndex = 0;
//cmbBud3.SelectedIndex = 0;
//cmbBud9.SelectedIndex = 0;
//cmbBud39.SelectedIndex = 0;
lsvBudget.Items[0].Selected = true;
lsvBudget_Click(null, null);
}
private void CCWiseBudgetReport()
{
Cursor.Current = Cursors.WaitCursor;
List<ReportDataSource> dataSource = new List<ReportDataSource>();
ObjectsTemplate<Employee> oEmps = Employee.Get();
Payroll.Service.BudgetProcessMonthlyService ps=new Payroll.Service.BudgetProcessMonthlyService();
ObjectsTemplate<BudgetMonthlyCC> budCCs = ps.GetBudgetMonthlyCCs(_BudgetMasters[cmbBudget.SelectedIndex].ID.Integer, dtpFromDate.Value, dtpToDate.Value);
_BudgetProcessMonthlieDetails1 = BudgetProcessMonthlyDetail.Get(Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfMonth(dtpFromDate.Value), Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(dtpToDate.Value), _BudgetMasters[comboBox1.SelectedIndex].ID.Integer);
if (_BudgetProcessMonthlieDetails1.Count == 0)
{
MessageBox.Show("No data found", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
ObjectsTemplate<Costcenter> oCrgs = new ObjectsTemplate<Costcenter>();
oCrgs = Costcenter.Get();
DataTable oBody = new Payroll.Report.PayrollDataSet.dsEmpLeaveLedger.BudgetCCDataTable();
foreach (BudgetProcessMonthlyDetail oItem in _BudgetProcessMonthlieDetails1)
{
Employee oEmp = oEmps.Find(delegate(Employee emp) { return oItem.EmployeeID == emp.ID; });
BudgetMonthlyCC empCC = budCCs.Find(delegate(BudgetMonthlyCC cc) { return oItem.EmployeeID == cc.EmployeeID; });
Costcenter occ = oCrgs.Find(delegate(Costcenter cc) { return empCC.CCID == cc.ID; });
if (oItem.BudgetCode!=EnumBudgetCode.Guranted_Cash)
oBody.Rows.Add(occ.Name, oEmp == null ? oItem.EmployeeID.ToString() : oEmp.EmployeeNo, oEmp == null ? oItem.EmployeeID.ToString() : oEmp.Name, "", oItem.Name, GlobalFunctions.TakaFormat(Math.Round(oItem.Calculatedamount, 2)), "Budget Name: " + cmbBudget.Text + " From " + dtpFromDate.Value.ToString("MMM yyyy") + " To " + dtpToDate.Value.ToString("MMM yyyy"));
}
string embeddedResource = "Payroll.Report.RDLC.rptBudgetCCReport.rdlc";
string caption = "Cost Center Wise Forecasting Report";
dataSource = new List<ReportDataSource>();
dataSource.Add(new ReportDataSource("dsEmpLeaveLedger_BudgetCC", oBody));
Cursor.Current = Cursors.Default;
try
{
fReportViewer fViewer = new fReportViewer();
fViewer.PreviewReport(dataSource, embeddedResource, caption);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
private void EmployeeWiseBudgetReport()
{
_BudgetProcessMonthlieDetails1 = new ObjectsTemplate<BudgetProcessMonthlyDetail>();
Cursor.Current = Cursors.WaitCursor;
List<ReportDataSource> dataSource;
ObjectsTemplate<Employee> oEmps = Employee.Get();
DataTable oBody = new Payroll.Report.PayrollDataSet.dsEmpLeaveLedger.BudgetDataTable();
DataTable oSortedBody = new Payroll.Report.PayrollDataSet.dsEmpLeaveLedger.BudgetDataTable();
DataTable oSortedBody2 = new Payroll.Report.PayrollDataSet.dsEmpLeaveLedger.BudgetDataTable();
_BudgetProcessMonthlieDetails1 = BudgetProcessMonthlyDetail.Get(Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfMonth(dtpFromDate.Value), Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(dtpToDate.Value),_BudgetMasters[cmbBudget.SelectedIndex].ID.Integer);
if (_BudgetProcessMonthlieDetails1.Count == 0)
{
MessageBox.Show("No data found", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
foreach (BudgetProcessMonthlyDetail oItem in _BudgetProcessMonthlieDetails1)
{
Employee oEmp = oEmps.Find(delegate(Employee emp) { return oItem.EmployeeID == emp.ID; });
if (oItem.BudgetCode != EnumBudgetCode.Guranted_Cash)
oBody.Rows.Add(oEmp == null ? oItem.EmployeeID.ToString() : oEmp.EmployeeNo, oEmp == null ? oItem.EmployeeID.ToString() : oEmp.Name, "", oItem.Name, GlobalFunctions.TakaFormat(Math.Round(oItem.Calculatedamount, 2)), "Budget Name: " + cmbBudget.Text + " From " + dtpFromDate.Value.ToString("MMM yyyy") + " To " + dtpToDate.Value.ToString("MMM yyyy"),oItem.Position);
}
var sortedData = from DataRow dr in oBody.Rows orderby dr["EmpNo"] select dr;
foreach (DataRow dr in sortedData)
{
DataRow nDr = oSortedBody.NewRow();
nDr.ItemArray = dr.ItemArray;
oSortedBody.Rows.Add(nDr);
}
var sortedData2 = from DataRow dr in oSortedBody.Rows orderby dr["Position"] select dr;
foreach (DataRow dr in sortedData2)
{
DataRow nDr = oSortedBody2.NewRow();
nDr.ItemArray = dr.ItemArray;
oSortedBody2.Rows.Add(nDr);
}
string embeddedResource = "Payroll.Report.RDLC.Budget.rdlc";
string caption = "Budget Report";
dataSource = new List<ReportDataSource>();
dataSource.Add(new ReportDataSource("dsEmpLeaveLedger_Budget", oSortedBody2));
Cursor.Current = Cursors.Default;
try
{
fReportViewer fViewer = new fReportViewer();
fViewer.PreviewReport(dataSource, embeddedResource, caption);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
private void BudgetComparison()
{
int nMonth = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("m",Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfMonth(_BudgetMasters[comboBox1.SelectedIndex].FromDate),Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(_BudgetMasters[comboBox1.SelectedIndex].ToDate))+1;
_BudgetProcessMonthlieDetails1 = new ObjectsTemplate<BudgetProcessMonthlyDetail>();
_BudgetProcessMonthlieDetails2 = new ObjectsTemplate<BudgetProcessMonthlyDetail>();
Cursor.Current = Cursors.WaitCursor;
List<ReportDataSource> dataSource = new List<ReportDataSource>();
ObjectsTemplate<Costcenter> oCrgs1 = new ObjectsTemplate<Costcenter>();
oCrgs1 = Costcenter.Get();
Payroll.Service.BudgetProcessMonthlyService ps = new Payroll.Service.BudgetProcessMonthlyService();
ObjectsTemplate<BudgetMonthlyCC> budCCs1 = ps.GetBudgetMonthlyCCs(_BudgetMasters[comboBox1.SelectedIndex].ID.Integer, _BudgetMasters[comboBox1.SelectedIndex].FromDate, _BudgetMasters[comboBox1.SelectedIndex].ToDate);
_BudgetProcessMonthlieDetails1 = BudgetProcessMonthlyDetail.Get2(Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfMonth(_BudgetMasters[comboBox1.SelectedIndex].FromDate), Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(_BudgetMasters[comboBox1.SelectedIndex].ToDate), _BudgetMasters[comboBox1.SelectedIndex].ID.Integer);
_BudgetProcessMonthlieDetails2 = BudgetProcessMonthlyDetail.Get2(Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfMonth(_BudgetMasters[comboBox2.SelectedIndex].FromDate), Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(_BudgetMasters[comboBox2.SelectedIndex].ToDate), _BudgetMasters[comboBox2.SelectedIndex].ID.Integer);
ObjectsTemplate<BudgetMonthlyCC> budCCs2 = ps.GetBudgetMonthlyCCs(_BudgetMasters[comboBox2.SelectedIndex].ID.Integer, _BudgetMasters[comboBox2.SelectedIndex].FromDate, _BudgetMasters[comboBox2.SelectedIndex].ToDate);
if (_BudgetProcessMonthlieDetails1.Count == 0)
{
MessageBox.Show("No data found", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
DataTable oBody = new Payroll.Report.PayrollDataSet.dsEmpLeaveLedger.BudgetComparisonDataTable();
double nTotalA = 0.0;
double nTotalB = 0.0;
foreach (Costcenter cc in oCrgs1)
{
double ctcA = 0.0;
double ctcB = 0.0;
double basicA = 0.0;
double basicB = 0.0;
double gCashA = 0.0;
double gCashB = 0.0;
double baseAmountA = 0.0;
double baseAmountB = 0.0;
List<BudgetMonthlyCC> ccs1 = budCCs1.FindAll(delegate(BudgetMonthlyCC bcc1) { return bcc1.CCID == cc.ID; });
foreach (BudgetMonthlyCC mcc in ccs1)
{
ctcA += GetCCAmountCC(mcc, _BudgetProcessMonthlieDetails1, EnumBudgetCode.CTC);
basicA += GetCCAmountCC(mcc, _BudgetProcessMonthlieDetails1, EnumBudgetCode.Basic_Salary);
gCashA += GetCCAmountCC(mcc, _BudgetProcessMonthlieDetails1, EnumBudgetCode.Guranted_Cash);
baseAmountA += CalculateBaseAmountCC(mcc,_BudgetProcessMonthlieDetails1, mcc.EmployeeID);
}
List<BudgetMonthlyCC> ccs2 = budCCs2.FindAll(delegate(BudgetMonthlyCC bcc1) { return bcc1.CCID == cc.ID; });
foreach (BudgetMonthlyCC mcc in ccs2)
{
ctcB += GetCCAmountCC(mcc, _BudgetProcessMonthlieDetails2, EnumBudgetCode.CTC);
basicB += GetCCAmountCC(mcc, _BudgetProcessMonthlieDetails2, EnumBudgetCode.Basic_Salary);
gCashB += GetCCAmountCC(mcc, _BudgetProcessMonthlieDetails2, EnumBudgetCode.Guranted_Cash);
baseAmountB += CalculateBaseAmountCC(mcc,_BudgetProcessMonthlieDetails2, mcc.EmployeeID);
}
double bSalary = 0;
double gCash = 0;
double yBase = 0;
double cTC = 0;
if (basicA == 0)
{
bSalary = 0;
}
else
{
bSalary = Math.Round(((basicB - basicA) * 100) / basicA, 2);
}
if (gCashA == 0)
{
gCash = 0;
}
else
{
gCash = Math.Round(((gCashB - gCashA) * 100) / gCashA, 2);
}
if (baseAmountA == 0)
{
yBase = 0;
}
else
{
yBase = Math.Round(((baseAmountB - baseAmountA) * 100) / baseAmountA, 2);
}
if (ctcA == 0)
{
cTC = 100;
}
else
{
cTC = Math.Round(((ctcB - ctcA) * 100) / ctcA, 2);
}
//Math.Round(((basicB - basicA) * 100) / basicA, 2)
//Math.Round(((gCashB - gCashA) * 100) / gCashA, 2)
//Math.Round(((baseAmountB - baseAmountA) * 100) / baseAmountA, 2)
//Math.Round(((ctcB - ctcA) * 100) / ctcA, 2)
if (ctcA == 0 && ctcB == 0)
continue;
else
oBody.Rows.Add(cc.Code, cc.Name, GlobalFunctions.TakaFormat(bSalary) + "%", GlobalFunctions.TakaFormat(gCash) + "%", GlobalFunctions.TakaFormat(yBase) + "%", GlobalFunctions.TakaFormat(Math.Round(ctcA, 2)), GlobalFunctions.TakaFormat(Math.Round(ctcB, 2)), GlobalFunctions.TakaFormat(cTC) + "%", (ccs1.Count / nMonth).ToString());
nTotalA += ctcA;
nTotalB += ctcB;
}
foreach (DataRow dr in oBody.Rows)
{
dr["DataColumn2"] = GlobalFunctions.TakaFormat(Math.Round(nTotalA, 2));
dr["DataColumn"] = GlobalFunctions.TakaFormat(Math.Round(nTotalB, 2));
}
string embeddedResource = "Payroll.Report.RDLC.BudgetComparison.rdlc";
string caption = "Forecasting Comparison Report";
dataSource = new List<ReportDataSource>();
dataSource.Add(new ReportDataSource("dsEmpLeaveLedger_BudgetComparison", oBody));
Cursor.Current = Cursors.Default;
List<ReportParameter> parameters = new List<ReportParameter>();
ReportParameter parameter = new ReportParameter("Header", "Budget Comparison Report Between " + comboBox1.Text + " and " + comboBox2.Text);
parameters.Add(parameter);
//parameter = new ReportParameter("FilterCriteria", SearchCriteria);
//parameters.Add(parameter);
DataSet dSet = new DataSet();
oBody.TableName = "dsEmpLeaveLedger_BudgetComparison";
dSet.Tables.Add(oBody);
try
{
fReportViewer fViewer = new fReportViewer();
//fViewer.PreviewReport(dataSource, embeddedResource, caption);
fViewer.CommonReportView(null, dSet, "Payroll.Report.RDLC.BudgetComparison.rdlc", parameters);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
private double GetCCAmount(BudgetMonthlyCC mcc,List<BudgetProcessMonthlyDetail> details,EnumBudgetCode budCode)
{
double amount = 0.0;
BudgetProcessMonthlyDetail oCA = details.Find(delegate(BudgetProcessMonthlyDetail item1) { return mcc.EmployeeID == item1.EmployeeID && item1.BudgetCode == budCode; });
if (oCA != null)
amount = oCA.Calculatedamount;
return amount;
}
private double GetCCAmountCC(BudgetMonthlyCC mcc, List<BudgetProcessMonthlyDetail> details, EnumBudgetCode budCode)
{
double amount = 0.0;
BudgetProcessMonthlyDetail oCA = details.Find(delegate(BudgetProcessMonthlyDetail item1) { return mcc.EmployeeID == item1.EmployeeID && item1.BudgetCode == budCode && item1.BudgetProcessMonthlyID == mcc.BudgetProcessMonthlyID; });
if (oCA != null)
amount = oCA.Calculatedamount;
return amount;
}
private void BudgetComparison39()
{
int nMonth = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("m", Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfMonth(_BudgetMasters[comboBox1.SelectedIndex].FromDate), Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(_BudgetMasters[comboBox1.SelectedIndex].ToDate)) + 1;
_BudgetProcessMonthlieDetails1 = new ObjectsTemplate<BudgetProcessMonthlyDetail>();
_BudgetProcessMonthlieDetails2 = new ObjectsTemplate<BudgetProcessMonthlyDetail>();
_BudgetProcessMonthlieDetails3 = new ObjectsTemplate<BudgetProcessMonthlyDetail>();
Cursor.Current = Cursors.WaitCursor;
List<ReportDataSource> dataSource = new List<ReportDataSource>();
ObjectsTemplate<Costcenter> oCrgs1 = new ObjectsTemplate<Costcenter>();
oCrgs1 = Costcenter.Get();
Payroll.Service.BudgetProcessMonthlyService ps = new Payroll.Service.BudgetProcessMonthlyService();
_BudgetProcessMonthlieDetails1 = BudgetProcessMonthlyDetail.Get(Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfMonth(_BudgetMasters[cmbBud3.SelectedIndex].FromDate), Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(_BudgetMasters[cmbBud3.SelectedIndex].ToDate), _BudgetMasters[cmbBud3.SelectedIndex].ID.Integer);
ObjectsTemplate<BudgetMonthlyCC> budCCs1 = ps.GetBudgetMonthlyCCs(_BudgetMasters[cmbBud3.SelectedIndex].ID.Integer, _BudgetMasters[cmbBud3.SelectedIndex].FromDate, _BudgetMasters[cmbBud3.SelectedIndex].ToDate);
_BudgetProcessMonthlieDetails2 = BudgetProcessMonthlyDetail.Get(Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfMonth(_BudgetMasters[cmbBud9.SelectedIndex].FromDate), Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(_BudgetMasters[cmbBud9.SelectedIndex].ToDate), _BudgetMasters[cmbBud9.SelectedIndex].ID.Integer);
ObjectsTemplate<BudgetMonthlyCC> budCCs2 = ps.GetBudgetMonthlyCCs(_BudgetMasters[cmbBud9.SelectedIndex].ID.Integer, _BudgetMasters[cmbBud9.SelectedIndex].FromDate, _BudgetMasters[cmbBud9.SelectedIndex].ToDate);
_BudgetProcessMonthlieDetails3 = BudgetProcessMonthlyDetail.Get(Ease.CoreV35.Utility.Global.DateFunctions.FirstDateOfMonth(_BudgetMasters[cmbBud39.SelectedIndex].FromDate), Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(_BudgetMasters[cmbBud39.SelectedIndex].ToDate), _BudgetMasters[cmbBud39.SelectedIndex].ID.Integer);
ObjectsTemplate<BudgetMonthlyCC> budCCs3 = ps.GetBudgetMonthlyCCs(_BudgetMasters[cmbBud39.SelectedIndex].ID.Integer, _BudgetMasters[cmbBud39.SelectedIndex].FromDate, _BudgetMasters[cmbBud39.SelectedIndex].ToDate);
if (_BudgetProcessMonthlieDetails1.Count == 0)
{
MessageBox.Show("No data found", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
DataTable oBody = new Payroll.Report.PayrollDataSet.dsEmpLeaveLedger.BudgetComparisonDataTable();
foreach (Costcenter cc in oCrgs1)
{
double ctcA = 0.0;
double ctcB = 0.0;
double ctcC = 0.0;
double basicA = 0.0;
double basicB = 0.0;
double basicC = 0.0;
double gCashA = 0.0;
double gCashB = 0.0;
double gCashC = 0.0;
double baseAmountA = 0.0;
double baseAmountB = 0.0;
double baseAmountC = 0.0;
double ctcTotal = 0.0;
double basicTotal = 0.0;
double cashTotal = 0.0;
double baseTotal = 0.0;
List<BudgetMonthlyCC> ccs1 = budCCs1.FindAll(delegate(BudgetMonthlyCC bcc1) { return bcc1.CCID == cc.ID; });
foreach (BudgetMonthlyCC mcc in ccs1)
{
ctcA += (GetCCAmount(mcc, _BudgetProcessMonthlieDetails1, EnumBudgetCode.CTC)/12)*3;
basicA += (GetCCAmount(mcc, _BudgetProcessMonthlieDetails1, EnumBudgetCode.Basic_Salary) / 12) * 3;
gCashA += (GetCCAmount(mcc, _BudgetProcessMonthlieDetails1, EnumBudgetCode.Guranted_Cash) / 12) * 3;
baseAmountA += (CalculateBaseAmount(_BudgetProcessMonthlieDetails1, mcc.EmployeeID)/12)*3;
}
List<BudgetMonthlyCC> ccs2 = budCCs2.FindAll(delegate(BudgetMonthlyCC bcc1) { return bcc1.CCID == cc.ID; });
foreach (BudgetMonthlyCC mcc in ccs2)
{
ctcB += (GetCCAmount(mcc, _BudgetProcessMonthlieDetails2, EnumBudgetCode.CTC) / 12) * 9;
basicB += (GetCCAmount(mcc, _BudgetProcessMonthlieDetails2, EnumBudgetCode.Basic_Salary)/ 12) * 9;
gCashB += (GetCCAmount(mcc, _BudgetProcessMonthlieDetails2, EnumBudgetCode.Guranted_Cash)/ 12) * 9;
baseAmountB += (CalculateBaseAmount(_BudgetProcessMonthlieDetails2, mcc.EmployeeID)/ 12) * 9;
}
List<BudgetMonthlyCC> ccs3 = budCCs3.FindAll(delegate(BudgetMonthlyCC bcc1) { return bcc1.CCID == cc.ID; });
foreach (BudgetMonthlyCC mcc in ccs3)
{
ctcC += GetCCAmount(mcc, _BudgetProcessMonthlieDetails3, EnumBudgetCode.CTC);
basicC += GetCCAmount(mcc, _BudgetProcessMonthlieDetails3, EnumBudgetCode.Basic_Salary);
gCashC += GetCCAmount(mcc, _BudgetProcessMonthlieDetails3, EnumBudgetCode.Guranted_Cash);
baseAmountC += CalculateBaseAmount(_BudgetProcessMonthlieDetails3, mcc.EmployeeID);
}
ctcTotal = ctcA + ctcB;
basicTotal = basicA + basicB;
cashTotal = gCashA + gCashB;
baseTotal = baseAmountA + baseAmountB;
double bSalary = 0;
double gCash = 0;
double yBase = 0;
double cTC = 0;
if (basicC == 0)
{
bSalary = 0;
}
else
{
bSalary = Math.Round(((basicTotal - basicC) * 100) / basicC, 2);
}
if (gCashC == 0)
{
gCash = 0;
}
else
{
gCash = Math.Round(((cashTotal - gCashC) * 100) / gCashC, 2);
}
if (baseAmountC == 0)
{
yBase = 0;
}
else
{
yBase = Math.Round(((baseTotal - baseAmountC) * 100) / baseAmountC, 2);
}
if (ctcC == 0)
{
cTC = 0;
}
else
{
cTC = Math.Round(((ctcTotal - ctcC) * 100) / ctcC, 2);
}
//Math.Round(((basicTotal - basicC) * 100) / basicC, 2)
//Math.Round(((cashTotal - gCashC) * 100) / gCashC, 2)
//Math.Round(((baseTotal - baseAmountC) * 100) / baseAmountC, 2)
//Math.Round(((ctcTotal - ctcC) * 100) / ctcC, 2)
oBody.Rows.Add(cc.Code, cc.Name, GlobalFunctions.TakaFormat(bSalary) + "%", GlobalFunctions.TakaFormat(gCash) + "%", GlobalFunctions.TakaFormat(yBase) + "%", GlobalFunctions.TakaFormat(Math.Round(ctcC, 2)), GlobalFunctions.TakaFormat(Math.Round(ctcTotal, 2)), GlobalFunctions.TakaFormat(cTC) + "%", (ccs1.Count / nMonth).ToString());
}
string embeddedResource = "Payroll.Report.RDLC.BudgetComparison.rdlc";
string caption = "Forecasting Comparison Report";
dataSource = new List<ReportDataSource>();
dataSource.Add(new ReportDataSource("dsEmpLeaveLedger_BudgetComparison", oBody));
Cursor.Current = Cursors.Default;
List<ReportParameter> parameters = new List<ReportParameter>();
ReportParameter parameter = new ReportParameter("Header", "Forecasting Comparison Report Between " + comboBox1.Text + " and " + comboBox2.Text);
parameters.Add(parameter);
//parameter = new ReportParameter("FilterCriteria", SearchCriteria);
//parameters.Add(parameter);
DataSet dSet = new DataSet();
oBody.TableName = "dsEmpLeaveLedger_BudgetComparison";
dSet.Tables.Add(oBody);
try
{
fReportViewer fViewer = new fReportViewer();
//fViewer.PreviewReport(dataSource, embeddedResource, caption);
fViewer.CommonReportView(null, dSet, "Payroll.Report.RDLC.BudgetComparison.rdlc", parameters);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
private void lsvBudget_Click(object sender, EventArgs e)
{
if (lsvBudget.SelectedItems.Count > 0)
{
if (lsvBudget.SelectedItems[0].Text == "Employee Wise Forecasting Report")
{
panel1.Show();
panel4.Hide();
panel5.Hide();
}
else
{
panel1.Hide();
panel4.Show();
panel5.Hide();
}
//else if (lsvBudget.SelectedItems[0].Index == 1 || lsvBudget.SelectedItems[0].Index == 4)
//{
// panel1.Hide();
// panel4.Hide();
// panel5.Show();
//}
}
}
private double CalculateBaseAmount(List<BudgetProcessMonthlyDetail> details,ID empID)
{
double nAmount = 0.0;
foreach (GrossDefination gd in grossDefinations)
{
switch (gd.SalaryComponentType)
{
case EnumSalaryComponent.Basic:
BudgetProcessMonthlyDetail oBasic = details.Find(delegate(BudgetProcessMonthlyDetail item1) { return empID == item1.EmployeeID && item1.Name == "Basic Salary"; });
if (oBasic != null)
nAmount += oBasic.Calculatedamount;
break;
case EnumSalaryComponent.Allowance:
case EnumSalaryComponent.Bonus:
BudgetProcessMonthlyDetail oAA = details.Find(delegate(BudgetProcessMonthlyDetail item1) { return empID == item1.EmployeeID && item1.OriginID == gd.ComponentID; });
if (oAA != null)
nAmount += oAA.Calculatedamount;
break;
default:
break;
}
}
return nAmount;
}
private double CalculateBaseAmountCC(BudgetMonthlyCC mcc, List<BudgetProcessMonthlyDetail> details, ID empID)
{
double nAmount = 0.0;
foreach (GrossDefination gd in grossDefinations)
{
switch (gd.SalaryComponentType)
{
case EnumSalaryComponent.Basic:
BudgetProcessMonthlyDetail oBasic = details.Find(delegate(BudgetProcessMonthlyDetail item1) { return empID == item1.EmployeeID && item1.Name == "Basic Salary" && mcc.BudgetProcessMonthlyID==item1.BudgetProcessMonthlyID; });
if (oBasic != null)
nAmount += oBasic.Calculatedamount;
break;
case EnumSalaryComponent.Allowance:
case EnumSalaryComponent.Bonus:
BudgetProcessMonthlyDetail oAA = details.Find(delegate(BudgetProcessMonthlyDetail item1) { return empID == item1.EmployeeID && item1.OriginID == gd.ComponentID && mcc.BudgetProcessMonthlyID == item1.BudgetProcessMonthlyID; });
if (oAA != null)
nAmount += oAA.Calculatedamount;
break;
default:
break;
}
}
return nAmount;
}
private void cmbBudget_SelectedIndexChanged(object sender, EventArgs e)
{
dtpFromDate.Value = _BudgetMasters[cmbBudget.SelectedIndex].FromDate;
dtpToDate.Value = _BudgetMasters[cmbBudget.SelectedIndex].ToDate;
}
private void lsvBudget_ColumnClick(object sender, ColumnClickEventArgs e)
{
//this.Cursor = Cursors.WaitCursor;
//System.Windows.Forms.SortOrder order = System.Windows.Forms.SortOrder.Ascending;
//if (order == lsvBudget.Sorting)
// order = System.Windows.Forms.SortOrder.Descending;
//else
// order = System.Windows.Forms.SortOrder.Ascending;
//lsvBudget.ListViewItemSorter = new Global.ItemSorter(e.Column, order);
//lsvBudget.Sorting = order;
//this.Cursor = Cursors.Default;
}
}
}