/*********************** * 说明:单据BillInfo模块加载 * 创建人:龚宇超 * 创建日期: * 修改人: * 修改日期: * 修改备注: * 版本: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.Control; using Lskj.Model; using Lskj.Control.Model; using Lskj.Util; using Lskj.Business.Impl; using Lskj.Data; using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraEditors; using DevExpress.XtraGrid.Columns; using DevExpress.XtraBars; using DevExpress.XtraTab; using Lskj.Business; namespace Lskj.PubBillInfo { public partial class FrmMain : BaseForm { #region 私有变量 /// /// 初始化完成 /// private bool _isInitFinish; /// /// 是否直接打印 /// private bool _isExcPrint; /// /// 推送模块编号 /// private int _beforeId; /// /// 明细Sql /// private string _detailSql; /// /// 主打印Sql /// private string _mainPrintSql; /// /// 打印主sql中关联打印次数返回条件 /// private string _printModeCond; /// /// 审核意见 /// private string _auditAdvice; /// /// 推送菜单名 /// private string _beforeMenuName; /// /// 推送用户 /// private string _beforeUsers; /// /// 单据信息 /// private DataRow _drBillInfo; /// /// 打印完成后添加数据用到的参数 /// private List _printSaveParams; /// /// 水印 /// private WaterMark _waterMark; #endregion #region 公共变量 /// /// 单据弹出模块模型 /// public AccraditationModel AuditModelObj; /// /// 单据模型 /// public BillAuditModel BillModelObj; /// /// 单据审批公共属性模型 /// public BillAuditCommonModel BillComModelObj; /// /// BillInfo模型 /// public DynamicBillInfoModel SysModel; /// /// 主表控件 /// public MyControl ControlObj; #endregion #region 初始化操作 public FrmMain() { InitializeComponent(); } /// /// 说明:窗口加载 /// 创建人:龚宇超 /// 创建日期:2018-05-29 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The instance containing the event data. protected override void OnLoad(EventArgs e) { WaitForm.ShowForm(); try { this._isInitFinish = false; this.InitializeSetting(); this.InitializeControl(); this.InitializeSplitterPosition(); this.GetPrintOtherParam(); } catch (Exception ex) { LogHelper.Instance.WriteError(ex); //MessageUtil.Show(ex.StackTrace); string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } finally { Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this); WaitForm.HideForm(); this._isInitFinish = true; } } /// /// 说明:单据BillInfo初始化属性设置 /// 创建人:龚宇超 /// 创建日期:2017-01-12 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializeSetting() { this.BillComModelObj = new BillAuditCommonModel(); this.BillModelObj = new BillAuditModel(BillImpl.GetBillInfo(this.SysModel.ModuleCode)); this.BillModelObj.MasterPreFix = BaseImpl.GetColumnPrefix(this.BillModelObj.MasterTable); this.AuditModelObj = new AccraditationModel(BillAuditImpl.GetBillFlowData(this.SysModel.ModuleCode, this.SysModel.StepCode)); string text = ResourceKeys.BillInfoTitle; if (Business.Impl.LanguageTranslation.Translatable) { text = "【{0}】" + Business.Impl.LanguageTranslation.GetTranslatedText("单据号") + "【{1}】"; } this.Text = !string.IsNullOrEmpty(this.SysModel.FormTitle) ? string.Format(text, this.SysModel.FormText, this.SysModel.BillDocumentId) : this.SysModel.FormText; this.txt_billDocumentId.EditText = this.SysModel.BillDocumentId; } /// /// 说明:初始化控件 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializeControl() { this.InitializeTabPages(); this.InitializeBillInfo(); this.InitializeCommonMenus(); this.InitializePrint(); this.InitializeFlowInfo(); } /// /// 说明:绑定选项卡 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializeTabPages() { this.baseTab.Model = this.SysModel; this.baseTab.InitTabPages(GetTabDetails()); if (baseTab.TabControlObj.TabPages.Count == 0) splitLeft.PanelVisibility = SplitPanelVisibility.Panel1; this.baseTab.OnRightCallback += new EventHandler(OnTabPageGridViewRightCallback); } /// /// 说明:单据管理 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializeBillInfo() { //初始表头 this.ControlObj = new MyControl(); this.ControlObj.PrimaryValue = this.SysModel.BillDocumentId; this.ControlObj.InitControl(BaseModuleImpl.GetControlLocation(this.BillModelObj.FormKey, this.SysModel.ModuleCode), this.pl_top); this.ControlObj.SetReadOnlyAllControl(true); this.ControlObj.OnDataSourceBindCallBack += new EventHandler(OnControlObjOnDataSourceBindCallBack); this.pl_top.Height = (this.BillModelObj.ParentHeight - 36) > this.pl_top.Height ? this.pl_top.Height : this.BillModelObj.ParentHeight; this.gridBillInfo.Model = this.SysModel; //设置billInfo数据源 this.gridBillInfo.SetReadOnlyColumns(BillAuditImpl.GetSpareBillColumns(this.SysModel.ModuleCode, this.SysModel.UserName), GridCustomColumnStruct.AuditMainGridView + this.BillModelObj.FormKey); //排序 this.BillModelObj.DetailPreFix = BaseImpl.GetColumnPrefix(this.BillModelObj.DetailTable);// 明细表列前缀 this.BillModelObj.DetailOrderField = this.BillModelObj.DetailPreFix + "lsidx_id";// 单据来源id if (SystemInfo.Instance.IsNotBillDetailOrder)//禁用排序 this.BillModelObj.DetailOrderField = string.Empty; //DataTable gridTable = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.DetailSql, this.SysModel.BillDocumentId)); //gridTable.OrderBy(this.BillModelObj.DetailOrderField); //this.gridBillInfo.SetGridViewDataSource(gridTable); this.gridBillInfo.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(this.BillModelObj.DetailFormKey)); this.gridBillInfo.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus("BILLDETAIL_" + this.SysModel.ModuleCode), this.SysModel, null, this.ControlObj); this.gridBillInfo.gridControl.Paint += new PaintEventHandler(OnMyPaint); if (string.IsNullOrEmpty(this.BillModelObj.AuditLoadDetailFlag) || this.BillModelObj.AuditLoadDetailFlag == "0") this.gridBillInfo.GridView.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(OnGridViewRowSelectionClick); else this.gridBillInfo.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick); } /// /// 说明:数据绑定完成后刷新显示数据 /// 创建人:龚宇超 /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void OnControlObjOnDataSourceBindCallBack(object sender, EventArgs e) { try { this.ControlObj.CanExecControl = false; this._drBillInfo = BaseAuditImpl.GetCurrentFlowRowData(this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, this.SysModel.BillDocumentId); this.ControlObj.SetAllControlValue(this._drBillInfo); this.ControlObj.CanExecControl = true; //加载明细数据 DataTable gridTable = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(_drBillInfo, this.BillModelObj.DetailSql)); gridTable.OrderBy(this.BillModelObj.DetailOrderField); this.gridBillInfo.SetGridViewDataSource(gridTable); //加载水印 this._waterMark = new WaterMark(this.BillModelObj.MasterPreFix, this._drBillInfo); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:初始化常用菜单 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializeCommonMenus() { DataTable tableCommon = BaseModuleImpl.GetBaseGridRightMenus(this.SysModel.ModuleCode, ModuleType.BillDetail); string text = Business.Impl.LanguageTranslation.Translatable ? Business.Impl.LanguageTranslation.GetTranslatedText("附件") : "附件"; this.btnAtt.Text = text + "(" + AttachImpl.GetFileCount(this.BillModelObj.DirId + "", this.SysModel.BillDocumentId) + ")"; if (tableCommon.Rows.Count == 0) { this.dpb_Tools.Visible = false; this.btnAtt.Location = new Point(6, 121); this.btnPrint.Location = new Point(6, 63); //this.btnAtt.Width = 226; return; } foreach (DataRow item in tableCommon.Rows) { BarButtonItem itemCommon = new BarButtonItem(); itemCommon.Caption = item["menuname"] + ""; itemCommon.Tag = item; itemCommon.ItemClick += new ItemClickEventHandler(OnCommonItemClick); this.pMenu.AddItem(itemCommon); } } /// /// 说明:打印 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializePrint() { if (string.IsNullOrEmpty(this.BillModelObj.PrintFile)) return; string[] files = this.BillModelObj.PrintFile.Split('|'); for (int i = 0; i < files.Length; i++) { BarButtonItem Item = new BarButtonItem(); Item.Caption = files[i].Replace(".rmf", "").Replace(".frx", ""); Item.Tag = files[i]; Item.ItemClick += new ItemClickEventHandler(OnPrintItemClick); pMprint.AddItem(Item); } } /// /// 说明:初始化流转记录 /// 创建人:龚宇超 /// 创建日期:2018-05-29 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void InitializeFlowInfo() { // 初始化流转流转记录 this.gridFlow.GridView.RowStyle += new RowStyleEventHandler(OnGridViewFlowRecordRowStyle); this.gridFlow.SetReadOnlyColumns(BaseAuditImpl.GetFlowRecordColumn(), GridCustomColumnStruct.AuditPopupAttachGridView + this.BillModelObj.FormKey); this.gridFlow.SetGridViewDataSource(BaseAuditImpl.GetFlowRecordData(this.BillComModelObj.SystemTabFlowStep, this.SysModel.BillDocumentId, this.SysModel.ModuleCode)); } /// /// 说明:初始化分割条位置 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本: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); } } /// /// 说明:记录本次推送人员 /// 创建人:龚宇超 /// 创建日期:2018-01-09 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void GetPushOpers() { DataRow beforeOpers = BillAuditImpl.GetPushedOpers(this.SysModel.BillDocumentId, this.SysModel.StepCode); if (beforeOpers != null) { //记录本次操作信息 this._beforeMenuName = beforeOpers["menuname"] + ""; this._beforeUsers = beforeOpers["operators"] + ""; this._beforeId = Convert.ToInt32(beforeOpers["id"]); } } #endregion #region 方法 /// /// 说明:打印完成需要参数 /// 创建人:龚宇超 /// 创建日期:2018-07-09 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// protected void GetPrintOtherParam() { //取得打印完成后的参数 if (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(';'); DataRow item = AttachImpl.GetSystemModule(str[0]); if (item == null) { MessageUtil.Show("打印参数有误"); 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; } } } /// /// 说明:绑定选项卡 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private List GetTabDetails() { List details = new List(); DataTable table = BaseAuditImpl.GetAttachTabs(this.SysModel.ModuleCode, this.SysModel.StepCode); foreach (DataRow item in table.Rows) { DataTable dtGridColumns = BaseAuditImpl.GetBottomBasicInformation(item["formKey"] + ""); details.Add(new GridDetailModel(item, dtGridColumns, GridCustomColumnStruct.AuditPopupDetailGridView + item["formKey"] + "")); } return details; } /// /// 说明:返回审核 /// 创建人:龚宇超 /// 创建日期:2018-01-09 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The row. /// System.Int32. private int ExecuteBackSelect(DataRow row) { if (row == null) { MessageUtil.Show(ResourceKeys.NoFindAntiauditBill); return -9; } string stepCode = row[this.BillModelObj.MasterPreFix + "stepCode"] + ""; if (this.BillModelObj.BackSelected == "0") return -1; if (stepCode == "100") return 0; FrmBackSelect frmBackSel = new FrmBackSelect(); frmBackSel.SysModel = this.SysModel; frmBackSel.BillModelObj = this.BillModelObj; frmBackSel.StepCode = stepCode; frmBackSel.InitControl(); if (frmBackSel.ShowDialog() != DialogResult.OK) return -9; this._auditAdvice = frmBackSel.ComfirmMsg; return frmBackSel.SelectStepCode; } /// /// 说明:gridBillInfo点击事件共用函数 /// 创建人:龚宇超 /// 创建日期:2018-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// private void GridViewClick() { foreach (XtraTabPage tabPage in this.baseTab.TabControlObj.TabPages) { GridDetailModel model = this.baseTab.GetGridDetailModel(tabPage); bool isDetailAttach = (model.IsReadOnly || model.IsChart); DataRow dataRow = this.gridBillInfo.GridView.GetFocusedDataRow(); //string sqlValue = ReplaceHelper.ReplaceRowParam(this.gridBillInfo.GridView.GetFocusedDataRow(), model.DetailSql); //this.baseTab.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(sqlValue)); if (tabPage.Tag is ModuleWebView) { // 加载网页 string url = ReplaceHelper.ReplaceRowParam(dataRow, 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(dataRow, 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(dataRow, 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 ? ReplaceHelper.ReplaceRowParam(dataRow, model.DetailSql) : GetSearchSql(model); GridControlEx grdExMain = (tabPage.Tag as GridControlEx); if (!isDetailAttach) grdExMain.LastSearchSql = sqlValue; //this.tab_basicInfo.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(sqlValue)); this.baseTab.SetGridDataSource(tabPage, sqlValue); } else if (tabPage.Tag is TabMultipledetails) { TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails; tabMultipledetails.SetConditionValues(dataRow); GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx); GridDetailModel MainModel = grdExMain.Tag as GridDetailModel; string searchMainSql = isDetailAttach ? ReplaceHelper.ReplaceRowParam(dataRow, MainModel.DetailSql) : this.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 = isDetailAttach ? ReplaceHelper.ReplaceRowParam(dataRow, AdditionalModel.DetailSql) : this.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); } } } } #endregion #region 事件 /// /// 说明:绘制水印 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// void OnMyPaint(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; SolidBrush brush = new SolidBrush(Color.Red); Pen pen = new Pen(Color.Red, 2f); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; if (!string.IsNullOrEmpty(this._waterMark.Text)) { int x = (control.Width - 120) / 2; int y = (control.Height - 32) / 2; graphicsText.DrawString(this._waterMark.Text, new Font("宋体", 20, FontStyle.Bold), brush, new PointF(x, y), format, -20f); e.Graphics.TranslateTransform(x, y); e.Graphics.RotateTransform(-20f); if (Business.Impl.LanguageTranslation.Translatable) { // 1. 测量文本尺寸 SizeF textSize = e.Graphics.MeasureString(this._waterMark.Text, new Font("宋体", 20, FontStyle.Bold), new SizeF(float.MaxValue, float.MaxValue), format); // 2. 计算边框矩形的尺寸和位置 int rectWidth = (int)textSize.Width + 10; e.Graphics.DrawRectangle(pen, new Rectangle(-rectWidth / 2, -19, rectWidth, 32)); } else { e.Graphics.DrawRectangle(pen, new Rectangle(-60, -19, 120, 32)); } } e.Graphics.ResetTransform(); if (!string.IsNullOrEmpty(this._waterMark.Print)) { int x = (control.Width - 120) / 2; int y = (control.Height - 90) / 2 - 40; graphicsText.DrawString(this._waterMark.Print, new Font("宋体", 18, FontStyle.Bold), brush, new PointF(x, y), format, -20f); e.Graphics.TranslateTransform(x, y); e.Graphics.RotateTransform(-20f); if (Business.Impl.LanguageTranslation.Translatable) { // 1. 测量文本尺寸 SizeF textSize = e.Graphics.MeasureString(this._waterMark.Print, new Font("宋体", 18, FontStyle.Bold), new SizeF(float.MaxValue, float.MaxValue), format); // 2. 计算边框矩形的尺寸和位置 int rectWidth = (int)textSize.Width + 10; e.Graphics.DrawRectangle(pen, new Rectangle(-rectWidth / 2, -19, rectWidth, 32)); } else { e.Graphics.DrawRectangle(pen, new Rectangle(-60, -19, 120, 32)); } } e.Graphics.ResetTransform(); if (!string.IsNullOrEmpty(this._waterMark.Collect)) { int x = (control.Width - 120) / 2; int y = (control.Height - 180) / 2 + 100; graphicsText.DrawString(this._waterMark.Collect, new Font("宋体", 20, FontStyle.Bold), brush, new PointF(x, y), format, -20f); e.Graphics.TranslateTransform(x, y); e.Graphics.RotateTransform(-20f); if (Business.Impl.LanguageTranslation.Translatable) { // 1. 测量文本尺寸 SizeF textSize = e.Graphics.MeasureString(this._waterMark.Collect, new Font("宋体", 20, FontStyle.Bold), new SizeF(float.MaxValue, float.MaxValue), format); // 2. 计算边框矩形的尺寸和位置 int rectWidth = (int)textSize.Width + 10; e.Graphics.DrawRectangle(pen, new Rectangle(-rectWidth / 2, -19, rectWidth, 32)); } else { e.Graphics.DrawRectangle(pen, new Rectangle(-60, -19, 120, 32)); } } } } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:常用菜单点击事件 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// void OnCommonItemClick(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); } } /// /// 说明:打印事件 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// void OnPrintItemClick(object sender, ItemClickEventArgs e) { try { string printPath = PubUtil.PrintFileAbsolutelyPath; string printFile = e.Item.Tag + ""; string sqlValue = string.Format("select * from {0} where {1}='{2}'", this.BillModelObj.MasterTable, this.BillModelObj.PrimaryKey, txt_billDocumentId.EditText); DataRow masterRow = BillImpl.GetDataRowResult(sqlValue); if (masterRow == null) { MessageUtil.Show(ResourceKeys.DataNotFount); return; } if (!ReplaceHelper.ReplaceRowParamCond(masterRow, this.BillModelObj.PrintCond)) { MessageUtil.Show(ResourceKeys.DisSatisfyPrintCond); return; } string tmpSql = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModelObj.PrintSql); string tmpSql1 = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModelObj.PrintSql1); string tmpSql2 = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModelObj.PrintSql2); if (printFile.Contains(PrintUtil.TemplateFlag)) { 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) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:打印完成后回调 /// 创建人:龚宇超 /// 创建日期:2018-07-05 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The e. 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); } } /// /// 说明:单据右键菜单执行后刷新数据 /// 创建人:龚宇超 /// 创建日期:2018-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void OnTabPageGridViewRightCallback(object sender, EventArgs e) { try { GridDetailModel model = this.baseTab.GetFocusTabPageGridDetailModel(); string sqlValue = ReplaceHelper.ReplaceRowParam(this.gridBillInfo.GridView.GetFocusedDataRow(), model.DetailSql); this.baseTab.SetGridDataSource(MainImpl.GetDataTableResult(sqlValue)); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:单元格选中 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. void OnGridViewRowSelectionClick(object sender, DevExpress.Data.SelectionChangedEventArgs e) { try { this.GridViewClick(); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:单元格双击事件 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// void OnGridViewDoubleClick(object sender, EventArgs e) { try { this.GridViewClick(); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:流转表格行样式 /// 创建人:龚宇超 /// 创建日期:2017-12-15 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// void OnGridViewFlowRecordRowStyle(object sender, 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); } } /// /// 说明:附件 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// void OnAttachButtonClick(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(this.SysModel.BillDocumentId)) { MessageUtil.Show(ResourceKeys.NotFoundBillNo); } 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.BillDocumentId, 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[] { this.SysModel.BillDocumentId, "1", this.BillModelObj.DirId + "", "" }; 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) { LogUtil.WriteError("附件出错!", ex); //MessageUtil.Show("附件出错!" + ex); string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:分割条位置变化事件 /// 创建人:龚宇超 /// 创建日期:2017-01-24 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// void OnSplitterPositionChanged(object sender, EventArgs e) { try { if (_isInitFinish) { IniHelper.Write(string.Format("base_SplitterPositionLeft_{0}", this.SysModel.ModuleCode), this.splitLeft.SplitterPosition + ""); 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); } } /// /// 说明:返退 /// 创建人:龚宇超 /// 创建日期:2018-08-29 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. void OnReturnClick(object sender, EventArgs e) { try { int ret = ExecuteBackSelect(this._drBillInfo); if (ret == -9) return; string nextSelectStepCode = string.Empty; string nextSelectStepOper = string.Empty; if (MessageUtil.Show(ResourceKeys.ConfimAuditFailAndReturnBill, MessageBoxButtons.YesNo) == DialogResult.Yes) { string result = BaseAuditImpl.Audit(out nextSelectStepCode, out nextSelectStepOper, this.SysModel, this.SysModel.StepCode, this.SysModel.BillDocumentId, "", this.BillComModelObj.ProcedureName, "R", "0", this._auditAdvice, "", "", true, ret); if (result == "1") { MessageUtil.Show(ResourceKeys.ForcedSuccess); PushHelper push = new PushHelper(this.SysModel.BillDocumentId, this.SysModel.StepCode, this.SysModel.ModuleCode, this._beforeUsers, this._beforeMenuName, this._beforeId); push.Push_Bill_Oper_Message(); this.DialogResult = DialogResult.OK; } else { MessageUtil.Show(string.Format(ResourceKeys.ForcedFail, result)); } } } catch (Exception ex) { LogUtil.WriteError("反审出错!", ex); //MessageUtil.Show("反审出错!" + ex); string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } /// /// 说明:帮助文档 /// 创建人:龚宇超 /// 创建日期: /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The sender. /// The instance containing the event data. void OnHelpClick(object sender, EventArgs e) { try { WebBrowserUtil.StartWebBrowser(this.SysModel.ModuleCode, this.SysModel.FormTitle); } catch (Exception ex) { string Message = ErrorMessage.PromptErrorMessage(ex); MessageUtil.Show(Message, ex.Message); } } #endregion #region 获取查询条件 /// /// 说明:获取查询条件 /// 创建人:王一帆 /// 创建日期:2021-01-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The model. /// The row item. /// System.String. protected string GetSearchSql(GridDetailModel model) { string fieldName = !string.IsNullOrEmpty(model.UnionParentField) ? model.UnionParentField : BaseImpl.GetBasePrimaryKey(model.UnionModule); DataRow dr = this.BillModelObj.DetailTreeTable ? (this.gridBillInfo as TreeGridControlEx).GetViewFocusedDataRow() : this.gridBillInfo.GridView.GetFocusedDataRow(); fieldName = dr.Table.Columns.Contains(fieldName) ? dr[fieldName].ToString() : this.ControlObj.PrimaryValue; string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql; if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue)) { string[] sqlValues = sqlValue.Split(new string[] { "where " }, StringSplitOptions.None); if (sqlValues.Length > 1) { string sql = string.Empty; for (int i = 0; i < sqlValues.Length; i++) { if (i == sqlValues.Length - 2) { sql += sqlValues[i] + string.Format(" where {0}='{1}' and ", model.UnionValue, fieldName) + sqlValues[i + 1]; break; } sql += sqlValues[i] + " where "; } sqlValue = sql; } else { sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, fieldName); } } if (!string.IsNullOrEmpty(model.UnionCond)) { string UnionCond = ReplaceHelper.ReplaceRowParam(dr, model.UnionCond); sqlValue += UnionCond; } return sqlValue; } #endregion } }