//--------https://khanhn.wordpress.com/2016/10/13/rememberme-trong-windows-forms-voi-c/--------- Nguồn. private void bt_DangNhap_Click(object sender, EventArgs e) { DataTable tb = TK.Dang_Nhap(txt_TaiKhoan.Text, txt_MatKhau.Text); DataTable tb1 = TK.Thong_Tin_Tai_Khoan(txt_TaiKhoan.Text); string A = txt_TaiKhoan.Text; try { if (txt_TaiKhoan.Text == "" || txt_MatKhau.Text == "") { throw new Exception("Bạn chưa điền đầy đủ thông tin đăng nhập. Mời đăng nhập lại!"); } else { if (tb.Rows.Count > 0) { KiemTra_NhanVien(A); KiemTra_QLKho(A); KiemTra_ThuNgan(A); KiemTra_ChuQL(A); KiemTra_ThongKe(A); lb_ThongBao.Text = "Đăng nhập thành công!"; Chay(); this.Hide(); TrangChu.DangXuat(true); TrangChu.DangNhap(false); TrangChu.TieuDe(A, tb1.Rows[0][0].ToString(), tb1.Rows[0][1].ToString()); Luu_DN(); } else { lb_ThongBao.Text = "Thông tin đăng nhập sai!"; } } } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } finally { txt_TaiKhoan.ResetText(); txt_MatKhau.ResetText(); } }
private void bt_ThayDoi_Click(object sender, EventArgs e) { string A = txt_TenTaiKhoan.Text; string B = txt_MatKhauCu.Text; string C = txt_MatKhauMoi.Text; TK1.TEN_TAI_KHOAN1 = A; TK1.MAT_KHAU1 = C; DataTable tb = TK.Dang_Nhap(A, B); try { if (txt_TenTaiKhoan.Text == "" || txt_MatKhauCu.Text == "" || txt_MatKhauMoi.Text == "") { throw new Exception("Bạn chưa điền đầy đủ thông tin để đổi mật khẩu. Mời điền lại thông tin lại!"); } else { if (tb.Rows.Count > 0) { TK.Doi_Mat_Khau(TK1); MessageBox.Show("Đổi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { throw new Exception("Thông tin tài khoản, mật khẩu không chính xác!"); } } } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } finally { txt_TenTaiKhoan.ResetText(); txt_MatKhauCu.ResetText(); txt_MatKhauMoi.ResetText(); } }