From 3a2ead1b8a6f048dd689199018ac5cefed76ae4f Mon Sep 17 00:00:00 2001 From: cyf Date: Mon, 11 May 2026 02:25:38 +0000 Subject: [PATCH] SVN r1174 SVN-Revision: r1174 --- .../FrmBaseAccraditation.cs | 135 +++++++++++++++++- 1 file changed, 131 insertions(+), 4 deletions(-) diff --git a/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.cs b/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.cs index 83e9445..39ab89e 100644 --- a/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.cs +++ b/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.cs @@ -33,6 +33,7 @@ using System.Text.RegularExpressions; using Lskj.Core; using System.Diagnostics; using System.Threading.Tasks; +using System.IO; namespace Lskj.BaseAccraditation { @@ -146,7 +147,22 @@ namespace Lskj.BaseAccraditation /// 是否有明细必填 /// public bool DetailsRequired = false; - + /// + /// 打印完成后添加数据用到的参数: 表名,列前缀,主键字段,主键值,模块编号,主打印Sql + /// + private List _printSaveParams; + /// + /// 主打印Sql + /// + private string _mainPrintSql; + /// + /// 打印主sql中关联打印次数返回条件 + /// + private string _printModeCond; + /// + /// 是否直接打印 + /// + private bool _isExcPrint; #endregion @@ -246,7 +262,7 @@ namespace Lskj.BaseAccraditation this.InitializeControl(); this.InitSpliterPosition(); this.InitPrint(); - + this.GetPrintOtherParam(); if (this.ModuleModelObj.DisplayScroll) { this.pl_main.AutoScroll = true; @@ -547,7 +563,7 @@ namespace Lskj.BaseAccraditation if (!string.IsNullOrWhiteSpace(fileName)) { BarButtonItem itemPrint = new BarButtonItem(); - itemPrint.Caption = fileName.Replace(".rmf", ""); + itemPrint.Caption = fileName.Replace(".rmf", "").Replace(".frx", ""); itemPrint.Tag = files[i]; itemPrint.ItemClick += new ItemClickEventHandler(itemPrint_ItemClick); pMprint.AddItem(itemPrint); @@ -1644,6 +1660,56 @@ namespace Lskj.BaseAccraditation } #endregion #region 打印 + + + + + /// + /// 说明:打印完成需要参数 + /// 创建人:龚宇超 + /// 创建日期:2018-07-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void GetPrintOtherParam() + { + //取得打印完成后的参数 + if (this.ModuleModelObj.PrintSql.Contains("<<")) + { + string[] strs = this.ModuleModelObj.PrintSql.Split(new[] { ">>" }, 2, StringSplitOptions.None); + _mainPrintSql = strs[1]; + _printModeCond = strs[0].Replace("<<", ""); + } + if (!string.IsNullOrEmpty(_printModeCond) && _printModeCond.IndexOf(';') > 0) + { + string[] str = _printModeCond.Split(';'); + DataRow item = AttachImpl.GetSystemModule(str[0]); + string tableName = item["TableName"] + ""; + string modetype = item["modType"] + ""; + string comprefix = BaseImpl.GetColumnPrefix(tableName); + string primaryKey = modetype == "1" ? BaseImpl.GetBasePrimaryKey(str[0]) : comprefix + "billdocument_id"; + //表名,列前缀,主键字段,主键值,模块编号,主打印Sql + _printSaveParams = new List() { tableName, comprefix, primaryKey, str[1], str[0], _mainPrintSql }; + + //判断是否直接打印 modetype 区别单据和基础档案模块 + switch (modetype) + { + case "1": + ModuleModel mode = new ModuleModel(MainImpl.GetSystemdllTab(str[0])); + if (mode != null) _isExcPrint = mode.PrintType == 3; + break; + case "2": + BaseAccraditationModel model = new BaseAccraditationModel(BillAuditImpl.GetPubAuditProperty(str[0])); + if (model != null) _isExcPrint = model.BillPrintType == 3; + break; + } + } + } + + + /// /// 说明:打印事件 /// 创建人:龚宇超 @@ -1659,8 +1725,14 @@ namespace Lskj.BaseAccraditation { try { + string printFile = e.Item.Tag + ""; this._flowRowData = BaseAuditImpl.GetCurrentFlowRowData(this.ModuleModelObj.MenuTable, this.ModuleModelObj.ParmaryKey, this.SysModel.PrimaryValue); string printPath = PubUtil.PrintFileAbsolutelyPath; + if (!File.Exists(printPath)) + { + MessageUtil.Show(ResourceKeys.NotFoundPrintFile); + return; + } if (_flowRowData == null) { MessageUtil.Show(ResourceKeys.DataNotFount); @@ -1675,8 +1747,63 @@ namespace Lskj.BaseAccraditation string tmpSql = ReplaceHelper.ReplaceRowParam(_flowRowData, this.ModuleModelObj.PrintSql); string tmpSql1 = ReplaceHelper.ReplaceRowParam(_flowRowData, this.ModuleModelObj.PrintSql1); string tmpSql2 = ReplaceHelper.ReplaceRowParam(_flowRowData, this.ModuleModelObj.PrintSql2); - DelphiHelper.LoadDelphiDll(printPath, printPath, e.Item.Tag + "", tmpSql, tmpSql1, this.ModuleModelObj.PrintType, tmpSql2); + + + + //主Sql + string mainSql = string.Empty; + List tmpSqls = new List(); + if (_printSaveParams != null && _printSaveParams.Count > 0) + { + _printSaveParams[5] = mainSql = ReplaceHelper.ReplaceRowParam(_flowRowData, _mainPrintSql); + _printSaveParams[3] = _flowRowData[_printSaveParams[2]] + ""; + tmpSqls.Add(mainSql); + tmpSqls.Add(tmpSql1); + tmpSqls.AddRange(tmpSql2.Split(';').ToList()); + } + if (printFile.Contains(PrintUtil.TemplateFlag)) + { + PrintUtil.OnAfterPrint -= new EventHandler(OnReportPrintAfter); + PrintUtil.OnAfterPrint += new EventHandler(OnReportPrintAfter); + PrintUtil.FastReportPrint(tmpSqls, printFile, _isExcPrint); + } + else + { + DelphiHelper.LoadDelphiDll(printPath, printPath, printFile, tmpSql, tmpSql1, this.ModuleModelObj.PrintType, tmpSql2); + } + + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + + } + + + + /// + /// 说明:打印完成后回调 + /// 创建人:龚宇超 + /// 创建日期:2018-07-05 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The e. + protected void OnReportPrintAfter(object sender, EventArgs e) + { + try + { + if (_printSaveParams != null && _printSaveParams.Count > 0) + { + //打印完成后添加数据库 + int result = BaseModuleImpl.SavePrintRecord(_printSaveParams[0], _printSaveParams[1], _printSaveParams[2], _printSaveParams[3], _printSaveParams[4]); + } } catch (Exception ex) {