Пример #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("CrystalReport.rpt"));
        Sales_invoiceTableAdapters.DataTable1TableAdapter ta = new Sales_invoiceTableAdapters.DataTable1TableAdapter();
        Sales_invoice.DataTable1DataTable table = ta.GetData(Convert.ToInt32(TextBox1.Text), Convert.ToInt32(TextBox2.Text));
        rprt.SetDataSource(table.DefaultView);



        CrystalReportViewer1.ReportSource = rprt;
        CrystalReportViewer1.DataBind();
        // CrystalReportViewer1.SeparatePages = false;
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        TextBox1.Text = Session["Name"].ToString();
        ReportDocument rprt = new ReportDocument();

        rprt.Load(Server.MapPath("CrystalReport.rpt"));
        Sales_invoiceTableAdapters.DataTable1TableAdapter ta = new Sales_invoiceTableAdapters.DataTable1TableAdapter();
        Sales_invoice.DataTable1DataTable table = ta.GetData(TextBox1.Text);
        rprt.SetDataSource(table.DefaultView);
        rprt.SetDatabaseLogon("sa", "vertex123");


        CrystalReportViewer1.ReportSource = rprt;
        CrystalReportViewer1.DataBind();
    }