Exemple #1
0
        protected void loadReport(string cachedReports)
        {
            DailyCostSheet rpt = new DailyCostSheet();
            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 dleCompanyId = Request.Cookies["dlecompanyId"].Value;

            adapter = new SqlDataAdapter("select * from vwDailyCostSheet where DLEcodeCompanyID IN (SELECT * FROM dbo.DLEIdToTable(@DLEcodeCompanyID)) AND (date_ between @startdate and @enddate)", connection);
            adapter.SelectCommand.Parameters.Add("@DLEcodeCompanyID", SqlDbType.VarChar).Value = dleCompanyId;
            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, "vwDailyCostSheet");
            rpt.SetDataSource(ds);

            adapter.Dispose();
            connection.Dispose();
            Session[cachedReports] = rpt;
            DailyCostSheetReport_All.ReportSource = rpt;
        }
        protected void DailyCostSheetReport_Load(object sender, EventArgs e)
        {
            string startdate    = Request.QueryString["st"].ToString();
            string enddate      = Request.QueryString["ed"].ToString();
            string reqno        = Request.QueryString["reqno"].ToString();
            string dleCompanyId = Request.Cookies["dlecompanyId"].Value;

            adapter = new SqlDataAdapter("select * from vwDailyCostSheet where DLEcodeCompanyID IN (SELECT * FROM dbo.DLEIdToTable(@DLEcodeCompanyID)) AND Reqno like '%' + @reqno + '%' and (date_ between @startdate and @enddate)", connection);
            adapter.SelectCommand.Parameters.Add("@DLEcodeCompanyID", SqlDbType.VarChar).Value = dleCompanyId;
            adapter.SelectCommand.Parameters.Add("@reqno", SqlDbType.VarChar).Value            = reqno;
            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, "vwDailyCostSheet");
            rpt.SetDataSource(ds);

            adapter.Dispose();
            connection.Dispose();

            DailyCostSheetReport.ReportSource = rpt;

            rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Context.Response, false, String.Empty);
        }