예제 #1
0
        public static void InitDataTableList( )
        {
            DataTablesList.Clear();

            InitDataTableList(true);

            InitDataTableList(false);

            DataConfigProvider.InvalidateConfigList();
        }
예제 #2
0
        public static void LogAction(BusinessObject obj, String ViewDesc, String Action)
        {
            Guid iID = BusinessObjectHelper.GetIDValue(obj);

            if (iID == Guid.Empty)
            {
                return;
            }

            String strNo        = BusinessObjectHelper.GetNoValue(obj);
            String strRemark    = BusinessObjectHelper.GetRemarkValue(obj);
            String strTableDesc = DataConfigProvider.GetTableCaption(obj.AATableName);

            LogAction(obj.AATableName, iID, strNo, strRemark, strTableDesc, ViewDesc, Action);
        }
예제 #3
0
        public static void CreateNewNotifyFromComment(String strUser, String strTableName, Guid iID)
        {
            if (strUser != ABCUserProvider.CurrentUserName)
            {
                String strTitle      = DataConfigProvider.GetTableCaption(strTableName);
                String strDisplayCol = DataStructureProvider.GetDisplayColumn(strTableName);
                String strIDCol      = DataStructureProvider.GetPrimaryKeyColumn(strTableName);

                object obj = BusinessObjectController.GetData(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}' ", strDisplayCol, strTableName, strIDCol, iID));
                if (obj != null && obj != DBNull.Value)
                {
                    strTitle = strTitle + " : " + obj.ToString();
                }
                CreateNewNotify(strUser, strTitle, "", strTableName, iID, "");
            }
        }
예제 #4
0
        public static bool CalculateMainOnly(BaseVoucher voucher, BusinessObject obj, Dictionary <String, IEnumerable <BusinessObject> > lstObjecItems, String strAferValidateFieldName, bool isSave)
        {
            if (FormulasList == null)
            {
                InitFormulas();
            }

            if (!FormulasList.ContainsKey(obj.AATableName))
            {
                return(false);
            }

            bool isCalculated = false;

            Dictionary <String, double> lstVariables = new Dictionary <string, double>();
            bool isContinue = false;

            foreach (GEFormulaItemsInfo formula in FormulasList[obj.AATableName].Values)
            {
                if (String.IsNullOrWhiteSpace(formula.FormulaName))
                {
                    continue;
                }

                #region isNeedCalc
                bool isNeedCalc = isContinue;
                if (!isNeedCalc)
                {
                    if (formula.IsVariable)
                    {
                        isNeedCalc = true;
                    }
                    else
                    {
                        if (String.IsNullOrWhiteSpace(strAferValidateFieldName))
                        {
                            isNeedCalc = true;
                        }
                        else
                        {
                            if (FormulasList[obj.AATableName].Values.Count(t => t.FormulaName == strAferValidateFieldName) > 0)
                            {
                                if (formula.FormulaName == strAferValidateFieldName)
                                {
                                    isContinue = true;
                                    continue;
                                }
                            }
                            else
                            {
                                if (DataConfigProvider.GetFieldSortOrder(obj.AATableName, strAferValidateFieldName) <= DataConfigProvider.GetFieldSortOrder(obj.AATableName, formula.FormulaName))
                                {
                                    isContinue = true;
                                    isNeedCalc = true;
                                }
                            }
                        }
                    }
                }

                if (!isNeedCalc)
                {
                    continue;
                }
                #endregion

                object objAmt = null;
                if (formula.IsUseQuery && !String.IsNullOrWhiteSpace(formula.QueryString))
                {
                    #region Query
                    String strQuery = formula.QueryString.Replace("{TableName}", obj.AATableName);
                    if (obj.GetID() != Guid.Empty)
                    {
                        strQuery = strQuery.Replace("{ID}", obj.GetID().ToString());
                    }

                    foreach (String strProperty in DataStructureProvider.DataTablesList[obj.AATableName].ColumnsList.Keys)
                    {
                        if (strQuery.Contains("{" + strProperty + "}"))
                        {
                            object objValue = ABCDynamicInvoker.GetValue(obj, strProperty);
                            if (objValue == null || objValue == DBNull.Value)
                            {
                                strQuery = strQuery.Replace("{" + strProperty + "}", "NULL");
                            }
                            else
                            {
                                strQuery = strQuery.Replace("{" + strProperty + "}", objValue.ToString());
                            }
                        }
                    }

                    foreach (String strVariableName in lstVariables.Keys)
                    {
                        if (strQuery.Contains("{" + strVariableName + "}"))
                        {
                            strQuery = strQuery.Replace("{" + strVariableName + "}", lstVariables[strVariableName].ToString());
                        }
                    }
                    #endregion

                    objAmt = BusinessObjectController.GetData(strQuery);
                }
                else if (formula.IsUseFormula && !String.IsNullOrWhiteSpace(formula.Formula))
                {
                    String strExpression = formula.Formula;

                    #region Formula
                    foreach (String strProperty in DataStructureProvider.DataTablesList[obj.AATableName].ColumnsList.Keys)
                    {
                        strExpression = strExpression.Replace("{" + strProperty + "}", "[" + strProperty + "]");
                    }

                    foreach (String strVariableName in lstVariables.Keys)
                    {
                        strExpression = strExpression.Replace("{" + strVariableName + "}", "[" + strVariableName + "]");
                    }


                    Expression e = new Expression(strExpression);
                    foreach (String strProperty in DataStructureProvider.DataTablesList[obj.AATableName].ColumnsList.Keys)
                    {
                        if (strExpression.Contains("[" + strProperty + "]"))
                        {
                            object objValue = ABCDynamicInvoker.GetValue(obj, strProperty);
                            if (objValue == null)
                            {
                                continue;
                            }

                            double dbValue = 0;
                            Double.TryParse(objValue.ToString(), out dbValue);
                            e.Parameters[strProperty] = dbValue;
                        }
                    }

                    foreach (String strVariableName in lstVariables.Keys)
                    {
                        if (strExpression.Contains("[" + strVariableName + "]"))
                        {
                            e.Parameters[strVariableName] = lstVariables[strVariableName];
                        }
                    }

                    #endregion

                    objAmt = e.Evaluate();
                }
                else if (formula.IsUseSumFromChild)
                {
                    objAmt = 0;
                    if (lstObjecItems.ContainsKey(formula.SumChildTableName) && DataStructureProvider.IsTableColumn(formula.SumChildTableName, formula.SumChildFieldName))
                    {
                        objAmt = lstObjecItems[formula.SumChildTableName].Sum(t => Convert.ToDouble(ABCDynamicInvoker.GetValue((BusinessObject)t, formula.SumChildFieldName)));
                    }
                }

                if (formula.IsVariable && lstVariables.ContainsKey(formula.FormulaName) == false)
                {
                    lstVariables.Add(formula.FormulaName, Math.Round(Convert.ToDouble(objAmt), 3));
                }

                bool isCalculatedWithCurrentFormula = false;
                if (!formula.IsVariable && DataStructureProvider.IsTableColumn(obj.AATableName, formula.FormulaName))
                {
                    if (objAmt != null)
                    {
                        if (objAmt is double)
                        {
                            objAmt = Math.Round(Convert.ToDouble(objAmt), 3);
                        }

                        if (ABCDynamicInvoker.GetValue(obj, formula.FormulaName).ToString() != objAmt.ToString())
                        {
                            ABCDynamicInvoker.SetValue(obj, formula.FormulaName, objAmt);
                            isCalculatedWithCurrentFormula = true;
                        }
                    }
                }


                if (voucher != null && formula.IsCustomByCode)
                {
                    isCalculatedWithCurrentFormula = voucher.CustomFormulaCalc(obj, lstObjecItems, formula);
                }

                isCalculated = isCalculated | isCalculatedWithCurrentFormula;

                if (isCalculatedWithCurrentFormula && !string.IsNullOrWhiteSpace(formula.FieldRelations))
                {
                    foreach (String strRelation in formula.FieldRelations.Split(';').ToList())
                    {
                        if (FormulasList[obj.AATableName].Values.Count(t => t.FormulaName == strRelation) > 0)
                        {
                            int?iIndex = FormulasList[obj.AATableName].Values.Where(t => t.FormulaName == strRelation).Select(t => t.CalcIndex).First();
                            if (!iIndex.HasValue)
                            {
                                continue;
                            }

                            if (FormulasList[obj.AATableName].Values.Count(t => t.CalcIndex == iIndex.Value - 1) > 0)
                            {
                                iIndex = FormulasList[obj.AATableName].Values.Where(t => t.CalcIndex == iIndex.Value - 1).Select(t => t.CalcIndex).First();
                                if (!iIndex.HasValue)
                                {
                                    continue;
                                }

                                CalculateMainOnly(voucher, obj, lstObjecItems, strRelation, isSave);
                            }
                        }
                    }
                }
            }

            if (isCalculated && obj.GetID() != null && isSave)
            {
                BusinessControllerFactory.GetBusinessController(obj.AATableName).UpdateObject(obj);

                if (!CalculateQueue.ContainsKey(obj.AATableName))
                {
                    CalculateQueue.Add(obj.AATableName, new List <Guid>());
                }

                if (!CalculateQueue[obj.AATableName].Contains(obj.GetID()))
                {
                    CalculateQueue[obj.AATableName].Add(obj.GetID());

                    if (DataStructureProvider.DataTablesList.ContainsKey(obj.AATableName))
                    {
                        foreach (String strFkCol in DataStructureProvider.DataTablesList[obj.AATableName].ForeignColumnsList.Keys)
                        {
                            Guid fkID = ABCHelper.DataConverter.ConvertToGuid(ABCDynamicInvoker.GetValue(obj, strFkCol));
                            if (fkID == Guid.Empty)
                            {
                                continue;
                            }

                            BusinessObjectController FKCtrl = BusinessControllerFactory.GetBusinessController(DataStructureProvider.GetTableNameOfForeignKey(obj.AATableName, strFkCol));
                            if (FKCtrl != null)
                            {
                                BusinessObject fkObj = FKCtrl.GetObjectByID(fkID);
                                if (fkObj != null)
                                {
                                    Calculate(fkObj, true);
                                }
                            }
                        }
                    }

                    if (!CalculateQueue.ContainsKey(obj.AATableName))
                    {
                        CalculateQueue.Add(obj.AATableName, new List <Guid>());
                    }

                    if (!CalculateQueue[obj.AATableName].Contains(obj.GetID()))
                    {
                        CalculateQueue[obj.AATableName].Remove(obj.GetID());
                    }
                }
            }

            return(isCalculated);
        }
예제 #5
0
        public static void SynchronizeFieldPermission( )
        {
            GEPermissionFieldsController permissionCtrl = new GEPermissionFieldsController();
            String strQuery = String.Format(@"DELETE FROM GEPermissionFields WHERE FK_GEPermissionID NOT IN (SELECT GEPermissionID FROM GEPermissions)");

            BusinessObjectController.RunQuery(strQuery);

            foreach (GEPermissionsInfo permission in new GEPermissionsController().GetListAllObjects())
            {
                #region Field
                Dictionary <String, GEPermissionFieldsInfo> lstFields = new Dictionary <string, GEPermissionFieldsInfo>();

                foreach (GEPermissionFieldsInfo fieldInfo in permissionCtrl.GetListByForeignKey("FK_GEPermissionID", permission.GEPermissionID).Cast <GEPermissionFieldsInfo>().ToList())
                {
                    if (lstFields.ContainsKey(fieldInfo.FieldName) == false)
                    {
                        String strTableCaption = DataConfigProvider.GetTableCaption(fieldInfo.TableName);
                        String strFieldCaption = DataConfigProvider.GetFieldCaption(fieldInfo.TableName, fieldInfo.FieldName);

                        if (DataStructureProvider.IsTableColumn(fieldInfo.TableName, fieldInfo.FieldName) &&
                            strTableCaption != String.Empty && strTableCaption != fieldInfo.TableName &&
                            strFieldCaption != String.Empty && strFieldCaption != fieldInfo.FieldName)
                        {
                            lstFields.Add(fieldInfo.TableName + fieldInfo.FieldName, fieldInfo);
                        }
                        else
                        {
                            permissionCtrl.DeleteObject(fieldInfo);
                        }
                    }
                }


                foreach (String strTableName in DataStructureProvider.DataTablesList.Keys)
                {
                    foreach (String strFieldName in DataStructureProvider.DataTablesList[strTableName].ColumnsList.Keys)
                    {
                        if (DataStructureProvider.IsPrimaryKey(strTableName, strFieldName))
                        {
                            continue;
                        }

                        if (lstFields.ContainsKey(strTableName + strFieldName) == false)
                        {
                            GEPermissionFieldsInfo fieldInfo = new GEPermissionFieldsInfo();
                            fieldInfo.FK_STFieldConfigID = DataConfigProvider.TableConfigList[strTableName].FieldConfigList[strFieldName].ConfigID;
                            fieldInfo.FK_STTableConfigID = DataConfigProvider.TableConfigList[strTableName].ConfigID;
                            fieldInfo.TableName          = strTableName;
                            fieldInfo.FieldName          = strFieldName;
                            fieldInfo.FK_GEPermissionID  = permission.GEPermissionID;
                            fieldInfo.AllowView          = true;
                            fieldInfo.AllowEdit          = true;

                            permissionCtrl.CreateObject(fieldInfo);
                            lstFields.Add(fieldInfo.TableName + fieldInfo.FieldName, fieldInfo);
                        }
                    }
                }
                #endregion
            }
        }
예제 #6
0
        public static void CreateNewNotifyFromComment(String strTableName, Guid iID)
        {
            if (DataStructureProvider.IsExistedTable(strTableName) == false)
            {
                return;
            }

            String strIDCol = DataStructureProvider.GetPrimaryKeyColumn(strTableName);

            #region Get Users
            List <String> lstUsers = new List <string>();
            DataSet       ds       = BusinessObjectController.RunQuery(String.Format(@"SELECT CreateUser FROM GEComments WHERE TableName ='{0}' AND ID = '{1}' GROUP BY CreateUser", strTableName, iID));
            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (lstUsers.Contains(dr[0].ToString()) == false)
                    {
                        lstUsers.Add(dr[0].ToString());
                    }
                }
            }
            ds = BusinessObjectController.RunQuery(String.Format(@"SELECT TagString FROM GEComments WHERE TableName ='{0}' AND ID = '{1}'  AND TagString IS NOT NULL AND TagString NOT LIKE '' GROUP BY TagString", strTableName, iID));
            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr[0] != null && dr[0] != DBNull.Value && String.IsNullOrWhiteSpace(dr[0].ToString()) == false)
                    {
                        string[] arr = { "::" };
                        arr = dr[0].ToString().Split(arr, StringSplitOptions.None);
                        for (int i = 0; i < arr.Length; i++)
                        {
                            if (lstUsers.Contains(arr[i]) == false)
                            {
                                lstUsers.Add(arr[i]);
                            }
                        }
                    }
                }
            }



            if (DataStructureProvider.IsTableColumn(strTableName, ABCCommon.ABCConstString.colCreateUser))
            {
                ds = BusinessObjectController.RunQuery(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}'", ABCCommon.ABCConstString.colCreateUser, strTableName, strIDCol, iID));
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    object objCreateUser = ds.Tables[0].Rows[0][0];
                    if (objCreateUser != null && objCreateUser != DBNull.Value && lstUsers.Contains(objCreateUser.ToString()) == false)
                    {
                        lstUsers.Add(objCreateUser.ToString());
                    }
                }
            }
            if (DataStructureProvider.IsTableColumn(strTableName, ABCCommon.ABCConstString.colUpdateUser))
            {
                ds = BusinessObjectController.RunQuery(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}'", ABCCommon.ABCConstString.colUpdateUser, strTableName, strIDCol, iID));
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    object objUpdateUser = ds.Tables[0].Rows[0][0];
                    if (objUpdateUser != null && objUpdateUser != DBNull.Value && lstUsers.Contains(objUpdateUser.ToString()) == false)
                    {
                        lstUsers.Add(objUpdateUser.ToString());
                    }
                }
            }

            #endregion

            String strTitle      = DataConfigProvider.GetTableCaption(strTableName);
            String strDisplayCol = DataStructureProvider.GetDisplayColumn(strTableName);

            object obj = BusinessObjectController.GetData(String.Format(@"SELECT {0} FROM {1} WHERE {2} ='{3}' ", strDisplayCol, strTableName, strIDCol, iID));
            if (obj != null && obj != DBNull.Value)
            {
                strTitle = strTitle + " : " + obj.ToString();
            }

            foreach (String strUser in lstUsers)
            {
                if (strUser != ABCUserProvider.CurrentUserName)
                {
                    CreateNewNotify(strUser, strTitle, "", strTableName, iID, "");
                }
            }
        }
예제 #7
0
        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);
        }