Esempio n. 1
0
        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="dicUser">用户信息</param>
        /// <returns></returns>
        public string UpdateUser(Dictionary <string, string> dicUser)
        {
            foreach (string key in dicUser.Keys)
            {
                switch (key)
                {
                case ColumnName.UserCode:
                    m_UserCode = dicUser[key];
                    break;

                case ColumnName.UserName:
                    m_UserName = dicUser[key];
                    break;

                case ColumnName.UserPassword:
                    m_UserPassword = Encryption.Encrypt(dicUser[key]);
                    break;

                case ColumnName.RoleID:
                    m_UserRole = new Role(dicUser[key], m_dbOperate);
                    break;
                }
            }
            if (string.IsNullOrEmpty(m_UserCode))
            {
                return(string.Format("无法修改用户:用户ID不能为空"));
            }
            DataTable pTable = m_dbOperate.GetTable(TableName.TUser, string.Format("{0}='{1}'", ColumnName.UserCode, m_UserCode));

            if (pTable.Rows.Count <= 0)
            {
                return(string.Format("无法修改用户:当前用户ID不存在"));
            }
            if (!m_dbOperate.UpdateTable(TableName.TUser,
                                         string.Format("{0}='{1}'", ColumnName.UserCode, m_UserCode),
                                         string.Format("{0}='{1}'", ColumnName.UserName, m_UserName),
                                         string.Format("{0}='{1}'", ColumnName.UserPassword, m_UserPassword)
                                         ))
            {
                return(string.Format("修改用户失败:请查询相应日志信息"));
            }
            else
            {
                if (!m_dbOperate.UpdateTable(TableName.TUserRole,
                                             string.Format("{0}='{1}'", ColumnName.UserCode, m_UserCode),
                                             string.Format("{0}='{1}'", ColumnName.RoleID, m_UserRole.RoleID)))
                {
                    return(string.Format("修改用户授权失败:请查询相应日志信息"));
                }
            }
            return(string.Empty);
        }
Esempio n. 2
0
        public string UpdateSysConfig(string ConfigCode, string ConfigValue, string ConfigName = "")
        {
            if (m_Dboperate == null)
            {
                return(string.Format("无数据库操作信息"));
            }
            if (string.IsNullOrEmpty(ConfigCode) || string.IsNullOrEmpty(ConfigValue))
            {
                return(string.Format("未设置系统配置更新项"));
            }
            DataTable pConfigDt = m_Dboperate.GetTable(TableName.TSysConfig, string.Empty);

            if (pConfigDt == null || pConfigDt.Rows.Count == 0)
            {
                return(string.Format("无法获取系统配置信息"));
            }
            DataRow[] pSelectRows = pConfigDt.Select(string.Format("{0}='{1}'", ColumnName.ConfigCode, ConfigCode));
            if (pSelectRows.Length <= 0)
            {
                if (!m_Dboperate.AddRow(TableName.TSysConfig, new List <string> {
                    ColumnName.ConfigCode, ColumnName.ConfigName, ColumnName.ConfigValue
                },
                                        ConfigCode, ConfigName, ConfigValue))
                {
                    return(string.Format("更新表失败,请查看日志信息"));
                }
            }
            else
            {
                bool flag = false;
                if (string.IsNullOrEmpty(ConfigName))
                {
                    flag = m_Dboperate.UpdateTable(TableName.TSysConfig, string.Format("{0}='{1}'", ColumnName.ConfigCode, ConfigCode),
                                                   ColumnName.ConfigValue, ConfigValue);
                }
                else
                {
                    flag = m_Dboperate.UpdateTable(TableName.TSysConfig, string.Format("{0}='{1}'", ColumnName.ConfigCode, ConfigCode),
                                                   ColumnName.ConfigValue, ConfigValue,
                                                   ColumnName.ConfigName, ConfigName);
                }
                if (!flag)
                {
                    return(string.Format("更新表失败,请查看日志信息"));
                }
            }
            return(string.Empty);
        }
Esempio n. 3
0
        /// <summary>
        /// 更新角色信息
        /// </summary>
        /// <param name="UpdateRole">角色信息</param>
        /// <returns></returns>
        public string UpdateRole(Dictionary <string, string> UpdateRole)
        {
            if (UpdateRole == null || UpdateRole.Count <= 0)
            {
                return(string.Format("更新角色信息失败"));
            }
            foreach (string key in UpdateRole.Keys)
            {
                switch (key)
                {
                case ColumnName.RoleName:
                    m_RoleName = UpdateRole[key];
                    break;

                case ColumnName.RoleID:
                    m_RoleID = UpdateRole[key];
                    break;
                }
            }
            if (!m_DbOperate.UpdateTable(TableName.TRole, string.Format("{0}='{1}'", ColumnName.RoleID, m_RoleID),
                                         string.Format("{0}='{1}'", ColumnName.RoleName, m_RoleName)))
            {
                return(string.Format("更新角色信息失败:更新数据库失败"));
            }
            return(string.Empty);
        }