Пример #1
0
        private void cboTenCc_TextChanged(object sender, EventArgs e)
        {
            if (cboTenCc.Text == "")
            {
                DanhSachThongKe();
                return;
            }

            cboLoaiSp.Text = "";

            int i   = 0;
            int Sum = 0;

            tk.TenCc = cboTenCc.Text;
            List <ThongKe> tklist = tkbll.ThongKePhieuNhapTheoNhaCungCap(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 cboNhaCc_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (cboNhaCc.Text == "")
                {
                    DanhSachThongKe();
                    return;
                }

                cboLoaiSp.Text = "";

                int i   = 0;
                int Sum = 0;
                tk.TenCc = cboNhaCc.Text;
                List <ThongKe> tklist = tkbll.ThongKePhieuNhapTheoNhaCungCap(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.TongSoLuongNhapTheoNhaCc(tk);
                List <ThongKe> tklist2 = tkbll.TongSoLuongConNhapTheoNhaCc(tk);
                List <ThongKe> tklist3 = tkbll.TinhThanhTienPhieuNhapTheoNhaCc(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 Nhà Cung Cấp !" + ex.Message);
            }
        }