void LoadData() { nhanVien.LayNhanVien(dtgvDS); nhanVien.LoadDiaChi(cbbDiaChi); this.btnLuu.Enabled = false; this.btnHuy.Enabled = true; this.btnSua.Enabled = false; this.btnThem.Enabled = true; this.btnXoa.Enabled = false; this.txtHoTen.Enabled = false; this.cbbGioiTinh.Enabled = false; this.cbbNgaySinh.Enabled = false; this.txtDiaChi.Enabled = false; this.txtSDT.Enabled = false; this.cbbNgayVL.Enabled = false; this.txtLuongCB.Enabled = false; this.txtDiaChi.ResetText(); this.txtHoTen.ResetText(); this.txtLuongCB.ResetText(); this.txtMaNV.ResetText(); this.cbbNgaySinh.ResetText(); this.cbbNgayVL.ResetText(); this.cbbGioiTinh.ResetText(); this.txtSDT.ResetText(); }
void loadData() { try { dtChucVu = new DataTable(); dtChucVu.Clear(); dtChucVu = dbChucVu.LayChucVu().Tables[0]; (dgv.Columns["colChucVu"] as DataGridViewComboBoxColumn).DataSource = dtChucVu; (dgv.Columns["colChucVu"] as DataGridViewComboBoxColumn).DisplayMember = "TenChucVu"; (dgv.Columns["colChucVu"] as DataGridViewComboBoxColumn).ValueMember = "MaChucVu"; dtNhanVien = new DataTable(); dtNhanVien.Clear(); dtNhanVien = dbNhanVien.LayNhanVien().Tables[0]; (dgv.Columns["colNhanVien"] as DataGridViewComboBoxColumn).DataSource = dtNhanVien; (dgv.Columns["colNhanVien"] as DataGridViewComboBoxColumn).DisplayMember = "TenNV"; (dgv.Columns["colNhanVien"] as DataGridViewComboBoxColumn).ValueMember = "MaNV"; dtCTChucVu = new DataTable(); dtCTChucVu.Clear(); dtCTChucVu = dbCTChucVu.LayChiTietChucVu().Tables[0]; dgv.DataSource = dtCTChucVu; } catch (SqlException) { MessageBox.Show("Không lấy được nội dung trong table . Lỗi rồi!!!"); } }
public void LoadNhanVien() { try { //đổ dữ liệu vào datatable NhanVien dtNhanVien = new DataTable(); dtNhanVien.Clear(); dtNhanVien = nhanVien.LayNhanVien().Tables[0]; //đưa vào List List <NhanVien> NhanViens = new List <NhanVien>(); foreach (DataRow p in dtNhanVien.Rows) { NhanVien nv = new NhanVien(); nv.MaNV = int.Parse(p["MaNV"].ToString()); nv.HoTenDem = p["TenLot"].ToString(); nv.TenNV = p["TenNV"].ToString(); nv.Nu = (bool)p["GioiTinh"]; nv.SoDienThoai = p["SDT"].ToString(); //lưu NhanVien vào list NhanViens.Add(nv); } //hiển thị lên combobox cbNhanVien.DataSource = NhanViens; cbNhanVien.DisplayMember = "TenNV"; cbNhanVien.ValueMember = "MaNV"; } catch { MessageBox.Show("Không Lấy Được Dữ Liệu!!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
void loadData() { try { dtNhanVien = new DataTable(); dtNhanVien.Clear(); dtNhanVien = dbNhanVien.LayNhanVien().Tables[0]; dgv.DataSource = dtNhanVien; this.txtMaNV.ResetText(); this.txtCMND.ResetText(); this.txtHoNV.ResetText(); this.txtTenLot.ResetText(); this.txtTenNV.ResetText(); this.chkboxNu.ResetText(); chkboxNu.ResetText(); dtpickerNgaySinh.ResetText(); this.txtLuong.ResetText(); this.txtSDT.ResetText(); this.ptBoxHinhNV.ResetText(); this.txtDiaChi.ResetText(); this.pnl.Enabled = false; this.btnLuu.Enabled = false; this.btnHuy.Enabled = false; this.btnRefresh.Enabled = true; this.btnThem.Enabled = true; this.btnXoa.Enabled = true; this.btnSua.Enabled = true; this.btnThoat.Enabled = true; } catch { MessageBox.Show("Không lấy được nội dung trong table . Lỗi rồi!!!"); } }