private void frmXemDanhMucNCC_Load(object sender, EventArgs e) { dbNCC = new DBNhaCungCap(); dgvDanhMucNCC.DataSource = dbNCC.GetAllNhaCC(); dgvDanhMucNCC.Columns["HopDong"].Visible = false; foreach (DataGridViewRow row in dgvDanhMucNCC.Rows) { row.HeaderCell.Value = (row.Index + 1).ToString(); } dgvDanhMucNCC.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders); cmCotTimKiem.DataSource = new string[] { "MaNCC", "TenNCC", "DiaChi", "SDT" }; }
public void DataLoad() { dbSanPham = new DBSanPham(); dbNCC = new DBNhaCungCap(); dbHopDong = new DBHopDong(); BuidHopDong(); SetMaHopDong(); dgvDanhMucSanPham.DataSource = dbSanPham.GetAllProduct(); dgvDanhMucSanPham.Columns["ChiTietHoaDon"].Visible = false; dgvDanhMucSanPham.Columns["ChiTietHopDong"].Visible = false; dgvDanhMucSanPham.Columns["GiaBan"].Visible = false; // Tạo số thứ tự đầu dòng của dgvDanhMucSanPham và tự auto size foreach (DataGridViewRow row in dgvDanhMucSanPham.Rows) { row.HeaderCell.Value = (row.Index + 1).ToString(); } dgvDanhMucSanPham.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders); var numbers = from n in Enumerable.Range(1, 20) select n; cmSoLuong.DataSource = numbers.ToList(); cmNhaCC.DataSource = dbNCC.GetAllNhaCC(); cmNhaCC.DisplayMember = "TenNCC"; cmNhaCC.ValueMember = "MaNCC"; cmNhaCC.Text = ""; txtMaNCC.Text = ""; txtTenNCC.Text = ""; btnGiamSP.Enabled = false; btnXoaSP.Enabled = false; btnThanhToan.Enabled = false; toolStrip2.Enabled = false; }