ab56a9bcf7
SVN-Revision: r240
721 lines
30 KiB
C#
721 lines
30 KiB
C#
using DevExpress.Utils;
|
||
using DevExpress.XtraGrid.Views.Base;
|
||
using DevExpress.XtraGrid.Views.Grid;
|
||
using DevExpress.XtraTab;
|
||
using Lskj.Business;
|
||
using Lskj.Business.Impl;
|
||
using Lskj.Control;
|
||
using Lskj.Control.Model;
|
||
using Lskj.Data;
|
||
using Lskj.Model;
|
||
using Lskj.Util;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
|
||
namespace Lskj.PubDetailBom
|
||
{
|
||
public partial class DetailBom : UserControl
|
||
{
|
||
public DetailBom()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
#region 公有字段
|
||
/// <summary>
|
||
/// 入口实体参数
|
||
/// </summary>
|
||
public DynamicModuleDetailModel Model;
|
||
/// <summary>
|
||
/// 系统模块实体对象
|
||
/// </summary>
|
||
/// <value>The system model.</value>
|
||
public ModuleModel SysModel { get; private set; }
|
||
#endregion
|
||
|
||
#region 私有字段
|
||
/// <summary>
|
||
/// 查询条件
|
||
/// </summary>
|
||
/// <value>The search object.</value>
|
||
public MyControl SearchObj { get { return this.gcMain.SearchObj; } }
|
||
|
||
/// <summary>
|
||
/// 明细数据
|
||
/// </summary>
|
||
public List<GridDetailModel> Details;
|
||
/// <summary>
|
||
/// 左下方明细 -1
|
||
/// </summary>
|
||
public List<GridDetailModel> GridDetailleft;
|
||
/// <summary>
|
||
/// 右上方明细 -2
|
||
/// </summary>
|
||
public List<GridDetailModel> GridDetailRightTop;
|
||
/// <summary>
|
||
/// 右下方明细 -3
|
||
/// </summary>
|
||
public List<GridDetailModel> GridDetailRightBelow;
|
||
/// <summary>
|
||
/// 右中间明细 -4
|
||
/// </summary>
|
||
public List<GridDetailModel> GridDetailRightMiddle;
|
||
/// <summary>
|
||
/// 右侧页签明细 序号>=0
|
||
/// </summary>
|
||
public List<GridDetailModel> GridDetailRight;
|
||
/// <summary>
|
||
/// 初始化完成
|
||
/// </summary>
|
||
private bool _isInitFinish=false;
|
||
/// <summary>
|
||
/// 是否已经执行行改变事件并刷新明细数据
|
||
/// </summary>
|
||
public bool isFocusedRowChanged = true;
|
||
#endregion
|
||
/// <summary>
|
||
/// <para>说明:窗口加载</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2019-06-28 </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>
|
||
public void OnLoad(DynamicModuleDetailModel Model)
|
||
{
|
||
WaitForm.ShowForm();
|
||
try
|
||
{
|
||
this.Model = Model;
|
||
this.InitializeConotrl();
|
||
this.InitSpliterPosition();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError(ex, ResourceKeys.BaseModule);
|
||
//MessageUtil.Show(ex.Message + "\r\n" + ex.StackTrace);
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
}
|
||
finally
|
||
{
|
||
this._isInitFinish = true;
|
||
}
|
||
WaitForm.HideForm();
|
||
}
|
||
|
||
|
||
#region 初始化分割条位置
|
||
/// <summary>
|
||
/// <para>说明:初始化分割条位置</para>
|
||
/// <para>创建人:王一帆</para>
|
||
/// <para>创建日期:2020-06-19</para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void InitSpliterPosition()
|
||
{
|
||
string spliterPosition = IniHelper.Read(string.Format("PubDetailBom_SplitterPositionMain_{0}", this.Model.ModuleCode));
|
||
if (!string.IsNullOrEmpty(spliterPosition)) this.splitContainerControl1.SplitterPosition = Convert.ToInt32(spliterPosition);
|
||
string splitterTopPosition = IniHelper.Read(string.Format("PubDetailBom_spliterPositionTop_{0}", this.Model.ModuleCode));
|
||
if (!string.IsNullOrEmpty(splitterTopPosition)) this.splitLeftControl.SplitterPosition = Convert.ToInt32(splitterTopPosition);
|
||
string splitterBottonPosition = IniHelper.Read(string.Format("PubDetailBom_spliterPositionBotton_{0}", this.Model.ModuleCode));
|
||
if (!string.IsNullOrEmpty(splitterBottonPosition)) this.splitBottomControl.SplitterPosition = Convert.ToInt32(splitterBottonPosition);
|
||
}
|
||
#endregion
|
||
|
||
#region 分割条位置改变
|
||
/// <summary>
|
||
/// <para>说明:分割条位置改变事件</para>
|
||
/// <para>创建人:王一帆</para>
|
||
/// <para>创建日期:2020-06-19 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void splitContainer_SplitterPositionChanged(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (_isInitFinish)
|
||
{
|
||
IniHelper.Write(string.Format("PubDetailBom_SplitterPositionMain_{0}", this.Model.ModuleCode), this.splitContainerControl1.SplitterPosition + "");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
}
|
||
}
|
||
private void splitContainerTop_SplitterPositionChanged(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (this._isInitFinish)
|
||
{
|
||
IniHelper.Write(string.Format("PubDetailBom_spliterPositionTop_{0}", this.Model.ModuleCode), this.splitLeftControl.SplitterPosition + "");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
}
|
||
}
|
||
private void splitContainerBotton_SplitterPositionChanged(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (this._isInitFinish)
|
||
{
|
||
IniHelper.Write(string.Format("PubDetailBom_spliterPositionBotton_{0}", this.Model.ModuleCode), this.splitBottomControl.SplitterPosition + "");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// <para>说明:初始化主控件</para>
|
||
/// <para>创建人:王一帆</para>
|
||
/// <para>创建日期:2024-09-18 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
|
||
public void InitializeConotrl()
|
||
{
|
||
try
|
||
{
|
||
DataRow modelRow = MainImpl.GetSystemdllTab(this.Model.ModuleCode);
|
||
if (modelRow == null)
|
||
{
|
||
MessageUtil.Show("模块编号[" + this.Model.ModuleCode + "],配置错误!\r\n该模块信息未找到!");
|
||
return;
|
||
}
|
||
this.SysModel = new ModuleModel(modelRow);
|
||
this.InitializeGridControl();
|
||
this.InitializeDetailGrid();
|
||
|
||
this.gcMain.GridControlObj.GridView.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(OnGridViewFocusedRowObjectChanged);
|
||
this.gcMain.GridControlObj.GridView.RowCellClick += new RowCellClickEventHandler(GridView_RowCellClick);
|
||
this.SearchObj.OnSearchAfterCallBack += SearchObj_ClearDetails;
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||
MessageUtil.Show(Message, ex.Message);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:初始化主表控件</para>
|
||
/// <para>创建人:王一帆</para>
|
||
/// <para>创建日期:2024-09-18 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
public void InitializeGridControl()
|
||
{
|
||
this.gcMain.InitializeControl(this.SysModel, this.Model);
|
||
}
|
||
|
||
/// <summary>
|
||
/// <para>说明:初始化所有明细</para>
|
||
/// <para>创建人:曹屹峰</para>
|
||
/// <para>创建日期:2024-09-23 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void InitializeDetailGrid()
|
||
{
|
||
//左下方 编号为-1
|
||
this.GridDetailleft=this.Details.Where(o => o.Orderid == -1).ToList();
|
||
if (GridDetailleft.Count > 0)
|
||
{
|
||
GridDetailModel gridDetailModel = GridDetailleft[0];
|
||
gcDetailLeft.Tag = gridDetailModel;
|
||
gridDetailModel.SystemModel = new ModuleModel(MainImpl.GetSystemdllTab(gridDetailModel.UnionModule));
|
||
this.gcDetailLeft.SetReadOnlyColumns(gridDetailModel.GridColumns, gridDetailModel.GridCustomColumnKey);
|
||
this.gcDetailLeft.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(gridDetailModel.UnionModule));
|
||
this.gcDetailLeft.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(gridDetailModel.UnionModule), this.Model, OnGridLeftRightCallBack, null, null);//右键
|
||
}
|
||
//右上方 编号为-2
|
||
this.GridDetailRightTop = this.Details.Where(o => o.Orderid == -2).ToList();
|
||
if (GridDetailRightTop.Count > 0)
|
||
{
|
||
GridDetailModel gridDetailModel = GridDetailRightTop[0];
|
||
gridControlEx2.Tag = gridDetailModel;
|
||
gridDetailModel.SystemModel = new ModuleModel(MainImpl.GetSystemdllTab(gridDetailModel.UnionModule));
|
||
this.gridControlEx2.SetReadOnlyColumns(gridDetailModel.GridColumns, gridDetailModel.GridCustomColumnKey);
|
||
this.gridControlEx2.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(gridDetailModel.UnionModule));
|
||
this.gridControlEx2.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(gridDetailModel.UnionModule), this.Model, null, null, null);//右键
|
||
//this.label1.Text = gridDetailModel.SystemModel.MenuText;
|
||
this.label1.Text = gridDetailModel.DetailName;
|
||
this.gridControlEx2.GridView.OptionsView.ShowFooter = false; // 隐藏合计行
|
||
this.gridControlEx2.GridView.OptionsView.ShowIndicator = false; // 隐藏序号列
|
||
}
|
||
//右下方 编号为-3
|
||
this.GridDetailRightBelow = this.Details.Where(o => o.Orderid == -3).ToList();
|
||
if (GridDetailRightBelow.Count > 0)
|
||
{
|
||
GridDetailModel gridDetailModel = GridDetailRightBelow[0];
|
||
gridControlEx1.Tag = gridDetailModel;
|
||
gridDetailModel.SystemModel = new ModuleModel(MainImpl.GetSystemdllTab(gridDetailModel.UnionModule));
|
||
this.gridControlEx1.SetReadOnlyColumns(gridDetailModel.GridColumns, gridDetailModel.GridCustomColumnKey);
|
||
this.gridControlEx1.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(gridDetailModel.UnionModule));
|
||
this.gridControlEx1.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(gridDetailModel.UnionModule), this.Model, null, null, null);//右键
|
||
this.gridControlEx1.GridView.OptionsView.ShowFooter = false; // 隐藏合计行
|
||
this.gridControlEx1.GridView.OptionsView.ShowIndicator = false; // 隐藏序号列
|
||
}
|
||
//右上方第二个(Tab_Top) 编号为-4
|
||
this.GridDetailRightMiddle = this.Details.Where(o => o.Orderid == -4).ToList();
|
||
if (GridDetailRightMiddle.Count > 0)
|
||
{
|
||
List<GridDetailModel> newList = new List<GridDetailModel> { GridDetailRightMiddle[0] };
|
||
this.Tab_Top.Model = this.Model;
|
||
this.Tab_Top.DrgaParentPrimaryKey = this.SysModel.ParmaryKey;
|
||
this.Tab_Top.ParentControlEx = this.SearchObj;
|
||
this.Tab_Top.ParentGridEx = this.gcMain.GridControlObj;
|
||
this.Tab_Top.InitTabPages(newList);
|
||
this.Tab_Top.OnRightCallback += new EventHandler(OnGridViewRightCallBack_Top);
|
||
|
||
this.Tab_Top.TabControlObj.ShowTabHeader =DefaultBoolean.False ;
|
||
}
|
||
//右侧整体明细页签 编号>=0
|
||
this.GridDetailRight = this.Details.Where(o => o.Orderid >=0).ToList();
|
||
if (GridDetailRight.Count > 0)
|
||
{
|
||
this.Tab_Bottom.Model = this.Model;
|
||
this.Tab_Bottom.DrgaParentPrimaryKey = this.SysModel.ParmaryKey;
|
||
this.Tab_Bottom.ParentControlEx = this.SearchObj;
|
||
this.Tab_Bottom.ParentGridEx = this.gcMain.GridControlObj;
|
||
this.Tab_Bottom.InitTabPages(this.GridDetailRight);
|
||
this.Tab_Bottom.OnRightCallback += new EventHandler(OnGridViewRightCallBack_Bottom);
|
||
}
|
||
}
|
||
|
||
|
||
#region 刷新所有明细
|
||
/// <summary>
|
||
/// <para>说明:刷新所有明细</para>
|
||
/// <para>创建人:曹屹峰</para>
|
||
/// <para>创建日期:2024-09-23 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void RefreshAllDetails()
|
||
{
|
||
try
|
||
{
|
||
WaitForm.ShowForm();
|
||
DataRow rowItem = this.gcMain.GridControlObj.GetViewFocusedDataRow();
|
||
//-1
|
||
if (GridDetailleft.Count>=0)
|
||
{
|
||
GridDetailModel model = GridDetailleft[0];
|
||
if (rowItem == null)
|
||
{
|
||
this.gcDetailLeft.SetGridViewDataSource(new DataTable());
|
||
}
|
||
else
|
||
{
|
||
string searchSql = this.GetSearchSql(model, rowItem);
|
||
this.gcDetailLeft.LastSearchSql = searchSql;
|
||
this.gcDetailLeft.SetGridViewDataSource(MainImpl.GetDataTableResult(gcDetailLeft.LastSearchSql));
|
||
}
|
||
}
|
||
//-2
|
||
if (GridDetailRightTop.Count > 0)
|
||
{
|
||
GridDetailModel model = GridDetailRightTop[0];
|
||
if (rowItem == null)
|
||
{
|
||
this.gridControlEx2.SetGridViewDataSource(new DataTable());
|
||
}
|
||
else
|
||
{
|
||
string searchSql = this.GetSearchSql(model, rowItem);
|
||
this.gridControlEx2.LastSearchSql = searchSql;
|
||
this.gridControlEx2.SetGridViewDataSource(MainImpl.GetDataTableResult(gridControlEx2.LastSearchSql));
|
||
}
|
||
}
|
||
//-3
|
||
if (rowItem != null && GridDetailRightBelow.Count > 0)
|
||
{
|
||
GridDetailModel model = GridDetailRightBelow[0];
|
||
if (rowItem == null)
|
||
{
|
||
this.gridControlEx1.SetGridViewDataSource(new DataTable());
|
||
}
|
||
else
|
||
{
|
||
string searchSql = this.GetSearchSql(model, rowItem);
|
||
this.gridControlEx1.LastSearchSql = searchSql;
|
||
this.gridControlEx1.SetGridViewDataSource(MainImpl.GetDataTableResult(gridControlEx1.LastSearchSql));
|
||
}
|
||
}
|
||
//-4
|
||
if (GridDetailRightMiddle.Count > 0)
|
||
{
|
||
this.SetDetailGridDataSource(this.Tab_Top);
|
||
}
|
||
|
||
//序号>=0
|
||
if (GridDetailRight.Count > 0)
|
||
{
|
||
this.SetDetailGridDataSource(this.Tab_Bottom);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
finally
|
||
{
|
||
WaitForm.HideForm();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// <para>说明:获取底部多标签数据</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-12-19 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
public void SetDetailGridDataSource(TabControlEx tabControlEx,XtraTabPage tabPage = null)
|
||
{
|
||
if (tabPage != null)
|
||
{
|
||
this.SetTabPageDataSource(tabPage, tabControlEx);
|
||
}
|
||
else
|
||
{
|
||
DataRow rowItem = this.gcMain.GridControlObj.GetViewFocusedDataRow();
|
||
if (this.SysModel.RefreshDetail == "0")
|
||
{
|
||
XtraTabPage RefreshPage = tabControlEx.TabControlObj.SelectedTabPage;
|
||
if (rowItem != null && RefreshPage != null)
|
||
{
|
||
this.SetTabPageDataSource(RefreshPage, tabControlEx);
|
||
}
|
||
else
|
||
{
|
||
SetTabPageDataSource(RefreshPage, tabControlEx, true);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
foreach (XtraTabPage page in tabControlEx.TabControlObj.TabPages)
|
||
{
|
||
|
||
if (rowItem != null && page != null)
|
||
{
|
||
this.SetTabPageDataSource(page, tabControlEx);
|
||
}
|
||
else
|
||
{
|
||
SetTabPageDataSource(page, tabControlEx, true);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// <para>说明:设置表格数据</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2018-01-29 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="tabPage">The tab page.</param>
|
||
/// <param name="index">1为Tab_Top(序号=-4),2为Tab_Bottom(序号>=0)</param>
|
||
protected void SetTabPageDataSource(XtraTabPage tabPage, TabControlEx tabControlEx,bool isNull = false)
|
||
{
|
||
if (isNull)
|
||
{
|
||
tabControlEx.SetGridDataSource(tabPage, new DataTable());
|
||
return;
|
||
}
|
||
GridDetailModel model = tabControlEx.GetGridDetailModel(tabPage);
|
||
DataRow rowItem = this.gcMain.GridControlObj.GetViewFocusedDataRow();
|
||
Object moduleObject = tabPage.Controls.Cast<Object>().FirstOrDefault();
|
||
ModuleGridEx moduleGridEx = null;
|
||
//if (moduleObject is ModuleGridEx)
|
||
//{
|
||
// moduleGridEx = moduleObject as ModuleGridEx;
|
||
// if (this.SysModel.RefreshTheInterface)//
|
||
// {
|
||
// moduleGridEx.OnSaveGridCallBack -= OnSaveGridCallBack;
|
||
// moduleGridEx.OnSaveGridCallBack += OnSaveGridCallBack;
|
||
// }
|
||
//}
|
||
if (rowItem != null && model != null)
|
||
{
|
||
if (!string.IsNullOrEmpty(model.UnionModule) && (string.IsNullOrEmpty(model.UnionValue) && string.IsNullOrEmpty(model.UnionCond))) return;
|
||
if (tabPage.Tag is FrmWebBrowser)
|
||
{
|
||
// 加载网页
|
||
FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser;
|
||
string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
||
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
||
//webView.FrmLoad(url);
|
||
webView.LoadUrl(url);
|
||
webView.Dock = DockStyle.Fill;
|
||
webView.Tag = model;
|
||
}
|
||
else if (tabPage.Tag is FrmWebBrowser2)
|
||
{
|
||
// 加载网页
|
||
FrmWebBrowser2 webView = tabPage.Tag as FrmWebBrowser2;
|
||
string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
||
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
||
webView.LoadUrl(url);
|
||
webView.Dock = DockStyle.Fill;
|
||
webView.Tag = model;
|
||
}
|
||
else if (tabPage.Tag is FrmMiniBlink)
|
||
{
|
||
// 加载网页
|
||
FrmMiniBlink webView = tabPage.Tag as FrmMiniBlink;
|
||
string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql));
|
||
url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url;
|
||
webView.LoadUrl(url);
|
||
webView.Dock = DockStyle.Fill;
|
||
webView.Tag = model;
|
||
}
|
||
else if (rowItem != null && tabPage.Tag is TabMultipledetails)
|
||
{
|
||
TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails;
|
||
tabMultipledetails.SetConditionValues(rowItem);
|
||
GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx);
|
||
GridDetailModel MainModel = grdExMain.Tag as GridDetailModel;
|
||
string searchMainSql = this.GetSearchSql(MainModel, rowItem);
|
||
DataTable firstTable = MainImpl.GetDataTableResult(searchMainSql);
|
||
grdExMain.LastSearchSql = searchMainSql;
|
||
grdExMain.SetGridViewDataSource(firstTable);
|
||
if (tabMultipledetails.SplitMain.Panel2.Tag is GridControlEx)
|
||
{
|
||
GridControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx);
|
||
GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel;
|
||
string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem);
|
||
if (!MainModel.IsUnioDetail)
|
||
{
|
||
grdExAdditional.LastSearchSql = searchAddSql;
|
||
grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql));
|
||
}
|
||
//右侧是左侧的明细,左侧没有数据时。右侧赋空值(因为无法触发左侧行改变事件)
|
||
if (MainModel.IsUnioDetail && firstTable.Rows.Count == 0)
|
||
{
|
||
grdExAdditional.LastSearchSql = "";
|
||
grdExAdditional.SetGridViewDataSource(new DataTable());
|
||
}
|
||
}
|
||
else if (tabMultipledetails.SplitMain.Panel2.Tag is ChartControlEx)
|
||
{
|
||
ChartControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as ChartControlEx);
|
||
GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel;
|
||
string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem);
|
||
DataTable table = MainImpl.GetDataTableResult(searchAddSql);
|
||
grdExAdditional.CreateChart(table);
|
||
}
|
||
|
||
tabPage.Text = MainModel.DetailName + "(" + firstTable.Rows.Count + "条)";
|
||
tabPage.Appearance.Header.ForeColor = firstTable.Rows.Count > 0 ? Color.Red : Color.FromArgb(0, 0, 0);
|
||
}
|
||
else
|
||
{
|
||
string searchSql = this.GetSearchSql(model, rowItem);
|
||
|
||
//if (moduleGridEx != null&& moduleGridEx.SearchObj!=null)
|
||
//{
|
||
// searchSql= moduleGridEx.SearchObj.SetSearchSqlValue(searchSql);
|
||
//}
|
||
|
||
if (tabPage.Tag is GridControlEx)
|
||
{
|
||
(tabPage.Tag as GridControlEx).LastSearchSql = searchSql;
|
||
}
|
||
GridView view = this.gcMain.GridControlObj.GridView;
|
||
//DataTable dataTable = MainImpl.GetDataTableResult(searchSql);//明细数据源
|
||
tabControlEx.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(searchSql), view);
|
||
if (tabPage.Tag is GridControlEx && (tabPage.Tag as GridControlEx).ParentControl != null)
|
||
(tabPage.Tag as GridControlEx).ParentControl.SetAllControlValue(rowItem);
|
||
//配置明细直接根据条件加载
|
||
if (model.SystemModel != null && 1 == model.SystemModel.isFirstLoad)
|
||
{
|
||
(tabPage.Tag as GridControlEx).ParentControl.SearchGrid();
|
||
tabPage.Text = model.DetailName + "(" + (tabPage.Tag as GridControlEx).ParentControl.GridRowCount + "条)";
|
||
}
|
||
}
|
||
if (moduleGridEx != null) moduleGridEx.ParentButtonState(rowItem);
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
|
||
|
||
/// <summary>
|
||
/// 主表行改变事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void OnGridViewFocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e)
|
||
{
|
||
this.RefreshAllDetails();
|
||
this.isFocusedRowChanged = false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 点击主表
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void GridView_RowCellClick(object sender, RowCellClickEventArgs e)
|
||
{
|
||
if (this.isFocusedRowChanged)
|
||
{
|
||
this.RefreshAllDetails();
|
||
}
|
||
this.isFocusedRowChanged = true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主表查询后
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void SearchObj_ClearDetails(object sender, EventArgs e)
|
||
{
|
||
//主表内容为空时清空所有明细数据
|
||
if (this.gcMain.GridControlObj.gridControl.DataSourceTable().Rows.Count == 0)
|
||
{
|
||
this.RefreshAllDetails();
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 明细右键后刷新当前明细
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void OnGridViewRightCallBack_Top(object sender, EventArgs e)
|
||
{
|
||
if (GridDetailRightMiddle.Count > 0)
|
||
{
|
||
this.SetDetailGridDataSource(this.Tab_Top);
|
||
}
|
||
}
|
||
private void OnGridViewRightCallBack_Bottom(object sender, EventArgs e)
|
||
{
|
||
if (GridDetailRight.Count > 0)
|
||
{
|
||
this.SetDetailGridDataSource(this.Tab_Bottom);
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 明细右键后刷新主表
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void OnGridLeftRightCallBack(object sender, EventArgs e)
|
||
{
|
||
DataRow rowItem = this.gcMain.GridControlObj.GetViewFocusedDataRow();
|
||
//-1
|
||
if (GridDetailleft.Count >= 0)
|
||
{
|
||
GridDetailModel model = GridDetailleft[0];
|
||
if (rowItem == null)
|
||
{
|
||
this.gcDetailLeft.SetGridViewDataSource(new DataTable());
|
||
}
|
||
else
|
||
{
|
||
string searchSql = this.GetSearchSql(model, rowItem);
|
||
this.gcDetailLeft.LastSearchSql = searchSql;
|
||
this.gcDetailLeft.SetGridViewDataSource(MainImpl.GetDataTableResult(gcDetailLeft.LastSearchSql));
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// <para>说明:获取查询条件</para>
|
||
/// <para>创建人:龚宇超</para>
|
||
/// <para>创建日期:2017-11-22 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="model">The model.</param>
|
||
/// <param name="rowItem">The row item.</param>
|
||
/// <returns>System.String.</returns>
|
||
protected string GetSearchSql(GridDetailModel model, DataRow rowItem, bool isLeft = false)
|
||
{
|
||
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : this.gcMain.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))
|
||
{
|
||
string WhereConnect = rowItem.Table.Columns.Contains(fieldName) ? string.Format(" and {0}='{1}'", model.UnionValue, rowItem[fieldName] + "") : "and 1<>1";
|
||
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + WhereConnect;
|
||
}
|
||
if (!string.IsNullOrEmpty(model.UnionCond))
|
||
{
|
||
string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond);
|
||
sqlValue += UnionCond;
|
||
}
|
||
return sqlValue;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
}
|
||
}
|