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 Microsoft.Reporting.WinForms; namespace Payroll.Report { public class PaySlip { DataSet dSet = new DataSet(); private ReportSetup _selectedParameter; ObjectsTemplate _oGratuityParams = null; private DateTime _dSalaryMonth = DateTime.MinValue; private DateTime _dMonthEndDate = DateTime.MinValue; DateTime _fiscalyearStart; DateTime _SalaryMonth; public PaySlip() { } public ReportSetup SelectedParameter { set { _selectedParameter = value; } } private DataRow GrossMerge(DataRow destination, DataRow source) { if (Convert.ToInt32(source["ItemGroup"]) == 3) { destination["Name"] = source["Name"]; destination["EMPLOYEENO"] = source["EMPLOYEENO"]; destination["Grade"] = source["Grade"]; destination["Designation"] = source["Designation"]; destination["Department"] = source["Department"]; destination["LName"] = source["LName"]; destination["JoiningDate"] = source["JoiningDate"]; destination["BName"] = source["BName"]; destination["REMARKS"] = source["REMARKS"]; destination["ActualBasic"] = source["ActualBasic"]; destination["TINNo"] = source["TINNo"]; if (source["PAYMENTMODE"].Equals(1)) { destination["PAYMENTMODE"] = "CashPayment"; } else if (source["PAYMENTMODE"].Equals(2)) { destination["PAYMENTMODE"] = "BankTransfer"; } else if (source["PAYMENTMODE"].Equals(3)) { destination["PAYMENTMODE"] = "Provision"; } destination["ACCOUNTNO"] = source["ACCOUNTNO"]; destination["SalaryMonth"] = Convert.ToDateTime(source["SalaryMonth"]).ToString("dd MMM yyyy"); destination["Description"] = ""; destination["ItemGroup"] = source["ITEMGROUP"]; destination["ItemCode"] = source["ITEMCode"]; destination["ItemID"] = source["ITEMID"]; _SalaryMonth = Convert.ToDateTime(source["SalaryMonth"]); if (_SalaryMonth.Month >= 1 && _SalaryMonth.Month < 7) { _fiscalyearStart = new DateTime(_SalaryMonth.Year - 1, 7, 1); destination["TaxMonth"] = _fiscalyearStart.ToString("MMM yyyy"); } else { _fiscalyearStart = new DateTime(_SalaryMonth.Year, 7, 1); destination["TaxMonth"] = _fiscalyearStart.ToString("MMM yyyy"); } //destination["TaxMonth"] = Payroll.BO.SystemInformation.CurrentSysInfo.TaxYearEndDate.AddMonths(1); // destination["TaxFiscalYearAmount"] = GlobalFunctions.Round(item.GetAmountOnRange(oEmp, _dFiscalYear, _SalaryMonth.AddMinutes(1), EnumSalaryGroup.Deductions, EnumSalaryItemCode.Inc_Tax_Deduction, (int)EnumSalaryItemCode.Inc_Tax_Deduction)); return destination; } else { destination["Name"] = source["Name"]; destination["EMPLOYEENO"] = source["EMPLOYEENO"]; destination["Grade"] = source["Grade"]; destination["Designation"] = source["Designation"]; destination["Department"] = source["Department"]; destination["LName"] = source["LName"]; destination["JoiningDate"] = source["JoiningDate"]; destination["BName"] = source["BName"]; destination["ActualBasic"] = source["ActualBasic"]; destination["TINNo"] = source["TINNo"]; destination["REMARKS"] = source["REMARKS"]; if (source["PAYMENTMODE"].Equals(1)) { destination["PAYMENTMODE"] = "CashPayment"; } else if (source["PAYMENTMODE"].Equals(2)) { destination["PAYMENTMODE"] = "BankTransfer"; } else if (source["PAYMENTMODE"].Equals(3)) { destination["PAYMENTMODE"] = "Provision"; } destination["ACCOUNTNO"] = source["ACCOUNTNO"]; destination["SalaryMonth"] = Convert.ToDateTime(source["SalaryMonth"]).ToString("dd MMM yyyy"); destination["Description"] = source["Description"]; destination["ItemGroup"] = source["ITEMGROUP"]; destination["ItemCode"] = source["ITEMCode"]; destination["ItemID"] = source["ITEMID"]; _SalaryMonth = Convert.ToDateTime(source["SalaryMonth"]); if (_SalaryMonth.Month >= 1 && _SalaryMonth.Month < 7) { _fiscalyearStart = new DateTime(_SalaryMonth.Year - 1, 7, 1); destination["TaxMonth"] = _fiscalyearStart.ToString("MMM yyyy"); } else { _fiscalyearStart = new DateTime(_SalaryMonth.Year, 7, 1); destination["TaxMonth"] = _fiscalyearStart.ToString("MMM yyyy"); } // destination["TaxFiscalYearAmount"] = GlobalFunctions.Round(item.GetAmountOnRange(oEmp, _dFiscalYear, _SalaryMonth.AddMinutes(1), EnumSalaryGroup.Deductions, EnumSalaryItemCode.Inc_Tax_Deduction, (int)EnumSalaryItemCode.Inc_Tax_Deduction)); return destination; } } private DataRow GrossMergeForOverAll(DataRow destination, DataRow source, int nTotalEmp, DateTime sMonth) { destination["TotalEmp"] = nTotalEmp; if (source["Description"].ToString().Contains("'")) { destination["Description"] = source["Description"].ToString().Replace("'", "\'"); } else if (source["Description"].ToString().Contains("/")) { destination["Description"] = source["Description"].ToString().Replace("/", "/'"); } else { destination["Description"] = source["Description"]; } destination["ItemGroup"] = source["ITEMGROUP"]; destination["ItemCode"] = source["ITEMCode"]; destination["ItemID"] = source["ITEMID"]; destination["Month"] = sMonth; return destination; } private DataRow GetItem(PayrollDataSet.PayrollDataSet.PayslipDataTable Source, string sEmpNo, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int ITemID) { foreach (DataRow odRow in Source.Rows) { if (Convert.ToString(odRow["EMPLOYEENO"]) == sEmpNo && Convert.ToInt32(odRow["ItemCode"]) == (int)itemCode && Convert.ToInt32(odRow["ItemID"]) == ITemID) { return odRow; } } return null; } private DataRow GetItem2(DataTable Source, string sEmpNo, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int ITemID,string sDescription) { foreach (DataRow odRow in Source.Rows) { if (Convert.ToString(odRow["EMPLOYEENO"]) == sEmpNo && Convert.ToInt32(odRow["ItemCode"]) == (int)itemCode && Convert.ToInt32(odRow["ItemID"]) == ITemID && odRow["Description"].ToString().Replace(" hour", "").Trim() == sDescription) { return odRow; } } return null; } private DataRow GetItemForOverAll(PayrollDataSet.PayrollDataSet.OverAllSummaryDataTable Source, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int ITemID) { foreach (DataRow odRow in Source.Rows) { if (Convert.ToInt32(odRow["ItemCode"]) == (int)itemCode && Convert.ToInt32(odRow["ItemID"]) == ITemID) { return odRow; } } return null; } private double ServiceYears(DateTime dt, Employee oEmp) { double n = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("d", oEmp.JoiningDate, dt); if (n >= 365) return n / 365; else return 0.0; } public double GetGratuityAmount(ObjectsTemplate oItems, Employee oEmp, DateTime salaryMonth) { double nAmout = 0.0; double nFracYear = 0.0; ESBDefinition item = ESBDefinition.Get(oItems, oEmp); double nServiceLength = ServiceYears(GlobalFunctions.LastDateOfMonth(salaryMonth), oEmp); if (item != null) { foreach (ESBSlab eslb in item.ESBSlabs) { nAmout = 0.0; if (eslb.ServiceYear <= nServiceLength) { string[] sFracMonth = nServiceLength.ToString().Split(new char[] { '.' }); nFracYear = 0; if (sFracMonth.Length > 1) nFracYear = GlobalFunctions.Round(Convert.ToDouble("." + sFracMonth[1])); if (nFracYear >= 0.5) { nServiceLength = Convert.ToDouble(sFracMonth[0]) + 1; } else { nServiceLength = Convert.ToDouble(sFracMonth[0]); } nAmout = oEmp.BasicSalary * eslb.CalculateNo * nServiceLength; } else { nAmout = 0; } } } return nAmout; } public double GetPFAmount(Employee oEmp, DateTime salaryMonth) { double nAmout = 0.0; DataSet ds = PFTransaction.GetPFBalance(oEmp.ID.Integer, GlobalFunctions.LastDateOfMonth(salaryMonth)); double nServiceLength = ServiceYears(GlobalFunctions.LastDateOfMonth(salaryMonth), oEmp); foreach (DataRow dr in ds.Tables[0].Rows) { if (Convert.ToInt16(dr["TranTP"]) == 1) { nAmout = Convert.ToDouble(dr["Amount"]); } //if (nServiceLength > 5) //{ // nAmout += Convert.ToDouble(dr["Amount"]); //} //else //{ // if (Convert.ToInt16(dr["TranTP"]) != 2) // { // nAmout += Convert.ToDouble(dr["Amount"]); // } //} } return nAmout; } //public void ShowReport() //{ // _oGratuityParams = ESBDefinition.Get(); // Employee oEmployee = null; // ObjectsTemplate oEmps = new ObjectsTemplate(); // oEmps = Employee.Get(); // ObjectsTemplate oLoanScheduls = new ObjectsTemplate(); // oLoanScheduls = LoanSchedule.Get(); // //ObjectsTemplate oLoanIssues = new ObjectsTemplate(); // //oLoanIssues = LoanIssue.GetE Get(); // fReportViewer form = new fReportViewer(); // DateTime salaryMonth = _selectedParameter.FromDate.Value; // string sEmpID = _selectedParameter.ReportItem.INSQL; // SalaryProcess oSaProcess = new SalaryProcess(); // //bool bIsProcess = SalaryMonthly.IsSalaryProcessed(SessionManager.CurrentEmployee.ID, _SalaryMonth); // DataSet oSalaryMonthlysGross = SalaryMonthly.GetEmpPaySlipGrossForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); // PayrollDataSet.PayrollDataSet.PayslipDataTable PayslipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.PayslipDataTable(); // //bool IsApproved = oSaProcess.GetBySMonth(GlobalFunctions.LastDateOfMonth(salaryMonth)); // foreach (DataRow odRow in oSalaryMonthlysGross.Tables[0].Rows) // { // DataRow oRow = this.GetItem(PayslipData, Convert.ToString(odRow["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(odRow["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]), Convert.ToInt32(odRow["ItemID"])); // if (oRow == null) // { // oRow = PayslipData.NewRow(); // oRow = this.GrossMerge(oRow, odRow); // PayslipData.Rows.Add(oRow); // } // if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Gross)) // oRow["Earning"] = odRow["CHANGEDAMOUNT"]; // else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Arrear)) // oRow["Arrear"] = odRow["CHANGEDAMOUNT"]; // else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.UnauthLeave)) // oRow["unAuthLeave"] = odRow["CHANGEDAMOUNT"]; // } // int nCount = 0; // DataSet oSalaryMonthlysDeduct = SalaryMonthly.GetEmpPaySlipDeductForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); // string employeeNo = ""; // DataRow[] odros = null; // if (oSalaryMonthlysDeduct.Tables[0].Rows.Count > 0) // { // employeeNo = oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); // odros = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); // } // //if(oSalaryMonthlysDeduct.Tables[0].Rows.Count>oSalaryMonthlysGross.Tables[0].Rows.Count) // //{ // // odros=new DataRow[oSalaryMonthlysDeduct.Tables[0].Rows.Count]; // //} // foreach (DataRow odRow in oSalaryMonthlysDeduct.Tables[0].Rows) // { // DataRow oRow = null; // if (employeeNo != odRow["EMPLOYEENO"].ToString()) // { // odros = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); // nCount = 0; // } // if (odros.Length <= nCount) // { // oRow = PayslipData.NewRow(); // oRow = this.GrossMerge(oRow, odRow); // PayslipData.Rows.Add(oRow); // } // else oRow = odros[nCount]; // //if (odros.Length <= nCount) continue; // //oRow = odros[nCount]; // oRow["DeducDescription"] = odRow["Description"]; // if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Deductions)) // oRow["DeducAmount"] = odRow["CHANGEDAMOUNT"]; // oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); // //GetGratuityAmount(_oGratuityParams, oEmployee); // // GetPFAmount(oEmployee); // //Gratuity // if (oEmployee != null) // { // if (_oGratuityParams.Count > 0 && _oGratuityParams != null) // { // oRow["Gratuity"] = GetGratuityAmount(_oGratuityParams, oEmployee); // } // else // { // oRow["Gratuity"] = 0; // } // oRow["PF"] = GetPFAmount(oEmployee); // } // #region Loan Issue // ////Personal Loan // //if ((Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Monthly_Installment) && ((Convert.ToInt32(odRow["ItemID"]) == 3))) // //{ // // loanAmounn = 0.0; // // actuInterest = 0.0; // // principleAmount = 0.0; // // interest = 0.0; // // balance = 0.0; // // sattelmentAmount = 0.0; // // LoanIssue oLIssue=LoanIssue.GetExistingLoan(ID.FromInteger(Convert.ToInt32(odRow["ItemID"])),oEmployee.ID); // // //LoanIssue oLIssue = oLoanIssues.Find(delegate(LoanIssue item1) { return oEmployee.ID == item1.EmployeeID && item1.LoanID == ID.FromInteger(Convert.ToInt32(odRow["ItemID"])); }); // // if (oLIssue != null) // // { // // loanAmounn = oLIssue.LoanAmount; // // List oLSS = oLoanScheduls.FindAll(delegate(LoanSchedule oitem) { return oitem.LoanIssueID == oLIssue.ID; }); // // if (oLSS.Count>0) // // { // // List oBeforeSMonths = oLSS.FindAll(delegate(LoanSchedule oitem) { return oitem.DueInstallmentDate <= GlobalFunctions.LastDateOfMonth(salaryMonth); }); // // foreach (LoanSchedule oScedule in oBeforeSMonths) // // { // // actuInterest = actuInterest + oScedule.ActualInterest; // // principleAmount = principleAmount + oScedule.InstallmentPrincipal; // // interest = interest + oScedule.InstallmentInterest; // // balance = balance + oScedule.OpeningBalance; // // //oTemLoanSchedule.Add(oScedule); // // } // // } // // sattelmentAmount = (loanAmounn + actuInterest) - (principleAmount + interest); // // } // // oRow["PersonalLoan"] = sattelmentAmount;//odRow["CHANGEDAMOUNT"]; // //} // //Vehicle Loan // //if ((Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Monthly_Installment && (Convert.ToInt32(odRow["ItemID"]) == 4))) // //{ // // loanAmounn = 0.0; // // actuInterest = 0.0; // // principleAmount = 0.0; // // interest = 0.0; // // balance = 0.0; // // sattelmentAmount = 0.0; // // LoanIssue oLIssue=LoanIssue.GetExistingLoan(ID.FromInteger(Convert.ToInt32(odRow["ItemID"])),oEmployee.ID); // // //LoanIssue oLIssue = oLoanIssues.Find(delegate(LoanIssue item1) { return oEmployee.ID == item1.EmployeeID && item1.LoanID == ID.FromInteger(Convert.ToInt32(odRow["ItemID"])); }); // // if (oLIssue != null) // // { // // loanAmounn = oLIssue.LoanAmount; // // List oLSS = oLoanScheduls.FindAll(delegate(LoanSchedule oitem) { return oitem.LoanIssueID == oLIssue.ID; }); // // if (oLSS.Count > 0) // // { // // List oBeforeSMonths = oLSS.FindAll(delegate(LoanSchedule oitem) { return oitem.DueInstallmentDate <= GlobalFunctions.LastDateOfMonth(salaryMonth); }); // // foreach (LoanSchedule oScedule in oBeforeSMonths) // // { // // actuInterest = actuInterest + oScedule.ActualInterest; // // principleAmount = principleAmount + oScedule.InstallmentPrincipal; // // interest = interest + oScedule.InstallmentInterest; // // balance = balance + oScedule.OpeningBalance; // // //oTemLoanSchedule.Add(oScedule); // // } // // } // // sattelmentAmount = (loanAmounn + actuInterest) - (principleAmount + interest); // // } // // oRow["VechileLoan"] = sattelmentAmount;//odRow["CHANGEDAMOUNT"]; // //} // //House Loan // //if ((Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Monthly_Installment && (Convert.ToInt32(odRow["ItemID"]) == 2))) // //{ // // loanAmounn = 0.0; // // actuInterest = 0.0; // // principleAmount = 0.0; // // interest = 0.0; // // balance = 0.0; // // sattelmentAmount = 0.0; // // LoanIssue oLIssue=LoanIssue.GetExistingLoan(ID.FromInteger(Convert.ToInt32(odRow["ItemID"])),oEmployee.ID); // // //LoanIssue oLIssue = oLoanIssues.Find(delegate(LoanIssue item1) { return oEmployee.ID == item1.EmployeeID && item1.LoanID == ID.FromInteger(Convert.ToInt32(odRow["ItemID"])); }); // // if (oLIssue != null) // // { // // loanAmounn = oLIssue.LoanAmount; // // List oLSS = oLoanScheduls.FindAll(delegate(LoanSchedule oitem) { return oitem.LoanIssueID == oLIssue.ID; }); // // if (oLSS.Count > 0) // // { // // List oBeforeSMonths = oLSS.FindAll(delegate(LoanSchedule oitem) { return oitem.DueInstallmentDate <= GlobalFunctions.LastDateOfMonth(salaryMonth); }); // // foreach (LoanSchedule oScedule in oBeforeSMonths) // // { // // actuInterest = actuInterest + oScedule.ActualInterest; // // principleAmount = principleAmount + oScedule.InstallmentPrincipal; // // interest = interest + oScedule.InstallmentInterest; // // balance = balance + oScedule.OpeningBalance; // // //oTemLoanSchedule.Add(oScedule); // // } // // } // // sattelmentAmount = (loanAmounn + actuInterest) - (principleAmount + interest); // // } // // oRow["HomeLoan"] = sattelmentAmount;//odRow["CHANGEDAMOUNT"]; // //} // //if ((Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.PF_Contribution && (Convert.ToInt32(odRow["ItemID"]) == (int)EnumSalaryItemCode.PF_Contribution))) // //{ // // oRow["PF"] = odRow["CHANGEDAMOUNT"]; // //} // #endregion // nCount = nCount + 1; // employeeNo = odRow["EMPLOYEENO"].ToString(); // } // nCount = 0; // DataSet oSalaryMonthlysIncomeTax = SalaryMonthly.GetEmpPaySlipIncomeTaxAmountForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); // string employeeNo1 = ""; // DataRow[] odros1 = null; // if (oSalaryMonthlysIncomeTax.Tables[0].Rows.Count > 0) // { // employeeNo1 = oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); // odros1 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); // } // foreach (DataRow odRow in oSalaryMonthlysIncomeTax.Tables[0].Rows) // { // DataRow oRow = null; // if (employeeNo1 != odRow["EMPLOYEENO"].ToString()) // { // odros1 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); // nCount = 0; // } // if (odros1.Length <= nCount) continue; // oRow = odros1[nCount]; // //oRow["DeducDescription"] = odRow["Description"]; // if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.OtherItem) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Inc_Tax_Deduction)) // oRow["IncomTaxAmount"] = odRow["CHANGEDAMOUNT"]; // nCount = nCount + 1; // employeeNo1 = odRow["EMPLOYEENO"].ToString(); // } // nCount = 0; // DataSet oSalaryMonthlysLaonAmount = SalaryMonthly.GetEmpPaySlipDeductForLR(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); // string employeeNo12 = ""; // DataRow[] odros12 = null; // if (oSalaryMonthlysLaonAmount.Tables[0].Rows.Count > 0) // { // employeeNo12 = oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); // odros12 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); // } // foreach (DataRow odRow in oSalaryMonthlysLaonAmount.Tables[0].Rows) // { // DataRow oRow = null; // if (employeeNo12 != odRow["EMPLOYEENO"].ToString()) // { // odros12 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); // nCount = 0; // } // if (odros12.Length <= nCount) continue; // oRow = odros12[nCount]; // //oRow["DeducDescription"] = odRow["Description"]; // if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Miscellaneous) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Remain_Balance)) // { // oRow["LoanDescription"] = odRow["Description"]; // oRow["LoanAmount"] = odRow["CHANGEDAMOUNT"]; // } // nCount = nCount + 1; // employeeNo12 = odRow["EMPLOYEENO"].ToString(); // } // //if (IsApproved) // //{ // form.ShowDlgForPaySlip(_selectedParameter.ReportItem, PayslipData); // //} // //else // //{ // // MessageBox.Show("This salary process is not approve for the month of " + salaryMonth.ToString("MMM yyyy"), "Salary Approved", MessageBoxButtons.OK, MessageBoxIcon.Information); // //} //} public void ShowReport() { DataSet dBasicInfoDset = null; DataSet oFDST = new DataSet(); _oGratuityParams = ESBDefinition.Get(); Employee oEmployee = null; ObjectsTemplate oEmps = new ObjectsTemplate(); oEmps = Employee.Get(); List oDesigs = Designation.Get(EnumStatus.Regardless); DataRow oRow = null; fReportViewer form = new fReportViewer(); DateTime salaryMonth = _selectedParameter.FromDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; ObjectsTemplate oSaProcess = new ObjectsTemplate(); oSaProcess = SalaryProcess.Get(GlobalFunctions.LastDateOfMonth(salaryMonth)); //bool bIsProcess = SalaryMonthly.IsSalaryProcessed(SessionManager.CurrentEmployee.ID, _SalaryMonth); dBasicInfoDset = Employee.GetEmpBasicInfoForPSlipNew(sEmpID, GlobalFunctions.LastDateOfMonth(salaryMonth)); DataSet oSalaryMonthlysGross = SalaryMonthly.GetEmpPaySlipGrossForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); DataSet oSalaryMonthlysDeduct = SalaryMonthly.GetEmpPaySlipDeductForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); PayrollDataSet.PayrollDataSet.PayslipDataTable PayslipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.PayslipDataTable(); PayrollDataSet.PayrollDataSet.LoanDataDataTable loanDT = new Payroll.Report.PayrollDataSet.PayrollDataSet.LoanDataDataTable(); //bool IsApproved = oSaProcess.GetBySMonth(GlobalFunctions.LastDateOfMonth(salaryMonth)); DataTable basicInfo = new PayrollDataSet.PayrollDataSet.PayslipBasicInfoDataTable(); _dSalaryMonth = GlobalFunctions.LastDateOfMonth(salaryMonth); if (oSaProcess != null && oSaProcess.Count > 0 && oSalaryMonthlysGross.Tables[0].Rows.Count > 0) { if (oSaProcess[0].PaymentDate != DateTime.MinValue) { _dMonthEndDate = Convert.ToDateTime(oSaProcess[0].PaymentDate); } else { _dMonthEndDate = DateTime.MinValue; } } foreach (DataRow odRow in oSalaryMonthlysGross.Tables[0].Rows) { double dbl = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); if (dbl == 0) { continue; } if ((EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]) == EnumSalaryItemCode.Over_Time_Amount) oRow = this.GetItem2(PayslipData, Convert.ToString(odRow["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(odRow["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]), Convert.ToInt32(odRow["ItemID"]), odRow["Description"].ToString().Trim()); else oRow = this.GetItem(PayslipData, Convert.ToString(odRow["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(odRow["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]), Convert.ToInt32(odRow["ItemID"])); if (oRow == null) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } if ((EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]) == EnumSalaryItemCode.Over_Time_Amount) { DataRow oRow6 = this.GetItem2(oSalaryMonthlysGross.Tables[1], Convert.ToString(odRow["EMPLOYEENO"]), EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Over_Time_Hours, Convert.ToInt32(odRow["ItemID"]), odRow["Description"].ToString().Replace(" hour","").Trim()); if (oRow6 != null) { if (oRow["Description"].ToString().IndexOf('[') < 0) oRow["Description"] += " [" + Convert.ToDouble(oRow6["CHANGEDAMOUNT"]).ToString("#") + " Hours]"; } } if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Gross)) { if (oRow["Earning"].ToString() != "" && (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"])!=EnumSalaryItemCode.Over_Time_Amount) { oRow["Earning"] = Convert.ToDouble(oRow["Earning"]) + Convert.ToDouble(odRow["CHANGEDAMOUNT"]); } else { oRow["Earning"] = odRow["CHANGEDAMOUNT"]; } } if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Deductions) && (Convert.ToInt32(odRow["ITEMID"]) == (int)EnumSalaryItemCode.PF_Contribution)) { if (oRow["Earning"].ToString() != "") { oRow["Earning"] = Convert.ToDouble(oRow["Earning"]) + (Convert.ToDouble(odRow["CHANGEDAMOUNT"])); oRow["Description"] = "Company PF Contribution"; } else { oRow["Earning"] = Convert.ToDouble(odRow["CHANGEDAMOUNT"]); oRow["Description"] = "Company PF Contribution"; } } else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Arrear)) { double dArrear = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); oRow["Arrear"] = dArrear; } else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.UnauthLeave)) { oRow["unAuthLeave"] = odRow["CHANGEDAMOUNT"]; } } //DataRow[] odrowsPF = oSalaryMonthlysDeduct.Tables[0].Select(" ItemCode='" + (int)EnumSalaryItemCode.PF_Contribution + "' AND EMPLOYEEID='" + Convert.ToInt32(sEmpID) + "'"); //if (odrowsPF.Length > 0) //{ // DataRow orowPF = odrowsPF[0]; // if (Convert.ToDouble( orowPF["CHANGEDAMOUNT"].ToString()) >0) // { // oRow = PayslipData.NewRow(); // oRow = this.GrossMerge(oRow, orowPF); // oRow["Description"] = "Company PF Contribution"; // oRow["Earning"] = Convert.ToDouble(orowPF["CHANGEDAMOUNT"]); // PayslipData.Rows.Add(oRow); // } //} int nCount = 0; string employeeNo = ""; DataRow[] odros = null; if (oSalaryMonthlysDeduct.Tables[0].Rows.Count > 0) { employeeNo = oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } double dGratuityAmount = 0; double dPFAmount = 0; string sTEmpEmpNo = ""; double nCurrPFAmount = 0; foreach (DataRow odRow in oSalaryMonthlysDeduct.Tables[0].Rows) { double dbl = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); if (dbl == 0) { continue; } oRow = null; if (employeeNo != odRow["EMPLOYEENO"].ToString()) { odros = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros.Length <= nCount) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } else oRow = odros[nCount]; oRow["DeducDescription"] = odRow["Description"]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Deductions)) { if (oRow["DeducDescription"].ToString().ToLower() == "pf contribution") oRow["DeducAmount"] = Convert.ToDouble(odRow["CHANGEDAMOUNT"]) * 2; else oRow["DeducAmount"] = odRow["CHANGEDAMOUNT"]; } oRow["DeducDescription"] = odRow["Description"]; //oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); if (sTEmpEmpNo == "" || sTEmpEmpNo != odRow["EMPLOYEENO"].ToString()) { nCurrPFAmount = 0; dPFAmount = 0; oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); DataRow[] odrosPF = oSalaryMonthlysDeduct.Tables[0].Select(" ItemCode='" + (int)EnumSalaryItemCode.PF_Contribution + "' AND EMPLOYEENO='" + odRow["EMPLOYEENO"].ToString() + "'"); if (odrosPF.Length > 0) { DataRow oRowPF = odrosPF[0]; nCurrPFAmount = Convert.ToDouble(oRowPF["CHANGEDAMOUNT"]) * 2; } if (oEmployee != null) { if (_oGratuityParams.Count > 0 && _oGratuityParams != null) { dGratuityAmount = GetGratuityAmount(_oGratuityParams, oEmployee, salaryMonth); } else { dGratuityAmount = 0; } dPFAmount = GetPFAmount(oEmployee, salaryMonth); } } oRow["Gratuity"] = dGratuityAmount; double nServiceLength = 0; if (oEmployee != null) nServiceLength = ServiceYears(GlobalFunctions.LastDateOfMonth(salaryMonth), oEmployee); if (nServiceLength > 5) { //oRow["PF"] = dPFAmount + nCurrPFAmount * 2; oRow["PF"] = (dPFAmount + nCurrPFAmount); } else { oRow["PF"] = (dPFAmount + nCurrPFAmount); } nCount = nCount + 1; employeeNo = odRow["EMPLOYEENO"].ToString(); sTEmpEmpNo = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysIncomeTax = SalaryMonthly.GetEmpPaySlipIncomeTaxAmountForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo1 = ""; DataRow[] odros1 = null; if (oSalaryMonthlysIncomeTax.Tables[0].Rows.Count > 0) { employeeNo1 = oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros1 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysIncomeTax.Tables[0].Rows) { oRow = null; if (employeeNo1 != odRow["EMPLOYEENO"].ToString()) { odros1 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros1.Length <= nCount) continue; oRow = odros1[nCount]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.OtherItem) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Inc_Tax_Deduction)) oRow["IncomTaxAmount"] = odRow["CHANGEDAMOUNT"]; nCount = nCount + 1; employeeNo1 = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysLaonAmount = SalaryMonthly.GetEmpPaySlipDeductForLR(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo12 = ""; DataRow[] odros12 = null; if (oSalaryMonthlysLaonAmount.Tables[0].Rows.Count > 0) { employeeNo12 = oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros12 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysLaonAmount.Tables[0].Rows) { oRow = null; if (employeeNo12 != odRow["EMPLOYEENO"].ToString()) { odros12 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros12.Length <= nCount) continue; oRow = odros12[nCount]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Miscellaneous) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Remain_Balance)) { oRow["LoanDescription"] = odRow["Description"]; oRow["LoanAmount"] = odRow["CHANGEDAMOUNT"]; } nCount = nCount + 1; employeeNo12 = odRow["EMPLOYEENO"].ToString(); } bool isDesigFromEmp = ConfigurationManager.GetBoolValue("designation", "desigfromdescriptiontext", EnumConfigurationType.Logic); foreach (DataRow row in PayslipData.Rows) { Employee oEmp = oEmps .Where(o => o.EmployeeNo.ToUpper().Trim() == row["EMPLOYEENO"].ToString().ToUpper().Trim()) .SingleOrDefault(); if (oEmp != null) { if (isDesigFromEmp) { row["Designation"] = oEmp.DescriptionText; } else { Designation oDesg = oDesigs.Where(o => o.ID == oEmp.DesignationID).SingleOrDefault(); if (oDesg != null) { row["Designation"] = oDesg.Name; } } } } basicInfo = dBasicInfoDset.Tables[0]; basicInfo.TableName = "BasicInfo"; //loanDT.TableName = "PayrollDataSet_LoanData"; //PayslipData.TableName = "PayrollDataSet_Payslip"; //oFDST.Tables.Add(PayslipData); //oFDST.Tables.Add(loanDT); //form.ShowDlgForPaySlipCiti1(_selectedParameter.ReportItem, oFDST); DataSet dsSubReport = new DataSet(); PayslipData.TableName = "SalaryMonthlysGross"; dsSubReport.Tables.Add(PayslipData); form.ShowDlgForNewPaySlip(_selectedParameter.ReportItem, basicInfo, dsSubReport, salaryMonth.ToString("MMMM yyyy")); } public byte[] MailReport(DateTime salaryMonth2, string sEmpID2) { DataSet dBasicInfoDset = null; DataSet oFDST = new DataSet(); _oGratuityParams = ESBDefinition.Get(); Employee oEmployee = null; ObjectsTemplate oEmps = new ObjectsTemplate(); oEmps = Employee.Get(); List oDesigs = Designation.Get(EnumStatus.Regardless); DataRow oRow = null; fReportViewer form = new fReportViewer(); DateTime salaryMonth =salaryMonth2; string sEmpID = sEmpID2; ObjectsTemplate oSaProcess = new ObjectsTemplate(); oSaProcess = SalaryProcess.Get(GlobalFunctions.LastDateOfMonth(salaryMonth)); //bool bIsProcess = SalaryMonthly.IsSalaryProcessed(SessionManager.CurrentEmployee.ID, _SalaryMonth); dBasicInfoDset = Employee.GetEmpBasicInfoForPSlipNew(sEmpID, GlobalFunctions.LastDateOfMonth(salaryMonth)); DataSet oSalaryMonthlysGross = SalaryMonthly.GetEmpPaySlipGrossForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); DataSet oSalaryMonthlysDeduct = SalaryMonthly.GetEmpPaySlipDeductForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); PayrollDataSet.PayrollDataSet.PayslipDataTable PayslipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.PayslipDataTable(); PayrollDataSet.PayrollDataSet.LoanDataDataTable loanDT = new Payroll.Report.PayrollDataSet.PayrollDataSet.LoanDataDataTable(); //bool IsApproved = oSaProcess.GetBySMonth(GlobalFunctions.LastDateOfMonth(salaryMonth)); DataTable basicInfo = new PayrollDataSet.PayrollDataSet.PayslipBasicInfoDataTable(); _dSalaryMonth = GlobalFunctions.LastDateOfMonth(salaryMonth); if (oSaProcess != null && oSaProcess.Count > 0 && oSalaryMonthlysGross.Tables[0].Rows.Count > 0) { if (oSaProcess[0].PaymentDate != DateTime.MinValue) { _dMonthEndDate = Convert.ToDateTime(oSaProcess[0].PaymentDate); } else { _dMonthEndDate = DateTime.MinValue; } } foreach (DataRow odRow in oSalaryMonthlysGross.Tables[0].Rows) { double dbl = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); if (dbl == 0) { continue; } if ((EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]) == EnumSalaryItemCode.Over_Time_Amount) oRow = this.GetItem2(PayslipData, Convert.ToString(odRow["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(odRow["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]), Convert.ToInt32(odRow["ItemID"]), odRow["Description"].ToString().Trim()); else oRow = this.GetItem(PayslipData, Convert.ToString(odRow["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(odRow["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]), Convert.ToInt32(odRow["ItemID"])); if (oRow == null) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } if ((EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]) == EnumSalaryItemCode.Over_Time_Amount) { DataRow oRow6 = this.GetItem2(oSalaryMonthlysGross.Tables[1], Convert.ToString(odRow["EMPLOYEENO"]), EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Over_Time_Hours, Convert.ToInt32(odRow["ItemID"]), odRow["Description"].ToString().Replace(" hour", "").Trim()); if (oRow6 != null) { if (oRow["Description"].ToString().IndexOf('[') < 0) oRow["Description"] += " [" + Convert.ToDouble(oRow6["CHANGEDAMOUNT"]).ToString("#") + " Hours]"; } } if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Gross)) { if (oRow["Earning"].ToString() != "" && (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]) != EnumSalaryItemCode.Over_Time_Amount) { oRow["Earning"] = Convert.ToDouble(oRow["Earning"]) + Convert.ToDouble(odRow["CHANGEDAMOUNT"]); } else { oRow["Earning"] = odRow["CHANGEDAMOUNT"]; } } if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Deductions) && (Convert.ToInt32(odRow["ITEMID"]) == (int)EnumSalaryItemCode.PF_Contribution)) { if (oRow["Earning"].ToString() != "") { oRow["Earning"] = Convert.ToDouble(oRow["Earning"]) + (Convert.ToDouble(odRow["CHANGEDAMOUNT"])); oRow["Description"] = "Company PF Contribution"; } else { oRow["Earning"] = Convert.ToDouble(odRow["CHANGEDAMOUNT"]); oRow["Description"] = "Company PF Contribution"; } } else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Arrear)) { double dArrear = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); oRow["Arrear"] = dArrear; } else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.UnauthLeave)) { oRow["unAuthLeave"] = odRow["CHANGEDAMOUNT"]; } } //DataRow[] odrowsPF = oSalaryMonthlysDeduct.Tables[0].Select(" ItemCode='" + (int)EnumSalaryItemCode.PF_Contribution + "' AND EMPLOYEEID='" + Convert.ToInt32(sEmpID) + "'"); //if (odrowsPF.Length > 0) //{ // DataRow orowPF = odrowsPF[0]; // if (Convert.ToDouble( orowPF["CHANGEDAMOUNT"].ToString()) >0) // { // oRow = PayslipData.NewRow(); // oRow = this.GrossMerge(oRow, orowPF); // oRow["Description"] = "Company PF Contribution"; // oRow["Earning"] = Convert.ToDouble(orowPF["CHANGEDAMOUNT"]); // PayslipData.Rows.Add(oRow); // } //} int nCount = 0; string employeeNo = ""; DataRow[] odros = null; if (oSalaryMonthlysDeduct.Tables[0].Rows.Count > 0) { employeeNo = oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } double dGratuityAmount = 0; double dPFAmount = 0; string sTEmpEmpNo = ""; double nCurrPFAmount = 0; foreach (DataRow odRow in oSalaryMonthlysDeduct.Tables[0].Rows) { double dbl = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); if (dbl == 0) { continue; } oRow = null; if (employeeNo != odRow["EMPLOYEENO"].ToString()) { odros = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros.Length <= nCount) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } else oRow = odros[nCount]; oRow["DeducDescription"] = odRow["Description"]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Deductions)) { if (oRow["DeducDescription"].ToString().ToLower() == "pf contribution") oRow["DeducAmount"] = Convert.ToDouble(odRow["CHANGEDAMOUNT"]) * 2; else oRow["DeducAmount"] = odRow["CHANGEDAMOUNT"]; } oRow["DeducDescription"] = odRow["Description"]; //oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); if (sTEmpEmpNo == "" || sTEmpEmpNo != odRow["EMPLOYEENO"].ToString()) { nCurrPFAmount = 0; dPFAmount = 0; oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); DataRow[] odrosPF = oSalaryMonthlysDeduct.Tables[0].Select(" ItemCode='" + (int)EnumSalaryItemCode.PF_Contribution + "' AND EMPLOYEENO='" + odRow["EMPLOYEENO"].ToString() + "'"); if (odrosPF.Length > 0) { DataRow oRowPF = odrosPF[0]; nCurrPFAmount = Convert.ToDouble(oRowPF["CHANGEDAMOUNT"]) * 2; } if (oEmployee != null) { if (_oGratuityParams.Count > 0 && _oGratuityParams != null) { dGratuityAmount = GetGratuityAmount(_oGratuityParams, oEmployee, salaryMonth); } else { dGratuityAmount = 0; } dPFAmount = GetPFAmount(oEmployee, salaryMonth); } } oRow["Gratuity"] = dGratuityAmount; double nServiceLength = 0; if (oEmployee != null) nServiceLength = ServiceYears(GlobalFunctions.LastDateOfMonth(salaryMonth), oEmployee); if (nServiceLength > 5) { //oRow["PF"] = dPFAmount + nCurrPFAmount * 2; oRow["PF"] = (dPFAmount + nCurrPFAmount); } else { oRow["PF"] = (dPFAmount + nCurrPFAmount); } nCount = nCount + 1; employeeNo = odRow["EMPLOYEENO"].ToString(); sTEmpEmpNo = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysIncomeTax = SalaryMonthly.GetEmpPaySlipIncomeTaxAmountForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo1 = ""; DataRow[] odros1 = null; if (oSalaryMonthlysIncomeTax.Tables[0].Rows.Count > 0) { employeeNo1 = oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros1 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysIncomeTax.Tables[0].Rows) { oRow = null; if (employeeNo1 != odRow["EMPLOYEENO"].ToString()) { odros1 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros1.Length <= nCount) continue; oRow = odros1[nCount]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.OtherItem) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Inc_Tax_Deduction)) oRow["IncomTaxAmount"] = odRow["CHANGEDAMOUNT"]; nCount = nCount + 1; employeeNo1 = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysLaonAmount = SalaryMonthly.GetEmpPaySlipDeductForLR(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo12 = ""; DataRow[] odros12 = null; if (oSalaryMonthlysLaonAmount.Tables[0].Rows.Count > 0) { employeeNo12 = oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros12 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysLaonAmount.Tables[0].Rows) { oRow = null; if (employeeNo12 != odRow["EMPLOYEENO"].ToString()) { odros12 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros12.Length <= nCount) continue; oRow = odros12[nCount]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Miscellaneous) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Remain_Balance)) { oRow["LoanDescription"] = odRow["Description"]; oRow["LoanAmount"] = odRow["CHANGEDAMOUNT"]; } nCount = nCount + 1; employeeNo12 = odRow["EMPLOYEENO"].ToString(); } bool isDesigFromEmp = ConfigurationManager.GetBoolValue("designation", "desigfromdescriptiontext", EnumConfigurationType.Logic); foreach (DataRow row in PayslipData.Rows) { Employee oEmp = oEmps .Where(o => o.EmployeeNo.ToUpper().Trim() == row["EMPLOYEENO"].ToString().ToUpper().Trim()) .SingleOrDefault(); if (oEmp != null) { if (isDesigFromEmp) { row["Designation"] = oEmp.DescriptionText; } else { Designation oDesg = oDesigs.Where(o => o.ID == oEmp.DesignationID).SingleOrDefault(); if (oDesg != null) { row["Designation"] = oDesg.Name; } } } } basicInfo = dBasicInfoDset.Tables[0]; basicInfo.TableName = "BasicInfo"; //loanDT.TableName = "PayrollDataSet_LoanData"; //PayslipData.TableName = "PayrollDataSet_Payslip"; //oFDST.Tables.Add(PayslipData); //oFDST.Tables.Add(loanDT); //form.ShowDlgForPaySlipCiti1(_selectedParameter.ReportItem, oFDST); DataSet dsSubReport = new DataSet(); PayslipData.TableName = "SalaryMonthlysGross"; dsSubReport.Tables.Add(PayslipData); return form.MailNewPaySlip(null, basicInfo, dsSubReport, salaryMonth.ToString("MMMM yyyy")); } public void ShowReport(SalaryMonthly oSalMonthly) { DataSet oFDST = new DataSet(); //_oGratuityParams = ESBDefinition.Get(); Employee oEmployee = null; //ObjectsTemplate oEmps = new ObjectsTemplate(); //oEmps = Employee.Get(); List oDesigs = Designation.Get(EnumStatus.Regardless); List oDepts = Department.Get(); List oLocs = Location.Get(); List oGrades = Grade.Get(EnumStatus.Regardless); List oCategories = Category.Get(EnumStatus.Regardless); List oBranchs = Branch.Get(EnumStatus.Regardless); // List oDepts = Department.Get(); fReportViewer form = new fReportViewer(); DateTime salaryMonth = oSalMonthly.SalaryMonth; string sEmpID = oSalMonthly.EmployeeID.Integer.ToString(); ObjectsTemplate oSaProcess = new ObjectsTemplate(); oSaProcess = SalaryProcess.Get(GlobalFunctions.LastDateOfMonth(salaryMonth)); //bool bIsProcess = SalaryMonthly.IsSalaryProcessed(SessionManager.CurrentEmployee.ID, _SalaryMonth); DataSet oSalaryMonthlysGross = SalaryMonthly.GetEmpPaySlipGrossForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); Employee emp = oSalMonthly.Employee; Designation deg = oDesigs.Find(x => x.ID == oSalMonthly.DesignationID); Department dep = oDepts.Find(x => x.ID == oSalMonthly.DepartmentID); Location loc = oLocs.Find(x => x.ID == oSalMonthly.LocationID); Grade grd = oGrades.Find(x => x.ID == oSalMonthly.GradeID); Category cat = oCategories.Find(x => x.ID == oSalMonthly.CategoryID); Branch branch = oBranchs.Find(x => x.ID == oSalMonthly.BranchID); try { foreach (SalaryMonthlyDetail smd in oSalMonthly.Details) { if (smd.itemGroupCode == EnumSalaryGroup.Gross || smd.itemGroupCode == EnumSalaryGroup.UnauthLeave || smd.itemGroupCode == EnumSalaryGroup.Arrear) { oSalaryMonthlysGross.Tables[0].Rows.Add( emp.Name, emp.EmployeeNo, grd.Name, deg.Name, loc.Name, dep.Name, branch.Name, oSalMonthly.ThisMonthBasic, emp.PaymentMode, oSalMonthly.AccountNo, oSalMonthly.SalaryMonth, oSalMonthly.Remarks, smd.Description, smd.itemGroupCode, oSalMonthly.IsFinalized, smd.ChangedAmount, smd.ItemCode, smd.ItemID, cat.Name, emp.JoiningDate, emp.TinNo, oSalMonthly.DepartmentID.Integer ); } } } catch (Exception exp) { } PayrollDataSet.PayrollDataSet.PayslipDataTable PayslipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.PayslipDataTable(); PayrollDataSet.PayrollDataSet.LoanDataDataTable loanDT = new Payroll.Report.PayrollDataSet.PayrollDataSet.LoanDataDataTable(); //bool IsApproved = oSaProcess.GetBySMonth(GlobalFunctions.LastDateOfMonth(salaryMonth)); _dSalaryMonth = GlobalFunctions.LastDateOfMonth(salaryMonth); //if (oSaProcess != null && oSaProcess.Count > 0 && oSalaryMonthlysGross.Tables[0].Rows.Count > 0) //{ // if (oSaProcess[0].PaymentDate != DateTime.MinValue) // { // _dMonthEndDate = Convert.ToDateTime(oSaProcess[0].PaymentDate); // } // else // { // _dMonthEndDate = DateTime.MinValue; // } //} foreach (DataRow odRow in oSalaryMonthlysGross.Tables[0].Rows) { double dbl = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); if (dbl == 0) { continue; } DataRow oRow = this.GetItem(PayslipData, Convert.ToString(odRow["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(odRow["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]), Convert.ToInt32(odRow["ItemID"])); if (oRow == null) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Gross)) { oRow["Earning"] = odRow["CHANGEDAMOUNT"]; } else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Arrear)) { double dArrear = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); oRow["Arrear"] = dArrear; } else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.UnauthLeave)) { oRow["unAuthLeave"] = odRow["CHANGEDAMOUNT"]; } } int nCount = 0; DataSet oSalaryMonthlysDeduct = SalaryMonthly.GetEmpPaySlipDeductForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth.AddYears(-80)), sEmpID); foreach (SalaryMonthlyDetail smd in oSalMonthly.Details) { if (smd.itemGroupCode == EnumSalaryGroup.Deductions) { oSalaryMonthlysDeduct.Tables[0].Rows.Add( emp.Name, emp.ID.Integer, emp.EmployeeNo, emp.JoiningDate, emp.TinNo, grd.Name, deg.Name, loc.Name, dep.Name, branch==null?"":branch.Name, oSalMonthly.ThisMonthBasic, emp.PaymentMode, oSalMonthly.AccountNo, oSalMonthly.SalaryMonth, oSalMonthly.Remarks, smd.Description, smd.itemGroupCode, smd.ChangedAmount, smd.ItemCode, smd.ItemID ); } } string employeeNo = ""; DataRow[] odros = null; if (oSalaryMonthlysDeduct.Tables[0].Rows.Count > 0) { employeeNo = oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } double dGratuityAmount = 0; double dPFAmount = 0; string sTEmpEmpNo = ""; double nCurrPFAmount = 0; foreach (DataRow odRow in oSalaryMonthlysDeduct.Tables[0].Rows) { double dbl = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); if (dbl == 0) { continue; } DataRow oRow = null; if (employeeNo != odRow["EMPLOYEENO"].ToString()) { odros = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros.Length <= nCount) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } else oRow = odros[nCount]; oRow["DeducDescription"] = odRow["Description"]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Deductions)) { if (oRow["DeducDescription"].ToString().ToLower() == "pf contibution") oRow["DeducAmount"] = Convert.ToDouble(odRow["CHANGEDAMOUNT"]) * 2; else oRow["DeducAmount"] = odRow["CHANGEDAMOUNT"]; } oRow["DeducDescription"] = odRow["Description"]; //oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); if (sTEmpEmpNo == "" || sTEmpEmpNo != odRow["EMPLOYEENO"].ToString()) { nCurrPFAmount = 0; dPFAmount = 0; oEmployee = emp; DataRow[] odrosPF = oSalaryMonthlysDeduct.Tables[0].Select(" ItemCode='" + (int)EnumSalaryItemCode.PF_Contribution + "' AND EMPLOYEENO='" + odRow["EMPLOYEENO"].ToString() + "'"); if (odrosPF.Length > 0) { DataRow oRowPF = odrosPF[0]; nCurrPFAmount = Convert.ToDouble(oRowPF["CHANGEDAMOUNT"]); } if (oEmployee != null) { //if (_oGratuityParams.Count > 0 && _oGratuityParams != null) //{ // dGratuityAmount = GetGratuityAmount(_oGratuityParams, oEmployee, salaryMonth); //} //else //{ // dGratuityAmount = 0; //} dPFAmount = GetPFAmount(oEmployee, salaryMonth); } } oRow["Gratuity"] = dGratuityAmount; double nServiceLength = 0; if (oEmployee != null) nServiceLength = ServiceYears(GlobalFunctions.LastDateOfMonth(salaryMonth), oEmployee); if (nServiceLength > 5) { //oRow["PF"] = dPFAmount + nCurrPFAmount * 2; oRow["PF"] = dPFAmount + nCurrPFAmount; } else { oRow["PF"] = dPFAmount + nCurrPFAmount; } nCount = nCount + 1; employeeNo = odRow["EMPLOYEENO"].ToString(); sTEmpEmpNo = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysIncomeTax = SalaryMonthly.GetEmpPaySlipIncomeTaxAmountForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth.AddYears(-80)), sEmpID); foreach (SalaryMonthlyDetail smd in oSalMonthly.Details) { if (smd.itemGroupCode == EnumSalaryGroup.OtherItem || smd.ItemCode == EnumSalaryItemCode.Inc_Tax_Deduction || smd.ItemCode == EnumSalaryItemCode.Net_Payable) { oSalaryMonthlysIncomeTax.Tables[0].Rows.Add( emp.Name, emp.EmployeeNo, grd.Name, deg.Name, loc.Name, dep.Name, oSalMonthly.ThisMonthBasic, emp.PaymentMode, oSalMonthly.AccountNo, oSalMonthly.SalaryMonth, smd.Description, smd.itemGroupCode, smd.ChangedAmount, smd.ItemCode, smd.ItemID ); } } string employeeNo1 = ""; DataRow[] odros1 = null; if (oSalaryMonthlysIncomeTax.Tables[0].Rows.Count > 0) { employeeNo1 = oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros1 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysIncomeTax.Tables[0].Rows) { DataRow oRow = null; if (employeeNo1 != odRow["EMPLOYEENO"].ToString()) { odros1 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros1.Length <= nCount) continue; oRow = odros1[nCount]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.OtherItem) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Inc_Tax_Deduction)) oRow["IncomTaxAmount"] = odRow["CHANGEDAMOUNT"]; nCount = nCount + 1; employeeNo1 = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysLaonAmount = SalaryMonthly.GetEmpPaySlipDeductForLR(GlobalFunctions.LastDateOfMonth(salaryMonth.AddYears(-80)), sEmpID); foreach (SalaryMonthlyDetail smd in oSalMonthly.Details) { if (smd.itemGroupCode == EnumSalaryGroup.Miscellaneous || smd.ItemCode == EnumSalaryItemCode.Loan_Remain_Balance) { oSalaryMonthlysLaonAmount.Tables[0].Rows.Add( emp.Name, emp.EmployeeNo, grd.Name, deg.Name, loc.Name, dep.Name, branch == null ? "" : branch.Name, oSalMonthly.ThisMonthBasic, emp.PaymentMode, oSalMonthly.AccountNo, oSalMonthly.SalaryMonth, smd.Description, smd.itemGroupCode, smd.ChangedAmount, smd.ItemCode, smd.ItemID ); } } string employeeNo12 = ""; DataRow[] odros12 = null; if (oSalaryMonthlysLaonAmount.Tables[0].Rows.Count > 0) { employeeNo12 = oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros12 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysLaonAmount.Tables[0].Rows) { DataRow oRow = null; if (employeeNo12 != odRow["EMPLOYEENO"].ToString()) { odros12 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros12.Length <= nCount) continue; oRow = odros12[nCount]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Miscellaneous) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Remain_Balance)) { oRow["LoanDescription"] = odRow["Description"]; oRow["LoanAmount"] = odRow["CHANGEDAMOUNT"]; } nCount = nCount + 1; employeeNo12 = odRow["EMPLOYEENO"].ToString(); } bool isDesigFromEmp = ConfigurationManager.GetBoolValue("designation", "desigfromdescriptiontext", EnumConfigurationType.Logic); foreach (DataRow oRow in PayslipData.Rows) { Employee oEmp = emp; if (oEmp != null) { if (isDesigFromEmp) { oRow["Designation"] = oEmp.DescriptionText; } else { Designation oDesg = oDesigs.Where(o => o.ID == oEmp.DesignationID).SingleOrDefault(); if (oDesg != null) { oRow["Designation"] = oDesg.Name; } } } } loanDT.TableName = "PayrollDataSet_LoanData"; PayslipData.TableName = "PayrollDataSet_Payslip"; oFDST.Tables.Add(PayslipData); oFDST.Tables.Add(loanDT); form.ShowDlgForPaySlipCiti4(oFDST); } public void ShowReportOld(DateTime dtFrom, string sEmpIDs) { DataSet oFDST = new DataSet(); _oGratuityParams = ESBDefinition.Get(); Employee oEmployee = null; ObjectsTemplate oEmps = new ObjectsTemplate(); oEmps = Employee.Get(); List oDesigs = Designation.Get(EnumStatus.Regardless); fReportViewer form = new fReportViewer(); DateTime salaryMonth = dtFrom; string sEmpID = sEmpIDs; ObjectsTemplate oSaProcess = new ObjectsTemplate(); oSaProcess = SalaryProcess.Get(GlobalFunctions.LastDateOfMonth(salaryMonth)); //bool bIsProcess = SalaryMonthly.IsSalaryProcessed(SessionManager.CurrentEmployee.ID, _SalaryMonth); DataSet oSalaryMonthlysGross = SalaryMonthly.GetEmpPaySlipGrossForOthersOld(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); PayrollDataSet.PayrollDataSet.PayslipDataTable PayslipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.PayslipDataTable(); PayrollDataSet.PayrollDataSet.LoanDataDataTable loanDT = new Payroll.Report.PayrollDataSet.PayrollDataSet.LoanDataDataTable(); //bool IsApproved = oSaProcess.GetBySMonth(GlobalFunctions.LastDateOfMonth(salaryMonth)); _dSalaryMonth = GlobalFunctions.LastDateOfMonth(salaryMonth); if (oSaProcess != null && oSaProcess.Count > 0 && oSalaryMonthlysGross.Tables[0].Rows.Count > 0) { if (oSaProcess[0].PaymentDate != DateTime.MinValue) { _dMonthEndDate = Convert.ToDateTime(oSaProcess[0].PaymentDate); } else { _dMonthEndDate = DateTime.MinValue; } } foreach (DataRow odRow in oSalaryMonthlysGross.Tables[0].Rows) { double dbl = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); if (dbl == 0) { continue; } DataRow oRow = this.GetItem(PayslipData, Convert.ToString(odRow["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(odRow["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]), Convert.ToInt32(odRow["ItemID"])); if (oRow == null) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Gross)) { oRow["Earning"] = odRow["CHANGEDAMOUNT"]; } else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Arrear)) { double dArrear = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); oRow["Arrear"] = dArrear; } else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.UnauthLeave)) { oRow["unAuthLeave"] = odRow["CHANGEDAMOUNT"]; } } int nCount = 0; DataSet oSalaryMonthlysDeduct = SalaryMonthly.GetEmpPaySlipDeductForOthersOld(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo = ""; DataRow[] odros = null; if (oSalaryMonthlysDeduct.Tables[0].Rows.Count > 0) { employeeNo = oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } double dGratuityAmount = 0; double dPFAmount = 0; string sTEmpEmpNo = ""; double nCurrPFAmount = 0; foreach (DataRow odRow in oSalaryMonthlysDeduct.Tables[0].Rows) { double dbl = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); if (dbl == 0) { continue; } DataRow oRow = null; if (employeeNo != odRow["EMPLOYEENO"].ToString()) { odros = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros.Length <= nCount) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } else oRow = odros[nCount]; oRow["DeducDescription"] = odRow["Description"]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Deductions)) { if (oRow["DeducDescription"].ToString().ToLower() == "pf contibution") oRow["DeducAmount"] = Convert.ToDouble(odRow["CHANGEDAMOUNT"]) * 2; else oRow["DeducAmount"] = odRow["CHANGEDAMOUNT"]; } oRow["DeducDescription"] = odRow["Description"]; //oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); if (sTEmpEmpNo == "" || sTEmpEmpNo != odRow["EMPLOYEENO"].ToString()) { nCurrPFAmount = 0; dPFAmount = 0; // oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); DataRow[] odrosPF = oSalaryMonthlysDeduct.Tables[0].Select(" ItemCode='" + (int)EnumSalaryItemCode.PF_Contribution + "' AND EMPLOYEENO='" + odRow["EMPLOYEENO"].ToString() + "'"); if (odrosPF.Length > 0) { DataRow oRowPF = odrosPF[0]; nCurrPFAmount = Convert.ToDouble(oRowPF["CHANGEDAMOUNT"]); } //if (oEmployee != null) //{ // if (_oGratuityParams.Count > 0 && _oGratuityParams != null) // { // dGratuityAmount = GetGratuityAmount(_oGratuityParams, oEmployee, salaryMonth); // } // else // { // dGratuityAmount = 0; // } // dPFAmount = GetPFAmount(oEmployee, salaryMonth); //} } oRow["Gratuity"] = dGratuityAmount; double nServiceLength = 0; //if (oEmployee != null) // nServiceLength = ServiceYears(GlobalFunctions.LastDateOfMonth(salaryMonth), oEmployee); if (nServiceLength > 5) { //oRow["PF"] = dPFAmount + nCurrPFAmount * 2; oRow["PF"] = dPFAmount + nCurrPFAmount; } else { oRow["PF"] = dPFAmount + nCurrPFAmount; } nCount = nCount + 1; employeeNo = odRow["EMPLOYEENO"].ToString(); sTEmpEmpNo = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysIncomeTax = SalaryMonthly.GetEmpPaySlipIncomeTaxAmountForOthersOld(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo1 = ""; DataRow[] odros1 = null; if (oSalaryMonthlysIncomeTax.Tables[0].Rows.Count > 0) { employeeNo1 = oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros1 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysIncomeTax.Tables[0].Rows) { DataRow oRow = null; if (employeeNo1 != odRow["EMPLOYEENO"].ToString()) { odros1 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros1.Length <= nCount) continue; oRow = odros1[nCount]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.OtherItem) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Inc_Tax_Deduction)) oRow["IncomTaxAmount"] = odRow["CHANGEDAMOUNT"]; nCount = nCount + 1; employeeNo1 = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysLaonAmount = SalaryMonthly.GetEmpPaySlipDeductForLROld(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo12 = ""; DataRow[] odros12 = null; if (oSalaryMonthlysLaonAmount.Tables[0].Rows.Count > 0) { employeeNo12 = oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros12 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysLaonAmount.Tables[0].Rows) { DataRow oRow = null; if (employeeNo12 != odRow["EMPLOYEENO"].ToString()) { odros12 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros12.Length <= nCount) continue; oRow = odros12[nCount]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Miscellaneous) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Remain_Balance)) { oRow["LoanDescription"] = odRow["Description"]; oRow["LoanAmount"] = odRow["CHANGEDAMOUNT"]; } nCount = nCount + 1; employeeNo12 = odRow["EMPLOYEENO"].ToString(); } bool isDesigFromEmp = ConfigurationManager.GetBoolValue("designation", "desigfromdescriptiontext", EnumConfigurationType.Logic); //foreach (DataRow oRow in PayslipData.Rows) //{ // Employee oEmp = oEmps // .Where(o => o.EmployeeNo.ToUpper().Trim() == oRow["EMPLOYEENO"].ToString().ToUpper().Trim()) // .SingleOrDefault(); // if (oEmp != null) // { // if (isDesigFromEmp) // { // oRow["Designation"] = oEmp.DescriptionText; // } // else // { // Designation oDesg = oDesigs.Where(o => o.ID == oEmp.DesignationID).SingleOrDefault(); // if (oDesg != null) // { // oRow["Designation"] = oDesg.Name; // } // } // } //} loanDT.TableName = "PayrollDataSet_LoanData"; PayslipData.TableName = "PayrollDataSet_Payslip"; oFDST.Tables.Add(PayslipData); oFDST.Tables.Add(loanDT); form.ShowDlgForPaySlipCiti1(null, oFDST); } public void SKFExpencesPaySlip() { fReportViewer form = new fReportViewer(); DateTime salaryMonth = _selectedParameter.FromDate.Value; DateTime fromDate = GlobalFunctions.FirstDateOfMonth(salaryMonth); DateTime toDate = GlobalFunctions.LastDateOfMonth(salaryMonth); string sEmpID = _selectedParameter.ReportItem.INSQL; DataRow odr = null; string month = salaryMonth.ToString("MMM-yyyy"); DataSet oDataset = new DataSet(); DataSet oExpensesPSlipDSet = MiscellaneousDataset.GetExpensesPaySlipData(fromDate, toDate, sEmpID); PayrollDataSet.PayrollDataSet.SKFExpencesPaySlipDataTable skfExpTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.SKFExpencesPaySlipDataTable(); foreach (DataRow odrow in oExpensesPSlipDSet.Tables[0].Rows) { odr = skfExpTable.NewRow(); odr["EmpNo"] = odrow["EmployeeNo"]; odr["EmpName"] = odrow["EmpName"]; odr["Designation"] = odrow["Designation"]; odr["Department"] = odrow["Department"]; odr["AccountNo"] = odrow["AccountNo"]; odr["Tinno"] = odrow["TinNo"]; odr["JoiningDate"] = odrow["JoiningDate"]; odr["Grade"] = odrow["Grade"]; if (!odrow.IsNull("Utility Expenses")) { odr["UtilityExp"] = odrow["Utility Expenses"]; } if (!odrow.IsNull("Leave Fare Assistance Expense")) { odr["LFAExp"] = odrow["Leave Fare Assistance Expense"]; } if (!odrow.IsNull("Medical Expenses")) { odr["MedicalExp"] = odrow["Medical Expenses"]; } if (!odrow.IsNull("Servant Allowances")) { odr["ServantAllow"] = odrow["Servant Allowances"]; } if (!odrow.IsNull("Car Allowances/ Expenses")) { odr["CarAllow"] = odrow["Car Allowances/ Expenses"]; } if (!odrow.IsNull("Driver Allowances")) { odr["DriverAllow"] = odrow["Driver Allowances"]; } if (!odrow.IsNull("Security Allowances")) { odr["SecurityAllow"] = odrow["Security Allowances"]; } if (!odrow.IsNull("Worker’s Profit Participation Fund")) { odr["WPPFund"] = odrow["Worker’s Profit Participation Fund"]; } if (!odrow.IsNull("Manager’s Telephone Expenses")) { odr["ManagerTelExp"] = odrow["Manager’s Telephone Expenses"]; } if (!odrow.IsNull("Telephone Expenses (Mobile Bill)")) { odr["TelExp"] = odrow["Telephone Expenses (Mobile Bill)"]; } if (!odrow.IsNull("Mobile Set")) { odr["MobileSet"] = odrow["Mobile Set"]; } if (!odrow.IsNull("Group Insurance")) { odr["[GroupInsurance]"] = odrow["Group Insurance"]; } if (!odrow.IsNull("Other Expenses")) { odr["OtherExp"] = odrow["Other Expenses"]; } skfExpTable.Rows.Add(odr); } form.ShowDlgForSkfExpensesPSlip(skfExpTable, month); } public byte[] SKFExpencesPaySlip1(DateTime dDate, string sID) { fReportViewer form = new fReportViewer(); DateTime salaryMonth = dDate; DateTime fromDate = GlobalFunctions.FirstDateOfMonth(salaryMonth); DateTime toDate = GlobalFunctions.LastDateOfMonth(salaryMonth); string sEmpID = sID; DataRow odr = null; string month = salaryMonth.ToString("MMM-yyyy"); DataSet oDataset = new DataSet(); DataSet oExpensesPSlipDSet = MiscellaneousDataset.GetExpensesPaySlipData(fromDate, toDate, sEmpID); PayrollDataSet.PayrollDataSet.SKFExpencesPaySlipDataTable skfExpTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.SKFExpencesPaySlipDataTable(); foreach (DataRow odrow in oExpensesPSlipDSet.Tables[0].Rows) { odr = skfExpTable.NewRow(); odr["EmpNo"] = odrow["EmployeeNo"]; odr["EmpName"] = odrow["EmpName"]; odr["Designation"] = odrow["Designation"]; odr["Department"] = odrow["Department"]; if (!odrow.IsNull("Utility Expenses")) { odr["UtilityExp"] = odrow["Utility Expenses"]; } if (!odrow.IsNull("Leave Fare Assistance Expense")) { odr["LFAExp"] = odrow["Leave Fare Assistance Expense"]; } if (!odrow.IsNull("Medical Expenses")) { odr["MedicalExp"] = odrow["Medical Expenses"]; } if (!odrow.IsNull("Servant Allowances")) { odr["ServantAllow"] = odrow["Servant Allowances"]; } if (!odrow.IsNull("Car Allowances/ Expenses")) { odr["CarAllow"] = odrow["Car Allowances/ Expenses"]; } if (!odrow.IsNull("Driver Allowances")) { odr["DriverAllow"] = odrow["Driver Allowances"]; } if (!odrow.IsNull("Security Allowances")) { odr["SecurityAllow"] = odrow["Security Allowances"]; } if (!odrow.IsNull("Worker’s Profit Participation Fund")) { odr["WPPFund"] = odrow["Worker’s Profit Participation Fund"]; } if (!odrow.IsNull("Manager’s Telephone Expenses")) { odr["ManagerTelExp"] = odrow["Manager’s Telephone Expenses"]; } if (!odrow.IsNull("Telephone Expenses (Mobile Bill)")) { odr["TelExp"] = odrow["Telephone Expenses (Mobile Bill)"]; } if (!odrow.IsNull("Mobile Set")) { odr["MobileSet"] = odrow["Mobile Set"]; } if (!odrow.IsNull("Group Insurance")) { odr["[GroupInsurance]"] = odrow["Group Insurance"]; } if (!odrow.IsNull("Other Expenses")) { odr["OtherExp"] = odrow["Other Expenses"]; } skfExpTable.Rows.Add(odr); } return form.ShowDlgForSkfExpensesPSlip1(skfExpTable, month); } public void SKFSalaryPaySlip() { fReportViewer form = new fReportViewer(); DateTime salaryMonth = _selectedParameter.FromDate.Value; DateTime dmonth = GlobalFunctions.LastDateOfMonth(salaryMonth); string sEmpID = _selectedParameter.ReportItem.INSQL; string month = dmonth.ToString("MMM-yyyy"); DataRow odr = null; DataSet oDataset = new DataSet(); PayrollDataSet.PayrollDataSet.SkfSalaryPaySlipDataTable skfSPPdTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.SkfSalaryPaySlipDataTable(); DataSet oSalaryPSlipSet = MiscellaneousDataset.GetSalaryPaySlipData(dmonth, sEmpID); foreach (DataRow odrow in oSalaryPSlipSet.Tables[0].Rows) { odr = skfSPPdTable.NewRow(); odr["EmpNo"] = odrow["EMPLOYEENO"]; odr["EmpName"] = odrow["Name"]; odr["Designation"] = odrow["Designation"]; odr["Department"] = odrow["Department"]; if (!odrow.IsNull("Children Education Allowances")) { odr["ChildEduAllow"] = odrow["Children Education Allowances"]; } if (!odrow.IsNull("Medical Allowances")) { odr["MedicAllow"] = odrow["Medical Allowances"]; } if (!odrow.IsNull("Other Allowances")) { odr["OtherAllow"] = odrow["Other Allowances"]; } if (!odrow.IsNull("Manager's Incentive")) { odr["ManagerIncentive"] = odrow["Manager's Incentive"]; } if (!odrow.IsNull("Entertainment Allowances")) { odr["EntertainmentAllow"] = odrow["Entertainment Allowances"]; } if (!odrow.IsNull("Motor Bike (Penalty) Deduction")) { odr["MotorBike"] = odrow["Motor Bike (Penalty) Deduction"]; } if (!odrow.IsNull("Conveyance Allowances")) { odr["ConveyAllow"] = odrow["Conveyance Allowances"]; } if (!odrow.IsNull("Basic")) { odr["Basic"] = odrow["Basic"]; } if (!odrow.IsNull("PF")) { odr["PF"] = odrow["PF"]; } if (!odrow.IsNull("Provident Fund Loan")) { odr["PFloan"] = odrow["Provident Fund Loan"]; } if (!odrow.IsNull("Provident Fund Loan interest")) { odr["PFLoanInt"] = odrow["Provident Fund Loan interest"]; } if (!odrow.IsNull("House Rent Allowances")) { odr["HouseRent"] = odrow["House Rent Allowances"]; } if (!odrow.IsNull("PF")) { odr["PFCom"] = odrow["PF"]; } if (!odrow.IsNull("Gift for Anniversary")) { odr["GiftAnivers"] = odrow["Gift for Anniversary"]; } if (!odrow.IsNull("Income Tax")) { odr["IncomeTax"] = odrow["Income Tax"]; } if (!odrow.IsNull("Article Loan")) { odr["ArticleLoan"] = odrow["Article Loan"]; } skfSPPdTable.Rows.Add(odr); } form.ShowDlgForSkfSalaryPSlip(_selectedParameter.ReportItem, skfSPPdTable, month); } public byte[] SKFSalaryPaySlip1(DateTime dDate, string sID) { fReportViewer form = new fReportViewer(); DateTime salaryMonth = dDate; DateTime dmonth = GlobalFunctions.LastDateOfMonth(salaryMonth); string sEmpID = sID; string month = dmonth.ToString("MMM-yyyy"); DataRow odr = null; DataSet oDataset = new DataSet(); PayrollDataSet.PayrollDataSet.SkfSalaryPaySlipDataTable skfSPPdTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.SkfSalaryPaySlipDataTable(); DataSet oSalaryPSlipSet = MiscellaneousDataset.GetSalaryPaySlipData(dmonth, sEmpID); foreach (DataRow odrow in oSalaryPSlipSet.Tables[0].Rows) { odr = skfSPPdTable.NewRow(); odr["EmpNo"] = odrow["EMPLOYEENO"]; odr["EmpName"] = odrow["Name"]; odr["Designation"] = odrow["Designation"]; odr["Department"] = odrow["Department"]; if (!odrow.IsNull("Children Education Allowances")) { odr["ChildEduAllow"] = odrow["Children Education Allowances"]; } if (!odrow.IsNull("Medical Allowances")) { odr["MedicAllow"] = odrow["Medical Allowances"]; } if (!odrow.IsNull("Other Allowances")) { odr["OtherAllow"] = odrow["Other Allowances"]; } if (!odrow.IsNull("Manager's Incentive")) { odr["ManagerIncentive"] = odrow["Manager's Incentive"]; } if (!odrow.IsNull("Entertainment Allowances")) { odr["EntertainmentAllow"] = odrow["Entertainment Allowances"]; } if (!odrow.IsNull("Motor Bike (Penalty) Deduction")) { odr["MotorBike"] = odrow["Motor Bike (Penalty) Deduction"]; } if (!odrow.IsNull("Conveyance Allowances")) { odr["ConveyAllow"] = odrow["Conveyance Allowances"]; } if (!odrow.IsNull("Basic")) { odr["Basic"] = odrow["Basic"]; } if (!odrow.IsNull("PF")) { odr["PF"] = odrow["PF"]; } if (!odrow.IsNull("Provident Fund Loan")) { odr["PFloan"] = odrow["Provident Fund Loan"]; } if (!odrow.IsNull("Provident Fund Loan interest")) { odr["PFLoanInt"] = odrow["Provident Fund Loan interest"]; } if (!odrow.IsNull("House Rent Allowances")) { odr["HouseRent"] = odrow["House Rent Allowances"]; } if (!odrow.IsNull("PF")) { odr["PFCom"] = odrow["PF"]; } if (!odrow.IsNull("Gift for Anniversary")) { odr["GiftAnivers"] = odrow["Gift for Anniversary"]; } if (!odrow.IsNull("Income Tax")) { odr["IncomeTax"] = odrow["Income Tax"]; } if (!odrow.IsNull("Article Loan")) { odr["ArticleLoan"] = odrow["Article Loan"]; } skfSPPdTable.Rows.Add(odr); } return form.ShowDlgForSkfSalaryPSlip1(null, skfSPPdTable, month); } public byte[] ShowReport(DateTime salaryMonth2, string sEmpID2) { DataSet oFDST = new DataSet(); _oGratuityParams = ESBDefinition.Get(); Employee oEmployee = null; ObjectsTemplate oEmps = new ObjectsTemplate(); oEmps = Employee.Get(); List oDesigs = Designation.Get(EnumStatus.Regardless); fReportViewer form = new fReportViewer(); DateTime salaryMonth = salaryMonth2; string sEmpID = sEmpID2; ObjectsTemplate oSaProcess = new ObjectsTemplate(); oSaProcess = SalaryProcess.Get(GlobalFunctions.LastDateOfMonth(salaryMonth)); //bool bIsProcess = SalaryMonthly.IsSalaryProcessed(SessionManager.CurrentEmployee.ID, _SalaryMonth); DataSet oSalaryMonthlysGross = SalaryMonthly.GetEmpPaySlipGrossForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); PayrollDataSet.PayrollDataSet.PayslipDataTable PayslipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.PayslipDataTable(); PayrollDataSet.PayrollDataSet.LoanDataDataTable loanDT = new Payroll.Report.PayrollDataSet.PayrollDataSet.LoanDataDataTable(); //bool IsApproved = oSaProcess.GetBySMonth(GlobalFunctions.LastDateOfMonth(salaryMonth)); _dSalaryMonth = GlobalFunctions.LastDateOfMonth(salaryMonth); if (oSaProcess != null && oSaProcess.Count > 0 && oSalaryMonthlysGross.Tables[0].Rows.Count > 0) { if (oSaProcess[0].PaymentDate != DateTime.MinValue) { _dMonthEndDate = Convert.ToDateTime(oSaProcess[0].PaymentDate); } else { _dMonthEndDate = DateTime.MinValue; } } foreach (DataRow odRow in oSalaryMonthlysGross.Tables[0].Rows) { double dbl = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); if (dbl == 0) { continue; } DataRow oRow = this.GetItem(PayslipData, Convert.ToString(odRow["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(odRow["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]), Convert.ToInt32(odRow["ItemID"])); if (oRow == null) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Gross)) { oRow["Earning"] = odRow["CHANGEDAMOUNT"]; } else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Arrear)) { double dArrear = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); oRow["Arrear"] = dArrear; } else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.UnauthLeave)) { oRow["unAuthLeave"] = odRow["CHANGEDAMOUNT"]; } } int nCount = 0; DataSet oSalaryMonthlysDeduct = SalaryMonthly.GetEmpPaySlipDeductForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo = ""; DataRow[] odros = null; if (oSalaryMonthlysDeduct.Tables[0].Rows.Count > 0) { employeeNo = oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } double dGratuityAmount = 0; double dPFAmount = 0; string sTEmpEmpNo = ""; double nCurrPFAmount = 0; foreach (DataRow odRow in oSalaryMonthlysDeduct.Tables[0].Rows) { double dbl = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString()); if (dbl == 0) { continue; } DataRow oRow = null; if (employeeNo != odRow["EMPLOYEENO"].ToString()) { odros = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros.Length <= nCount) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } else oRow = odros[nCount]; oRow["DeducDescription"] = odRow["Description"]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Deductions)) { if (oRow["DeducDescription"].ToString().ToLower() == "pf contibution") oRow["DeducAmount"] = Convert.ToDouble(odRow["CHANGEDAMOUNT"]) * 2; else oRow["DeducAmount"] = odRow["CHANGEDAMOUNT"]; } oRow["DeducDescription"] = odRow["Description"]; //oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); if (sTEmpEmpNo == "" || sTEmpEmpNo != odRow["EMPLOYEENO"].ToString()) { nCurrPFAmount = 0; dPFAmount = 0; oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); DataRow[] odrosPF = oSalaryMonthlysDeduct.Tables[0].Select(" ItemCode='" + (int)EnumSalaryItemCode.PF_Contribution + "' AND EMPLOYEENO='" + odRow["EMPLOYEENO"].ToString() + "'"); if (odrosPF.Length > 0) { DataRow oRowPF = odrosPF[0]; nCurrPFAmount = Convert.ToDouble(oRowPF["CHANGEDAMOUNT"]); } if (oEmployee != null) { if (_oGratuityParams.Count > 0 && _oGratuityParams != null) { dGratuityAmount = GetGratuityAmount(_oGratuityParams, oEmployee, salaryMonth); } else { dGratuityAmount = 0; } dPFAmount = GetPFAmount(oEmployee, salaryMonth); } } oRow["Gratuity"] = dGratuityAmount; double nServiceLength = 0; if (oEmployee != null) nServiceLength = ServiceYears(GlobalFunctions.LastDateOfMonth(salaryMonth), oEmployee); if (nServiceLength > 5) { //oRow["PF"] = dPFAmount + nCurrPFAmount * 2; oRow["PF"] = dPFAmount + nCurrPFAmount; } else { oRow["PF"] = dPFAmount + nCurrPFAmount; } nCount = nCount + 1; employeeNo = odRow["EMPLOYEENO"].ToString(); sTEmpEmpNo = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysIncomeTax = SalaryMonthly.GetEmpPaySlipIncomeTaxAmountForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo1 = ""; DataRow[] odros1 = null; if (oSalaryMonthlysIncomeTax.Tables[0].Rows.Count > 0) { employeeNo1 = oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros1 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysIncomeTax.Tables[0].Rows) { DataRow oRow = null; if (employeeNo1 != odRow["EMPLOYEENO"].ToString()) { odros1 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros1.Length <= nCount) continue; oRow = odros1[nCount]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.OtherItem) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Inc_Tax_Deduction)) oRow["IncomTaxAmount"] = odRow["CHANGEDAMOUNT"]; nCount = nCount + 1; employeeNo1 = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysLaonAmount = SalaryMonthly.GetEmpPaySlipDeductForLR(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo12 = ""; DataRow[] odros12 = null; if (oSalaryMonthlysLaonAmount.Tables[0].Rows.Count > 0) { employeeNo12 = oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros12 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysLaonAmount.Tables[0].Rows) { DataRow oRow = null; if (employeeNo12 != odRow["EMPLOYEENO"].ToString()) { odros12 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros12.Length <= nCount) continue; oRow = odros12[nCount]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Miscellaneous) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Remain_Balance)) { oRow["LoanDescription"] = odRow["Description"]; oRow["LoanAmount"] = odRow["CHANGEDAMOUNT"]; } nCount = nCount + 1; employeeNo12 = odRow["EMPLOYEENO"].ToString(); } bool isDesigFromEmp = ConfigurationManager.GetBoolValue("designation", "desigfromdescriptiontext", EnumConfigurationType.Logic); foreach (DataRow oRow in PayslipData.Rows) { Employee oEmp = oEmps .Where(o => o.EmployeeNo.ToUpper().Trim() == oRow["EMPLOYEENO"].ToString().ToUpper().Trim()) .SingleOrDefault(); if (oEmp != null) { if (isDesigFromEmp) { oRow["Designation"] = oEmp.DescriptionText; } else { Designation oDesg = oDesigs.Where(o => o.ID == oEmp.DesignationID).SingleOrDefault(); if (oDesg != null) { oRow["Designation"] = oDesg.Name; } } } } loanDT.TableName = "PayrollDataSet_LoanData"; PayslipData.TableName = "PayrollDataSet_Payslip"; oFDST.Tables.Add(PayslipData); oFDST.Tables.Add(loanDT); return form.ShowDlgForPaySlipCiti2(null, oFDST); } public void BanglaPaySlipOld() { #region Initialize Components fReportViewer form = new fReportViewer(); DateTime salaryMonth = _selectedParameter.FromDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; ObjectsTemplate salarymonthlies = SalaryMonthly.Get(sEmpID, GlobalFunctions.LastDateOfMonth(salaryMonth)); DataSet oSalaryMonthlyDetails = SalaryMonthly.GetEmpPaySlipGrossForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); List oAllDeducts = AllowanceDeduction.Get(EnumStatus.Regardless); List oLeaves = Leave.Get(); List oEmployees = Employee.GetByEmpIDs(sEmpID); DataRow oDR = null; double totalGross = 0.0; PayrollDataSet.PayrollDataSet.BanglaPaySlipDataTable banglaPaySlipData = new PayrollDataSet.PayrollDataSet.BanglaPaySlipDataTable(); #region Calcullate Bangla Month string[] BanglaMonths = {"Rvbyqvwi","‡deªyqvix","gvP©","GwcÖj", "‡g","Ryb","RyjvB","AvMó", "‡m‡Þ¤^i","A‡±vei","b‡f¤^i","wW‡m¤^i"}; string month = BanglaMonths[salaryMonth.Month - 1]; #endregion //parameter = new ReportParameter("rptMonth", month); //parameters.Add(parameter); #endregion foreach (SalaryMonthly itemMonthly in salarymonthlies) { totalGross = 0.0; oDR = banglaPaySlipData.NewRow(); oDR["SalaryMonth"] = salaryMonth; oDR["EmpNo"] = itemMonthly.Employee.EmployeeNo; oDR["Name"] = itemMonthly.Employee.Name; oDR["Grade"] = itemMonthly.Employee.Grade.Name; oDR["Designation"] = itemMonthly.Employee.Designation.Name; oDR["DOfJoining"] = itemMonthly.Employee.JoiningDate; #region Gross Payment oDR["Basic"] = itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Basic_Salary) + +itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Basic_Salary); #region Calcullate Allowances // House rent code: 001 AllowanceDeduction oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "001"); oDR["HouseRent"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // Conveyance code: 002 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "002"); oDR["Transport"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // medical code: 003 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "003"); oDR["Medical"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // FoodAllowance code: 004 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "004"); oDR["Food"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // Attendence Bonus code: 010 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "010"); oDR["AttBon"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // Conduct Bonus code: 011 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "011"); oDR["ConductBonus"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // Production Bonus code: 009 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "009"); oDR["ProdBonus"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; #endregion totalGross = Convert.ToDouble(oDR["Basic"]) + Convert.ToDouble(oDR["HouseRent"]) + Convert.ToDouble(oDR["Medical"]) + Convert.ToDouble(oDR["Transport"]) + Convert.ToDouble(oDR["Food"]) + Convert.ToDouble(oDR["AttBon"]) + Convert.ToDouble(oDR["ConductBonus"]) + Convert.ToDouble(oDR["ProdBonus"]); // +Convert.ToDouble(oDR["SplAllow"]); oDR["MonthlyWages"] = totalGross; #endregion #region Day Calcullation oDR["WRDays"] = itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Total_Days); oDR["PRDays"] = itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Tot_Attend_Days); oDR["HolyDays"] = itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Total_HoliDays); oDR["DeducDays"] = itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Tot_UnauthLeave_Days); #endregion #region Leave Calcullation Leave currentLeave = null; currentLeave = oLeaves.SingleOrDefault(x => x.Code.ToUpper().Trim() == "CL"); oDR["CLDays"] = currentLeave != null ? itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Leave_Days, currentLeave.ID.Integer) : 0; currentLeave = oLeaves.SingleOrDefault(x => x.Code.ToUpper().Trim() == "SL"); oDR["SLDays"] = currentLeave != null ? itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Leave_Days, currentLeave.ID.Integer) : 0; currentLeave = oLeaves.SingleOrDefault(x => x.Code.ToUpper().Trim() == "EL"); oDR["ELDays"] = currentLeave != null ? itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Leave_Days, currentLeave.ID.Integer) : 0; currentLeave = oLeaves.SingleOrDefault(x => x.Code.ToUpper().Trim() == "ML"); oDR["MLDays"] = currentLeave != null ? itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Leave_Days, currentLeave.ID.Integer) : 0; currentLeave = oLeaves.SingleOrDefault(x => x.Code.ToUpper().Trim() == "PL"); oDR["PLDays"] = currentLeave != null ? itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Leave_Days, currentLeave.ID.Integer) : 0; currentLeave = oLeaves.SingleOrDefault(x => x.Code.ToUpper().Trim() == "LWP"); oDR["LWPDays"] = currentLeave != null ? itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Leave_Days, currentLeave.ID.Integer) : 0; currentLeave = oLeaves.SingleOrDefault(x => x.Code.ToUpper().Trim() == "L/OUT"); oDR["LOUTDays"] = currentLeave != null ? itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Leave_Days, currentLeave.ID.Integer) : 0; oDR["MTRDays"] = 0; // ?? What is This #endregion #region Overtime oDR["OTHours"] = itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Over_Time_Hours);// (item.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Over_Time_Hours, 1) <= 52) ? item.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Over_Time_Hours, 1) : 52; oDR["OTPayable"] = itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Over_Time_Amount); oDR["OTRate"] = Convert.ToDouble(oDR["OTHours"]) > 0 ? Math.Round(Convert.ToDouble(oDR["OTPayable"]) / Convert.ToDouble(oDR["OTHours"]), 2) : 0.0; #endregion #region Deductions // variable used if muliple basic deduction exist double deductBasic = 0; // UnAuthorize Leave Basic Deduct deductBasic += itemMonthly .GetAmount(EnumSalaryGroup.UnauthLeave, EnumSalaryItemCode.Basic_Salary); oDR["DeductAmnt"] = deductBasic; oDR["DeductPF"] = Convert.ToDouble(oDR["Basic"]) * 0.08; oDR["DeductSalaryAdvance"] = 0.0; oDR["NetDeductAmnt"] = Convert.ToDouble(oDR["DeductAmnt"]) + Convert.ToDouble(oDR["DeductPF"]) + Convert.ToDouble(oDR["DeductSalaryAdvance"]); #endregion // Gross + Overtime - Deductions oDR["NetWages"] = Convert.ToDouble(oDR["MonthlyWages"]) + Convert.ToDouble(oDR["OTPayable"]) - Convert.ToDouble(oDR["NetDeductAmnt"]); oDR["ProdBonusDescription"] = string.Empty; if (Convert.ToDouble(oDR["ProdBonus"]) > 0) { ProdBonusProcessEmp oPREmp = ProdBonusProcess.GetProdBonusEmp(itemMonthly.EmployeeID, salaryMonth.LastDateOfMonth()); oDR["ProdBonusDescription"] = oPREmp.Description; } banglaPaySlipData.Rows.Add(oDR); } //form.ShowDlgForBanglaPaySlipOverAllSummary(_selectedParameter.ReportItem, banglaPaySlipData, month); } public void BanglaPaySlip() { #region Initialize Components fReportViewer form = new fReportViewer(); DateTime salaryMonth = _selectedParameter.FromDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; ObjectsTemplate salarymonthlies = SalaryMonthly.Get(sEmpID, GlobalFunctions.LastDateOfMonth(salaryMonth)); DataSet oSalaryMonthlyDetails = SalaryMonthly.GetEmpPaySlipGrossForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); List oAllDeducts = AllowanceDeduction.Get(EnumStatus.Regardless); List oLeaves = Leave.Get(); List oEmployees = Employee.GetByEmpIDs(sEmpID); List oCards = AccessCard.Get(); DataRow oDR = null; double totalGross = 0.0; PayrollDataSet.PayrollDataSet.BanglaPaySlipNewDataTable banglaPaySlipData = new PayrollDataSet.PayrollDataSet.BanglaPaySlipNewDataTable(); PayrollDataSet.PayrollDataSet.BanglaPaySlipNewProdBonusDataTable banglaPaySlipProdData = new PayrollDataSet.PayrollDataSet.BanglaPaySlipNewProdBonusDataTable(); DataSet dsProdBonus = ProdBonusProcess.GetDetailItems(GlobalFunctions.LastDateOfMonth(salaryMonth)); if (dsProdBonus.Tables != null && dsProdBonus.Tables.Count > 0) { foreach (DataRow dRow in dsProdBonus.Tables[0].Rows) { DataRow ToRow = banglaPaySlipProdData.NewRow(); ToRow["EmployeeNo"] = dRow["EMPLOYEENO"]; ToRow["Name"] = dRow["Description"]; ToRow["Amount"] = dRow["Amount"]; banglaPaySlipProdData.Rows.Add(ToRow); } } #region Calcullate Bangla Month string[] BanglaMonths = {"Rvbyqvwi","‡deªyqvix","gvP©","GwcÖj", "‡g","Ryb","RyjvB","AvMó", "‡m‡Þ¤^i","A‡±vei","b‡f¤^i","wW‡m¤^i"}; string month = BanglaMonths[salaryMonth.Month - 1] + "," + salaryMonth.Year + "Bs gv‡mi †eZb I Ab¨vb¨ fvZvi cÖ‡`q wej t"; #endregion #endregion //SalaryProcess oProcess = SalaryProcess.Get(GlobalFunctions.LastDateOfMonth(salaryMonth)); foreach (SalaryMonthly itemMonthly in salarymonthlies) { totalGross = 0.0; oDR = banglaPaySlipData.NewRow(); string sDiv = ""; string sDivBangla = ""; if (itemMonthly.Employee.Department.Tier == 1) { sDiv = itemMonthly.Employee.Department.Name; } else if (itemMonthly.Employee.Department.Tier == 2) { sDiv = itemMonthly.Employee.Department.Parent.Name; } else if (itemMonthly.Employee.Department.Tier == 3) { sDiv = itemMonthly.Employee.Department.Parent.Parent.Name; } else if (itemMonthly.Employee.Department.Tier == 4) { sDiv = itemMonthly.Employee.Department.Parent.Parent.Parent.Name; } if (itemMonthly.Employee.Department.Tier == 4) { oDR["Line"] = itemMonthly.Employee.Department.Name; } oDR["Division"] = sDiv; oDR["BanglaDivision"] = sDivBangla; oDR["SalaryMonth"] = salaryMonth; oDR["EmpNo"] = itemMonthly.Employee.EmployeeNo; oDR["Name"] = itemMonthly.Employee.Name; oDR["Designation"] = itemMonthly.Employee.Designation.Name; oDR["DOfJoining"] = itemMonthly.Employee.JoiningDate.Day.ToString() + " " + BanglaMonths[salaryMonth.Month - 1] + " " + itemMonthly.Employee.JoiningDate.Year.ToString(); AccessCard ac = oCards.Find(x => x.ID.Integer == itemMonthly.Employee.CardID.Integer); oDR["CardNo"] = ac != null ? ac.CardNumber : string.Empty; #region Gross Payment oDR["BasicSalary"] = itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Basic_Salary) + +itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Basic_Salary); #region Calcullate Allowances // House rent code: 008 AllowanceDeduction oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "008"); oDR["HouseRent"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // Conveyance code: 010 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "010"); oDR["Conveynce"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // medical code: 011 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "011"); oDR["Medical"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // FoodAllowance code: 009 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "006"); oDR["Food"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // Attendence Bonus code: 001 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "001"); oDR["AttBon"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // Conduct Bonus code: 002 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "002"); oDR["ConductBonus"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; // Production Bonus code: 012 oAllDeduct = oAllDeducts.FirstOrDefault(x => x.Code.Trim() == "012"); oDR["ProdBonus"] = oAllDeduct != null ? itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) + itemMonthly.GetAmount(EnumSalaryGroup.Arrear, EnumSalaryItemCode.Allowance, oAllDeduct.ID.Integer) : 0; #endregion totalGross = Convert.ToDouble(oDR["BasicSalary"]) + Convert.ToDouble(oDR["HouseRent"]) + Convert.ToDouble(oDR["Medical"]) + Convert.ToDouble(oDR["Conveynce"]) + Convert.ToDouble(oDR["Food"]); oDR["NetPayment"] = totalGross; #endregion #region Day Calcullation oDR["TotalWorkDays"] = itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Total_Days); oDR["PresentDays"] = itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Tot_Attend_Days); oDR["HolidayDays"] = itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Total_HoliDays); oDR["AbsentDays"] = itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Tot_UnauthLeave_Days); #endregion oDR["DeductPF"] = Convert.ToDouble(oDR["BasicSalary"]) * 0.08; oDR["DeductSalaryAdvance"] = 0.0; double givenTaka = Convert.ToDouble(oDR["DeductPF"]) + Convert.ToDouble(oDR["DeductSalaryAdvance"]) + Convert.ToDouble(oDR["AbsentDays"]); givenTaka = totalGross - givenTaka; oDR["GivenSalary"] = givenTaka; #region Overtime oDR["OTHours"] = itemMonthly.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Over_Time_Hours);// (item.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Over_Time_Hours, 1) <= 52) ? item.GetAmount(EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Over_Time_Hours, 1) : 52; oDR["OTPayable"] = itemMonthly.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Over_Time_Amount); oDR["OTRate"] = Convert.ToDouble(oDR["OTHours"]) > 0 ? Math.Round(Convert.ToDouble(oDR["OTPayable"]) / Convert.ToDouble(oDR["OTHours"]), 2) : 0.0; #endregion #region Production Bonus int nCount = 0; if (dsProdBonus.Tables != null && dsProdBonus.Tables.Count > 0) { if (dsProdBonus.Tables[0] != null && dsProdBonus.Tables[0].Rows.Count > 0) { DataTable dt2 = new DataTable(); oDR["ProdBonus"] = 0; var accItems = dsProdBonus.Tables[0].AsEnumerable().Where(x => x["EMPLOYEENO"].ToString().Trim() == oDR["EmpNo"].ToString()); if (accItems.Count() > 0) dt2 = accItems.CopyToDataTable(); if (dt2 != null && dt2.Rows.Count > 0) { //int i = 1; foreach (DataRow dr in dt2.Rows) { // This is not needed as we show detail in a subreport //oDR["ProdBonusName" + i.ToString()] = dr["LineName"]; //oDR["ProdBonusAmount" + i.ToString()] = Convert.ToDouble(dr["Amount"]); oDR["ProdBonus"] = Convert.ToDouble(oDR["ProdBonus"]) + Convert.ToDouble(dr["Amount"]); //i++; } } } } #endregion #region Deductions // variable used if muliple basic deduction exist double deductBasic = 0; // UnAuthorize Leave Basic Deduct deductBasic += itemMonthly .GetAmount(EnumSalaryGroup.UnauthLeave, EnumSalaryItemCode.Basic_Salary); oDR["DeductAmnt"] = deductBasic; double totalTaka = givenTaka + Convert.ToDouble(oDR["AttBon"]) + Convert.ToDouble(oDR["ConductBonus"]) + Convert.ToDouble(oDR["ProdBonus"]) + Convert.ToDouble(oDR["OTPayable"]); oDR["TotalTaka"] = totalTaka; #endregion banglaPaySlipData.Rows.Add(oDR); } DataSet ds = new DataSet(); banglaPaySlipData.TableName = "PayrollDataSet_BanglaPaySlipNew"; ds.Tables.Add(banglaPaySlipData); DataSet dsSub = new DataSet(); banglaPaySlipProdData.TableName = "PayrollDataSet_BanglaPaySlipNewProdBonus"; dsSub.Tables.Add(banglaPaySlipProdData); string reportName = "Payroll.Report.RDLC.BanglaPSlip.rdlc"; List _parameters = new List(); ReportParameter parameter = new ReportParameter("rptMonth", month); _parameters = new List(); _parameters.Add(parameter); parameter = new ReportParameter("companyName", System.Configuration.ConfigurationSettings.AppSettings["companyBanglaName"]); _parameters.Add(parameter); parameter = new ReportParameter("SalalyMonthEng", salaryMonth.ToString("MMM-yyyy")); _parameters.Add(parameter); form.CommonReportView(_selectedParameter.ReportItem, ds, dsSub, reportName, _parameters, false); } public void ShowReportCiti1() { _oGratuityParams = ESBDefinition.Get(); Employee oEmployee = null; ObjectsTemplate oEmps = new ObjectsTemplate(); oEmps = Employee.Get(); ObjectsTemplate oLoanScheduls = new ObjectsTemplate(); oLoanScheduls = LoanSchedule.Get(); //ObjectsTemplate oLoanIssues = new ObjectsTemplate(); //oLoanIssues = LoanIssue.GetE Get(); fReportViewer form = new fReportViewer(); DateTime salaryMonth = _selectedParameter.FromDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; SalaryProcess oSaProcess = new SalaryProcess(); //bool bIsProcess = SalaryMonthly.IsSalaryProcessed(SessionManager.CurrentEmployee.ID, _SalaryMonth); DataSet oSalaryMonthlysGross = SalaryMonthly.GetEmpPaySlipGrossForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); PayrollDataSet.PayrollDataSet.PayslipDataTable PayslipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.PayslipDataTable(); //bool IsApproved = oSaProcess.GetBySMonth(GlobalFunctions.LastDateOfMonth(salaryMonth)); foreach (DataRow odRow in oSalaryMonthlysGross.Tables[0].Rows) { DataRow oRow = this.GetItem(PayslipData, Convert.ToString(odRow["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(odRow["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]), Convert.ToInt32(odRow["ItemID"])); if (oRow == null) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Gross)) oRow["Earning"] = odRow["CHANGEDAMOUNT"]; else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Arrear)) oRow["Arrear"] = odRow["CHANGEDAMOUNT"]; else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.UnauthLeave)) oRow["unAuthLeave"] = odRow["CHANGEDAMOUNT"]; } int nCount = 0; DataSet oSalaryMonthlysDeduct = SalaryMonthly.GetEmpPaySlipDeductForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo = ""; DataRow[] odros = null; if (oSalaryMonthlysDeduct.Tables[0].Rows.Count > 0) { employeeNo = oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysDeduct.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } //if(oSalaryMonthlysDeduct.Tables[0].Rows.Count>oSalaryMonthlysGross.Tables[0].Rows.Count) //{ // odros=new DataRow[oSalaryMonthlysDeduct.Tables[0].Rows.Count]; //} foreach (DataRow odRow in oSalaryMonthlysDeduct.Tables[0].Rows) { DataRow oRow = null; if (employeeNo != odRow["EMPLOYEENO"].ToString()) { odros = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros.Length <= nCount) { oRow = PayslipData.NewRow(); oRow = this.GrossMerge(oRow, odRow); PayslipData.Rows.Add(oRow); } else oRow = odros[nCount]; //if (odros.Length <= nCount) continue; //oRow = odros[nCount]; oRow["DeducDescription"] = odRow["Description"]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Deductions)) { if (oRow["DeducDescription"].ToString().ToLower() == "pf contibution") oRow["DeducAmount"] = Convert.ToDouble(odRow["CHANGEDAMOUNT"]) * 2; else oRow["DeducAmount"] = odRow["CHANGEDAMOUNT"]; } oEmployee = oEmps.Find(delegate(Employee oEmpItem) { return oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim(); }); //GetGratuityAmount(_oGratuityParams, oEmployee); // GetPFAmount(oEmployee); //Gratuity if (_oGratuityParams.Count > 0 && _oGratuityParams != null) { oRow["Gratuity"] = GetGratuityAmount(_oGratuityParams, oEmployee, salaryMonth); } else { oRow["Gratuity"] = 0; } oRow["PF"] = GetPFAmount(oEmployee, salaryMonth); #region Loan Issue ////Personal Loan //if ((Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Monthly_Installment) && ((Convert.ToInt32(odRow["ItemID"]) == 3))) //{ // loanAmounn = 0.0; // actuInterest = 0.0; // principleAmount = 0.0; // interest = 0.0; // balance = 0.0; // sattelmentAmount = 0.0; // LoanIssue oLIssue=LoanIssue.GetExistingLoan(ID.FromInteger(Convert.ToInt32(odRow["ItemID"])),oEmployee.ID); // //LoanIssue oLIssue = oLoanIssues.Find(delegate(LoanIssue item1) { return oEmployee.ID == item1.EmployeeID && item1.LoanID == ID.FromInteger(Convert.ToInt32(odRow["ItemID"])); }); // if (oLIssue != null) // { // loanAmounn = oLIssue.LoanAmount; // List oLSS = oLoanScheduls.FindAll(delegate(LoanSchedule oitem) { return oitem.LoanIssueID == oLIssue.ID; }); // if (oLSS.Count>0) // { // List oBeforeSMonths = oLSS.FindAll(delegate(LoanSchedule oitem) { return oitem.DueInstallmentDate <= GlobalFunctions.LastDateOfMonth(salaryMonth); }); // foreach (LoanSchedule oScedule in oBeforeSMonths) // { // actuInterest = actuInterest + oScedule.ActualInterest; // principleAmount = principleAmount + oScedule.InstallmentPrincipal; // interest = interest + oScedule.InstallmentInterest; // balance = balance + oScedule.OpeningBalance; // //oTemLoanSchedule.Add(oScedule); // } // } // sattelmentAmount = (loanAmounn + actuInterest) - (principleAmount + interest); // } // oRow["PersonalLoan"] = sattelmentAmount;//odRow["CHANGEDAMOUNT"]; //} //Vehicle Loan //if ((Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Monthly_Installment && (Convert.ToInt32(odRow["ItemID"]) == 4))) //{ // loanAmounn = 0.0; // actuInterest = 0.0; // principleAmount = 0.0; // interest = 0.0; // balance = 0.0; // sattelmentAmount = 0.0; // LoanIssue oLIssue=LoanIssue.GetExistingLoan(ID.FromInteger(Convert.ToInt32(odRow["ItemID"])),oEmployee.ID); // //LoanIssue oLIssue = oLoanIssues.Find(delegate(LoanIssue item1) { return oEmployee.ID == item1.EmployeeID && item1.LoanID == ID.FromInteger(Convert.ToInt32(odRow["ItemID"])); }); // if (oLIssue != null) // { // loanAmounn = oLIssue.LoanAmount; // List oLSS = oLoanScheduls.FindAll(delegate(LoanSchedule oitem) { return oitem.LoanIssueID == oLIssue.ID; }); // if (oLSS.Count > 0) // { // List oBeforeSMonths = oLSS.FindAll(delegate(LoanSchedule oitem) { return oitem.DueInstallmentDate <= GlobalFunctions.LastDateOfMonth(salaryMonth); }); // foreach (LoanSchedule oScedule in oBeforeSMonths) // { // actuInterest = actuInterest + oScedule.ActualInterest; // principleAmount = principleAmount + oScedule.InstallmentPrincipal; // interest = interest + oScedule.InstallmentInterest; // balance = balance + oScedule.OpeningBalance; // //oTemLoanSchedule.Add(oScedule); // } // } // sattelmentAmount = (loanAmounn + actuInterest) - (principleAmount + interest); // } // oRow["VechileLoan"] = sattelmentAmount;//odRow["CHANGEDAMOUNT"]; //} //House Loan //if ((Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Monthly_Installment && (Convert.ToInt32(odRow["ItemID"]) == 2))) //{ // loanAmounn = 0.0; // actuInterest = 0.0; // principleAmount = 0.0; // interest = 0.0; // balance = 0.0; // sattelmentAmount = 0.0; // LoanIssue oLIssue=LoanIssue.GetExistingLoan(ID.FromInteger(Convert.ToInt32(odRow["ItemID"])),oEmployee.ID); // //LoanIssue oLIssue = oLoanIssues.Find(delegate(LoanIssue item1) { return oEmployee.ID == item1.EmployeeID && item1.LoanID == ID.FromInteger(Convert.ToInt32(odRow["ItemID"])); }); // if (oLIssue != null) // { // loanAmounn = oLIssue.LoanAmount; // List oLSS = oLoanScheduls.FindAll(delegate(LoanSchedule oitem) { return oitem.LoanIssueID == oLIssue.ID; }); // if (oLSS.Count > 0) // { // List oBeforeSMonths = oLSS.FindAll(delegate(LoanSchedule oitem) { return oitem.DueInstallmentDate <= GlobalFunctions.LastDateOfMonth(salaryMonth); }); // foreach (LoanSchedule oScedule in oBeforeSMonths) // { // actuInterest = actuInterest + oScedule.ActualInterest; // principleAmount = principleAmount + oScedule.InstallmentPrincipal; // interest = interest + oScedule.InstallmentInterest; // balance = balance + oScedule.OpeningBalance; // //oTemLoanSchedule.Add(oScedule); // } // } // sattelmentAmount = (loanAmounn + actuInterest) - (principleAmount + interest); // } // oRow["HomeLoan"] = sattelmentAmount;//odRow["CHANGEDAMOUNT"]; //} //if ((Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.PF_Contribution && (Convert.ToInt32(odRow["ItemID"]) == (int)EnumSalaryItemCode.PF_Contribution))) //{ // oRow["PF"] = odRow["CHANGEDAMOUNT"]; //} #endregion nCount = nCount + 1; employeeNo = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysIncomeTax = SalaryMonthly.GetEmpPaySlipIncomeTaxAmountForOthers(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo1 = ""; DataRow[] odros1 = null; if (oSalaryMonthlysIncomeTax.Tables[0].Rows.Count > 0) { employeeNo1 = oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros1 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysIncomeTax.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysIncomeTax.Tables[0].Rows) { DataRow oRow = null; if (employeeNo1 != odRow["EMPLOYEENO"].ToString()) { odros1 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros1.Length <= nCount) continue; oRow = odros1[nCount]; //oRow["DeducDescription"] = odRow["Description"]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.OtherItem) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Inc_Tax_Deduction)) oRow["IncomTaxAmount"] = odRow["CHANGEDAMOUNT"]; nCount = nCount + 1; employeeNo = odRow["EMPLOYEENO"].ToString(); } nCount = 0; DataSet oSalaryMonthlysLaonAmount = SalaryMonthly.GetEmpPaySlipDeductForLR(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); string employeeNo12 = ""; DataRow[] odros12 = null; if (oSalaryMonthlysLaonAmount.Tables[0].Rows.Count > 0) { employeeNo12 = oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString(); odros12 = PayslipData.Select(" EmployeeNo='" + oSalaryMonthlysLaonAmount.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'"); } foreach (DataRow odRow in oSalaryMonthlysLaonAmount.Tables[0].Rows) { DataRow oRow = null; if (employeeNo12 != odRow["EMPLOYEENO"].ToString()) { odros12 = PayslipData.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'"); nCount = 0; } if (odros12.Length <= nCount) continue; oRow = odros12[nCount]; //oRow["DeducDescription"] = odRow["Description"]; if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Miscellaneous) && (Convert.ToInt32(odRow["ItemCode"]) == (int)EnumSalaryItemCode.Loan_Remain_Balance)) { oRow["LoanDescription"] = odRow["Description"]; oRow["LoanAmount"] = odRow["CHANGEDAMOUNT"]; } nCount = nCount + 1; employeeNo = odRow["EMPLOYEENO"].ToString(); } //if (IsApproved) //{ form.ShowDlgForPaySlipCiti(_selectedParameter.ReportItem, PayslipData); //} //else //{ // MessageBox.Show("This salary process is not approve for the month of " + salaryMonth.ToString("MMM yyyy"), "Salary Approved", MessageBoxButtons.OK, MessageBoxIcon.Information); //} } public void ReportOverAllSummary() { fReportViewer form = new fReportViewer(); DateTime salaryMonth = _selectedParameter.FromDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; string[] sEmp = sEmpID.Split(new char[] { ',' }); int nTotalEmp = sEmp.Count(); int nCount = 0; DataSet oSalaryMonthlys = SalaryMonthly.GetEmpOverAllSummaryGross(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); PayrollDataSet.PayrollDataSet.OverAllSummaryDataTable PayslipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.OverAllSummaryDataTable(); PayrollDataSet.PayrollDataSet.OverAllSummaryDataTable deducDataTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.OverAllSummaryDataTable(); foreach (DataRow odRow in oSalaryMonthlys.Tables[0].Rows) { DataRow oRow = this.GetItemForOverAll(PayslipData, (EnumSalaryGroup)Convert.ToInt32(odRow["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(odRow["ItemCode"]), Convert.ToInt32(odRow["ItemID"])); if (oRow == null) { oRow = PayslipData.NewRow(); oRow = this.GrossMergeForOverAll(oRow, odRow, nTotalEmp, salaryMonth); nCount = nCount + 1; PayslipData.Rows.Add(oRow); } if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Gross)) oRow["Earnings"] = odRow["Amount"]; else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.Arrear)) oRow["Arrear"] = odRow["Amount"]; else if ((Convert.ToInt32(odRow["ITEMGROUP"]) == (int)EnumSalaryGroup.UnauthLeave)) oRow["UnAuthLeave"] = odRow["Amount"]; } oSalaryMonthlys = SalaryMonthly.GetEmpOverAllSummaryDeduct(GlobalFunctions.LastDateOfMonth(salaryMonth), sEmpID); int deductRowCount = oSalaryMonthlys.Tables[0].Rows.Count; int addedDeductRowCount = 0; try { foreach (DataRow odRow in oSalaryMonthlys.Tables[0].Rows) { if (deductRowCount <= nCount) { DataRow oRow = PayslipData.Rows[addedDeductRowCount]; oRow["DeducDescription"] = odRow["DESCRIPTION"]; oRow["DeducAmount"] = odRow["Amount"]; deductRowCount--; addedDeductRowCount++; } else { DataRow oRow = PayslipData.NewRow(); oRow["DeducDescription"] = odRow["Description"]; oRow["DeducAmount"] = odRow["Amount"]; deductRowCount--; PayslipData.Rows.Add(oRow); } } } catch (Exception ex) { throw new Exception(ex.Message); } form.ShowDlgForPaySlipOverAllSummary(_selectedParameter.ReportItem, PayslipData); } } }