private void SetVisible()
 {
     string[] roles = UserManagementAdmin.GetRoles(admin.Roles);
     if (roles.Contains("读者信息管理员"))
     {
         userManagementSystemButton.Visible = true;
     }
     if (roles.Contains("流通管理员"))
     {
         circulationSystemButton.Visible = true;
     }
     if (roles.Contains("编目员"))
     {
         catalogSystemBtn.Visible = true;
     }
     if (roles.Contains("采访员"))
     {
         interviewSystemButton.Visible = true;
     }
     if (roles.Contains("系统维护员"))
     {
         maintainaceSystemButton.Visible = true;
     }
     if (roles.Contains("统计员"))
     {
         statisticalSystemButton.Visible = true;
     }
     if (roles.Contains("期刊管理员"))
     {
         periodicalSystemButton.Visible = true;
     }
 }
Exemple #2
0
        /// <summary>
        /// 登录
        /// </summary>
        private void Login()
        {
            List <string>       errorList = new List <string>();
            UserManagementLogin login     = GetAllLoginInformation();
            UserManagementAdmin admin     = new UserManagementAdmin();
            int responseCode = userManagementBll.adminLogin(login, out admin, ref errorList);

            if (responseCode == 200 && admin != null)
            {
                MessageBox.Show("登陆成功");
                var form = new AdminForm(this, admin);
                form.Show();
                Hide();
            }
            else if (responseCode == 401)
            {
                MessageBox.Show("密码不正确,请重新输入");
            }
            else if (responseCode == 403)
            {
                MessageBox.Show("权限不足,禁止登陆");
            }
            else if (responseCode == 415)
            {
                MessageBox.Show("输入格式有误,请重新输入");
            }
            else
            {
                MessageBox.Show("登录失败");
            }
        }
Exemple #3
0
        /// <summary>
        /// 管理员登陆
        /// 格式错误 415
        /// </summary>
        /// <param name="login">登录信息</param>
        /// <returns>状态码</returns>
        public int adminLogin(UserManagementLogin login, out UserManagementAdmin admin, ref List <string> errorMsg)
        {
            int result = 415;

            try
            {
                if (!UserManagementLogin.isNull(login))                       //是否有空项
                {
                    if (UserManagementLogin.isNormative(login, ref errorMsg)) //是否符合规范
                    {
                        return(userManagementDal.adminLogin(login, out admin));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
            admin = null;
            return(result);
        }
 public AdminForm(Form form, UserManagementAdmin user)
 {
     InitializeComponent();
     parentForm = form;
     admin      = user;
 }
Exemple #5
0
        public int adminLogin(UserManagementLogin login, out UserManagementAdmin admin)
        {
            int       result;
            SQLHelper helper = new SQLHelper();
            string    pwd    = helper.GetMD5(login.Password);
            string    sql    = " SELECT " +
                               " tb_BasicInformation.UserId AS `编号`,  " +
                               " tb_Login.`Password` AS `密码`,  " +
                               " tb_BasicInformation.UserName AS `名称`,  " +
                               " tb_BasicInformation.UserNumber AS `账号`,  " +
                               " GROUP_CONCAT( tb_AdminInformation.AdminRole SEPARATOR '|') AS `角色` " +
                               " FROM " +
                               " tb_AdminInformation " +
                               " INNER JOIN " +
                               " tb_BasicInformation " +
                               " ON  " +
                               " tb_AdminInformation.UserId = tb_BasicInformation.UserId " +
                               " INNER JOIN " +
                               " tb_Login " +
                               " ON  " +
                               " tb_BasicInformation.UserId = tb_Login.UserId " +
                               " WHERE " +
                               " tb_BasicInformation.UserNumber =@userNumber  AND " +
                               " tb_Login.`Password` = @password " +
                               " GROUP BY " +
                               " tb_BasicInformation.UserId,tb_Login.`Password` ;";

            MySqlParameter[] adminPara = new MySqlParameter[]
            {
                new MySqlParameter("@userNumber", login.UserNumber),
                new MySqlParameter("@password", pwd)
            };
            DataTable dt = helper.ExecuteQuery(sql, adminPara, CommandType.Text);

            if (dt.Rows.Count == 1)
            {
                if ((string)dt.Rows[0]["密码"] == pwd)
                {
                    result = 200;
                    admin  = new UserManagementAdmin()
                    {
                        Id     = (int)dt.Rows[0]["编号"],
                        Name   = dt.Rows[0]["名称"].ToString(),
                        Number = dt.Rows[0]["账号"].ToString(),
                        Roles  = dt.Rows[0]["角色"].ToString(),
                    };
                    return(result);
                }
                else
                {
                    result = 401;
                }
            }
            else if (dt.Rows.Count == 0)
            {
                result = 403;
            }
            else
            {
                result = 420;
            }
            admin = null;
            return(result);
        }