Esempio n. 1
0
        public override void ImportToDatabase()
        {
            DataTable dataTable = GetImportDataFromTempDatabase(null);

            if (dataTable.Rows.Count > 0)
            {
                EHitRateProcessImportBatch batchDetail = new EHitRateProcessImportBatch();
                batchDetail.HitRateProcessImportBatchDateTime = AppUtils.ServerDateTime();
                //batchDetail.HitRateProcessImportBatchOriginalFilename = OriginalBatchFilename;
                batchDetail.HitRateProcessImportBatchRemark     = Remark;
                batchDetail.HitRateProcessImportBatchUploadedBy = m_UserID;
                EHitRateProcessImportBatch.db.insert(dbConn, batchDetail);


                foreach (DataRow row in dataTable.Rows)
                {
                    EUploadHitRateProcess obj = new EUploadHitRateProcess();
                    EUploadHitRateProcess.db.toObject(row, obj);

                    EHitRateProcess HitRateProcess = new EHitRateProcess();
                    HitRateProcess.HitRate   = obj.HitRate;
                    HitRateProcess.payCodeID = obj.payCodeID;
                    HitRateProcess.EmpID     = obj.EmpID;
                    HitRateProcess.HitRateProcessImportBatchID = batchDetail.HitRateProcessImportBatchID;

                    EHitRateProcess.db.insert(dbConn, HitRateProcess);
                    EUploadHitRateProcess.db.delete(dbConn, obj);
                }
            }
        }
Esempio n. 2
0
        public DataTable UploadToTempDatabase(DataTable rawDataTable, int UserID)
        {
            if (rawDataTable == null)
            {
                return(GetImportDataFromTempDatabase(null));
            }

            int rowCount = 1;

            //ArrayList results = new ArrayList();
            try
            {
                foreach (DataRow row in rawDataTable.Rows)
                {
                    rowCount++;
                    string EmpNo = row[FIELD_EMP_NO].ToString();
                    int    EmpID = HROne.Import.Parse.GetEmpID(dbConn, EmpNo, UserID);
                    if (EmpID < 0)
                    {
                        errors.addError(ImportErrorMessage.ERROR_ACCESS_DENIED_EMP_NO, new string[] { EmpNo, rowCount.ToString() });
                    }

                    //string EffDateString = row[FIELD_EFFECTIVE_DATE].ToString();
                    //DateTime EffDate = Import.Parse.toDateTimeObject(row[FIELD_EFFECTIVE_DATE]);

                    string paymentCode   = row[FIELD_PAYMENT_CODE].ToString();
                    int    paymentCodeID = Parse.GetPaymentCodeID(dbConn, paymentCode);

                    string percentString = row[FIELD_PERCENT].ToString();
                    double percent       = 0;

                    //string effDateString = row[FIELD_EFF_DATE].ToString();
                    //DateTime effDate = new DateTime();

                    if (EmpID > 0 && double.TryParse(percentString, out percent) && paymentCodeID > 0)
                    {
                        EUploadHitRateProcess HitRateProcess = new EUploadHitRateProcess();
                        HitRateProcess.EmpID              = EmpID;
                        HitRateProcess.payCodeID          = paymentCodeID;
                        HitRateProcess.HitRate            = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(percent, 2, 2);
                        HitRateProcess.payCodeID          = paymentCodeID;
                        HitRateProcess.SessionID          = m_SessionID;
                        HitRateProcess.TransactionDate    = UploadDateTime;
                        HitRateProcess.ImportActionStatus = ImportDBObject.ImportActionEnum.UPDATE;

                        db.insert(dbConn, HitRateProcess);
                    }
                    else
                    {
                        if (EmpID == 0)
                        {
                            errors.addError(ImportErrorMessage.ERROR_INVALID_EMP_NO, new string[] { EmpNo, rowCount.ToString() });
                        }
                        else if (percent <= 0)
                        {
                            errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_PERCENT + "=" + percentString, EmpNo, rowCount.ToString() });
                        }
                        else if (paymentCodeID <= 0)
                        {
                            errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_PAYMENT_CODE + "=" + paymentCode, EmpNo, rowCount.ToString() });
                        }
                    }
                }
            }
            catch (Exception e)
            {
                errors.addError(e.Message, null);
            }
            if (errors.List.Count > 0)
            {
                ClearTempTable();
                throw (new HRImportException(rawDataTable.TableName + "\r\n" + errors.Message()));
            }
            return(GetImportDataFromTempDatabase(null));
        }