示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (User.Identity.IsAuthenticated)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connection"]);
            SqlCommand    cmd = new SqlCommand("select * from user_details where Name='" + User.Identity.Name + "'", con);
            SqlDataReader dr;
            con.Open();
            dr = cmd.ExecuteReader();
            if (dr.Read())
            {
                company_id = Convert.ToInt32(dr["com_id"].ToString());
            }
            con.Close();
        }

        TextBox1.Text = Session["Name"].ToString();
        TextBox2.Text = company_id.ToString();
        ReportDocument rprt = new ReportDocument();

        rprt.Load(Server.MapPath("CrystalReport2.rpt"));

        DataSet3TableAdapters.DataTable1TableAdapter TA = new DataSet3TableAdapters.DataTable1TableAdapter();
        DataSet3.DataTable1DataTable TABLE = TA.GetData(TextBox1.Text, Convert.ToInt32(TextBox2.Text), Convert.ToInt32(TextBox2.Text));

        rprt.SetDataSource(TABLE.DefaultView);



        CrystalReportViewer1.ReportSource = rprt;
        CrystalReportViewer1.DataBind();
    }
        private void button1_Click(object sender, EventArgs e)
        {
            DataSet3TableAdapters.DataTable1TableAdapter adapter = new DataSet3TableAdapters.DataTable1TableAdapter();
            DataSet3.DataTable1DataTable table = new  DataSet3.DataTable1DataTable();
            adapter.FillBYCUSTO(table, toname.Text);

            ReportDataSource MyNewDatSource1 = new ReportDataSource("DataSet1", (DataTable)table);

            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(MyNewDatSource1);
            this.reportViewer1.LocalReport.Refresh();
            this.reportViewer1.RefreshReport();
        }