private void DangNhap() { if (txtAccount.Text.Trim().Equals("") == true) { MessageBox.Show("Tài khoản không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtAccount.Focus(); return; } if (txtPass.Text.Trim().Equals("") == true) { MessageBox.Show("Mật khẩu không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPass.Focus(); return; } string shashPass = ""; shashPass = _validation.EncryptPassword(txtAccount.Text.Trim(), txtPass.Text.Trim()); nhanvienBL ctr = new nhanvienBL(); if (ctr.DangNhap(txtAccount.Text.Trim(), shashPass) == true) { Data.use = txtAccount.Text.Trim(); success = true; } else { MessageBox.Show("Đăng nhập không thành công.\nVui lòng kiểm tra lại tài khoản và mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtAccount.Focus(); return; } }
private void ChangePass() { string loi = ""; string sidnhanvien = ""; try { sidnhanvien = Data.iduse; } catch { } nhanvien _obj = new nhanvien(); nhanvienBL _ctr = new nhanvienBL(); _obj = _ctr.GetByID(sidnhanvien); string soldpass = ""; soldpass = _validation.EncryptPassword(_obj.taikhoan.Trim(), txtOldPass.Text.Trim()); if (soldpass.Trim().Equals(_obj.matkhau) == false) { MessageBox.Show("Mật khẩu cũ không đúng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtOldPass.Focus(); return; } if (txtNewPass.Text.Trim().Equals(txtReNewPass.Text.Trim()) == false) { MessageBox.Show("Mật nhắc lại không đúng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtNewPass.Focus(); return; } string snewpass = ""; snewpass = _validation.EncryptPassword(_obj.taikhoan.Trim(), txtNewPass.Text.Trim()); if (_obj != null) { _obj.matkhau = snewpass; loi = _ctr.ChangePass(sidnhanvien, snewpass); if (loi.Trim().Equals("") == true) { _ctrlog.Append(Data.use, "Đổi mật khẩu người dùng: " + _obj.taikhoan.Trim() + "(" + _obj.hoten + ")"); MessageBox.Show("Đổi mật khẩu người dùng thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(loi, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
private void DangNhap() { if (txtAccount.Text.Trim().Equals("") == true) { MessageBox.Show("Tài khoản không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtAccount.Focus(); return; } if (txtPass.Text.Trim().Equals("") == true) { MessageBox.Show("Mật khẩu không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPass.Focus(); return; } string shashPass = ""; shashPass = _validation.EncryptPassword(txtAccount.Text.Trim(), txtPass.Text.Trim()); nhanvienBL ctr = new nhanvienBL(); if (ctr.DangNhap(txtAccount.Text.Trim(), shashPass) == true) { try { Data.iduse = ctr.GetIDNhanVienByAccount(txtAccount.Text.Trim()); Data.use = txtAccount.Text.Trim(); this.Hide(); _ctrlog.Append(Data.use, "Đăng nhập hệ thống."); frmMain frm = new frmMain(); frm.ShowDialog(); if (frm.isActiveclose == false) { this.Show(); } else { this.Dispose(); } } catch (Exception e) { this.Dispose(); } } else { MessageBox.Show("Đăng nhập không thành công.\nVui lòng kiểm tra lại tài khoản và mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtAccount.Focus(); return; } }
private nhanvien GetDataValue() { nhanvien _obj = new nhanvien(); int iidchucvu = 0; try { iidchucvu = Convert.ToInt32(cbChucVu.SelectedValue.ToString().Trim()); } catch { } string sidphongban = ""; try { sidphongban = cbPhongBan.SelectedValue.ToString().Trim(); } catch { } if (trangthai == TrangThai.add) { _obj.idnhanvien = Guid.NewGuid().ToString(); } if (trangthai == TrangThai.update) { _obj.idnhanvien = c1FlexGrid1[c1FlexGrid1.RowSel, "idnhanvien"].ToString().Trim(); } if (txtAccount.Text.Equals("") == true) { MessageBox.Show("Tài khoản không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtAccount.Focus(); return(null); } if (txtPass.Text.Equals("") == true && trangthai == TrangThai.add) { MessageBox.Show("Mật khẩu không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPass.Focus(); return(null); } if (iidchucvu == 0) { MessageBox.Show("Chức vụ không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); cbChucVu.Focus(); return(null); } if (sidphongban.Trim().Equals("") == true) { MessageBox.Show("Phòng ban không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); cbPhongBan.Focus(); return(null); } if (txtHoTen.Text.Equals("") == true) { MessageBox.Show("Họ tên không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtHoTen.Focus(); return(null); } if (dpkNgaySinh.Value == null) { MessageBox.Show("Ngày sinh không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); dpkNgaySinh.Focus(); return(null); } if (txtDienThoai.Text.Equals("") == true) { MessageBox.Show("Điện thoại không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtDienThoai.Focus(); return(null); } if (txtEmail.Text.Equals("") == true) { MessageBox.Show("Email không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtEmail.Focus(); return(null); } _obj.diachi = txtDiaChi.Text.Trim(); _obj.dienthoai = txtDienThoai.Text.Trim(); _obj.email = txtEmail.Text.Trim(); _obj.ghichu = txtGhiChu.Text.Trim(); _obj.gioitinh = cbGioiTinh.Checked; _obj.hoten = txtHoTen.Text.Trim(); _obj.idphongban = sidphongban; _obj.idchucvu = iidchucvu; _obj.ngaysinh = dpkNgaySinh.Value; _obj.taikhoan = txtAccount.Text.Trim(); _obj.matkhau = _validation.EncryptPassword(_obj.taikhoan.Trim(), txtPass.Text); return(_obj); }