From d35bb711f8d3d267b44b4a80c20e31dabf309ae7 Mon Sep 17 00:00:00 2001 From: lu <99954486@qq.com> Date: 星期二, 14 一月 2025 08:17:18 +0800 Subject: [PATCH] 其它入库 --- DevApp/Gs.DevApp/DevFrm/Rpt/RptPreview.cs | 89 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 89 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..dfad8ad --- /dev/null +++ b/DevApp/Gs.DevApp/DevFrm/Rpt/RptPreview.cs @@ -0,0 +1,89 @@ +锘縰sing System; +using System.Data; +using System.IO; +using DevExpress.Utils.VisualEffects; +using DevExpress.XtraEditors; +using FastReport; +using Gs.DevApp.ToolBox; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Gs.DevApp.DevFrm.Rpt +{ + public partial class RptPreview : XtraForm + { + private readonly string _rptParameter; + private readonly string _rptGuid; + public RptPreview(string strGuid, string rptParameter) + { + _rptParameter = rptParameter; + _rptGuid = strGuid; + InitializeComponent(); + Text = _rptParameter + "鎶ヨ〃鏌ョ湅锛�"; + getRptData(); + } + + /// <summary> + /// 璇诲彇鎶ヨ〃鏁版嵁 + /// </summary> + private void getRptData() + { + var _obj = new + { + rptParameter = _rptParameter, + guid = _rptGuid, + isDesign = 0 + }; + try + { + var strJson = UtilityHelper.HttpPost("", "Report/GetRptData", + JsonConvert.SerializeObject(_obj)); + var _job = JObject.Parse(strJson); + var rtnCode = _job["rtnCode"].ToString(); + if (int.Parse(rtnCode) > 0) + { + //妯℃澘 + var report = new Report(); + var buffer = (byte[])_job["rtnData"]["reportTemplateData"]; + using (var Stream = new MemoryStream(buffer)) + { + report.Load(Stream); + } + //涓昏〃 + var array = new JArray(); + foreach (var a in _job["rtnData"]["zb"]) array.Add(a); + var _zb =JsonConvert.DeserializeObject<DataTable>(array.ToString()); + _zb.TableName = "zb"; + //鏄庣粏琛�1 + var array1 = new JArray(); + foreach (var a in _job["rtnData"]["mx1"]) array1.Add(a); + var _mx1 =JsonConvert.DeserializeObject<DataTable>( array1.ToString()); + _mx1.TableName = "mx1"; + //鏄庣粏琛�2 + var array2 = new JArray(); + foreach (var a in _job["rtnData"]["mx2"]) array2.Add(a); + var _mx2 =JsonConvert.DeserializeObject<DataTable>(array2.ToString()); + _mx2.TableName = "mx2"; + //鍔犲埌鏁版嵁闆嗕腑 + var 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 + { + MsgHelper.Warning("鎻愮ず锛�" + _job["rtnMsg"]); + this.Close(); + } + } + catch (Exception ex) + { + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + } + } +} \ No newline at end of file -- Gitblit v1.9.3