Esempio n. 1
0
        public static void InitializeNumberings( )
        {
            #region NumberingTypes
            NumberingTypes = new Dictionary <Guid, NumberingType>();

            DataSet ds = BusinessObjectController.RunQuery(@"SELECT * FROM GENumberingTypes");
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["GENumberingTypeID"] == DBNull.Value)
                    {
                        continue;
                    }

                    NumberingType type = new NumberingType();

                    #region type
                    type.ID = ABCHelper.DataConverter.ConvertToGuid(dr["GENumberingTypeID"]);
                    if (type.ID == Guid.Empty)
                    {
                        continue;
                    }

                    if (dr["PatternType"] != DBNull.Value)
                    {
                        type.PatternType = dr["PatternType"].ToString();
                    }

                    type.IsByUser = false;
                    if (dr["IsByUser"] != DBNull.Value)
                    {
                        type.IsByUser = Convert.ToBoolean(dr["IsByUser"]);
                    }

                    type.IsByUserGroup = false;
                    if (dr["IsByUserGroup"] != DBNull.Value)
                    {
                        type.IsByUserGroup = Convert.ToBoolean(dr["IsByUserGroup"]);
                    }

                    type.IsByEmployee = false;
                    if (dr["IsByEmployee"] != DBNull.Value)
                    {
                        type.IsByEmployee = Convert.ToBoolean(dr["IsByEmployee"]);
                    }

                    type.IsByCompanyUnit = false;
                    if (dr["IsByCompanyUnit"] != DBNull.Value)
                    {
                        type.IsByCompanyUnit = Convert.ToBoolean(dr["IsByCompanyUnit"]);
                    }

                    type.IsYYMMCount = false;
                    if (dr["IsYYMMCount"] != DBNull.Value)
                    {
                        type.IsYYMMCount = Convert.ToBoolean(dr["IsYYMMCount"]);
                    }

                    type.IsYYMMDDCount = false;
                    if (dr["IsYYMMDDCount"] != DBNull.Value)
                    {
                        type.IsYYMMDDCount = Convert.ToBoolean(dr["IsYYMMDDCount"]);
                    }

                    type.IsMMDDCount = false;
                    if (dr["IsMMDDCount"] != DBNull.Value)
                    {
                        type.IsMMDDCount = Convert.ToBoolean(dr["IsMMDDCount"]);
                    }

                    type.CountingSpace = 2;
                    if (dr["CountingSpace"] != DBNull.Value)
                    {
                        type.CountingSpace = Convert.ToInt32(dr["CountingSpace"]);
                    }


                    type.IsByField = false;
                    if (dr["IsByField"] != DBNull.Value)
                    {
                        type.IsByField = Convert.ToBoolean(dr["IsByField"]);
                    }

                    if (dr["FieldName"] != DBNull.Value)
                    {
                        type.FieldName = dr["FieldName"].ToString();
                    }
                    #endregion


                    if (!NumberingTypes.ContainsKey(type.ID))
                    {
                        NumberingTypes.Add(type.ID, type);
                    }
                }
            }
            #endregion

            #region NumberingConfigs
            NumberingConfigs = new List <Numbering>();

            ds = BusinessObjectController.RunQuery(@"SELECT * FROM GENumberings");
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["GENumberingID"] == DBNull.Value)
                    {
                        continue;
                    }

                    Numbering number = new Numbering();

                    #region Number

                    number.ID = ABCHelper.DataConverter.ConvertToGuid(dr["GENumberingID"]);
                    if (number.ID == Guid.Empty)
                    {
                        continue;
                    }

                    if (dr["TableName"] != DBNull.Value)
                    {
                        number.TableName = dr["TableName"].ToString();
                    }

                    if (dr["ConditionString"] != DBNull.Value)
                    {
                        number.ConditionString = dr["ConditionString"].ToString();
                    }

                    if (dr["FieldCondition"] != DBNull.Value)
                    {
                        number.FieldCondition = dr["FieldCondition"].ToString();
                    }

                    if (dr["FieldValue"] != DBNull.Value)
                    {
                        number.FieldValue = dr["FieldValue"].ToString();
                    }

                    if (dr["SeperateChar"] != DBNull.Value)
                    {
                        number.SeperateChar = dr["SeperateChar"].ToString();
                    }

                    if (dr["Prefix"] != DBNull.Value)
                    {
                        number.Prefix = dr["Prefix"].ToString();
                    }

                    if (dr["Suffix"] != DBNull.Value)
                    {
                        number.Suffix = dr["Suffix"].ToString();
                    }

                    number.IsUsePattern = false;
                    if (dr["IsUsePattern"] != DBNull.Value)
                    {
                        number.IsUsePattern = Convert.ToBoolean(dr["IsUsePattern"]);
                    }

                    if (dr["NumberPattern"] != DBNull.Value)
                    {
                        number.NumberPattern = dr["NumberPattern"].ToString();
                    }
                    #endregion

                    #region   number.MiddleConfigs

                    number.MiddleConfigs = new List <NumberingType>();

                    List <Object> lstTypeIDs = BusinessObjectController.GetListObjects(String.Format(@"SELECT FK_GENumberingTypeID FROM GENumberingMiddleItems WHERE FK_GENumberingID ='{0}' ORDER BY MiddleIndex", number.ID));
                    foreach (Object objID in lstTypeIDs)
                    {
                        Guid typeID = ABCHelper.DataConverter.ConvertToGuid(objID);
                        if (typeID == Guid.Empty)
                        {
                            continue;
                        }

                        if (NumberingTypes.ContainsKey(typeID))
                        {
                            number.MiddleConfigs.Add(NumberingTypes[typeID]);
                        }
                    }
                    #endregion

                    NumberingConfigs.Add(number);
                }
            }
            #endregion
        }