Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a CR that prints out fine. I want to have another report to print out that is already setup. When the user enters their data and clicks submit. The data is saved and the user can print out the report. The report will have the data that the user submitted. I also want another report to print out showing the user different data in different departments when they click on print. Can this be done? Here is my code for one report to be printed.

C#
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Web;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Windows.Forms;
using CrystalDecisions.ReportSource;
using CrystalDecisions.ReportAppServer;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml.Linq;
using System.Web.SessionState;

namespace SACSCOCLogin1._1
{
    public partial class ReportFormFTE : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
            con.Open();
            TextBoxuser_ID.Text = Session["user_id"].ToString();
            CrystalReportViewer1.Visible = true;

            ReportDocument CrystalReport = new ReportDocument();
            ParameterField paramField = new ParameterField();
            ParameterFields paramFields = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();

            paramField.Name = "user_id";
            paramField.CurrentValues.Clear();
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = TextBoxINST_ID.Text;
            paramFields.Add(paramField);
            CrystalReportViewer1.ParameterFieldInfo = paramFields;

            CrystalReport.Load(Server.MapPath("FormFTEReport.rpt"));
            string sessiontype = TextBoxINST_ID.Text;
            CrystalReport.SetParameterValue("inst_id", TextBoxuser_ID.Text);

            string sessionid = TextBoxuser_ID.Text;
            CrystalReport.SetParameterValue("user_id", TextBoxuser_ID.Text);
            CrystalReportViewer1.ReportSource = CrystalReport;
            con.Close();
        }
    }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900