Esempio n. 1
0
        protected ESalaryIncrementBatchDetail Transform(DataRow row, int UserID)
        {
            ESalaryIncrementBatchDetail m_new = new ESalaryIncrementBatchDetail();

            string m_EmpNo = row[FIELD_EMP_NO].ToString().Trim();

            m_new.EmpID        = HROne.Import.Parse.GetEmpID(dbConn, m_EmpNo, UserID);
            m_new.SchemeCode   = row[FIELD_SCHEME_CODE].ToString().Trim();
            m_new.Capacity     = row[FIELD_CAPACITY].ToString().Trim();
            m_new.CurrentPoint = Decimal.Parse(row[FIELD_CURRENT_POINT].ToString());
            m_new.NewPoint     = Decimal.Parse(row[FIELD_NEW_POINT].ToString());

            return(m_new);
        }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        foreach (RepeaterItem i in Repeater.Items)
        {
            CheckBox cb = (CheckBox)i.FindControl("ItemSelect");
            if (cb.Checked)
            {
                HtmlInputHidden m_hiddenID = (HtmlInputHidden)i.FindControl("DetailID");

                ESalaryIncrementBatchDetail o = new ESalaryIncrementBatchDetail();
                o.DetailID = int.Parse(m_hiddenID.Value);
                ESalaryIncrementBatchDetail.db.delete(dbConn, o);
            }
        }

        loadData(info, db, Repeater);
    }
Esempio n. 3
0
        protected bool ValidateBusinessRule(ESalaryIncrementBatchDetail inputObject, out string errorMessage)
        {
            // validate if new point is .5 or .0

            if (inputObject.NewPoint % Decimal.One != (decimal)0.5 && inputObject.NewPoint % Decimal.One != Decimal.Zero)
            {
                errorMessage = String.Format("Point({0}) must be a mupltiple of 0.5.", new string[] { inputObject.NewPoint.ToString("0.00") });
                return(false);
            }

            if (inputObject.CurrentPoint + ALLOWABLE_POINT_CHANGE_IN_BACKPAY < inputObject.NewPoint || inputObject.CurrentPoint - ALLOWABLE_POINT_CHANGE_IN_BACKPAY > inputObject.NewPoint)
            {
                errorMessage = String.Format("Point change violation. New Point ({0}) is cannot be 0.5 point more / less than the Original Point({1})", new string[] { inputObject.NewPoint.ToString("0.00"), inputObject.CurrentPoint.ToString("0.00") });
                return(false);
            }

            if (inputObject.SchemeCode != "" && inputObject.Capacity != "" && inputObject.CurrentPoint >= 0)
            {
                DBFilter m_recurringFilter = new DBFilter();

                m_recurringFilter.add(new NullTerm("EmpRPEffTo"));
                m_recurringFilter.add(new Match("EmpID", inputObject.EmpID));

                string m_schemeCode = AppUtils.Encode(EEmpRecurringPayment.db.getField("SchemeCode"), inputObject.SchemeCode);
                string m_capacity   = AppUtils.Encode(EEmpRecurringPayment.db.getField("Capacity"), inputObject.Capacity);

                m_recurringFilter.add(new Match("SchemeCode", m_schemeCode));
                m_recurringFilter.add(new Match("Capacity", m_capacity));
                m_recurringFilter.add(new Match("Point", inputObject.CurrentPoint));

                DBFilter m_paymentTypeFilter = new DBFilter();
                m_paymentTypeFilter.add(new Match("PaymentTypeCode", "BASICSAL"));

                DBFilter m_paymentCodeFilter = new DBFilter();
                m_paymentCodeFilter.add(new IN("PaymentTypeID", "SELECT PaymentTypeID FROM PaymentType", m_paymentTypeFilter));

                m_recurringFilter.add(new IN("PayCodeID", "SELECT PaymentCodeID FROM PaymentCode", m_paymentCodeFilter));
                m_recurringFilter.add("EmpRPID", false);

                ArrayList m_recurringList = EEmpRecurringPayment.db.select(dbConn, m_recurringFilter);

                if (m_recurringList.Count > 0)  // recurring payment matched
                {
                    EEmpRecurringPayment m_recurringPayment = (EEmpRecurringPayment)m_recurringList[0];

                    // cross check if payscale is out of range
                    DBFilter m_payScaleFilter = new DBFilter();
                    m_payScaleFilter.add(new Match("SchemeCode", m_schemeCode));
                    m_payScaleFilter.add(new Match("Capacity", m_capacity));

                    ArrayList m_payScaleList = EPayScale.db.select(dbConn, m_payScaleFilter);
                    if (m_payScaleList.Count > 0)
                    {
                        EPayScale m_payScale = (EPayScale)m_payScaleList[0];
                        if (inputObject.NewPoint < m_payScale.FirstPoint || inputObject.NewPoint > m_payScale.LastPoint)
                        {
                            errorMessage = string.Format("New Point({0}) is out of range({1}-{2}) according to PayScale Setup.", new string[] { inputObject.NewPoint.ToString("0.00"), m_payScale.FirstPoint.ToString("0.00"), m_payScale.LastPoint.ToString("0.00") });
                            return(false);
                        }
                    }
                }
                else
                {
                    errorMessage = string.Format("Recurring Payment not matched. (Scheme Code={0}, Capacity={1}, Point={2})", new string[] { inputObject.SchemeCode, inputObject.Capacity, inputObject.CurrentPoint.ToString("0.00") });
                    return(false);
                }
            }
            else
            {
                errorMessage = string.Format("Recurring Payment not matched. (Scheme Code={0}, Capacity={1}, Point={2})", new string[] { inputObject.SchemeCode, inputObject.Capacity, inputObject.CurrentPoint.ToString("0.00") });
                return(false);
            }
            errorMessage = "";
            return(true);
        }
Esempio n. 4
0
        public override DataTable UploadToTempDatabase(string Filename, int UserID, string ZipPassword)
        {
            ESalaryIncrementBatch m_processHeader = ESalaryIncrementBatch.GetObject(dbConn, m_processID);

            if (m_processHeader == null)
            {
                errors.addError("Salary Increment Batch ID is not initialized!", new string[] { "" });
                return(null);
            }

            DataTable rawDataTable = HROne.Import.ExcelImport.parse(Filename, ZipPassword).Tables[0];
            ArrayList results      = new ArrayList();
            int       rowCount     = 0;
            string    m_errorMessage;
            string    m_colName;

            foreach (DataRow row in rawDataTable.Rows)
            {
                rowCount++;
                if (!ValidateInputData(row, out m_errorMessage, out m_colName))
                {
                    errors.addError(m_errorMessage, new string[] { rowCount.ToString("0"), m_colName });
                }
                else
                {
                    ESalaryIncrementBatchDetail m_upload = Transform(row, UserID);  // m_util.Transform(row);
                    m_upload.BatchID = m_processID;

                    // check batch detail existenc
                    DBFilter m_existingRecordFilter = new DBFilter();
                    m_existingRecordFilter.add(new Match("BatchID", m_processID));
                    m_existingRecordFilter.add(new Match("EmpID", m_upload.EmpID));
                    m_existingRecordFilter.add(new Match("SchemeCode", AppUtils.Encode(ESalaryIncrementBatchDetail.db.getField("SchemeCode"), m_upload.SchemeCode)));
                    m_existingRecordFilter.add(new Match("Capacity", AppUtils.Encode(ESalaryIncrementBatchDetail.db.getField("Capacity"), m_upload.Capacity)));
                    m_existingRecordFilter.add(new Match("CurrentPoint", m_upload.CurrentPoint));

                    ArrayList m_existingRecordList = ESalaryIncrementBatchDetail.db.select(dbConn, m_existingRecordFilter);

                    if (m_existingRecordList.Count > 0)
                    {
                        if (!ValidateBusinessRule(m_upload, out m_errorMessage))
                        {
                            errors.addError(m_errorMessage + "(row#={0})", new string[] { rowCount.ToString("0") });
                        }
                        else
                        {
                            ESalaryIncrementBatchDetail m_currentRecord = (ESalaryIncrementBatchDetail)m_existingRecordList[0];

                            m_currentRecord.NewPoint = m_upload.NewPoint;

                            ESalaryIncrementBatchDetail.db.update(dbConn, m_currentRecord);
                        }
                    }
                    else
                    {
                        errors.addError("Cannot find record from batch. (Row# : {0})", new string[] { rowCount.ToString("0") });
                    }
                }
            }
            if (errors.List.Count <= 0)
            {
                // update process header
                m_processHeader.Status         = ESalaryIncrementBatch.STATUS_OPEN;
                m_processHeader.UploadDateTime = AppUtils.ServerDateTime();
                m_processHeader.UploadBy       = UserID;
                ESalaryIncrementBatch.db.update(dbConn, m_processHeader);
            }

            return(rawDataTable);
        }
    protected int GenerateInitialData(PageErrors errors)
    {
        DateTime m_AsAtDate = new DateTime();
        int      m_count    = 0;

        if (!(DateTime.TryParse(AsAtDate.Value, out m_AsAtDate)))
        {
            errors.addError("Invalid Date Format: As At Date");
            return(0);
        }

        if (CurID < 0)
        {
            errors.addError("Cannot get BatchID");
            return(0);
        }

        if (errors.isEmpty())
        {
            // clear current batch detail
            DBFilter m_BatchDetailFilter = new DBFilter();
            m_BatchDetailFilter.add(new Match("BatchID", CurID));
            ESalaryIncrementBatchDetail.db.delete(dbConn, m_BatchDetailFilter);

            // select as-at-month and as-at-month-1 join-date employee, remove those join-day <=15 (of as-at-month-1) and join-day > 16(of as-at-month)
            DBFilter m_allFilter = new DBFilter();
            DBFilter m_recurringPaymentFilter = new DBFilter();

            m_recurringPaymentFilter.add(new Match("Point", ">=", 0));

            m_allFilter.add(new Match("EmpNextSalaryIncrementDate", m_AsAtDate));
            m_allFilter.add(new IN("EmpID", "SELECT EmpID FROM EmpRecurringPayment", m_recurringPaymentFilter));

            m_allFilter.add(WebUtils.AddRankFilter(Session, "EmpID", true));

            ArrayList m_list = EEmpPersonalInfo.db.select(dbConn, m_allFilter);

            if (m_list.Count > 0)
            {
                DBFilter m_paymentTypeFilter = new DBFilter();
                m_paymentTypeFilter.add(new Match("PaymentTypeCode", "BASICSAL"));

                DBFilter m_paymentCodeFilter = new DBFilter();
                m_paymentCodeFilter.add(new IN("PaymentTypeID", "SELECT PaymentTypeID FROM PaymentType", m_paymentTypeFilter));

                ArrayList m_paymentCodeList = EPaymentCode.db.select(dbConn, m_paymentCodeFilter);

                int[] m_paymentCodeIDList = AppUtils.ObjectList2IDList(m_paymentCodeList, "PaymentCodeID");

                foreach (EEmpPersonalInfo empInfo in m_list)
                {
                    if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                    {
                        DBFilter m_recurringFilter = new DBFilter();
                        m_recurringFilter.add(new NullTerm("EmpRPEffTo"));
                        m_recurringFilter.add(new Match("EmpID", empInfo.EmpID));
//                        m_recurringFilter.add(new IN("PayCodeID", m_paymentCodeIDList));

                        foreach (EEmpRecurringPayment rp in EEmpRecurringPayment.db.select(dbConn, m_recurringFilter))
                        {
                            m_count++;
                            ESalaryIncrementBatchDetail m_detail = new ESalaryIncrementBatchDetail();

                            m_detail.BatchID      = CurID;
                            m_detail.EmpID        = empInfo.EmpID;
                            m_detail.SchemeCode   = rp.SchemeCode;
                            m_detail.Capacity     = rp.Capacity;
                            m_detail.CurrentPoint = rp.Point;
                            m_detail.EmpRPID      = rp.EmpRPID;

                            ESalaryIncrementBatchDetail.db.insert(dbConn, m_detail);
                        }
                    }
                }

                return(m_count);
            }
            else
            {
                errors.addError("No employee in range");
            }
        }
        return(m_count);
    }