5e7945767d
SVN-Revision: r754
1301 lines
55 KiB
C#
1301 lines
55 KiB
C#
/******************************
|
|
* 说明:顶部为表格、底部为多标签内容模版(适用于基础档案上下模版、报表上下模版、单据审批模版)
|
|
* 创建人:龚宇超
|
|
* 创建日期:2017-11-21
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraTab;
|
|
using Lskj.Model;
|
|
using Lskj.Data;
|
|
using Lskj.Control.Model;
|
|
using DevExpress.XtraEditors;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Util;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using Lskj.Business;
|
|
using DevExpress.Utils;
|
|
using System.Diagnostics;
|
|
using Lskj.Core;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using System.Collections;
|
|
|
|
namespace Lskj.Control
|
|
{
|
|
/// <summary>
|
|
/// 顶部为表格、底部为多标签内容模版
|
|
/// </summary>
|
|
public partial class ModuleGridDetailEx : UserControl
|
|
{
|
|
/// <summary>
|
|
/// 系统模块实体对象
|
|
/// </summary>
|
|
/// <value>The system model.</value>
|
|
public ModuleModel SysModel { get; private set; }
|
|
/// <summary>
|
|
/// 调用动态链接库默认传递参数对象
|
|
/// </summary>
|
|
public DynamicModel Model { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets a value indicating whether [visible detail panel].
|
|
/// </summary>
|
|
/// <value><c>true</c> if [visible detail panel]; otherwise, <c>false</c>.</value>
|
|
public bool VisibleDetailPanel
|
|
{
|
|
get
|
|
{
|
|
return this.scc_container.PanelVisibility == SplitPanelVisibility.Both;
|
|
}
|
|
set
|
|
{
|
|
this.scc_container.PanelVisibility = value ? SplitPanelVisibility.Both : SplitPanelVisibility.Panel1;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 是否为拖拽明细模式
|
|
/// </summary>
|
|
public bool IsDragDetail;
|
|
/// <summary>
|
|
/// 底部多标签表格数据
|
|
/// </summary>
|
|
public List<GridDetailModel> GridDetailList;
|
|
/// <summary>
|
|
/// 左边查询条件
|
|
/// </summary>
|
|
public MyControl _leftGridSearchObj;
|
|
/// <summary>
|
|
/// 查询条件
|
|
/// </summary>
|
|
/// <value>The search object.</value>
|
|
public MyControl SearchObj { get { return this.mg_control.SearchObj; } }
|
|
/// <summary>
|
|
/// 顶部表格控件
|
|
/// </summary>
|
|
public ModuleGridEx ModuleGridObj { get { return this.mg_control; } }
|
|
/// <summary>
|
|
/// 底部多标签控件
|
|
/// </summary>
|
|
public XtraTabControl TabObj { get { return this.tcButtom.TabControlObj; } }
|
|
|
|
/// <summary>
|
|
/// 多标签,标签内容包含表格和图表
|
|
/// </summary>
|
|
public TabControlEx TcButtom { get { return this.tcButtom; } }
|
|
/// <summary>
|
|
/// 底部容器
|
|
/// </summary>
|
|
/// <value>The container object.</value>
|
|
public PanelControl BottomPanel { get { return this.pl_bottom; } }
|
|
/// <summary>
|
|
/// 是否只刷新当前选中明细
|
|
/// </summary>
|
|
/// <value>The container object.</value>
|
|
public bool RefreshDetail = false;
|
|
/// <summary>
|
|
/// 右键执行后是否刷新全部明细
|
|
/// </summary>
|
|
/// <value>The container object.</value>
|
|
public bool callRefreshDetail = false;
|
|
/// <summary>
|
|
/// 是否已经执行行改变事件并刷新明细数据
|
|
/// </summary>
|
|
public bool isFocusedRowChanged = true;
|
|
/// <summary>
|
|
/// 高效验证后,取消切换选中行
|
|
/// </summary>
|
|
public bool CancelSwitchingRow = false;
|
|
/// <summary>
|
|
/// 上一次选中行
|
|
/// </summary>
|
|
public int LastFocusedRowHandle;
|
|
|
|
/// <summary>
|
|
/// 主表格行点击事件回调
|
|
/// </summary>
|
|
public event EventHandler OnGridViewRowClickCallBack;
|
|
|
|
/// <summary>
|
|
/// 是否为主表汇总模式
|
|
/// </summary>
|
|
public bool IsDynamicDetailType = false;
|
|
public ModuleGridDetailEx()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuRow">The menu row.</param>
|
|
public void InitializeControl(ModuleModel sysModel, DynamicModel dyncModel)
|
|
{
|
|
try
|
|
{
|
|
if (sysModel != null && dyncModel != null)
|
|
{
|
|
this.SysModel = sysModel;//系统模块实体对象
|
|
this.Model = dyncModel;//调用动态链接库默认传递参数对象
|
|
Console.WriteLine(DateTime.Now);
|
|
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
dataCaches.GetValue(this, "DataCaches", out bool _);//等待缓存数据加载完成
|
|
if (SysModel.isLeftRightMode) this.scc_container.Horizontal = true;
|
|
// 初始化顶部GridView
|
|
this.ModuleGridObj._leftGridSearchObj = _leftGridSearchObj;// 顶部表格控件
|
|
|
|
this.ModuleGridObj.TabObj = TabObj;
|
|
this.ModuleGridObj.InitializeControl(sysModel, dyncModel);
|
|
|
|
this.ModuleGridObj.AfterRefreshingCallBack += ModuleGridObj_AfterRefreshingCallBack;
|
|
//this.ModuleGridObj.verifyDetailsTab += ModuleGridObj_verifyDetailsTab;//未启用
|
|
|
|
RefreshDetail = this.SysModel.RefreshDetail == "0";
|
|
callRefreshDetail = this.SysModel.callRefreshDetail;
|
|
Console.WriteLine(DateTime.Now);
|
|
this.IsDynamicDetailType = !string.IsNullOrEmpty(SysModel.MainModuleCodeField) && this.ModuleGridObj.GridControlObj.GridView.Columns.ColumnByFieldName(SysModel.MainModuleCodeField) != null;
|
|
if (IsDynamicDetailType)
|
|
{
|
|
InitializeDynamicPages();
|
|
}
|
|
else
|
|
{
|
|
// 初始化底部多标签
|
|
this.InitializePages();
|
|
}
|
|
Console.WriteLine(DateTime.Now);
|
|
//tcButtom.TabControlObj.ShowTabHeader = tcButtom.TabControlObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.MenuCodeIsNotNull);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
//throw;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取数据源缓存
|
|
/// </summary>
|
|
/// <param name="cachesDic"></param>
|
|
/// <param name="sysModel"></param>
|
|
/// <param name="dynamicModel"></param>
|
|
public void GetDataCaches(Dictionary<object, Hashtable> cachesDic)
|
|
{
|
|
//获取通用数据
|
|
Task<ModuleModel> sysModelTask = cachesDic.GetTask<ModuleModel>(this, "SysModel");
|
|
Task<DynamicModel> dynamicModelTask = cachesDic.GetTask<DynamicModel>(this, "DynamicModel");
|
|
Task<List<GridDetailModel>> detailsTask = cachesDic.GetTask<List<GridDetailModel>>(this, "Details");
|
|
ModuleGridObj._leftGridSearchObj = _leftGridSearchObj;
|
|
Task<bool> getDataCachesTask = cachesDic.AddTask(this, "DataCaches", new Task<bool>(() =>
|
|
{
|
|
ModuleModel sysModel = sysModelTask.Result;
|
|
DynamicModel dynamicModel = dynamicModelTask.Result;
|
|
if (sysModel != null && dynamicModel != null)
|
|
{
|
|
cachesDic.AddTask(ModuleGridObj, "DynamicModel", dynamicModelTask);
|
|
cachesDic.AddTask(ModuleGridObj, "SysModel", sysModelTask);
|
|
this.ModuleGridObj.GetDataCaches(cachesDic);
|
|
if (!string.IsNullOrEmpty(sysModel.MainModuleCodeField) && this.ModuleGridObj.GridControlObj.GridView.Columns.ColumnByFieldName(sysModel.MainModuleCodeField) != null)
|
|
{
|
|
//InitializeDynamicPages();
|
|
}
|
|
else
|
|
{
|
|
//添加数据到mControl
|
|
cachesDic.AddTask(tcButtom, "DynamicModel", dynamicModelTask);
|
|
cachesDic.AddTask(tcButtom, "Details", detailsTask);
|
|
// 初始化底部多标签
|
|
this.tcButtom.GetDataCaches(cachesDic);
|
|
}
|
|
}
|
|
return true;
|
|
}));
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:初始化底部多标签数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void InitializePages()
|
|
{
|
|
if (this.GridDetailList == null || this.GridDetailList.Count == 0)
|
|
{
|
|
this.scc_container.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
}
|
|
else
|
|
{
|
|
this.InitlizeSpiltLocation();
|
|
this.InitilizeGridViewEvent();
|
|
|
|
//下方明细中ModuleGridEx执行右键后是否刷新明细
|
|
if (this.SysModel.RefreshDetails)
|
|
{
|
|
tcButtom.OnDetailRightCallback += OnGridViewRightCallBack;
|
|
}
|
|
|
|
this.tcButtom.Model = this.Model;
|
|
this.tcButtom.DrgaParentPrimaryKey = this.SysModel.ParmaryKey;
|
|
this.tcButtom.IsDragDetail = this.IsDragDetail;
|
|
this.tcButtom.ParentControlEx = this.SearchObj;
|
|
this.tcButtom.ParentGridEx = this.ModuleGridObj.GridControlObj;
|
|
this.tcButtom.InitTabPages(this.GridDetailList);
|
|
this.tcButtom.OnRightCallback += new EventHandler(OnGridViewRightCallBack);
|
|
|
|
|
|
//明细只有一个选项卡时是否隐藏
|
|
if (SystemInfo.Instance.HidingIndividualDetails)
|
|
{
|
|
this.TabObj.ShowTabHeader = this.TabObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 动态明细模式下,初始化底部多标签数据
|
|
/// </summary>
|
|
protected void InitializeDynamicPages()
|
|
{
|
|
this.InitlizeSpiltLocation();
|
|
this.InitilizeGridViewEvent();
|
|
|
|
//下方明细中ModuleGridEx执行右键后是否刷新明细
|
|
if (this.SysModel.RefreshDetails)
|
|
{
|
|
tcButtom.OnDetailRightCallback += OnGridViewRightCallBack;
|
|
}
|
|
|
|
this.tcButtom.Model = this.Model;
|
|
this.tcButtom.DrgaParentPrimaryKey = this.SysModel.ParmaryKey;
|
|
this.tcButtom.IsDragDetail = this.IsDragDetail;
|
|
this.tcButtom.ParentGridEx = this.ModuleGridObj.GridControlObj;
|
|
//this.tcButtom.InitTabPages(this.GridDetailList);
|
|
this.tcButtom.OnRightCallback += new EventHandler(OnGridViewRightCallBack);
|
|
|
|
//明细只有一个选项卡时是否隐藏
|
|
if (SystemInfo.Instance.HidingIndividualDetails)
|
|
{
|
|
this.TabObj.ShowTabHeader = this.TabObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void InitlizeSpiltLocation()
|
|
{
|
|
try
|
|
{
|
|
string htight = IniHelper.Read(string.Format("base_height_{0}", this.Model.ModuleCode));
|
|
if (!string.IsNullOrEmpty(htight))
|
|
{
|
|
this.scc_container.SplitterPosition = Convert.ToInt32(htight);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:绑定事件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void InitilizeGridViewEvent()
|
|
{
|
|
if (this.IsDragDetail)
|
|
{
|
|
// 拖拽模式
|
|
|
|
}
|
|
else
|
|
{
|
|
// 非拖拽模式
|
|
if (Model.IsBaseModule)
|
|
{
|
|
if (this.ModuleGridObj.GridControlObj is TreeGridControlEx)
|
|
{
|
|
(this.ModuleGridObj.GridControlObj as TreeGridControlEx).TreeListObj.FocusedNodeChanged += OnFocusedNodeChanged;
|
|
}
|
|
if (this.SysModel.DoubleClickDetail)
|
|
{
|
|
//双击刷新的话,和行改变事件冲突。
|
|
this.ModuleGridObj.GridControlObj.GridView.DoubleClick += new EventHandler(GridView_DoubleClick);
|
|
this.SearchObj.OnSearchAfterCallBack += SearchObj_ClearDetails_DoubleMode;
|
|
this.SearchObj.OnLastQueryTriggered += SearchObj_ClearDetails_DoubleMode;
|
|
}
|
|
else
|
|
{
|
|
if (this.SysModel.bandRowClickEvent == 1)
|
|
{
|
|
//this.ModuleGridObj.GridControlObj.GridView.RowCellClick += new RowCellClickEventHandler(GridView_RowCellClick);
|
|
this.ModuleGridObj.GridControlObj.GridView.MouseDown += new MouseEventHandler(GridView_MouseDown);
|
|
}
|
|
else
|
|
{
|
|
this.ModuleGridObj.GridControlObj.GridView.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(OnGridViewFocusedRowObjectChanged);
|
|
//this.ModuleGridObj.GridControlObj.GridView.RowCellClick += new RowCellClickEventHandler(GridView_RowCellClick);
|
|
this.ModuleGridObj.GridControlObj.GridView.MouseDown += new MouseEventHandler(GridView_MouseDown);
|
|
|
|
this.SearchObj.OnSearchAfterCallBack += SearchObj_ClearDetails;
|
|
this.SearchObj.OnLastQueryTriggered += SearchObj_ClearDetails;
|
|
//this.ModuleGridObj.GridControlObj.GridView.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(OnGridViewFocusedRowChanged);
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (this.ModuleGridObj.GridControlObj is TreeGridControlEx)
|
|
{
|
|
(this.ModuleGridObj.GridControlObj as TreeGridControlEx).TreeListObj.FocusedNodeChanged += OnFocusedNodeChanged;
|
|
}
|
|
if (SystemInfo.Instance.ReportMainTabClickRefresh)
|
|
{
|
|
if (this.SysModel.DoubleClickDetail)
|
|
{
|
|
//全局变量和模块属性冲突的话,以模块设置的为准
|
|
this.ModuleGridObj.GridControlObj.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);
|
|
}
|
|
else
|
|
{
|
|
this.ModuleGridObj.GridControlObj.GridView.Click += new EventHandler(OnGridViewDoubleClick);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.ModuleGridObj.GridControlObj.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <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 = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
|
|
if (RefreshDetail)
|
|
{
|
|
XtraTabPage RefreshPage = this.TabObj.SelectedTabPage;
|
|
if (rowItem != null && RefreshPage != null)
|
|
{
|
|
this.SetTabPageDataSource(RefreshPage);
|
|
}
|
|
else
|
|
{
|
|
SetTabPageDataSource(RefreshPage, true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (XtraTabPage page in this.TabObj.TabPages)
|
|
{
|
|
|
|
if (rowItem != null && page != null)
|
|
{
|
|
this.SetTabPageDataSource(page);
|
|
}
|
|
else
|
|
{
|
|
SetTabPageDataSource(page, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (this.OnGridViewRowClickCallBack != null)
|
|
this.OnGridViewRowClickCallBack(this.ModuleGridObj.GridControlObj, null);
|
|
}
|
|
/// <summary>
|
|
/// 动态明细模式下,获取底部多标签数据
|
|
/// </summary>
|
|
/// <param name="tabPage"></param>
|
|
public void DynamicSetDetailGridDataSource(XtraTabPage tabPage = null)
|
|
{
|
|
if (tabPage != null)
|
|
{
|
|
this.SetTabPageDataSource(tabPage);
|
|
}
|
|
else
|
|
{
|
|
DataRow rowItem = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
|
|
string mainModuleCode = (rowItem[SysModel.MainModuleCodeField] + "").ToLower();
|
|
//mainModuleCode = String.Empty;
|
|
this.TabObj.TabPages.Clear();
|
|
//if (string.IsNullOrWhiteSpace(mainModuleCode)) return;
|
|
if (!string.IsNullOrWhiteSpace(mainModuleCode) && this.tcButtom.DetailTabPagesDic.ContainsKey(mainModuleCode))
|
|
{
|
|
List<DetailTabPageModel> details = new List<DetailTabPageModel>();
|
|
details = this.tcButtom.DetailTabPagesDic[mainModuleCode].OrderBy(n => n.TabPageIndex).ToList();
|
|
foreach (DetailTabPageModel item in details)
|
|
{
|
|
this.TabObj.TabPages.Add(item.DetailTabPage);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
List<GridDetailModel> gridDetailModels = new List<GridDetailModel>();
|
|
DataTable detailTab = BaseModuleImpl.GetBaseDetailPages(mainModuleCode);
|
|
foreach (DataRow item in detailTab.Rows)
|
|
{
|
|
DataTable gridColumns = ReportImpl.GetReportDetailColumns(mainModuleCode, item["id"] + "");
|
|
gridDetailModels.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
this.tcButtom.InitTabPages(gridDetailModels);
|
|
}
|
|
bool isLoadAttach = rowItem.Table.Columns.Contains("P_PlmIsBX") && "1" == rowItem["P_PlmIsBX"] + "";
|
|
if (!string.IsNullOrWhiteSpace(this.SysModel.AttachDetail) && isLoadAttach)
|
|
{
|
|
List<GridDetailModel> attachDetailModels = new List<GridDetailModel>();
|
|
DataTable AttachdelTab = BaseModuleImpl.GetBaseDetailPages(this.SysModel.AttachDetail);
|
|
foreach (DataRow item in AttachdelTab.Rows)
|
|
{
|
|
DataTable gridColumns = ReportImpl.GetReportDetailColumns(mainModuleCode, item["id"] + "");
|
|
attachDetailModels.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
this.tcButtom.InitTabPages(attachDetailModels, true, true);
|
|
}
|
|
if (RefreshDetail)
|
|
{
|
|
XtraTabPage RefreshPage = this.TabObj.SelectedTabPage;
|
|
if (rowItem != null && RefreshPage != null)
|
|
{
|
|
this.SetTabPageDataSource(RefreshPage);
|
|
}
|
|
else
|
|
{
|
|
SetTabPageDataSource(RefreshPage, true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (XtraTabPage page in this.TabObj.TabPages)
|
|
{
|
|
if (rowItem != null && page != null)
|
|
{
|
|
this.SetTabPageDataSource(page);
|
|
}
|
|
else
|
|
{
|
|
SetTabPageDataSource(page, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (this.OnGridViewRowClickCallBack != null)
|
|
this.OnGridViewRowClickCallBack(this.ModuleGridObj.GridControlObj, null);
|
|
if (this.TabObj == null || this.TabObj.TabPages.Count == 0)
|
|
{
|
|
this.scc_container.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
}
|
|
else if (this.TabObj != null && this.TabObj.TabPages.Count > 0 && this.ModuleGridObj.GridControlObj.DataRowCount() > 0)
|
|
{
|
|
this.scc_container.PanelVisibility = SplitPanelVisibility.Both;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:拖拽模式获取底部多标签数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-12-19 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void SetDetailGridDataSource(string where, bool isTree, TreeViewEx treeViewEx, GridControlEx gridControlEx)
|
|
{
|
|
foreach (XtraTabPage tabPage in this.TabObj.TabPages)
|
|
{
|
|
GridDetailModel model = this.tcButtom.GetGridDetailModel(tabPage);
|
|
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
|
if (isTree)
|
|
{
|
|
// 左侧为树,查询数据则追加条件
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
sqlValue = ReplaceHelper.IsProcedure(sqlValue) ?
|
|
ReplaceHelper.ReplaceTreeViewParentKeyCond(sqlValue, treeViewEx.GetSelectNodeValue()) :
|
|
sqlValue + where;
|
|
(tabPage.Tag as GridControlEx).LastSearchSql = sqlValue;
|
|
}
|
|
this.tcButtom.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(sqlValue));
|
|
}
|
|
else
|
|
{
|
|
if (gridControlEx is TreeGridControlEx) return;
|
|
// 左侧为表格,查询数据则替换选中行数据
|
|
DataRow rowItem = gridControlEx.GridView.GetFocusedDataRow();
|
|
string searchSql = this.GetSearchSql(model, rowItem, true);
|
|
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
(tabPage.Tag as GridControlEx).LastSearchSql = searchSql;
|
|
}
|
|
this.tcButtom.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(searchSql));
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
/// <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)
|
|
{
|
|
GridDetailModel model = this.tcButtom.GetGridDetailModel(tabPage);
|
|
if (isNull)
|
|
{
|
|
DataRow leftrow = _leftGridSearchObj!=null?_leftGridSearchObj.MainGridEx.GetViewFocusedDataRow():null;
|
|
if (model.IsUnionleft&& leftrow!=null)//为空状态下若明细关联左侧则去替换数据源
|
|
{
|
|
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
|
|
|
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
|
{
|
|
string Conditions = string.Empty;
|
|
//是左侧选中行,并且没有替换字段,则使用主表选中行
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, Conditions);
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(model.UnionCond))
|
|
{
|
|
string UnionCond = ReplaceHelper.ReplaceRowParam(leftrow, model.UnionCond);
|
|
sqlValue += UnionCond;
|
|
}
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(leftrow, sqlValue);
|
|
this.tcButtom.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(sqlValue));
|
|
return;
|
|
}
|
|
this.tcButtom.SetGridDataSource(tabPage, new DataTable());
|
|
return;
|
|
}
|
|
|
|
DataRow rowItem = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
|
|
if (!string.IsNullOrEmpty(SysModel.PageVisbleCond))
|
|
{
|
|
string condSql = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(SysModel.PageVisbleCond));
|
|
// 形如 "1,2,3" 的返回值
|
|
string numberList = MainImpl.GetResult(condSql) + "";
|
|
|
|
// ---------- 判断当前 orderid 是否在列表中 ----------
|
|
string orderIdStr = model.Orderid.ToString(); // 统一转成字符串
|
|
string[] idArr = numberList.Split(new[] { ',' },
|
|
StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
if (!string.IsNullOrEmpty(numberList) && !idArr.Contains(orderIdStr))
|
|
{
|
|
tabPage.PageVisible = false;
|
|
return; // 不包含当前 orderid,直接退出
|
|
}
|
|
else
|
|
{
|
|
tabPage.PageVisible = true;
|
|
}
|
|
}
|
|
|
|
|
|
if (IsDynamicDetailType)
|
|
{
|
|
//string mainModuleCode = model.ParentModuleCode;
|
|
//ModuleModel mainModuleModel = new ModuleModel(MainImpl.GetSystemdllTab(model.ParentModuleCode));
|
|
//mainModuleModel.ParmaryKey = BaseImpl.GetBasePrimaryKey(model.ParentModuleCode);
|
|
//string sqlValue = mainModuleModel.MenuSql;
|
|
//sqlValue = ReplaceHelper.ReplaceUserInfo(sqlValue);
|
|
//sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue);
|
|
//string selectMainRowSql = string.Format(sqlValue + " and {0}='{1}'", mainModuleModel.ParmaryKey, rowItem[model.SystemModel.ParmaryKey] + "");
|
|
//rowItem = MainImpl.GetDataRowResult(selectMainRowSql);
|
|
}
|
|
Object moduleObject = tabPage.Controls.Cast<Object>().FirstOrDefault();
|
|
ModuleGridEx moduleGridEx = null;
|
|
if (moduleObject is ModuleGridEx)
|
|
{
|
|
moduleGridEx = moduleObject as ModuleGridEx;
|
|
if (this.SysModel.RefreshTheInterface)//
|
|
{
|
|
moduleGridEx.OnSaveGridCallBack -= OnSaveGridCallBack;
|
|
moduleGridEx.OnSaveGridCallBack += OnSaveGridCallBack;
|
|
}
|
|
}
|
|
if (rowItem != null && model != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(model.UnionModule) && (string.IsNullOrEmpty(model.UnionValue) && string.IsNullOrEmpty(model.UnionCond))) return;
|
|
if (tabPage.Tag is FrmWebBrowser)
|
|
{
|
|
// 加载网页
|
|
FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser;
|
|
string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
|
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
|
//webView.FrmLoad(url);
|
|
webView.LoadUrl(url);
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
}
|
|
else if (tabPage.Tag is FrmWebBrowser2)
|
|
{
|
|
// 加载网页
|
|
FrmWebBrowser2 webView = tabPage.Tag as FrmWebBrowser2;
|
|
string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
|
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
|
webView.LoadUrl(url);
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
}
|
|
else if (tabPage.Tag is FrmMiniBlink)
|
|
{
|
|
// 加载网页
|
|
FrmMiniBlink webView = tabPage.Tag as FrmMiniBlink;
|
|
string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
|
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
|
webView.LoadUrl(url);
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
}
|
|
else if (tabPage.Tag is TabMultipledetails)
|
|
{
|
|
TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails;
|
|
tabMultipledetails.SetConditionValues(rowItem);
|
|
GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx);
|
|
GridDetailModel MainModel = grdExMain.Tag as GridDetailModel;
|
|
string searchMainSql = this.GetSearchSql(MainModel, rowItem);
|
|
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 = this.GetSearchSql(AdditionalModel, rowItem);
|
|
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, rowItem);
|
|
DataTable table = MainImpl.GetDataTableResult(searchAddSql);
|
|
grdExAdditional.CreateChart(table);
|
|
}
|
|
|
|
tabPage.Text = MainModel.DetailName + "(" + firstTable.Rows.Count + "条)";
|
|
tabPage.Appearance.Header.ForeColor = firstTable.Rows.Count > 0 ? Color.Red : Color.FromArgb(0, 0, 0);
|
|
}
|
|
else
|
|
{
|
|
if (model.IsDrag)
|
|
{
|
|
return;
|
|
}
|
|
string searchSql = this.GetSearchSql(model, rowItem);
|
|
//if (moduleGridEx != null&& moduleGridEx.SearchObj!=null)
|
|
//{
|
|
// searchSql= moduleGridEx.SearchObj.SetSearchSqlValue(searchSql);
|
|
//}
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
(tabPage.Tag as GridControlEx).LastSearchSql = searchSql;
|
|
}
|
|
GridView view = this.ModuleGridObj.GridControlObj.GridView;
|
|
//DataTable dataTable = MainImpl.GetDataTableResult(searchSql);//明细数据源
|
|
if (model.DynamicDetails && rowItem.Table.Columns.Contains("DisplayColumns")) //
|
|
{
|
|
this.tcButtom.SetGridDisplayColumns(tabPage, rowItem["DisplayColumns"] + "");
|
|
}
|
|
this.tcButtom.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 + "条)";
|
|
}
|
|
|
|
}
|
|
if (moduleGridEx != null)
|
|
{
|
|
moduleGridEx.ParentButtonState(rowItem);
|
|
moduleGridEx.SelectTheSpecifiedRow();
|
|
//主表,页签中的表格都设置了复选框,并且为第一个页签
|
|
//if (this.ModuleGridObj.GridControlObj.GridView.OptionsSelection.MultiSelect == true && moduleGridEx.GridControlObj.GridView.OptionsSelection.MultiSelect == true && this.TabObj.TabPages[0] == tabPage)
|
|
//{
|
|
// if (this.SearchObj.DetailSelection.ContainsKey(model.DetailName))
|
|
// {
|
|
// Dictionary<DataRow, string> dictionary = this.SearchObj.DetailSelection[model.DetailName];
|
|
// if (dictionary.ContainsKey(rowItem))
|
|
// {
|
|
// DataTable dataTable = moduleGridEx.GridControlObj.GridControl.DataSource as DataTable;
|
|
// string value = dictionary[rowItem];
|
|
// for (int rowHandle = 0; rowHandle < moduleGridEx.GridControlObj.GridView.RowCount; rowHandle++)
|
|
// {
|
|
// string cellValue = moduleGridEx.GridControlObj.GridView.GetRowCellValue(rowHandle, moduleGridEx.ParmaryKey) + "";
|
|
// if (value.Split(',').Contains(cellValue))
|
|
// {
|
|
// moduleGridEx.GridControlObj.GridView.SelectRow(rowHandle); // 勾选
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 明细数据变化后刷新主表数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnSaveGridCallBack(object sender, EventArgs e)
|
|
{
|
|
|
|
int oldRowHandle = 0;
|
|
XtraTabPage RefreshPage = this.TabObj.SelectedTabPage;
|
|
Object moduleObject = RefreshPage.Controls.Cast<Object>().FirstOrDefault();
|
|
ModuleGridEx moduleGridEx = null;
|
|
if (moduleObject is ModuleGridEx)
|
|
{
|
|
moduleGridEx = moduleObject as ModuleGridEx;
|
|
oldRowHandle = moduleGridEx.GridControlObj.GridView.FocusedRowHandle;//上一次选中行
|
|
}
|
|
ModuleGridObj.SearchObj.SearchLastGrid();
|
|
|
|
if (moduleGridEx.SearchObj.RememberRow)
|
|
{
|
|
moduleGridEx.GridControlObj.GridView.SelectRowHandler(oldRowHandle);
|
|
}
|
|
}
|
|
|
|
void GridControl_EditorKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-22 </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, bool isLeft = false)
|
|
{
|
|
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : ModuleGridObj.ParmaryKey;
|
|
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
|
if (model.IsUnionleft&& _leftGridSearchObj!=null)
|
|
{
|
|
DataRow leftrow = _leftGridSearchObj.MainGridEx.GetViewFocusedDataRow();
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(leftrow, sqlValue);
|
|
}
|
|
else
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
|
}
|
|
DataRow row = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
|
|
if (row != null && isLeft)
|
|
{
|
|
//先替换左侧选中行,在替换主表
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(row, sqlValue);
|
|
}
|
|
|
|
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
|
{
|
|
string Conditions = string.Empty;
|
|
//是左侧选中行,并且没有替换字段,则使用主表选中行
|
|
Conditions = isLeft ? rowItem.Table.Columns.Contains(fieldName) ? rowItem[fieldName] + "" : row[fieldName] + "" : rowItem[fieldName] + "";
|
|
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, Conditions);
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(model.UnionCond))
|
|
{
|
|
string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond);
|
|
sqlValue += UnionCond;
|
|
}
|
|
return sqlValue;
|
|
}
|
|
/// <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
|
|
{
|
|
if (callRefreshDetail)
|
|
{
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
else
|
|
{
|
|
this.SetDetailGridDataSource(this.TabObj.SelectedTabPage);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:双击加载明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-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>
|
|
protected void OnGridViewDoubleClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:双击加载树表格明细</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-02-12 </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>
|
|
private void OnFocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 双击模式时,主表搜索为空
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SearchObj_ClearDetails_DoubleMode(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//主表内容为空时清空所有明细数据
|
|
if (this.ModuleGridObj.GridControlObj.gridControl.DataSourceTable().Rows.Count == 0)
|
|
{
|
|
GridView_DoubleClick(null, null);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("加载明细数据失败!" + Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 基础模块双击加载明细
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void GridView_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
if (IsDynamicDetailType)
|
|
{
|
|
this.DynamicSetDetailGridDataSource();
|
|
}
|
|
else
|
|
{
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 加载明细数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void GridView_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
this.CancelSwitchingRow = false;
|
|
//验证是否切换选中行
|
|
if (SystemInfo.Instance.EfficientVerification && !this.TcButtom.CheckIfSaved())
|
|
{
|
|
//开启验证,且切换时保存失败。取消切换行操作
|
|
this.CancelSwitchingRow = true;
|
|
return;
|
|
}
|
|
|
|
GridView view = sender as GridView;
|
|
// 计算点击位置的信息
|
|
DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hitInfo = view.CalcHitInfo(e.X, e.Y);
|
|
// 检查点击是否在行内
|
|
if (hitInfo.InRowCell)
|
|
{
|
|
// 获取点击的行句柄
|
|
int rowHandle = hitInfo.RowHandle;
|
|
|
|
if (LastFocusedRowHandle == rowHandle)
|
|
{
|
|
//和上一次点击行一致就刷新数据原
|
|
if (IsDynamicDetailType)
|
|
{
|
|
this.DynamicSetDetailGridDataSource();
|
|
}
|
|
else
|
|
{
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <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();
|
|
if (this.isFocusedRowChanged)
|
|
{
|
|
if (IsDynamicDetailType)
|
|
{
|
|
this.DynamicSetDetailGridDataSource();
|
|
}
|
|
else
|
|
{
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
}
|
|
this.isFocusedRowChanged = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("加载明细数据失败!" + Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:数据行发生改变加载明细</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewFocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
if (this.CancelSwitchingRow)
|
|
{
|
|
//this.CancelSwitchingRow = false;
|
|
this.BeginInvoke(new Action(() =>
|
|
{
|
|
this.ModuleGridObj.GridControlObj.GridView.FocusedRowHandle = this.LastFocusedRowHandle;
|
|
this.ModuleGridObj.GridControlObj.GridView.RefreshData();
|
|
}));
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (e != null) this.LastFocusedRowHandle = e.RowHandle;
|
|
if (IsDynamicDetailType)
|
|
{
|
|
this.DynamicSetDetailGridDataSource();
|
|
}
|
|
else
|
|
{
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("加载明细数据失败!" + Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 主表数据查询后发生
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SearchObj_ClearDetails(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//主表内容为空时清空所有明细数据
|
|
if (this.ModuleGridObj.GridControlObj.gridControl.DataSourceTable().Rows.Count == 0)
|
|
{
|
|
OnGridViewFocusedRowObjectChanged(null, null);
|
|
}
|
|
}
|
|
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-11-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="DevExpress.Data.SelectionChangedEventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewFocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs 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>创建日期:2018-02-01 </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>
|
|
protected void OnSplitterMoved(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.Model != null)
|
|
{
|
|
IniHelper.Write(string.Format("base_height_{0}", this.Model.ModuleCode), this.scc_container.SplitterPosition + "");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 刷新子页签数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ModuleGridObj_AfterRefreshingCallBack(object sender, EventArgs e)
|
|
{
|
|
foreach (XtraTabPage tabPage in this.TabObj.TabPages)
|
|
{
|
|
GridDetailModel model = this.tcButtom.GetGridDetailModel(tabPage);
|
|
if (model != null)
|
|
{
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
(tabPage.Tag as GridControlEx).RefreshDataSource();
|
|
}
|
|
}
|
|
else if (tabPage.Tag is TabMultipledetails)
|
|
{
|
|
TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails;
|
|
(tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx).RefreshDataSource();
|
|
(tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx).RefreshDataSource();
|
|
|
|
}
|
|
}
|
|
|
|
|