public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rptDailyActiveWorkerRecord rpt = new rptDailyActiveWorkerRecord(); rpt.Site = this.Site; return(rpt); }
protected void loadReport(string cachedReports) { //int rptCacheTimeout = Convert.ToInt32(ConfigurationManager.AppSettings.Get("rptCacheTimeout").ToString()); rptDailyActiveWorkerRecord rpt = new rptDailyActiveWorkerRecord(); string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection connection = new SqlConnection(connectionString); SqlDataAdapter adapter = new SqlDataAdapter(); DataSet ds = new DataSet(); string startdate = Request.QueryString["st"].ToString(); string enddate = Request.QueryString["ed"].ToString(); string workerId = Request.QueryString["workerid"].ToString(); ParameterValues parameters = new ParameterValues(); ParameterDiscreteValue sdate = new ParameterDiscreteValue(); ParameterDiscreteValue edate = new ParameterDiscreteValue(); ParameterDiscreteValue worker = new ParameterDiscreteValue(); sdate.Value = startdate; edate.Value = enddate; worker.Value = workerId; adapter = new SqlDataAdapter("select * from vwDailyActiveWorkerRecord where (date_ between @startdate and @enddate) and workerid = @workerId", connection); adapter.SelectCommand.Parameters.Add("@workerId", SqlDbType.VarChar).Value = workerId; adapter.SelectCommand.Parameters.Add("@startdate", SqlDbType.DateTime).Value = startdate; adapter.SelectCommand.Parameters.Add("@enddate", SqlDbType.DateTime).Value = enddate; if (connection.State == ConnectionState.Closed) { connection.Open(); } adapter.Fill(ds, "vwDailyActiveWorkerRecord"); rpt.SetDataSource(ds); parameters.Add(sdate); rpt.DataDefinition.ParameterFields["Startdate"].ApplyCurrentValues(parameters); parameters.Add(edate); rpt.DataDefinition.ParameterFields["Enddate"].ApplyCurrentValues(parameters); parameters.Add(worker); rpt.DataDefinition.ParameterFields["WorkerID"].ApplyCurrentValues(parameters); adapter.Dispose(); connection.Dispose(); //Cache.Insert(cachedReports, rpt, null, DateTime.MaxValue, TimeSpan.FromMinutes(rptCacheTimeout)); Session[cachedReports] = rpt; DailyActiveWorkerRecordReport.ReportSource = rpt; }