示例#1
0
        private void BaoCaoN_F_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();
            string        sql = @"Data Source=DESKTOP-3SFFPGN\HAUMTA;Initial Catalog=QuanLyKhoHang;Integrated Security=True";

            con.ConnectionString = sql;
            con.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "BCN";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@TENNV", TenNv));
            cmd.Parameters.Add(new SqlParameter("@TENSP", TenSp));
            cmd.Parameters.Add(new SqlParameter("@TENNCC", TenNcc_Kh));
            cmd.Parameters.Add(new SqlParameter("@TENKHO", TenKho));
            cmd.Parameters.Add(new SqlParameter("@NGAYNHAP", NgayNh_Xu));
            cmd.Parameters.Add(new SqlParameter("@GIA", Gia));
            cmd.Parameters.Add(new SqlParameter("@TUNGAY", TuNgay));
            cmd.Parameters.Add(new SqlParameter("@DENNGAY", DenNgay));
            cmd.Connection = con;
            cmd.ExecuteNonQuery();
            DataSet        ds  = new DataSet();
            SqlDataAdapter sda = new SqlDataAdapter(cmd);

            sda.Fill(ds);
            //ReportParameter tungay = new ReportParameter("Tungay", TuNgay);
            //ReportParameter denngay = new ReportParameter("Denngay", DenNgay);
            //ReportParameter tu = new ReportParameter("Tu", "Từ");
            //ReportParameter den = new ReportParameter("Den", "Đến");
            reportViewer1.ProcessingMode         = ProcessingMode.Local;
            reportViewer1.LocalReport.ReportPath = "BaoCaoNhap.rdlc";
            if (ds.Tables[0].Rows.Count > 0)
            {
                ReportDataSource rds = new ReportDataSource();
                rds.Name  = "BaoCaoNhap";
                rds.Value = ds.Tables[0];
                reportViewer1.LocalReport.DataSources.Clear();
                reportViewer1.LocalReport.DataSources.Add(rds);
                //rpv_baocao.LocalReport.SetParameters(new ReportParameter[] { tu });
                //rpv_baocao.LocalReport.SetParameters(new ReportParameter[] { den });
                //rpv_baocao.LocalReport.SetParameters(new ReportParameter[] { tungay });
                //rpv_baocao.LocalReport.SetParameters(new ReportParameter[] { denngay });
                reportViewer1.RefreshReport();
            }
            else
            {
                MessageBox.Show("Không Có Dữ Liệu!");
                Frm_BaoCaoN_F bcf = new Frm_BaoCaoN_F();
                bcf.Hide();
            }

            //this.reportViewer1.RefreshReport();
        }
示例#2
0
        private void buttonX4_Click(object sender, EventArgs e)
        {
            SelectQuery = "Select N.MAPN as [Mã Phiếu], KHO.TENKHO as [Kho], SP.TENSP as [Sản Phẩm], NCC.TENNHACC as [Nhà Cung Cấp], CTN.DONGIAN as [Đơn Giá], TONGTIEN=CTN.SOLUONG*DONGIAN, NV.TENNV as [Nhân Viên], N.NGAYNHAP as [Ngày Nhập] from PHIEUNHAPKHO N, CHITIETPHIEUNHAP CTN, SANPHAM SP, NHACUNGCAP NCC, NHANVIEN NV, KHOHANG KHO where N.MAPN = CTN.MAPN and CTN.MASP = SP.MASP and N.MANCC = NCC.MANCC and N.NVNHAP = NV.MANV and N.MAKHO = KHO.MAKHO  ";

            if (cbx_kho.Text != "")
            {
                FromQuery            = FromQuery + " And " + "KHO.TENKHO like N'%" + cbx_kho.Text + "%'";
                Frm_BaoCaoN_F.TenKho = cbx_kho.Text;
            }


            if (cbx_tensp.Text != "")
            {
                FromQuery = FromQuery + "And " + "SP.TENSP like N'%" + cbx_tensp.Text + "%'";
            }

            if (cbx_ncc.Text != "")
            {
                FromQuery = FromQuery + "And " + "NCC.TENNHACC like N'%" + cbx_ncc.Text + "%'";
            }

            if (cbx_giasp.Text != "")
            {
                FromQuery = FromQuery + "And " + "DONGIAN like N'%" + cbx_giasp.Text + "%'";
            }

            if (cbx_nv.Text != "")
            {
                FromQuery = FromQuery + "And " + "NV.TENNV like N'%" + cbx_nv.Text + "%'";
            }

            if (tbx_ngaynhap.Text != "")
            {
                FromQuery = FromQuery + "And " + "N.NGAYNHAP = Convert(Datetime,'" + tbx_ngaynhap.Text + "',103)";
            }

            if (tbx_tungay.Text != "" && tbx_denngay.Text != "")
            {
                FromQuery = FromQuery + "And " + "N.NGAYNHAP > Convert(Datetime,'" + tbx_tungay.Text + "',103) And N.NGAYNHAP < Convert(Datetime,'" + tbx_denngay.Text + "',103)";
            }

            Query = SelectQuery + FromQuery;
            if ((cbx_kho.Text != "" || cbx_ncc.Text != "" || cbx_giasp.Text != "" || cbx_nv.Text != "" || cbx_tensp.Text != "" || tbx_ngaynhap.Text != "") || (tbx_tungay.Text != "" && tbx_denngay.Text != ""))
            {
                dgv_thongkenhap.DataSource = acc.Select_Data(Query);
                FromQuery = null;

                btn_xembc.Enabled = true;
                ClearN();
            }
            else
            {
                Frm_BaoCaoN_F.TenKho    = cbx_kho.Text;
                Frm_BaoCaoN_F.TenNcc_Kh = cbx_ncc.Text;
                Frm_BaoCaoN_F.TenNv     = cbx_nv.Text;
                Frm_BaoCaoN_F.TenSp     = cbx_tensp.Text;
                Frm_BaoCaoN_F.TuNgay    = tbx_tungay.Text;
                Frm_BaoCaoN_F.NgayNh_Xu = tbx_ngaynhap.Text;
                Frm_BaoCaoN_F.DenNgay   = tbx_denngay.Text;
                Frm_BaoCaoN_F.Gia       = cbx_giasp.Text;
                Frm_BaoCaoN_F baocaof = new Frm_BaoCaoN_F();
                baocaof.ShowDialog();
            }
        }