示例#1
0
        private async void btnDangNhap_Click(object sender, EventArgs e)
        {
            string Account  = txtAccount.Text;
            string Password = txtPassword.Text;

            if (Account != "" && Password != "")
            {
                pbCheck.Show();
                lbCheck.Show();
                await Task.Delay(2000);

                if (dnv.DangNhap(Account, Password))
                {
                    DanhSachChucNang DSCN = new DanhSachChucNang(int.Parse(dnv.CheckRole(Account)), dnv.GetUserName(Account));
                    DSCN.Show();
                    this.Hide();
                    if (Ckb_SaveMyPass.Checked)
                    {
                        Properties.Settings.Default.userName = txtAccount.Text;
                        Properties.Settings.Default.passUser = txtPassword.Text;
                        Properties.Settings.Default.Save();
                    }
                }
                else
                {
                    pbCheck.Hide();
                    lbCheck.Hide();
                    MessageBox.Show("Sai tài khoản hoặc mật khẩu vui lòng kiểm tra lại !");
                }
            }
            else
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin !");
            }
        }
 public void check()
 {
     if (Properties.Settings.Default.userName != "")
     {
         string Account  = Properties.Settings.Default.userName;
         string Password = Properties.Settings.Default.passUser;
         if (dnv.DangNhap(Account, Password))
         {
             DanhSachChucNang DSCN = new DanhSachChucNang(int.Parse(dnv.CheckRole(Account)), dnv.GetUserName(Account));
             DSCN.Show();
         }
     }
     else
     {
         DangNhap dn = new DangNhap();
         dn.Show();
     }
 }