private void cboLoaiSp_TextChanged(object sender, EventArgs e) { if (cboLoaiSp.Text == "") { DanhSachThongKe(); return; } cboTenCc.Text = ""; int i = 0; int Sum = 0; tk.TenLoai = cboLoaiSp.Text; List <ThongKe> tklist = tkbll.ThongKePhieuNhapLoaiSp(tk); dgvThongKePhieuNhap.Rows.Clear(); foreach (ThongKe tks in tklist) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgvThongKePhieuNhap); row.Cells[0].Value = i + 1; row.Cells[1].Value = tks.MaSp.ToString(); row.Cells[2].Value = tks.TenSp.ToString(); row.Cells[3].Value = tks.TenLoai.ToString(); row.Cells[4].Value = tks.TenSx.ToString(); row.Cells[5].Value = tks.Sld.ToString(); row.Cells[6].Value = tks.Sln.ToString(); row.Cells[7].Value = tks.Slcl.ToString(); row.Cells[8].Value = tks.DonGia.ToString(); row.Cells[9].Value = tks.ThanhTien.ToString(); dgvThongKePhieuNhap.Rows.Add(row); ++i; Sum += i; } txtTongPhieuNhap.Text = i.ToString(); }
private void cboLoaiSp_TextChanged(object sender, EventArgs e) { try { if (cboLoaiSp.Text == "") { DanhSachThongKe(); return; } cboNhaCc.Text = ""; int i = 0; int Sum = 0; tk.TenLoai = cboLoaiSp.Text; List <ThongKe> tklist = tkbll.ThongKePhieuNhapLoaiSp(tk); dgvThongKePhieuNhap.Rows.Clear(); foreach (ThongKe tks in tklist) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgvThongKePhieuNhap); row.Cells[0].Value = i + 1; row.Cells[1].Value = tks.MaSp.ToString(); row.Cells[2].Value = tks.TenSp.ToString(); row.Cells[3].Value = tks.TenLoai.ToString(); row.Cells[4].Value = tks.TenSx.ToString(); row.Cells[5].Value = tks.Sld.ToString(); row.Cells[6].Value = tks.Sln.ToString(); row.Cells[7].Value = tks.Slcl.ToString(); row.Cells[8].Value = tks.DonGia.ToString(); row.Cells[9].Value = tks.ThanhTien.ToString("00,00.##"); dgvThongKePhieuNhap.Rows.Add(row); ++i; Sum += i; } cboTongSoPhieu.Text = i.ToString(); List <ThongKe> tklist1 = tkbll.TongSoLuongNhapTheoLoaiSp(tk); List <ThongKe> tklist2 = tkbll.TongSoLuongConNhapTheoLoaiSp(tk); List <ThongKe> tklist3 = tkbll.TinhThanhTienPhieuNhapTheoLoaiSp(tk); foreach (ThongKe tks1 in tklist1) { cboTongSln.Text = tks1.Sln.ToString(); } foreach (ThongKe tks2 in tklist2) { cboTongSlcn.Text = tks2.Slcl.ToString(); } foreach (ThongKe tks3 in tklist3) { cboTongThanhTien.Text = tks3.ThanhTien.ToString("00,00.##"); } } catch (Exception ex) { MessageBox.Show("Lỗi Loại Sản Phẩm!" + ex.Message); } }