2616d5dbad
SVN-Revision: r1047
2684 lines
129 KiB
C#
2684 lines
129 KiB
C#
/******************************
|
|
* 说明:TabControlEx多标签(标签内容包含表格和图表) 应用于审核附加信息、基础档案审核附加信息
|
|
* 创建人:龚宇超
|
|
* 创建日期:2018-01-10
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本: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.Util;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Model;
|
|
using DevExpress.XtraEditors;
|
|
using Lskj.Data;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using Lskj.Business;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using System.Threading.Tasks;
|
|
using System.Collections;
|
|
using DevExpress.XtraGrid.Views.BandedGrid;
|
|
|
|
namespace Lskj.Control
|
|
{
|
|
/// <summary>
|
|
/// 多标签,标签内容包含表格和图表
|
|
/// </summary>
|
|
public partial class TabControlEx : UserControl
|
|
{
|
|
|
|
/// <summary>
|
|
/// 是否加载明细刷新
|
|
/// </summary>
|
|
/// <value><c>true</c> if [_ un refresh]; otherwise, <c>false</c>.</value>
|
|
private bool _UnRefresh
|
|
{
|
|
get
|
|
{
|
|
return Model is DynamicModuleDetailModel || Model is DynamicModuleModel || Model is DynamicProductionModel;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 拖拽模式
|
|
/// </summary>
|
|
public bool IsDragDetail;
|
|
/// <summary>
|
|
/// 拖拽目标主键字段
|
|
/// </summary>
|
|
public string DrgaParentPrimaryKey;
|
|
/// <summary>
|
|
/// 添加数据sql赋值
|
|
/// </summary>
|
|
public string ControlSql;
|
|
/// <summary>
|
|
/// tab标签
|
|
/// </summary>
|
|
private List<GridDetailModel> _gridDetail;
|
|
/// <summary>
|
|
/// tab标签里明细数据
|
|
/// </summary>
|
|
private List<GridDetailModel> _gridIntoDetail;
|
|
/// <summary>
|
|
/// 是否为Mrp明细页签
|
|
/// </summary>
|
|
private bool isMrpDetail = false;
|
|
/// <summary>
|
|
/// The system model
|
|
/// </summary>
|
|
public DynamicModel Model;
|
|
/// <summary>
|
|
/// 父表格
|
|
/// </summary>
|
|
public GridControlEx ParentGridEx;
|
|
/// <summary>
|
|
/// Mrp父表格
|
|
/// </summary>
|
|
public GridControlEx MrpParentGridEx;
|
|
/// <summary>
|
|
/// Mrp父明细表格
|
|
/// </summary>
|
|
public GridControlEx MrpDetailGridEx;
|
|
/// <summary>
|
|
/// 父容器
|
|
/// </summary>
|
|
public MyControl ParentControlEx;
|
|
/// <summary>
|
|
/// 明细数据里的主表格
|
|
/// </summary>
|
|
public ModuleGridEx ModuleGridObj;
|
|
/// <summary>
|
|
/// 选项卡
|
|
/// </summary>
|
|
public XtraTabControl TabControlObj
|
|
{
|
|
get { return this.xtc_container; }
|
|
}
|
|
/// <summary>
|
|
/// 替换其他页签中条件的表
|
|
/// </summary>
|
|
public GridControlEx ReplaceControlEx;
|
|
|
|
/// <summary>
|
|
/// 右键菜单执行后调用
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
public event EventHandler OnRightCallback;
|
|
/// <summary>
|
|
/// 在保存网格回调(右键)
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
public event EventHandler OnDetailRightCallback;
|
|
/// <summary>
|
|
/// 在保存网格回调
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
public event EventHandler OnDetailSaveGridCallBack;
|
|
//拖拽模式拖拽完成委托
|
|
public delegate void DragCompleteCallbackEventHandler(object sender, GridDragGridArgs e);
|
|
//拖拽模式拖拽完成回调
|
|
public event DragCompleteCallbackEventHandler OnDragCompleteCallback;
|
|
/// <summary>
|
|
/// 拖拽模式DetailView双击点击事件回调
|
|
/// </summary>
|
|
public event EventHandler OnDetailViewDoubleClickCallBack;
|
|
/// <summary>
|
|
/// mrp拖拽完成后
|
|
/// </summary>
|
|
public event EventHandler OnMrpDragCallback;
|
|
public event EventHandler OnMrpBtnClickCallback;
|
|
/// <summary>
|
|
/// 明细页签与主模块对应关系
|
|
/// </summary>
|
|
public Dictionary<string, List<DetailTabPageModel>> DetailTabPagesDic = new Dictionary<string, List<DetailTabPageModel>>();
|
|
/// <summary>
|
|
/// 页签控件集合
|
|
/// </summary>
|
|
public Dictionary<GridDetailModel, object> PageControlsDic = new Dictionary<GridDetailModel, object>();
|
|
/// <summary>
|
|
/// 页签名(判断是否有重复的左右结构)
|
|
/// </summary>
|
|
public string DetaiName = string.Empty;
|
|
public TabControlEx()
|
|
{
|
|
InitializeComponent();
|
|
this.Disposed += OnTabControlExDisposed;
|
|
}
|
|
#region ▼ 通用工具 ▼
|
|
|
|
/// <summary>尝试从 XtraTabPage 解析出 GridDetailModel。</summary>
|
|
private static GridDetailModel ResolveModel(XtraTabPage page)
|
|
{
|
|
// ① page.Tag 直接就是 GridDetailModel
|
|
if (page.Tag is GridDetailModel m) return m;
|
|
|
|
// ② page.Tag 是装控件,控件.Tag 才是 GridDetailModel
|
|
if (page.Tag is System.Windows.Forms.Control c && c.Tag is GridDetailModel m2) return m2;
|
|
|
|
// ③ page.Controls 里找第一个带 Tag 的控件
|
|
foreach (System.Windows.Forms.Control ctl in page.Controls)
|
|
if (ctl.Tag is GridDetailModel m3) return m3;
|
|
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 将 DataTable 绑定到指定 XtraTabPage(根据 page.Tag 控件类型自动处理)。
|
|
/// </summary>
|
|
private static void BindTableToPage(XtraTabPage page, DataTable table, string lastSql = null)
|
|
{
|
|
switch (page.Tag)
|
|
{
|
|
/* ① page.Tag 直接就是 GridControlEx -------------------------- */
|
|
case GridControlEx gridEx:
|
|
gridEx.LastSearchSql = lastSql ?? gridEx.LastSearchSql;
|
|
gridEx.SetGridViewDataSource(table);
|
|
|
|
break;
|
|
|
|
/* ② page.Tag 是某种 Control,且本身是 GridControlEx ----------- */
|
|
case System.Windows.Forms.Control ctl when ctl is GridControlEx g:
|
|
g.LastSearchSql = lastSql ?? g.LastSearchSql;
|
|
g.SetGridViewDataSource(table);
|
|
break;
|
|
|
|
/* ③ Tag 是面板/其它容器,递归找内部网格 ------------------------ */
|
|
case System.Windows.Forms.Control container when FindGridControlEx(container) is GridControlEx g2:
|
|
g2.LastSearchSql = lastSql ?? g2.LastSearchSql;
|
|
g2.SetGridViewDataSource(table);
|
|
break;
|
|
|
|
/* ④ 图表控件 ---------------------------------------------------- */
|
|
case ChartControlEx chartEx:
|
|
chartEx.CreateChart(table);
|
|
break;
|
|
|
|
/* ⑤ 其它控件无需绑定 ------------------------------------------- */
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
private static GridControlEx FindGridControlEx(System.Windows.Forms.Control root)
|
|
{
|
|
foreach (System.Windows.Forms.Control child in root.Controls)
|
|
{
|
|
if (child is GridControlEx gx) // 找到就返回
|
|
return gx;
|
|
|
|
GridControlEx inner = FindGridControlEx(child);
|
|
if (inner != null) return inner; // 递归向下
|
|
}
|
|
return null;
|
|
}
|
|
#endregion
|
|
|
|
#region ▼ 新核心方法 ▼
|
|
|
|
/// <summary>
|
|
/// 统一刷新页签(既可用于旧底部 tcButtom,也可用于新右侧 rightTab)。
|
|
/// </summary>
|
|
protected void SetTabPageDataSource(
|
|
XtraTabPage tabPage,
|
|
GridControlEx leftGrid,
|
|
bool isNull = false,
|
|
DataRow overrideRow = null)
|
|
{
|
|
/********* 0. 前置:获得模型对象 & 当前行 *********/
|
|
GridDetailModel model = ResolveModel(tabPage);
|
|
if (model == null) { BindTableToPage(tabPage, new DataTable()); return; }
|
|
|
|
// 行:优先 overrideRow,其次主表当前行
|
|
DataRow rowItem = overrideRow ?? leftGrid.GetViewFocusedDataRow();
|
|
//if (leftGrid.CustomGroupBandEx != null && overrideRow == null)
|
|
// rowItem = leftGrid.CustomGroupBandEx.GetViewFocusedDataRow();
|
|
if (leftGrid.CustomGroupSelectedRow != null && overrideRow == null)
|
|
rowItem = leftGrid.CustomGroupSelectedRow;
|
|
|
|
/********* 1. 置空逻辑 ***********************************************/
|
|
if (isNull || rowItem == null)
|
|
{
|
|
// 1-A: 左右结构且允许 UnionLeft → 仍可带条件取数
|
|
if (model.IsUnionleft && overrideRow != null)
|
|
{
|
|
string sqlValue = model.IsReadOnly || model.IsChart
|
|
? model.DetailSql
|
|
: model.SystemModel.MenuSql;
|
|
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue);
|
|
DataTable dt = MainImpl.GetDataTableResult(sqlValue);
|
|
BindTableToPage(tabPage, dt);
|
|
}
|
|
else
|
|
{
|
|
BindTableToPage(tabPage, new DataTable());
|
|
}
|
|
return;
|
|
}
|
|
|
|
/********* 2. PageVisibleCond(可见性判定) ***************************/
|
|
if (!string.IsNullOrEmpty(leftGrid.SysModel.PageVisbleCond))
|
|
{
|
|
string condSql = ReplaceHelper.ReplaceRowParam(rowItem,
|
|
ReplaceHelper.ReplaceUserInfo(leftGrid.SysModel.PageVisbleCond));
|
|
string numberList = MainImpl.GetResult(condSql) + "";
|
|
if (!string.IsNullOrEmpty(numberList))
|
|
{
|
|
string orderIdStr = model.Orderid.ToString();
|
|
bool visible = numberList.Split(',').Contains(orderIdStr);
|
|
tabPage.PageVisible = visible;
|
|
if (!visible) { BindTableToPage(tabPage, new DataTable()); return; }
|
|
}
|
|
}
|
|
|
|
/********* 3. 浏览器页签 ************************************************/
|
|
if (tabPage.Tag is FrmWebBrowser ||
|
|
tabPage.Tag is FrmWebBrowser2 ||
|
|
tabPage.Tag is FrmMiniBlink)
|
|
{
|
|
string url = ReplaceHelper.ReplaceRowParam(rowItem,
|
|
ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
|
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
|
|
|
switch (tabPage.Tag)
|
|
{
|
|
case FrmWebBrowser w1: w1.LoadUrl(url); break;
|
|
case FrmWebBrowser2 w2: w2.LoadUrl(url); break;
|
|
case FrmMiniBlink mb: mb.LoadUrl(url); break;
|
|
}
|
|
return;
|
|
}
|
|
|
|
/********* 4. 多明细 TabMultipledetails ********************************/
|
|
if (tabPage.Tag is TabMultipledetails multi)
|
|
{
|
|
multi.SetConditionValues(rowItem);
|
|
|
|
// 主格
|
|
GridControlEx grdMain = multi.SplitMain.Panel1.Tag as GridControlEx;
|
|
GridDetailModel mainM = grdMain.Tag as GridDetailModel;
|
|
string sqlMain = GetSearchSql(mainM, rowItem);
|
|
DataTable mainTable = MainImpl.GetDataTableResult(sqlMain);
|
|
grdMain.LastSearchSql = sqlMain;
|
|
grdMain.SetGridViewDataSource(mainTable);
|
|
|
|
// 附格 / 图表
|
|
System.Windows.Forms.Control rightCtl = multi.SplitMain.Panel2.Tag as System.Windows.Forms.Control;
|
|
if (rightCtl is GridControlEx grdAdd)
|
|
{
|
|
GridDetailModel addM = grdAdd.Tag as GridDetailModel;
|
|
string sqlAdd = GetSearchSql(addM, rowItem);
|
|
|
|
if (!mainM.IsUnioDetail)
|
|
{
|
|
grdAdd.LastSearchSql = sqlAdd;
|
|
grdAdd.SetGridViewDataSource(MainImpl.GetDataTableResult(sqlAdd));
|
|
}
|
|
else if (mainTable.Rows.Count == 0) // 主表无数据 → 清空
|
|
{
|
|
grdAdd.LastSearchSql = "";
|
|
grdAdd.SetGridViewDataSource(new DataTable());
|
|
}
|
|
}
|
|
else if (rightCtl is ChartControlEx chartAdd)
|
|
{
|
|
GridDetailModel addM = chartAdd.Tag as GridDetailModel;
|
|
string sqlAdd = GetSearchSql(addM, rowItem);
|
|
chartAdd.CreateChart(MainImpl.GetDataTableResult(sqlAdd));
|
|
}
|
|
|
|
tabPage.Text = $"{mainM.DetailName}({mainTable.Rows.Count}条)";
|
|
tabPage.Appearance.Header.ForeColor =
|
|
mainTable.Rows.Count > 0 ? Color.Red : Color.Black;
|
|
return;
|
|
}
|
|
|
|
/********* 5. 普通 Grid / Chart / 动态列 ******************************/
|
|
if (!string.IsNullOrEmpty(model.UnionModule) &&
|
|
string.IsNullOrEmpty(model.UnionValue) &&
|
|
string.IsNullOrEmpty(model.UnionCond))
|
|
return; // 无关联字段→不刷
|
|
|
|
if (model.IsDrag) return; // 拖拽页签不刷
|
|
|
|
string finalSql = GetSearchSql(model, rowItem);
|
|
|
|
//if (model.DynamicDetails && rowItem.Table.Columns.Contains("DisplayColumns"))
|
|
// tabContainer.SetGridDisplayColumns?.Invoke(tabPage, rowItem["DisplayColumns"] + "");
|
|
|
|
DataTable table = MainImpl.GetDataTableResult(finalSql);
|
|
BindTableToPage(tabPage, table, finalSql);
|
|
tabPage.Text = $"{model.DetailName}({table.Rows.Count}条)";
|
|
tabPage.Appearance.Header.ForeColor = table.Rows.Count > 0 ? Color.Red : Color.FromArgb(0, 0, 0);
|
|
// 首次加载自动查询
|
|
if (model.SystemModel != null && model.SystemModel.isFirstLoad == 1
|
|
&& tabPage.Tag is GridControlEx gc)
|
|
{
|
|
gc.ParentControl.SearchGrid();
|
|
tabPage.Text = $"{model.DetailName}({gc.ParentControl.GridRowCount}条)";
|
|
tabPage.Appearance.Header.ForeColor = gc.ParentControl.GridRowCount > 0 ? Color.Red : Color.FromArgb(0, 0, 0);
|
|
}
|
|
|
|
// 行定位 / 按钮状态
|
|
if (tabPage.Controls.OfType<ModuleGridEx>().FirstOrDefault() is ModuleGridEx mod)
|
|
{
|
|
mod.ParentButtonState(rowItem);
|
|
mod.SelectTheSpecifiedRow();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
/// <summary>根据左侧选中行刷新右侧整个 TabControl。</summary>
|
|
private void RefreshRightTab(XtraTabControl rightTab, GridControlEx leftGrid)
|
|
{
|
|
DataRow rowItem = leftGrid.GetViewFocusedDataRow();
|
|
|
|
foreach (XtraTabPage page in rightTab.TabPages)
|
|
{
|
|
bool isNull = rowItem == null;
|
|
SetTabPageDataSource(page, leftGrid, isNull, rowItem);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 新模式加载明细控件
|
|
/// </summary>
|
|
/// <param name="gridDetail"></param>
|
|
/// <param name="isGridmerge"></param>
|
|
/// <param name="isAddPages"></param>
|
|
|
|
public void InitTabPages(List<GridDetailModel> gridDetail, bool isGridmerge = true, bool isAddPages = false)
|
|
{
|
|
if (ParentGridEx != null && ParentGridEx.CustomGroupBandEx != null)
|
|
{
|
|
ParentGridEx.CustomGroupBandEx.BandedView.LeftCoordChanged += OnBandedViewLeftCoordChanged;
|
|
ParentGridEx.CustomGroupBandEx.BandedView.ColumnWidthChanged += OnBandedViewColumnWidthChanged;
|
|
ParentGridEx.OnBuildGroupedColumnCallBack += OnBandedViewColumnWidthChanged;
|
|
}
|
|
if (ParentGridEx != null && ParentGridEx.CustomGroupTreeBandEx != null)
|
|
{
|
|
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoordChanged += OnBandedViewLeftCoordChanged; ;
|
|
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.ColumnWidthChanged += OnBandedViewColumnWidthChanged;
|
|
ParentGridEx.OnBuildGroupedColumnCallBack += OnBandedViewColumnWidthChanged;
|
|
}
|
|
this._gridDetail = gridDetail;
|
|
if (!isAddPages) this.xtc_container.TabPages.Clear();
|
|
|
|
// 1️⃣ 预分组:Rightdockid > 0 的明细
|
|
var rightGroups = gridDetail
|
|
.Where(m => m.Rightdockid > 0)
|
|
.GroupBy(m => m.Rightdockid)
|
|
.ToDictionary(g => g.Key, g => g.ToList());
|
|
|
|
Dictionary<object, Hashtable> dataCaches = Model?.DataCaches;
|
|
|
|
this.DetaiName = string.Empty;
|
|
|
|
foreach (GridDetailModel model in gridDetail)
|
|
{
|
|
// 子明细交给父明细右侧页签生成
|
|
if (model.Rightdockid > 0) continue;
|
|
|
|
if (this.DetaiName.Equals(model.DetailName) && isGridmerge) continue;
|
|
|
|
|
|
bool hasRight = rightGroups.TryGetValue(model.Orderid, out var rightChildren);
|
|
|
|
XtraTabPage page = new XtraTabPage
|
|
{
|
|
Text = model.DetailName
|
|
};
|
|
page.SizeChanged += OnPageSizeChanged;
|
|
|
|
// 2️⃣ 先生成“左侧”父明细控件
|
|
System.Windows.Forms.Control leftCtrl = CreateDetailControl(page, model, dataCaches);
|
|
int position = int.TryParse(IniHelper.Read($"base_TabPageMain_{model.Id}"), out int value) ? value : 0; // 0 是转换失败时的默认值
|
|
if (hasRight && isGridmerge)
|
|
{
|
|
/* ── 带右侧 Dock 的父明细 ───────────────────────────── */
|
|
SplitContainerControl split = new SplitContainerControl
|
|
{
|
|
Dock = DockStyle.Fill,
|
|
FixedPanel = SplitFixedPanel.Panel1,
|
|
SplitterPosition = position > 0 ? position : Math.Max(350, this.xtc_container.Width / 2)
|
|
};
|
|
split.Panel1.Controls.Add(leftCtrl);
|
|
split.SplitterPositionChanged += OnSplitterPositionChanged;
|
|
XtraTabControl rightTab = new XtraTabControl
|
|
{
|
|
Dock = DockStyle.Fill
|
|
};
|
|
if (rightChildren.Count == 1)
|
|
rightTab.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False;
|
|
|
|
foreach (var child in rightChildren.OrderBy(c => c.Orderid))
|
|
{
|
|
XtraTabPage childPage = new XtraTabPage { Text = child.DetailName };
|
|
System.Windows.Forms.Control childCtrl = CreateDetailControl(childPage, child, dataCaches);
|
|
childPage.Controls.Add(childCtrl);
|
|
rightTab.TabPages.Add(childPage);
|
|
}
|
|
split.Panel2.Controls.Add(rightTab);
|
|
|
|
// split.Panel1 里是“左侧控件”
|
|
// 如果它是网格,就把事件绑上去
|
|
if (leftCtrl is GridControlEx g1)
|
|
{
|
|
g1.GridView.FocusedRowChanged += (s, e) => RefreshRightTab(rightTab, g1);
|
|
RefreshRightTab(rightTab, g1);// 首次加载
|
|
}
|
|
else if (leftCtrl is ModuleGridEx mg)
|
|
{
|
|
var g2 = mg.GridControlObj;
|
|
g2.GridView.FocusedRowChanged += (s, e) => RefreshRightTab(rightTab, g2);
|
|
RefreshRightTab(rightTab, g2); // 首次加载
|
|
}
|
|
page.Controls.Add(split);// 跟原来保持一致的 Tag 用法
|
|
}
|
|
else
|
|
{
|
|
/* ── 普通明细 ─────────────────────────────────────── */
|
|
page.Controls.Add(leftCtrl);
|
|
}
|
|
/* 3️⃣ 加入到容器 & 索引字典 */
|
|
this.xtc_container.TabPages.Add(page);
|
|
var dtp = new DetailTabPageModel
|
|
{
|
|
TabPageIndex = this.xtc_container.TabPages.IndexOf(page),//this._gridDetail.IndexOf(model), 如果是有左右结构,会跳过1个序号(右侧模块不会存序号),导致报错
|
|
DetailTabPage = page,
|
|
DetailModel = model
|
|
};
|
|
if (!string.IsNullOrEmpty(model.ParentModuleCode))
|
|
{
|
|
string key = model.ParentModuleCode.ToLower();
|
|
if (!this.DetailTabPagesDic.TryGetValue(key, out var list))
|
|
this.DetailTabPagesDic[key] = list = new List<DetailTabPageModel>();
|
|
list.Add(dtp);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:绑定选项卡</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitTabPagesOld(List<GridDetailModel> gridDetail, bool isGridmerge = true, bool isAddPages = false)
|
|
{
|
|
this._gridDetail = gridDetail;
|
|
if (!isAddPages)
|
|
{
|
|
this.xtc_container.TabPages.Clear();
|
|
}
|
|
string DetaiName = string.Empty;
|
|
|
|
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
|
|
|
|
foreach (GridDetailModel model in this._gridDetail)
|
|
{
|
|
object control = PageControlsDic.ContainsKey(model) ? PageControlsDic[model] : null;
|
|
bool hasControl = control != null;
|
|
if (DetaiName.Equals(model.DetailName) && isGridmerge) continue;
|
|
GridDetailModel[] isMeage = gridDetail.Cast<GridDetailModel>().Where(x => x.DetailName.Equals(model.DetailName)).ToArray();
|
|
XtraTabPage page = new XtraTabPage();
|
|
page.SizeChanged += OnPageSizeChanged;
|
|
page.Text = model.DetailName;
|
|
|
|
if (SystemInfo.Instance.GridRowFontSize > 0)
|
|
{
|
|
//页签大小
|
|
FontFamily fontFamily = page.Appearance.Header.Font.FontFamily;
|
|
page.Appearance.Header.Font = new System.Drawing.Font(fontFamily, SystemInfo.Instance.GridRowFontSize);
|
|
}
|
|
|
|
if (model.IsChart)
|
|
{
|
|
ChartControlEx chartEx = hasControl && control is ChartControlEx ? (ChartControlEx)control : new ChartControlEx();
|
|
chartEx.Dock = DockStyle.Fill;
|
|
chartEx.transverseHistogram = model.transverseHistogram;
|
|
//chartEx.SetCharts(BaseModuleImpl.GetChartParams(model.FormKey));
|
|
//chartEx.SetChartRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
|
if (!dataCaches.GetValue(chartEx, "ChartParams", out DataTable dtChartParams))
|
|
{
|
|
dtChartParams = BaseModuleImpl.GetChartParams(model.FormKey);
|
|
}
|
|
if (!dataCaches.GetValue(chartEx, "ChartRightMenus", out DataTable dtBaseGridRightMenus))
|
|
{
|
|
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus(model.FormKey);
|
|
}
|
|
chartEx.SetCharts(dtChartParams);
|
|
chartEx.SetChartRightMenus(dtBaseGridRightMenus, this.Model, OnGridViewRightCallBack);
|
|
chartEx.Tag = model;
|
|
page.Tag = chartEx;
|
|
page.Controls.Add(chartEx);
|
|
}
|
|
else if (model.IsExcel)
|
|
{
|
|
ExcelControlEx excelEx = hasControl && control is ExcelControlEx ? (ExcelControlEx)control : new ExcelControlEx();
|
|
excelEx.Dock = DockStyle.Fill;
|
|
excelEx.Tag = model;
|
|
page.Tag = excelEx;
|
|
page.Controls.Add(excelEx);
|
|
}
|
|
else if (model.IsWebView)
|
|
{
|
|
// 加载网页
|
|
string url = model.DetailSql.StartsWith("http") ? model.DetailSql : SystemInfo.Instance.OAUrl + model.DetailSql;
|
|
//url= System.Web.HttpUtility.UrlEncode(url);
|
|
if (SystemInfo.Instance.PrimitiveBrowser)
|
|
{
|
|
FrmMiniBlink webView = hasControl && control is FrmMiniBlink ? (FrmMiniBlink)control : new FrmMiniBlink();
|
|
webView.IsDownVerify = true;
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
page.Tag = webView;
|
|
page.Controls.Add(webView);
|
|
webView.LoadUrl(ReplaceHelper.ReplaceUserInfo(url));
|
|
}
|
|
else
|
|
{
|
|
FrmWebBrowser webView = hasControl && control is FrmWebBrowser ? (FrmWebBrowser)control : new FrmWebBrowser();
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
page.Tag = webView;
|
|
page.Controls.Add(webView);
|
|
webView.FrmLoad(ReplaceHelper.ReplaceUserInfo(url));
|
|
}
|
|
}
|
|
else if (model.IsWebView2)
|
|
{
|
|
// 加载网页
|
|
string url = model.DetailSql.StartsWith("http") ? model.DetailSql : SystemInfo.Instance.OAUrl + model.DetailSql;
|
|
//url= System.Web.HttpUtility.UrlEncode(url);
|
|
if (SystemInfo.Instance.PrimitiveBrowser)
|
|
{
|
|
FrmMiniBlink webView = hasControl && control is FrmMiniBlink ? (FrmMiniBlink)control : new FrmMiniBlink();
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
page.Tag = webView;
|
|
page.Controls.Add(webView);
|
|
webView.LoadUrl(ReplaceHelper.ReplaceUserInfo(url));
|
|
}
|
|
else
|
|
{
|
|
FrmWebBrowser2 webView = hasControl && control is FrmWebBrowser2 ? (FrmWebBrowser2)control : new FrmWebBrowser2();
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
page.Tag = webView;
|
|
page.Controls.Add(webView);
|
|
webView.FrmLoad(ReplaceHelper.ReplaceUserInfo(url));
|
|
}
|
|
}
|
|
else if (model.IsWebView3)
|
|
{
|
|
// 加载网页
|
|
string url = model.DetailSql.StartsWith("http") ? model.DetailSql : SystemInfo.Instance.OAUrl + model.DetailSql;
|
|
//url= System.Web.HttpUtility.UrlEncode(url);
|
|
if (SystemInfo.Instance.PrimitiveBrowser)
|
|
{
|
|
FrmMiniBlink webView = hasControl && control is FrmMiniBlink ? (FrmMiniBlink)control : new FrmMiniBlink();
|
|
webView.AllowDownload = false;
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
page.Tag = webView;
|
|
page.Controls.Add(webView);
|
|
webView.LoadUrl(ReplaceHelper.ReplaceUserInfo(url));
|
|
}
|
|
else
|
|
{
|
|
FrmWebBrowser2 webView = hasControl && control is FrmWebBrowser2 ? (FrmWebBrowser2)control : new FrmWebBrowser2();
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
webView.AllowDownload = false;
|
|
page.Tag = webView;
|
|
page.Controls.Add(webView);
|
|
webView.FrmLoad(ReplaceHelper.ReplaceUserInfo(url));
|
|
}
|
|
}
|
|
else if (model.IsAddPanel && isGridmerge)
|
|
{
|
|
// 加载添加界面
|
|
ModulePanelEx modulePanel = hasControl && control is ModulePanelEx ? (ModulePanelEx)control : new ModulePanelEx();
|
|
modulePanel.Dock = DockStyle.Fill;
|
|
|
|
if (!dataCaches.GetValue(modulePanel, "BasePrimaryKey", out string primaryKey))
|
|
{
|
|
primaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);
|
|
}
|
|
modulePanel.PrimaryKey = primaryKey;
|
|
if (!dataCaches.GetValue(modulePanel, "SystemDllRow", out DataRow systemRow))
|
|
{
|
|
systemRow = MainImpl.GetSystemdllTab(this.Model.ModuleCode);
|
|
}
|
|
modulePanel.InitializeControl(new ModuleModel(systemRow), this.Model);
|
|
//modulePanel.OnAddRecordCallBack += new EventHandler(OnAddRecordCallBack);
|
|
//modulePanel.OnCloseCallback += new EventHandler(OnAddRecordCallBack);
|
|
modulePanel.OperatePanelControlObj.Visible = false;
|
|
modulePanel.SpeciesPanelControlObj.Visible = false;
|
|
modulePanel.Tag = model;
|
|
page.Tag = modulePanel;
|
|
page.Controls.Add(modulePanel);
|
|
}
|
|
else if (model.IsDetailView)
|
|
{
|
|
ModuleGridDetailEx DetailEx = hasControl && control is ModuleGridDetailEx ? (ModuleGridDetailEx)control : new ModuleGridDetailEx();
|
|
DetailEx.Dock = DockStyle.Fill;
|
|
if (!dataCaches.GetValue(DetailEx, "DynamicModel", out DynamicModel dyncModel))
|
|
{
|
|
dyncModel = new DynamicModuleModel(new string[] { model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.Model.Privilege, model.UnionModule, "0" });
|
|
}
|
|
if (!dataCaches.GetValue(DetailEx, "SystemDllRow", out DataRow moduleInformation))
|
|
{
|
|
moduleInformation = MainImpl.GetSystemdllTab(model.UnionModule);
|
|
}
|
|
if (moduleInformation == null)
|
|
{
|
|
MessageUtil.Show("没有找到编号为" + model.UnionModule + "的模块信息");
|
|
return;
|
|
}
|
|
if (!dataCaches.GetValue(DetailEx, "SysModel", out model.SystemModel))
|
|
{
|
|
model.SystemModel = new ModuleModel(moduleInformation);
|
|
}
|
|
if (!dataCaches.GetValue(DetailEx, "Details", out List<GridDetailModel> details))
|
|
{
|
|
details = GetDetails(model.SystemModel.ModeCode);//底部多标签表格数据
|
|
}
|
|
|
|
DetailEx.GridDetailList = details;
|
|
DetailEx.IsDragDetail = IsDragDetail;
|
|
DetailEx.TcButtom.OnDetailViewDoubleClickCallBack += OnDetailGridViewDoubleClick;
|
|
DetailEx.TcButtom.OnDragCompleteCallback += OnDragGridCompleted;
|
|
DetailEx.InitializeControl(model.SystemModel, dyncModel);//初始化控件
|
|
if (!Model.DataCaches.GetValue(DetailEx, "BaseGridRightMenus", out DataTable rightDt))
|
|
{
|
|
rightDt = rightDt = BaseModuleImpl.GetBaseGridRightMenus(model.UnionModule, ModuleType.MrpClickBtn);
|
|
}
|
|
if ((rightDt != null && rightDt.Rows.Count > 0) || this.isMrpDetail)
|
|
{
|
|
this.isMrpDetail = true;
|
|
//gridEx.VisibleMrpSearchPanel = true;
|
|
}
|
|
if (IsDragDetail && this.ParentGridEx != null && model.IsDrag)
|
|
{
|
|
// 拖拽模式,绑定拖拽对象
|
|
//GridDragGrid dragGrid = new GridDragGrid(DetailEx.ModuleGridObj.GridControlObj.GridView, this.ParentGridEx.GridView);
|
|
//dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragGridCompleted);
|
|
}
|
|
if (this.MrpParentGridEx != null && model.IsMrpDrag)//mrp拖拽
|
|
{
|
|
GridDragGrid dragGrid = new GridDragGrid(this.MrpParentGridEx.GridView, DetailEx.ModuleGridObj.GridControlObj.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnMrpDragGridCompleted);
|
|
}
|
|
if (this.MrpDetailGridEx != null && model.IsMrpDrag)//mrp拖拽
|
|
{
|
|
GridDragGrid dragGrid = new GridDragGrid(this.MrpDetailGridEx.GridView, DetailEx.ModuleGridObj.GridControlObj.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnMrpDragGridCompleted);
|
|
}
|
|
if (this.isMrpDetail && this.OnMrpBtnClickCallback != null)//当前为mrp模块
|
|
{
|
|
DetailEx.ModuleGridObj.RightGridCallBack += this.OnMrpBtnClickCallback;
|
|
}
|
|
if (model.MrpConditionTab)
|
|
{
|
|
this.ReplaceControlEx = DetailEx.ModuleGridObj.GridControlObj;
|
|
}
|
|
DetailEx.ModuleGridObj.VisibleSearchPanel = Model.IsDetailSearch || model.DetailSearch;
|
|
DetailEx.ModuleGridObj.GridControlObj.Tag = model;
|
|
page.Tag = DetailEx.ModuleGridObj.GridControlObj;
|
|
page.Controls.Add(DetailEx);
|
|
}
|
|
else
|
|
{
|
|
if (model.IsReadOnly && isMeage.Count() == 1)
|
|
{
|
|
PanelControl plBottom = new PanelControl();
|
|
plBottom.Dock = DockStyle.Bottom;
|
|
plBottom.Visible = false;
|
|
PanelControl plMain = new PanelControl();
|
|
plMain.Dock = DockStyle.Fill;
|
|
GridControlEx gridEx = null;
|
|
if (model.AutoMultiHeader == 1)
|
|
{
|
|
gridEx = hasControl && control is BandedGridControlEx ? (BandedGridControlEx)control : new BandedGridControlEx();
|
|
}
|
|
else
|
|
{
|
|
gridEx = hasControl && control is GridControlEx ? (GridControlEx)control : new GridControlEx();
|
|
}
|
|
gridEx.Dock = DockStyle.Fill;
|
|
gridEx.Tag = model;
|
|
gridEx.Parent = plMain;
|
|
gridEx.Model = this.Model;
|
|
if (!dataCaches.GetValue(model, "GridColumns", out DataTable dtGridColumns))
|
|
{
|
|
dtGridColumns = model.GridColumns;
|
|
}
|
|
gridEx.SetReadOnlyColumns(dtGridColumns, model.GridCustomColumnKey);
|
|
//gridEx.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
|
//gridEx.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(model.FormKey));
|
|
if (!dataCaches.GetValue(gridEx, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
|
|
{
|
|
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus(model.FormKey);
|
|
}
|
|
if (!dataCaches.GetValue(gridEx, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
|
|
{
|
|
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors(model.FormKey);
|
|
}
|
|
gridEx.SetGridRightMenus(dtBaseGridRightMenus, this.Model, OnGridViewRightCallBack);
|
|
gridEx.SetGridRowColors(dtBaseGridRowColors);
|
|
|
|
if (model.IsCheck == 1)//加载复选框
|
|
{
|
|
GridDragGrid.GridAddCheckBox(gridEx.GridView);
|
|
}
|
|
if (model.LoadFilter)//加载筛选行
|
|
{
|
|
gridEx.GridView.OptionsView.ShowAutoFilterRow = true;
|
|
}
|
|
if (IsDragDetail && this.ParentGridEx != null && model.IsDrag)
|
|
{
|
|
// 拖拽模式,绑定拖拽对象
|
|
GridDragGrid dragGrid = new GridDragGrid(gridEx.GridView, this.ParentGridEx.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragGridCompleted);
|
|
}
|
|
if (this.MrpParentGridEx != null && model.IsMrpDrag)//mrp拖拽
|
|
{
|
|
GridDragGrid dragGrid = new GridDragGrid(this.MrpParentGridEx.GridView, gridEx.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnMrpDragGridCompleted);
|
|
}
|
|
if (this.MrpDetailGridEx != null && model.IsMrpDrag)//mrp拖拽
|
|
{
|
|
GridDragGrid dragGrid = new GridDragGrid(this.MrpDetailGridEx.GridView, gridEx.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnMrpDragGridCompleted);
|
|
}
|
|
if (model.MrpConditionTab)
|
|
{
|
|
this.ReplaceControlEx = gridEx;
|
|
}
|
|
// 加载配置查询条件
|
|
if (Model != null && Model.IsDetailSearch)
|
|
{
|
|
plBottom.Visible = true;
|
|
MyControl searchObj = new MyControl(model.DetailSql, gridEx);
|
|
if (!dataCaches.GetValue(gridEx, "CustomQueryFields", out DataTable dtCustomQueryFields))
|
|
{
|
|
dtCustomQueryFields = BaseModuleImpl.GetCustomQueryFields(model.FormKey);
|
|
}
|
|
plBottom.Height = searchObj.InitSearchControl(dtCustomQueryFields, plBottom);
|
|
}
|
|
page.Tag = gridEx;
|
|
page.Controls.AddRange(new PanelControl[] { plBottom, plMain });
|
|
}
|
|
else if (isMeage.Count() > 1 && isGridmerge)
|
|
{
|
|
DetaiName = model.DetailName;
|
|
TabMultipledetails tabMultipledetails = hasControl && control is TabMultipledetails ? (TabMultipledetails)control : new TabMultipledetails();
|
|
tabMultipledetails.Model = this.Model;
|
|
tabMultipledetails.ParentGridEx = this.ParentGridEx;
|
|
tabMultipledetails.ParentControlEx = this.ParentControlEx;
|
|
tabMultipledetails.IsDragDetail = this.IsDragDetail;
|
|
tabMultipledetails.Model = this.Model;
|
|
tabMultipledetails.DrgaParentPrimaryKey = this.DrgaParentPrimaryKey;
|
|
tabMultipledetails.InitTabPages(isMeage);
|
|
tabMultipledetails.Dock = DockStyle.Fill;
|
|
tabMultipledetails.Tag = model;
|
|
page.Tag = tabMultipledetails;
|
|
page.Controls.Add(tabMultipledetails);
|
|
}
|
|
else
|
|
{
|
|
ModuleGridEx gridEx = hasControl && control is ModuleGridEx ? (ModuleGridEx)control : new ModuleGridEx();
|
|
if (!dataCaches.GetValue(gridEx, "DynamicModel", out DynamicModel dyncModel))
|
|
{
|
|
dyncModel = new DynamicModuleModel(new string[] { model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.Model.Privilege, model.UnionModule, "0" });
|
|
}
|
|
if (!dataCaches.GetValue(gridEx, "SystemDllRow", out DataRow moduleInformation))
|
|
{
|
|
moduleInformation = MainImpl.GetSystemdllTab(model.UnionModule);
|
|
}
|
|
if (moduleInformation == null)
|
|
{
|
|
MessageUtil.Show("没有找到编号为" + model.UnionModule + "的模块信息");
|
|
return;
|
|
}
|
|
if (!dataCaches.GetValue(gridEx, "SysModel", out model.SystemModel))
|
|
{
|
|
model.SystemModel = new ModuleModel(moduleInformation);
|
|
}
|
|
|
|
|
|
if (Model != null)
|
|
{
|
|
if (!dataCaches.GetValue(gridEx, "ParentPrimaryKey", out string primaryKey))
|
|
{
|
|
primaryKey = BaseImpl.GetBasePrimaryKey(Model.ModuleCode);
|
|
}
|
|
model.SystemModel.ParmaryKey = primaryKey;
|
|
}
|
|
gridEx.OnSaveGridCallBack += OnDetailSaveGridCallBack;
|
|
gridEx.DetailRightGridCallBack += OnDetailRightCallback;
|
|
|
|
gridEx.Name = "gridEx";
|
|
gridEx.IsDetail = true;
|
|
gridEx.Dock = DockStyle.Fill;
|
|
gridEx.OperShortMode = Model.IsDetailSearch; // 不显示简短模式
|
|
gridEx.VisibleSearchPanel = Model.IsDetailSearch || model.DetailSearch;
|
|
|
|
if (!dataCaches.GetValue(gridEx, "UnionBaseGridRightMenus", out DataTable rightDt))
|
|
{
|
|
rightDt = BaseModuleImpl.GetBaseGridRightMenus(model.UnionModule, ModuleType.MrpClickBtn);
|
|
}
|
|
if ((rightDt != null && rightDt.Rows.Count > 0) || this.isMrpDetail)
|
|
{
|
|
this.isMrpDetail = true;
|
|
gridEx.VisibleMrpSearchPanel = true;
|
|
}
|
|
gridEx.VisibleOperPanel = !model.IsReadOnly;
|
|
gridEx.InitializeControl(model.SystemModel, dyncModel);
|
|
gridEx.GridControlObj.Tag = model;
|
|
gridEx.ParentControlEx = this.ParentControlEx;
|
|
gridEx.ParentGridEx = this.ParentGridEx;
|
|
gridEx.ParentKeyField = string.IsNullOrEmpty(model.UnionParentField) ? model.SystemModel.ParmaryKey : model.UnionParentField;
|
|
gridEx.DetailKeyField = model.UnionValue;
|
|
gridEx.GridControlObj.ParentControl = gridEx.SearchObj;
|
|
if (model.IsCheck == 1)//加载复选框
|
|
{
|
|
GridDragGrid.GridAddCheckBox(gridEx.GridControlObj.GridView);
|
|
|
|
//判断父表格是否是复选框
|
|
if (model.RecordDetailsCheckbox && ParentGridEx != null && ParentGridEx.GridView.OptionsSelection.MultiSelect == true)
|
|
{
|
|
gridEx.TagName = model.DetailName;
|
|
gridEx.GridControlObj.GridView.SelectionChanged += GridView_SelectionChanged;
|
|
}
|
|
}
|
|
if (model.LoadFilter)//加载筛选行
|
|
{
|
|
gridEx.GridControlObj.GridView.OptionsView.ShowAutoFilterRow = true;
|
|
}
|
|
if (this.ParentGridEx != null && model.IsDrag)//IsDragDetail &&
|
|
{
|
|
gridEx.GridControlObj.GridView.DoubleClick += OnDetailGridViewDoubleClick;
|
|
// 拖拽模式,绑定拖拽对象
|
|
if (model.IsDrag)
|
|
{
|
|
GridDragGrid dragGrid = new GridDragGrid(gridEx.GridControlObj.GridView, this.ParentGridEx.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragGridCompleted);
|
|
}
|
|
}
|
|
if (this.MrpParentGridEx != null && model.IsMrpDrag)//mrp拖拽
|
|
{
|
|
GridDragGrid dragGrid = new GridDragGrid(this.MrpParentGridEx.GridView, gridEx.GridControlObj.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnMrpDragGridCompleted);
|
|
}
|
|
if (this.MrpDetailGridEx != null && model.IsMrpDrag)//mrp拖拽
|
|
{
|
|
GridDragGrid dragGrid = new GridDragGrid(this.MrpDetailGridEx.GridView, gridEx.GridControlObj.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnMrpDragGridCompleted);
|
|
}
|
|
if (this.isMrpDetail && this.OnMrpBtnClickCallback != null)//当前为mrp模块
|
|
{
|
|
gridEx.RightGridCallBack += this.OnMrpBtnClickCallback;
|
|
}
|
|
if (model.MrpConditionTab)
|
|
{
|
|
this.ReplaceControlEx = gridEx.GridControlObj;
|
|
}
|
|
if (model.AutoRefresh && !_UnRefresh && isGridmerge)
|
|
gridEx.SearchObj.SearchGrid();
|
|
page.Tag = gridEx.GridControlObj;
|
|
page.Controls.Add(gridEx);
|
|
}
|
|
}
|
|
this.xtc_container.TabPages.Add(page);
|
|
DetailTabPageModel detailTabPageModel = new DetailTabPageModel();
|
|
detailTabPageModel.TabPageIndex = this._gridDetail.IndexOf(model);
|
|
detailTabPageModel.DetailTabPage = page;
|
|
detailTabPageModel.DetailModel = model;
|
|
if (!string.IsNullOrEmpty(model.ParentModuleCode))
|
|
{
|
|
string ParentModuleCode = model.ParentModuleCode.ToLower();
|
|
if (this.DetailTabPagesDic.ContainsKey(ParentModuleCode))
|
|
{
|
|
List<DetailTabPageModel> detailTabPageModels = this.DetailTabPagesDic[ParentModuleCode];
|
|
detailTabPageModels.Add(detailTabPageModel);
|
|
}
|
|
else
|
|
{
|
|
List<DetailTabPageModel> detailTabPageModels = new List<DetailTabPageModel>();
|
|
detailTabPageModels.Add(detailTabPageModel);
|
|
this.DetailTabPagesDic.Add(ParentModuleCode, detailTabPageModels);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:并行分割条位置变化事件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-08-24</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
void OnSplitterPositionChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SplitContainerControl splitContainerControl = sender as SplitContainerControl;
|
|
if (splitContainerControl.Parent is XtraTabPage tabPage)
|
|
{
|
|
GridDetailModel model = ResolveModel(tabPage);
|
|
if (model != null)
|
|
{
|
|
//GridDetailModel model = splitContainerControl.Panel1.Controls[0].Tag as GridDetailModel;
|
|
IniHelper.Write(string.Format("base_TabPageMain_{0}", model.Id), splitContainerControl.SplitterPosition + "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 创建公用的页签显示
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <param name="dataCaches"></param>
|
|
/// <param name="isGridmerge"></param>
|
|
/// <returns></returns>
|
|
private System.Windows.Forms.Control CreateDetailControl(System.Windows.Forms.Control parentControl, GridDetailModel model, Dictionary<object, Hashtable> dataCaches, bool isGridmerge = true)
|
|
{
|
|
|
|
GridDetailModel[] isMeage = _gridDetail.Cast<GridDetailModel>().Where(x => x.DetailName.Equals(model.DetailName)).ToArray();
|
|
|
|
// ① 取缓存的已生成控件
|
|
object control = PageControlsDic.ContainsKey(model) ? PageControlsDic[model] : null;
|
|
bool hasControl = control != null;
|
|
|
|
/* ───── 1. 图表 ───────────────────────────────────────── */
|
|
if (model.IsChart)
|
|
{
|
|
ChartControlEx chartEx = hasControl && control is ChartControlEx
|
|
? (ChartControlEx)control
|
|
: new ChartControlEx();
|
|
|
|
chartEx.Dock = DockStyle.Fill;
|
|
chartEx.transverseHistogram = model.transverseHistogram;
|
|
|
|
if (!dataCaches.GetValue(chartEx, "ChartParams", out DataTable dtChartParams))
|
|
dtChartParams = BaseModuleImpl.GetChartParams(model.FormKey);
|
|
|
|
if (!dataCaches.GetValue(chartEx, "ChartRightMenus", out DataTable dtBaseGridRightMenus))
|
|
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus(model.FormKey);
|
|
|
|
chartEx.SetCharts(dtChartParams);
|
|
chartEx.SetChartRightMenus(dtBaseGridRightMenus, this.Model, OnGridViewRightCallBack);
|
|
chartEx.Tag = model;
|
|
parentControl.Tag = chartEx;
|
|
return chartEx;
|
|
}
|
|
|
|
/* ───── 2. Excel ──────────────────────────────────────── */
|
|
else if (model.IsExcel)
|
|
{
|
|
ExcelControlEx excelEx = hasControl && control is ExcelControlEx
|
|
? (ExcelControlEx)control
|
|
: new ExcelControlEx();
|
|
excelEx.Dock = DockStyle.Fill;
|
|
excelEx.Tag = model;
|
|
parentControl.Tag = excelEx;
|
|
return excelEx;
|
|
}
|
|
|
|
/* ───── 3. WebView 系列 ───────────────────────────────── */
|
|
else if (model.IsWebView || model.IsWebView2 || model.IsWebView3)
|
|
{
|
|
string url = model.DetailSql.StartsWith("http")
|
|
? model.DetailSql
|
|
: SystemInfo.Instance.OAUrl + model.DetailSql;
|
|
url = ReplaceHelper.ReplaceUserInfo(url);
|
|
|
|
bool forbidDownload = model.IsWebView3;
|
|
|
|
if (SystemInfo.Instance.PrimitiveBrowser)
|
|
{
|
|
FrmMiniBlink webView = hasControl && control is FrmMiniBlink
|
|
? (FrmMiniBlink)control
|
|
: new FrmMiniBlink();
|
|
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.AllowDownload = !forbidDownload;
|
|
webView.IsDownVerify = model.IsWebView;
|
|
webView.Tag = model;
|
|
webView.LoadUrl(url);
|
|
return webView;
|
|
}
|
|
else
|
|
{
|
|
if (model.IsWebView2 || model.IsWebView3)
|
|
{
|
|
FrmWebBrowser2 webView = hasControl && control is FrmWebBrowser2
|
|
? (FrmWebBrowser2)control
|
|
: new FrmWebBrowser2();
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.AllowDownload = !forbidDownload;
|
|
webView.Tag = model;
|
|
parentControl.Tag = webView;
|
|
webView.FrmLoad(url);
|
|
return webView;
|
|
}
|
|
else
|
|
{
|
|
FrmWebBrowser webView = hasControl && control is FrmWebBrowser
|
|
? (FrmWebBrowser)control
|
|
: new FrmWebBrowser();
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
parentControl.Tag = webView;
|
|
webView.FrmLoad(url);
|
|
return webView;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* ───── AddPanel ───────────────────────────────────── */
|
|
else if (model.IsSched)
|
|
{
|
|
DynamicFrmProductSchedModel mainModel = new DynamicFrmProductSchedModel(new string[]
|
|
{
|
|
model.DetailName,
|
|
ERPInfo.Instance.UserId,
|
|
ERPInfo.Instance.UserName,
|
|
this.Model.Privilege,
|
|
model.UnionModule,
|
|
"0"
|
|
});
|
|
DataRow systemdllTab = MainImpl.GetSystemdllTab(model.UnionModule);
|
|
model.SystemModel = new ModuleModel(systemdllTab);
|
|
if (this.Model != null)
|
|
{
|
|
model.SystemModel.ParmaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);
|
|
}
|
|
FrmProductSched frmProductSched = new FrmProductSched();
|
|
frmProductSched.Dock = DockStyle.Fill;
|
|
frmProductSched.Tag = model;
|
|
parentControl.Tag = frmProductSched;
|
|
frmProductSched.InitializeControl(mainModel);
|
|
frmProductSched.DataModel.TopSearchObj.ButtonObj.Visible = false;
|
|
return frmProductSched;
|
|
}
|
|
|
|
|
|
/* ───── 4. AddPanel ───────────────────────────────────── */
|
|
else if (model.IsAddPanel && isGridmerge)
|
|
{
|
|
ModulePanelEx modulePanel = hasControl && control is ModulePanelEx
|
|
? (ModulePanelEx)control
|
|
: new ModulePanelEx();
|
|
modulePanel.Dock = DockStyle.Fill;
|
|
|
|
if (!dataCaches.GetValue(modulePanel, "BasePrimaryKey", out string primaryKey))
|
|
primaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);
|
|
modulePanel.PrimaryKey = primaryKey;
|
|
|
|
if (!dataCaches.GetValue(modulePanel, "SystemDllRow", out DataRow systemRow))
|
|
systemRow = MainImpl.GetSystemdllTab(this.Model.ModuleCode);
|
|
modulePanel.InitializeControl(new ModuleModel(systemRow), this.Model);
|
|
|
|
modulePanel.OperatePanelControlObj.Visible = false;
|
|
modulePanel.SpeciesPanelControlObj.Visible = false;
|
|
modulePanel.Tag = model;
|
|
parentControl.Tag = modulePanel;
|
|
return modulePanel;
|
|
}
|
|
|
|
/* ───── 5. DetailView ─────────────────────────────────── */
|
|
else if (model.IsDetailView)
|
|
{
|
|
ModuleGridDetailEx detailEx = hasControl && control is ModuleGridDetailEx
|
|
? (ModuleGridDetailEx)control
|
|
: new ModuleGridDetailEx();
|
|
detailEx.Dock = DockStyle.Fill;
|
|
|
|
// DynamicModel
|
|
if (!dataCaches.GetValue(detailEx, "DynamicModel", out DynamicModel dyncModel))
|
|
dyncModel = new DynamicModuleModel(new[]
|
|
{ model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName,
|
|
this.Model.Privilege, model.UnionModule, "0" });
|
|
|
|
// SysModel
|
|
if (!dataCaches.GetValue(detailEx, "SystemDllRow", out DataRow moduleRow))
|
|
moduleRow = MainImpl.GetSystemdllTab(model.UnionModule);
|
|
if (moduleRow == null)
|
|
{
|
|
MessageUtil.Show($"没有找到编号为 {model.UnionModule} 的模块信息");
|
|
return new Panel();
|
|
}
|
|
if (!dataCaches.GetValue(detailEx, "SysModel", out model.SystemModel))
|
|
model.SystemModel = new ModuleModel(moduleRow);
|
|
|
|
if (model.SystemModel.GridObjIsCheck == 1)//主表加载复选框
|
|
{
|
|
GridDragGrid.GridAddCheckBox(detailEx.ModuleGridObj.GridControlObj.GridView);
|
|
}
|
|
|
|
// 子明细集合
|
|
if (!dataCaches.GetValue(detailEx, "Details", out List<GridDetailModel> details))
|
|
details = GetDetails(model.SystemModel.ModeCode);
|
|
|
|
detailEx.GridDetailList = details;
|
|
detailEx.IsDragDetail = IsDragDetail;
|
|
detailEx.TcButtom.OnDetailViewDoubleClickCallBack += OnDetailGridViewDoubleClick;
|
|
detailEx.TcButtom.OnDragCompleteCallback += OnDragGridCompleted;
|
|
detailEx.InitializeControl(model.SystemModel, dyncModel);
|
|
|
|
if (!Model.DataCaches.GetValue(detailEx, "BaseGridRightMenus", out DataTable rightDt))
|
|
rightDt = BaseModuleImpl.GetBaseGridRightMenus(model.UnionModule, ModuleType.MrpClickBtn);
|
|
if ((rightDt?.Rows.Count > 0) || isMrpDetail) isMrpDetail = true;
|
|
|
|
if (MrpParentGridEx != null && model.IsMrpDrag)
|
|
{
|
|
var dg = new GridDragGrid(MrpParentGridEx.GridView, detailEx.ModuleGridObj.GridControlObj.GridView);
|
|
dg.OnDragComplete += OnMrpDragGridCompleted;
|
|
}
|
|
if (MrpDetailGridEx != null && model.IsMrpDrag)
|
|
{
|
|
var dg = new GridDragGrid(MrpDetailGridEx.GridView, detailEx.ModuleGridObj.GridControlObj.GridView);
|
|
dg.OnDragComplete += OnMrpDragGridCompleted;
|
|
}
|
|
if (isMrpDetail && OnMrpBtnClickCallback != null)
|
|
detailEx.ModuleGridObj.RightGridCallBack += OnMrpBtnClickCallback;
|
|
|
|
if (model.MrpConditionTab) ReplaceControlEx = detailEx.ModuleGridObj.GridControlObj;
|
|
detailEx.ModuleGridObj.VisibleSearchPanel = Model.IsDetailSearch || model.DetailSearch;
|
|
detailEx.ModuleGridObj.GridControlObj.Tag = model;
|
|
parentControl.Tag = detailEx.ModuleGridObj.GridControlObj;
|
|
return detailEx;
|
|
}
|
|
|
|
/* ───── 6. 只读网格(单明细) ───────────────────────────── */
|
|
else if (model.IsReadOnly && isMeage.Count() == 1)
|
|
{
|
|
// 外层容器
|
|
Panel parent = new Panel { Dock = DockStyle.Fill };
|
|
|
|
PanelControl plBottom = new PanelControl { Dock = DockStyle.Bottom, Visible = false };
|
|
PanelControl plMain = new PanelControl { Dock = DockStyle.Fill };
|
|
|
|
GridControlEx gridEx;
|
|
if (model.AutoMultiHeader == 1)
|
|
gridEx = hasControl && control is BandedGridControlEx
|
|
? (BandedGridControlEx)control
|
|
: new BandedGridControlEx();
|
|
else
|
|
gridEx = hasControl && control is GridControlEx
|
|
? (GridControlEx)control
|
|
: new GridControlEx();
|
|
|
|
gridEx.Dock = DockStyle.Fill;
|
|
gridEx.Model = this.Model;
|
|
gridEx.Tag = model;
|
|
|
|
if (!dataCaches.GetValue(model, "GridColumns", out DataTable dtGridColumns))
|
|
dtGridColumns = model.GridColumns;
|
|
gridEx.SetReadOnlyColumns(dtGridColumns, model.GridCustomColumnKey);
|
|
|
|
if (!dataCaches.GetValue(gridEx, "BaseGridRightMenus", out DataTable dtRightMenu))
|
|
dtRightMenu = BaseModuleImpl.GetBaseGridRightMenus(model.FormKey);
|
|
if (!dataCaches.GetValue(gridEx, "BaseGridRowColors", out DataTable dtRowColor))
|
|
dtRowColor = BaseModuleImpl.GetBaseGridRowColors(model.FormKey);
|
|
|
|
gridEx.SetGridRightMenus(dtRightMenu, this.Model, OnGridViewRightCallBack);
|
|
gridEx.SetGridRowColors(dtRowColor);
|
|
|
|
if (model.IsCheck == 1) GridDragGrid.GridAddCheckBox(gridEx.GridView);
|
|
if (model.LoadFilter) gridEx.GridView.OptionsView.ShowAutoFilterRow = true;
|
|
|
|
// 拖拽
|
|
if (IsDragDetail && ParentGridEx != null && model.IsDrag)
|
|
{
|
|
var dg = new GridDragGrid(gridEx.GridView, ParentGridEx.GridView);
|
|
dg.OnDragComplete += OnDragGridCompleted;
|
|
}
|
|
if (MrpParentGridEx != null && model.IsMrpDrag)
|
|
{
|
|
var dg = new GridDragGrid(MrpParentGridEx.GridView, gridEx.GridView);
|
|
dg.OnDragComplete += OnMrpDragGridCompleted;
|
|
}
|
|
if (MrpDetailGridEx != null && model.IsMrpDrag)
|
|
{
|
|
var dg = new GridDragGrid(MrpDetailGridEx.GridView, gridEx.GridView);
|
|
dg.OnDragComplete += OnMrpDragGridCompleted;
|
|
}
|
|
|
|
if (model.MrpConditionTab) ReplaceControlEx = gridEx;
|
|
|
|
// 查询面板
|
|
if (Model != null && Model.IsDetailSearch)
|
|
{
|
|
plBottom.Visible = true;
|
|
MyControl searchObj = new MyControl(model.DetailSql, gridEx);
|
|
|
|
if (!dataCaches.GetValue(gridEx, "CustomQueryFields", out DataTable dtCustomQuery))
|
|
dtCustomQuery = BaseModuleImpl.GetCustomQueryFields(model.FormKey);
|
|
|
|
plBottom.Height = searchObj.InitSearchControl(dtCustomQuery, plBottom);
|
|
}
|
|
|
|
plMain.Controls.Add(gridEx);
|
|
parent.Controls.Add(plMain);
|
|
parent.Controls.Add(plBottom);
|
|
parentControl.Tag = gridEx;
|
|
return parent;
|
|
}
|
|
else if (isMeage.Count() > 1 && isGridmerge)
|
|
{
|
|
this.DetaiName = model.DetailName;
|
|
TabMultipledetails tabMultipledetails = hasControl && control is TabMultipledetails ? (TabMultipledetails)control : new TabMultipledetails();
|
|
tabMultipledetails.Model = this.Model;
|
|
tabMultipledetails.ParentGridEx = this.ParentGridEx;
|
|
tabMultipledetails.ParentControlEx = this.ParentControlEx;
|
|
tabMultipledetails.IsDragDetail = this.IsDragDetail;
|
|
tabMultipledetails.Model = this.Model;
|
|
tabMultipledetails.OnSaveGridCallBack += OnDetailSaveGridCallBack;
|
|
tabMultipledetails.DetailRightGridCallBack += OnDetailRightCallback;
|
|
tabMultipledetails.DrgaParentPrimaryKey = this.DrgaParentPrimaryKey;
|
|
tabMultipledetails.InitTabPages(isMeage);
|
|
tabMultipledetails.Dock = DockStyle.Fill;
|
|
tabMultipledetails.Tag = model;
|
|
parentControl.Tag = tabMultipledetails;
|
|
return tabMultipledetails;
|
|
}
|
|
/* ───── 7. 普通 ModuleGridEx 明细 ──────────────────────── */
|
|
else
|
|
{
|
|
ModuleGridEx gridEx = hasControl && control is ModuleGridEx
|
|
? (ModuleGridEx)control
|
|
: new ModuleGridEx();
|
|
|
|
if (!dataCaches.GetValue(gridEx, "DynamicModel", out DynamicModel dyncModel))
|
|
dyncModel = new DynamicModuleModel(new[]
|
|
{ model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName,
|
|
this.Model.Privilege, model.UnionModule, "0" });
|
|
|
|
if (!dataCaches.GetValue(gridEx, "SystemDllRow", out DataRow moduleRow))
|
|
moduleRow = MainImpl.GetSystemdllTab(model.UnionModule);
|
|
if (moduleRow == null)
|
|
{
|
|
MessageUtil.Show($"没有找到编号为 {model.UnionModule} 的模块信息");
|
|
return new Panel();
|
|
}
|
|
if (!dataCaches.GetValue(gridEx, "SysModel", out model.SystemModel))
|
|
model.SystemModel = new ModuleModel(moduleRow);
|
|
|
|
if (Model != null)
|
|
{
|
|
if (!dataCaches.GetValue(gridEx, "ParentPrimaryKey", out string primaryKey))
|
|
primaryKey = BaseImpl.GetBasePrimaryKey(Model.ModuleCode);
|
|
model.SystemModel.ParmaryKey = primaryKey;
|
|
}
|
|
|
|
gridEx.OnSaveGridCallBack += OnDetailSaveGridCallBack;
|
|
gridEx.DetailRightGridCallBack += OnDetailRightCallback;
|
|
|
|
gridEx.Name = "gridEx";
|
|
gridEx.IsDetail = true;
|
|
gridEx.Dock = DockStyle.Fill;
|
|
|
|
gridEx.OperShortMode = Model.IsDetailSearch;
|
|
gridEx.VisibleSearchPanel = Model.IsDetailSearch || model.DetailSearch;
|
|
|
|
if (!dataCaches.GetValue(gridEx, "UnionBaseGridRightMenus", out DataTable rightDt))
|
|
rightDt = BaseModuleImpl.GetBaseGridRightMenus(model.UnionModule, ModuleType.MrpClickBtn);
|
|
if ((rightDt?.Rows.Count > 0) || isMrpDetail)
|
|
{
|
|
isMrpDetail = true;
|
|
gridEx.VisibleMrpSearchPanel = true;
|
|
}
|
|
|
|
gridEx.VisibleOperPanel = !model.IsReadOnly;
|
|
gridEx.InitializeControl(model.SystemModel, dyncModel);
|
|
|
|
gridEx.GridControlObj.Tag = model;
|
|
gridEx.ParentControlEx = ParentControlEx;
|
|
gridEx.ParentGridEx = ParentGridEx;
|
|
gridEx.ParentKeyField = string.IsNullOrEmpty(model.UnionParentField)
|
|
? model.SystemModel.ParmaryKey
|
|
: model.UnionParentField;
|
|
gridEx.DetailKeyField = model.UnionValue;
|
|
gridEx.GridControlObj.ParentControl = gridEx.SearchObj;
|
|
if (gridEx.GridControlObj.CustomGroupBandEx != null)
|
|
{
|
|
gridEx.GridControlObj.CustomGroupBandEx.BandedView.LeftCoordChanged += OnBandedViewLeftCoordChanged;
|
|
}
|
|
if (gridEx.GridControlObj.CustomGroupTreeBandEx != null)
|
|
{
|
|
gridEx.GridControlObj.CustomGroupTreeBandEx.TreeListObj.LeftCoordChanged += OnBandedViewLeftCoordChanged;
|
|
}
|
|
//gridEx.Tag = model;
|
|
if (model.IsCheck == 1)
|
|
{
|
|
GridDragGrid.GridAddCheckBox(gridEx.GridControlObj.GridView);
|
|
if (model.RecordDetailsCheckbox &&
|
|
ParentGridEx?.GridView.OptionsSelection.MultiSelect == true)
|
|
{
|
|
gridEx.TagName = model.DetailName;
|
|
gridEx.GridControlObj.GridView.SelectionChanged += GridView_SelectionChanged;
|
|
}
|
|
}
|
|
if (model.LoadFilter)
|
|
gridEx.GridControlObj.GridView.OptionsView.ShowAutoFilterRow = true;
|
|
|
|
if (ParentGridEx != null && model.IsDrag)
|
|
{
|
|
gridEx.GridControlObj.GridView.DoubleClick += OnDetailGridViewDoubleClick;
|
|
var dg = new GridDragGrid(gridEx.GridControlObj.GridView, ParentGridEx.GridView);
|
|
dg.OnDragComplete += OnDragGridCompleted;
|
|
}
|
|
if (MrpParentGridEx != null && model.IsMrpDrag)
|
|
{
|
|
var dg = new GridDragGrid(MrpParentGridEx.GridView, gridEx.GridControlObj.GridView);
|
|
dg.OnDragComplete += OnMrpDragGridCompleted;
|
|
}
|
|
if (MrpDetailGridEx != null && model.IsMrpDrag)
|
|
{
|
|
var dg = new GridDragGrid(MrpDetailGridEx.GridView, gridEx.GridControlObj.GridView);
|
|
dg.OnDragComplete += OnMrpDragGridCompleted;
|
|
}
|
|
if (isMrpDetail && OnMrpBtnClickCallback != null)
|
|
gridEx.RightGridCallBack += OnMrpBtnClickCallback;
|
|
|
|
if (model.MrpConditionTab) ReplaceControlEx = gridEx.GridControlObj;
|
|
if (model.AutoRefresh && !_UnRefresh && isGridmerge)
|
|
gridEx.SearchObj.SearchGrid();
|
|
|
|
parentControl.Tag = gridEx.GridControlObj;
|
|
return gridEx;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 主表和当前页签中表格配置了复选框时,记录当前页签表格的选中记录
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void GridView_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
|
|
{
|
|
DataRow FatherTableRow = this.ParentGridEx.GridView.GetFocusedDataRow();
|
|
if (FatherTableRow == null) return;
|
|
|
|
XtraTabPage RefreshPage = this.xtc_container.SelectedTabPage;
|
|
|
|
Object moduleObject = RefreshPage.Controls.Cast<Object>().FirstOrDefault();
|
|
if (moduleObject is ModuleGridEx)
|
|
{
|
|
ModuleGridEx moduleGridEx = moduleObject as ModuleGridEx;
|
|
DataRow[] rowArray = moduleGridEx.GridControlObj.GetViewFocusedDataRows();
|
|
string value = string.Empty;
|
|
foreach (DataRow item in rowArray)
|
|
{
|
|
value += item[moduleGridEx.ParmaryKey] + ",";
|
|
}
|
|
value = value.Trim(',');
|
|
GridDetailModel model = GetGridDetailModel(RefreshPage);
|
|
|
|
|
|
if (ParentControlEx.DetailSelection.ContainsKey(model.DetailName))
|
|
{
|
|
Dictionary<DataRow, string> dictionary = ParentControlEx.DetailSelection[model.DetailName];
|
|
if (dictionary.ContainsKey(FatherTableRow))
|
|
{
|
|
dictionary[FatherTableRow] = value;
|
|
}
|
|
else
|
|
{
|
|
dictionary.Add(FatherTableRow, value);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Dictionary<DataRow, string> dictionary = new Dictionary<DataRow, string>();
|
|
dictionary.Add(FatherTableRow, value);
|
|
ParentControlEx.DetailSelection.Add(model.DetailName, dictionary);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取数据源缓存
|
|
/// </summary>
|
|
/// <param name="cachesDic"></param>
|
|
/// <param name="dynamicModel"></param>
|
|
/// <param name="isGridmerge"></param>
|
|
/// <param name="isAddPages"></param>
|
|
public void GetDataCaches(Dictionary<object, Hashtable> cachesDic, bool isGridmerge = true, bool isAddPages = false)
|
|
{
|
|
//获取通用数据
|
|
Task<DynamicModel> dynamicModelTask = cachesDic.GetTask<DynamicModel>(this, "DynamicModel");
|
|
Task<List<GridDetailModel>> detailsTask = cachesDic.GetTask<List<GridDetailModel>>(this, "Details");
|
|
DynamicModel dynamicModel = dynamicModelTask.Result;
|
|
List<GridDetailModel> details = detailsTask.Result;
|
|
string DetaiName = string.Empty;
|
|
PageControlsDic.Clear();
|
|
foreach (GridDetailModel model in details)
|
|
{
|
|
if (DetaiName.Equals(model.DetailName) && isGridmerge)
|
|
{
|
|
continue;
|
|
}
|
|
List<GridDetailModel> isMeage = details.Cast<GridDetailModel>().Where(x => x.DetailName.Equals(model.DetailName)).ToList();
|
|
if (model.IsChart)
|
|
{
|
|
ChartControlEx chartEx = new ChartControlEx();
|
|
Task<DataTable> chartParamsTask = cachesDic.AddTask(chartEx, "ChartParams", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetChartParams(model.FormKey);
|
|
}));
|
|
Task<DataTable> chartRightMenusTask = cachesDic.AddTask(chartEx, "ChartRightMenus", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridRightMenus(model.FormKey);
|
|
}));
|
|
PageControlsDic.Add(model, chartEx);
|
|
}
|
|
else if (model.IsExcel)
|
|
{
|
|
ExcelControlEx excelEx = new ExcelControlEx();
|
|
PageControlsDic.Add(model, excelEx);
|
|
}
|
|
else if (model.IsWebView)
|
|
{
|
|
if (SystemInfo.Instance.PrimitiveBrowser)
|
|
{
|
|
FrmMiniBlink webView = new FrmMiniBlink();
|
|
PageControlsDic.Add(model, webView);
|
|
}
|
|
else
|
|
{
|
|
FrmWebBrowser webView = new FrmWebBrowser();
|
|
PageControlsDic.Add(model, webView);
|
|
}
|
|
}
|
|
else if (model.IsWebView2)
|
|
{
|
|
if (SystemInfo.Instance.PrimitiveBrowser)
|
|
{
|
|
FrmMiniBlink webView = new FrmMiniBlink();
|
|
PageControlsDic.Add(model, webView);
|
|
}
|
|
else
|
|
{
|
|
FrmWebBrowser2 webView = new FrmWebBrowser2();
|
|
PageControlsDic.Add(model, webView);
|
|
}
|
|
}
|
|
else if (model.IsWebView3)
|
|
{
|
|
if (SystemInfo.Instance.PrimitiveBrowser)
|
|
{
|
|
FrmMiniBlink webView = new FrmMiniBlink();
|
|
PageControlsDic.Add(model, webView);
|
|
}
|
|
else
|
|
{
|
|
FrmWebBrowser2 webView = new FrmWebBrowser2();
|
|
PageControlsDic.Add(model, webView);
|
|
}
|
|
}
|
|
else if (model.IsAddPanel && isGridmerge)
|
|
{
|
|
ModulePanelEx modulePanel = new ModulePanelEx();
|
|
Task<string> basePrimaryKeyTask = cachesDic.AddTask(modulePanel, "BasePrimaryKey", new Task<string>(() =>
|
|
{
|
|
return BaseImpl.GetBasePrimaryKey(dynamicModel.ModuleCode);
|
|
}));
|
|
Task<DataRow> systemdllTabTask = cachesDic.AddTask(modulePanel, "SystemDllRow", new Task<DataRow>(() =>
|
|
{
|
|
return MainImpl.GetSystemdllTab(dynamicModel.ModuleCode);
|
|
}));
|
|
modulePanel.GetDataCaches(cachesDic, new ModuleModel(systemdllTabTask.Result), dynamicModel);
|
|
PageControlsDic.Add(model, modulePanel);
|
|
}
|
|
else if (model.IsDetailView)
|
|
{
|
|
ModuleGridDetailEx DetailEx = new ModuleGridDetailEx();
|
|
Task<DynamicModel> detailViewDynamicModelTask = cachesDic.AddTask(DetailEx, "DynamicModel", new Task<DynamicModel>(() =>
|
|
{
|
|
DynamicModuleModel dyncModel = new DynamicModuleModel(new string[] { model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, dynamicModel.Privilege, model.UnionModule, "0" });
|
|
dyncModel.DataCaches = cachesDic;
|
|
return dyncModel;
|
|
}));
|
|
Task<string> basePrimaryKeyTask = cachesDic.AddTask(DetailEx, "BasePrimaryKey", new Task<string>(() =>
|
|
{
|
|
return BaseImpl.GetBasePrimaryKey(dynamicModel.ModuleCode);
|
|
}));
|
|
Task<DataRow> detailViewSystemDllRowTask = cachesDic.AddTask(DetailEx, "SystemDllRow", new Task<DataRow>(() =>
|
|
{
|
|
return MainImpl.GetSystemdllTab(model.UnionModule);
|
|
}));
|
|
if (detailViewSystemDllRowTask.Result == null)
|
|
{
|
|
return;
|
|
}
|
|
Task<ModuleModel> detailViewSystemModelTask = cachesDic.AddTask(DetailEx, "SysModel", new Task<ModuleModel>(() =>
|
|
{
|
|
return new ModuleModel(detailViewSystemDllRowTask.Result);
|
|
}));
|
|
Task<List<GridDetailModel>> detailViewDetailsTask = cachesDic.AddTask(DetailEx, "Details", new Task<List<GridDetailModel>>(() =>
|
|
{
|
|
return GetDetails(detailViewSystemModelTask.Result.ModeCode);//底部多标签表格数据
|
|
}));
|
|
Task<DataTable> baseGridRightMenusTask = cachesDic.AddTask(DetailEx, "BaseGridRightMenus", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridRightMenus(model.UnionModule, ModuleType.MrpClickBtn);
|
|
}));
|
|
DetailEx.GetDataCaches(cachesDic);
|
|
PageControlsDic.Add(model, DetailEx);
|
|
}
|
|
else
|
|
{
|
|
if (model.IsReadOnly && isMeage.Count() == 1)
|
|
{
|
|
GridControlEx gridEx = model.AutoMultiHeader == 1 ? new BandedGridControlEx() : new GridControlEx();
|
|
Task<bool> hasExistsSettingTableTask = cachesDic.AddTask(gridEx, "HasExistsSettingTable", new Task<bool>(() =>
|
|
{
|
|
return BaseImpl.HasExistsTable(ResourceKeys.SettingTableName);
|
|
}));
|
|
Task<DataTable> setGridRightMenusTask = cachesDic.AddTask(gridEx, "RightMenuBtn", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode);
|
|
}));
|
|
Task<DataTable> sourceColumnByDatabaseTask = cachesDic.AddTask(gridEx, "CustomColumnByDatabase", new Task<DataTable>(() =>
|
|
{
|
|
string customColumKey = model.GridCustomColumnKey;
|
|
return gridEx.GridView.GetCustomColumnByDatabase(customColumKey);
|
|
}));
|
|
Task<DataTable> baseGridRightMenusTask = cachesDic.AddTask(gridEx, "BaseGridRightMenus", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridRightMenus(model.FormKey);
|
|
}));
|
|
Task<DataTable> baseGridRowColorsTask = cachesDic.AddTask(gridEx, "BaseGridRowColors", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridRowColors(model.FormKey);
|
|
}));
|
|
// 加载配置查询条件
|
|
if (dynamicModel != null && dynamicModel.IsDetailSearch)
|
|
{
|
|
Task<DataTable> customQueryFieldsTask = cachesDic.AddTask(gridEx, "CustomQueryFields", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetCustomQueryFields(model.FormKey);
|
|
}));
|
|
}
|
|
PageControlsDic.Add(model, gridEx);
|
|
}
|
|
else if (isMeage.Count() > 1 && isGridmerge)
|
|
{
|
|
DetaiName = model.DetailName;
|
|
TabMultipledetails tabMultipledetails = new TabMultipledetails();
|
|
PageControlsDic.Add(model, tabMultipledetails);
|
|
//tabMultipledetails.InitTabPages(isMeage);
|
|
}
|
|
else
|
|
{
|
|
ModuleGridEx gridEx = new ModuleGridEx();
|
|
Task<DynamicModel> gridExDynamicModelTask = cachesDic.AddTask(gridEx, "DynamicModel", new Task<DynamicModel>(() =>
|
|
{
|
|
DynamicModuleModel dyncModel = new DynamicModuleModel(new string[] { model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, dynamicModel.Privilege, model.UnionModule, "0" });
|
|
dyncModel.DataCaches = cachesDic;
|
|
return dyncModel;
|
|
}));
|
|
Task<DataRow> gridExSystemDllRowTask = cachesDic.AddTask(gridEx, "SystemDllRow", new Task<DataRow>(() =>
|
|
{
|
|
return MainImpl.GetSystemdllTab(model.UnionModule);
|
|
}));
|
|
Task<ModuleModel> gridExSystemModelTask = cachesDic.AddTask(gridEx, "SysModel", new Task<ModuleModel>(() =>
|
|
{
|
|
return new ModuleModel(gridExSystemDllRowTask.Result);
|
|
}));
|
|
if (dynamicModel != null)
|
|
{
|
|
Task<string> basePrimaryKeyTask = cachesDic.AddTask(gridEx, "ParentPrimaryKey", new Task<string>(() =>
|
|
{
|
|
string basePrimaryKey = BaseImpl.GetBasePrimaryKey(dynamicModel.ModuleCode);
|
|
return basePrimaryKey;
|
|
}));
|
|
}
|
|
Task<DataTable> baseGridRightMenusTask = cachesDic.AddTask(gridEx, "UnionBaseGridRightMenus", new Task<DataTable>(() =>
|
|
{
|
|
return BaseModuleImpl.GetBaseGridRightMenus(model.UnionModule, ModuleType.MrpClickBtn);
|
|
}));
|
|
gridEx.GetDataCaches(cachesDic);
|
|
if (model.AutoRefresh && !_UnRefresh && isGridmerge)
|
|
{
|
|
//gridEx.SearchObj.SearchGrid();
|
|
}
|
|
PageControlsDic.Add(model, gridEx);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 页签大小改变时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnPageSizeChanged(object sender, EventArgs e)
|
|
{
|
|
XtraTabPage tabPage = (XtraTabPage)sender;
|
|
if (tabPage.Tag is FrmWebBrowser)
|
|
{
|
|
// 加载网页
|
|
FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser;
|
|
}
|
|
else if (tabPage.Tag is FrmWebBrowser2)
|
|
{
|
|
// 加载网页
|
|
FrmWebBrowser2 webView = tabPage.Tag as FrmWebBrowser2;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:特殊情况绑定选项卡</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="gridDetail">The grid detail.</param>
|
|
/// <param name="parentValue">The parent value.</param>
|
|
public void InitTabPages(List<GridDetailModel> gridDetail, string parentValue)
|
|
{
|
|
this._gridDetail = gridDetail;
|
|
this.xtc_container.TabPages.Clear();
|
|
|
|
bool ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists() && SystemInfo.Instance.isExecload);
|
|
|
|
foreach (GridDetailModel model in this._gridDetail)
|
|
{
|
|
XtraTabPage page = new XtraTabPage();
|
|
page.Text = model.DetailName;
|
|
|
|
if (model.IsChart)
|
|
{
|
|
ChartControlEx chartEx = new ChartControlEx();
|
|
chartEx.Dock = DockStyle.Fill;
|
|
if (ProcessExists)
|
|
{
|
|
chartEx.SetCharts(Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields());
|
|
chartEx.SetChartRightMenus(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRightMenus(), this.Model, OnGridViewRightCallBack);
|
|
}
|
|
else
|
|
{
|
|
chartEx.SetCharts(BaseModuleImpl.GetChartParams(model.FormKey));
|
|
chartEx.SetChartRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
|
}
|
|
chartEx.Tag = model;
|
|
|
|
page.Tag = chartEx;
|
|
page.Controls.Add(chartEx);
|
|
}
|
|
else if (model.IsExcel)
|
|
{
|
|
ExcelControlEx excelEx = new ExcelControlEx();
|
|
excelEx.Dock = DockStyle.Fill;
|
|
excelEx.Tag = model;
|
|
|
|
page.Tag = excelEx;
|
|
page.Controls.Add(excelEx);
|
|
}
|
|
else
|
|
{
|
|
if (model.IsReadOnly)
|
|
{
|
|
PanelControl plTop = new PanelControl();
|
|
plTop.Dock = DockStyle.Top;
|
|
|
|
PanelControl plMain = new PanelControl();
|
|
plMain.Dock = DockStyle.Fill;
|
|
|
|
GridControlEx gridEx = new GridControlEx();
|
|
gridEx.Dock = DockStyle.Fill;
|
|
gridEx.Tag = model;
|
|
gridEx.Parent = plMain;
|
|
|
|
gridEx.Model = this.Model;
|
|
gridEx.SetReadOnlyColumns(model.GridColumns, model.GridCustomColumnKey);
|
|
|
|
if (ProcessExists)
|
|
{
|
|
gridEx.SetGridRightMenus(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRightMenus(), this.Model, OnGridViewRightCallBack);
|
|
gridEx.SetGridRowColors(Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomColumnByDatabase());
|
|
}
|
|
else
|
|
{
|
|
gridEx.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
|
gridEx.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(model.FormKey));
|
|
}
|
|
|
|
|
|
// 加载配置查询条件
|
|
if (model.IsSearch)
|
|
{
|
|
MyControl searchObj = new MyControl(model.DetailSql, gridEx);
|
|
if (!string.IsNullOrEmpty(model.UnionValue) && !string.IsNullOrEmpty(parentValue))
|
|
searchObj.WhereCond = string.Format(" and {0}='{1}'", model.UnionValue, parentValue);
|
|
plTop.Height = searchObj.InitSearchControl(BaseModuleImpl.GetCustomQueryFields(model.SystemModel.CondKey), plTop);
|
|
}
|
|
|
|
page.Tag = gridEx;
|
|
page.Controls.AddRange(new PanelControl[] { plTop, plMain });
|
|
}
|
|
else
|
|
{
|
|
DynamicModel dyncModel = new DynamicModel(new string[] { model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.Model.Privilege, model.UnionModule, "0" });
|
|
dyncModel.Params = Model.OtherParams();
|
|
//if (ProcessExists)
|
|
//{
|
|
// model.SystemModel = new ModuleModel(Lskj.Data.Caches.CacheSYSConfig.Instance().GetSystemdllTab());
|
|
//}
|
|
//else
|
|
//{
|
|
// model.SystemModel = new ModuleModel(MainImpl.GetSystemdllTab(model.UnionModule));
|
|
//}
|
|
|
|
DataRow moduleInformation = ProcessExists ? Lskj.Data.Caches.CacheSYSConfig.Instance().GetSystemdllTab() : MainImpl.GetSystemdllTab(model.UnionModule);
|
|
if (moduleInformation == null)
|
|
{
|
|
MessageUtil.Show("没有找到编号为" + model.UnionModule + "的模块信息");
|
|
return;
|
|
}
|
|
model.SystemModel = new ModuleModel(moduleInformation);
|
|
|
|
|
|
ModuleGridEx gridEx = new ModuleGridEx();
|
|
gridEx.Name = "gridEx";
|
|
gridEx.Dock = DockStyle.Fill;
|
|
gridEx.OperShortMode = false; // 不显示简短模式
|
|
gridEx.VisibleSearchPanel = model.IsSearch;
|
|
gridEx.VisibleOperPanel = true;
|
|
gridEx.ParentGridEx = this.ParentGridEx;
|
|
gridEx.ParentControlEx = this.ParentControlEx;
|
|
gridEx.ParentKeyField = string.IsNullOrEmpty(model.UnionParentField) ? model.UnionValue : model.UnionParentField;
|
|
gridEx.ParentKeyValue = parentValue;
|
|
gridEx.DetailKeyField = model.UnionValue;
|
|
gridEx.UnionKey = model.UnionValue;
|
|
gridEx.UnionValue = parentValue; //Model.ObjectId;
|
|
gridEx.InitializeControl(model.SystemModel, dyncModel);
|
|
gridEx.GridControlObj.Tag = model;
|
|
gridEx.ControlSql = ControlSql;
|
|
gridEx.GridControlObj.ParentControl = gridEx.SearchObj;
|
|
if (model.AutoRefresh)
|
|
gridEx.SearchObj.SearchGrid();
|
|
|
|
page.Tag = gridEx.GridControlObj;
|
|
page.Controls.Add(gridEx);
|
|
|
|
}
|
|
}
|
|
this.xtc_container.TabPages.Add(page);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:加载tab标签里得明细数据</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();
|
|
|
|
XtraTabPage tabPage = this.xtc_container.SelectedTabPage;
|
|
foreach (System.Windows.Forms.Control control in tabPage.Controls)
|
|
{
|
|
if (control is SplitContainer)
|
|
{
|
|
SplitContainer splitContainer = control as SplitContainer;
|
|
ModuleGridEx gcMain = splitContainer.Panel1.Tag as ModuleGridEx;
|
|
TabAddControl tabadd = splitContainer.Panel2.Tag as TabAddControl;
|
|
GridDetailModel model = tabadd.gridEx.Tag as GridDetailModel;
|
|
GridDetailModel model2 = tabadd.gridEx2.GridControlObj.Tag as GridDetailModel;
|
|
DataRow rowItem = gcMain.GridControlObj.GridView.GetFocusedDataRow();
|
|
this.ModuleGridObj = gcMain;
|
|
tabadd.PrimaryKey = this.ModuleGridObj.ParmaryKey;
|
|
if (rowItem != null && model != null)
|
|
{
|
|
string searchSql = this.GetSearchSql(model, rowItem);
|
|
tabadd.gridEx.LastSearchSql = searchSql;
|
|
tabadd.gridEx.SetGridViewDataSource(MainImpl.GetDataTableResult(tabadd.gridEx.LastSearchSql));
|
|
string searchSql2 = this.GetSearchSql(model2, rowItem);
|
|
tabadd.gridEx2.GridControlObj.LastSearchSql = searchSql2;
|
|
tabadd.gridEx2.SearchObj.SearchLastGrid();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.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="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) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : ModuleGridObj != null ? ModuleGridObj.ParmaryKey : "";
|
|
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
|
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
|
|
|
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, rowItem[fieldName] + "");
|
|
}
|
|
return sqlValue;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:判断多标签里是否有明细表</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2019-12-19 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>List<GridDetailModel>.</returns>
|
|
private List<GridDetailModel> GetDetails(string ModuleCode)
|
|
{
|
|
List<GridDetailModel> details = new List<GridDetailModel>();
|
|
|
|
DataTable table = BaseModuleImpl.GetBaseDetailPages(ModuleCode);
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
DataTable gridColumns = ReportImpl.GetReportDetailColumns(ModuleCode, item["id"] + "");
|
|
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
|
|
return details;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取TabPage绑定的实体对象</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tabPage">The tab page.</param>
|
|
/// <returns>GridDetailModel.</returns>
|
|
public GridDetailModel GetGridDetailModel(XtraTabPage tabPage)
|
|
{
|
|
if (tabPage == null) return null;
|
|
|
|
if (tabPage.Tag is GridControlEx)
|
|
return (tabPage.Tag as GridControlEx).Tag as GridDetailModel;
|
|
if (tabPage.Tag is ChartControlEx)
|
|
return (tabPage.Tag as ChartControlEx).Tag as GridDetailModel;
|
|
if (tabPage.Tag is ModuleWebView)
|
|
return (tabPage.Tag as ModuleWebView).Tag as GridDetailModel;
|
|
if (tabPage.Tag is FrmWebBrowser)
|
|
return (tabPage.Tag as FrmWebBrowser).Tag as GridDetailModel;
|
|
if (tabPage.Tag is FrmWebBrowser2)
|
|
return (tabPage.Tag as FrmWebBrowser2).Tag as GridDetailModel;
|
|
if (tabPage.Tag is FrmMiniBlink)
|
|
return (tabPage.Tag as FrmMiniBlink).Tag as GridDetailModel;
|
|
if (tabPage.Tag is TabMultipledetails)
|
|
return (tabPage.Tag as TabMultipledetails).Tag as GridDetailModel;
|
|
if (tabPage.Tag is FrmProductSched)
|
|
return (tabPage.Tag as FrmProductSched).Tag as GridDetailModel;
|
|
return null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取选中TabPage绑定的实体对象</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>GridDetailModel.</returns>
|
|
public GridDetailModel GetFocusTabPageGridDetailModel()
|
|
{
|
|
return this.GetGridDetailModel(this.xtc_container.SelectedTabPage);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置指定TabPage数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tabPage">The tab page.</param>
|
|
/// <param name="rowItem">The row item.</param>
|
|
public void SetGridDataSource(XtraTabPage tabPage, DataTable table, GridView view = null)
|
|
{
|
|
try
|
|
{
|
|
if (tabPage == null) return;
|
|
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
this.SetGridViewTabPage(tabPage, table);
|
|
}
|
|
else if (tabPage.Tag is ChartControlEx)
|
|
{
|
|
this.SetChartViewTabPage(tabPage, table, view);
|
|
}
|
|
else if (tabPage.Tag is TabMultipledetails)
|
|
{
|
|
this.SetTabMultipledetailsTabPage(tabPage, table);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
}
|
|
public void SetGridDataSource(XtraTabPage tabPage, string sqlValue, GridView view = null)
|
|
{
|
|
try
|
|
{
|
|
if (tabPage == null) return;
|
|
DataTable table = MainImpl.GetDataTableResult(sqlValue);
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
this.SetGridViewTabPage(tabPage, table);
|
|
}
|
|
else if (tabPage.Tag is ChartControlEx)
|
|
{
|
|
this.SetChartViewTabPage(tabPage, table, view);
|
|
}
|
|
else if (tabPage.Tag is FrmWebBrowser)
|
|
{
|
|
this.SetWebUrlTabPage(tabPage, sqlValue);
|
|
}
|
|
else if (tabPage.Tag is FrmWebBrowser2)
|
|
{
|
|
this.SetWebUrlTabPage2(tabPage, sqlValue);
|
|
}
|
|
else if (tabPage.Tag is FrmMiniBlink)
|
|
{
|
|
this.SetMiniBlinkWebUrlTabPage(tabPage, sqlValue);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置选中TabPage数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="table">The table.</param>
|
|
public void SetGridDataSource(DataTable table)
|
|
{
|
|
this.SetGridDataSource(this.xtc_container.SelectedTabPage, table);
|
|
}
|
|
/// <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 SetGridViewTabPage(XtraTabPage tabPage, DataTable table)
|
|
{
|
|
GridControlEx gridControl = tabPage.Tag as GridControlEx;
|
|
GridDetailModel model = gridControl.Tag as GridDetailModel;
|
|
int dataRowCount = 0;
|
|
|
|
gridControl.GridView.DoubleClick -= new EventHandler(OnGridCompleted);
|
|
if (gridControl is TreeGridControlEx)
|
|
{
|
|
TreeGridControlEx treeGridControlEx = gridControl as TreeGridControlEx;
|
|
treeGridControlEx.SetGridViewDataSource(table, false);
|
|
dataRowCount = (treeGridControlEx.TreeListObj.DataSource as DataTable).Rows.Count;
|
|
//treeGridControlEx.TreeListObj.ExpandAll();
|
|
}
|
|
else
|
|
{
|
|
|
|
gridControl.SetGridViewDataSource(table);
|
|
dataRowCount = gridControl.GridView.DataRowCount;
|
|
}
|
|
if (IsDragDetail && this.ParentGridEx != null && model.IsDrag)
|
|
{
|
|
gridControl.GridView.DoubleClick += new EventHandler(OnGridCompleted);
|
|
}
|
|
|
|
if (gridControl.CustomGroupBandEx != null)
|
|
{
|
|
tabPage.Text = model.DetailName + "(" + gridControl.CustomGroupBandEx.DataRowCount() + "条)";
|
|
}
|
|
else if (gridControl.CustomGroupTreeBandEx != null)
|
|
{
|
|
tabPage.Text = model.DetailName + "(" + gridControl.CustomGroupTreeBandEx.DataRowCount() + "条)";
|
|
}
|
|
else
|
|
{
|
|
tabPage.Text = model.DetailName + "(" + dataRowCount + ")";
|
|
}
|
|
//tabPage.Text = gridControl.CustomGroupBandEx != null ? model.DetailName + "(" + gridControl.CustomGroupBandEx.DataRowCount() + "条)" : model.DetailName + "(" + dataRowCount + ")";
|
|
tabPage.Appearance.Header.ForeColor = dataRowCount > 0 ? Color.Red : Color.FromArgb(0, 0, 0);
|
|
}
|
|
|
|
|
|
/// <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 SetTabMultipledetailsTabPage(XtraTabPage tabPage, DataTable table)
|
|
{
|
|
TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails;
|
|
|
|
GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx);
|
|
GridDetailModel MainModel = grdExMain.Tag as GridDetailModel;
|
|
grdExMain.SetGridViewDataSource(table);
|
|
GridControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx);
|
|
grdExAdditional.SetGridViewDataSource(table);
|
|
|
|
tabPage.Text = MainModel.DetailName + "(" + table.Rows.Count + ")";
|
|
tabPage.Appearance.Header.ForeColor = table.Rows.Count > 0 ? Color.Red : Color.FromArgb(0, 0, 0);
|
|
}
|
|
|
|
|
|
|
|
/// <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="chartControl">The chart control.</param>
|
|
protected void SetChartViewTabPage(XtraTabPage tabPage, DataTable table, GridView view = null)
|
|
{
|
|
ChartControlEx chartEx = tabPage.Tag as ChartControlEx;
|
|
GridDetailModel model = chartEx.Tag as GridDetailModel;
|
|
|
|
chartEx.CreateChart(table, view);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置网页Url</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="chartControl">The chart control.</param>
|
|
protected void SetWebUrlTabPage(XtraTabPage tabPage, string Url)
|
|
{
|
|
FrmWebBrowser webBrowser = tabPage.Tag as FrmWebBrowser;
|
|
webBrowser.LoadUrl(Url);
|
|
}
|
|
protected void SetWebUrlTabPage2(XtraTabPage tabPage, string Url)
|
|
{
|
|
FrmWebBrowser2 webBrowser = tabPage.Tag as FrmWebBrowser2;
|
|
webBrowser.LoadUrl(Url);
|
|
}
|
|
protected void SetMiniBlinkWebUrlTabPage(XtraTabPage tabPage, string Url)
|
|
{
|
|
FrmMiniBlink webBrowser = tabPage.Tag as FrmMiniBlink;
|
|
webBrowser.LoadUrl(Url);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </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 (this.OnRightCallback != null)
|
|
this.OnRightCallback(sender, e);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:表格双击完成</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2019-08-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
protected void OnGridCompleted(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
XtraTabPage tabPage = this.xtc_container.SelectedTabPage;
|
|
GridControlEx ge = tabPage.Tag as GridControlEx;
|
|
DataRow[] rowItems = new DataRow[] { ge.GridView.GetFocusedDataRow() };
|
|
GridColumnCollection gridColumns = this.ParentGridEx.GridView.Columns;
|
|
DataTable table = this.ParentGridEx.gridControl.DataSource as DataTable;
|
|
foreach (DataRow rowItem in rowItems)
|
|
{
|
|
DataRow newRow = table.NewRow();
|
|
foreach (GridColumn col in gridColumns)
|
|
{
|
|
if ("id".Equals(col.FieldName) || col.FieldName.Equals(this.DrgaParentPrimaryKey)) continue;
|
|
|
|
if (rowItem.Table.Columns.Contains(col.FieldName))
|
|
{
|
|
// 列中是否包含对应字段,包含则使用值
|
|
newRow[col.FieldName] = rowItem[col.FieldName];
|
|
}
|
|
else
|
|
{
|
|
// 未包含字段,则使用控件默认值.
|
|
GridColumnModel model = col.Tag as GridColumnModel;
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
|
|
if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
newRow[col.FieldName] = fieldValue;
|
|
}
|
|
}
|
|
}
|
|
table.Rows.Add(newRow);
|
|
}
|
|
|
|
this.ParentGridEx.GridView.ClearSelection();
|
|
this.ParentGridEx.GridView.SelectRowHandler(table.Rows.Count - 1);
|
|
this.ParentGridEx.GridView.UpdateCurrentRow();
|
|
this.ParentGridEx.GridView.ShowEditor();
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
// MessageUtil.Show(ResourceKeys.OperFault);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:表格拖拽完成</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
protected void OnDragGridCompleted(object sender, GridDragGridArgs e)
|
|
{
|
|
if (e.GridViewSelectRows == null || e.GridViewSelectRows.Length == 0 || this.ParentGridEx == null) return;
|
|
try
|
|
{
|
|
if (OnDragCompleteCallback != null)
|
|
{
|
|
OnDragCompleteCallback(sender, e);
|
|
}
|
|
else
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
GridColumnCollection gridColumns = this.ParentGridEx.GridView.Columns;
|
|
DataTable table = this.ParentGridEx.gridControl.DataSource as DataTable;
|
|
foreach (DataRow rowItem in e.GridViewSelectRows)
|
|
{
|
|
DataRow newRow = table.NewRow();
|
|
foreach (GridColumn col in gridColumns)
|
|
{
|
|
if ("id".Equals(col.FieldName) || col.FieldName.Equals(this.DrgaParentPrimaryKey)) continue;
|
|
|
|
if (rowItem.Table.Columns.Contains(col.FieldName))
|
|
{
|
|
// 列中是否包含对应字段,包含则使用值
|
|
newRow[col.FieldName] = rowItem[col.FieldName];
|
|
}
|
|
else
|
|
{
|
|
// 未包含字段,则使用控件默认值.
|
|
GridColumnModel model = col.Tag as GridColumnModel;
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
newRow[col.FieldName] = fieldValue;
|
|
}
|
|
}
|
|
}
|
|
table.Rows.Add(newRow);
|
|
}
|
|
this.ParentGridEx.GridView.ClearSelection();
|
|
this.ParentGridEx.GridView.SelectRowHandler(table.Rows.Count - 1);
|
|
this.ParentGridEx.GridView.UpdateCurrentRow();
|
|
this.ParentGridEx.GridView.ShowEditor();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
// MessageUtil.Show(ResourceKeys.OperFault);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:表格拖拽完成</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
protected void OnMrpDragGridCompleted(object sender, GridDragGridArgs e)
|
|
{
|
|
if (e.GridViewSelectRows == null || e.GridViewSelectRows.Length == 0 || this.MrpParentGridEx == null) return;
|
|
|
|
try
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
GridColumnCollection gridColumns = e.TargetGridViewObj.Columns;
|
|
DataTable table = e.TargetGridViewObj.GridControl.DataSource as DataTable;
|
|
ModuleModel mrpMainModule = e.SourceGridViewObj.Tag as ModuleModel;
|
|
GridControlEx gridControlEx = e.TargetGridViewObj.GridControl.Parent.Parent as GridControlEx;
|
|
|
|
GridDetailModel gridDetailModel = gridControlEx.Tag as GridDetailModel;
|
|
//if (table == null)
|
|
//{
|
|
// gridControlEx.ParentControl.SearchGrid();
|
|
// table = e.TargetGridViewObj.GridControl.DataSource as DataTable;
|
|
//}
|
|
// 验证删除存储过程
|
|
string tipMsg = string.Empty;
|
|
int[] records = new int[e.GridViewSelectRows.Length];
|
|
string ParmaryKey = mrpMainModule.ParmaryKey;
|
|
for (int i = 0; i < e.GridViewSelectRows.Length; i++)
|
|
{
|
|
DataRow item = e.GridViewSelectRows[i];
|
|
try
|
|
{
|
|
string outMsg = "";
|
|
records[i] = BaseImpl.getMrpPlanAdd(mrpMainModule.ModeCode, item[ParmaryKey] + "", out outMsg);
|
|
tipMsg += outMsg;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
//MessageUtil.Show("表格拖拽出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
//int successCount = records.Contains(1) ? records.Where(x => x == 1).Count() : 0;
|
|
//int faultCount = records.Contains(0) ? records.Where(x => x == 0).Count() : 0;
|
|
//string Msg = string.Empty;
|
|
//string filepath = string.Empty;
|
|
//string paramstr = string.Empty;
|
|
//if (successCount > 0) Msg = string.Format(ResourceKeys.DragSuccessCount, successCount);
|
|
//if (faultCount > 0) Msg += successCount > 0 ? "\r\n" : "" + string.Format(ResourceKeys.DragFaultCount, faultCount);
|
|
//Msg = string.IsNullOrWhiteSpace(Msg) ? tipMsg : Msg;
|
|
if (!string.IsNullOrWhiteSpace(tipMsg))
|
|
{
|
|
MessageUtil.Show(tipMsg);
|
|
}
|
|
if (this.OnMrpDragCallback != null)
|
|
{
|
|
OnMrpDragCallback(gridControlEx, null);
|
|
}
|
|
if (table == null) table = e.TargetGridViewObj.GridControl.DataSource as DataTable;
|
|
if (table != null)
|
|
{
|
|
e.TargetGridViewObj.ClearSelection();
|
|
e.TargetGridViewObj.SelectRowHandler(table.Rows.Count - 1);
|
|
e.TargetGridViewObj.UpdateCurrentRow();
|
|
e.TargetGridViewObj.ShowEditor();
|
|
}
|
|
//gridControlEx.ParentControl.SearchGrid();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
// MessageUtil.Show(ResourceKeys.OperFault);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 设置动态列
|
|
/// </summary>
|
|
/// <param name="tabPage"></param>
|
|
/// <param name="ColumnName"></param>
|
|
public void SetGridDisplayColumns(XtraTabPage tabPage, string ColumnName)
|
|
{
|
|
try
|
|
{
|
|
if (tabPage == null) return;
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
GridControlEx gridControl = tabPage.Tag as GridControlEx;
|
|
gridControl.SetDisplayColumns(ColumnName);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 拖拽模式DetailView明细表双击
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnDetailGridViewDoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (OnDetailViewDoubleClickCallBack != null)
|
|
{
|
|
OnDetailViewDoubleClickCallBack("Detail", null);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 提示保存所有页签中有修改的数据
|
|
/// </summary>
|
|
public bool CheckIfSaved()
|
|
{
|
|
try
|
|
{
|
|
foreach (XtraTabPage tabPage in this.TabControlObj.TabPages)
|
|
{
|
|
if (tabPage.Tag is GridControlEx && (tabPage.Tag as GridControlEx).IsDataNotSaved())
|
|
{
|
|
GridDetailModel model = this.GetGridDetailModel(tabPage);
|
|
DialogResult dialog = MessageUtil.Show(string.Format("{0}有数据未保存,是否保存", model.DetailName), MessageBoxButtons.YesNo);
|
|
if (dialog == DialogResult.Yes)
|
|
{
|
|
Object moduleObject = tabPage.Controls.Cast<Object>().FirstOrDefault();
|
|
if (moduleObject is ModuleGridEx)
|
|
{
|
|
ModuleGridEx moduleGridEx = moduleObject as ModuleGridEx;
|
|
bool SaveResults = moduleGridEx.SaveWhenSwitching();
|
|
if (!SaveResults) return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
LogHelper.Instance.WriteError(ex);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// 控件注销时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnTabControlExDisposed(object sender, EventArgs e)
|
|
{
|
|
PageControlsDic?.Clear();
|
|
DetailTabPagesDic?.Clear();
|
|
}
|
|
/// <summary>
|
|
/// 水平滚动条改变时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnBandedViewLeftCoordChanged(object sender, EventArgs e)
|
|
{
|
|
BandedGridControlEx childBandView = null;
|
|
TreeBandedGridControlEx childTreeBandView = null;
|
|
if (this.TabControlObj.SelectedTabPage != null && this.TabControlObj.SelectedTabPage.Controls.Count > 0)
|
|
{
|
|
foreach (System.Windows.Forms.Control item in this.TabControlObj.SelectedTabPage.Controls)
|
|
{
|
|
if (item is ModuleGridEx moduleGridEx && moduleGridEx.GridControlObj.CustomGroupBandEx != null)
|
|
{
|
|
childBandView = moduleGridEx.GridControlObj.CustomGroupBandEx;
|
|
break;
|
|
}
|
|
if (item is ModuleGridEx moduleGridExNew && moduleGridExNew.GridControlObj.CustomGroupTreeBandEx != null)
|
|
{
|
|
childTreeBandView = moduleGridExNew.GridControlObj.CustomGroupTreeBandEx;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
//父表格是 表格 的情况
|
|
if (childBandView != null && ParentGridEx != null && ParentGridEx.CustomGroupBandEx != null)
|
|
{
|
|
if (sender == ParentGridEx.CustomGroupBandEx.BandedView)
|
|
{
|
|
childBandView.BandedView.LeftCoord = ParentGridEx.CustomGroupBandEx.BandedView.LeftCoord;
|
|
}
|
|
else if (sender == childBandView.BandedView)
|
|
{
|
|
ParentGridEx.CustomGroupBandEx.BandedView.LeftCoord = childBandView.BandedView.LeftCoord;
|
|
}
|
|
}
|
|
if (childTreeBandView != null && ParentGridEx != null && ParentGridEx.CustomGroupBandEx != null)
|
|
{
|
|
if (sender == ParentGridEx.CustomGroupBandEx.BandedView)
|
|
{
|
|
childTreeBandView.TreeListObj.LeftCoord = ParentGridEx.CustomGroupBandEx.BandedView.LeftCoord;
|
|
}
|
|
else if (sender == childTreeBandView.TreeListObj)
|
|
{
|
|
ParentGridEx.CustomGroupBandEx.BandedView.LeftCoord = childTreeBandView.TreeListObj.LeftCoord;
|
|
}
|
|
}
|
|
//父表格是 树表格 的情况
|
|
if (childBandView != null && ParentGridEx != null && ParentGridEx.CustomGroupTreeBandEx != null)
|
|
{
|
|
if (sender == ParentGridEx.CustomGroupTreeBandEx.TreeListObj)
|
|
{
|
|
childBandView.BandedView.LeftCoord = ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoord;
|
|
}
|
|
else if (sender == childBandView.BandedView)
|
|
{
|
|
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoord = childBandView.BandedView.LeftCoord;
|
|
}
|
|
}
|
|
if (childTreeBandView != null && ParentGridEx != null && ParentGridEx.CustomGroupTreeBandEx != null)
|
|
{
|
|
if (sender == ParentGridEx.CustomGroupTreeBandEx.TreeListObj)
|
|
{
|
|
childTreeBandView.TreeListObj.LeftCoord = ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoord;
|
|
}
|
|
else if (sender == childTreeBandView.TreeListObj)
|
|
{
|
|
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoord = childTreeBandView.TreeListObj.LeftCoord;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 宽度改变事件处理,兼容BandedGridView和TreeList
|
|
/// </summary>
|
|
public void OnBandedViewColumnWidthChanged(object sender, EventArgs e)
|
|
{
|
|
BandedGridControlEx childBandView = null;
|
|
TreeBandedGridControlEx childTreeBandView = null;
|
|
if (this.TabControlObj.SelectedTabPage != null && this.TabControlObj.SelectedTabPage.Controls.Count > 0)
|
|
{
|
|
foreach (System.Windows.Forms.Control item in this.TabControlObj.SelectedTabPage.Controls)
|
|
{
|
|
if (item is ModuleGridEx moduleGridEx && moduleGridEx.GridControlObj.CustomGroupBandEx != null)
|
|
{
|
|
childBandView = moduleGridEx.GridControlObj.CustomGroupBandEx;
|
|
break;
|
|
}
|
|
if (item is ModuleGridEx moduleGridExNew && moduleGridExNew.GridControlObj.CustomGroupTreeBandEx != null)
|
|
{
|
|
childTreeBandView = moduleGridExNew.GridControlObj.CustomGroupTreeBandEx;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((childBandView != null || childTreeBandView != null) && ParentGridEx != null && (ParentGridEx.CustomGroupBandEx != null || ParentGridEx.CustomGroupTreeBandEx != null))
|
|
{
|
|
int allWidth = 0;
|
|
// 如果sender为原有的BandedView类型
|
|
if (ParentGridEx.CustomGroupBandEx != null && sender == ParentGridEx.CustomGroupBandEx.BandedView)
|
|
{
|
|
foreach (GridBand gridBand in ParentGridEx.CustomGroupBandEx.BandedView.Bands)
|
|
{
|
|
if (gridBand.Caption.Equals("基本信息"))
|
|
{
|
|
allWidth += gridBand.Width;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else if (ParentGridEx.CustomGroupTreeBandEx != null && sender == ParentGridEx.CustomGroupTreeBandEx.TreeListObj)
|
|
{
|
|
//父表格为树表格
|
|
foreach (DevExpress.XtraTreeList.Columns.TreeListBand gridBand in ParentGridEx.CustomGroupTreeBandEx.TreeListObj.Bands)
|
|
{
|
|
if (gridBand.Caption.Equals("基本信息"))
|
|
{
|
|
allWidth += gridBand.VisibleWidth;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return; // 非预期sender类型时直接退出
|
|
}
|
|
|
|
if (childBandView != null)
|
|
{
|
|
// 调整底部bandGcBottom的列宽(始终为BandedGridView类型)
|
|
List<BandedGridColumn> bottomColumnList = new List<BandedGridColumn>();
|
|
foreach (GridBand gridBand in childBandView.BandedView.Bands)
|
|
{
|
|
if (gridBand.Caption.Equals("基本信息"))
|
|
{
|
|
bottomColumnList.AddRange(gridBand.Columns.Cast<BandedGridColumn>());
|
|
break;
|
|
}
|
|
}
|
|
// 按计算好的宽度均分调整
|
|
if (bottomColumnList.Count > 0)
|
|
{
|
|
int perWidth = allWidth / bottomColumnList.Count;
|
|
foreach (BandedGridColumn bandedGridColumn in bottomColumnList)
|
|
{
|
|
bandedGridColumn.Width = perWidth;
|
|
}
|
|
}
|
|
}
|
|
//选中页签为树表格
|
|
if (childTreeBandView != null)
|
|
{
|
|
// 调整底部bandGcBottom的列宽(始终为BandedGridView类型)
|
|
List<DevExpress.XtraTreeList.Columns.TreeListColumn> bottomColumnList = new List<DevExpress. |