WebReportView.aspx.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using Stimulsoft.Report;
  3. namespace PMS.WebUI.WebForms
  4. {
  5. public partial class WebReportView : System.Web.UI.Page
  6. {
  7. protected void Page_Load(object sender, EventArgs e)
  8. {
  9. StiConfig.Services.Add(new Stimulsoft.Report.Dictionary.StiOracleODPAdapterService()); //注册oracleOpd
  10. base.OnInit(e);
  11. GetReport();
  12. }
  13. protected void StiWebViewer1_ReportDesign(object sender, Stimulsoft.Report.Web.StiReportDesignEventArgs e)
  14. {
  15. }
  16. //售后渠道统计
  17. private void GetReport()
  18. {
  19. StiReport report = new StiReport();
  20. report.RequestParameters = true;
  21. var reportName = Request.QueryString["reportName"];
  22. if (!string.IsNullOrEmpty(reportName))
  23. {
  24. reportName += ".mrt";
  25. report.Load(base.Server.MapPath("/Reports/" + reportName + ""));
  26. //if (report.Dictionary.Databases.Count > 0)
  27. //{//修改数据源
  28. //((StiSqlDatabase)report.Dictionary.Databases[0]).ConnectionString = "Data Source=192.168.0.106/orcl;Persist Security Info=True;User ID=zlchs;Password=zlchs2013"; //重新定义数据库连接
  29. //}
  30. //参数值
  31. //report.Dictionary.Variables["xmid"].Value = "c321e858-c4b9-4492-972c-ea1d81a39ef3";
  32. var list = report.Dictionary.Variables.Items;
  33. foreach(var item in list)
  34. {
  35. switch (item.Name)
  36. {
  37. case "xmid": report.Dictionary.Variables["xmid"].Value = Request.QueryString["xmid"]; break;
  38. case "qdid": report.Dictionary.Variables["qdid"].Value = Request.QueryString["channelid"]; break;
  39. case "stime": report.Dictionary.Variables["stime"].Value = Request.QueryString["stime"]; break;
  40. case "etime": report.Dictionary.Variables["etime"].Value = Request.QueryString["etime"]; break;
  41. case "person": report.Dictionary.Variables["person"].Value = Request.QueryString["person"]; break;
  42. case "jjbb": report.Dictionary.Variables["jjbb"].Value = Request.QueryString["jjbb"]; break;
  43. case "dd": report.Dictionary.Variables["dd"].Value = Request.QueryString["dd"]; break;
  44. }
  45. //if(item.Name=="xmid")
  46. //{
  47. // report.Dictionary.Variables["xmid"].Value = Request.QueryString["xmid"]; /*"c321e858-c4b9-4492-972c-ea1d81a39ef3";*/
  48. //}
  49. }
  50. report.ReportName = "统计报表";
  51. report.Compile();
  52. report.Render(false);
  53. StiWebViewer1.Report = report;
  54. StiWebViewer1.DataBind();
  55. }
  56. }
  57. }
  58. }