void LoadData()
 {
     try
     {
         dvgTableHangHoa.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
         dvgTableHangHoa.Enabled             = true;
         //
         dtHangHoa = new DataTable();
         dtHangHoa.Clear();
         //
         dtHangHoa = dbHangHoa.LayBangHangHoa();
         dvgTableHangHoa.DataSource = dtHangHoa;
         //
         this.btnHuy.Enabled = false;
         this.btnLuu.Enabled = false;
         //
         this.btnSua.Enabled    = true;
         this.btnTaiLai.Enabled = true;
         this.btnThem.Enabled   = true;
         this.btnTroVe.Enabled  = true;
         this.btnXoa.Enabled    = true;
         //
         this.txtTimHH.Enabled = true;
         this.btnTim.Enabled   = true;
         this.txtTimHH.ResetText();
         //
         this.txtGia.Enabled      = false;
         this.cbKho.Enabled       = false;
         this.txtMaHH.Enabled     = false;
         this.cbMaNCC.Enabled     = false;
         this.txtSLTonKho.Enabled = false;
         this.txtTenHH.Enabled    = false;
         this.rtbGhiChu.Enabled   = false;
         //
         DvgTableHangHoa_CellClick(null, null);
         this.txtMaHH.Focus();
     }
     catch (SqlException)
     {
         MessageBox.Show("Lỗi Rồi! Không Load Được Bảng", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #2
0
 private void BtnHT_Click(object sender, EventArgs e)
 {
     //LoadData();
     if (cbTable.SelectedValue.ToString() == "CHINHANH")
     {
         LoadData();
         dvgShowTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
         dt = dbChiNhanh.LayBangChiNhanh();
         dvgShowTable.DataSource       = dt;
         dvgShowTable.Rows[0].Selected = false;
     }
     else if (cbTable.SelectedValue.ToString() == "NHANVIEN")
     {
         LoadData();
         dvgShowTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
         dt = dbNhanVien.LayBangNhanVien();
         dvgShowTable.DataSource       = dt;
         dvgShowTable.Rows[0].Selected = false;
     }
     else if (cbTable.SelectedValue.ToString() == "PHIEUNHAPHANG")
     {
         LoadData();
         dvgShowTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
         dt = dbPhieuNhap.LayBangPhieuNhap();
         dvgShowTable.DataSource       = dt;
         dvgShowTable.Rows[0].Selected = false;
     }
     else if (cbTable.SelectedValue.ToString() == "KHO")
     {
         LoadData();
         dvgShowTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
         dt = dbKho.LayBangKho();
         dvgShowTable.DataSource       = dt;
         dvgShowTable.Rows[0].Selected = false;
     }
     else if (cbTable.SelectedValue.ToString() == "HANGHOA")
     {
         LoadData();
         dvgShowTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
         dt = dbHangHoa.LayBangHangHoa();
         dvgShowTable.DataSource       = dt;
         dvgShowTable.Rows[0].Selected = false;
     }
     else if (cbTable.SelectedValue.ToString() == "NHACUNGCAP")
     {
         LoadData();
         dvgShowTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
         dt = dbNhaCungCap.LayBangNhaCungCap();
         dvgShowTable.DataSource       = dt;
         dvgShowTable.Rows[0].Selected = false;
     }
     else if (cbTable.SelectedValue.ToString() == "PHIEUXUATHANG")
     {
         LoadData();
         dvgShowTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
         dt = dbPhieuXuat.LayBangPhieuXuat();
         dvgShowTable.DataSource       = dt;
         dvgShowTable.Rows[0].Selected = false;
     }
     else if (cbTable.SelectedValue.ToString() == "KHACHHANG")
     {
         LoadData();
         dvgShowTable.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;
         dt = dbKhachHang.LayBangKhachHang();
         dvgShowTable.DataSource       = dt;
         dvgShowTable.Rows[0].Selected = false;
     }
     else
     {
         MessageBox.Show("Chưa Chọn bảng ??");
     }
 }
Exemple #3
0
 void LoadMaHH(ComboBox cb)
 {
     cbMaHH.DataSource    = dbHangHoa.LayBangHangHoa();
     cbMaHH.ValueMember   = "MaHH";
     cbMaHH.DropDownStyle = ComboBoxStyle.DropDownList;
 }