Example #1
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     lstTK = TaiKhoanController.getAllDataTaiKhoan();
     try
     {
         foreach (TaiKhoan tk in lstTK)
         {
             if (tk.TenTaiKhoan == txtUserName.Text.Trim() && tk.MatKhau == txtPassWord.Text.Trim())
             {
                 SingletonData.Getlates().nguoidung = new TaiKhoan()
                 {
                     TenTaiKhoan = txtUserName.Text
                 };
                 MessageBox.Show("Đăng nhập thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 if (ckLuu.Checked)
                 {
                     file.ghifileLG(pathFile, txtUserName.Text.Trim(),
                                    txtPassWord.Text.Trim());
                     lblLuu.Text         = "✓ success";
                     ckLuu.Enabled       = false;
                     btnDangNhap.Enabled = true;
                 }
                 else
                 {
                     lblLuu.Text = "X error";
                 }
                 this.Close();
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     SingletonData.Getlates().nguoidung = null;
     MessageBox.Show("Đăng nhập thất bại. Xem lại tài khoản hoặc mật khẩu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }