protected void btnRollback_Click(object sender, EventArgs e)
    {
        PageErrors pageErrors = PageErrors.getErrors(db, Page.Master);

        if (!IsValidRollbackKey(txtPassCode.Text))
        {
            pageErrors.addError("Incorrect pass code!");
            return;
        }
        else
        {
            PayrollProcess payrollProcess = new PayrollProcess(dbConn);
            WebUtils.StartFunction(Session, FUNCTION_CODE, true);
            payrollProcess.RollBackPayroll(CurPayPeriodID, WebUtils.GetCurUser(Session).UserID);
            WebUtils.EndFunction(dbConn);
            pageErrors.addError("Rollback Complete");
            binding.init(Request, Session);

            if (CurID > 0)
            {
                panelPayPeriod.Visible = true;
                loadObject();
            }
            else
            {
                panelPayPeriod.Visible      = false;
                panelRollbackOption.Visible = false;
            }
        }
        loadState();

        //        Response.Redirect(Request.Url.LocalPath + "?" + Request.QueryString);
    }
Esempio n. 2
0
    protected void btnProcessEnd_Click(object sender, EventArgs e)
    {
        PageErrors pageErrors = PageErrors.getErrors(db, Page.Master);
        ArrayList  list       = WebUtils.SelectedRepeaterItemToBaseObjectList(EPayrollGroup.db, Repeater, "ItemSelect");

        if (list.Count <= 0)
        {
            pageErrors.addError("no payroll group is selected");
        }

        string payGroupStringList = string.Empty;

        if (!string.IsNullOrEmpty(PayPeriodFr.Value) && !string.IsNullOrEmpty(PayPeriodTo.Value))
        {
            DateTime dtPayPeriodFr = DateTime.Parse(PayPeriodFr.Value);
            DateTime dtPayPeriodTo = DateTime.Parse(PayPeriodTo.Value);

            foreach (EPayrollGroup payGroup in list)
            {
                DBFilter payPeriodFilter = new DBFilter();
                payPeriodFilter.add(new Match("PayGroupID", payGroup.PayGroupID));
                payPeriodFilter.add(new Match("PayPeriodFr", "<=", dtPayPeriodFr));
                payPeriodFilter.add(new Match("PayPeriodTo", ">=", dtPayPeriodFr));
                ArrayList payPeriodList = EPayrollPeriod.db.select(dbConn, payPeriodFilter);
                if (payPeriodList.Count <= 0)
                {
                    pageErrors.addError("Start Period does NOT exists");
                    break;
                }

                if (string.IsNullOrEmpty(payGroupStringList))
                {
                    payGroupStringList = payGroup.PayGroupID.ToString();
                }
                else
                {
                    payGroupStringList += "|" + payGroup.PayGroupID.ToString();
                }
            }



            if (pageErrors.isEmpty())
            {
                if (RollbackPayrollProcess.Checked)
                {
                    if (!WebUtils.CheckPermission(Session, ROLLBACK_FUNCTION_CODE, WebUtils.AccessLevel.ReadWrite))
                    {
                        pageErrors.addError("privilege for Rollback Payroll Process is required!");
                        return;
                    }
                    if (!IsValidRollbackKey(txtPassCode.Text))
                    {
                        pageErrors.addError("Incorrect pass code!");
                        return;
                    }
                    else
                    {
                        // Start rollback process
                        WebUtils.StartFunction(Session, ROLLBACK_FUNCTION_CODE, true);
                        PayrollProcess payrollProcess = new PayrollProcess(dbConn);
                        foreach (EPayrollGroup payGroup in list)
                        {
                            DBFilter payPeriodFilter = new DBFilter();
                            payPeriodFilter.add(new Match("PayGroupID", payGroup.PayGroupID));
                            payPeriodFilter.add(new Match("PayPeriodTo", ">=", dtPayPeriodFr));
                            payPeriodFilter.add(new Match("PayPeriodFr", "<=", dtPayPeriodTo));
                            ArrayList payPeriodList = EPayrollPeriod.db.select(dbConn, payPeriodFilter);
                            foreach (EPayrollPeriod payPeriod in payPeriodList)
                            {
                                payrollProcess.RollBackPayroll(payPeriod.PayPeriodID, WebUtils.GetCurUser(Session).UserID);
                            }
                        }
                        WebUtils.EndFunction(dbConn);
                    }
                }

                Session.Remove("PayrollContinuousProcess_EmpList");
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/Payroll_GroupProcessContinuous_Process.aspx?"
                                                                            + "PayGroupIDList=" + payGroupStringList
                                                                            + "&PayPeriodFr=" + dtPayPeriodFr.Ticks
                                                                            + "&PayPeriodTo=" + dtPayPeriodTo.Ticks
                                                                            + "&SkipRecurringPaymentProcess=" + (SkipRecurringPaymentProcess.Checked ? "Yes" : "No")
                                                                            + "&SkipClaimsAndDeductionsProcess=" + (SkipClaimsAndDeductionsProcess.Checked ? "Yes" : "No")
                                                                            + "&SkipYearEndBonusProcess=" + (SkipYearEndBonusProcess.Checked ? "Yes" : "No")
                                                                            + "&SkipAdditionalRenumerationProcess=" + (SkipAdditionalRenumerationProcess.Checked ? "Yes" : "No")
                                                                            );
            }
        }
        else
        {
            pageErrors.addError("Invalid number of cycle");
        }
    }