protected ELeaveType GetLeaveTypeFromLeaveCode(int LeaveCodeID)
    {
        ELeaveCode m_leaveCode = ELeaveCode.GetObject(dbConn, LeaveCodeID);

        ELeaveType m_leaveType = ELeaveType.GetObject(dbConn, m_leaveCode.LeaveTypeID);

        return(m_leaveType);
    }
Esempio n. 2
0
    protected void Save_Click(object sender, EventArgs e)
    {
        ELeaveBalanceAdjustment c = new ELeaveBalanceAdjustment();

        Hashtable values = new Hashtable();

        binding.toValues(values);

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

        errors.clear();


        db.validate(errors, values);

        if (!errors.isEmpty())
        {
            return;
        }
        db.parse(values, c);


        // validate if Compensation Leave selected, no Balance Reset is allowed
        if (c.LeaveTypeID > 0)
        {
            ELeaveType m_leaveType = ELeaveType.GetObject(dbConn, c.LeaveTypeID);
            if (m_leaveType != null)
            {
                if (m_leaveType.LeaveType == ELeaveType.LEAVETYPECODE_COMPENSATION &&
                    c.LeaveBalAdjType == ELeaveBalanceAdjustment.ADJUST_TYPE_RESET_BALANCE)
                {
                    errors.addError("Compensation Leave Adjustment does not support Balance Reset");
                }
            }

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

        DBFilter filter = new DBFilter();

        filter.add(new Match("EmpID", c.EmpID));
        filter.add(new Match("LeaveBalAdjID", "<>", c.LeaveBalAdjID));
        OR  or = new OR();
        AND and;

        and = new AND();
        and.add(new Match("LeaveBalAdjDate", "=", c.LeaveBalAdjDate));
        and.add(new Match("LeaveTypeID", "=", c.LeaveTypeID));
        or.add(and);

        filter.add(or);
        if (db.count(dbConn, filter) > 0)
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_LEAVE_ADJ_OVERLAP);
        }

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

        WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID);
        //LeaveBalanceCalc leaaveBalCal = new LeaveBalanceCalc(dbConn, c.EmpID);

        if (CurID < 0)
        {
            db.insert(dbConn, c);
            CurID = c.LeaveBalAdjID;
            //leaaveBalCal.RecalculateAfter(c.LeaveBalAdjDate, c.LeaveTypeID);
        }
        else
        {
            //ELeaveBalanceAdjustment leaveBalAdjust = new ELeaveBalanceAdjustment();
            //leaveBalAdjust.LeaveBalAdjID = CurID;
            //db.select(dbConn, leaveBalAdjust);
            db.update(dbConn, c);
            //leaaveBalCal.RecalculateAfter(leaveBalAdjust.LeaveBalAdjDate < c.LeaveBalAdjDate ? leaveBalAdjust.LeaveBalAdjDate : c.LeaveBalAdjDate);
        }
        WebUtils.EndFunction(dbConn);


        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Emp_LeaveBalanceAdjustment_View.aspx?EmpID=" + c.EmpID + "&LeaveBalAdjID=" + CurID);
    }