public override ReportDocument GenerateReport()
        {
            DataSet.Payroll_ORSOStatement dataSet = new DataSet.Payroll_ORSOStatement();
            DataSet.Payroll_ORSOStatement.ExistingMemberDataTable existingORSO;
            DataSet.Payroll_ORSOStatement.ORSOPlanDataTable       orsoPlan;

            existingORSO = dataSet.ExistingMember;

            orsoPlan = dataSet.ORSOPlan;



            if (PayPeriodFr.Ticks != 0 && PayPeriodTo.Ticks != 0 && EmpList != null)
            {
                string strPrintPeriod = PayPeriodFr.ToString("yyyy-MM-dd") + " - " + PayPeriodTo.ToString("yyyy-MM-dd");


                DBFilter payPeriodFilter = new DBFilter();
                payPeriodFilter.add(new Match("pp.PayPeriodFr", "<=", PayPeriodTo));
                payPeriodFilter.add(new Match("pp.PayPeriodTo", ">=", PayPeriodFr));

                foreach (EEmpPersonalInfo empInfo in EmpList)
                {
                    EEmpPersonalInfo.db.select(dbConn, empInfo);



                    DBFilter empPayrollFilter = new DBFilter();
                    empPayrollFilter.add(new Match("EmpID", empInfo.EmpID));
                    empPayrollFilter.add(new IN("PayPeriodID", "Select PayPeriodID from PayrollPeriod pp", payPeriodFilter));


                    DBFilter orsoRecordFilter = new DBFilter();
                    orsoRecordFilter.add(new IN("EmpPayrollID", "Select EmpPayrollID from EmpPayroll", empPayrollFilter));
                    orsoRecordFilter.add(new Match("ORSOPlanID", ORSOPlanID));
                    orsoRecordFilter.add("ORSORecPeriodFr", true);
                    orsoRecordFilter.add("ORSORecPeriodTo", true);
                    ArrayList orsoRecords = EORSORecord.db.select(dbConn, orsoRecordFilter);


                    DataSet.Payroll_ORSOStatement.ExistingMemberRow existingORSORow = null;
                    foreach (EORSORecord orsoRecord in orsoRecords)
                    {
                        EORSOPlan orsoPlanObject = new EORSOPlan();
                        orsoPlanObject.ORSOPlanID = orsoRecord.ORSOPlanID;
                        if (EORSOPlan.db.select(dbConn, orsoPlanObject))
                        {
                            if (orsoPlan.Select("ORSOPlanID=" + orsoPlanObject.ORSOPlanID).Length == 0)
                            {
                                DataSet.Payroll_ORSOStatement.ORSOPlanRow orsoPlanRow = orsoPlan.NewORSOPlanRow();
                                orsoPlanRow.ORSOPlanID          = orsoPlanObject.ORSOPlanID;
                                orsoPlanRow.ORSOPlanCode        = orsoPlanObject.ORSOPlanCode;
                                orsoPlanRow.ORSOPlanCompanyName = orsoPlanObject.ORSOPlanCompanyName;
                                orsoPlanRow.ORSOPlanPayCenter   = orsoPlanObject.ORSOPlanPayCenter;
                                orsoPlanRow.ORSOPlanSchemeNo    = orsoPlanObject.ORSOPlanSchemeNo;
                                orsoPlanRow.ORSOPlanDesc        = orsoPlanObject.ORSOPlanDesc;

                                orsoPlan.Rows.Add(orsoPlanRow);
                            }
                        }
                        EEmpPayroll empPayroll = new EEmpPayroll();
                        empPayroll.EmpPayrollID = orsoRecord.EmpPayrollID;
                        EEmpPayroll.db.select(dbConn, empPayroll);
                        EPayrollPeriod payrollPeriod = new EPayrollPeriod();
                        payrollPeriod.PayPeriodID = empPayroll.PayPeriodID;
                        EPayrollPeriod.db.select(dbConn, payrollPeriod);

                        {
                            if (existingORSORow == null)
                            {
                                existingORSORow = existingORSO.NewExistingMemberRow();
                                LoadExistingMemberRowInfo(empInfo, orsoRecord, existingORSORow);
                            }
                            else
                            {
                                if (!(existingORSORow.EmpID == empInfo.EmpID && existingORSORow.PeriodFrom.Equals(orsoRecord.ORSORecPeriodFr) && existingORSORow.PeriodTo.Equals(orsoRecord.ORSORecPeriodTo)))
                                {
                                    existingORSO.Rows.Add(existingORSORow);
                                    existingORSORow = existingORSO.NewExistingMemberRow();
                                    LoadExistingMemberRowInfo(empInfo, orsoRecord, existingORSORow);
                                }
                            }

                            existingORSORow.RelevantIncome += orsoRecord.ORSORecActRI;
                            existingORSORow.EE             += orsoRecord.ORSORecActEE;
                            existingORSORow.ER             += orsoRecord.ORSORecActER;
                        }
                    }

                    if (existingORSORow != null)
                    {
                        existingORSO.Rows.Add(existingORSORow);
                    }
                }



                if (reportDocument == null)
                {
                    reportDocument = new ReportTemplate.Report_Payroll_PFundStatement();
                }
                else
                {
                }


                reportDocument.SetDataSource(dataSet);
                reportDocument.SetParameterValue("ContributionPeriod", PayPeriodFr.ToString("yyyy-MM-dd") + " - " + PayPeriodTo.ToString("yyyy-MM-dd"));
                return(reportDocument);
            }
            else
            {
                return(null);
            }
        }
        //public System.Data.DataSet GenerateDataSet()
        //{

        //DataSet.Payroll_MPFRemittanceStatement dataSet = new DataSet.Payroll_MPFRemittanceStatement();

        //DataSet.Payroll_MPFRemittanceStatement.ExistingMemberDataTable existingMPF = dataSet.ExistingMember;
        //DataSet.Payroll_MPFRemittanceStatement.NewJoinMemberDataTable newJoinMPF = dataSet.NewJoinMember;
        //additionalMPF = dataSet.AdditionalMember;

        //DataSet.Payroll_MPFRemittanceStatement.MPFPlanDataTable mpfPlan = dataSet.MPFPlan;
        //DataSet.Payroll_MPFRemittanceStatement.MPFSchemeDataTable mpfScheme = dataSet.MPFScheme;

        //string strPrintPeriod = PayPeriodFr.ToString("yyyy-MM-dd") + " - " + PayPeriodTo.ToString("yyyy-MM-dd");

        //DBFilter payPeriodFilter = new DBFilter();
        //payPeriodFilter.add(new Match("pp.PayPeriodFr", "<=", PayPeriodTo));
        //payPeriodFilter.add(new Match("pp.PayPeriodTo", ">=", PayPeriodFr));


        //foreach (EEmpPersonalInfo empInfo in EmpList)
        //{

        //EEmpPersonalInfo.db.select(dbConn, empInfo);



        //DBFilter empPayrollFilter = new DBFilter();
        //empPayrollFilter.add(new Match("EmpID", empInfo.EmpID));
        //empPayrollFilter.add(new IN("PayPeriodID", "Select PayPeriodID from PayrollPeriod pp", payPeriodFilter));


        //DBFilter mpfRecordFilter = new DBFilter();
        //mpfRecordFilter.add(new IN("EmpPayrollID", "Select EmpPayrollID from EmpPayroll", empPayrollFilter));
        //mpfRecordFilter.add(new Match("MPFPlanID", MPFPlanID));
        //mpfRecordFilter.add("MPfRecPeriodFr", true);
        //mpfRecordFilter.add("MPfRecPeriodTo", true);
        //ArrayList mpfRecords = EMPFRecord.db.select(dbConn, mpfRecordFilter);


        //DataSet.Payroll_MPFRemittanceStatement.ExistingMemberRow existingMPFRow = null;
        //DataSet.Payroll_MPFRemittanceStatement.NewJoinMemberRow newJoinMPFRow = null;
        //foreach (EMPFRecord mpfRecord in mpfRecords)
        //{
        //    EMPFPlan mpfPlanObject = new EMPFPlan();
        //    mpfPlanObject.MPFPlanID = mpfRecord.MPFPlanID;
        //    if (EMPFPlan.db.select(dbConn, mpfPlanObject))
        //    {

        //        if (mpfPlan.Select("MPFPlanID=" + mpfPlanObject.MPFPlanID).Length == 0)
        //        {
        //            DataSet.Payroll_MPFRemittanceStatement.MPFPlanRow mpfPlanRow = mpfPlan.NewMPFPlanRow();
        //            mpfPlanRow.MPFPlanID = mpfPlanObject.MPFPlanID;
        //            mpfPlanRow.MPFPlanCode = mpfPlanObject.MPFPlanCode;
        //            mpfPlanRow.MPFPlanCompanyAddress = mpfPlanObject.MPFPlanCompanyAddress;
        //            mpfPlanRow.MPFPlanCompanyName = mpfPlanObject.MPFPlanCompanyName;
        //            mpfPlanRow.MPFPlanContactName = mpfPlanObject.MPFPlanContactName;
        //            mpfPlanRow.MPFPlanContactNo = mpfPlanObject.MPFPlanContactNo;
        //            mpfPlanRow.MPFPlanDesc = mpfPlanObject.MPFPlanDesc;
        //            mpfPlanRow.MPFPlanParticipationNo = mpfPlanObject.MPFPlanParticipationNo;
        //            mpfPlanRow.MPFSchemeID = mpfPlanObject.MPFSchemeID;
        //            if (!string.IsNullOrEmpty(mpfPlanObject.MPFPlanExtendData))
        //            {
        //                System.Xml.XmlNodeList payCenterList = Utility.GetXmlDocumentByDataString(mpfPlanObject.MPFPlanExtendData).DocumentElement.GetElementsByTagName("MPFPlanPayCenter");
        //                if (payCenterList.Count > 0)
        //                {
        //                    mpfPlanRow.MPFHSBCPayCenter = payCenterList[0].InnerText;
        //                }
        //            }
        //            EMPFScheme mpfSchemeObject = new EMPFScheme();
        //            mpfSchemeObject.MPFSchemeID = mpfPlanObject.MPFSchemeID;
        //            if (EMPFScheme.db.select(dbConn, mpfSchemeObject))
        //            {
        //                if (mpfScheme.Select("MPFSchemeID=" + mpfSchemeObject.MPFSchemeID).Length == 0)
        //                {

        //                    DataSet.Payroll_MPFRemittanceStatement.MPFSchemeRow schemeRow = mpfScheme.NewMPFSchemeRow();
        //                    schemeRow.MPFSchemeCode = mpfSchemeObject.MPFSchemeCode;
        //                    schemeRow.MPFSchemeDesc = mpfSchemeObject.MPFSchemeDesc;
        //                    schemeRow.MPFSchemeID = mpfSchemeObject.MPFSchemeID;
        //                    mpfScheme.Rows.Add(schemeRow);
        //                }
        //            }
        //            mpfPlan.Rows.Add(mpfPlanRow);
        //        }
        //    }
        //    EEmpPayroll empPayroll = new EEmpPayroll();
        //    empPayroll.EmpPayrollID = mpfRecord.EmpPayrollID;
        //    EEmpPayroll.db.select(dbConn, empPayroll);
        //    EPayrollPeriod payrollPeriod = new EPayrollPeriod();
        //    payrollPeriod.PayPeriodID = empPayroll.PayPeriodID;
        //    EPayrollPeriod.db.select(dbConn, payrollPeriod);

        //    if (mpfRecord.MPFRecType.Equals("N"))
        //    {
        //        if (newJoinMPFRow == null)
        //        {
        //            newJoinMPFRow = newJoinMPF.NewNewJoinMemberRow();
        //            LoadNewJoinMemberRowInfo(empInfo, mpfRecord, newJoinMPFRow);
        //        }
        //        else
        //        {
        //            if (!(newJoinMPFRow.EmpID == empInfo.EmpID && newJoinMPFRow.PeriodFrom.Equals(mpfRecord.MPFRecPeriodFr) && newJoinMPFRow.PeriodTo.Equals(mpfRecord.MPFRecPeriodTo)))
        //            {
        //                newJoinMPF.Rows.Add(newJoinMPFRow);
        //                newJoinMPFRow = newJoinMPF.NewNewJoinMemberRow();
        //                LoadNewJoinMemberRowInfo(empInfo, mpfRecord, newJoinMPFRow);
        //            }
        //        }

        //        newJoinMPFRow.RelevantIncome += mpfRecord.MPFRecActMCRI;
        //        newJoinMPFRow.MCEE += mpfRecord.MPFRecActMCEE;
        //        newJoinMPFRow.VCEE += mpfRecord.MPFRecActVCEE;
        //        newJoinMPFRow.MCER += mpfRecord.MPFRecActMCER;
        //        newJoinMPFRow.VCER += mpfRecord.MPFRecActVCER;

        //    }
        //    else if (mpfRecord.MPFRecType.Equals("A"))
        //    {
        //        if (newJoinMPFRow != null)
        //            if (newJoinMPFRow.EmpID == empInfo.EmpID)
        //            {
        //                if (!(newJoinMPFRow.PeriodFrom.Equals(mpfRecord.MPFRecPeriodFr) && newJoinMPFRow.PeriodTo.Equals(mpfRecord.MPFRecPeriodTo)))
        //                {
        //                    newJoinMPF.Rows.Add(newJoinMPFRow);
        //                    newJoinMPFRow = newJoinMPF.NewNewJoinMemberRow();
        //                    LoadNewJoinMemberRowInfo(empInfo, mpfRecord, newJoinMPFRow);

        //                }
        //                newJoinMPFRow.RelevantIncome += mpfRecord.MPFRecActMCRI;
        //                newJoinMPFRow.MCEE += mpfRecord.MPFRecActMCEE;
        //                newJoinMPFRow.VCEE += mpfRecord.MPFRecActVCEE;
        //                newJoinMPFRow.MCER += mpfRecord.MPFRecActMCER;
        //                newJoinMPFRow.VCER += mpfRecord.MPFRecActVCER;
        //            }

        //        if (existingMPFRow != null)
        //            if (existingMPFRow.EmpID == empInfo.EmpID)
        //            {
        //                if (!(existingMPFRow.PeriodFrom.Equals(mpfRecord.MPFRecPeriodFr) && existingMPFRow.PeriodTo.Equals(mpfRecord.MPFRecPeriodTo)))
        //                {
        //                    existingMPF.Rows.Add(existingMPFRow);
        //                    existingMPFRow = existingMPF.NewExistingMemberRow();
        //                    LoadExistingMemberRowInfo(empInfo, mpfRecord, existingMPFRow);
        //                }

        //                existingMPFRow.RelevantIncome += mpfRecord.MPFRecActMCRI;
        //                existingMPFRow.MCEE += mpfRecord.MPFRecActMCEE;
        //                existingMPFRow.VCEE += mpfRecord.MPFRecActVCEE;
        //                existingMPFRow.MCER += mpfRecord.MPFRecActMCER;
        //                existingMPFRow.VCER += mpfRecord.MPFRecActVCER;
        //            }

        //    }
        //    else
        //    {
        //        if (existingMPFRow == null)
        //        {
        //            existingMPFRow = existingMPF.NewExistingMemberRow();
        //            LoadExistingMemberRowInfo(empInfo, mpfRecord, existingMPFRow);

        //        }
        //        else
        //        {
        //            if (!(existingMPFRow.EmpID == empInfo.EmpID && existingMPFRow.PeriodFrom.Equals(mpfRecord.MPFRecPeriodFr) && existingMPFRow.PeriodTo.Equals(mpfRecord.MPFRecPeriodTo)))
        //            {
        //                existingMPF.Rows.Add(existingMPFRow);
        //                existingMPFRow = existingMPF.NewExistingMemberRow();
        //                LoadExistingMemberRowInfo(empInfo, mpfRecord, existingMPFRow);
        //            }
        //        }

        //        existingMPFRow.RelevantIncome += mpfRecord.MPFRecActMCRI;
        //        existingMPFRow.MCEE += mpfRecord.MPFRecActMCEE;
        //        existingMPFRow.VCEE += mpfRecord.MPFRecActVCEE;
        //        existingMPFRow.MCER += mpfRecord.MPFRecActMCER;
        //        existingMPFRow.VCER += mpfRecord.MPFRecActVCER;
        //    }
        //}
        //if (existingMPFRow != null)
        //{
        //    existingMPF.Rows.Add(existingMPFRow);
        //}

        //if (newJoinMPFRow != null)
        //{
        //    newJoinMPF.Rows.Add(newJoinMPFRow);
        //}


        //}
        //return dataSet;
        //}

        public override ReportDocument GenerateReport()
        {
            if (PayPeriodFr.Ticks != 0 && PayPeriodTo.Ticks != 0 && EmpList != null)
            {
                MPFFile.GenericMPFFile mpfFile = new MPFFile.GenericMPFFile(dbConn);
                mpfFile.LoadMPFFileDetail(EmpList, MPFPlanID, PayPeriodFr, PayPeriodTo);
                System.Data.DataSet dataSet = mpfFile.CreateRemittanceStatementDataSet();

                if (reportDocument == null)
                {
                    if (mpfFile.MPFSchemeTrusteeCode.Equals("HSBC") || mpfFile.MPFSchemeTrusteeCode.Equals("HangSeng"))
                    {
                        reportDocument = new ReportTemplate.Report_Payroll_MPFRemittanceStatement_HSBC();
                    }
                    else if (mpfFile.MPFSchemeTrusteeCode.Equals("AIA"))
                    {
                        reportDocument = new ReportTemplate.Report_Payroll_MPFRemittanceStatement_AIA();
                    }
                    else if (mpfFile.MPFSchemeTrusteeCode.Equals("AXA"))
                    {
                        reportDocument = new ReportTemplate.Report_Payroll_MPFRemittanceStatement_AXA();
                    }
                    else if (mpfFile.MPFSchemeTrusteeCode.Equals("BOCI"))
                    {
                        reportDocument = new ReportTemplate.Report_Payroll_MPFRemittanceStatement_BOCI();
                    }
                    else
                    {
                        reportDocument = new ReportTemplate.Report_Payroll_MPFRemittanceStatement();
                    }
                }
                else
                {
                }


                reportDocument.SetDataSource(dataSet);
                //foreach (ReportDocument o in reportDocument.Subreports)
                //{
                //    o.SetDataSource(dataSet);
                //}

                reportDocument.SetParameterValue("ContributionPeriod", PayPeriodFr.ToString("yyyy-MM-dd") + " - " + PayPeriodTo.ToString("yyyy-MM-dd"));
                reportDocument.SetParameterValue("ContributionPeriodFrom", PayPeriodFr);
                reportDocument.SetParameterValue("ContributionPeriodTo", PayPeriodTo);
                reportDocument.SetParameterValue("TotalAdditionalEmployeeMC", mpfFile.TotalAdditionalEmployeeMC);
                reportDocument.SetParameterValue("TotalAdditionalEmployeeVC", mpfFile.TotalAdditionalEmployeeVC);
                reportDocument.SetParameterValue("TotalBackpayEmployeeMC", mpfFile.TotalBackPaymentEmployeeMC);
                reportDocument.SetParameterValue("TotalBackpayEmployeeVC", mpfFile.TotalBackPaymentEmployeeVC);
                reportDocument.SetParameterValue("TotalExistingEmployeeMC", mpfFile.TotalExistingEmployeeMC);
                reportDocument.SetParameterValue("TotalExistingEmployeeVC", mpfFile.TotalExistingEmployeeVC);
                reportDocument.SetParameterValue("TotalNewJoinEmployeeMC", mpfFile.TotalNewJoinEmployeeMC);
                reportDocument.SetParameterValue("TotalNewJoinEmployeeVC", mpfFile.TotalNewJoinEmployeeVC);

                if (mpfFile.MPFSchemeTrusteeCode.Equals("AIA"))
                {
                    reportDocument.SetParameterValue("ChequeNo", this.ChequeNo);
                }

                return(reportDocument);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        //public void LoadBankFileDetail(string MPFFileFullPath)
        //{
        //    FileInfo fileInfo = new FileInfo(MPFFileFullPath);
        //    if (fileInfo.Length % 80 != 0)
        //        throw new Exception("Incorrect file size");

        //    StreamReader mpfFileStream = fileInfo.OpenText();
        //    char[] charRead = new char[80];

        //    int lineNo = 0;

        //    try
        //    {
        //        while (mpfFileStream.Read(charRead, 0, 80) > 0)
        //        {
        //            string line = new string(charRead);
        //            lineNo++;

        //            if (lineNo == 1)
        //            {
        //                string[] mpfFileHeader1 = new string[7];
        //                mpfFileHeader1[0] = line.Substring(0, 1);
        //                mpfFileHeader1[1] = line.Substring(1, 18);
        //                mpfFileHeader1[2] = line.Substring(19, 28);
        //                mpfFileHeader1[3] = line.Substring(47, 16);
        //                mpfFileHeader1[4] = line.Substring(63, 3);
        //                mpfFileHeader1[5] = line.Substring(66, 8);
        //                mpfFileHeader1[6] = line.Substring(74, 6);

        //                if (!mpfFileHeader1[0].Equals("S"))
        //                    throw new Exception("Invalid file header on line 1");

        //                RemoteProfileID = mpfFileHeader1[1].Trim();
        //                TransactionReference = mpfFileHeader1[3].Trim();
        //                if (!DateTime.TryParseExact(mpfFileHeader1[5] + mpfFileHeader1[6], "yyyyMMddHHmmss", null, System.Globalization.DateTimeStyles.None, out TransactionTime))
        //                    TransactionTime = TransactionTime = AppUtils.ServerDateTime();

        //            }
        //            else
        //            {
        //                string[] bankFileDetailRecord = new string[10];

        //                bankFileDetailRecord[0] = line.Substring(0, 1);
        //                bankFileDetailRecord[1] = line.Substring(1, 12);
        //                bankFileDetailRecord[2] = line.Substring(13, 20);
        //                bankFileDetailRecord[3] = line.Substring(33, 3);
        //                bankFileDetailRecord[4] = line.Substring(36, 3);
        //                bankFileDetailRecord[5] = line.Substring(39, 9);
        //                bankFileDetailRecord[6] = line.Substring(48, 10);
        //                bankFileDetailRecord[7] = line.Substring(58, 4);
        //                bankFileDetailRecord[8] = line.Substring(62, 6);
        //                bankFileDetailRecord[9] = line.Substring(68, 12);

        //                GenericBankFileDetail bankFileDetail = new GenericBankFileDetail();
        //                if (!bankFileDetailRecord[0].Equals(" "))
        //                    throw new Exception("Invalid record header on record detail" + " (line " + lineNo + ")");

        //                bankFileDetail.EmpNo = bankFileDetailRecord[1] + bankFileDetailRecord[8];
        //                bankFileDetail.EmpNo = bankFileDetail.EmpNo.Trim();
        //                bankFileDetail.EmpBankAccountHolderName = bankFileDetailRecord[2].Trim();
        //                bankFileDetail.BankCode = bankFileDetailRecord[3].Trim();
        //                bankFileDetail.BranchCode = bankFileDetailRecord[4].Trim();
        //                bankFileDetail.AccountNo = bankFileDetailRecord[5].Trim();
        //                double tmpRecordAmount = 0;
        //                if (!double.TryParse(bankFileDetailRecord[6].Insert(8, "."), out tmpRecordAmount))
        //                    throw new Exception("Invalid amount on record detail" + " (line " + lineNo + ")");
        //                bankFileDetail.Amount = tmpRecordAmount;

        //                int valueDateNumeric = 0;
        //                if (m_PlanCode == "F" || m_PlanCode == "G")
        //                {
        //                    if (!bankFileDetailRecord[7].Trim().Equals(string.Empty))
        //                        throw new Exception("Invalid value date on record detail" + " (line " + lineNo + ")");
        //                }
        //                else
        //                {
        //                    if (!int.TryParse(bankFileDetailRecord[7], out valueDateNumeric))
        //                        throw new Exception("Invalid value date on record detail" + " (line " + lineNo + ")");
        //                    int days = valueDateNumeric / 100;
        //                    int month = valueDateNumeric % 100;
        //                    bankFileDetail.ValueDate = new DateTime(currentDateTime.Year, month, days);
        //                    //  find a value date which is nearest to the current date
        //                    if (bankFileDetail.ValueDate < currentDateTime.AddDays(-180))
        //                        //  to prevent 29 Feb issue, use "new DateTime" to re-assign the value
        //                        bankFileDetail.ValueDate = new DateTime(currentDateTime.Year + 1, month, days);
        //                    if (bankFileDetail.ValueDate.Day != days && bankFileDetail.ValueDate.Month != month)
        //                        throw new Exception("Invalid value date on record detail" + " (line " + lineNo + ")");

        //                }
        //                m_TotalAmount += bankFileDetail.Amount;
        //                BankFileDetails.Add(bankFileDetail);
        //            }
        //        }

        //        if (m_TotalAmount - tmpHeaderTotalAmount >= 0.01 || RecordCount != tmpHeaderRecordCount)
        //            throw new Exception("Total Amount / Record Count does not match with File Header");
        //    }
        //    finally
        //    {
        //        mpfFileStream.Close();
        //    }
        //}
        public override FileInfo GenerateMPFFile()
        {
            string mpfFileData = string.Empty;

            // get Form No
            if (MPFSchemeCode.Equals("MT00261", StringComparison.CurrentCultureIgnoreCase))
            {
                FormNo = "INB1";
            }
            else if (MPFSchemeCode.Equals("MT00245", StringComparison.CurrentCultureIgnoreCase))
            {
                FormNo = "INB2";
            }
            else if (MPFSchemeCode.Equals("MT00512", StringComparison.CurrentCultureIgnoreCase))
            {
                FormNo = "INB7";
            }
            else if (MPFSchemeCode.Equals("MT00555", StringComparison.CurrentCultureIgnoreCase))
            {
                FormNo = "INBA";
            }
            else if (MPFSchemeCode.Equals("MT0027A", StringComparison.CurrentCultureIgnoreCase))
            {
                FormNo = "HAB1";
            }
            else if (MPFSchemeCode.Equals("MT00253", StringComparison.CurrentCultureIgnoreCase))
            {
                FormNo = "HAB2";
            }
            else if (MPFSchemeCode.Equals("MT00520", StringComparison.CurrentCultureIgnoreCase))
            {
                FormNo = "HAB7";
            }
            else if (MPFSchemeCode.Equals("MT00563", StringComparison.CurrentCultureIgnoreCase))
            {
                FormNo = "HABA";
            }
            else
            {
                FormNo = "    ";
            }
            // get Employer ID
            System.Xml.XmlNodeList mpfEmployerIDNode = HROne.CommonLib.Utility.GetXmlDocumentByDataString(MPFPlanExtendXMLString).GetElementsByTagName("MPFPlanEmployerID");
            if (mpfEmployerIDNode.Count > 0)
            {
                m_EmployerID = mpfEmployerIDNode[0].InnerText.PadRight(8).Substring(0, 8);
            }
            else
            {
                m_EmployerID = string.Empty.PadRight(8);
            }


            System.Xml.XmlNodeList defaultClassNameNode = HROne.CommonLib.Utility.GetXmlDocumentByDataString(MPFPlanExtendXMLString).GetElementsByTagName("MPFPlanDefaultClassName");
            if (defaultClassNameNode.Count > 0)
            {
                m_DefaultClassName = defaultClassNameNode[0].InnerText.Trim().ToUpper();
            }
            else
            {
                m_DefaultClassName = string.Empty;
            }

            System.Xml.XmlNodeList payCenterNode = HROne.CommonLib.Utility.GetXmlDocumentByDataString(MPFPlanExtendXMLString).GetElementsByTagName("MPFPlanPayCenter");
            if (payCenterNode.Count > 0)
            {
                m_PayCenterCode = payCenterNode[0].InnerText.PadRight(4).Substring(0, 4).ToUpper();
            }
            else
            {
                m_PayCenterCode = string.Empty.PadRight(4);
            }

            {
                HashCount = 1;
                string[] mpfFileHeader3 = new string[8];
                mpfFileHeader3[0] = " ";
                mpfFileHeader3[1] = "0";
                if (FormNo.Substring(2).Equals("B1"))
                {
                    mpfFileHeader3[2] = "B5";
                }
                else if (FormNo.Substring(2).Equals("B2"))
                {
                    mpfFileHeader3[2] = "B6";
                }
                else if (FormNo.Substring(2).Equals("B7"))
                {
                    mpfFileHeader3[2] = "BM";
                }
                else if (FormNo.Substring(2).Equals("BA"))
                {
                    mpfFileHeader3[2] = "BX";
                }
                mpfFileHeader3[3] = PayPeriodFr.ToString("yyyyMMdd");
                mpfFileHeader3[4] = PayPeriodTo.ToString("yyyyMMdd");


                mpfFileHeader3[5] = m_PayCenterCode.PadRight(4).Substring(0, 4).ToUpper();


                mpfFileHeader3[6] = "D";
                mpfFileHeader3[7] = string.Empty.PadLeft(55);


                string mpfFileHeaderString3 = string.Join(FIELD_DELIMITER, mpfFileHeader3);
                if (mpfFileHeaderString3.Length != 80)
                {
                    throw new Exception("Invalid Length on header line 3");
                }
                mpfFileData = mpfFileHeaderString3;
            }
            foreach (GenericExistingEmployeeMPFFileDetail bankFileDetail in ExistingEmployeeMPFFileDetails)
            {
                mpfFileData += GenerateExistingMPFFileDetail(bankFileDetail) + RECORD_DELIMITER;
            }
            foreach (GenericNewJoinEmployeeMPFFileDetail mpfFileDetail in NewJoinEmployeeMPFFileDetails)
            {
                mpfFileData += GenerateNewJoinMPFFileDetail(mpfFileDetail) + RECORD_DELIMITER;
            }
            //foreach (GenericAdditionalEmployeeMPFFileDetail bankFileDetail in AdditionalEmployeeMPFFileDetails)
            //{
            //    mpfFileData += GenerateAdditionalMPFFileDetail(bankFileDetail) + RECORD_DELIMITER;
            //}
            foreach (GenericBackPaymentEmployeeMPFFileDetail bankFileDetail in BackPaymentEmployeeMPFFileDetails)
            {
                mpfFileData += GenerateBackPaymentMPFFileDetail(bankFileDetail) + RECORD_DELIMITER;
            }
            {
                HashCount++;

                string[] mpfFileFooter = new string[9];
                mpfFileFooter[0] = " ";
                mpfFileFooter[1] = "9";
                mpfFileFooter[2] = ((double)(this.TotalAdditionalEmployeeMC + this.TotalAdditionalEmployeeVC + this.TotalBackPaymentEmployeeMC + this.TotalBackPaymentEmployeeVC + this.TotalExistingEmployeeMC + this.TotalExistingEmployeeVC + this.TotalNewJoinEmployeeMC + this.TotalNewJoinEmployeeVC)).ToString("0000000000000000.00").Replace(".", "");
                mpfFileFooter[3] = "D";
                mpfFileFooter[4] = "      ";
                mpfFileFooter[5] = "        ";
                mpfFileFooter[6] = ExistingEntitiesCount.ToString("0000000");
                mpfFileFooter[7] = NewJoinEntitiesCount.ToString("0000000");
                mpfFileFooter[8] = string.Empty.PadRight(31);

                string mpfFileFooterString = string.Join(FIELD_DELIMITER, mpfFileFooter);
                if (mpfFileFooterString.Length != 80)
                {
                    throw new Exception("Invalid Length on header line 3");
                }

                mpfFileData += mpfFileFooterString;
            }

            {
                string[] mpfFileHeader2 = new string[8];
                mpfFileHeader2[0] = "M";
                mpfFileHeader2[1] = EmployerID.PadRight(8).Substring(0, 8);
                mpfFileHeader2[2] = "0000";
                mpfFileHeader2[3] = FormNo.Substring(0, 2);
                mpfFileHeader2[4] = HashCount.ToString("0000000");
                mpfFileHeader2[5] = TransactionTime.ToString("yyyyMMdd");
                mpfFileHeader2[6] = TransactionTime.ToString("HHmmss");
                mpfFileHeader2[7] = string.Empty.PadRight(44);
                string mpfFileHeaderString2 = string.Join(FIELD_DELIMITER, mpfFileHeader2);
                if (mpfFileHeaderString2.Length != 80)
                {
                    throw new Exception("Invalid Length on header line 3");
                }
                mpfFileData = mpfFileHeaderString2 + RECORD_DELIMITER
                              + mpfFileData;
            }

            //{
            //    string[] mpfFileHeader1 = new string[7];
            //    mpfFileHeader1[0] = "S";
            //    mpfFileHeader1[1] = RemoteProfileID.PadRight(18).Substring(0, 18);
            //    mpfFileHeader1[2] = string.Empty.PadRight(28);
            //    mpfFileHeader1[3] = TransactionReference.PadRight(16).Substring(0, 16);
            //    mpfFileHeader1[4] = string.Empty.PadRight(3);
            //    mpfFileHeader1[5] = TransactionTime.ToString("yyyyMMdd");
            //    mpfFileHeader1[6] = TransactionTime.ToString("HHmmss");

            //    string mpfFileHeaderString1 = string.Join(FIELD_DELIMITER, mpfFileHeader1);
            //    if (mpfFileHeaderString1.Length != 80)
            //        throw new Exception("Invalid Length on header line 3");
            //    mpfFileData = mpfFileHeaderString1 + RECORD_DELIMITER
            //        + mpfFileData;
            //}



            FileInfo     result = GenerateTempFileName();
            StreamWriter writer = new StreamWriter(result.OpenWrite());

            writer.Write(mpfFileData);
            writer.Close();
            return(result);
        }
Example #4
0
        public override ReportDocument GenerateReport()
        {
            if (PayPeriodFr.Ticks != 0 && PayPeriodTo.Ticks != 0 && EmpList != null)
            {
                MPFFile.GenericMPFFile mpfFile = new MPFFile.GenericMPFFile(dbConn);

                mpfFile.LoadMPFFileDetail(EmpList, MPFPlanID, PayPeriodFr, PayPeriodTo);
                System.Data.DataSet dataSet = mpfFile.CreateFirstContributionStatementDataSet();

                if (reportDocument == null)
                {
                    reportDocument = new ReportTemplate.Report_Payroll_MPFFirstContributionStatement();
                }
                else
                {
                }

                reportDocument.SetDataSource(dataSet);
                reportDocument.SetParameterValue("ContributionPeriod", PayPeriodFr.ToString("yyyy-MM-dd") + " - " + PayPeriodTo.ToString("yyyy-MM-dd"));
                reportDocument.SetParameterValue("ContributionPeriodFrom", PayPeriodFr);
                reportDocument.SetParameterValue("ContributionPeriodTo", PayPeriodTo);
                reportDocument.SetParameterValue("TotalAdditionalEmployeeMC", mpfFile.TotalAdditionalEmployeeMC);
                reportDocument.SetParameterValue("TotalAdditionalEmployeeVC", mpfFile.TotalAdditionalEmployeeVC);
                reportDocument.SetParameterValue("TotalBackpayEmployeeMC", mpfFile.TotalBackPaymentEmployeeMC);
                reportDocument.SetParameterValue("TotalBackpayEmployeeVC", mpfFile.TotalBackPaymentEmployeeVC);
                reportDocument.SetParameterValue("TotalExistingEmployeeMC", mpfFile.TotalExistingEmployeeMC);
                reportDocument.SetParameterValue("TotalExistingEmployeeVC", mpfFile.TotalExistingEmployeeVC);
                reportDocument.SetParameterValue("TotalNewJoinEmployeeMC", mpfFile.TotalNewJoinEmployeeMC);
                reportDocument.SetParameterValue("TotalNewJoinEmployeeVC", mpfFile.TotalNewJoinEmployeeVC);

                return(reportDocument);
            }
            else
            {
                return(null);
            }
        }