public DataSet GetDataSetByCondition(String strConditionQuery) { String strQuery = QueryGenerator.GenSelectAll(TableName, false, true); strQuery = QueryGenerator.AddCondition(strQuery, strConditionQuery); return(DatabaseHelper.RunQuery(strQuery)); }
public static Dictionary <String, object> GetSameColumnValues(List <Guid> lstObjects, String strTableName) { String strQuery = QueryGenerator.GenSelect(strTableName, "*", false); strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@"{0} IN ({1})", DataStructureProvider.GetPrimaryKeyColumn(strTableName), string.Format("'{0}'", String.Join("','", lstObjects)))); return(GetSameColumnValues(BusinessControllerFactory.GetBusinessController(strTableName).GetList(strQuery))); }
public static Boolean IsNeedAlert(Guid alertID) { if (AlertList == null) { GetAlertConfigs(ABCUserProvider.CurrentUser.ADUserID); } if (AlertList.ContainsKey(alertID) == false) { return(false); } GEAlertsInfo alertInfo = AlertList[alertID]; if (alertInfo == null || alertInfo.GetID() == null) { return(false); } String strQuery = QueryGenerator.GenSelect(alertInfo.TableName, "COUNT(*)", false); strQuery = QueryGenerator.AddCondition(strQuery, alertInfo.ConditionString); object obj = BusinessObjectController.GetData(strQuery); if (obj != null && obj != DBNull.Value) { return(Convert.ToInt32(obj) > 0); } return(false); }
public void ReloadDatas( ) { if (!String.IsNullOrWhiteSpace(TableName) && GridCtrl != null && DataStructureProvider.IsExistedTable(TableName)) { BusinessObjectController ctrl = BusinessControllerFactory.GetBusinessController(TableName); String strQuery = QueryGenerator.GenSelect(TableName, "*", true); strQuery = QueryGenerator.AddCondition(strQuery, ConditionString); if (DataStructureProvider.IsTableColumn(TableName, ABCCommon.ABCConstString.colDocumentDate)) { strQuery = strQuery + String.Format(@" ORDER BY {0} DESC", ABCCommon.ABCConstString.colDocumentDate); } GridCtrl.GridDataSource = ctrl.GetListByQuery(strQuery); GridCtrl.RefreshDataSource(); this.GridCtrl.GridDefaultView.BestFitColumns(); } }
public static double GetCredit(Guid partnerID, CreditConfigType configType) { double amt = 0; foreach (CRCreditConfigsInfo config in GetCreditConfigs(configType)) { String strFKPartnerIDCol = config.PartnerIDField; if (String.IsNullOrWhiteSpace(strFKPartnerIDCol)) { strFKPartnerIDCol = "FK_MAPartnerID"; } String strQuery = QueryGenerator.GenSelect(config.TableName, String.Format("SUM({0})", config.AmtFCField), true); strQuery = QueryGenerator.AddCondition(strQuery, config.ConditionString); if (DataStructureProvider.IsTableColumn(config.TableName, strFKPartnerIDCol)) { strQuery = QueryGenerator.AddEqualCondition(strQuery, strFKPartnerIDCol, partnerID); } else { if (DataStructureProvider.IsExistedTable(config.ParentTableName)) { if (DataStructureProvider.IsTableColumn(config.ParentTableName, strFKPartnerIDCol)) { String strFK = DataStructureProvider.GetForeignKeyOfTableName(config.TableName, config.ParentTableName); String strQuery2 = QueryGenerator.GenSelect(config.ParentTableName, DataStructureProvider.GetPrimaryKeyColumn(config.ParentTableName), true); strQuery2 = QueryGenerator.AddEqualCondition(strQuery2, strFKPartnerIDCol, partnerID); strQuery = QueryGenerator.AddCondition(strQuery, String.Format("{0} IN ({1})", strFK, strQuery2)); } } } object obj = BusinessObjectController.GetData(strQuery); if (obj != null && obj != DBNull.Value) { amt += Convert.ToDouble(obj); } } return(amt); }
public static Numbering GetNumberingConfig(BusinessObject obj) { if (NumberingConfigs == null || NumberingTypes == null) { InitializeNumberings(); } foreach (Numbering config in NumberingConfigs) { if (config.TableName != obj.AATableName) { continue; } if (!String.IsNullOrWhiteSpace(config.FieldCondition) && !String.IsNullOrWhiteSpace(config.FieldValue)) { object fileValue = ABCDynamicInvoker.GetValue(obj, config.FieldCondition); if (fileValue == null || fileValue == DBNull.Value || fileValue.ToString() != config.FieldValue) { continue; } } if (!String.IsNullOrWhiteSpace(config.ConditionString)) { String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false); strQuery = QueryGenerator.AddCondition(strQuery, config.ConditionString); strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@"{0}='{1}'", DataStructureProvider.GetPrimaryKeyColumn(obj.AATableName), obj.GetID())); object objCount = BusinessObjectController.GetData(strQuery); if (objCount == null || objCount == DBNull.Value || Convert.ToInt32(objCount.ToString()) <= 0) { continue; } } return(config); } return(null); }
public static void Synchronize(STDataServerSyncsInfo syncInfo) { if (!syncInfo.FK_STDataServerID.HasValue) { return; } if (!syncInfo.IsPull && !syncInfo.IsPush) { return; } if (syncInfo.LastSyncDate.HasValue && syncInfo.IntervalMinute.HasValue && (DateTime.Now < syncInfo.LastSyncDate.Value || DateTime.Now.Subtract(syncInfo.LastSyncDate.Value).TotalMinutes < syncInfo.IntervalMinute.Value)) { return; } STDataServersController serverCtrl = new STDataServersController(); STDataServersInfo server = serverCtrl.GetObjectByID(syncInfo.FK_STDataServerID.Value) as STDataServersInfo; if (server == null) { return; } DBConnectionController connection = null; if (DataStructureProvider.IsSystemTable(syncInfo.TableName)) { connection = InitSystemConnection(server.STDataServerID); } else { connection = InitCompanyConnection(server.STDataServerID); } if (connection != null) { using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope()) { String strRunQuery = @"SET XACT_ABORT ON;BEGIN TRANSACTION ABCSYNC; "; String strQuery = String.Empty; if (syncInfo.IsPush) { if (syncInfo.IsPushMatched) { #region Delete strQuery = String.Format(@"DELETE [{0}].[{1}].[dbo].[{2}] WHERE [{3}] NOT IN (SELECT [{3}] FROM [dbo].[{2}] )", server.Name, connection.Connection.DatabaseName, syncInfo.TableName, DataStructureProvider.GetPrimaryKeyColumn(syncInfo.TableName)); strRunQuery = String.Format(@"{0} {1}", strRunQuery, Environment.NewLine + strQuery); #endregion } #region Insert New Records strQuery = QueryGenerator.GenSelect(syncInfo.TableName, DataStructureProvider.GetPrimaryKeyColumn(syncInfo.TableName), false, false); if (syncInfo.LastSyncDate.HasValue && DataStructureProvider.IsTableColumn(syncInfo.TableName, ABCCommon.ABCConstString.colCreateTime)) { strQuery = QueryGenerator.AddCondition(strQuery, String.Format("{0} > '{1}'", ABCCommon.ABCConstString.colCreateTime, syncInfo.LastSyncDate.Value.ToString("yyyy-MM-dd HH:mm:ss"))); } strQuery = String.Format(@"INSERT INTO [{0}].[{1}].[dbo].[{2}] SELECT * FROM [dbo].[{2}] WHERE [dbo].[{2}].[{3}] IN ({4}) AND [dbo].[{2}].[{3}] NOT IN (SELECT {3} FROM [{0}].[{1}].[dbo].[{2}])", server.Name, connection.Connection.DatabaseName, syncInfo.TableName, DataStructureProvider.GetPrimaryKeyColumn(syncInfo.TableName), strQuery); strRunQuery = String.Format(@"{0} {1}", strRunQuery, Environment.NewLine + strQuery); #endregion #region Update Modified Records strQuery = QueryGenerator.GenSelect(syncInfo.TableName, DataStructureProvider.GetPrimaryKeyColumn(syncInfo.TableName), false, false); if (syncInfo.LastSyncDate.HasValue && DataStructureProvider.IsTableColumn(syncInfo.TableName, ABCCommon.ABCConstString.colUpdateTime)) { strQuery = QueryGenerator.AddCondition(strQuery, String.Format("{0} > '{1}'", ABCCommon.ABCConstString.colUpdateTime, syncInfo.LastSyncDate.Value.ToString("yyyy-MM-dd HH:mm:ss"))); } strQuery = String.Format(@"UPDATE [{0}].[{1}].[dbo].[{2}] SET #FIELD# FROM [{0}].[{1}].[dbo].[{2}] Target,[dbo].[{2}] Source WHERE Target.[{3}]=Source.[{3}] AND Source.[{3}] IN ({4}) AND Source.[{3}] IN (SELECT {3} FROM [{0}].[{1}].[dbo].[{2}])", server.Name, connection.Connection.DatabaseName, syncInfo.TableName, DataStructureProvider.GetPrimaryKeyColumn(syncInfo.TableName), strQuery); List <String> lstSetFields = new List <string>(); foreach (String strField in DataStructureProvider.GetAllTableColumns(syncInfo.TableName).Keys) { if (DataStructureProvider.IsPrimaryKey(syncInfo.TableName, strField) == false) { lstSetFields.Add(String.Format(" [{0}]=Source.[{0}] ", strField)); } } strQuery = strQuery.Replace("#FIELD#", String.Join(",", lstSetFields)); strRunQuery = String.Format(@"{0} {1}", strRunQuery, Environment.NewLine + strQuery); #endregion } if (syncInfo.IsPull) { if (syncInfo.IsPullMatched) { #region Delete strQuery = String.Format(@"DELETE [dbo].[{2}] WHERE [{3}] NOT IN (SELECT [{3}] FROM [{0}].[{1}].[dbo].[{2}] )", server.Name, connection.Connection.DatabaseName, syncInfo.TableName, DataStructureProvider.GetPrimaryKeyColumn(syncInfo.TableName)); strRunQuery = String.Format(@"{0} {1}", strRunQuery, Environment.NewLine + strQuery); #endregion } #region Insert New Records strQuery = QueryGenerator.GenSelect(syncInfo.TableName, DataStructureProvider.GetPrimaryKeyColumn(syncInfo.TableName), false, false); if (syncInfo.LastSyncDate.HasValue && DataStructureProvider.IsTableColumn(syncInfo.TableName, ABCCommon.ABCConstString.colCreateTime)) { strQuery = QueryGenerator.AddCondition(strQuery, String.Format("{0} > '{1}'", ABCCommon.ABCConstString.colCreateTime, syncInfo.LastSyncDate.Value.ToString("yyyy-MM-dd HH:mm:ss"))); } strQuery = strQuery.Replace("[dbo]", String.Format(@"[{0}].[{1}].[dbo]", server.Name, connection.Connection.DatabaseName)); strQuery = String.Format(@"INSERT INTO [dbo].[{2}] SELECT * FROM [{0}].[{1}].[dbo].[{2}] WHERE [{3}] IN ({4}) AND [{3}] NOT IN (SELECT {3} FROM [dbo].[{2}])", server.Name, connection.Connection.DatabaseName, syncInfo.TableName, DataStructureProvider.GetPrimaryKeyColumn(syncInfo.TableName), strQuery); strRunQuery = String.Format(@"{0} {1}", strRunQuery, Environment.NewLine + strQuery); #endregion #region Update Modified Records strQuery = QueryGenerator.GenSelect(syncInfo.TableName, DataStructureProvider.GetPrimaryKeyColumn(syncInfo.TableName), false, false); if (syncInfo.LastSyncDate.HasValue && DataStructureProvider.IsTableColumn(syncInfo.TableName, ABCCommon.ABCConstString.colUpdateTime)) { strQuery = QueryGenerator.AddCondition(strQuery, String.Format("{0} > '{1}'", ABCCommon.ABCConstString.colUpdateTime, syncInfo.LastSyncDate.Value.ToString("yyyy-MM-dd HH:mm:ss"))); } strQuery = strQuery.Replace("[dbo]", String.Format(@"[{0}].[{1}].[dbo]", server.Name, connection.Connection.DatabaseName)); strQuery = String.Format(@"UPDATE [dbo].[{2}] SET #FIELD# FROM [dbo].[{2}] Target,[{0}].[{1}].[dbo].[{2}] Source WHERE Target.[{3}]=Source.[{3}] AND Source.[{3}] IN ({4}) AND Source.[{3}] IN (SELECT {3} FROM [dbo].[{2}])", server.Name, connection.Connection.DatabaseName, syncInfo.TableName, DataStructureProvider.GetPrimaryKeyColumn(syncInfo.TableName), strQuery); List <String> lstSetFields = new List <string>(); foreach (String strField in DataStructureProvider.GetAllTableColumns(syncInfo.TableName).Keys) { if (DataStructureProvider.IsPrimaryKey(syncInfo.TableName, strField) == false) { lstSetFields.Add(String.Format(" [{0}]=Source.[{0}] ", strField)); } } strQuery = strQuery.Replace("#FIELD#", String.Join(",", lstSetFields)); strRunQuery = String.Format(@"{0} {1}", strRunQuery, Environment.NewLine + strQuery); #endregion } strRunQuery = String.Format(@"{0} COMMIT TRANSACTION ABCSYNC; SET XACT_ABORT OFF;", strRunQuery + Environment.NewLine); BusinessObjectController.RunQuery(strRunQuery, syncInfo.TableName); BusinessObjectController.RunQuery(String.Format(@"UPDATE STDataServerSyncs SET LastSyncDate =GetDate() WHERE STDataServerSyncID='{0}'", syncInfo.GetID()), syncInfo.AATableName); scope.Complete(); } } }
public static String GetAlertQueryString(Guid alertID) { if (AlertList == null) { GetAlertConfigs(ABCUserProvider.CurrentUser.ADUserID); } if (AlertList.ContainsKey(alertID) == false) { return(String.Empty); } if (AlertQueryList.ContainsKey(alertID)) { return(AlertQueryList[alertID]); } GEAlertsInfo alertInfo = AlertList[alertID]; if (alertInfo == null || alertInfo.GetID() == null) { return(String.Empty); } String strQuery = QueryGenerator.GenSelect(alertInfo.TableName, "*", false); strQuery = QueryGenerator.AddCondition(strQuery, alertInfo.ConditionString); #region Filter with current User if (alertInfo.ByUser) { String strFK = DataStructureProvider.GetForeignKeyOfTableName(alertInfo.TableName, "ADUsers"); if (!String.IsNullOrWhiteSpace(strFK) && ABCUserProvider.CurrentUser != null) { strQuery = QueryGenerator.AddCondition(strQuery, String.Format(" {0} = '{1}'", strFK, ABCUserProvider.CurrentUser.ADUserID)); } } if (alertInfo.ByUserGroup) { String strFK = DataStructureProvider.GetForeignKeyOfTableName(alertInfo.TableName, "ADUsers"); if (!String.IsNullOrWhiteSpace(strFK) && ABCUserProvider.CurrentUser != null) { if (ABCUserProvider.CurrentUserGroup != null) { String strQueryUserID = QueryGenerator.AddEqualCondition(QueryGenerator.GenSelect("ADUsers", "ADUserID", false), "FK_ADUserGroupID", ABCUserProvider.CurrentUserGroup.ADUserGroupID); strQuery = QueryGenerator.AddCondition(strQuery, String.Format("{0} IN ({1})", strFK, strQueryUserID)); } } else { strFK = DataStructureProvider.GetForeignKeyOfTableName(alertInfo.TableName, "ADUserGroups"); if (!String.IsNullOrWhiteSpace(strFK) && ABCUserProvider.CurrentUserGroup != null) { strQuery = QueryGenerator.AddCondition(strQuery, String.Format(" {0} = '{1}'", strFK, ABCUserProvider.CurrentUserGroup.ADUserGroupID)); } } } if (alertInfo.ByEmployee) { String strFK = DataStructureProvider.GetForeignKeyOfTableName(alertInfo.TableName, "HREmployees"); if (!String.IsNullOrWhiteSpace(strFK) && ABCUserProvider.CurrentEmployee != null) { strQuery = QueryGenerator.AddCondition(strQuery, String.Format(" {0} = '{1}'", strFK, ABCUserProvider.CurrentEmployee.HREmployeeID)); } } if (alertInfo.ByCompanyUnit) { String strFK = DataStructureProvider.GetForeignKeyOfTableName(alertInfo.TableName, "GECompanyUnits"); if (!String.IsNullOrWhiteSpace(strFK) && ABCUserProvider.CurrentCompanyUnit != null) { strQuery = QueryGenerator.AddCondition(strQuery, String.Format(" {0} = '{1}'", strFK, ABCUserProvider.CurrentCompanyUnit.GECompanyUnitID)); } else { if (!String.IsNullOrWhiteSpace(strFK) && !String.IsNullOrWhiteSpace(DataStructureProvider.GetForeignKeyOfTableName("HREmployees", "GECompanyUnits"))) { String strTemp = QueryGenerator.GenSelect("GECompanyUnits", DataStructureProvider.GetForeignKeyOfTableName("HREmployees", "GECompanyUnits"), false); strQuery = QueryGenerator.AddCondition(strQuery, String.Format(" {0} IN ({1})", strFK, strTemp)); } } } #endregion if (DataStructureProvider.IsTableColumn(alertInfo.TableName, ABCCommon.ABCConstString.colDocumentDate)) { strQuery = strQuery + String.Format(@" ORDER BY {0} DESC", ABCCommon.ABCConstString.colDocumentDate); } AlertQueryList.Add(alertID, strQuery); return(strQuery); }
public static String GenerateNo(BusinessObject obj) { if (obj.GetID() == Guid.Empty) { obj.SetNoValue(String.Empty); return(String.Empty); } String strNoValue = String.Empty; Numbering numbering = GetNumberingConfig(obj); if (numbering != null) { if (!numbering.IsUsePattern) { #region Not UsePattern if (numbering.MiddleConfigs.Count > 0) { #region Have Parts List <String> lstParts = new List <string>(); foreach (NumberingType numberType in numbering.MiddleConfigs) { #region Others if (numberType.IsByUser) { } if (numberType.IsByUserGroup) { } if (numberType.IsByEmployee) { } if (numberType.IsByCompanyUnit) { } #endregion if ((numberType.IsYYMMCount || numberType.IsYYMMDDCount || numberType.IsMMDDCount)) { String strDateCol = String.Empty; if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateTime)) { strDateCol = ABCCommon.ABCConstString.colCreateTime; } if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colDocumentDate)) { strDateCol = ABCCommon.ABCConstString.colDocumentDate; } if (!String.IsNullOrWhiteSpace(strDateCol)) { object objValue = ABCDynamicInvoker.GetValue(obj, strDateCol); if (objValue != null && (objValue is DateTime || (objValue is Nullable <DateTime> && (objValue as Nullable <DateTime>).HasValue))) { #region With DateTime DateTime createTime = DateTime.MinValue; if (objValue is Nullable <DateTime> ) { createTime = (objValue as Nullable <DateTime>).Value; } else { createTime = Convert.ToDateTime(objValue); } if (numberType.IsYYMMCount) { String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false, false); strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@" YEAR({0}) = {1} AND MONTH({0}) = {2} AND {0} < {3}", strDateCol, createTime.Year, createTime.Month, TimeProvider.GenDateTimeString(createTime))); int iCount = Convert.ToInt32(BusinessObjectController.GetData(strQuery)); if (iCount <= 0) { iCount = 0; } iCount++; int iCountSpace = numberType.CountingSpace; if (iCountSpace < iCount.ToString().Length) { iCountSpace = iCount.ToString().Length + 2; } String strTemp = createTime.ToString("yyMM") + String.Format("{0:D" + iCountSpace + "}", iCount); lstParts.Add(strTemp); } if (numberType.IsYYMMDDCount) { String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false, false); strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@" YEAR({0}) = {1} AND MONTH({0}) = {2} AND DAY({0}) = {3} AND {0} < {4}", strDateCol, createTime.Year, createTime.Month, createTime.Day, TimeProvider.GenDateTimeString(createTime))); int iCount = Convert.ToInt32(BusinessObjectController.GetData(strQuery)); if (iCount <= 0) { iCount = 0; } iCount++; int iCountSpace = numberType.CountingSpace; if (iCountSpace < iCount.ToString().Length) { iCountSpace = iCount.ToString().Length + 2; } String strTemp = createTime.ToString("yyMMdd") + String.Format("{0:D" + iCountSpace + "}", iCount); lstParts.Add(strTemp); } if (numberType.IsMMDDCount) { String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false, false); strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@" YEAR({0}) = {1} AND MONTH({0}) = {2} AND DAY({0}) = {3} AND {0} < {4}", strDateCol, createTime.Year, createTime.Month, createTime.Day, TimeProvider.GenDateTimeString(createTime))); int iCount = Convert.ToInt32(BusinessObjectController.GetData(strQuery)); if (iCount <= 0) { iCount = 0; } iCount++; int iCountSpace = numberType.CountingSpace; if (iCountSpace < iCount.ToString().Length) { iCountSpace = iCount.ToString().Length + 2; } String strTemp = createTime.ToString("MMdd") + String.Format("{0:D" + iCountSpace + "}", iCount); lstParts.Add(strTemp); } #endregion } } } #region By Field if (numberType.IsByField && !String.IsNullOrWhiteSpace(numberType.FieldName)) { if (DataStructureProvider.IsTableColumn(obj.AATableName, numberType.FieldName)) { object objValue = ABCDynamicInvoker.GetValue(obj, numberType.FieldName); if (objValue != null) { if (DataStructureProvider.IsForeignKey(obj.AATableName, numberType.FieldName)) { String strFieldName = numberType.FieldName + ":" + DataStructureProvider.GetDisplayColumn(obj.AATableName); objValue = DataCachingProvider.GetCachingObjectAccrossTable(obj, ABCHelper.DataConverter.ConvertToGuid(objValue), strFieldName); } lstParts.Add(objValue.ToString()); } } } #endregion } strNoValue = numbering.Prefix + String.Join(numbering.SeperateChar, lstParts) + numbering.Suffix; #endregion } else { String strDateCol = String.Empty; if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateTime)) { strDateCol = ABCCommon.ABCConstString.colCreateTime; } if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colDocumentDate)) { strDateCol = ABCCommon.ABCConstString.colDocumentDate; } if (!String.IsNullOrWhiteSpace(strDateCol)) { object objValue = ABCDynamicInvoker.GetValue(obj, strDateCol); if (objValue != null && (objValue is DateTime || (objValue is Nullable <DateTime> && (objValue as Nullable <DateTime>).HasValue))) { #region With DateTime DateTime createTime = DateTime.MinValue; if (objValue is Nullable <DateTime> ) { createTime = (objValue as Nullable <DateTime>).Value; } else { createTime = Convert.ToDateTime(objValue); } String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false, false); strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@" YEAR({0}) = {1} AND MONTH({0}) = {2} AND {0} < {3}", strDateCol, createTime.Year, createTime.Month, TimeProvider.GenDateTimeString(createTime))); int iCount = Convert.ToInt32(BusinessObjectController.GetData(strQuery)); if (iCount <= 0) { iCount = 0; } iCount++; int iCountSpace = 3; if (iCountSpace < iCount.ToString().Length) { iCountSpace = iCount.ToString().Length + 2; } strNoValue = numbering.Prefix + createTime.ToString("yyMM") + String.Format("{0:D" + iCountSpace + "}", iCount) + numbering.Suffix; #endregion } } else if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colNoIndex)) { int iNoIndex = Convert.ToInt32(ABCDynamicInvoker.GetValue(obj, ABCCommon.ABCConstString.colNoIndex)); int iCountSpace = 4; if (iNoIndex >= 10000) { iCountSpace = iNoIndex.ToString().Length + 2; } strNoValue = numbering.Prefix + String.Format("{0:D" + iCountSpace + "}", iNoIndex) + numbering.Suffix; } } #endregion } else { #region UsePattern #endregion } } else { #region Have No Config if (!String.IsNullOrWhiteSpace(DataConfigProvider.TableConfigList[obj.AATableName].PrefixNo)) { strNoValue = DataConfigProvider.TableConfigList[obj.AATableName].PrefixNo; } else { strNoValue = new Regex("[^A-Z]+").Replace(DataConfigProvider.GetTableCaption(obj.AATableName), ""); } String strDateCol = String.Empty; if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colCreateTime)) { strDateCol = ABCCommon.ABCConstString.colCreateTime; } if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colDocumentDate)) { strDateCol = ABCCommon.ABCConstString.colDocumentDate; } if (!String.IsNullOrWhiteSpace(strDateCol)) { object objValue = ABCDynamicInvoker.GetValue(obj, strDateCol); if (objValue != null && (objValue is DateTime || (objValue is Nullable <DateTime> && (objValue as Nullable <DateTime>).HasValue))) { #region With DateTime DateTime createTime = DateTime.MinValue; if (objValue is Nullable <DateTime> ) { createTime = (objValue as Nullable <DateTime>).Value; } else { createTime = Convert.ToDateTime(objValue); } String strQuery = QueryGenerator.GenSelect(obj.AATableName, "COUNT(*)", false, false); strQuery = QueryGenerator.AddCondition(strQuery, String.Format(@" YEAR({0}) = {1} AND MONTH({0}) = {2} AND {0} < {3}", strDateCol, createTime.Year, createTime.Month, TimeProvider.GenDateTimeString(createTime))); int iCount = Convert.ToInt32(BusinessObjectController.GetData(strQuery)); if (iCount <= 0) { iCount = 0; } iCount++; int iCountSpace = 3; if (iCountSpace < iCount.ToString().Length) { iCountSpace = iCount.ToString().Length + 2; } strNoValue += createTime.ToString("yyMM") + String.Format("{0:D" + iCountSpace + "}", iCount); #endregion } } else if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colNoIndex)) { int iNoIndex = Convert.ToInt32(ABCDynamicInvoker.GetValue(obj, ABCCommon.ABCConstString.colNoIndex)); int iCountSpace = 4; if (iNoIndex >= 10000) { iCountSpace = iNoIndex.ToString().Length + 2; } strNoValue += String.Format("{0:D" + iCountSpace + "}", iNoIndex); } #endregion } obj.SetNoValue(strNoValue); return(strNoValue); }