private void simpleButton1_Click(object sender, EventArgs e) { try { if (NguoiDungBUS.KiemTraTenDangNhap(txtTenDangNhap.Text.Trim())) { NguoiDung user = NguoiDungBUS.LayThongTin(txtTenDangNhap.Text.Trim()); if (user.MatKhau == UtilitiesClass.MaHoaMD5(txtMatKhau.Text)) { StaticClass.User = user; StaticClass.DangNhap = true; Settings.Default.TenDangNhap = user.TenDangNhap; if (ckbNhoMatKhau.Checked) { Settings.Default.MatKhau = txtMatKhau.Text; } else { Settings.Default.MatKhau = ""; } Settings.Default.Save(); DialogResult = DialogResult.OK; StaticClass.Log.GhiFile("Đăng nhập hệ thống"); this.Close(); } else { MsgboxUtil.Exclamation("Mật khẩu không đúng."); txtMatKhau.Focus(); txtMatKhau.SelectAll(); return; } } else { MsgboxUtil.Exclamation("Người dùng không tồn tại"); txtTenDangNhap.Focus(); txtTenDangNhap.SelectAll(); return; } } catch (Exception ex) { MsgboxUtil.Error(ex.Message); } }
private void simpleButton1_Click(object sender, EventArgs e) { try { SinhVien sv = new SinhVien(); if (TaoMoi(sv)) { frmMatKhau frm = new frmMatKhau(); frm.truyen += new frmMatKhau.TruyenMatKhau(GetMatKhau); if (frm.ShowDialog() == DialogResult.OK) { NguoiDung user = new NguoiDung() { TenDangNhap = sv.MSSV.ToLower(), MatKhau = UtilitiesClass.MaHoaMD5(_matKhau), TenNguoiDung = sv.HoTen, Quyen = (int)QuyenNguoiDung.SinhVien, MoTaQuyen = "Sinh viên" }; NguoiDungBUS.Them(user); SinhVienBUS.Them(sv); StaticClass.LuuThayDoi(); log.GhiFile("Thêm mới sinh viên: " + sv.MSSV); MsgboxUtil.Success("Thành công"); ClearText(); TaoMa(); } else { MsgboxUtil.Exclamation("Không thể thêm sinh viên khi chưa thiết lập mật khẩu"); } } } catch (Exception ex) { ExceptionUtil.ThrowMsgBox(ex.Message); } }