HasToggleGroupTreeButton = "False" HasZoomFactorList = "False"> cr: CrystalReportViewer>
asp: Button> asp: button> asp: button>
form> body> HTML> using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System .Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using CrystalDecisions.Shared; // TableLogOnInfo class using CrystalDecisions.CrystalReports.Engine; // ReportDocument class
Namespace Angushine.Web.Report {/// /// Customers' summary description. /// summary> public class Customers: System.Web.UI.Page {protected System.Web.UI.WebControls.Button btnEmployees; protected System.Web.UI.WebControls.Button btnProducts; protected System.Web.UI. WebControls.Button BTNCUSTOMERS; protected crystaldecisions.web.crystalReportviewer CrystalReportViewer1;
Private static reportDocument ORPT; Private Void Page_load (Object Sender, System.EventArgs E) {if (! ispostback) {
} Else {// If the report has been previewed once, the ReportSource needs to be // set on each postback. When the Preview Report button is first clicked, // it loads the report, binds it to the viewer, and puts the ReportDocument // object into a Session varable This code pulls that ReportDocument object // from Session and reassigns the viewer's ReportSource, for each postback if (oRpt = null!) {CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX;.. CrystalReportViewer1 .Reportsource = orpt;}}} #Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} /// /// Designer Supports the required method - Do not use the code editor to modify the // / this method. /// summary> private void InitializeComponent () {this.btnCustomers.Click = new System.EventHandler (this.btnCustomers_Click); this.btnEmployees.Click = new System.EventHandler (this.btnEmployees_Click); this.btnProducts .Click = new system.eventhandler (this.btnproducts_click; this.load = new system.eventhandler (this.page_load);
} #Endregion
Private Void BTNCUSTOMERS_CLICK (Object sender, system.eventargs e) {/ * * Pull mode, build RPT files, and web pages, where the page control does not need to specify the data source. * * / TableLogonInfo LogonInfo = New TableLogonInfo (); ORPT = New REPORTDocument ();
String path = this.server.mappath ("crreports / customers.rpt"); ORPT.LOAD (PATH); / * MS Server 2000 database, other modified changes * / logoninfo.connectioninfo.servername = "localhost"; logonInfo // Create a file between CryStalReportviewer .rpt file; .ConnectionInfo.UserID = "sa"; logOnInfo.ConnectionInfo.Password = "sa"; oRpt.Database.Tables [0] .ApplyLogOnInfo (logOnInfo); CrystalReportViewer1.ReportSource = oRpt Connection // The ReportDocument Object Will Need To Placed Into Session So That // on Each Postback, The Viewer's Reportsource Can Be Set To this Instance Session.Add ("Report", ORPT);
private void btnEmployees_Click (object sender, System.EventArgs e) {string strDB = System.Configuration.ConfigurationSettings.AppSettings [ "strDB"]; SqlConnection conn = new SqlConnection (strDB); SqlDataAdapter da = new SqlDataAdapter ( "Select * from Employees" , CRREPORTS.DATASET1 DS = new angushine.web.report.crreports.dataset1 (); crreports.employees myrpt = new angushine.web.report.crreports.employees (); da.fill (DS, "t") Myrpt.SetDataSource (DS.Tables ["T"]); myrpt.refresh (); this.crystalReportViewer1.reportsource = Myrpt; //myrpt.printtoprinter (1 ,true, 1, 1); this.crystalReportViewer1.DATABIND ( }
private void btnProducts_Click (object sender, System.EventArgs e) {// the data source is connected to Access oRpt = new ReportDocument (); string path = this.Server.MapPath ( "CrReports / Customer.rpt"); oRpt.Load (path CrystalReportViewer1.Reportsource = ORPT;}
Private Void ReportPrint1_submitclicked (Object Sender, System.EventArgs E) {//orpt.printtoprinter (1, False, 0,0);}