// 查看报表 private void cmdQuery_ServerClick(object sender, EventArgs e) { ArrayList listInput = new ArrayList(); string strMess = string.Empty; // 遍历每个输入项 for (int i = 0; i < this.tbInput.Rows.Count; i++) { for (int n = 0; n < this.tbInput.Rows[i].Cells.Count; n++) { for (int x = 0; x < this.tbInput.Rows[i].Cells[n].Controls.Count; x++) { Control ctl = this.tbInput.Rows[i].Cells[n].Controls[x]; string strType = "", strName = "", strValue = ""; decimal dSqlSeq = 0; bool bIsInputControl = false; if (ctl is WebControl || ctl is System.Web.UI.UserControl) { if (ctl is WebControl && ((WebControl)ctl).Attributes["IsReportViewerInput"] == "1") { bIsInputControl = true; WebControl wcontrol = (WebControl)ctl; strType = wcontrol.Attributes["InputType"]; strName = wcontrol.Attributes["InputName"]; dSqlSeq = decimal.Parse(wcontrol.Attributes["SqlFilterSequence"]); } else if (ctl is System.Web.UI.UserControl && ((System.Web.UI.UserControl)ctl).Attributes["IsReportViewerInput"] == "1") { bIsInputControl = true; System.Web.UI.UserControl wcontrol = (System.Web.UI.UserControl)ctl; strType = wcontrol.Attributes["InputType"]; strName = wcontrol.Attributes["InputName"]; dSqlSeq = decimal.Parse(wcontrol.Attributes["SqlFilterSequence"]); } } if (bIsInputControl == true) { if (ctl is TextBox) { strValue = ((TextBox)ctl).Text.Trim().ToUpper(); } else if (ctl is CheckBox) { strValue = FormatHelper.BooleanToString(((CheckBox)ctl).Checked); } else if (ctl is DropDownList) { strValue = ((DropDownList)ctl).SelectedValue; } else if (ctl is UserControl.eMESDate) { strValue = FormatHelper.TODateInt(((UserControl.eMESDate)ctl).Text).ToString(); } else if (ctl is BenQGuru.eMES.Web.SelectQuery.SelectableTextBox) { strValue = ((BenQGuru.eMES.Web.SelectQuery.SelectableTextBox)ctl).Text; } RptViewUserSubscription subs = new RptViewUserSubscription(); subs.InputType = strType; subs.InputName = strName; //Add 2008/11/04 if (string.IsNullOrEmpty(strValue) || (ctl is UserControl.eMESDate && strValue == "0")) { if (rptFacade == null) { rptFacade = new ReportViewFacade(this.DataProvider); } RptViewFilterUI[] objUIs = rptFacade.GetRptViewFilterUIByReportIdAndSeq(this.ReportID, strName, dSqlSeq); if (objUIs != null && objUIs.Length > 0) { foreach (RptViewFilterUI objUI in objUIs) { if (objUI.CheckExist == "Y") { //添加异常 //throw new Exception( strName + "$ReportDesign_NOT_AllowNull"); //string alertInfo = // string.Format("<script language=javascript>alert('{0}');</script>",strName + " " +this.languageComponent1.GetString("$ReportDesign_NOT_AllowNull")); //if (!this.ClientScript.IsClientScriptBlockRegistered("Message")) //{ // this.ClientScript.RegisterClientScriptBlock(typeof(string), "Message", alertInfo); //} //return; if (string.IsNullOrEmpty(strMess)) { if (rptFacade == null) { rptFacade = new ReportViewFacade(this.DataProvider); } RptViewGridFilter objFilter = rptFacade.GetRptViewGridFiltersByReportIdAndName(this.ReportID, strName, dSqlSeq); if (objFilter != null) { strMess = objFilter.Description; } else { strMess = strName; } } else { if (rptFacade == null) { rptFacade = new ReportViewFacade(this.DataProvider); } RptViewGridFilter objFilter = rptFacade.GetRptViewGridFiltersByReportIdAndName(this.ReportID, strName, dSqlSeq); if (objFilter != null) { strMess = strMess + "," + objFilter.Description; } else { strMess = strMess + "," + strName; } } } } } } //Add End subs.InputValue = strValue; subs.SqlFilterSequence = dSqlSeq; listInput.Add(subs); } /* * if (ctl is TextBox) * { * if (((TextBox)ctl).Attributes["IsReportViewerInput"] == "1") * { * TextBox txt = (TextBox)ctl; * string strType = txt.Attributes["InputType"]; * string strName = txt.Attributes["InputName"]; * string strValue = txt.Text.Trim().ToUpper(); * decimal dSqlSeq = decimal.Parse(txt.Attributes["SqlFilterSequence"]); * RptViewUserSubscription subs = new RptViewUserSubscription(); * subs.InputType = strType; * subs.InputName = strName; * subs.InputValue = strValue; * subs.SqlFilterSequence = dSqlSeq; * listInput.Add(subs); * } * } */ } } } //查询所有的输入项,一次性报错 if (strMess != null && strMess.Length > 0) { string alertInfo = string.Format("<script language=javascript>alert('{0}');</script>", strMess + " " + this.languageComponent1.GetString("$ReportDesign_NOT_AllowNull")); //if (!this.ClientScript.IsClientScriptBlockRegistered("Message")) //{ // this.ClientScript.RegisterClientScriptBlock(typeof(string), "Message", alertInfo); ScriptManager.RegisterClientScriptBlock(this, GetType(), "Message", alertInfo, false); //} return; } // 执行查询 RptViewUserSubscription[] viewerInput = new RptViewUserSubscription[listInput.Count]; listInput.CopyTo(viewerInput); if (rptFacade == null) { rptFacade = new ReportViewFacade(this.DataProvider); } DataSet dsSource = rptFacade.ExecuteDataSetFromSource(this.ReportID, viewerInput, Server.MapPath("").ToString().Substring(0, Server.MapPath("").ToString().LastIndexOf("\\"))); this.txtDataCount.Text = dsSource.Tables[0].Rows.Count.ToString(); // 绑定报表 DisplayReportHelper rptHelper = new DisplayReportHelper(); rptHelper.BindReportViewer(rptFacade, designMain, this.ReportViewer1, dsSource, viewerInput); this.ReportViewer1.DataBind(); string[] values = new string[viewerInput.Length]; for (int i = 0; i < viewerInput.Length; i++) { values[i] = ((RptViewUserSubscription)viewerInput[i]).InputValue; } //导出报表数据 BenQGuru.eMES.DataExp.BaseEngine.ExpData(designMain.ReportName, dsSource.Tables[0], values); }