Пример #1
0
    protected void Save_Click(object sender, EventArgs e)
    {
        ERequestOTClaim c = new ERequestOTClaim();

        Hashtable values = new Hashtable();

        binding.toValues(values);

        PageErrors errors = PageErrors.getErrors(db, Page);

        errors.clear();


        db.validate(errors, values);

        if (!errors.isEmpty())
        {
            return;
        }


        db.parse(values, c);

        if (c.RequestOTClaimHourTo < c.RequestOTClaimHourFrom)
        {
            errors.addError("RequestOTClaimTimeFrom", "Invald hours");
        }
        if (c.RequestOTClaimPeriodTo < c.RequestOTClaimPeriodFrom)
        {
            errors.addError("RequestOTClaimPeriodFrom", "Date To cannot be earlier than Date From");
        }

        if (c.RequestOTHours <= 0)
        {
            errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_FIELD_REQUIRED, new string[] { lblOTHours.Text }));
        }

        if (!errors.isEmpty())
        {
            return;
        }

        // Start Ricky So, 2014-09-05, Avoid checking time overlap for CL Requisition
        //ArrayList overlapOTClaimList = new ArrayList();
        //if (c.IsOverlapOTClaim(dbConn, out overlapOTClaimList))
        //{
        //    string strHourlyOverlapMessage = string.Empty;

        //    foreach (BaseObject overlapOTClaim in overlapOTClaimList)
        //    {
        //        if (overlapOTClaim is EOTClaim)
        //        {
        //            EOTClaim previousOTClaim = (EOTClaim)overlapOTClaim;
        //            if (string.IsNullOrEmpty(strHourlyOverlapMessage))
        //                strHourlyOverlapMessage = "Leave time cannot overlap with previous CL Requisition";
        //        }
        //        else if (overlapOTClaim is ERequestOTClaim)
        //        {
        //            ERequestOTClaim previousRequestOTClaim = (ERequestOTClaim)overlapOTClaim;
        //            if (string.IsNullOrEmpty(strHourlyOverlapMessage))
        //                strHourlyOverlapMessage = "Leave time cannot overlap with previous CL Requisition";

        //        }
        //    }

        //    if (!string.IsNullOrEmpty(strHourlyOverlapMessage))
        //        errors.addError(strHourlyOverlapMessage);
        //}
        // End Ricky So, 2014-09-05

        if (!errors.isEmpty())
        {
            return;
        }

        try
        {
            ESSAuthorizationProcess authorization = new ESSAuthorizationProcess(dbConn);
            authorization.SubmitOTClaim(c);
        }
        catch (Exception ex)
        {
            errors.addError(ex.Message);
        }

        if (!errors.isEmpty())
        {
            return;
        }
        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/ESS_EmpRequestStatus.aspx");
    }