private void cboLoaiSp_TextChanged(object sender, EventArgs e) { if (cboLoaiSp.Text == "") { HienThiThongKe(); return; } cboNhaSx.Text = ""; int i = 0; tk.TenLoai = cboLoaiSp.Text; List <ThongKe> tklist = tkbll.ThongKeDonDatHangTheoLoaiSp(tk); dgvThongKeDoDh.Rows.Clear(); foreach (ThongKe tks in tklist) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgvThongKeDoDh); row.Cells[0].Value = i + 1; row.Cells[1].Value = tks.MaSp; row.Cells[2].Value = tks.TenSp; row.Cells[3].Value = tks.TenLoai; row.Cells[4].Value = tks.TenSx; row.Cells[5].Value = tks.Sld; dgvThongKeDoDh.Rows.Add(row); ++i; Sum += i; } cboTongDodh.Text = i.ToString(); }
private void cboLoaiSp_TextChanged(object sender, EventArgs e) { try { if (cboLoaiSp.Text == "") { HienThiThongKe(); return; } cboNhaSx.Text = ""; int i = 0; tk.TenLoai = cboLoaiSp.Text; List <ThongKe> tklist = tkbll.ThongKeDonDatHangTheoLoaiSp(tk); dgvThongKeDonHang.Rows.Clear(); foreach (ThongKe tks in tklist) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgvThongKeDonHang); row.Cells[0].Value = i + 1; row.Cells[1].Value = tks.MaSp; row.Cells[2].Value = tks.TenSp; row.Cells[3].Value = tks.TenLoai; row.Cells[4].Value = tks.TenSx; row.Cells[5].Value = tks.Sld; dgvThongKeDonHang.Rows.Add(row); ++i; } cboTongDondh.Text = i.ToString(); cboTongSldh.DataSource = tkbll.TongSldhTheoLoaiSp(tk); } catch (Exception ex) { MessageBox.Show("Lỗi Loại Sản Phẩm!" + ex.Message); } }