Exemplo n.º 1
0
    protected void btnGenerate_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        ArrayList list = WebUtils.SelectedRepeaterItemToBaseObjectList(EEmpPersonalInfo.db, Repeater, "ItemSelect");

        if (list.Count > 0)
        {
            HROne.Reports.Payroll.PaymentSummaryListProcess reportProcess;
            if (Payroll_PeriodSelectionList1.SelectedPayrollStatus.Equals("T"))
            {
                reportProcess = new HROne.Reports.Payroll.PaymentSummaryListProcess(dbConn, ci, list, HROne.Reports.Payroll.PaymentSummaryListProcess.ReportType.TrialRun, Payroll_PeriodSelectionList1.GetTrialRunPayPeriodList(), null);
            }
            else
            {
                reportProcess = new HROne.Reports.Payroll.PaymentSummaryListProcess(dbConn, ci, list, HROne.Reports.Payroll.PaymentSummaryListProcess.ReportType.History, null, Payroll_PeriodSelectionList1.GetPayBatchList());
            }

            if (Response.IsClientConnected)
            {
                HROneConfig config = HROneConfig.GetCurrentHROneConfig();
                if (config.GenerateReportAsInbox)
                {
                    if (EInboxAttachment.GetTotalSize(dbConn, 0) < WebUtils.productLicense(Session).MaxInboxSizeMB * 1000 * 1000)
                    {
                        HROne.TaskService.GenericExcelReportTaskFactory reportTask = new HROne.TaskService.GenericExcelReportTaskFactory(dbConn, user, lblReportHeader.Text, reportProcess, "PaymentList");
                        AppUtils.reportTaskQueueService.AddTask(reportTask);
                        errors.addError(HROne.Translation.PageMessage.REPORT_GENERATING_TO_INBOX);
                    }
                    else
                    {
                        errors.addError(HROne.Translation.PageMessage.INBOX_SIZE_EXCEEDED);
                    }
                }
                else
                {
                    System.IO.FileInfo excelFile = reportProcess.GenerateExcelReport();
                    WebUtils.TransmitFile(Response, excelFile.FullName, "PaymentList_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
                }
            }

//            const string PAYMENTCODE_PREFIX = "[Payment] ";
//            string exportFileName = System.IO.Path.GetTempFileName();
//            System.IO.File.Delete(exportFileName);
//            exportFileName += ".xls";
//            //System.IO.File.Copy(Server.MapPath("~/template/HistoryList_Template.xls"), exportFileName, true);
//            HROne.Export.ExcelExport export = new HROne.Export.ExcelExport(exportFileName);
//            DataSet dataSet = new DataSet(); //export.GetDataSet();
//            DataTable dataTable = new DataTable("Payroll$");
//            dataSet.Tables.Add(dataTable);
//            dataTable.Columns.Add("Company", typeof(string));

//            DBFilter hierarchyLevelFilter = new DBFilter();
//            Hashtable hierarchyLevelHashTable = new Hashtable();
//            hierarchyLevelFilter.add("HLevelSeqNo", true);
//            ArrayList hierarchyLevelList = EHierarchyLevel.db.select(dbConn, hierarchyLevelFilter);
//            foreach (EHierarchyLevel hlevel in hierarchyLevelList)
//            {
//                dataTable.Columns.Add(hlevel.HLevelDesc, typeof(string));
//                hierarchyLevelHashTable.Add(hlevel.HLevelID, hlevel);
//            }
//            dataTable.Columns.Add("Payroll Group", typeof(string));
//            dataTable.Columns.Add("Position", typeof(string));
//            dataTable.Columns.Add("EmpNo", typeof(string));
//            dataTable.Columns.Add("English Name", typeof(string));
//            dataTable.Columns.Add("Chinese Name", typeof(string));
//            dataTable.Columns.Add("HKID", typeof(string));
//            dataTable.Columns.Add("From", typeof(DateTime));
//            dataTable.Columns.Add("To", typeof(DateTime));
//            int firstSummaryColumnPos = dataTable.Columns.Count;
//            dataTable.Columns.Add("Net Payment", typeof(double));
//            dataTable.Columns.Add("Relevant Income", typeof(double));
//            dataTable.Columns.Add("Non-Relevant Income", typeof(double));
//            dataTable.Columns.Add("Wages Payable for Min Wages", typeof(double));
//            dataTable.Columns.Add("Total Hours Worked", typeof(double));
//            dataTable.Columns.Add("Min Wages Required", typeof(double));
//            dataTable.Columns.Add("Employer Mandatory Contribution", typeof(double));
////            dataTable.Columns.Add("Employee Mandatory Contribution", typeof(double));
//            dataTable.Columns.Add("Employer Voluntary Contribution", typeof(double));
////            dataTable.Columns.Add("Employee Voluntary Contribution", typeof(double));
//            dataTable.Columns.Add("Employer P-Fund Contribution", typeof(double));
////            dataTable.Columns.Add("Employee P-Fund Contribution", typeof(double));
//            dataTable.Columns.Add("Total Employer Contribution", typeof(double));
//            dataTable.Columns.Add("Total Employee Contribution", typeof(double));
//            dataTable.Columns.Add("Total Taxable Payment", typeof(double));
//            dataTable.Columns.Add("Total Non-Taxable Payment", typeof(double));
//            int firstDetailColumnPos = dataTable.Columns.Count;


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



//                DBFilter empPayrollFilterForPayrollPeriod = new DBFilter();
//                empPayrollFilterForPayrollPeriod.add(new Match("ep.EmpID", empInfo.EmpID));
//                empPayrollFilterForPayrollPeriod.add(Payroll_PeriodSelectionList1.GetEmpPayrollDBTerm());

//                DBFilter payPeriodFilter = new DBFilter();
//                payPeriodFilter.add(new IN("PayPeriodID", "SELECT PayPeriodID from " + EEmpPayroll.db.dbclass.tableName + " ep", empPayrollFilterForPayrollPeriod));
//                ArrayList payPeriodList = EPayrollPeriod.db.select(dbConn, payPeriodFilter);

//                foreach (EPayrollPeriod payPeriod in payPeriodList)
//                {
//                    if (EPayrollPeriod.db.select(dbConn, payPeriod))
//                    {

//                        EPayrollGroup payrollGroup = new EPayrollGroup();
//                        payrollGroup.PayGroupID = payPeriod.PayGroupID;
//                        EPayrollGroup.db.select(dbConn, payrollGroup);

//                        DataRow row = dataTable.NewRow();
//                        row["EmpNo"] = empInfo.EmpNo;
//                        row["English Name"] = empInfo.EmpEngFullName;
//                        row["Chinese Name"] = empInfo.EmpChiFullName;
//                        row["HKID"] = empInfo.EmpHKID;
//                        row["From"] = payPeriod.PayPeriodFr;
//                        row["To"] = payPeriod.PayPeriodTo;
//                        row["Payroll Group"] = payrollGroup.PayGroupDesc;
//                        DBFilter empPosFilter = new DBFilter();

//                        EEmpPositionInfo empPos = AppUtils.GetLastPositionInfo(dbConn, payPeriod.PayPeriodTo, empInfo.EmpID);
//                        if (empPos != null)
//                        {
//                            ECompany company = new ECompany();
//                            company.CompanyID = empPos.CompanyID;
//                            if (ECompany.db.select(dbConn, company))
//                                row["Company"] = company.CompanyCode;

//                            DBFilter empHierarchyFilter = new DBFilter();
//                            empHierarchyFilter.add(new Match("EmpPosID", empPos.EmpPosID));
//                            ArrayList empHierarchyList = EEmpHierarchy.db.select(dbConn, empHierarchyFilter);
//                            foreach (EEmpHierarchy empHierarchy in empHierarchyList)
//                            {
//                                EHierarchyLevel hierarchyLevel = (EHierarchyLevel)hierarchyLevelHashTable[empHierarchy.HLevelID];
//                                if (hierarchyLevel != null)
//                                {
//                                    EHierarchyElement hierarchyElement = new EHierarchyElement();
//                                    hierarchyElement.HElementID = empHierarchy.HElementID;
//                                    if (EHierarchyElement.db.select(dbConn, hierarchyElement))
//                                        row[hierarchyLevel.HLevelDesc] = hierarchyElement.HElementDesc;
//                                }
//                            }
//                            EPosition position = new EPosition();
//                            position.PositionID = empPos.PositionID;
//                            if (EPosition.db.select(dbConn, position))
//                                row["Position"] = position.PositionDesc;


//                        }

//                        double netAmount = 0, releventIncome = 0, nonRelevantIncome = 0, taxableAmount = 0, nonTaxableAmount = 0;
//                        double mcER = 0, mcEE = 0;
//                        double vcER = 0, vcEE = 0;
//                        double pFundER = 0, pFundEE = 0;

//                        DBFilter empPayrollFilterForPaymentRecord = new DBFilter(empPayrollFilterForPayrollPeriod);
//                        empPayrollFilterForPaymentRecord.add(new Match("PayPeriodID", payPeriod.PayPeriodID));
//                        DBFilter paymentRecordFilter = new DBFilter();
//                        paymentRecordFilter.add(new IN("EmpPayrollID", "Select EmpPayrollID from " + EEmpPayroll.db.dbclass.tableName + " ep ", empPayrollFilterForPaymentRecord));
//                        paymentRecordFilter.add(new Match("PayRecStatus", "A"));
//                        ArrayList paymentRecords = EPaymentRecord.db.select(dbConn, paymentRecordFilter);

//                        foreach (EPaymentRecord paymentRecord in paymentRecords)
//                        {
//                            EPaymentCode payCode = new EPaymentCode();
//                            payCode.PaymentCodeID = paymentRecord.PaymentCodeID;
//                            EPaymentCode.db.select(dbConn, payCode);
//                            //  Always Use Payment Code Description for grouping payment code with same description
//                            string fieldName = PAYMENTCODE_PREFIX + payCode.PaymentCodeDesc;
//                            if (dataTable.Columns[fieldName] == null)
//                                dataTable.Columns.Add(new DataColumn(fieldName, typeof(double)));
//                            if (row[fieldName] == null || row[fieldName] == DBNull.Value)
//                                row[fieldName] = 0;
//                            row[fieldName] = (double)row[fieldName] + paymentRecord.PayRecActAmount;


//                            netAmount += paymentRecord.PayRecActAmount;
//                            if (payCode.PaymentCodeIsMPF)
//                                releventIncome += paymentRecord.PayRecActAmount;
//                            else
//                                nonRelevantIncome += paymentRecord.PayRecActAmount;

//                            DBFilter taxPaymentMapFilter = new DBFilter();
//                            taxPaymentMapFilter.add(new Match("PaymentCodeID", paymentRecord.PaymentCodeID));
//                            if (ETaxPaymentMap.db.count(dbConn, taxPaymentMapFilter) > 0)
//                                taxableAmount += paymentRecord.PayRecActAmount;
//                            else
//                                nonTaxableAmount += paymentRecord.PayRecActAmount;

//                        }

//                        row["Net Payment"] = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(netAmount, ExchangeCurrency.DefaultCurrencyDecimalPlaces(), ExchangeCurrency.DefaultCurrencyDecimalPlaces());
//                        row["Relevant Income"] = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(releventIncome, ExchangeCurrency.DefaultCurrencyDecimalPlaces(), ExchangeCurrency.DefaultCurrencyDecimalPlaces());
//                        row["Non-Relevant Income"] = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(nonRelevantIncome, ExchangeCurrency.DefaultCurrencyDecimalPlaces(), ExchangeCurrency.DefaultCurrencyDecimalPlaces());
//                        row["Wages Payable for Min Wages"] = PayrollProcess.GetTotalWagesWithoutRestDayPayment(dbConn, empInfo.EmpID, payPeriod.PayPeriodFr, payPeriod.PayPeriodTo, null);
//                        row["Total Hours Worked"] = PayrollProcess.GetTotalEmpPayrollWorkingHours(dbConn, empInfo.EmpID, payPeriod.PayPeriodID);
//                        row["Min Wages Required"] = (double)row["Total Hours Worked"] * PayrollProcess.GetMinimumWages(dbConn, empInfo.EmpID, payPeriod.PayPeriodTo);
//                        row["Total Taxable Payment"] = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(taxableAmount, ExchangeCurrency.DefaultCurrencyDecimalPlaces(), ExchangeCurrency.DefaultCurrencyDecimalPlaces());
//                        row["Total Non-Taxable Payment"] = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(nonTaxableAmount, ExchangeCurrency.DefaultCurrencyDecimalPlaces(), ExchangeCurrency.DefaultCurrencyDecimalPlaces());

//                        DBFilter mpfRecordFilter = new DBFilter();
//                        mpfRecordFilter.add(new IN("EmpPayrollID", "Select EmpPayrollID from " + EEmpPayroll.db.dbclass.tableName + " ep ", empPayrollFilterForPaymentRecord));
//                        ArrayList mpfRecords = EMPFRecord.db.select(dbConn, mpfRecordFilter);
//                        foreach (EMPFRecord mpfRecord in mpfRecords)
//                        {
//                            vcER += mpfRecord.MPFRecActVCER;
//                            mcER += +mpfRecord.MPFRecActMCER;
//                            vcEE += mpfRecord.MPFRecActVCEE;
//                            mcEE += mpfRecord.MPFRecActMCEE;
//                        }
//                        ArrayList orsoRecords = EORSORecord.db.select(dbConn, mpfRecordFilter);
//                        foreach (EORSORecord orsoRecord in orsoRecords)
//                        {
//                            pFundER += orsoRecord.ORSORecActER;
//                            pFundEE += orsoRecord.ORSORecActEE;
//                        }
//                        row["Employer Mandatory Contribution"] = mcER;
//                        //                        row["Employee Mandatory Contribution"] = mcEE;
//                        row["Employer Voluntary Contribution"] = vcER;
//                        //                        row["Employee Voluntary Contribution"] = vcEE;
//                        row["Employer P-Fund Contribution"] = pFundER;
//                        //                        row["Employee P-Fund Contribution"] = pFundEE;

//                        row["Total Employer Contribution"] = mcER + vcER + pFundER;
//                        row["Total Employee Contribution"] = mcEE + vcEE + pFundEE;
//                        dataTable.Rows.Add(row);
//                    }
//                }
//            }

//            DBFilter paymentCodeFilter = new DBFilter();
//            paymentCodeFilter.add("PaymentCodeDisplaySeqNo", false);
//            paymentCodeFilter.add("PaymentCode", false);
//            ArrayList paymentCodeList = EPaymentCode.db.select(dbConn, paymentCodeFilter);
//            foreach (EPaymentCode paymentCode in paymentCodeList)
//            {
//                if (dataTable.Columns.Contains(PAYMENTCODE_PREFIX + paymentCode.PaymentCodeDesc))
//                {
//                    DataColumn paymentColumn = dataTable.Columns[PAYMENTCODE_PREFIX + paymentCode.PaymentCodeDesc];
//                    paymentColumn.SetOrdinal(firstDetailColumnPos);
//                    if (!dataTable.Columns.Contains(paymentCode.PaymentCodeDesc))
//                        paymentColumn.ColumnName = paymentCode.PaymentCodeDesc;
//                    else
//                    {
//                        System.Diagnostics.Debug.Write("System reserved payment column is used");
//                    }
//                }
//            }
//            for (int i = 0; i < firstDetailColumnPos; i++)
//                dataTable.Columns[i].ColumnName = HROne.Common.WebUtility.GetLocalizedString(dataTable.Columns[i].ColumnName);

//            for (int i = firstSummaryColumnPos; i < firstDetailColumnPos; i++)
//                dataTable.Columns[firstSummaryColumnPos].SetOrdinal(dataTable.Columns.Count - 1);


//            export.Update(dataSet);
//            WebUtils.TransmitFile(Response, exportFileName, "PaymentList_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
//            return;
        }
        else
        {
            errors.addError("Employee not selected");
        }
    }
Exemplo n.º 2
0
    protected void btnGenerate_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(EPayrollGroup.db, Page.Master);

        DateTime dtPeriodFrom        = new DateTime();
        DateTime dtPeriodTo          = new DateTime();
        int      intHierarchyLevelID = 0;

        if (!string.IsNullOrEmpty(PayPeriodFr.Value))
        {
            if (!DateTime.TryParse(PayPeriodFr.Value, out dtPeriodFrom))
            {
                errors.addError(HROne.Translation.PageErrorMessage.ERROR_DATE_FORMAT);
                return;
            }
        }
        if (!string.IsNullOrEmpty(PayPeriodTo.Value))
        {
            if (!DateTime.TryParse(PayPeriodTo.Value, out dtPeriodTo))
            {
                errors.addError(HROne.Translation.PageErrorMessage.ERROR_DATE_FORMAT);
                return;
            }
        }
        if (!int.TryParse(HLevelID.SelectedValue, out intHierarchyLevelID))
        {
            errors.addError("Invalid Hierarchy Level");
        }

        // Start 0000185, KuangWei, 2015-05-05
        ArrayList empList = WebUtils.SelectedRepeaterItemToBaseObjectList(db, Repeater, "ItemSelect");

        if (empList.Count <= 0)
        {
            errors.addError("No Employees selected");
        }

        if (errors.isEmpty())
        {
            HROne.Reports.Payroll.PaymentAllocationListProcess reportProcess = new HROne.Reports.Payroll.PaymentAllocationListProcess(dbConn, ci, dtPeriodFrom, dtPeriodTo, intHierarchyLevelID, WebUtils.GetCurUser(Session), empList);
            // End 0000185, KuangWei, 2015-05-05

            if (Response.IsClientConnected)
            {
                HROneConfig config = HROneConfig.GetCurrentHROneConfig();
                if (config.GenerateReportAsInbox)
                {
                    if (EInboxAttachment.GetTotalSize(dbConn, 0) < WebUtils.productLicense(Session).MaxInboxSizeMB * 1000 * 1000)
                    {
                        HROne.TaskService.GenericExcelReportTaskFactory reportTask = new HROne.TaskService.GenericExcelReportTaskFactory(dbConn, user, lblReportHeader.Text, reportProcess, "PaymentAllocationList");
                        AppUtils.reportTaskQueueService.AddTask(reportTask);
                        errors.addError(HROne.Translation.PageMessage.REPORT_GENERATING_TO_INBOX);
                    }
                    else
                    {
                        errors.addError(HROne.Translation.PageMessage.INBOX_SIZE_EXCEEDED);
                    }
                }
                else
                {
                    System.IO.FileInfo excelFile = reportProcess.GenerateExcelReport();
                    WebUtils.TransmitFile(Response, excelFile.FullName, "PaymentAllocationList_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
                }
            }
        }
        //{
        //    string hierarchyLevelName = string.Empty;

        //    DataSet dataSet = new DataSet();

        //    DataTable empInfoTable = new DataTable("EmpInfo");
        //    DataTable payrollTable = new DataTable("Payment");

        //    dataSet.Tables.Add(empInfoTable);
        //    dataSet.Tables.Add(payrollTable);

        //    payrollTable.Columns.Add("EmpPayrollID", typeof(string));
        //    int firstDetailColumnPos = payrollTable.Columns.Count;


        //    empInfoTable.Columns.Add("EmployeeID", typeof(string));
        //    empInfoTable.Columns.Add("EmpPayrollID", typeof(int));
        //    empInfoTable.Columns.Add("EnglishName", typeof(string));
        //    empInfoTable.Columns.Add("Alias", typeof(string));

        //    empInfoTable.Columns.Add("Company", typeof(string));
        //    DBFilter hierarchyLevelFilter = new DBFilter();
        //    Hashtable hierarchyLevelHashTable = new Hashtable();
        //    hierarchyLevelFilter.add("HLevelSeqNo", true);
        //    ArrayList hierarchyLevelList = EHierarchyLevel.db.select(dbConn, hierarchyLevelFilter);
        //    foreach (EHierarchyLevel hlevel in hierarchyLevelList)
        //    {

        //        if (hlevel.HLevelID.Equals(intHierarchyLevelID))
        //            hierarchyLevelName = hlevel.HLevelDesc;
        //        empInfoTable.Columns.Add(hlevel.HLevelDesc, typeof(string));
        //        hierarchyLevelHashTable.Add(hlevel.HLevelID, hlevel);
        //    }
        //    empInfoTable.Columns.Add("Payroll Group", typeof(string));

        //    empInfoTable.Columns.Add("Date Join", typeof(DateTime));
        //    empInfoTable.Columns.Add("Date Left", typeof(DateTime));
        //    empInfoTable.Columns.Add("Net Payable", typeof(double));
        //    empInfoTable.Columns.Add("MCEE", typeof(double));
        //    empInfoTable.Columns.Add("MCER", typeof(double));
        //    empInfoTable.Columns.Add("VCEE", typeof(double));
        //    empInfoTable.Columns.Add("VCER", typeof(double));
        //    empInfoTable.Columns.Add("PFundEE", typeof(double));
        //    empInfoTable.Columns.Add("PFundER", typeof(double));

        //    DBFilter payPeriodFilter = new DBFilter();
        //    if (!dtPeriodFrom.Ticks.Equals(0))
        //        payPeriodFilter.add(new Match("PayPeriodTo", ">=", dtPeriodFrom));
        //    if (!dtPeriodTo.Ticks.Equals(0))
        //        payPeriodFilter.add(new Match("PayPeriodTo", "<=", dtPeriodTo));


        //    ArrayList payPeriodList = EPayrollPeriod.db.select(dbConn, payPeriodFilter);
        //    if (payPeriodList.Count > 0)
        //    {
        //        // reset period
        //        dtPeriodFrom = new DateTime();
        //        dtPeriodTo = new DateTime();
        //    }
        //    foreach (EPayrollPeriod payPeriod in payPeriodList)
        //    {
        //        if (dtPeriodFrom > payPeriod.PayPeriodFr || dtPeriodFrom.Ticks.Equals(0))
        //            dtPeriodFrom = payPeriod.PayPeriodFr;
        //        if (dtPeriodTo < payPeriod.PayPeriodTo || dtPeriodTo.Ticks.Equals(0))
        //            dtPeriodTo = payPeriod.PayPeriodTo;



        //        DBFilter empPayrollFilter = new DBFilter();
        //        empPayrollFilter.add(new Match("PayPeriodID", payPeriod.PayPeriodID));
        //        ArrayList empPayrollList = EEmpPayroll.db.select(dbConn, empPayrollFilter);

        //        foreach (EEmpPayroll empPayroll in empPayrollList)
        //        {
        //            EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
        //            empInfo.EmpID = empPayroll.EmpID;
        //            EEmpPersonalInfo.db.select(dbConn, empInfo);

        //            DataRow row = empInfoTable.NewRow();
        //            DataRow paymentRow = payrollTable.NewRow();

        //            row["EmployeeID"] = empInfo.EmpNo;
        //            row["EmpPayrollID"] = empPayroll.EmpPayrollID;
        //            paymentRow["EmpPayrollID"] = empPayroll.EmpPayrollID;
        //            row["EnglishName"] = empInfo.EmpEngFullName;
        //            row["Alias"] = empInfo.EmpAlias;

        //            row["Date Join"] = empInfo.EmpDateOfJoin;
        //            DBFilter empTerminationFilter = new DBFilter();
        //            empTerminationFilter.add(new Match("EmpID", empInfo.EmpID));
        //            ArrayList empTerminationList = EEmpTermination.db.select(dbConn, empTerminationFilter);
        //            if (empTerminationList.Count > 0)
        //                row["Date Left"] = ((EEmpTermination)empTerminationList[0]).EmpTermLastDate;

        //            DBFilter empPosFilter = new DBFilter();

        //            EEmpPositionInfo empPos = AppUtils.GetLastPositionInfo(dbConn, payPeriod.PayPeriodTo, empInfo.EmpID);
        //            if (empPos != null)
        //            {
        //                ECompany company = new ECompany();
        //                company.CompanyID = empPos.CompanyID;
        //                if (ECompany.db.select(dbConn, company))
        //                    row["Company"] = company.CompanyName;

        //                EPayrollGroup payrollGroup = new EPayrollGroup();
        //                payrollGroup.PayGroupID = empPos.PayGroupID;
        //                if (EPayrollGroup.db.select(dbConn, payrollGroup))
        //                    row["Payroll Group"] = payrollGroup.PayGroupDesc;
        //                DBFilter empHierarchyFilter = new DBFilter();
        //                empHierarchyFilter.add(new Match("EmpPosID", empPos.EmpPosID));
        //                ArrayList empHierarchyList = EEmpHierarchy.db.select(dbConn, empHierarchyFilter);
        //                foreach (EEmpHierarchy empHierarchy in empHierarchyList)
        //                {
        //                    EHierarchyLevel hierarchyLevel = (EHierarchyLevel)hierarchyLevelHashTable[empHierarchy.HLevelID];
        //                    if (hierarchyLevel != null)
        //                    {
        //                        EHierarchyElement hierarchyElement = new EHierarchyElement();
        //                        hierarchyElement.HElementID = empHierarchy.HElementID;
        //                        if (EHierarchyElement.db.select(dbConn, hierarchyElement))
        //                            row[hierarchyLevel.HLevelDesc] = hierarchyElement.HElementDesc;
        //                    }
        //                }
        //            }


        //            double netAmount = 0, releventIncome = 0, nonRelevantIncome = 0, MCEE = 0, MCER = 0, VCEE=0, VCER=0, PFUNDEE = 0, PFUNDER = 0;

        //            DBFilter paymentRecordFilter = new DBFilter();
        //            paymentRecordFilter.add(new Match("EmpPayrollID", empPayroll.EmpPayrollID));
        //            paymentRecordFilter.add(new Match("PayRecStatus", "A"));
        //            ArrayList paymentRecords = EPaymentRecord.db.select(dbConn, paymentRecordFilter);

        //            foreach (EPaymentRecord paymentRecord in paymentRecords)
        //            {
        //                EPaymentCode payCode = new EPaymentCode();
        //                payCode.PaymentCodeID = paymentRecord.PaymentCodeID;
        //                EPaymentCode.db.select(dbConn, payCode);
        //                string fieldName = payCode.PaymentCodeDesc;
        //                if (payrollTable.Columns[fieldName] == null)
        //                    payrollTable.Columns.Add(new DataColumn(fieldName, typeof(double)));
        //                if (paymentRow[fieldName] == null || paymentRow[fieldName] == DBNull.Value)
        //                    paymentRow[fieldName] = 0;
        //                paymentRow[fieldName] = (double)paymentRow[fieldName] + paymentRecord.PayRecActAmount;


        //                netAmount += paymentRecord.PayRecActAmount;
        //                if (payCode.PaymentCodeIsMPF)
        //                    releventIncome += paymentRecord.PayRecActAmount;
        //                else
        //                    nonRelevantIncome += paymentRecord.PayRecActAmount;

        //            }

        //            row["Net Payable"] = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(netAmount, ExchangeCurrency.DefaultCurrencyDecimalPlaces(), ExchangeCurrency.DefaultCurrencyDecimalPlaces());
        //            //row["Relevant Income"] = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(releventIncome, ExchangeCurrency.DefaultCurrencyDecimalPlaces(), ExchangeCurrency.DefaultCurrencyDecimalPlaces());
        //            //row["Non-Relevant Income"] = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(nonRelevantIncome, ExchangeCurrency.DefaultCurrencyDecimalPlaces(), ExchangeCurrency.DefaultCurrencyDecimalPlaces());

        //            DBFilter mpfRecordFilter = new DBFilter();
        //            mpfRecordFilter.add(new Match("EmpPayrollID", empPayroll.EmpPayrollID));
        //            ArrayList mpfRecords = EMPFRecord.db.select(dbConn, mpfRecordFilter);
        //            foreach (EMPFRecord mpfRecord in mpfRecords)
        //            {
        //                VCER += mpfRecord.MPFRecActVCER;
        //                MCER += mpfRecord.MPFRecActMCER;
        //                VCEE += mpfRecord.MPFRecActVCEE;
        //                MCEE += mpfRecord.MPFRecActMCEE;
        //            }
        //            row["MCEE"] = MCEE;
        //            row["VCEE"] = VCEE;
        //            row["MCER"] = MCER;
        //            row["VCER"] = VCER;
        //            ArrayList orsoRecords = EORSORecord.db.select(dbConn, mpfRecordFilter);
        //            foreach (EORSORecord orsoRecord in orsoRecords)
        //            {
        //                PFUNDER += orsoRecord.ORSORecActER;
        //                PFUNDEE += orsoRecord.ORSORecActEE;
        //            }
        //            row["PFundEE"] = PFUNDEE;
        //            row["PFundER"] = PFUNDER;

        //            empInfoTable.Rows.Add(row);
        //            payrollTable.Rows.Add(paymentRow);
        //        }
        //    }
        //    DBFilter paymentCodeFilter = new DBFilter();
        //    paymentCodeFilter.add("PaymentCodeDisplaySeqNo", false);
        //    paymentCodeFilter.add("PaymentCode", false);
        //    ArrayList paymentCodeList = EPaymentCode.db.select(dbConn, paymentCodeFilter);
        //    foreach (EPaymentCode paymentCode in paymentCodeList)
        //    {
        //        if (payrollTable.Columns.Contains(paymentCode.PaymentCodeDesc))
        //            payrollTable.Columns[paymentCode.PaymentCodeDesc].SetOrdinal(firstDetailColumnPos);
        //    }
        //    GenerateReport(dataSet, dtPeriodFrom, dtPeriodTo, hierarchyLevelName);
        //    return;

        //}
    }
    protected void btnGenerate_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(EPayrollGroup.db, Page.Master);

        DateTime dtPeriodFrom        = new DateTime();
        DateTime dtPeriodTo          = new DateTime();
        int      intHierarchyLevelID = 0;
        int      m_companyID         = int.Parse(CompanyID.SelectedValue);

        //if (!string.IsNullOrEmpty(PayPeriodFr.Value))
        if (!DateTime.TryParse(PayPeriodFr.Value, out dtPeriodFrom))
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_DATE_FORMAT);
            return;
        }

        //if (!string.IsNullOrEmpty(PayPeriodTo.Value))
        if (!DateTime.TryParse(PayPeriodTo.Value, out dtPeriodTo))
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_DATE_FORMAT);
            return;
        }

        if ((dtPeriodTo.Year * 12 + dtPeriodTo.Month) - (dtPeriodFrom.Year * 12 + dtPeriodFrom.Month) >= 36)
        {
            errors.addError("Payroll period exceed maximum (36 months)");
            return;
        }

        if (!int.TryParse(HLevelID.SelectedValue, out intHierarchyLevelID))
        {
            errors.addError("Invalid Hierarchy Level");
            return;
        }

        // Start 0000185, KuangWei, 2015-05-05
        ArrayList empList = WebUtils.SelectedRepeaterItemToBaseObjectList(db, Repeater, "ItemSelect");

        if (empList.Count <= 0)
        {
            errors.addError("No Employees are selected");
            return;
        }

        HROne.Reports.Payroll.PayrollAllocationReport_Detail_Process reportProcess = new HROne.Reports.Payroll.PayrollAllocationReport_Detail_Process(dbConn, ci, dtPeriodFrom, dtPeriodTo, intHierarchyLevelID, chkShowIndividuals.Checked, WebUtils.GetCurUser(Session), m_companyID, empList);
        // End 0000185, KuangWei, 2015-05-05

        if (Response.IsClientConnected)
        {
            HROneConfig config = HROneConfig.GetCurrentHROneConfig();
            if (config.GenerateReportAsInbox)
            {
                if (EInboxAttachment.GetTotalSize(dbConn, 0) < WebUtils.productLicense(Session).MaxInboxSizeMB * 1000 * 1000)
                {
                    HROne.TaskService.GenericExcelReportTaskFactory reportTask = new HROne.TaskService.GenericExcelReportTaskFactory(dbConn, user, lblReportHeader.Text, reportProcess, "PFundContributionSummary");
                    AppUtils.reportTaskQueueService.AddTask(reportTask);
                    errors.addError(HROne.Translation.PageMessage.REPORT_GENERATING_TO_INBOX);
                }
                else
                {
                    errors.addError(HROne.Translation.PageMessage.INBOX_SIZE_EXCEEDED);
                }
            }
            else
            {
                System.IO.FileInfo excelFile = reportProcess.GenerateExcelReport();
                WebUtils.TransmitFile(Response, excelFile.FullName, "PFundContributionSummary_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
            }
        }
    }
Exemplo n.º 4
0
    private void GenerateEmployeeExcel(ArrayList employeeList, ArrayList functionList)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        HROne.Import.EmployeeInformationExportProcess reportProcess = new HROne.Import.EmployeeInformationExportProcess(dbConn, ci, employeeList, functionList, IncludedEmployeeNameHierarchy.Checked, DisplayCodeOnly.Checked, ShowInternalID.Checked);

        if (Response.IsClientConnected)
        {
            HROneConfig config = HROneConfig.GetCurrentHROneConfig();
            if (config.GenerateReportAsInbox)
            {
                if (EInboxAttachment.GetTotalSize(dbConn, 0) < WebUtils.productLicense(Session).MaxInboxSizeMB * 1000 * 1000)
                {
                    HROne.TaskService.GenericExcelReportTaskFactory reportTask = new HROne.TaskService.GenericExcelReportTaskFactory(dbConn, user, lblReportHeader.Text, reportProcess, "EmployeeExport");
                    AppUtils.reportTaskQueueService.AddTask(reportTask);
                    errors.addError(HROne.Translation.PageMessage.REPORT_GENERATING_TO_INBOX);
                }
                else
                {
                    errors.addError(HROne.Translation.PageMessage.INBOX_SIZE_EXCEEDED);
                }
            }
            else
            {
                System.IO.FileInfo excelFile = reportProcess.GenerateExcelReport();
                WebUtils.TransmitFile(Response, excelFile.FullName, "EmployeeExport_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
            }
        }

        //DataSet excelDataSet= new DataSet();

        //foreach (string functionCode in functionList)
        //{
        //    if (functionCode.Equals("PER001"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpPersonalInfoProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked));
        //    if (functionCode.Equals("PER002"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpBankAccountProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked));
        //    if (functionCode.Equals("PER003"))
        //    {
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpSpouseProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked));
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpDependantProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked));
        //    }
        //    if (functionCode.Equals("PER004"))
        //    {
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpQualificationProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpSkillProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //    }
        //    if (functionCode.Equals("PER005"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpPlaceOfResidenceProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked));
        //    if (functionCode.Equals("PER006"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpContractTermsProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked));
        //    if (functionCode.Equals("PER007"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpPositionInfoProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //    if (functionCode.Equals("PER007_1"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpRecurringPaymentProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //    if (functionCode.Equals("PER008"))
        //    {
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpMPFPlanProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpAVCPlanProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpORSOPlanProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //    }
        //    if (functionCode.Equals("PER009"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportLeaveApplicationProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //    if (functionCode.Equals("PER011"))
        //    {
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpTerminationProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpFinalPaymentProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //    }
        //    if (functionCode.Equals("PER012"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpCostCenterProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //    if (functionCode.Equals("PER013"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpPermitProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //    if (functionCode.Equals("PER015"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpEmergencyContactProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked));
        //    if (functionCode.Equals("PER016"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpWorkExpProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked, !DisplayCodeOnly.Checked));
        //    if (functionCode.Equals("PER017"))
        //        excelDataSet.Tables.Add(HROne.Import.ImportEmpWorkInjuryRecordProcess.Export(dbConn, employeeList, IncludedEmployeeNameHierarchy.Checked));

        //}

        //string exportFileName = System.IO.Path.GetTempFileName();
        //System.IO.File.Delete(exportFileName);
        //exportFileName += ".xls";
        //HROne.Export.ExcelExport excelExport = new HROne.Export.ExcelExport(exportFileName);
        //excelExport.Update(excelDataSet);
        //WebUtils.TransmitFile(Response, exportFileName, "EmployeeExport_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
        //return;
    }