Exemple #1
0
        public static FieldAddState Add(UserFieldInfo field)
        {
            UserGroupInfo dataById = UserGroup.GetDataById(field.UserGroupID);
            FieldAddState result;

            if (dataById == null)
            {
                result = FieldAddState.ModelNotExists;
            }
            else
            {
                int value = BizBase.dbo.GetValue <int>(string.Concat(new object[]
                {
                    "SELECT COUNT(*) FROM cms_UserField WHERE UserGroupID=",
                    field.UserGroupID,
                    " AND FieldName='",
                    field.FieldName,
                    "'"
                }));
                if (value > 0)
                {
                    result = FieldAddState.FieldNameExists;
                }
                else
                {
                    if (BizBase.dbo.InsertModel <UserFieldInfo>(field) > 0)
                    {
                        try
                        {
                            string text = field.DataType;
                            if (string.Compare(text, "nvarchar", true) == 0)
                            {
                                object obj = text;
                                text = string.Concat(new object[]
                                {
                                    obj,
                                    "(",
                                    field.DataLength,
                                    ")"
                                });
                            }
                            TableManager.AddTableColumn(dataById.TableName, field.FieldName, text, true, field.DefaultValue);
                        }
                        catch
                        {
                            result = FieldAddState.CreateColumnError;
                            return(result);
                        }
                    }
                    CacheUtils.Del("JsonLeeCMS_CacheForGetUserGroup");
                    result = FieldAddState.Success;
                }
            }
            return(result);
        }
Exemple #2
0
        public static bool Delete(int fieldID)
        {
            UserFieldInfo dataById  = UserField.GetDataById(fieldID);
            UserGroupInfo dataById2 = UserGroup.GetDataById(dataById.UserGroupID);

            if (BizBase.dbo.DeleteModel <UserFieldInfo>(dataById))
            {
                TableManager.DropTableColumn(dataById2.TableName, dataById.FieldName);
            }
            CacheUtils.Del("JsonLeeCMS_CacheForGetUserGroup");
            return(true);
        }
Exemple #3
0
        public static bool Update(UserFieldInfo field)
        {
            UserGroupInfo dataById  = UserGroup.GetDataById(field.UserGroupID);
            UserFieldInfo dataById2 = UserField.GetDataById(field.AutoID);
            bool          result;

            if (BizBase.dbo.UpdateModel <UserFieldInfo>(field))
            {
                if (!dataById2.IsSystem)
                {
                    try
                    {
                        string text = field.DataType;
                        if (string.Compare(text, "nvarchar", true) == 0)
                        {
                            object obj = text;
                            text = string.Concat(new object[]
                            {
                                obj,
                                "(",
                                field.DataLength,
                                ")"
                            });
                        }
                        TableManager.AlterTableColumn(dataById.TableName, dataById2.FieldName, field.FieldName, text, true, field.DefaultValue);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                CacheUtils.Del("JsonLeeCMS_CacheForGetUserGroup");
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }