private void btnFilter_Click(object sender, EventArgs e) { int i = 0; tk.DateOne = DateTime.Parse(dtmTuNgay.Value.ToShortDateString()); tk.DateTwo = DateTime.Parse(dtmDenNgay.Value.ToShortDateString()); List <ThongKe> tklist = tkbll.ThongKePhieuNhapTheoNgayThang(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; } txtTongPhieuNhap.Text = i.ToString(); }
private void btnFilter_Click(object sender, EventArgs e) { try { int i = 0; tk.DateOne = DateTime.Parse(dtmTuNgay.Value.ToShortDateString()); tk.DateTwo = DateTime.Parse(dtmDenNgay.Value.ToShortDateString()); List <ThongKe> tklist = tkbll.ThongKePhieuNhapTheoNgayThang(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; } cboTongSoPhieu.Text = i.ToString(); List <ThongKe> tklist1 = tkbll.TongSoLuongNhapTheoNgayNhap(tk); List <ThongKe> tklist2 = tkbll.TongSoLuongConNhapTheoNgayNhap(tk); List <ThongKe> tklist3 = tkbll.TinhThanhTienPhieuNhapTheoNgayNhap(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 Filter!" + ex.Message); } }