public void DataLoad()
        {
            dbCTHoaDon = new DBChiTietHoaDon();
            dgvDanhMucCTHoaDon.DataSource = dbCTHoaDon.GetAllCTHoaDon();
            dgvDanhMucCTHoaDon.Columns["HoaDon"].Visible  = false;
            dgvDanhMucCTHoaDon.Columns["SanPham"].Visible = false;
            foreach (DataGridViewRow row in dgvDanhMucCTHoaDon.Rows)
            {
                row.HeaderCell.Value = (row.Index + 1).ToString();
            }
            dgvDanhMucCTHoaDon.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);

            if (dgvDanhMucCTHoaDon.Rows.Count == 0)
            {
                btnXoa.Enabled = false;
            }
            cmMaHoaDon.DataSource    = new DBHoaDon().GetAllHoaDon();
            cmMaHoaDon.DisplayMember = "MaHoaDon";
            cmMaHoaDon.ValueMember   = "MaHoaDon";

            cmMaSP.DataSource    = new DBSanPham().GetAllProduct();
            cmMaSP.DisplayMember = "MaSP";
            cmMaSP.ValueMember   = "MaSP";

            DataBind();
        }
Example #2
0
        private void frmXemDanhMucChiTietHoaDon_Load(object sender, EventArgs e)
        {
            dbCTHoaDon = new DBChiTietHoaDon();
            dgvDanhMucCTHoaDon.DataSource = dbCTHoaDon.GetAllCTHoaDon();
            dgvDanhMucCTHoaDon.Columns["HoaDon"].Visible  = false;
            dgvDanhMucCTHoaDon.Columns["SanPham"].Visible = false;
            foreach (DataGridViewRow row in dgvDanhMucCTHoaDon.Rows)
            {
                row.HeaderCell.Value = (row.Index + 1).ToString();
            }
            dgvDanhMucCTHoaDon.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);

            cmCotTimKiem.DataSource = new string[] { "MaHoaDon", "MaSP" };
        }