private void FindUse() { nhanvienBL _ctr = new nhanvienBL(); DataTable dt = new DataTable(); string sidphongban = ""; try { sidphongban = cbTK_PhongBan.SelectedValue.ToString().Trim(); } catch { } int sidchucvu = 0; try { sidchucvu = Convert.ToInt32(cbTK_ChucVu.SelectedValue.ToString().Trim()); } catch { } dt = _ctr.TimKiem(txtTK_HoTen.Text.Trim(), sidphongban, sidchucvu); c1FlexGrid1.DataSource = dt; FormatGrid(); if (c1FlexGrid1.Rows.Count - 1 > 0) { c1FlexGrid1.Select(1, c1FlexGrid1.Cols["hoten"].Index); string sidnhanvien = ""; try { sidnhanvien = c1FlexGrid1[1, "idnhanvien"].ToString().Trim(); } catch { } HienThiDSNhom(sidnhanvien); } else { UncheckAllNodes(treeNhom.Nodes); } }
private void Delete() { string staikhoan = ""; try { staikhoan = c1FlexGrid1[c1FlexGrid1.RowSel, "taikhoan"].ToString().Trim(); } catch { } if (staikhoan.Trim().Equals("admin") == false) { if (MessageBox.Show("Xác nhận xóa người dùng.", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string sidnhanvien = ""; try { sidnhanvien = c1FlexGrid1[c1FlexGrid1.RowSel, "idnhanvien"].ToString().Trim(); } catch { } nhanvien _obj = new nhanvien(); nhanvienBL _ctr = new nhanvienBL(); _obj = _ctr.GetByID(sidnhanvien); string loi = ""; loi = _ctr.Delete(sidnhanvien); if (loi.Trim().Equals("") == true) { try { _ctrlog.Append(Data.use, "Xóa người dùng: " + _obj.hoten.Trim() + "(" + _obj.taikhoan.Trim() + ")"); } catch { } FindUse(); ClearText(); trangthai = TrangThai.none; MessageBox.Show("Xóa người dùng thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show("Bạn không thể xóa người dùng này.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void Resetpass() { if (MessageBox.Show("Xác nhận đặt lại mật khẩu người dùng.\nSau khi thiết lập lại thì mật khẩu mặc định là: \"123456\".", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string loi = ""; string spass = ""; string sidnhanvien = ""; try { sidnhanvien = c1FlexGrid1[c1FlexGrid1.RowSel, "idnhanvien"].ToString().Trim(); } catch { } nhanvien _obj = new nhanvien(); nhanvienBL _ctr = new nhanvienBL(); _obj = _ctr.GetByID(sidnhanvien); spass = _validation.EncryptPassword(_obj.taikhoan.Trim(), "123456"); if (_obj != null) { _obj.matkhau = spass; loi = _ctr.ChangePass(sidnhanvien, spass); if (loi.Trim().Equals("") == true) { c1FlexGrid1.Select(c1FlexGrid1.FindRow(_obj.idnhanvien.Trim(), 1, c1FlexGrid1.Cols["idnhanvien"].Index, true), c1FlexGrid1.Cols["hoten"].Index, true); DisplayInfoUser(sidnhanvien); _ctrlog.Append(Data.use, "Đặt lập lại mật khẩu người dùng: " + _obj.taikhoan.Trim() + "(" + _obj.hoten + ")"); trangthai = TrangThai.update; MessageBox.Show("Đặt lập lạ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); } } } }
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 LoadCBNhanVien() { nhanvienBL ctrNhanVien = new nhanvienBL(); DataTable dt = new DataTable(); dt = ctrNhanVien.GetAll(); cbNhanVien.DataSource = dt; cbNhanVien.DisplayMember = "hoten"; cbNhanVien.ValueMember = "taikhoan"; }
private void FindUse() { nhanvienBL _ctr = new nhanvienBL(); DataTable dt = new DataTable(); string sidphongban = ""; try{ sidphongban = cbTK_PhongBan.SelectedValue.ToString().Trim(); }catch {} int sidchucvu = 0; try{ sidchucvu = Convert.ToInt32(cbTK_ChucVu.SelectedValue.ToString().Trim()); }catch {} dt = _ctr.TimKiem(txtTK_HoTen.Text.Trim(), sidphongban, sidchucvu); c1FlexGrid1.DataSource = dt; FormatGrid(); }
private void Save() { string loi = ""; nhanvien _obj = new nhanvien(); nhanvienBL _ctr = new nhanvienBL(); _obj = GetDataValue(); if (_obj != null) { if (trangthai == TrangThai.add) { loi = _ctr.Insert(_obj); if (loi.Trim().Equals("") == true) { _ctrlog.Append(Data.use, "Thêm mới người dùng: " + _obj.taikhoan.Trim() + "(" + _obj.hoten + ")"); FindUse(); c1FlexGrid1.Select(c1FlexGrid1.FindRow(_obj.idnhanvien.Trim(), 1, c1FlexGrid1.Cols["idnhanvien"].Index, true), c1FlexGrid1.Cols["hoten"].Index, true); MessageBox.Show("Thêm mới 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); } } if (trangthai == TrangThai.update) { loi = _ctr.Update(_obj); if (loi.Trim().Equals("") == true) { _ctrlog.Append(Data.use, "Cập nhật thông tin người dùng: " + _obj.taikhoan.Trim() + "(" + _obj.hoten + ")"); trangthai = TrangThai.update; FindUse(); c1FlexGrid1.Select(c1FlexGrid1.FindRow(_obj.idnhanvien.Trim(), 1, c1FlexGrid1.Cols["idnhanvien"].Index, true), c1FlexGrid1.Cols["hoten"].Index, true); MessageBox.Show("Cập nhật thông tin 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); } } } if (loi.Trim().Equals("") == true) { trangthai = TrangThai.update; DisplayInfoUser(_obj.idnhanvien); } }
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 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 frmMain_Load(object sender, EventArgs e) { DisplayMenu(); AddTabDefault(); nhanvienBL ctrnv = new nhanvienBL(); nhanvien objnv = new nhanvien(); objnv = ctrnv.GetByID(Data.iduse.Trim()); if (objnv != null) { tslbUser.Text = "Người dùng: " + Data.use.Trim() + "(" + objnv.hoten.Trim() + ")"; } else { tslbUser.Text = "Người dùng: " + Data.use.Trim(); } tslbPointTime.Text = "Đăng nhập lúc: " + DateTime.Now.ToString("HH:mm:ss - dd/MM/yyyy"); }
private void DisplayInfoUser(string sid) { nhanvien _obj = new nhanvien(); nhanvienBL _ctr = new nhanvienBL(); _obj = _ctr.GetByID(sid); if (_obj != null) { trangthai = TrangThai.update; txtAccount.Text = _obj.taikhoan.Trim(); txtAccount.Enabled = false; txtDiaChi.Text = _obj.diachi.Trim(); txtDienThoai.Text = _obj.dienthoai.Trim(); txtEmail.Text = _obj.email.Trim(); txtGhiChu.Text = _obj.ghichu.Trim(); txtHoTen.Text = _obj.hoten.Trim(); txtPass.Text = _obj.matkhau; txtPass.Enabled = false; dpkNgaySinh.Value = _obj.ngaysinh; cbGioiTinh.Checked = _obj.gioitinh; if (_obj.idchucvu == 0) { cbChucVu.SelectedIndex = -1; } else { cbChucVu.SelectedValue = _obj.idchucvu; } if (_obj.idphongban.Trim().Equals("") == true) { cbPhongBan.SelectedIndex = -1; } else { cbPhongBan.SelectedValue = _obj.idphongban.Trim(); } txtAccount.Focus(); } }
private void btnExport_Click(object sender, EventArgs e) { nhanvienBL ctrNhanVien = new nhanvienBL(); if (dpkTuNgay.Value.ToString("dd/MM/yyyy").Equals(dpkDenNgay.Value.ToString("dd/MM/yyyy")) == true || dpkTuNgay.Value > dpkDenNgay.Value) { MessageBox.Show("Ngày đầu kỳ thống kê phải nhỏ hơn ngày kết thúc kỳ thống kê.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); dpkTuNgay.Focus(); return; } Application.DoEvents(); progressBar1.PerformStep(); Application.DoEvents(); DateTime dttungay = dpkTuNgay.Value; DateTime dtdenngay = dpkDenNgay.Value; tblhoadonbanBL ctrhd = new tblhoadonbanBL(); DataTable dtnv = new DataTable(); try { Application.DoEvents(); progressBar1.PerformStep(); Application.DoEvents(); string sidnv = "-1"; try { sidnv = cbNhanVien.SelectedValue.ToString().Trim(); } catch { } if (sidnv.Trim().Equals("-1") == true) { try { dtnv = ctrNhanVien.LoadDSCBNV(); dtnv.Rows.RemoveAt(0); } catch { } } else { try { object[] obj = { cbNhanVien.SelectedValue.ToString().Trim(), cbNhanVien.Text.Trim() }; dtnv.Columns.Add("taikhoan"); dtnv.Columns.Add("hoten"); dtnv.Rows.Add(obj); } catch { } } Application.DoEvents(); progressBar1.PerformStep(); Application.DoEvents(); } catch { } if (dtnv != null) { TKDoanhThuByIDNV ctr = new TKDoanhThuByIDNV(); string kq = ""; kq = ctr.Generate(txtpath.Text, dttungay, dtdenngay, dtnv, progressBar1); Application.DoEvents(); progressBar1.Value = progressBar1.Maximum; Application.DoEvents(); if (kq.Trim().Equals("") == true) { MessageBox.Show("Tổng hợp dữ liệu thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Tổng hợp dữ liệu không thành công.\nChi tiết lỗi: " + kq, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } progressBar1.Value = 0; Application.DoEvents(); } else { MessageBox.Show("Lỗi không tổng hợp được dữ liệu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }