/*********************** * 说明:基础审批模块 * 创建人:龚宇超 * 创建日期:2017-12-29 * 修改人: * 修改日期: * 修改备注: * 版本:1.0.0.0 ***********************/ using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Lskj.Data; using Lskj.Model; using Lskj.Control; using Lskj.Control.Model; using Lskj.Business.Impl; using Lskj.Util; using DevExpress.XtraTab; using DevExpress.XtraBars; using DevExpress.XtraEditors; using System.IO; using Lskj.Business; using Lskj.Core; using System.Diagnostics; using System.Text.RegularExpressions; namespace Lskj.BaseInfo { /// /// Class FrmMain. /// public partial class FrmMain : BaseForm { public DataRow mRowItem; public FrmMain() { InitializeComponent(); } #region 公有变量 /// /// 系统模块配置 /// public DynamicBaseInfoModel SysModel; /// /// 主表控件 /// public MyControl ControlObj; #endregion #region 私有变量 /// /// 初始化完成 /// private bool _isInitFinish; /// /// 是否直接打印 /// private bool _isExcPrint; /// /// 推送模块编号 /// private int _beforeId; /// /// 返退意见 /// private string _auditAdvic; /// /// 推送菜单名 /// private string _beforeMenuName; /// /// 推送用户 /// private string _beforeUsers; /// /// 主打印Sql /// private string _mainPrintSql; /// /// 打印主sql中关联打印次数返回条件 /// private string _printModeCond; /// /// 审批进度 /// private string _stepCode; /// /// 打印完成后添加数据用到的参数 /// private List _printSaveParams; /// /// 当前数据来源 /// private DataRow _currentControlSource; /// /// 动态控件字段 /// private DataTable _dtFileds; /// /// 分组控件字段 /// private DataTable _dtAddGroup; /// /// 基础档案审批模型 /// private BaseAuditCommonModel _baseAuditModelObj; /// /// 审批模型 /// private BaseAuditModel _baseInfoModelObj; /// /// 单据水印 /// private WaterMark _waterMark; /// /// 传入的参数 /// public string[] IncomingParameters; #endregion #region 窗体加载时 /// /// 说明:窗体加载时 /// 创建人:龚宇超 /// 创建日期:2017-12-29 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The instance containing the event data. protected override void OnLoad(EventArgs e) { WaitForm.ShowForm(); try { SysModel.Privilege = this.SysModel.Privilege.Equals("3") ? "1" : SysModel.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(SysModel.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(SysModel.ModuleCode) + ""; if (!this.SysModel.HasPrivilege()) { MessageUtil.Show(ResourceKeys.UnPurview); this.Close(); } else { this._isInitFinish = false; this.Text = !string.IsNullOrEmpty(this.SysModel.FormText) ? this.SysModel.FormText : this.Text; this._baseAuditModelObj = new BaseAuditCommonModel(); this.InitializeSetting(); this.InitializeControl(); this.InitializeSplitterPosition(); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); LogHelper.Instance.WriteError(ex, ResourceKeys.BaseModuleAudit); } finally { Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this); WaitForm.HideForm(); this._isInitFinish = true; } } #endregion #region 初始化分割条位置 /// /// 说明:初始化分割条位置 /// 创建人:龚宇超 /// 创建日期:2017-12-29 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializeSplitterPosition() { try { string splitterPosition = IniHelper.Read(string.Format("base_splitterPositionLeft_{0}", this.SysModel.ModuleCode)); if (!string.IsNullOrEmpty(splitterPosition)) { this.splitLeft.SplitterPosition = Convert.ToInt32(splitterPosition); } string splitterMainPosition = IniHelper.Read(string.Format("base_spliterPositionMain_{0}", this.SysModel.ModuleCode)); if (!string.IsNullOrEmpty(splitterMainPosition)) { this.splitMain.SplitterPosition = Convert.ToInt32(splitterMainPosition); } } catch (Exception e) { LogHelper.Instance.WriteError(e); MessageUtil.Show("初始化分割条出错!"+e); } } #endregion #region 初始化属性 /// /// 说明:初始化属性设置 /// 创建人:龚宇超 /// 创建日期:2017-12-29 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializeSetting() { this.mRowItem = MainImpl.GetSystemdllTab(this.SysModel.ModuleCode); this._baseInfoModelObj = new BaseAuditModel(this.mRowItem); if (string.IsNullOrEmpty(this._baseInfoModelObj.FormKey)) { MessageUtil.Show(ResourceKeys.ModuleConfigError); return; } this._baseInfoModelObj.PrefixKey = BaseImpl.GetColumnPrefix(this._baseInfoModelObj.MenuTable); this._baseInfoModelObj.ParmaryKey = BaseImpl.GetBasePrimaryKey(this.SysModel.ModuleCode); this._dtFileds = BaseAuditImpl.GetControlLocation(this._baseInfoModelObj.FormKey); this._dtAddGroup = BaseModuleImpl.GetAddGroupData(this._baseInfoModelObj.FormKey); this._currentControlSource = BaseAuditImpl.GetCurrentFlowRowData(this._baseInfoModelObj.MenuTable, this._baseInfoModelObj.ParmaryKey, this.SysModel.PrimaryValue); if (_currentControlSource == null) { MessageUtil.Show("记录不存在!请检查"); return; } string stepCodeField = this._baseInfoModelObj.PrefixKey + "stepCode"; this._stepCode = this._currentControlSource.Table.Columns.Contains(stepCodeField) ? this._currentControlSource[stepCodeField] + "" : "0"; } #endregion #region 初始化窗体大小 /// /// 说明:初始化窗体大小 /// 创建人:龚宇超 /// 创建日期:2017-01-02 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitSetSize() { DataRow drSize = BaseModuleImpl.GetControlParentSize(this._baseInfoModelObj.FormKey); if (drSize != null) { int height = Convert.ToInt32(drSize["height"]); int width = Convert.ToInt32(drSize["width"]); this.Height = height + 130; this.pl_main.Height = height > 0 ? height : this.pl_main.Height; this.Width = width > 0 ? width + 242 : this.Width; this.CenterToScreen(); } if ((this.Width > Screen.PrimaryScreen.WorkingArea.Width || (this.Height > Screen.PrimaryScreen.WorkingArea.Height))) { int screenHeight = Screen.PrimaryScreen.WorkingArea.Height; screenHeight = screenHeight - 40; this.Height = screenHeight; this.CenterToScreen(); this.pl_main.AutoScroll = true; } } #endregion #region 初始化控件 /// /// 说明:初始化控件 /// 创建人:龚宇超 /// 创建日期:2017-01-02 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializeControl() { this.gridFlow.SetReadOnlyColumns(BaseAuditImpl.GetFlowRecordColumn()); this.gridFlow.SetGridViewDataSource(BaseAuditImpl.GetFlowRecordData(this._baseAuditModelObj.SystemTabFlowStep, this.SysModel.PrimaryValue, this.SysModel.ModuleCode)); this.gridFlow.gridControl.Paint += new PaintEventHandler(gridFlow_Panint); this.gridFlow.GridView.RowStyle += new DevExpress.XtraGrid.Views.Grid.RowStyleEventHandler(gridFlow_RowStyle); this.InitSetSize(); this.CreateBaseInfoControl(); this.BindTab(); this.InitPrint(); this.InitCommonTools(); } #endregion /// /// 说明:初始化本次推送人员 /// 创建人:龚宇超 /// 创建日期:2018-05-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitPushOpers() { DataRow rowItem = BaseAuditImpl.GetPushedOpers(this.SysModel.PrimaryValue, this._stepCode); if (rowItem != null) { //记录本次操作信息 this._beforeMenuName = rowItem["menuname"] + ""; this._beforeUsers = rowItem["operators"] + ""; this._beforeId = Convert.ToInt32(rowItem["id"]); } } #region 流转记录行样式 /// /// 说明:流转记录行颜色设置 /// 创建人:龚宇超 /// 创建日期:2017-01-02 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void gridFlow_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e) { try { if (e.RowHandle >= 0) { DataRow dr = this.gridFlow.GridView.GetDataRow(e.RowHandle); if (dr["sh"] + "" == "审") e.Appearance.ForeColor = Color.Blue; } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } #endregion #region 动态创建控件 /// /// 说明:动态创建控件 /// 创建人:龚宇超 /// 创建日期:2017-01-02 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void CreateBaseInfoControl() { this.ControlObj = new MyControl(); this.ControlObj.PrimaryValue = this.SysModel.PrimaryValue; this.ControlObj.InitControl(this._dtFileds, this.pl_main, this._dtAddGroup); this.ControlObj.SetReadOnlyAllControl(); this.ControlObj.OnDataSourceBindCallBack += new EventHandler(ControlObj_OnDataSourceBindCallBack); } /// /// 说明:数据源绑定完成后执行 /// 创建人:龚宇超 /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void ControlObj_OnDataSourceBindCallBack(object sender, EventArgs e) { try { this.ControlObj.CanExecControl = false; this.ControlObj.SetAllControlValue(this._currentControlSource); this.InitTabData(); this._waterMark = new WaterMark(this._baseInfoModelObj.PrefixKey, this._currentControlSource); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } #endregion #region 加载选项卡数据 /// /// 说明:加载选项卡数据 /// 创建人:龚宇超 /// 创建日期:2017-12-15 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitTabData() { foreach (XtraTabPage tabPage in this.baseTab.TabControlObj.TabPages) { GridDetailModel model = this.baseTab.GetGridDetailModel(tabPage); bool isDetailAttach = (model.IsReadOnly || model.IsChart); //string sqlValue = isDetailAttach ? model.DetailSql : GetSearchSql(model); //GridControlEx grdExMain = (tabPage.Tag as GridControlEx); //if (!isDetailAttach) grdExMain.LastSearchSql = sqlValue; //this.baseTab.SetGridDataSource(tabPage, this.ControlObj.ReplaceControlValue(sqlValue)); if (tabPage.Tag is ModuleWebView) { // 加载网页 string url = ReplaceHelper.ReplaceRowParam(this._currentControlSource, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; ModuleWebView webView = tabPage.Tag as ModuleWebView; webView.Dock = DockStyle.Fill; webView.Tag = model; webView.Navigate(url); } else if (tabPage.Tag is FrmWebBrowser) { // 加载网页 string url = ReplaceHelper.ReplaceRowParam(this._currentControlSource, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser; webView.Dock = DockStyle.Fill; webView.Tag = model; webView.LoadUrl(url); } else if (tabPage.Tag is FrmMiniBlink) { // 加载网页 string url = ReplaceHelper.ReplaceRowParam(this._currentControlSource, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; FrmMiniBlink webView = tabPage.Tag as FrmMiniBlink; webView.Dock = DockStyle.Fill; webView.Tag = model; webView.LoadUrl(url); } else if (tabPage.Tag is GridControlEx) { string sqlValue = isDetailAttach ? model.DetailSql : GetSearchSql(model); GridControlEx grdExMain = (tabPage.Tag as GridControlEx); if (!isDetailAttach) grdExMain.LastSearchSql = sqlValue; this.baseTab.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(this._currentControlSource, sqlValue))); //if (!model.IsReadOnly) isModifyPage.Add(model.FormKey, tabPage); } else if (tabPage.Tag is TabMultipledetails) { TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails; tabMultipledetails.SetConditionValues(this._currentControlSource); GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx); GridDetailModel MainModel = grdExMain.Tag as GridDetailModel; string searchMainSql = ReplaceHelper.ReplaceRowParam(this._currentControlSource, isDetailAttach ? MainModel.DetailSql : GetSearchSql(MainModel)); DataTable firstTable = MainImpl.GetDataTableResult(searchMainSql); grdExMain.LastSearchSql = searchMainSql; grdExMain.SetGridViewDataSource(firstTable); if (tabMultipledetails.SplitMain.Panel2.Tag is GridControlEx) { GridControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx); GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel; string searchAddSql = ReplaceHelper.ReplaceRowParam(this._currentControlSource, isDetailAttach ? AdditionalModel.DetailSql : GetSearchSql(AdditionalModel)); if (!MainModel.IsUnioDetail) { grdExAdditional.LastSearchSql = searchAddSql; grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql)); } //右侧是左侧的明细,左侧没有数据时。右侧赋空值(因为无法触发左侧行改变事件) if (MainModel.IsUnioDetail && firstTable.Rows.Count == 0) { grdExAdditional.LastSearchSql = ""; grdExAdditional.SetGridViewDataSource(new DataTable()); } } else if (tabMultipledetails.SplitMain.Panel2.Tag is ChartControlEx) { ChartControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as ChartControlEx); GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel; string searchAddSql = this.GetSearchSql(AdditionalModel); DataTable table = MainImpl.GetDataTableResult(searchAddSql); grdExAdditional.CreateChart(table); } } } } /// /// 说明:获取查询条件 /// 创建人:王一帆 /// 创建日期:2021-01-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The model. /// The row item. /// System.String. protected string GetSearchSql(GridDetailModel model) { string unionPatentValue = !string.IsNullOrEmpty(model.UnionParentField) && this._currentControlSource != null && this._currentControlSource.Table.Columns.Contains(model.UnionParentField) ? this._currentControlSource[model.UnionParentField] + "" : this._baseInfoModelObj.ParmaryKey; string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql; if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue)) { sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, unionPatentValue); } if (!string.IsNullOrEmpty(model.UnionCond)) { string UnionCond = ReplaceHelper.ReplaceRowParam(this._currentControlSource, model.UnionCond); sqlValue += UnionCond; } return sqlValue; } #endregion #region 绑定选项卡 /// /// 说明:绑定选项卡 /// 创建人:龚宇超 /// 创建日期:2017-01-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void BindTab() { //this.baseTab.Model = this.SysModel; DynamicBaseInfoModel dynamicModel = new DynamicBaseInfoModel(IncomingParameters); this.baseTab.Model = dynamicModel; this.baseTab.Model.Privilege = "2";//只读权限(此模块是终审界面,明细不能修改) this.baseTab.InitTabPages(GetDetails(),false); this.SetControlPanelHeight(); } /// /// 说明:获取tab明细 /// 创建人:龚宇超 /// 创建日期:2017-01-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private List GetTabDetails() { List details = new List(); DataTable table = BaseAuditImpl.GetAttachTabs(this.SysModel.ModuleCode, ""); foreach (DataRow item in table.Rows) { details.Add(new GridDetailModel(item)); } return details; } /// /// 说明:拿到底部表格数据 /// 创建人:龚宇超 /// 创建日期:2017-11-21 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// List<GridDetailModel>. private List GetDetails() { List details = new List();//表格明细对象的集合 DataTable table = BaseModuleImpl.GetBaseDetailPages(this.SysModel.ModuleCode);// 根据传入的模块编号获得基础档案底部标签的数据 foreach (DataRow item in table.Rows) { DataTable gridColumns = ReportImpl.GetReportDetailColumns(this.SysModel.ModuleCode, item["id"] + "");//获取报表明细列 details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView)); } return details; } #endregion #region 设置控件面板高度 /// /// 说明:设置控件面板高度 /// 创建人:龚宇超 /// 创建日期:2017-12-29 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void SetControlPanelHeight() { if (this.baseTab.TabControlObj.TabPages.Count > 0) { this.pl_main.Height = this.pl_main.Height < 350 ? 350 : this.pl_main.Height; this.Height = pl_main.Height + 300; } else { this.Height = pl_main.Height > 600 ? this.pl_main.Height : this.Height; if (this.baseTab.TabControlObj.TabPages.Count == 0) splitLeft.PanelVisibility = SplitPanelVisibility.Panel1; } } #endregion #region 初始化常用工具 /// /// 说明:初始化常用工具 /// 创建人:龚宇超 /// 创建日期:2017-12-15 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitCommonTools() { string text = Business.Impl.LanguageTranslation.Translatable ? Business.Impl.LanguageTranslation.GetTranslatedText("附件") : "附件"; this.btnFile.Text = text + "(" + AttachImpl.GetFileCount(this._baseInfoModelObj.MenuDirId + "", this.SysModel.PrimaryValue) + ")"; //DataTable toolsMenu = BaseModuleImpl.GetBaseGridRightMenus(this.SysModel.ModuleCode, ModuleType.BillDetail); //foreach (DataRow item in toolsMenu.Rows) //{ // BarButtonItem itemCommon = new BarButtonItem(); // itemCommon.Caption = item["menuname"] + ""; // itemCommon.Tag = item; // itemCommon.ItemClick += new ItemClickEventHandler(itemCommon_ItemClick); // this.pMenu.AddItem(itemCommon); //} //this.drop_tools.Enabled = toolsMenu.Rows.Count > 0; } /// /// 说明:常用工具点击 /// 创建人:龚宇超 /// 创建日期:2017-12-211 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. protected void itemCommon_ItemClick(object sender, ItemClickEventArgs e) { try { DataRow rowItem = e.Item.Tag as DataRow; CommonMenu menu = new CommonMenu(this.SysModel, this.ControlObj); menu.Apply(rowItem); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } #endregion #region 绘制水印 /// /// 说明:绘制水印 /// 创建人:龚宇超 /// 创建日期:2017-01-02 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void gridFlow_Panint(object sender, PaintEventArgs e) { try { if (this._waterMark != null) { System.Windows.Forms.Control control = sender as System.Windows.Forms.Control; GraphicsText graphicsText = new GraphicsText(); graphicsText.Graphics = e.Graphics; // 绘制围绕点旋转的文本 StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; int x = (control.Width - 90) / 2; int y = (control.Height - 32) / 2; // 绘制单据状态文本 graphicsText.DrawString("已审核", new Font("宋体", 20, FontStyle.Bold), new SolidBrush(Color.Red), new PointF(x, y), format, -20f); e.Graphics.TranslateTransform(x, y); e.Graphics.RotateTransform(-20f); e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(-45, -19, 90, 32)); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } #endregion #region 打印 /// /// 说明:初始化打印 /// 创建人:龚宇超 /// 创建日期:2018-01-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitPrint() { DataTable printTable = BaseImpl.GetPrintTemp70(this.SysModel.ModuleCode); if (printTable.Rows.Count > 0) { for (int i = 0; i < printTable.Rows.Count; i++) { DataRow item = printTable.Rows[i]; BarButtonItem bbi = new BarButtonItem(); int index = i + 1; bbi.Caption = (item["printFile"] + "").Replace(".rmf", "").Replace(".frx", ""); bbi.Tag = item; bbi.ItemClick += new ItemClickEventHandler(OnPrintItem70Click); pMprint.AddItem(bbi); } } else { if (!string.IsNullOrEmpty(this._baseInfoModelObj.PrintFile)) { String[] strs = this._baseInfoModelObj.PrintFile.Split('|'); for (int i = 0; i < strs.Length; i++) { BarButtonItem bbi = new BarButtonItem(); int index = i + 1; bbi.Caption = strs[i].Replace(".rmf", "").Replace(".frx", ""); bbi.Tag = strs[i]; bbi.ItemClick += new ItemClickEventHandler(OnPrintItemClick); pMprint.AddItem(bbi); } } } } /// /// 说明:打印完成需要参数 /// 创建人:龚宇超 /// 创建日期:2018-07-09 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// protected void GetPrintOtherParam() { //取得打印完成后的参数 if (this._baseInfoModelObj.PrintSql.Contains("<<")) { string[] strs = this._baseInfoModelObj.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; } } } /// /// 说明:模版打印 /// 创建人:龚宇超 /// 创建日期:2018-01-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. protected void OnPrintItemClick(object sender, ItemClickEventArgs e) { string printFile = e.Item.Tag + ""; string printPath = PubUtil.PrintFileAbsolutelyPath; if (!File.Exists(printPath)) { MessageUtil.Show(ResourceKeys.NotFoundPrintFile); return; } if (this._currentControlSource == null) { MessageUtil.Show(ResourceKeys.SelectRowIsNull); return; } try { string tmpSql = ReplaceHelper.ReplaceRowParam(this._currentControlSource, this._baseInfoModelObj.PrintSql); string tmpSql1 = ReplaceHelper.ReplaceRowParam(this._currentControlSource, this._baseInfoModelObj.PrintSql1); string tmpSql2 = ReplaceHelper.ReplaceRowParam(this._currentControlSource, this._baseInfoModelObj.PrintSql2); 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(this._currentControlSource, _mainPrintSql); _printSaveParams[3] = this._currentControlSource[_printSaveParams[2]] + ""; tmpSqls.Add(mainSql); tmpSqls.Add(tmpSql1); 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._baseInfoModelObj.PrintType, tmpSql2); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); LogHelper.Instance.WriteError(ex); } } /// /// 说明:模版新版打印 /// 创建人:龚宇超 /// 创建日期:2018-01-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. protected void OnPrintItem70Click(object sender, ItemClickEventArgs e) { DataRow printRowItem = e.Item.Tag as DataRow; string printFile = printRowItem["printFile"] + ""; string printName = printRowItem["printName"] + ""; string printParams = printRowItem["printParams"] + ""; string printType = printRowItem["printType"] + ""; string sourceType = printRowItem["sourceType"] + ""; string printPath = PubUtil.PrintFileAbsolutelyPath70; if (!File.Exists(printPath)) { MessageUtil.Show(ResourceKeys.NotFoundPrintFile); return; } if (this._currentControlSource == null) { MessageUtil.Show(ResourceKeys.SelectRowIsNull); return; } try { printParams = "2".Equals(sourceType) || "3".Equals(sourceType) ? this._currentControlSource.ToJsonObject() : ReplaceHelper.ReplaceRowParam(this._currentControlSource, printParams); DelphiHelper.LoadDelphiDll(printPath, printPath, this.SysModel.ModuleCode, printName, printParams, Convert.ToInt32(printType), ""); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); LogHelper.Instance.WriteError(ex); } } /// /// 说明:打印完成后回调 /// 创建人:龚宇超 /// 创建日期:2018-07-05 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The e. private 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) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } #endregion #region 附件管理 /// /// 说明:附件管理 /// 创建人:龚宇超 /// 创建日期:2017-01-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void btnAttach_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(this.SysModel.PrimaryValue)) { MessageUtil.Show(ResourceKeys.NotFoundMaterielNo); } else { string url = string.Format("pages/PhotoView.html?left=1&username={0}&password={1}&id={2}&isview={3}&dllcoid=", ERPInfo.Instance.UserName, ERPInfo.Instance.Password, this.SysModel.PrimaryValue, this.btnReturn.Enabled ? "0" : "1"); // 固定传入参数(窗口标题、操作员ID、操作员名称、权限、模版编号) string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode).Split('~'); string[] menuArgs = SystemInfo.Instance.BsAttachFlag.Equals("1") ? new string[] { "", "", url } : new string[] { string.Format(ModuleArgs.PubPhotoViewArgs, this.SysModel.PrimaryValue), this.SysModel.IsView ? "1" : "0", this._baseInfoModelObj.MenuDirId + "", "" }; string[] args = defaultArgs.Concat(menuArgs).ToArray(); IForm form = FormHelper.LoadDllForm(SystemInfo.Instance.BsAttachFlag.Equals("1") ? ResourceDynamic.PubBrower : ResourceDynamic.PhotoView, args); DialogResult result = form.SubForm.ShowDialog(); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } #endregion #region 分割条位置改变事件 /// /// 说明:分割条位置事件 /// 创建人:龚宇超 /// 创建日期:2017-01-25 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void splitLeft_SplitterPositionChanged(object sender, EventArgs e) { try { if (this._isInitFinish) { IniHelper.Write(string.Format("base_splitterPositionLeft_{0}", this.SysModel.ModuleCode), this.splitLeft.SplitterPosition + ""); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } void splitMain_SplitterPositionChanged(object sender, EventArgs e) { try { if (this._isInitFinish) { IniHelper.Write(string.Format("base_spliterPositionMain_{0}", this.SysModel.ModuleCode), this.splitMain.SplitterPosition + ""); } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } #endregion #region 返审 /// /// 说明:执行返退选择 /// 创建人:龚宇超 /// 创建日期:2017-12-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The row. /// System.Int32. private int ExecuteBackSelect(DataRow row) { if (row == null) { MessageUtil.Show(ResourceKeys.NoFindAntiauditBill); return -9; } if (this._baseInfoModelObj.BackSelected == "0") return -1; if (this._stepCode == "100") return 0; FrmBackSelect frmBackSel = new FrmBackSelect(); frmBackSel.Sysmodel = this.SysModel; frmBackSel.StepCode = this._stepCode; frmBackSel.ModuleModelObj = this._baseInfoModelObj; frmBackSel.InitControl(); if (frmBackSel.ShowDialog() != DialogResult.OK) return -9; this._auditAdvic = frmBackSel.ComfirmMsg; return frmBackSel.SelectStepCode; } /// /// 说明:返审 /// 创建人:龚宇超 /// 创建日期:2018-08-29 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. private void OnReturnClick(object sender, EventArgs e) { try { int returnd = ExecuteBackSelect(this._currentControlSource); if (returnd == -9) return; string nextSelectStepCode = string.Empty; string nextSelectStepOper = string.Empty; //确认审核不通过并反退该单据? if (MessageUtil.Show(string.Format(ResourceKeys.ConfimAuditFailAndReturnBill), MessageBoxButtons.YesNo) == DialogResult.Yes) { string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, this.SysModel, this._stepCode, this.SysModel.PrimaryValue, "", this._baseAuditModelObj.ProcedureName, "R", "", "", "", "", true, returnd); if ("1".Equals(result)) { MessageUtil.Show(ResourceKeys.ForcedSuccess); //暂未推送消息 PushHelper push = new PushHelper(this.SysModel.PrimaryValue, this._stepCode, this.SysModel.ModuleCode, this._beforeUsers, this._beforeMenuName, this._beforeId); push.Push_Base_Oper_Message(); this.DialogResult = DialogResult.OK; } else { MessageUtil.Show(ResourceKeys.ForcedFail + "\r\n" + result); } } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } #endregion private void simpleButton1_Click(object sender, EventArgs e) { try { WebBrowserUtil.StartWebBrowser(this.SysModel.ModuleCode, mRowItem["ToolsName"] + ""); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message,ex.Message); } } } }