01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.Linq;
04.
using
System.Web;
05.
using
System.Web.UI;
06.
using
System.Web.UI.WebControls;
07.
using
Microsoft.VisualBasic;
08.
using
System.Collections;
09.
using
System.Data;
10.
using
System.Diagnostics;
11.
using
CrystalDecisions.CrystalReports.Engine;
12.
using
System.Data.SqlClient;
13.
using
System.Text;
14.
using
CrystalDecisions.Shared;
15.
16.
namespace
Helpdesk
17.
{
18.
public
partial
class
report_jobm : System.Web.UI.Page
19.
{
20.
oCenter oC =
new
oCenter();
21.
protected
void
Page_Load(
object
sender, EventArgs e)
22.
{
23.
ConfigureCrystalReports();
24.
}
25.
26.
private
ReportDocument rpt;
27.
28.
void
ConfigureCrystalReports()
29.
{
30.
31.
rpt =
new
ReportDocument();
32.
rpt.Load(Server.MapPath(
"report4.rpt"
));
33.
TableLogOnInfo crtableLogoninfo =
new
TableLogOnInfo();
34.
ConnectionInfo crConnectionInfo =
new
ConnectionInfo();
35.
Tables CrTables;
36.
37.
crConnectionInfo.ServerName =
"TOEY-PC"
;
38.
crConnectionInfo.DatabaseName =
"Helpdesk"
;
39.
crConnectionInfo.UserID =
"sa"
;
40.
crConnectionInfo.Password =
"password"
;
41.
CrTables = rpt.Database.Tables;
42.
43.
foreach
(CrystalDecisions.CrystalReports.Engine.Table CrTable
in
CrTables)
44.
{
45.
crtableLogoninfo = CrTable.LogOnInfo;
46.
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
47.
CrTable.ApplyLogOnInfo(crtableLogoninfo);
48.
}
49.
50.
rpt.SetParameterValue(
"startdate"
, Session[
"startdate"
].ToString());
51.
rpt.SetParameterValue(
"enddate"
, Session[
"enddate"
].ToString());
52.
this
.CrystalReportViewer1.ReportSource = rpt;
53.
CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX;
54.
Session[
"ReportSource1"
] = rpt;
55.
}
56.
57.
protected
override
void
OnUnload(EventArgs e)
58.
{
59.
base
.OnUnload(e);
60.
61.
try
62.
{
63.
if
(rpt !=
null
)
64.
{
65.
66.
rpt.Close();
67.
rpt.Dispose();
68.
GC.Collect();
69.
}
70.
71.
}
72.
catch
(Exception ex)
73.
{
74.
75.
}
76.
}
77.
78.
protected
void
rptCrystal_Unload(
object
sender, EventArgs e)
79.
{
80.
try
81.
{
82.
if
(rpt !=
null
)
83.
{
84.
rpt.Close();
85.
rpt.Dispose();
86.
GC.Collect();
87.
}
88.
89.
}
90.
catch
(Exception ex)
91.
{
92.
93.
}
94.
}
95.
96.
}
97.
}