private async void btnDangNhap_Click(object sender, EventArgs e) { btnDangNhap.Enabled = false; string Account = txtAccount.Text; string Password = txtPassword.Text; if (Account != "" && Password != "") { pbCheck.Show(); lbCheck.Show(); await Task.Delay(2000); if (DNV.Login(txtAccount.Text, txtPassword.Text)) { MainForm form = new MainForm(DNV.getRole(txtAccount.Text), DNV.getName(txtAccount.Text), txtAccount.Text); form.Show(); this.Hide(); if (Ckb_SaveMyPass.Checked) { Properties.Settings.Default.UserName = txtAccount.Text; Properties.Settings.Default.Password = txtPassword.Text; Properties.Settings.Default.Save(); } } else { btnDangNhap.Enabled = true; pbCheck.Hide(); lbCheck.Hide(); txtSoLanDN.Show(); check += 1; txtSoLanDN.Text = "Lần thử thứ " + check + "/5"; MessageBox.Show("Sai tài khoản hoặc mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); if (check == 5) { second = second * numberCheck; btnDangNhap.Enabled = false; timer1.Interval = 1000; timer1.Start(); } } } else { btnDangNhap.Enabled = true; MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void check() { if (Properties.Settings.Default.UserName != "") { string Account = Properties.Settings.Default.UserName; string Password = Properties.Settings.Default.Password; if (DNV.Login(Account, Password)) { MainForm form = new MainForm(DNV.getRole(Account), DNV.getName(Account), Account); form.Show(); } else { MessageBox.Show("Có lỗi xảy ra, vui lòng đăng nhập lại"); DangNhap dn = new DangNhap(); dn.Show(); } } else { DangNhap dn = new DangNhap(); dn.Show(); } }