/// <summary> /// 更新角色功能权限,先删后新增 /// </summary> /// <param name="listFunc"></param> /// <returns></returns> public string UpdateRoleFunction(List <string> listFunc) { if (listFunc.Count <= 0) { return(string.Format("更新列表不能为空")); } if (!m_DbOperate.DeleteRow(TableName.TRoleFunction, string.Format("{0}='{1}'", ColumnName.RoleID, m_RoleID))) { return(string.Format("修改权限失败:删除权限失败")); } foreach (string func in listFunc) { if (m_DbOperate.AddRow(TableName.TRoleFunction, new List <string> { ColumnName.RoleID, ColumnName.FID }, m_RoleID, func)) { continue; } else { return(string.Format("修改权限失败")); } } return(string.Empty); }
/// <summary> /// 添加用户 /// </summary> /// <param name="dicUser">用户信息</param> /// <returns></returns> public string AddUser(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.AddRow(TableName.TUser, new List <string> { ColumnName.UserCode, ColumnName.UserName, ColumnName.UserPassword }, string.Format("'{0}'", m_UserCode), string.Format("'{0}'", m_UserName), string.Format("'{0}'", m_UserPassword))) { return(string.Format("添加用户失败:请查询相应日志信息")); } else { if (!m_dbOperate.AddRow(TableName.TUserRole, new List <string> { ColumnName.UserCode, ColumnName.RoleID }, string.Format("'{0}'", m_UserCode), string.Format("'{0}'", m_UserRole.RoleID))) { return(string.Format("新用户授权失败:请查询相应日志信息")); } } return(string.Empty); }
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); }