public override void ImportToDatabase() { DataTable dataTable = GetImportDataFromTempDatabase(null); if (dataTable.Rows.Count > 0) { EDoublePayAdjustmentImportBatch batchDetail = new EDoublePayAdjustmentImportBatch(); batchDetail.DoublePayAdjustImportBatchDateTime = AppUtils.ServerDateTime(); //batchDetail.DoublePayAdjustImportBatchOriginalFilename = OriginalBatchFilename; batchDetail.DoublePayAdjustImportBatchRemark = Remark; batchDetail.DoublePayAdjustImportBatchUploadedBy = m_UserID; EDoublePayAdjustmentImportBatch.db.insert(dbConn, batchDetail); foreach (DataRow row in dataTable.Rows) { EUploadDoublePayAdjustment obj = new EUploadDoublePayAdjustment(); EUploadDoublePayAdjustment.db.toObject(row, obj); EDoublePayAdjustment DoublePayAdjust = new EDoublePayAdjustment(); DoublePayAdjust.SalesAchievementRate = obj.SalesAchievementRate; DoublePayAdjust.DoublePayAdjustEffDate = obj.DoublePayAdjustEffDate; DoublePayAdjust.EmpID = obj.EmpID; DoublePayAdjust.DoublePayAdjustImportBatchID = batchDetail.DoublePayAdjustImportBatchID; EDoublePayAdjustment.db.insert(dbConn, DoublePayAdjust); EUploadDoublePayAdjustment.db.delete(dbConn, obj); } } }
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 percentString = row[FIELD_PERCENT].ToString(); double percent = 0; string effDateString = row[FIELD_EFF_DATE].ToString(); DateTime effDate = new DateTime(); //if (EmpID > 0 && EffDate.Ticks != 0 && double.TryParse(percentString, out percent)) if (EmpID > 0 && double.TryParse(percentString, out percent) && DateTime.TryParse(effDateString, out effDate)) { EUploadDoublePayAdjustment DoublePayAdjust = new EUploadDoublePayAdjustment(); DoublePayAdjust.EmpID = EmpID; DoublePayAdjust.SalesAchievementRate = HROne.CommonLib.GenericRoundingFunctions.RoundingTo(percent, 2, 2); DoublePayAdjust.DoublePayAdjustEffDate = effDate; DoublePayAdjust.SessionID = m_SessionID; DoublePayAdjust.TransactionDate = UploadDateTime; DoublePayAdjust.ImportActionStatus = ImportDBObject.ImportActionEnum.UPDATE; db.insert(dbConn, DoublePayAdjust); } else { if (EmpID == 0) { errors.addError(ImportErrorMessage.ERROR_INVALID_EMP_NO, new string[] { EmpNo, rowCount.ToString() }); } else if (effDate.Ticks == 0) { errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_EFF_DATE + "=" + effDateString, EmpNo, rowCount.ToString() }); } else if (!double.TryParse(percentString, out percent)) { errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_PERCENT + "=" + percentString, 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)); }