//Dang nhap private void ebtnDangNhap_Click(object sender, EventArgs e) { DataService.OpenConnection(); this.WindowState = FormWindowState.Maximized; //FrmDangNhap m_FrmDangNhap = new FrmDangNhap(); if (m_FrmDangNhap.ShowDialog() == DialogResult.OK) { String username = m_FrmDangNhap.txtUsername.Text; String password = m_FrmDangNhap.txtPassword.Text; NguoiDungCtrl m_NguoiDungCtrl = new NguoiDungCtrl(); int ketqua = m_NguoiDungCtrl.DangNhap(username, password); switch (ketqua) { case 0: MessageBox.Show("Người dùng này chưa có trong hệ thống", "Log In", MessageBoxButtons.OK, MessageBoxIcon.Warning); Disable(); break; case 1: MessageBox.Show("Bạn đã nhập sai mật khẩu", "Log In", MessageBoxButtons.OK, MessageBoxIcon.Warning); Disable(); break; case 2: MessageBoxEx.Show("Chào bạn " + staticClass.nguoidungStatic.TenNguoiDung + " vào hệ thống !"); lblTenNguoiDung.Text = staticClass.nguoidungStatic.TenNguoiDung; PhanQuyen(staticClass.nguoidungStatic.MaQuyen); break; } } }
private void btnThem_Click(object sender, EventArgs e) { NguoiDungCtrl ctr = new NguoiDungCtrl(); group.Enabled = true; txtMa.Enabled = true; txtMa.Text = ctrl.LayMaMax().ToString(); txtuser.Text = ""; txtHoTen.Text = ""; txtpas.Text = ""; cmbQuyen.SelectedIndex = (cmbQuyen.Items.Count > 0 ? 0 : -1); listDSNguoiDung.Enabled = false; adding = true; updating = false; btnThem.Enabled = false; btnXoa.Enabled = false; btnSua.Enabled = false; btnCapNhat.Enabled = true; btnBoQua.Visible = true; }
private void btnDangNhap_Click(object sender, EventArgs e) { int rs = NguoiDungCtrl.Login(txtTenDangNhap.Text, txtMatKhau.Text); if (rs == 0) { XtraMessageBox.Show("1. Tên đăng nhập hoặc mật khẩu không đúng.\n\n2. Hoặc kết nối đến máy chủ không thành công\n\n3. Hoặc cơ sở dữ liệu không phù hợp\n\n* Vui lòng kiểm tra lại thông tin đăng nhập hoặc kết nối cơ sở dữ liệu*", "Đăng nhập thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error); txtMatKhau.Focus(); txtMatKhau.SelectAll(); } else if (rs == 1) { this.DialogResult = DialogResult.OK; } else if (rs == 2) { if (Program.CurrentUser == null) { XtraMessageBox.Show("Tài khoản này đang đăng nhập ở một nơi khác.\n\nVui lòng liên hệ giám đốc để kiểm tra lại!", "Đăng nhập thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { XtraMessageBox.Show("Đăng nhập thành công.\n\nPhát hiện tài khoản giám đốc đang đăng nhập ở một nơi khác!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.DialogResult = DialogResult.OK; } } else { XtraMessageBox.Show("Tài khoản này đã bị khóa.\n\nVui lòng liên hệ giám đốc để kiểm tra lại!", "Đăng nhập thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnThoat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (XtraMessageBox.Show("Bạn có thực sự muốn thoát khỏi hệ thống không!", "Thoát khỏi hệ thống", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { NguoiDungCtrl.Logout(); Application.ExitThread(); } }
private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { //btnThoat.PerformClick(); if (XtraMessageBox.Show("Bạn có thực sự muốn thoát khỏi hệ thống không!", "Thoát khỏi hệ thống", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { NguoiDungCtrl.Logout(); Application.ExitThread(); } else { e.Cancel = true; } }
private void frmDangNhap_Load(object sender, EventArgs e) { NguoiDungCtrl m_NguoiDungCtrl = new NguoiDungCtrl(); m_NguoiDungCtrl.HienThiTaiKhoanDuocLuu(txtdangnhap, txtmatkhau); if (txtdangnhap.Text != "") { checkLuuMatKhau.Checked = true; } else //if (txtdangnhap.Text == "") { checkLuuMatKhau.Checked = false; } }
private void btnDangXuat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (NguoiDungCtrl.Logout() > 0) { tmrDongHo.Stop(); tmrTracker.Stop(); CloseAllForm(); Program.CurrentUser = null; XtraMessageBox.Show("Đăng xuất thành công khỏi hệ thống!", "Đăng xuất thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); btnDangNhap.Enabled = true; btnDangNhap.PerformClick(); } else { XtraMessageBox.Show("Không thể đăng xuất khỏi hệ thống!", "Đăng xuất thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSuaTaiKhoan_Click(object sender, EventArgs e) { if (txtMatKhau.Text.Length < 6 && txtMatKhau.Text.Length > 0) { XtraMessageBox.Show("Mật khẩu phải ít nhất là 6 ký tự.", "Nhập mật khẩu đăng nhập mới", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMatKhau.Focus(); } else if (txtMatKhauXacNhan.Text != txtMatKhau.Text) { XtraMessageBox.Show("Mật khẩu xác nhận không khớp.", "Xác nhận mật khẩu", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (tedThoiGianCho.Text == "00:00") { XtraMessageBox.Show("Thời gian chờ phải từ 1 phút trở lên.", "Nhập thời gian chờ", MessageBoxButtons.OK, MessageBoxIcon.Warning); tedThoiGianCho.Focus(); } else { if (txtMatKhau.Text == "") { if (XtraMessageBox.Show("Bạn chưa nhập mật khẩu mới.\nBạn có muốn giữ nguyên mật khẩu cũ không?", "Sửa tài khoản người dùng", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { XtraMessageBox.Show("Vui lòng nhập mật khẩu mới.", "Nhập mật khẩu mới", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMatKhau.Focus(); return; } } int rs = NguoiDungCtrl.Update(user.ID_nguoi_dung, txtMatKhauXacNhan.Text, txtTenDayDu.Text, chkKichHoatTaiKhoan.Checked ? 1 : 3, tedThoiGianCho.Text, db); if (rs == 0) { XtraMessageBox.Show("Sửa tài khoản người dùng không thành công!\nCó thể do lỗi hệ thống hoặc không có thông tin gì thay đổi!", "Sửa tài khoản người dùng", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { XtraMessageBox.Show("Sửa tài khoản người dùng thành công.", "Sửa tài khoản người dùng", MessageBoxButtons.OK, MessageBoxIcon.Information); //user.Ten_day_du = txtTenDayDu.Text; //user.ID_trang_thai = chkKichHoatTaiKhoan.Checked ? 1 : 3; //user.Thoi_gian_cho = TimeSpan.Parse(tedThoiGianCho.Text); btnLamLai.PerformClick(); } } }
private void btnTaoTaiKhoan_Click(object sender, EventArgs e) { if (txtTenDangNhap.Text.Length < 3) { XtraMessageBox.Show("Tên đăng nhập phải ít nhất là 3 ký tự.", "Nhập tên đăng nhập", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenDangNhap.Focus(); } else if (txtMatKhau.Text.Length < 6) { XtraMessageBox.Show("Mật khẩu phải ít nhất là 6 ký tự.", "Nhập mật khẩu đăng nhập", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMatKhau.Focus(); } else if (txtMatKhauXacNhan.Text != txtMatKhau.Text) { XtraMessageBox.Show("Mật khẩu xác nhận không khớp.", "Xác nhận mật khẩu", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (tedThoiGianCho.Text == "00:00") { XtraMessageBox.Show("Thời gian chờ phải từ 1 phút trở lên.", "Nhập thời gian chờ", MessageBoxButtons.OK, MessageBoxIcon.Warning); tedThoiGianCho.Focus(); } else { int rs = NguoiDungCtrl.Insert(ledNhanVien.EditValue, txtTenDangNhap.Text, txtMatKhau.Text, txtTenDayDu.Text, chkKichHoatTaiKhoan.Checked ? 1 : 3, tedThoiGianCho.Text, db); if (rs == -1) { XtraMessageBox.Show("Tài khoản này đã tồn tại.\nVui lòng chọn một tên đăng nhập khác!", "Tạo tài khoản người dùng", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (rs == 0) { XtraMessageBox.Show("Tạo tài khoản người dùng mới không thành công.", "Tạo tài khoản người dùng", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { XtraMessageBox.Show("Tạo tài khoản người dùng mới thành công.", "Tạo tài khoản người dùng mới", MessageBoxButtons.OK, MessageBoxIcon.Information); btnLamLai.PerformClick(); } } }
private void tmrTracker_Tick(object sender, EventArgs e) { // Cài đặt lại thông số đồng hồ CaiDatThongSoDongHo(); // Kiểm tra lại thông tin người dùng var user = NguoiDungCtrl.LayNguoiDungTheoID(Program.CurrentUser.ID_nguoi_dung); if (user == null) { XtraMessageBox.Show("Không kết nối được đến tài khoản!", "Theo dõi tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Stop); btnDangXuat.PerformClick(); tmrTracker.Stop(); tmrDongHo.Stop(); return; } if (user.ID_trang_thai == 3) { if (TotalTime.TotalMilliseconds > RemainingTime + tmrDongHo.Interval) { TotalTime = TimeSpan.FromMilliseconds((double)(RemainingTime + tmrDongHo.Interval)); lblRemainingTimeMessage.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; lblRemainingTime.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; waiting = true; XtraMessageBox.Show("Tài khoản đã bị giám đốc khóa!", "Theo dõi tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else if (user.ID_trang_thai == 1) { if (TotalTime.TotalMilliseconds > RemainingTime + tmrDongHo.Interval) { TotalTime = TimeSpan.FromMilliseconds((double)(RemainingTime + tmrDongHo.Interval)); lblRemainingTimeMessage.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; lblRemainingTime.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; waiting = true; XtraMessageBox.Show("Tài khoản không còn đăng nhập!", "Theo dõi tài khoản", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } }
private void btnMoTaiKhoan_Click(object sender, EventArgs e) { ViewNguoiDung user = (ViewNguoiDung)grvNguoiDung.GetFocusedRow(); if (user.ID_trang_thai != 3) { XtraMessageBox.Show("Tài khoản người dùng không bị khóa.", "Mở khóa tài khoản người dùng", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int rs = NguoiDungCtrl.ChangeState(user.ID_nguoi_dung, false, db); if (rs == 0) { XtraMessageBox.Show("Mở khóa tài khoản người dùng không thành công.", "Mở khóa tài khoản người dùng", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { XtraMessageBox.Show("Mở khóa tài khoản người dùng thành công.", "Mở khóa tài khoản người dùng", MessageBoxButtons.OK, MessageBoxIcon.Information); frmNguoiDung_Load(sender, e); } }
private void btnSuaTaiKhoan_Click(object sender, EventArgs e) { if (txtMatKhau.Text.Length < 6 && txtMatKhau.Text.Length > 0) { XtraMessageBox.Show("Mật khẩu phải ít nhất là 6 ký tự.", "Nhập mật khẩu đăng nhập mới", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMatKhau.Focus(); } else if (txtMatKhauXacNhan.Text != txtMatKhau.Text) { XtraMessageBox.Show("Mật khẩu xác nhận không khớp.", "Xác nhận mật khẩu", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (txtMatKhau.Text == "") { if (XtraMessageBox.Show("Bạn chưa nhập mật khẩu mới.\nBạn có muốn giữ nguyên mật khẩu cũ không?", "Sửa tài khoản người dùng", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { XtraMessageBox.Show("Vui lòng nhập mật khẩu mới.", "Nhập mật khẩu mới", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMatKhau.Focus(); return; } } int rs = NguoiDungCtrl.Update(Program.CurrentUser.ID_nguoi_dung, txtMatKhauXacNhan.Text, txtTenDayDu.Text); if (rs == 0) { XtraMessageBox.Show("Cập nhật thông tin cá nhân không thành công!\nCó thể do lỗi hệ thống hoặc không có thông tin gì thay đổi.", "Cập nhật thông tin cá nhân", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { XtraMessageBox.Show("Cập nhật thông tin cá nhân thành công.", "Cập nhật thông tin cá nhân", MessageBoxButtons.OK, MessageBoxIcon.Information); btnLamLai.PerformClick(); } } }
private void frmDangNhap_Load(object sender, EventArgs e) { NguoiDungCtrl m_NguoiDungCtrl = new NguoiDungCtrl(); m_NguoiDungCtrl.HienThiTaiKhoanDuocLuu(txtdangnhap, txtmatkhau); }
private void frmNguoiDung_Load(object sender, EventArgs e) { db = new Entities(); NguoiDungCtrl.LoadBindingSource(viewNguoiDungBindingSource, db); VaiTroQuyenCtrl.ReconfigFormControls(this, db); }