public void LoadLaptop() { try { dtLaptop = new DataTable(); dtLaptop.Clear(); dtLaptop = Laptop.LayLaptop().Tables[0]; cbMaLT.DataSource = dtLaptop; cbMaLT.DisplayMember = "TenLT"; cbMaLT.ValueMember = "MaLT"; } catch (SqlException) { MessageBox.Show("Không Lấy Được Dữ Liệu!!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
void loadData() { try { dtLoaiLaptop = new DataTable(); dtLoaiLaptop.Clear(); dtLoaiLaptop = dbLoaiLaptop.LayLoaiLT().Tables[0]; (dgvLaptop.Columns["Loai"] as DataGridViewComboBoxColumn).DataSource = dtLoaiLaptop; (dgvLaptop.Columns["Loai"] as DataGridViewComboBoxColumn).DisplayMember = "TenLoaiLT"; (dgvLaptop.Columns["Loai"] as DataGridViewComboBoxColumn).ValueMember = "MaLoaiLT"; dtLaptop = new DataTable(); dtLaptop.Clear(); dtLaptop = dbLaptop.LayLaptop().Tables[0]; dgvLaptop.DataSource = dtLaptop; this.txtMaLaptop.ResetText(); this.txtTenLaptop.ResetText(); this.cmbLoaiLT.ResetText(); this.ptBoxHinhLaptop.ResetText(); this.txtDonGia.ResetText(); this.txtSoLuongCon.ResetText(); this.txtxGhiChu.ResetText(); this.pnlLT.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 (SqlException) { MessageBox.Show("Không lấy được nội dung trong table . Lỗi rồi!!!"); } }
public void LoadSanPham() { try { dtLoaiLaptop = new DataTable(); dtLoaiLaptop.Clear(); dtLoaiLaptop = dbLoaiLaptop.LayLoaiLT().Tables[0]; (dgvLaptop.Columns["Loai"] as DataGridViewComboBoxColumn).DataSource = dtLoaiLaptop; (dgvLaptop.Columns["Loai"] as DataGridViewComboBoxColumn).DisplayMember = "TenLoaiLT"; (dgvLaptop.Columns["Loai"] as DataGridViewComboBoxColumn).ValueMember = "MaLoaiLT"; dtLaptop = new DataTable(); dtLaptop.Clear(); dtLaptop = laptop.LayLaptop().Tables[0]; dgvLaptop.DataSource = dtLaptop; } catch (SqlException) { MessageBox.Show("Không lấy được nội dung trong table . Lỗi rồi!!!"); } }