ab56a9bcf7
SVN-Revision: r240
1553 lines
63 KiB
C#
1553 lines
63 KiB
C#
/***********************
|
|
* 说明:生产过程模版
|
|
* 创建人:龚宇超
|
|
* 创建日期:2018-02-27
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本: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.Model;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Control;
|
|
using Lskj.Data;
|
|
using Lskj.Util;
|
|
using Lskj.Business.Impl;
|
|
using DevExpress.XtraTab;
|
|
using DevExpress.Utils;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraPdfViewer;
|
|
using DevExpress.XtraEditors.Controls;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using Lskj.Business;
|
|
using System.Runtime.InteropServices;
|
|
using Lskj.Core;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
|
|
namespace Lskj.Production2
|
|
{
|
|
/// <summary>
|
|
/// Class FrmMain.
|
|
/// </summary>
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
#region 公共变量
|
|
/// <summary>
|
|
/// 入口模型
|
|
/// </summary>
|
|
public DynamicProductionModel SysModel;
|
|
/// <summary>
|
|
/// pdf模型
|
|
/// </summary>
|
|
public GridDetailModel PdfViewObj;
|
|
/// <summary>
|
|
///查询条件控件
|
|
/// </summary>
|
|
public MyControl SearchObj;
|
|
/// <summary>
|
|
/// 主控件集
|
|
/// </summary>
|
|
public MyControl ControlObj;
|
|
/// <summary>
|
|
/// 基础模型
|
|
/// </summary>
|
|
public ModuleModel MoudleObj;
|
|
/// <summary>
|
|
/// 表格明细集合
|
|
/// </summary>
|
|
public List<GridDetailModel> GridDetailModelObjs;
|
|
|
|
|
|
#endregion
|
|
|
|
#region 私有变量
|
|
/// <summary>
|
|
/// 数据索引
|
|
/// </summary>
|
|
private int _dataIndex;
|
|
/// <summary>
|
|
/// 初始化完成标记
|
|
/// </summary>
|
|
private bool _isInitFinish;
|
|
/// <summary>
|
|
/// 附件部分显隐
|
|
/// </summary>
|
|
private bool _isFilePanelVisble;
|
|
/// <summary>
|
|
/// 附件源sql
|
|
/// </summary>
|
|
private string _fileSql;
|
|
/// <summary>
|
|
/// 主键值
|
|
/// </summary>
|
|
private string _keyValue;
|
|
/// <summary>
|
|
/// 主键名
|
|
/// </summary>
|
|
private string _primaryKey;
|
|
/// <summary>
|
|
/// 附件地址
|
|
/// </summary>
|
|
private string _filePath;
|
|
/// <summary>
|
|
/// 选项卡刷新页签
|
|
/// </summary>
|
|
private string[] _pageIndex;
|
|
/// <summary>
|
|
/// 当前数据内容
|
|
/// </summary>
|
|
private DataRow _rowItem;
|
|
/// <summary>
|
|
/// 控件源数据
|
|
/// </summary>
|
|
//private DataTable _dtFields;
|
|
/// <summary>
|
|
/// 主表数据
|
|
/// </summary>
|
|
private DataTable _dtMainTable;
|
|
/// <summary>
|
|
/// pdf附件资源
|
|
/// </summary>
|
|
private DataTable _dtFiles;
|
|
/// <summary>
|
|
/// 附件下拉菜单
|
|
/// </summary>
|
|
private LabelComboxEdit _fileComboBox;
|
|
/// <summary>
|
|
/// 查看附件
|
|
/// </summary>
|
|
private FrmWebBrowser _moduleWebView;
|
|
/// <summary>
|
|
/// 选项卡排序Sql
|
|
/// </summary>
|
|
private Dictionary<string, string> _dicOrder = new Dictionary<string, string>();
|
|
|
|
#endregion
|
|
|
|
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#region 窗体加载时
|
|
/// <summary>
|
|
/// <para>说明:窗体加载时</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
this.splitContainerMain.Visible = false;
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
SysModel.Privilege = this.SysModel.Privilege.Equals("3") ? "1" : SysModel.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(SysModel.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(SysModel.ModuleCode) + "";
|
|
this._isInitFinish = false;
|
|
if (!this.SysModel.HasPrivilege())
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnPurview);
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
|
|
this.InitializeSetting();
|
|
this.InitializeControl();
|
|
this.InitlizeSpiltLocation();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex, ResourceKeys.BaseModuleAudit);
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
|
this._isInitFinish = true;
|
|
WaitForm.HideForm();
|
|
this.splitContainerMain.IsSplitterFixed = true;
|
|
this.splitContainerMain.Visible = true;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化属性
|
|
/// <summary>
|
|
/// <para>说明:初始化属性设置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeSetting()
|
|
{
|
|
this._primaryKey = BaseImpl.GetBasePrimaryKey(this.SysModel.ModuleCode);
|
|
this.MoudleObj = new ModuleModel(MainImpl.GetSystemdllTab(this.SysModel.ModuleCode));
|
|
this.MoudleObj.ParmaryKey = BaseImpl.GetBasePrimaryKey(this.SysModel.ModuleCode);
|
|
this.GridDetailModelObjs = GetDetailGrids();
|
|
|
|
this.GetDetailOrderCond();
|
|
//this._dtFields = BaseModuleImpl.GetControlLocation(this.MoudleObj.FormKey, this.SysModel.ModuleCode);
|
|
if (!string.IsNullOrEmpty(this.SysModel.ParmaryValue))
|
|
{
|
|
this._keyValue = this.SysModel.ParmaryValue;
|
|
}
|
|
|
|
//注册下载成功回调
|
|
AttachHelper.OnDownLoadSuccess += new EventHandler(AttachHelper_OnDownLoadSuccess);
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化控件
|
|
/// <summary>
|
|
/// <para>说明:初始化控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeControl()
|
|
{
|
|
this.ControlObj = new MyControl();
|
|
//this.ControlObj.InitControl(_dtFields, this.pl_Controls);
|
|
|
|
//this.InitLeftTopTab();
|
|
//this.tabLeftBottomDetail.ParentControlEx = this.ControlObj;
|
|
|
|
this.tabRightDetail.Model = this.tabLeftBottomDetail.Model = this.SysModel;
|
|
|
|
//初始化搜索
|
|
this.InitSearchFiled();
|
|
//当前模块源数据
|
|
this.GetCurrentData();
|
|
//设置列
|
|
DataTable dataTable= BaseModuleImpl.GetBaseGridColumns(this.SysModel.ModuleCode);
|
|
this.tabLeftBottomDetail.SetReadOnlyColumns(dataTable);
|
|
//赋值数据源和点击事件
|
|
this.tabLeftBottomDetail.SetGridViewDataSource(_dtMainTable);
|
|
this.tabLeftBottomDetail.GridView.RowCellClick += new RowCellClickEventHandler(GridView_RowCellClick);
|
|
//右键
|
|
DataTable Rightdt = BaseModuleImpl.GetBaseGridRightMenus(this.SysModel.ModuleCode);
|
|
this.tabLeftBottomDetail.SetGridRightMenus(Rightdt, this.SysModel, OnGridViewRightCallBack, this.SearchObj, null);
|
|
|
|
//this.tabLeftBottomDetail.InitTabPages(this.GridDetailModelObjs.Where(o => o.Orderid >= 0 && o.Orderid <= 9).ToList());
|
|
//this.tabLeftBottomDetail.ma VisibleOperPanel
|
|
this.tabRightDetail.ParentControlEx = this.ControlObj;
|
|
this.tabRightDetail.InitTabPages(this.GridDetailModelObjs.Where(o => o.Orderid > 9).ToList());
|
|
this.SetTabPageStyle();
|
|
if (SysModel.HasReadPrivilege())
|
|
{
|
|
btnSubmit.Enabled = false;
|
|
}
|
|
//根据这字段对开始提交进行显隐
|
|
if (!this.MoudleObj.AddEnable)
|
|
{
|
|
btnStart.Visible = btnSubmit.Visible = false;
|
|
pl_Manager.Width = this.textBox.Width + 10;
|
|
}
|
|
|
|
|
|
this.textBox.Select();
|
|
}
|
|
#endregion
|
|
|
|
#region 获取明细SQL排序条件
|
|
/// <summary>
|
|
/// <para>说明:获取明细SQL排序条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-07-26 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void GetDetailOrderCond()
|
|
{
|
|
string orderStr = string.Empty;
|
|
foreach (GridDetailModel mode in GridDetailModelObjs)
|
|
{
|
|
if (mode.Orderid == -100) continue;
|
|
DataRow dr = ProduceImpl.GetTabPageOrderCond(mode.UnionModule);
|
|
if (dr != null) orderStr = dr["MobileOrderStr"] + "";
|
|
_dicOrder.Add(mode.UnionModule, orderStr);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 设置选项卡数据源
|
|
/// <summary>
|
|
/// <para>说明:设置选项卡数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void setTabPageGridData(TabControlEx tabDetail, DataRow rowItem)
|
|
{
|
|
foreach (XtraTabPage tabPage in tabDetail.TabControlObj.TabPages)
|
|
{
|
|
//附件预览跳过
|
|
if (tabPage.Text == "附件预览")
|
|
continue;
|
|
GridDetailModel model = tabDetail.GetGridDetailModel(tabPage);
|
|
GridControlEx gridControl = tabPage.Tag as GridControlEx;
|
|
gridControl.LastSearchSql = this.GetSearchSql(model, rowItem);
|
|
tabDetail.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(gridControl.LastSearchSql));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取查询条件
|
|
/// <summary>
|
|
/// <para>说明:获取查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <param name="rowItem">The row item.</param>
|
|
/// <returns>System.String.</returns>
|
|
protected string GetSearchSql(GridDetailModel model, DataRow rowItem)
|
|
{
|
|
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) ? model.UnionParentField : this.MoudleObj.ParmaryKey;
|
|
string sqlValue = model.IsReadOnly ? model.DetailSql : model.SystemModel.MenuSql;
|
|
string orderCond = _dicOrder.FirstOrDefault(o => o.Key == model.UnionModule).Value;
|
|
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, rowItem[fieldName] + "");
|
|
}
|
|
else
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
|
}
|
|
return sqlValue + orderCond;
|
|
}
|
|
#endregion
|
|
|
|
#region 设置动态TabPage的样式
|
|
/// <summary>
|
|
/// <para>说明:设置动态的TabPage的样式隐藏页签标题</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetTabPageStyle()
|
|
{
|
|
//if (tabLeftTopDetail.TabControlObj.TabPages.Count == 1 && !_isFilePanelVisble)
|
|
//{
|
|
// this.splitContainerLeft.PanelVisibility = SplitPanelVisibility.Panel2;
|
|
//}
|
|
//else
|
|
//{
|
|
// this.splitContainerLeft.PanelVisibility = SplitPanelVisibility.Both;
|
|
//}
|
|
//if (tabLeftBottomDetail.TabControlObj.TabPages.Count == 0)
|
|
//{
|
|
// this.splitContainerLeft.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
//}
|
|
if (tabRightDetail.TabControlObj.TabPages.Count == 0)
|
|
{
|
|
this.splitContainerRight.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
}
|
|
//tabLeftTopDetail.TabControlObj.ShowTabHeader = tabLeftTopDetail.TabControlObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
//tabLeftBottomDetail.TabControlObj.ShowTabHeader = tabLeftBottomDetail.TabControlObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
tabRightDetail.TabControlObj.ShowTabHeader = tabRightDetail.TabControlObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
tabRightDetail.TabControlObj.HeaderLocation = TabHeaderLocation.Bottom;
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化左上部分tab控件
|
|
/// <summary>
|
|
/// <para>说明:初始化左上tab控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-28</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
//private void InitLeftTopTab()
|
|
//{
|
|
// this.tabLeftTopDetail.Model = this.SysModel;
|
|
// this.tabLeftTopDetail.InitTabPages(this.GridDetailModelObjs.Where(o => o.Orderid < 0 && o.Orderid != -100).ToList());
|
|
// PdfViewObj = this.GridDetailModelObjs.FirstOrDefault(o => o.Orderid == -100);
|
|
|
|
// //生成附件预览Tabpage
|
|
// if (PdfViewObj != null)
|
|
// {
|
|
// PdfViewObj.SystemModel = new ModuleModel(MainImpl.GetSystemdllTab(PdfViewObj.UnionModule));
|
|
// XtraTabPage tabpage = new XtraTabPage();
|
|
// tabpage.Text = "附件预览";
|
|
// //构建左上部分结构
|
|
// PanelControl panelFileBar = new PanelControl();
|
|
// this._fileComboBox = new LabelComboxEdit();
|
|
// this._fileComboBox.LabelText = "工艺文件阅读";
|
|
// this._fileComboBox.Location = new Point(8, 6);
|
|
// this._fileComboBox.Parent = panelFileBar;
|
|
// this._fileComboBox.Width = 500;
|
|
// this._fileComboBox.TextEdit.SelectedIndexChanged += new EventHandler(fileComboBox_SelectedIndexChanged);
|
|
// panelFileBar.Height = 33;
|
|
// panelFileBar.Dock = DockStyle.Top;
|
|
// panelFileBar.SendToBack();
|
|
// this._fileSql = PdfViewObj.SystemModel.MenuSql;
|
|
// _moduleWebView = new FrmWebBrowser();
|
|
// _moduleWebView.Dock = DockStyle.Fill;
|
|
// _moduleWebView.Parent = panelFileBar.Parent = tabpage;
|
|
// //this.tabLeftTopDetail.TabControlObj.TabPages.Insert(0, tabpage);
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
#region 初始化搜索
|
|
/// <summary>
|
|
/// <para>说明:初始化搜索</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitSearchFiled()
|
|
{
|
|
this.SearchObj = new MyControl(this.MoudleObj.MenuSql, null);
|
|
DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.MoudleObj.CondKey);
|
|
this.SearchObj.ModuleId = SysModel.ModuleId;
|
|
this.SearchObj.RememberRow = true;
|
|
if (queryTable != null && queryTable.Rows.Count > 0)
|
|
{
|
|
// 加载自定义查询条件
|
|
this.pl_top_search.Controls.Clear();
|
|
this.SearchObj.OtherParams = SysModel.OtherParams();
|
|
this.SearchObj.InitSearchControl(queryTable, this.pl_top_search, null);
|
|
this.SearchObj.OnSearchBeforeCallBack += new SearchEventHandler(SearchObj_OnSearchBefore);
|
|
this.SearchObj.OnSearchAfterCallBack += new EventHandler(OnSearchAfter);
|
|
|
|
if (this.SearchObj.ControlModels != null && this.SearchObj.ControlModels.Count > 0)
|
|
{
|
|
BaseUserControl mControl = this.SearchObj.FindControl(this.SearchObj.ControlModels[0].FieldName);
|
|
if (mControl != null)
|
|
{
|
|
mControl.EditText = this.SysModel.ParmaryValue;
|
|
SearchObj_OnSearchBefore(null, null);
|
|
}
|
|
|
|
foreach (ControlModel item in this.SearchObj.ControlModels)
|
|
{
|
|
BaseUserControl uControl = this.SearchObj.FindControl(item.FieldName);
|
|
if (uControl != null)
|
|
{
|
|
//this.SysModel.SearchControlEnable
|
|
uControl.Enabled = true;
|
|
}
|
|
}
|
|
//this.SysModel.SearchControlEnable
|
|
this.SearchObj.ButtonObj.Enabled = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 加载固定查询条件
|
|
DataTable dtCond = BaseModuleImpl.GetFixedQueryFields(this.SysModel.ModuleCode);
|
|
this.cbField.DisplayMember = "username1";
|
|
this.cbField.ValueMember = "fieldname";
|
|
this.cbField.DataSource = dtCond;
|
|
this.SearchObj.InitDefaultSearchControl(dtCond, this.pl_top_search);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取明细
|
|
/// <summary>
|
|
/// <para>说明:获取报表明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private List<GridDetailModel> GetDetailGrids()
|
|
{
|
|
List<GridDetailModel> details = new List<GridDetailModel>();
|
|
DataTable moduleDetailBottomTable = BaseModuleImpl.GetBaseDetailPages(this.SysModel.ModuleCode);
|
|
if (moduleDetailBottomTable.Rows.Count == 0)
|
|
{
|
|
moduleDetailBottomTable = BaseModuleImpl.GetBaseAddTabDetail(this.SysModel.ModuleCode);
|
|
}
|
|
|
|
foreach (DataRow item in moduleDetailBottomTable.Rows)
|
|
{
|
|
DataTable dtGridColumns = ReportImpl.GetReportDetailColumns(this.SysModel.ModuleCode, item["id"] + "");
|
|
details.Add(new GridDetailModel(item, dtGridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
return details;
|
|
}
|
|
#endregion
|
|
|
|
#region 工单验证
|
|
/// <summary>
|
|
/// <para>说明:按键验证工单卡号</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void CheckCard(int operType)
|
|
{
|
|
try
|
|
{
|
|
DataRow dr = tabLeftBottomDetail.GetViewFocusedDataRow();
|
|
string key = dr.Table.Columns.Contains(this._primaryKey) ? dr[_primaryKey].ToString() : string.Empty;
|
|
if (!string.IsNullOrEmpty(key))
|
|
{
|
|
|
|
string msgs = string.Empty, refreshPages = string.Empty;
|
|
int returnValue = operType == 0 ? ProduceImpl.ScanningCheckCard(this.SysModel.ModuleCode, this.textBox.Text, key, this.SysModel.UserId, this.SysModel.UserName, 0, out msgs, out refreshPages) : ProduceImpl.OperationCheckCard(this.SysModel.ModuleCode, key, operType, this.SysModel.UserId, this.SysModel.UserName, 0, out msgs, out refreshPages);
|
|
string[] resultMsgs = msgs.ToLower().Split('&');
|
|
if (returnValue != 1)
|
|
{
|
|
this.messageInfo.Text = resultMsgs[0];
|
|
}
|
|
else
|
|
{
|
|
_pageIndex = refreshPages.Split(',');
|
|
if (resultMsgs.Length >= 2)
|
|
{
|
|
GetMsgParamters(resultMsgs);
|
|
}
|
|
else
|
|
{
|
|
if (_pageIndex != null) Refresh(_pageIndex);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("按键验证工单卡号出错!", ex);
|
|
MessageUtil.Show("按键验证工单卡号出错!" + ex);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化附件菜单
|
|
/// <summary>
|
|
/// <para>说明:初始化附件菜单</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitComboxItem(DataRow rowItem)
|
|
{
|
|
this._isFilePanelVisble = false;
|
|
if (this._fileComboBox == null || string.IsNullOrEmpty(_fileSql)) return;
|
|
this._fileComboBox.TextEdit.Properties.Items.Clear();
|
|
string where = PdfViewObj != null ? " AND " + PdfViewObj.UnionValue.Replace("{", "").Replace("}", "") + "='" + rowItem[PdfViewObj.UnionParentField.Replace("{", "").Replace("}", "")] + "'" : "";
|
|
string sqlValue = _fileSql + where;
|
|
DataTable dtPdfResult = BaseImpl.GetDataTableResult(sqlValue);
|
|
if (dtPdfResult.Rows.Count <= 0) return;
|
|
DataRow[] dtPdfRows = dtPdfResult.Select("1=1");
|
|
if (dtPdfRows.Length == 0) return;
|
|
//string fileId = dtPdfRows[0]["fileId"] + "";
|
|
//string directoryId = dtPdfRows[0]["ParentId"] + "";
|
|
this._fileComboBox.ValueMember = "fileId";
|
|
this._fileComboBox.ValueField = "fileId";
|
|
this._fileComboBox.TextField = "sName";
|
|
this._fileComboBox.SetDataSource(dtPdfRows.CopyToDataTable());
|
|
this._fileComboBox.TextEdit.SelectedIndex = 0;
|
|
this._isFilePanelVisble = true;
|
|
this._filePath = PubUtil.FileDownLoadTempPath + BaseModuleImpl.GetFileServerPath(Convert.ToInt32(dtPdfRows[0]["fileId"]));
|
|
if (!File.Exists(this._filePath))
|
|
{
|
|
//打开默认预览
|
|
string serverPath = Path.Combine(SystemInfo.Instance.ServerAttachPath, BaseModuleImpl.GetFileServerPath(Convert.ToInt32(dtPdfRows[0]["fileId"])));
|
|
string tipMsg = string.Empty;
|
|
// 调用附件下载(lstest.exe包含了下载权限验证)
|
|
//AttachHelper.DownLoadFile(this.Handle, fileId.Trim(','), directoryId + "");
|
|
if (AttachImpl.CheckAttachOperation(2, "", Convert.ToInt32(dtPdfRows[0]["fileId"]), "", 0, out tipMsg) == 1)
|
|
{
|
|
AttachHelper.DownLoadFile(this.Handle, serverPath);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 延迟扫码点击功能
|
|
/// <summary>
|
|
/// <para>说明:搜索后延迟点击图片(此功能仅为了解决内置浏览器控件加载自动放大的问题,待进一步优化)</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnSearchAfter(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this._isFilePanelVisble) TimeOut.Enabled = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:搜索后延迟自动点击方法</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-06-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnSimulateClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
TimeOut.Enabled = false;
|
|
int X = Cursor.Position.X;//鼠标当前位置
|
|
int Y = Cursor.Position.Y;
|
|
|
|
//Point location = tabLeftTopDetail.PointToScreen(new Point(0, 0));
|
|
//SetCursorPos(location.X + tabLeftTopDetail.Width / 2, location.Y + tabLeftTopDetail.Height / 2); //设置鼠标放的位置
|
|
//mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
|
|
|
Point location2 = textBox.PointToScreen(new Point(0, 0));
|
|
SetCursorPos(location2.X + textBox.Width / 2, location2.Y + textBox.Height / 2);
|
|
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
|
|
|
SetCursorPos(X, Y);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
//绑定事件 导入dll
|
|
[System.Runtime.InteropServices.DllImport("user32")]
|
|
private static extern int mouse_event(int mouseevent, int dx, int dy, int cButtons, int dwExtraInfo);
|
|
|
|
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
|
|
private const int MOUSEEVENTF_LEFTUP = 0x04;
|
|
[DllImport("User32")]
|
|
public extern static void SetCursorPos(int x, int y);
|
|
#endregion
|
|
|
|
#region 卡号输入框清空并且给于焦点
|
|
/// <summary>
|
|
/// <para>说明:清空卡号输入框,并给予焦点</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitCardInputBox()
|
|
{
|
|
//this.textBox.Clear();
|
|
this.textBox.Focus();
|
|
}
|
|
#endregion
|
|
|
|
#region 加载新数据源
|
|
/// <summary>
|
|
/// <para>说明:加载新的数据(用于上下键翻页刷新和搜索)</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="Index">数据索引</param>
|
|
private void LoadNewForm(int Index)
|
|
{
|
|
DataRow dataRowItem = _dtMainTable.Rows[Index];
|
|
this.tabLeftBottomDetail.GridView.FocusedRowHandle = Index;
|
|
setTabPageGridData(tabRightDetail, dataRowItem);
|
|
this.ControlObj.SetAllControlValue(dataRowItem);
|
|
this._keyValue = dataRowItem[this._primaryKey] + "";
|
|
InitCardInputBox();
|
|
}
|
|
#endregion
|
|
|
|
#region 刷新
|
|
/// <summary>
|
|
/// <para>说明:刷新</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void Refresh(string[] pageIndexs)
|
|
{
|
|
|
|
|
|
//foreach (GridDetailModel gridmodel in GridDetailModelObjs)
|
|
//{
|
|
|
|
//if (pageIndexs.Contains<string>(gridmodel.Orderid + ""))
|
|
//{
|
|
|
|
//if (0 <= gridmodel.Orderid && gridmodel.Orderid <= 9)
|
|
//{
|
|
// this.tabLeftBottomDetail.TabControlObj.SelectedTabPage = this.tabLeftBottomDetail.TabControlObj.TabPages.Where(o => o.Text == gridmodel.DetailName).FirstOrDefault();
|
|
// if (this.tabLeftBottomDetail.TabControlObj.SelectedTabPage == null)
|
|
// this.tabLeftBottomDetail.TabControlObj.SelectedTabPage = this.tabLeftBottomDetail.TabControlObj.TabPages[0];
|
|
// this.tabLeftBottomDetail.SetGridDataSource(MainImpl.GetDataTableResult(sqlValue));
|
|
//}
|
|
//if (gridmodel.Orderid > 9)
|
|
//{
|
|
// _rowItem = tabLeftBottomDetail.GetViewFocusedDataRow();
|
|
// string sqlValue = this.GetSearchSql(gridmodel, _rowItem);
|
|
|
|
// this.tabRightDetail.TabControlObj.SelectedTabPage = this.tabRightDetail.TabControlObj.TabPages.Where(o => o.Text == gridmodel.DetailName).FirstOrDefault();
|
|
// if (this.tabRightDetail.TabControlObj.SelectedTabPage == null)
|
|
// this.tabRightDetail.TabControlObj.SelectedTabPage = this.tabRightDetail.TabControlObj.TabPages[0];
|
|
// this.tabRightDetail.SetGridDataSource(MainImpl.GetDataTableResult(sqlValue));
|
|
//}
|
|
//else if (gridmodel.Orderid != 100)
|
|
//{
|
|
// this.tabLeftTopDetail.TabControlObj.SelectedTabPage = this.tabLeftTopDetail.TabControlObj.TabPages.Where(o => o.Text == gridmodel.DetailName).FirstOrDefault();
|
|
// if (this.tabLeftTopDetail.TabControlObj.SelectedTabPage == null)
|
|
// this.tabLeftTopDetail.TabControlObj.SelectedTabPage = this.tabLeftTopDetail.TabControlObj.TabPages[0];
|
|
// this.tabLeftTopDetail.SetGridDataSource(MainImpl.GetDataTableResult(sqlValue));
|
|
//}
|
|
// }
|
|
//}
|
|
}
|
|
#endregion
|
|
|
|
#region 当前模块源数据
|
|
/// <summary>
|
|
/// <para>说明:当前模块源数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void GetCurrentData()
|
|
{
|
|
// BaseImpl.GetDataTableResult(this.SearchObj.SetSearchSqlValue(this.MoudleObj.MenuSql));
|
|
string sqlValue = this.SearchObj.SetSearchSqlValue(ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql)) ;
|
|
_dtMainTable = BaseImpl.GetDataTableResult(sqlValue);
|
|
|
|
if (_dtMainTable != null && _dtMainTable.Rows.Count > 0)
|
|
{
|
|
//_dtMainTable.OrderBy(this._primaryKey);
|
|
if (!string.IsNullOrEmpty(this._keyValue))
|
|
{
|
|
sqlValue = string.Format("{0}='{1}'", this._primaryKey, this._keyValue);
|
|
DataRow[] dr = _dtMainTable.Select(sqlValue);
|
|
if ((dr != null) && (dr.Length > 0))
|
|
_rowItem = dr[0];
|
|
}
|
|
else
|
|
_rowItem = _dtMainTable.Rows[0];
|
|
this._keyValue = _rowItem[this._primaryKey] + "";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 扫码调用dll
|
|
/// <summary>
|
|
/// <para>说明:获取验证返回操作参数</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void GetMsgParamters(string[] msgs)
|
|
{
|
|
if (msgs[1].Contains("module="))
|
|
{
|
|
string[] paramters = msgs[1].Split('=');
|
|
if (paramters.Length != 2)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ProcNameSettingFault);
|
|
return;
|
|
}
|
|
string[] defaultParams = paramters[1].Split('^');
|
|
if (defaultParams.Length < 4)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ExcuteMoudleFail);
|
|
return;
|
|
}
|
|
string dllName = defaultParams[1];
|
|
string moduleTitle = defaultParams[2];
|
|
string saveState = defaultParams[3];
|
|
if ("lskj.pubadd3.dll".Equals(dllName) || "lskj.pubadd2.dll".Equals(dllName))
|
|
dllName = "Lskj.PubAdd.dll";
|
|
|
|
List<string> paramList = new List<string>();
|
|
for (int i = 4; i < 14; i++)
|
|
{
|
|
paramList.Add(defaultParams.Length > i ? defaultParams[i] : "");
|
|
}
|
|
//执行dll
|
|
string[] str = {
|
|
this.SysModel.FormText,
|
|
ERPInfo.Instance.UserId,
|
|
ERPInfo.Instance.UserName,
|
|
this.SysModel.Privilege,
|
|
this.SysModel.ModuleCode,
|
|
paramList[0],//5 模块编号
|
|
paramList[1],//6 按钮是否可操作
|
|
paramList[2],//7 主键值
|
|
paramList[3],//8 选中树结构Key
|
|
paramList[4],//9 选中树结构Valu
|
|
paramList[5],//10 控件默认带入值
|
|
paramList[6],//11 保存模式
|
|
paramList[7],//12
|
|
paramList[8],//13 获取搜索对象
|
|
paramList[9],//14 获取数据对象
|
|
"",
|
|
"",
|
|
saveState
|
|
};
|
|
IForm form = FormHelper.LoadDllForm(dllName, str);
|
|
if (form == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DyncmicDllNotFount);
|
|
return;
|
|
}
|
|
if (form.SubForm == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DyncmicDllInitFault);
|
|
return;
|
|
}
|
|
form.SubForm.WindowState = FormWindowState.Normal;
|
|
form.SubForm.StartPosition = FormStartPosition.CenterScreen;
|
|
form.SubForm.Text = moduleTitle;
|
|
DialogResult dr = form.SubForm.ShowDialog();
|
|
form.SubForm.Dispose();
|
|
form.SubForm = null;
|
|
form = null;
|
|
GC.Collect();
|
|
|
|
//刷新数据
|
|
//this.SetDetailGridDataSource();
|
|
if(dr== DialogResult.OK) RefreshAll();
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化分割条位置
|
|
/// <summary>
|
|
/// <para>说明:初始化分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-01/para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void InitlizeSpiltLocation()
|
|
{
|
|
try
|
|
{
|
|
//string positionMain = IniHelper.Read(string.Format("base_SplitterPositionMain_{0}", this.SysModel.ModuleCode));
|
|
//if (!string.IsNullOrEmpty(positionMain))
|
|
//{
|
|
// this.splitContainerMain.SplitterPosition = Convert.ToInt32(positionMain);
|
|
//}
|
|
//string positionLeft = IniHelper.Read(string.Format("base_SplitterPositionLeft_{0}", this.SysModel.ModuleCode));
|
|
//if (!string.IsNullOrEmpty(positionLeft))
|
|
//{
|
|
// this.splitContainerLeft.SplitterPosition = Convert.ToInt32(positionLeft);
|
|
//}
|
|
string positionRight = IniHelper.Read(string.Format("base_SplitterPositionRight_{0}", this.SysModel.ModuleCode));
|
|
if (!string.IsNullOrEmpty(positionRight))
|
|
{
|
|
this.splitContainerRight.SplitterPosition = Convert.ToInt32(positionRight);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 文件选取加载
|
|
/// <summary>
|
|
/// <para>说明:文件选择</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void fileComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//MessageBox.Show(SystemInfo.Instance.AttachOpenType.ToString());
|
|
if (SystemInfo.Instance.AttachOpenType == 1)
|
|
{
|
|
this._filePath = PubUtil.FileDownLoadTempPath + this._fileComboBox.TextEdit.Text;
|
|
string serverPath = Path.Combine(SystemInfo.Instance.ServerAttachPath, BaseModuleImpl.GetFileServerPath(this._fileComboBox.TextEdit.Text));
|
|
if (!File.Exists(this._filePath))
|
|
{
|
|
AttachHelper.DownLoadFile(this.Handle, serverPath);
|
|
}
|
|
else
|
|
{
|
|
this._moduleWebView.FrmLoad(serverPath);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string url = SystemInfo.Instance.AttachFileAddress + Uri.EscapeDataString(BaseModuleImpl.GetFileServerPath(this._fileComboBox.TextEdit.Text));
|
|
//MessageBox.Show(url);
|
|
this._moduleWebView.FrmLoad(url);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 下载成功
|
|
/// <summary>
|
|
/// <para>说明:下载成功</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
protected void AttachHelper_OnDownLoadSuccess(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (AttachHelper.IsDefWndProc(this.Handle, (System.Windows.Forms.Message)sender))
|
|
{
|
|
// 加载本地图片
|
|
this._moduleWebView.FrmLoad(this._filePath);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 记录分割条位置
|
|
private void splitContainerRight_SplitterPositionChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this._isInitFinish) IniHelper.Write(string.Format("base_SplitterPositionRight_{0}", this.SysModel.ModuleCode), this.splitContainerRight.SplitterPosition + "");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
//private void splitContainerLeft_SplitterPositionChanged(object sender, EventArgs e)
|
|
//{
|
|
// try
|
|
// {
|
|
// if (this._isInitFinish) IniHelper.Write(string.Format("base_SplitterPositionLeft_{0}", this.SysModel.ModuleCode), this.splitContainerLeft.SplitterPosition + "");
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
// MessageUtil.Show(Message, ex.Message);
|
|
// }
|
|
//}
|
|
//private void splitContainerMain_SplitterPositionChanged(object sender, EventArgs e)
|
|
//{
|
|
// try
|
|
// {
|
|
// if (this._isInitFinish) IniHelper.Write(string.Format("base_SplitterPositionMain_{0}", this.SysModel.ModuleCode), this.splitContainerMain.SplitterPosition + "");
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
// MessageUtil.Show(Message, ex.Message);
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
#region 窗口关闭
|
|
/// <summary>
|
|
/// <para>说明:窗口关闭</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-01</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void FrmMain_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.SysModel != null)
|
|
{
|
|
IniHelper.Write(string.Format("base_height_{0}", this.SysModel.ModuleCode), this.Height + "");
|
|
IniHelper.Write(string.Format("base_width_{0}", this.SysModel.ModuleCode), this.Width + "");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 初始化窗口大小
|
|
/// <summary>
|
|
/// <para>说明:初始化窗口大小</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-05/para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void FrmMain_Resize(object sender, EventArgs e)
|
|
{
|
|
//try
|
|
//{
|
|
// string width = IniHelper.Read(string.Format("base_width_{0}", this.SysModel.ModuleCode));
|
|
// if (!string.IsNullOrEmpty(width))
|
|
// {
|
|
// this.Width = Convert.ToInt32(width);
|
|
// }
|
|
// string height = IniHelper.Read(string.Format("base_height_{0}", this.SysModel.ModuleCode));
|
|
// if (!string.IsNullOrEmpty(height))
|
|
// {
|
|
// this.Height = Convert.ToInt32(height);
|
|
// }
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// //MessageUtil.Show(ex);
|
|
// LogHelper.Instance.WriteError(ex);
|
|
// string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
// MessageUtil.Show(Message, ex.Message);
|
|
//}
|
|
}
|
|
#endregion
|
|
|
|
#region 按钮事件
|
|
/// <summary>
|
|
/// <para>说明:开始执行事件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnStart_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
switch (this.btnStart.Text)
|
|
{
|
|
case "开始":
|
|
CheckCard(1);
|
|
this.btnStart.Text = "暂停";
|
|
break;
|
|
case "暂停":
|
|
CheckCard(2);
|
|
this.btnStart.Text = "开始";
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 键盘事件
|
|
/// <summary>
|
|
/// <para>说明:键盘事件操作</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void Form_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
switch (e.KeyCode)
|
|
{
|
|
case Keys.Enter:
|
|
this.messageInfo.Text = "";
|
|
DataRow dr = tabLeftBottomDetail.GetViewFocusedDataRow();
|
|
string key = dr.Table.Columns.Contains(this._primaryKey) ? dr[_primaryKey].ToString() : string.Empty;
|
|
if (!string.IsNullOrEmpty(key)) CheckCard(0);
|
|
InitCardInputBox();
|
|
break;
|
|
case Keys.Up:
|
|
if (_dataIndex > 0)
|
|
{
|
|
--_dataIndex;
|
|
LoadNewForm(_dataIndex);
|
|
this.messageInfo.Text = "";
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.BeforeNotData);
|
|
}
|
|
break;
|
|
case Keys.Down:
|
|
if (_dataIndex < _dtMainTable.Rows.Count - 1)
|
|
{
|
|
++_dataIndex;
|
|
LoadNewForm(_dataIndex);
|
|
this.messageInfo.Text = "";
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.AfterNotData);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 固定搜索事件
|
|
/// <summary>
|
|
/// <para>说明:固定搜索事件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string sqlWhere = string.Format("{0} like '%{1}%", this.cbField.SelectedValue, this.txtFixKey.Text);
|
|
DataRow[] rows = _dtMainTable.Select(sqlWhere);
|
|
if (rows.Length > 0) LoadNewForm(_dtMainTable.Rows.IndexOf(rows[0]));
|
|
this.ControlObj.SetAllControlValue(_rowItem);
|
|
textBox.Focus();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 自定义搜索事件
|
|
/// <summary>
|
|
/// <para>说明:初始化自定义搜索</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SearchObj_OnSearchBefore(object sender, SearchArgs e)
|
|
{
|
|
try
|
|
{
|
|
this._rowItem = MainImpl.GetDataRowResult(this.SearchObj.SetSearchSqlValue(this.MoudleObj.MenuSql));
|
|
this._dtMainTable = BaseImpl.GetDataTableResult(this.SearchObj.SetSearchSqlValue(this.MoudleObj.MenuSql));
|
|
|
|
if (this._rowItem != null)
|
|
{
|
|
this._keyValue = this._rowItem[this._primaryKey] + "";
|
|
//三部分明细数据源更新
|
|
//setTabPageGridData(tabLeftTopDetail, this._rowItem);
|
|
//setTabPageGridData(tabLeftBottomDetail, this._rowItem);
|
|
|
|
|
|
this.tabLeftBottomDetail.SetGridViewDataSource(_dtMainTable);
|
|
|
|
//setTabPageGridData(tabRightDetail, this._rowItem);
|
|
//this.ControlObj.SetAllControlValue(this._rowItem);
|
|
//初始化附件菜单
|
|
InitComboxItem(this._rowItem);
|
|
SetTabPageStyle();
|
|
this.InitCardInputBox();
|
|
}
|
|
else {
|
|
//this.tabLeftBottomDetail.SetGridViewDataSource(new DataTable());
|
|
}
|
|
this.textBox.Focus();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 提交事件
|
|
/// <summary>
|
|
/// <para>说明:按键提交验证</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
CheckCard(3);
|
|
//卡号输入框重置
|
|
InitCardInputBox();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 消息处理
|
|
/// <summary>
|
|
/// <para>说明:消息处理</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="m">要处理的 Windows<see cref="T:System.Windows.Forms.Message" />。</param>
|
|
protected override void DefWndProc(ref Message m)
|
|
{
|
|
base.DefWndProc(ref m);
|
|
|
|
if (this.Handle == m.HWnd)
|
|
AttachHelper.DefWndProc(m);
|
|
}
|
|
#endregion
|
|
|
|
private void simpleButton2_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WebBrowserUtil.StartWebBrowser(this.SysModel.ModuleCode, this.MoudleObj.MenuText);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:加载明细数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-09-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
protected void GridView_RowCellClick(object sender, RowCellClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("加载明细数据失败!" + Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:获取底部多标签数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-19 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void SetDetailGridDataSource(XtraTabPage tabPage = null)
|
|
{
|
|
if (tabPage != null)
|
|
{
|
|
this.SetTabPageDataSource(tabPage);
|
|
}
|
|
else
|
|
{
|
|
DataRow rowItem = tabLeftBottomDetail.GetViewFocusedDataRow();
|
|
bool RefreshDetail = true;
|
|
if (RefreshDetail)
|
|
{
|
|
XtraTabPage RefreshPage = tabRightDetail.TabControlObj.SelectedTabPage;
|
|
if (rowItem != null && RefreshPage != null)
|
|
{
|
|
this.SetTabPageDataSource(RefreshPage);
|
|
}
|
|
else
|
|
{
|
|
SetTabPageDataSource(RefreshPage, true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (XtraTabPage page in tabRightDetail.TabControlObj.TabPages)
|
|
{
|
|
|
|
if (rowItem != null && page != null)
|
|
{
|
|
this.SetTabPageDataSource(page);
|
|
}
|
|
else
|
|
{
|
|
SetTabPageDataSource(page, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tabPage">The tab page.</param>
|
|
/// <param name="gridControl">The grid control.</param>
|
|
protected void SetTabPageDataSource(XtraTabPage tabPage, bool isNull = false)
|
|
{
|
|
if (isNull)
|
|
{
|
|
this.tabRightDetail.SetGridDataSource(tabPage, new DataTable());
|
|
return;
|
|
}
|
|
GridDetailModel model = this.tabRightDetail.GetGridDetailModel(tabPage);
|
|
DataRow rowItem = tabLeftBottomDetail.GetViewFocusedDataRow();
|
|
if (rowItem != null && model != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(model.UnionModule) && (string.IsNullOrEmpty(model.UnionValue) && string.IsNullOrEmpty(model.UnionCond))) return;
|
|
if (tabPage.Tag is FrmWebBrowser)
|
|
{
|
|
// 加载网页
|
|
string url = model.DetailSql.StartsWith("http") ? model.DetailSql : SystemInfo.Instance.OAUrl + model.DetailSql;
|
|
FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser;
|
|
webView.LoadUrl(ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(url)));
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
}
|
|
else
|
|
{
|
|
string searchSql = this.GetSearchSql(model, rowItem);
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
(tabPage.Tag as GridControlEx).LastSearchSql = searchSql;
|
|
}
|
|
GridView view = tabLeftBottomDetail.GridView;
|
|
this.tabRightDetail.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(searchSql), view);
|
|
if (tabPage.Tag is GridControlEx && (tabPage.Tag as GridControlEx).ParentControl != null)
|
|
(tabPage.Tag as GridControlEx).ParentControl.SetAllControlValue(rowItem);
|
|
//配置明细直接根据条件加载
|
|
if (model.SystemModel != null && 1 == model.SystemModel.isFirstLoad)
|
|
{
|
|
(tabPage.Tag as GridControlEx).ParentControl.SearchGrid();
|
|
tabPage.Text = model.DetailName + "(" + (tabPage.Tag as GridControlEx).ParentControl.GridRowCount + "条)";
|
|
}
|
|
}
|
|
}
|
|
else if (rowItem != null && tabPage.Tag is TabMultipledetails)
|
|
{
|
|
TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails;
|
|
GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx);
|
|
GridControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx);
|
|
GridDetailModel MainModel = grdExMain.Tag as GridDetailModel;
|
|
GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel;
|
|
string searchMainSql = this.GetSearchSql(MainModel, rowItem);
|
|
string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem);
|
|
DataTable firstTable = MainImpl.GetDataTableResult(searchMainSql);
|
|
grdExMain.LastSearchSql = searchMainSql;
|
|
grdExAdditional.LastSearchSql = searchAddSql;
|
|
grdExMain.SetGridViewDataSource(firstTable);
|
|
tabPage.Text = MainModel.DetailName + "(" + firstTable.Rows.Count + "条)";
|
|
grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql));
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewRightCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
RefreshAll();
|
|
//int oldRowHandle = tabLeftBottomDetail.GridView.FocusedRowHandle;
|
|
//DataTable dt = this.tabLeftBottomDetail.GridView.GetGridViewFilteredAndSortedDataToDataTable();
|
|
//DataRow SelectTheLine = tabLeftBottomDetail is TreeGridControlEx ? (tabLeftBottomDetail as TreeGridControlEx).GetViewFocusedDataRow() : dt.Rows[oldRowHandle];
|
|
//this.SearchObj.RememberRow = (this.MoudleObj.AccordingNameSelected == 0);
|
|
//this.SearchObj.SearchLastGrid();
|
|
//if (this.MoudleObj.AccordingNameSelected != 0)//根据主键刷新目标选中行
|
|
//{
|
|
// // DataRow items = dt.Rows.Cast<DataRow>().FirstOrDefault(x => x[ParmaryKey].Equals(SelectTheLine[ParmaryKey]));
|
|
// dt = this.tabLeftBottomDetail.GridView.GetGridViewFilteredAndSortedDataToDataTable();
|
|
// BindingSource bindingSource = new BindingSource();
|
|
// bindingSource.DataSource = dt;
|
|
// int numberOfRows = bindingSource.Find(MoudleObj.ParmaryKey, SelectTheLine[MoudleObj.ParmaryKey].ToString());
|
|
// this.tabLeftBottomDetail.GridView.ClearSelection();
|
|
// this.tabLeftBottomDetail.GridView.FocusedRowHandle = numberOfRows;
|
|
// this.tabLeftBottomDetail.GridView.SelectRow(numberOfRows);
|
|
//}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:加载新的数据(用于上下键翻页刷新和搜索)</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="Index">数据索引</param>
|
|
private void RefreshAll()
|
|
{
|
|
int oldRowHandle = tabLeftBottomDetail.GridView.FocusedRowHandle;
|
|
this._dtMainTable = BaseImpl.GetDataTableResult(this.SearchObj.SetSearchSqlValue(ReplaceHelper.ReplaceWhereCond(this.MoudleObj.MenuSql)));
|
|
this.tabLeftBottomDetail.SetGridViewDataSource(_dtMainTable);
|
|
this.tabLeftBottomDetail.GridView.FocusedRowHandle=oldRowHandle;
|
|
if (_dtMainTable != null && _dtMainTable.Rows.Count > oldRowHandle)
|
|
{
|
|
DataRow dataRowItem = _dtMainTable.Rows[oldRowHandle];
|
|
setTabPageGridData(tabRightDetail, dataRowItem);
|
|
}
|
|
|
|
//this.ControlObj.SetAllControlValue(dataRowItem);
|
|
//this._keyValue = dataRowItem[this._primaryKey] + "";
|
|
InitCardInputBox();
|
|
}
|
|
|
|
}
|
|
}
|