From 4bc7030c4cea5b3deed0c938ec388ae94e33c51c Mon Sep 17 00:00:00 2001 From: lu <99954486@qq.com> Date: 星期五, 25 十月 2024 09:42:36 +0800 Subject: [PATCH] 修改会页 --- DevApp/Gs.DevApp/DevFrm/Rpt/RptPreview.cs | 90 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 90 insertions(+), 0 deletions(-) diff --git a/DevApp/Gs.DevApp/DevFrm/Rpt/RptPreview.cs b/DevApp/Gs.DevApp/DevFrm/Rpt/RptPreview.cs new file mode 100644 index 0000000..a35b756 --- /dev/null +++ b/DevApp/Gs.DevApp/DevFrm/Rpt/RptPreview.cs @@ -0,0 +1,90 @@ +锘� +using Gs.DevApp.ToolBox; +using Newtonsoft.Json; +using System; +using System.Data; +using Newtonsoft.Json.Linq; +using System.IO; + +namespace Gs.DevApp.DevFrm.Rpt +{ + public partial class RptPreview : DevExpress.XtraEditors.XtraForm + { + private string _rptParameter; + public RptPreview(string rptParameter) + { + _rptParameter = rptParameter; + InitializeComponent(); + this.Text = _rptParameter + "鎶ヨ〃鏌ョ湅锛�"; + getRptData(); + } + + /// <summary> + /// 璇诲彇鎶ヨ〃鏁版嵁 + /// </summary> + private void getRptData() + { + var _obj = new + { + rptParameter = this._rptParameter, + }; + try + { + string strJson = UtilityHelper.HttpPost("", "Report/GetRptData", JsonConvert.SerializeObject(_obj)); + JObject _job = JObject.Parse(strJson); + string rtnCode = _job["rtnCode"].ToString(); + if (int.Parse(rtnCode) > 0) + { + //妯℃澘 + FastReport.Report report = new FastReport.Report(); + byte[] buffer = (byte[])_job["rtnData"]["reportTemplateData"]; + using (MemoryStream Stream = new MemoryStream(buffer)) + { + report.Load(Stream); + } + //涓昏〃 + JArray array = new JArray(); + foreach (var a in _job["rtnData"]["zb"]) + { + array.Add(a); + } + DataTable _zb = JsonConvert.DeserializeObject<DataTable>(array.ToString()); + _zb.TableName = "zb"; + //鏄庣粏琛�1 + JArray array1 = new JArray(); + foreach (var a in _job["rtnData"]["mx1"]) + { + array1.Add(a); + } + DataTable _mx1 = JsonConvert.DeserializeObject<DataTable>(array1.ToString()); + _mx1.TableName = "mx1"; + //鏄庣粏琛�2 + JArray array2 = new JArray(); + foreach (var a in _job["rtnData"]["mx2"]) + { + array1.Add(a); + } + DataTable _mx2 = JsonConvert.DeserializeObject<DataTable>(array2.ToString()); + _mx2.TableName = "mx2"; + //鍔犲埌鏁版嵁闆嗕腑 + DataSet ds = new DataSet(); + ds.Tables.Add(_zb); + ds.Tables.Add(_mx1); + ds.Tables.Add(_mx2); + report.RegisterData(ds); + report.Preview = previewControl1; + report.Prepare(); + report.ShowPrepared(); + } + else + { + ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _job["rtnMsg"].ToString()); + } + } + catch (Exception ex) + { + ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + } + } +} \ No newline at end of file -- Gitblit v1.9.3