diff --git a/插件库/Lskj.PubAccraditation/FrmAccraditation.cs b/插件库/Lskj.PubAccraditation/FrmAccraditation.cs index 5847466..b951e2f 100644 --- a/插件库/Lskj.PubAccraditation/FrmAccraditation.cs +++ b/插件库/Lskj.PubAccraditation/FrmAccraditation.cs @@ -34,6 +34,7 @@ using DevExpress.Utils; using DevExpress.Data; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using System.IO; namespace Lskj.PubAccraditation { @@ -170,6 +171,22 @@ namespace Lskj.PubAccraditation /// 模块对应的权限表信息 /// public DataTable AuthorityTable; + /// + /// 打印完成后添加数据用到的参数: 表名,列前缀,主键字段,主键值,模块编号,主打印Sql + /// + private List _printSaveParams; + /// + /// 主打印Sql + /// + private string _mainPrintSql; + /// + /// 打印主sql中关联打印次数返回条件 + /// + private string _printModeCond; + /// + /// 是否直接打印 + /// + private bool _isExcPrint; #endregion /// @@ -1069,7 +1086,7 @@ namespace Lskj.PubAccraditation this.SetBillControl(this.AuditModelObj.BillModifyFields, this.AuditModelObj.RequiredFields); this.InitPrint(); - + this.GetPrintOtherParam(); //加载分配 this.dbpFP.Click += new System.EventHandler(this.OnBtnFPOldClick); BarButtonItem itemFPBatch = new BarButtonItem(); @@ -1590,7 +1607,7 @@ namespace Lskj.PubAccraditation 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); @@ -1600,6 +1617,60 @@ namespace Lskj.PubAccraditation #endregion #region 打印 + + + /// + /// 说明:打印完成需要参数 + /// 创建人:龚宇超 + /// 创建日期:2018-07-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected void GetPrintOtherParam() + { + Dictionary dataCaches = SysModel != null ? SysModel.DataCaches : null; + //取得打印完成后的参数 + if (!string.IsNullOrEmpty(this.BillModelObj.PrintSql) && this.BillModelObj.PrintSql.Contains("<<")) + { + string[] strs = this.BillModelObj.PrintSql.Split(new[] { ">>" }, 2, StringSplitOptions.None); + _mainPrintSql = strs[1]; + _printModeCond = strs[0].Replace("<<", ""); + } + if (!string.IsNullOrEmpty(_printModeCond) && _printModeCond.IndexOf(';') > 0) + { + string[] str = _printModeCond.Split(';'); + if (!dataCaches.GetValue(this, "PrintOtherSystemRow", out DataRow item)) + { + item = AttachImpl.GetSystemModule(str[0]); + } + if (item == null) return; + 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; + } + + } + } + /// /// 说明:打印事件 /// 创建人:龚宇超 @@ -1617,6 +1688,14 @@ namespace Lskj.PubAccraditation { string billNo = txt_billDocumentId.EditText; string printPath = PubUtil.PrintFileAbsolutelyPath; + string printFile = e.Item.Tag + ""; + + if (!File.Exists(printPath)) + { + MessageUtil.Show(ResourceKeys.NotFoundPrintFile); + return; + } + if (!string.IsNullOrEmpty(billNo)) { DataRow masterRow = BillImpl.GetDataRowResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.MasterSql, billNo)); @@ -1634,7 +1713,36 @@ namespace Lskj.PubAccraditation string tmpSql = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModelObj.PrintSql); string tmpSql1 = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModelObj.PrintSql1); string tmpSql2 = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModelObj.PrintSql2); - DelphiHelper.LoadDelphiDll(printPath, printPath, e.Item.Tag + "", tmpSql, tmpSql1, this.BillModelObj.PrintFileType, tmpSql2); + + + + if (printFile.Contains(PrintUtil.TemplateFlag)) + { + //主Sql + string mainSql = string.Empty; + List tmpSqls = new List(); + if (_printSaveParams != null && _printSaveParams.Count > 0) + { + _printSaveParams[5] = mainSql = ReplaceHelper.ReplaceRowParam(masterRow, _mainPrintSql); + _printSaveParams[3] = masterRow.Table.Columns.Contains(_printSaveParams[2] + "") ? masterRow[_printSaveParams[2]] + "" : masterRow[BillModelObj.PrimaryKey] + ""; + tmpSqls.Add(mainSql); + tmpSqls.Add(tmpSql1); + tmpSqls.AddRange(tmpSql2.Split(';').ToList()); + } + else + { + if (!string.IsNullOrWhiteSpace(tmpSql)) tmpSqls.Add(tmpSql); + if (!string.IsNullOrWhiteSpace(tmpSql1)) tmpSqls.Add(tmpSql1); + if (!string.IsNullOrWhiteSpace(tmpSql2)) tmpSqls.AddRange(tmpSql2.Split(';').ToList()); + } + PrintUtil.OnAfterPrint -= new EventHandler(OnReportPrintAfter); + PrintUtil.OnAfterPrint += new EventHandler(OnReportPrintAfter); + PrintUtil.FastReportPrint(tmpSqls, printFile, _isExcPrint); + } + else + { + DelphiHelper.LoadDelphiDll(printPath, printPath, printFile, tmpSql, tmpSql1, this.BillModelObj.PrintFileType, tmpSql2); + } } } catch (Exception ex) @@ -1643,6 +1751,28 @@ namespace Lskj.PubAccraditation MessageUtil.Show(Message, ex.Message); } } + + + /// + /// 说明:打印完成后回调 + /// 创建人:龚宇超 + /// 创建日期:2018-07-05 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The e. + private void OnReportPrintAfter(object sender, EventArgs e) + { + //打印完成后添加数据库 + if (_printSaveParams != null && _printSaveParams.Count > 0) + { + int result = BaseModuleImpl.SavePrintRecord(_printSaveParams[0], _printSaveParams[1], _printSaveParams[2], _printSaveParams[3], _printSaveParams[4]); + } + + } #endregion #region 绘制水印 @@ -1689,7 +1819,7 @@ namespace Lskj.PubAccraditation { e.Graphics.DrawRectangle(pen, new Rectangle(-45, -19, 90, 32)); } - + } e.Graphics.ResetTransform(); if (!string.IsNullOrEmpty(this._waterMark.Print)) @@ -1712,7 +1842,7 @@ namespace Lskj.PubAccraditation { e.Graphics.DrawRectangle(pen, new Rectangle(-60, -19, 120, 32)); } - + } e.Graphics.ResetTransform(); if (!string.IsNullOrEmpty(this._waterMark.Collect)) @@ -1735,7 +1865,7 @@ namespace Lskj.PubAccraditation { e.Graphics.DrawRectangle(pen, new Rectangle(-45, -19, 90, 32)); } - + } } catch (Exception ex) @@ -4367,30 +4497,4 @@ namespace Lskj.PubAccraditation /// /// public void SaveAdditionalModules() - { - try - { - foreach (XtraTabPage tabPage in this.tab_basicInfo.TabControlObj.TabPages) - { - GridDetailModel model = this.tab_basicInfo.GetGridDetailModel(tabPage); - - Object moduleObject = tabPage.Controls.Cast().FirstOrDefault(); - if (moduleObject is ModuleGridEx) - { - ModuleGridEx moduleGridEx = moduleObject as ModuleGridEx; - if (moduleGridEx.GridControlObj.IsDataNotSaved() && moduleGridEx.BtnSave.Visible && moduleGridEx.BtnSave.Enabled) - { - moduleGridEx.BtnSave.PerformClick(); - } - } - } - } - catch (Exception ex) - { - string Message = ErrorMessage.PromptErrorMessage(ex); - MessageUtil.Show(Message, ex.Message); - } - } - - } -} + { \ No newline at end of file