protected bool loadObject()
    {
        obj = new ELeaveBalanceAdjustment();
        bool isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);

        DBFilter filter = new DBFilter();

        filter.add(new Match("EmpID", CurEmpID));
        filter.add(WebUtils.AddRankFilter(Session, "EmpID", true));
        if (EEmpPersonalInfo.db.count(dbConn, filter) == 0)
        {
            if (CurEmpID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        if (!db.select(dbConn, obj))
        {
            if (CurID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        if (obj.EmpID != CurEmpID)
        {
            if (CurID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        Hashtable values = new Hashtable();

        db.populate(obj, values);
        binding.toControl(values);

        CurEmpID = obj.EmpID;
        return(true);
    }
    protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DataRowView row = (DataRowView)e.Item.DataItem;
        CheckBox    cb  = (CheckBox)e.Item.FindControl("ItemSelect");

        WebFormUtils.LoadKeys(sdb, row, cb);
        e.Item.FindControl("ItemSelect").Visible = toolBar.DeleteButton_Visible;

        ELeaveBalanceAdjustment obj = new ELeaveBalanceAdjustment();

        sdb.toObject(row.Row, obj);
    }
    protected void Delete_Click(object sender, EventArgs e)
    {
        ELeaveBalanceAdjustment c = new ELeaveBalanceAdjustment();

        c.LeaveBalAdjID = CurID;
        ELeaveBalanceAdjustment.db.select(dbConn, c);
        WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID);
        db.delete(dbConn, c);
        WebUtils.EndFunction(dbConn);
        //LeaveBalanceCalc leaaveBalCal = new LeaveBalanceCalc(dbConn, c.EmpID);
        //leaaveBalCal.RecalculateAfter(c.LeaveBalAdjDate, c.LeaveTypeID);
        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "EmpTab_LeaveBalance_View.aspx?EmpID=" + EmpID.Value);
    }
        public void ImportToDatabase(int UploadEmpID)
        {
            DBFilter sessionFilter = new DBFilter();

            sessionFilter.add(new Match("SessionID", m_SessionID));
            if (UploadEmpID > 0)
            {
                sessionFilter.add(new Match("UploadEmpID", UploadEmpID));
            }
            ArrayList uploadList = tempDB.select(dbConn, sessionFilter);

            foreach (EUploadLeaveBalanceAdjustment obj in uploadList)
            {
                ELeaveBalanceAdjustment leaveBalanceAdjustment = new ELeaveBalanceAdjustment();

                if (obj.ImportActionStatus != ImportDBObject.ImportActionEnum.INSERT)
                {
                    leaveBalanceAdjustment.LeaveBalAdjID = obj.LeaveBalAdjID;
                    uploadDB.select(dbConn, leaveBalanceAdjustment);
                }

                obj.ExportToObject(leaveBalanceAdjustment);

                if (obj.ImportActionStatus == ImportDBObject.ImportActionEnum.INSERT)
                {
                    leaveBalanceAdjustment.EmpID = ParseTemp.GetEmpIDFromUploadEmpID(dbConn, obj.UploadEmpID);
                    uploadDB.insert(dbConn, leaveBalanceAdjustment);
                }
                else if (obj.ImportActionStatus == ImportDBObject.ImportActionEnum.UPDATE)
                {
                    uploadDB.update(dbConn, leaveBalanceAdjustment);
                }

                tempDB.delete(dbConn, obj);
            }
        }
Exemple #5
0
    protected void Save_Click(object sender, EventArgs e)
    {
        EEmpPositionInfo newEmpPos = new EEmpPositionInfo();

        Hashtable values = new Hashtable();

        empPosBinding.toValues(values);
        PageErrors errors = PageErrors.getErrors(empPosDB, Page);

        errors.clear();
        empPosDB.validate(errors, values);
        if (!errors.isEmpty())
        {
            return;
        }
        empPosDB.parse(values, newEmpPos);
        int OldEmpPosID = newEmpPos.EmpPosID;

        EEmpPersonalInfo newEmpInfo = new EEmpPersonalInfo();

        values = new Hashtable();
        empBinding.toValues(values);
        errors = PageErrors.getErrors(empDB, Page);
        errors.clear();
        empDB.validate(errors, values);
        if (!errors.isEmpty())
        {
            return;
        }
        empDB.parse(values, newEmpInfo);
        int OldEmpID = newEmpInfo.EmpID;

        newEmpInfo.EmpID = 0;

        newEmpInfo.EmpNo = newEmpInfo.EmpNo.ToUpper();
        if (!AppUtils.checkDuplicate(dbConn, empDB, newEmpInfo, errors, "EmpNo"))
        {
            return;
        }

        DBFilter empTermFilter = new DBFilter();

        empTermFilter.add(new Match("EmpID", OldEmpID));
        empTermFilter.add(WebUtils.AddRankFilter(Session, "EmpID", true));
        ArrayList empTermList = EEmpTermination.db.select(dbConn, empTermFilter);

        if (empTermList.Count == 0)
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_TERMINATION_RECORD_NOT_FOUND);
            return;
        }
        EEmpTermination empTerm = (EEmpTermination)empTermList[0];

        if (!empTerm.EmpTermIsTransferCompany)
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_EMP_NOT_TRANSFERABLE);
            return;
        }
        if (empTerm.NewEmpID >= 0)
        {
            EEmpPersonalInfo NextEmpInfo = new EEmpPersonalInfo();
            NextEmpInfo.EmpID = empTerm.NewEmpID;
            if (EEmpPersonalInfo.db.select(dbConn, NextEmpInfo))
            {
                errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_EMP_TRANSFERRED_BEFORE, new string[] { NextEmpInfo.EmpNo }));
                return;
            }
        }
        empTerm.NewEmpID = CopyEmployeeDetail(OldEmpID);
        EEmpTermination.db.update(dbConn, empTerm);

        newEmpInfo.EmpID         = empTerm.NewEmpID;
        newEmpInfo.EmpStatus     = "A";
        newEmpInfo.EmpDateOfJoin = empTerm.EmpTermLastDate.AddDays(1);
        newEmpInfo.PreviousEmpID = OldEmpID;
        EEmpPersonalInfo.db.update(dbConn, newEmpInfo);

        EEmpPositionInfo oldEmpPos = new EEmpPositionInfo();

        oldEmpPos.EmpPosID = OldEmpPosID;
        if (EEmpPositionInfo.db.select(dbConn, oldEmpPos))
        {
            //oldEmpPos.EmpPosEffTo = empTerm.EmpTermLastDate;
            EEmpPositionInfo.db.update(dbConn, oldEmpPos);
        }
        newEmpPos.EmpPosEffFr = empTerm.EmpTermLastDate.AddDays(1);
        newEmpPos.EmpID       = newEmpInfo.EmpID;
        newEmpPos.EmpPosID    = 0;
        EEmpPositionInfo.db.insert(dbConn, newEmpPos);

        ArrayList list = new ArrayList();

        foreach (RepeaterItem item in HierarchyLevel.Items)
        {
            DropDownList d        = (DropDownList)item.FindControl("HElementID");
            int          HLevelID = Int32.Parse(d.Attributes["HLevelID"]);
            if (d.SelectedIndex > 0)
            {
                EEmpHierarchy h = new EEmpHierarchy();
                h.EmpID      = newEmpInfo.EmpID;
                h.EmpPosID   = newEmpPos.EmpPosID;
                h.HLevelID   = HLevelID;
                h.HElementID = Int32.Parse(d.SelectedValue);
                list.Add(h);
            }
        }

        DBFilter empHierarchyFilter = new DBFilter();

        empHierarchyFilter.add(new Match("EmpID", newEmpInfo.EmpID));
        empHierarchyFilter.add(new Match("EmpPosID", newEmpPos.EmpPosID));
        EEmpHierarchy.db.delete(dbConn, empHierarchyFilter);
        foreach (EEmpHierarchy h in list)
        {
            EEmpHierarchy.db.insert(dbConn, h);
        }

        HROne.LeaveCalc.LeaveBalanceCalc bal = new HROne.LeaveCalc.LeaveBalanceCalc(dbConn, OldEmpID, empTerm.EmpTermLastDate);
        ArrayList balList = bal.getCurrentBalanceList();

        foreach (ELeaveBalance leaveBalance in balList)
        {
            ELeaveBalanceAdjustment leaveAdj = new ELeaveBalanceAdjustment();
            leaveAdj.EmpID             = newEmpInfo.EmpID;
            leaveAdj.LeaveBalAdjDate   = empTerm.EmpTermLastDate;
            leaveAdj.LeaveBalAdjType   = ELeaveBalanceAdjustment.ADJUST_TYPE_RESET_BALANCE;
            leaveAdj.LeaveTypeID       = leaveBalance.LeaveTypeID;
            leaveAdj.LeaveBalAdjValue  = leaveBalance.getBalance();
            leaveAdj.LeaveBalAdjRemark = "System adjustment by transfer company";
            ELeaveBalanceAdjustment.db.insert(dbConn, leaveAdj);
        }


        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Emp_PositionInfo_View.aspx?EmpPosID=" + newEmpPos.EmpPosID + "&EmpID=" + newEmpInfo.EmpID);
    }
Exemple #6
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);
    }
        public DataTable UploadToTempDatabase(DataTable rawDataTable, int UserID)
        {
            if (rawDataTable == null)
            {
                return(GetImportDataFromTempDatabase(null));
            }

            int rowCount = 1;

            foreach (DataRow row in rawDataTable.Rows)
            {
                rowCount++;

                EUploadLeaveBalanceAdjustment uploadLeaveBalanceAdjustment = new EUploadLeaveBalanceAdjustment();
                //EEmpAVCPlan lastEmpAVC = null;
                //ArrayList uploadHierarchyList = new ArrayList();

                string EmpNo = row[FIELD_EMP_NO].ToString().Trim();
                uploadLeaveBalanceAdjustment.EmpID = Parse.GetEmpID(dbConn, EmpNo, UserID);
                if (uploadLeaveBalanceAdjustment.EmpID < 0)
                {
                    errors.addError(ImportErrorMessage.ERROR_ACCESS_DENIED_EMP_NO, new string[] { EmpNo, rowCount.ToString() });
                }
                try
                {
                    uploadLeaveBalanceAdjustment.LeaveBalAdjDate = Parse.toDateTimeObject(row[FIELD_DATE_ADJUST]);
                }
                catch
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_DATE_ADJUST + "=" + row[FIELD_DATE_ADJUST].ToString(), EmpNo, rowCount.ToString() });
                }

                uploadLeaveBalanceAdjustment.LeaveTypeID = Import.Parse.GetLeaveTypeID(dbConn, row[FIELD_LEAVE_TYPE].ToString(), false, UserID);

                if (uploadLeaveBalanceAdjustment.LeaveTypeID == 0)
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_LEAVE_TYPE + "=" + row[FIELD_LEAVE_TYPE].ToString(), EmpNo, rowCount.ToString() });
                }

                string tempString;
                if (rawDataTable.Columns.Contains(FIELD_ADJUST_TYPE))
                {
                    tempString = row[FIELD_ADJUST_TYPE].ToString().Trim();
                    if (tempString.Equals(ELeaveBalanceAdjustment.ADJUST_TYPE_RESET_BALANCE_NAME, StringComparison.CurrentCultureIgnoreCase) ||
                        tempString.Equals(ELeaveBalanceAdjustment.ADJUST_TYPE_RESET_BALANCE, StringComparison.CurrentCultureIgnoreCase))
                    {
                        uploadLeaveBalanceAdjustment.LeaveBalAdjType = ELeaveBalanceAdjustment.ADJUST_TYPE_RESET_BALANCE;
                    }
                    else if (tempString.Equals(ELeaveBalanceAdjustment.ADJUST_TYPE_ADJUSTMENT_NAME, StringComparison.CurrentCultureIgnoreCase) ||
                             tempString.Equals(ELeaveBalanceAdjustment.ADJUST_TYPE_ADJUSTMENT, StringComparison.CurrentCultureIgnoreCase))
                    {
                        uploadLeaveBalanceAdjustment.LeaveBalAdjType = ELeaveBalanceAdjustment.ADJUST_TYPE_ADJUSTMENT;
                    }
                    //else if (tempString.Equals(string.Empty))
                    //    uploadLeaveApp.LeaveAppUnit = string.Empty;
                    else
                    {
                        errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_ADJUST_TYPE + "=" + row[FIELD_ADJUST_TYPE].ToString(), EmpNo, rowCount.ToString() });
                    }
                }
                double adjustValue;
                if (double.TryParse(row[FIELD_ADJUST_VALUE].ToString(), out adjustValue))
                {
                    uploadLeaveBalanceAdjustment.LeaveBalAdjValue = adjustValue;
                }
                else
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_ADJUST_VALUE + "=" + row[FIELD_ADJUST_VALUE].ToString(), EmpNo, rowCount.ToString() });
                }

                uploadLeaveBalanceAdjustment.LeaveBalAdjRemark = row[FIELD_REMARK].ToString();

                uploadLeaveBalanceAdjustment.SessionID       = m_SessionID;
                uploadLeaveBalanceAdjustment.TransactionDate = UploadDateTime;


                if (uploadLeaveBalanceAdjustment.EmpID != 0 && errors.List.Count <= 0)
                {
                    if (rawDataTable.Columns.Contains(FIELD_SYNC_ID))
                    {
                        if (!row.IsNull(FIELD_SYNC_ID))
                        {
                            string strSynID = row[FIELD_SYNC_ID].ToString();
                            uploadLeaveBalanceAdjustment.SynID = strSynID;
                            if (!string.IsNullOrEmpty(strSynID))
                            {
                                DBFilter synIDFilter = new DBFilter();
                                synIDFilter.add(new Match("SynID", strSynID));
                                ArrayList objSameSynIDList = ELeaveBalanceAdjustment.db.select(dbConn, synIDFilter);
                                if (objSameSynIDList.Count > 0)
                                {
                                    uploadLeaveBalanceAdjustment.LeaveBalAdjID = ((ELeaveBalanceAdjustment)objSameSynIDList[0]).LeaveBalAdjID;
                                }
                            }
                        }
                    }

                    if (uploadLeaveBalanceAdjustment.LeaveBalAdjID == 0)
                    {
                        AND andTerm = new AND();
                        andTerm.add(new Match("LeaveBalAdjDate", "=", uploadLeaveBalanceAdjustment.LeaveBalAdjDate));
                        andTerm.add(new Match("LeaveTypeID", "=", uploadLeaveBalanceAdjustment.LeaveTypeID));
                        ELeaveBalanceAdjustment lastObject = (ELeaveBalanceAdjustment)AppUtils.GetLastObj(dbConn, uploadDB, "LeaveBalAdjDate", uploadLeaveBalanceAdjustment.EmpID, andTerm);
                        if (lastObject != null)
                        {
                            uploadLeaveBalanceAdjustment.LeaveBalAdjID = lastObject.LeaveBalAdjID;
                        }
                    }
                }

                if (uploadLeaveBalanceAdjustment.LeaveBalAdjID <= 0)
                {
                    uploadLeaveBalanceAdjustment.ImportActionStatus = ImportDBObject.ImportActionEnum.INSERT;
                }
                else
                {
                    uploadLeaveBalanceAdjustment.ImportActionStatus = ImportDBObject.ImportActionEnum.UPDATE;
                }

                uploadLeaveBalanceAdjustment.UploadEmpID = ParseTemp.GetUploadEmpID(dbConn, EmpNo, m_SessionID);
                if (uploadLeaveBalanceAdjustment.UploadEmpID == 0)
                {
                    if (uploadLeaveBalanceAdjustment.EmpID == 0)
                    {
                        errors.addError(ImportErrorMessage.ERROR_INVALID_EMP_NO, new string[] { EmpNo, rowCount.ToString() });
                    }
                    else
                    {
                        uploadLeaveBalanceAdjustment.UploadEmpID = ImportEmpPersonalInfoProcess.CreateDummyUploadEmployeeInfo(dbConn, uploadLeaveBalanceAdjustment.EmpID, m_SessionID, UploadDateTime);
                    }
                }

                Hashtable values = new Hashtable();
                tempDB.populate(uploadLeaveBalanceAdjustment, values);
                PageErrors pageErrors = new PageErrors(EUploadLeaveBalanceAdjustment.db);
                tempDB.validate(pageErrors, values);
                if (pageErrors.errors.Count == 0)
                {
                    tempDB.insert(dbConn, uploadLeaveBalanceAdjustment);
                }
                else
                {
                    pageErrors.addError(rawDataTable.TableName);
                    throw new HRImportException(pageErrors.getPrompt() + "(line " + rowCount.ToString() + ")");

                    //if (EmpID == 0)
                    //    errors.addError(ImportErrorMessage.ERROR_INVALID_EMP_NO, new string[] { EmpNo, rowCount.ToString() });
                    //else if (PayCodeID == 0)
                    //    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_PAYMENT_CODE + "=" + PaymentCode, EmpNo, rowCount.ToString() });
                    //else if (PayCodeID == 0)
                    //    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_PAYMENT_CODE + "=" + PaymentCode, EmpNo, rowCount.ToString() });
                    //else if (EffDate.Ticks == 0)
                    //    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_EFFECTIVE_DATE + "=" + EffDateString, EmpNo, rowCount.ToString() });
                    //else if (double.TryParse(amountString, out amount))
                    //    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_AMOUNT + "=" + amountString, EmpNo, rowCount.ToString() });
                }
            }
            if (errors.List.Count > 0)
            {
                ClearTempTable();
                throw (new HRImportException(rawDataTable.TableName + "\r\n" + errors.Message()));
            }
            return(GetImportDataFromTempDatabase(null));
        }