using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using Payroll.BO; using Ease.CoreV35; using Ease.Core.Model; using Ease.Core.Utility; using System.Windows.Forms; using HRM.BO; using HRM.DA; using System.IO; using Microsoft.Reporting.NETCore; using Payroll.Service; using static HRM.Report.PayrollDataSet.dsBonusDataSet; using static HRM.Report.PayrollDataSet.PayrollDataSet; using static NPOI.POIFS.Crypt.Dsig.SignatureInfo; namespace HRM.Report { public class rptBonus { public byte[] BonusPaySlip(int nBonusID, DateTime dBonusMonth, string sEmpID, int payrollTypeId, string reportType,bool isForESS) { List oBranches = new List(); oBranches = new BranchService().Get(EnumStatus.Active, payrollTypeId); List oBanks = new BankService().Get(EnumStatus.Active, payrollTypeId); string bonusName = ""; int count = 1; DataRow oDR = null; DataSet oBonusPaySlip = null; List oBProcess = new List(); DataTable basicInfo = new HRM.Report.PayrollDataSet.PayrollDataSet.PayslipBasicInfoDataTable(); if (isForESS) { oBProcess = new BonusProcessService().GetProcess(nBonusID,dBonusMonth, payrollTypeId); foreach (BonusProcess item in oBProcess) { if (!item.IsApprove) { throw new Exception("Bonus is not approved yet."); } } } oBonusPaySlip = new BonusProcessService().GetBonusPaySlip(nBonusID, GlobalFunctions.FirstDateOfMonth(dBonusMonth), sEmpID, payrollTypeId); PayrollDataSet.PayrollDataSet.BonusPaySlipDataTable dBonusPaySlipData = new 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["Gross"] = oDRow["GROSSSALARY"]; 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.ToString() == oDRow["branchid"].ToString(); }); Bank oBank = oBranch != null ? oBanks.Find(delegate (Bank dr) { return dr.ID.ToString() == oBranch.BankID.ToString(); }) : null ; if (oBranch != null) { sb.Append(Environment.NewLine); sb.Append(oBank.Name + " " + oBranch.Name); } oDR["PAYMENTMODE"] = sb.ToString(); oDR["AC"] = oDRow["accountno"].ToString(); //oDR["SLNo"] = count; dBonusPaySlipData.Rows.Add(oDR); count++; } if (oBonusPaySlip.Tables[0].Rows.Count > 0) { bonusName=oBonusPaySlip.Tables[0].Rows[0]["BonusName"].ToString(); } ReportProcessor reportProcessor = new ReportProcessor(); return reportProcessor.ShowDlgForBonusPaySlip(null, dBonusPaySlipData, payrollTypeId,bonusName, reportType); } public byte[] BonusBankAdvice(int nBonusID, DateTime dBonusMonth, string sEmpID, int payrollTypeId, string reportType) { int count = 1; DataRow oDR = null; DataSet oBonusBankAdvice = null; oBonusBankAdvice = new BonusProcessService().GetBonusBankAdvice(nBonusID, GlobalFunctions.LastDateOfMonth(dBonusMonth), sEmpID, payrollTypeId); PayrollDataSet.dsCompany.BonusBankAdviceDataTable dBonusBankData = new PayrollDataSet.dsCompany.BonusBankAdviceDataTable(); foreach (DataRow oDRow in oBonusBankAdvice.Tables[0].Rows) { oDR = dBonusBankData.NewRow(); oDR["EmpNo"] = oDRow["EMPLOYEENO"]; oDR["Name"] = oDRow["NAME"]; //oDR["BonusAmount"] = Math.Round(Convert.ToDouble(oDRow["BonusAmount"])); oDR["BonusAmount"] = GlobalFunctions.TakaFormat(Convert.ToDouble(oDRow["BonusAmount"])); oDR["AccountNo"] = oDRow["ACCOUNTNO"]; oDR["EmailAddress"] = oDRow["EMAILADDRESS"]; oDR["BonusMonth"] = dBonusMonth; oDR["SLNo"] = count; dBonusBankData.Rows.Add(oDR); count++; } ReportProcessor reportProcessor = new ReportProcessor(); string rdlcName = "BonusBankAdvice.rdlc"; return reportProcessor.ShowDlgForBankRegister(null, dBonusBankData, payrollTypeId, reportType, rdlcName); } public byte[] BonusRegister(int nBonusID, DateTime dBonusMonth, string sEmpID, int payrollTypeId, string reportType) { Bonus oBonus = new BonusService().Get(nBonusID); int count = 1; DataRow oDR = null; DataSet oBonusRegister = null; oBonusRegister = new BonusProcessService().GetBonusRegister(nBonusID, GlobalFunctions.FirstDateOfMonth(dBonusMonth), sEmpID, payrollTypeId); PayrollDataSet.PayrollDataSet.BonusRegisterDataTable dBonusRegData = new 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["BonusName"] = oBonus.Name; oDR["ConfirmDate"] = oDRow["DATEOFCONFIRMATION"]; //oDR["NetBonus"]=oDRow[""]; oDR["SLNo"] = count; int serlen = Convert.ToInt32(oDRow["ServiceLength"].ToString()) + 1; oDR["ServiceLength"] = serlen;// oDRow["ServiceLength"]; oDR["AccountNo"] = oDRow["AccountNo"]; if (serlen >= 25) { oDR["Percent"] = "200%"; } else if (serlen >= 20) { oDR["Percent"] = "150%"; } else if (serlen >= 15) { oDR["Percent"] = "100%"; } else if (serlen >= 10) { oDR["Percent"] = "50%"; } else if (serlen > 5) { oDR["Percent"] = "30%"; } dBonusRegData.Rows.Add(oDR); count++; } string rdlcName = "BonusRegister.rdlc"; ReportProcessor reportProcessor = new ReportProcessor(); return reportProcessor.ShowDlgForBonusRegister(null, dBonusRegData, payrollTypeId, reportType, rdlcName); } #region Production Bonus public byte[] MonthlyProdBonus(DateTime dBonusMonth, int payrollTypeId, string reportType) { int count = 1; DataRow oDR = null; DataSet oProdBonusProcessEmp = new ProdBonusProcessService().GetMontlyProdBonus(dBonusMonth); PayrollDataSet.PayrollDataSet.dtMonthlyProdBonusDataTable dTable = new PayrollDataSet.PayrollDataSet.dtMonthlyProdBonusDataTable(); if (oProdBonusProcessEmp.Tables[0].Rows.Count > 0) { GlobalFunctions.bDataFound = true; } //else //{ // throw new Exception(); //} 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 = "HRM.Report.RDLC.rptMontlyProdBonus.rdlc"; string RDLCName = "rptMontlyProdBonus.rdlc"; List _reportParameters = new List(); ReportParameter rParam = new ReportParameter("Month", dBonusMonth.ToString("MMM yyyy")); _reportParameters.Add(rParam); //form.CommonReportViewer(null, RDLC, dSet, _reportParameters, true); ReportProcessor reportProcessor = new ReportProcessor(); return reportProcessor.CommonReportViewForReports(null, dSet, null, RDLCName, _reportParameters, true, payrollTypeId, reportType); //CommonReportView(ReportItem item, string rdlcName, DataSet dSet, DataSet dSubReportDataSet, List PReportParameters, bool isBasicParametersNeeded, int payrollTypeId, string reportType = "PDF") } public byte[] EmpDesignWiseProdBonus(DateTime dBonusMonth, int payrollTypeId, string reportType) { int count = 1; DataRow oDR = null; DataSet oProdBonus = new ProdBonusProcessService().EmpDesignWiseProdBonus(dBonusMonth); if (oProdBonus.Tables[0].Rows.Count > 0) { GlobalFunctions.bDataFound = true; } //else //{ // throw new Exception(); //} PayrollDataSet.PayrollDataSet.dtEmpDesWiseProdBonusDataTable dTable = new PayrollDataSet.PayrollDataSet.dtEmpDesWiseProdBonusDataTable(); foreach (DataRow oDRow in oProdBonus.Tables[0].Rows) { //if(Convert.ToInt64(oDRow["EMPLOYEENO"]) == 43030) //{ //} oDR = dTable.NewRow(); oDR["EMPLOYEENO"] = oDRow["EMPLOYEENO"]; oDR["Name"] = oDRow["NAME"]; oDR["Designation"] = oDRow["Designation"]; oDR["Department"] = oDRow["Department"]; oDR["DepartmentID"] = oDRow["DepartmentID"]; 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["BonusHour"] = Convert.ToDouble(oDRow["BonusHour"]).ToString("0.00"); oDR["DesignNo"] = oDRow["DesignNo"]; oDR["StartDate"] = Convert.ToDateTime(oDRow["StartDate"]).ToString("dd MMM yyyy"); oDR["EndDate"] = Convert.ToDateTime(oDRow["EndDate"]).ToString("dd MMM yyyy"); dTable.Rows.Add(oDR); count++; } DataSet dSet = new DataSet(); dTable.TableName = "PayrollDataSet_dtEmpDesWiseProdBonus"; dSet.Tables.Add(dTable); //string RDLC = "Payroll.Report.RDLC.rptEmpDesignWiseProdBonus.rdlc"; string RDLC = "rptEmpDesignWiseProdBonus.rdlc"; List _reportParameters = new List(); ReportParameter rParam = new ReportParameter("Month", dBonusMonth.ToString("MMM yyyy")); _reportParameters.Add(rParam); ReportProcessor reportProcessor = new ReportProcessor(); return reportProcessor.CommonReportViewForReports(null, dSet, null, RDLC, _reportParameters, true, payrollTypeId, reportType); //form.CommonReportViewer(null, RDLC, dSet, _reportParameters, true); } public byte[] ProdBonusDetail(int designId, DateTime dBonusMonth, int payrollTypeId, string reportType) { int count = 1; DataRow oDR = null; DataSet oProdBonusDetail = new ProdBonusProcessService().GetProdBonusDetail(designId); if (oProdBonusDetail.Tables[0].Rows.Count > 0) { GlobalFunctions.bDataFound = true; } PayrollDataSet.PayrollDataSet.dtProdBonusDetailDataTable dTable = new 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"] = 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"); dTable.Rows.Add(oDR); count++; } DataSet dSet = new DataSet(); dTable.TableName = "PayrollDataSet_dtProdBonusDetail"; dSet.Tables.Add(dTable); //string RDLC = "Payroll.Report.RDLC.rptProdBonusDetail.rdlc"; string RDLC = "rptProdBonusDetail.rdlc"; ReportParameter rParam; List _reportParameters = new List(); rParam = new ReportParameter("DesignNo", new ProductionBonusSetupService().Get(designId).DesignNo); _reportParameters.Add(rParam); ReportProcessor reportProcessor = new ReportProcessor(); return reportProcessor.CommonReportViewForReports(null, dSet, null, RDLC, _reportParameters, true, payrollTypeId, reportType); } public byte[] DesignWiseProdBonusAttendance(int designId, DateTime dBonusMonth, int payrollTypeId, string reportType) { //fReportViewer form = new fReportViewer(); int count = 1; DataRow oDR = null; List oShifts = new ShiftService().GetAllShift(); Shift oShift = null; List prodAttn = new ProdBonusAttnService().GetBySetupID(designId); string empIds = string.Empty; empIds = prodAttn.Select(x => x.EmployeeID).Distinct().Aggregate(new StringBuilder(), (sb, empid) => sb.Append(empid + ","), sb => sb.ToString().Trim(',')); ProductionBonusSetup design = new ProductionBonusSetupService().Get(designId); List oDailyAttnProsess = new DailyAttnProcessService().Get(empIds, design.FromDate.Date, design.ToDate.Date); //List oDailyAttnProsess = DailyAttnProcess.Get(empIds,GlobalFunctions.FirstDateOfMonth(design.SalaryMonth.AddMonths(-1)), GlobalFunctions.LastDateOfMonth(design.SalaryMonth)); List emps = new EmployeeService().GetByEmpIDs(empIds); List attnEmp = new List(); PayrollDataSet.PayrollDataSet.dtProdAttendanceDataTable dTable = new PayrollDataSet.PayrollDataSet.dtProdAttendanceDataTable(); foreach (ProdBonusAttn item in prodAttn) { Employee tEmp = emps.FirstOrDefault(o => o.ID == item.EmployeeID); if (!attnEmp.Any(o => o.ID == tEmp.ID)) { attnEmp.Add(tEmp); } } if (prodAttn != null && prodAttn.Count > 0) { foreach (Employee item in attnEmp) { List tempAttn = prodAttn.Where(o => o.EmployeeID == item.ID).ToList();//.Sum(x => x.BonusHour); double hour = 0; foreach (ProdBonusAttn tAtt in tempAttn) { DailyAttnProcess dailyAtt = oDailyAttnProsess.FirstOrDefault(o => o.AttnDate.Date == tAtt.InTime.Date && o.EmployeeID == item.ID && (o.AttenType == EnumAttendanceType.Present || o.AttenType == EnumAttendanceType.HalfDay || o.AttenType == EnumAttendanceType.Delay || o.AttenType == EnumAttendanceType.Early || o.AttenType == EnumAttendanceType.Late || o.AttenType == EnumAttendanceType.OutSideDuty)); double wh = 0; if (dailyAtt != null) { if (dailyAtt.OutTime != DateTime.MinValue && dailyAtt.InTime != DateTime.MinValue) { oShift = oShifts.FirstOrDefault(x => x.ID == dailyAtt.ShiftID); if (design.FromDate.Date == dailyAtt.AttnDate.Date) dailyAtt.InTime = design.FromDate > dailyAtt.InTime ? design.FromDate : dailyAtt.InTime; else if (design.ToDate.Date == dailyAtt.AttnDate.Date) dailyAtt.OutTime = design.ToDate < dailyAtt.OutTime ? design.ToDate : dailyAtt.OutTime; else if (oShift != null && dailyAtt.InTime.Value.TimeOfDay < oShift.InTime.TimeOfDay) dailyAtt.InTime = dailyAtt.InTime.Value.Date.AddHours(oShift.InTime.Hour).AddMinutes(oShift.InTime.Minute); TimeSpan ts = dailyAtt.OutTime.Value - dailyAtt.InTime.Value; if (ts.Minutes < 16 && ts.Hours < 5) wh = ts.Hours; else if (ts.Minutes < 16) wh = ts.Hours - 1; else if (ts.TotalHours < 5) wh = ts.TotalHours; else wh = ts.TotalHours - 1; // hour += ts.Hours < 0 ? 0 : ts.Hours; hour = wh < 0 ? 0 : wh; oDR = dTable.NewRow(); oDR["EMPLOYEENO"] = item.EmployeeNo; oDR["Name"] = item.Name; oDR["Date"] = dailyAtt.InTime.Value.Date.ToString("dd-MMM-yyyy"); oDR["WorkingHour"] = hour.ToString("0.00"); dTable.Rows.Add(oDR); count++; } } } } } if (dTable.Rows.Count > 0) { GlobalFunctions.bDataFound = true; } DataSet dSet = new DataSet(); dTable.TableName = "PayrollDataSet_dtProdAttendance"; dSet.Tables.Add(dTable); //string RDLC = "Payroll.Report.RDLC.rptProdBonusAttendance.rdlc"; string RDLC = "rptProdBonusAttendance.rdlc"; ReportParameter rParam; List _reportParameters = new List(); rParam = new ReportParameter("DesignNo", design.DesignNo); _reportParameters.Add(rParam); //form.CommonReportViewer(null, RDLC, dSet, _reportParameters, true); ReportProcessor reportProcessor = new ReportProcessor(); return reportProcessor.CommonReportViewForReports(null, dSet, null, RDLC, _reportParameters, true, payrollTypeId, reportType); } #endregion Production Bonus public byte[] PRBBonusCalculation(int employeeID,DateTime prbYear) { DateTime lastDay = new DateTime(prbYear.Year, 12, 31); PayrollDataSet.dsBonusDataSet.PRBCalculationDataTable PRBCalculationDt = new PayrollDataSet.dsBonusDataSet.PRBCalculationDataTable(); DataRow oDR = null; PRBCalculation prbCalculation = new PRBCalculation(); List prbKpi = new List(); Employee employee = new Employee(); employee = new EmployeeService().Get(employeeID); prbCalculation = new PRBCalculationService().GetByEmployeeIDDecData(employeeID,prbYear); if (prbCalculation == null) throw new Exception("No Data found on this date "+ lastDay.ToString("MMM yyyy")); prbKpi = new PRBKpiService().GetKpiByPrbMonth(prbCalculation.EndDate); string employeeName = ""; string employeeNo = ""; string grade = ""; double totalPRBamount = 0; if (prbCalculation != null) { double? T1AcheiveTemp = 0; double? T1BonusAcheiveAmount = 0; double? T2AcheiveTemp = 0; double? T2BonusAcheiveAmount = 0; double? T3AcheiveTemp = 0; double? T3BonusAcheiveAmount = 0; double? T4AcheiveTemp = 0; double? T4BonusAcheiveAmount = 0; double? T5AcheiveTemp = 0; double? T5BonusAcheiveAmount = 0; double? T6AcheiveTemp = 0; double? T6BonusAcheiveAmount = 0; double? T7AcheiveTemp = 0; double? T7BonusAcheiveAmount = 0; double? T8AcheiveTemp = 0; double? T8BonusAcheiveAmount = 0; double? T9AcheiveTemp = 0; double? T9BonusAcheiveAmount = 0; double? T10BonusAcheiveAmount = 0; double? T10AcheiveTemp = 0; if (prbCalculation.TargetT1 > 0 && prbCalculation.AcheiveT1 > 0) { T1AcheiveTemp = prbCalculation.TargetT1 * (prbCalculation.AcheiveT1 / 100); T1BonusAcheiveAmount = (prbCalculation.BonusAmount * T1AcheiveTemp) / 100; oDR = PRBCalculationDt.NewRow(); oDR["Measure"] = prbKpi?.Where(x=>x.Serial.Trim() == "T1")?.FirstOrDefault().KpiName; oDR["BonusTarget"] = prbCalculation.TargetT1.ToString() + '%'; oDR["PayoutPerformance"] = prbCalculation.AcheiveT1.ToString() + '%'; double val = Convert.ToDouble(T1BonusAcheiveAmount); val = Math.Round(val, 2); oDR["Amount"] = val.ToString("N2"); PRBCalculationDt.Rows.Add(oDR); } if (prbCalculation.TargetT2 > 0 && prbCalculation.AcheiveT2 > 0) { T2AcheiveTemp = prbCalculation.TargetT2 * (prbCalculation.AcheiveT2 / 100); T2BonusAcheiveAmount = (prbCalculation.BonusAmount * T2AcheiveTemp) / 100; oDR = PRBCalculationDt.NewRow(); oDR["Measure"] = prbKpi?.Where(x => x.Serial.Trim() == "T2")?.FirstOrDefault().KpiName; oDR["BonusTarget"] = prbCalculation.TargetT2.ToString() + '%'; oDR["PayoutPerformance"] = prbCalculation.AcheiveT2.ToString() + '%'; double val = Convert.ToDouble(T2BonusAcheiveAmount); val = Math.Round(val, 2); oDR["Amount"] = val.ToString("N2"); PRBCalculationDt.Rows.Add(oDR); } if (prbCalculation.TargetT3 > 0 && prbCalculation.AcheiveT3 > 0) { T3AcheiveTemp = prbCalculation.TargetT3 * (prbCalculation.AcheiveT3 / 100); T3BonusAcheiveAmount = (prbCalculation.BonusAmount * T3AcheiveTemp) / 100; oDR = PRBCalculationDt.NewRow(); oDR["Measure"] = prbKpi?.Where(x => x.Serial.Trim() == "T3")?.FirstOrDefault().KpiName; oDR["BonusTarget"] = prbCalculation.TargetT3.ToString() + '%'; oDR["PayoutPerformance"] = prbCalculation.AcheiveT3.ToString() + '%'; double val = Convert.ToDouble(T3BonusAcheiveAmount); val = Math.Round(val, 2); oDR["Amount"] = val.ToString("N2"); PRBCalculationDt.Rows.Add(oDR); } if (prbCalculation.TargetT4 > 0 && prbCalculation.AcheiveT4 > 0) { T4AcheiveTemp = prbCalculation.TargetT4 * (prbCalculation.AcheiveT4 / 100); T4BonusAcheiveAmount = (prbCalculation.BonusAmount * T4AcheiveTemp) / 100; oDR = PRBCalculationDt.NewRow(); oDR["Measure"] = prbKpi?.Where(x => x.Serial.Trim() == "T4")?.FirstOrDefault().KpiName; oDR["BonusTarget"] = prbCalculation.TargetT4.ToString() + '%'; oDR["PayoutPerformance"] = prbCalculation.AcheiveT4.ToString() + '%'; double val = Convert.ToDouble(T4BonusAcheiveAmount); val = Math.Round(val, 2); oDR["Amount"] = val.ToString("N2"); PRBCalculationDt.Rows.Add(oDR); } if (prbCalculation.TargetT5 > 0 && prbCalculation.AcheiveT5 > 0) { T5AcheiveTemp = prbCalculation.TargetT5 * (prbCalculation.AcheiveT5 / 100); T5BonusAcheiveAmount = (prbCalculation.BonusAmount * T5AcheiveTemp) / 100; oDR = PRBCalculationDt.NewRow(); oDR["Measure"] = prbKpi?.Where(x => x.Serial.Trim() == "T5")?.FirstOrDefault().KpiName; oDR["BonusTarget"] = prbCalculation.TargetT5.ToString() + '%'; oDR["PayoutPerformance"] = prbCalculation.AcheiveT5.ToString() + '%'; double val = Convert.ToDouble(T5BonusAcheiveAmount); val = Math.Round(val, 2); oDR["Amount"] = val.ToString("N2"); PRBCalculationDt.Rows.Add(oDR); } if (prbCalculation.TargetT6 > 0 && prbCalculation.AcheiveT6 > 0) { T6AcheiveTemp = prbCalculation.TargetT6 * (prbCalculation.AcheiveT6 / 100); T6BonusAcheiveAmount = (prbCalculation.BonusAmount * T6AcheiveTemp) / 100; oDR = PRBCalculationDt.NewRow(); oDR["Measure"] = prbKpi?.Where(x => x.Serial.Trim() == "T6")?.FirstOrDefault().KpiName; oDR["BonusTarget"] = prbCalculation.TargetT6.ToString() + '%'; oDR["PayoutPerformance"] = prbCalculation.AcheiveT6.ToString() + '%'; double val = Convert.ToDouble(T6BonusAcheiveAmount); val = Math.Round(val, 2); oDR["Amount"] = val.ToString("N2"); PRBCalculationDt.Rows.Add(oDR); } if (prbCalculation.TargetT7 > 0 && prbCalculation.AcheiveT7 > 0) { T7AcheiveTemp = prbCalculation.TargetT7 * (prbCalculation.AcheiveT7 / 100); T7BonusAcheiveAmount = (prbCalculation.BonusAmount * T7AcheiveTemp) / 100; oDR = PRBCalculationDt.NewRow(); oDR["Measure"] = prbKpi?.Where(x => x.Serial.Trim() == "T7")?.FirstOrDefault().KpiName; oDR["BonusTarget"] = prbCalculation.TargetT7.ToString() + '%'; oDR["PayoutPerformance"] = prbCalculation.AcheiveT7.ToString() + '%'; double val = Convert.ToDouble(T7BonusAcheiveAmount); val = Math.Round(val, 2); oDR["Amount"] = val.ToString("N2"); PRBCalculationDt.Rows.Add(oDR); } if (prbCalculation.TargetT8 > 0 && prbCalculation.AcheiveT8 > 0) { T8AcheiveTemp = prbCalculation.TargetT8 * (prbCalculation.AcheiveT8 / 100); T8BonusAcheiveAmount = (prbCalculation.BonusAmount * T8AcheiveTemp) / 100; oDR = PRBCalculationDt.NewRow(); oDR["Measure"] = prbKpi?.Where(x => x.Serial.Trim() == "T8")?.FirstOrDefault().KpiName; oDR["BonusTarget"] = prbCalculation.TargetT8.ToString() + '%'; oDR["PayoutPerformance"] = prbCalculation.AcheiveT8.ToString() + '%'; double val = Convert.ToDouble(T8BonusAcheiveAmount); val = Math.Round(val, 2); oDR["Amount"] = val.ToString("N2"); PRBCalculationDt.Rows.Add(oDR); } if (prbCalculation.TargetT9 > 0 && prbCalculation.AcheiveT9 > 0) { T9AcheiveTemp = prbCalculation.TargetT8 * (prbCalculation.AcheiveT8 / 100); T9BonusAcheiveAmount = (prbCalculation.BonusAmount * T8AcheiveTemp) / 100; oDR = PRBCalculationDt.NewRow(); oDR["Measure"] = prbKpi?.Where(x => x.Serial.Trim() == "T9")?.FirstOrDefault().KpiName; oDR["BonusTarget"] = prbCalculation.TargetT8.ToString() + '%'; oDR["PayoutPerformance"] = prbCalculation.AcheiveT8.ToString() + '%'; double val = Convert.ToDouble(T8BonusAcheiveAmount); val = Math.Round(val, 2); oDR["Amount"] = val.ToString("N2"); PRBCalculationDt.Rows.Add(oDR); } if (prbCalculation.TargetT10 > 0 && prbCalculation.AcheiveT10 > 0) { T10AcheiveTemp = prbCalculation.TargetT10 * (prbCalculation.AcheiveT10 / 100); T10BonusAcheiveAmount = (prbCalculation.BonusAmount * T8AcheiveTemp) / 100; oDR = PRBCalculationDt.NewRow(); oDR["Measure"] = prbKpi?.Where(x => x.Serial.Trim() == "T10")?.FirstOrDefault().KpiName; oDR["BonusTarget"] = prbCalculation.TargetT10.ToString() + '%'; oDR["PayoutPerformance"] = prbCalculation.AcheiveT10.ToString() + '%'; double val = Convert.ToDouble(T8BonusAcheiveAmount); val = Math.Round(val, 2); oDR["Amount"] = val.ToString("N2"); PRBCalculationDt.Rows.Add(oDR); } double? totalAcheive = T1AcheiveTemp + T2AcheiveTemp + T3AcheiveTemp + T4AcheiveTemp + T5AcheiveTemp + T6AcheiveTemp + T7AcheiveTemp + T8AcheiveTemp + T9AcheiveTemp + T10AcheiveTemp; double? totalPRB = prbCalculation.BonusAmount * (totalAcheive / 100); double totalPRBAmount = Convert.ToDouble(totalPRB); totalPRBamount = Math.Round(totalPRBAmount, 2); } if (employee != null) { employeeName = employee.Name; employeeNo = employee.EmployeeNo; grade = employee.GradeName; } List authPersons = new AuthorizedPersonService().Get(); AuthorizedPerson authPersonHr = null; AuthorizedPerson authPersonCountryManager = null; string signaturePathHr = null; string signaturePathCountryManager = null; if (authPersons.Count > 0) { foreach (var item in authPersons) { var str = item.Designation.Replace(" ", ""); if (str.ToLower() == "countryhrmanager") { authPersonHr = item; signaturePathHr = Convert.ToBase64String(authPersonHr.Signature); } if (str.ToLower() == "countrymanager") { authPersonCountryManager = item; signaturePathCountryManager = Convert.ToBase64String(authPersonCountryManager.Signature); } } } ReportProcessor reportProcessor = new ReportProcessor(); string rdlcName = "PRBLetterSGS.rdlc"; ReportParameter rParam; List _reportParameters = new List(); string _PATH = string.Empty; rParam = new ReportParameter("ReportType", "PDF"); _reportParameters.Add(rParam); rParam = new ReportParameter("EmployeeName", employeeName); _reportParameters.Add(rParam); rParam = new ReportParameter("EmployeeNo", employeeNo); _reportParameters.Add(rParam); rParam = new ReportParameter("Grade", grade); _reportParameters.Add(rParam); rParam = new ReportParameter("Amount", totalPRBamount.ToString("N2")); _reportParameters.Add(rParam); rParam = new ReportParameter("signaturehr", signaturePathHr); _reportParameters.Add(rParam); rParam = new ReportParameter("signaturePathCountryManager", signaturePathCountryManager); _reportParameters.Add(rParam); rParam = new ReportParameter("authNameHr", authPersonHr != null ? authPersonHr.Name : null); _reportParameters.Add(rParam); rParam = new ReportParameter("authNameCountryManager", authPersonCountryManager != null ? authPersonCountryManager.Name : null); _reportParameters.Add(rParam); DataSet dSet = new DataSet(); dSet.Tables.Add(PRBCalculationDt); dSet.Tables[0].TableName = "dsCompany_PRBLetterSGS"; string RDLC = "PRBLetterSGS.rdlc"; return reportProcessor.CommonReportViewForReports(null, dSet, null, RDLC, _reportParameters, false, 1, "PDF"); } } } //namespace Payroll.Report //{ // public class rptBonus // { // private ReportSetup _selectedParameter; // public rptBonus() // { // } // public ReportSetup SelectedParameter // { // set // { // _selectedParameter = value; // } // } // 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; // DataSet oBonusBankAdvice = null; // oBonusBankAdvice = BonusProcess.GetBonusBankAdvice(nBonusID, GlobalFunctions.LastDateOfMonth(dBonusMonth), sEmpID); // PayrollDataSet.dsCompany.BonusBankAdviceDataTable dBonusBankData = new Payroll.Report.PayrollDataSet.dsCompany.BonusBankAdviceDataTable(); // foreach (DataRow oDRow in oBonusBankAdvice.Tables[0].Rows) // { // oDR = dBonusBankData.NewRow(); // oDR["EmpNo"] = oDRow["EMPLOYEENO"]; // oDR["Name"] = oDRow["NAME"]; // oDR["BonusAmount"] = oDRow["BonusAmount"]; // oDR["AccountNo"] = oDRow["ACCOUNTNO"]; // oDR["EmailAddress"] = oDRow["EMAILADDRESS"]; // oDR["BonusMonth"] = dBonusMonth; // oDR["CostCenter"] = oDRow["CostCenter"]; // oDR["SLNo"] = count; // dBonusBankData.Rows.Add(oDR); // count++; // } // form.ShowDlgForBankRegister(_selectedParameter.ReportItem, dBonusBankData); // } // public void BonusPaySlip() // { // fReportViewer form = new fReportViewer(); // List oBranches = new List(); // 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, _selectedParameter.Bonuses[0].ID.Integer); // } // 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 _reportParameters = new List(); // 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 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 _reportParameters = new List(); // 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 _reportParameters = new List(); // rParam = new ReportParameter("DesignNo", design.DesignNo); // _reportParameters.Add(rParam); // form.CommonReportViewer(null, RDLC, dSet, _reportParameters, true); // } // } //}