示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.button1.Text = "正在登陆";
            this.button1.Enabled = false;
            var tool = new UserManager();
            var user = tool.Login(this.textBox1.Text, this.textBox2.Text);
            if (user != null)
            {
                if (Form != null)
                {
                    Form.Enabled = true;
                    Form.CurrentUser = user;
                    Form.Power();
                }

                MessageBox.Show("成功登陆"+user.Role.GetDescription().Trim()+" 用户:"+user.Name.Trim());
                this.Close();
            }
            else
            {
                MessageBox.Show("用户名或者密码错误,请核对!");
            }
            this.button1.Text = "登陆";
            this.button1.Enabled = true;
        }
示例#2
0
 public ChangePasswordForm(User user,bool flag=false)
 {
     InitializeComponent();
     _user = user;
     _CurrentUser = user;
     _flag = flag;
     _tool = new UserManager();
 }
示例#3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
     {
         MessageBox.Show("用户名或者密码为空");
         return;
     }
     if (comboBox1.SelectedItem != null)
     {
         Role role = GetRole(comboBox1.SelectedItem.ToString());
         var Tool = new UserManager();
         if (this.CurrentUser == null)
         {
             Tool.Add(new User()
             {
                 Name = textBox1.Text,
                 Password = textBox2.Text.MD5(),
                 Role = role
             });
             MessageBox.Show("成功添加用户");
         }
         else
         {
             if (Tool.Edit(this.CurrentUser.ID, role))
             {
                 MessageBox.Show("成功修改权限");
             }
             else
             {
                 MessageBox.Show("修改权限失败!");
             }
         }
         if (_father != null)
         {
             _father.ReadData();
         }
         this.Close();
     }
     else
     {
         MessageBox.Show("权限组未选择!");
     }
 }