基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,789 @@
|
||||
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 Lskj.Control.Model;
|
||||
using Lskj.Model;
|
||||
using Lskj.Business.Impl;
|
||||
using Lskj.Data;
|
||||
using DevExpress.XtraGrid.Columns;
|
||||
using Lskj.Business;
|
||||
using Lskj.Util;
|
||||
using DevExpress.XtraGrid.Views.Grid;
|
||||
using DevExpress.XtraEditors;
|
||||
|
||||
namespace Lskj.Control
|
||||
{
|
||||
public partial class TabMultipledetails : UserControl
|
||||
{
|
||||
public TabMultipledetails()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
#region 公共变量
|
||||
/// <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 DevExpress.XtraEditors.SplitContainerControl SplitMain { get { return this.splitMainControl; } }
|
||||
/// <summary>
|
||||
/// 表一
|
||||
/// </summary>
|
||||
public ModuleGridEx gridEx1 = new ModuleGridEx();
|
||||
/// <summary>
|
||||
/// 表二
|
||||
/// </summary>
|
||||
public ModuleGridEx gridEx2 = new ModuleGridEx();
|
||||
/// <summary>
|
||||
/// tab标签
|
||||
/// </summary>
|
||||
private GridDetailModel[] _gridDetail;
|
||||
/// <summary>
|
||||
/// The system model
|
||||
/// </summary>
|
||||
public DynamicModel Model;
|
||||
/// <summary>
|
||||
/// 父表格
|
||||
/// </summary>
|
||||
public GridControlEx ParentGridEx;
|
||||
/// <summary>
|
||||
/// 父容器
|
||||
/// </summary>
|
||||
public MyControl ParentControlEx;
|
||||
/// <summary>
|
||||
/// 拖拽模式
|
||||
/// </summary>
|
||||
public bool IsDragDetail;
|
||||
/// <summary>
|
||||
/// 拖拽执行sql
|
||||
/// </summary>
|
||||
public string existDragSql;
|
||||
|
||||
/// <summary>
|
||||
/// 拖拽目标主键字段
|
||||
/// </summary>
|
||||
public string DrgaParentPrimaryKey;
|
||||
/// <summary>
|
||||
/// 左侧表刷新右侧表
|
||||
/// </summary>
|
||||
public bool UnioDetail=false;
|
||||
|
||||
#endregion
|
||||
#region
|
||||
/// <summary>
|
||||
/// 初始化完成
|
||||
/// </summary>
|
||||
private bool _isInitFinish;
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// <para>说明:绑定选项卡</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-09</para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void InitTabPages(GridDetailModel[] gridDetail)
|
||||
{
|
||||
try
|
||||
{
|
||||
this._isInitFinish = false;
|
||||
this._gridDetail = gridDetail;
|
||||
int i = 0;
|
||||
int MainTable = 0;//主表序号,1和2对应主表为第一个还是第二个
|
||||
bool ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists() && SystemInfo.Instance.isExecload);
|
||||
foreach (GridDetailModel model in this._gridDetail)
|
||||
{
|
||||
if (!model.IsAddPanel && !model.IsDetailView && !model.IsWebView && !model.IsWebView2 && !model.IsWebView3)
|
||||
{
|
||||
if (model.IsChart)
|
||||
{
|
||||
ChartControlEx chartEx = 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 (ProcessExists)
|
||||
{
|
||||
chartEx.SetCharts(Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomQueryFields());
|
||||
chartEx.SetChartRightMenus(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRightMenus(), this.Model, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
chartEx.SetCharts(BaseModuleImpl.GetChartParams(model.FormKey));
|
||||
chartEx.SetChartRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, null);
|
||||
}
|
||||
chartEx.Tag = model;
|
||||
if (i == 0)
|
||||
{
|
||||
splitMainControl.Panel1.Controls.Add(chartEx);
|
||||
splitMainControl.Panel1.Tag = chartEx;
|
||||
}
|
||||
else
|
||||
{
|
||||
splitMainControl.Panel2.Controls.Add(chartEx);
|
||||
splitMainControl.Panel2.Tag = chartEx;
|
||||
}
|
||||
}
|
||||
else if (model.IsReadOnly)
|
||||
{
|
||||
GridControlEx gridEx = model.AutoMultiHeader == 1 ? new BandedGridControlEx() : new GridControlEx();
|
||||
gridEx.Dock = DockStyle.Fill;
|
||||
gridEx.Tag = model;
|
||||
gridEx.Model = this.Model;
|
||||
gridEx.SetReadOnlyColumns(model.GridColumns, model.GridCustomColumnKey);
|
||||
//gridEx.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
||||
//gridEx.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(model.FormKey));
|
||||
if (ProcessExists)
|
||||
{
|
||||
gridEx.SetGridRightMenus(Lskj.Data.Caches.CacheSYSConfig.Instance().GetBaseGridRightMenus(), this.Model, null);
|
||||
gridEx.SetGridRowColors(Lskj.Data.Caches.CacheSYSConfig.Instance().GetCustomColumnByDatabase());
|
||||
}
|
||||
else
|
||||
{
|
||||
gridEx.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, null);
|
||||
gridEx.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(model.FormKey));
|
||||
}
|
||||
if (model.IsCheck == 1)//加载复选框
|
||||
{
|
||||
GridDragGrid.GridAddCheckBox(gridEx.GridView);
|
||||
}
|
||||
if (IsDragDetail && this.ParentGridEx != null && model.IsDrag)
|
||||
{
|
||||
// 拖拽模式,绑定拖拽对象
|
||||
GridDragGrid dragGrid = new GridDragGrid(gridEx.GridView, this.ParentGridEx.GridView);
|
||||
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragGridCompleted);
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
gridEx1.GridControlObj = gridEx;
|
||||
// 加载配置查询条件
|
||||
if (Model != null && Model.IsDetailSearch)
|
||||
{
|
||||
gridEx1.SearchObj.InitSearchControl(BaseModuleImpl.GetCustomQueryFields(model.FormKey), gridEx1.SearchPanel);
|
||||
}
|
||||
splitMainControl.Panel1.Controls.Add(gridEx);
|
||||
splitMainControl.Panel1.Tag = gridEx;
|
||||
if (!string.IsNullOrWhiteSpace(model.DragExecuteSql))
|
||||
{
|
||||
existDragSql = model.DragExecuteSql;
|
||||
MainTable = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gridEx2.GridControlObj = gridEx;// 加载配置查询条件
|
||||
if (Model != null && Model.IsDetailSearch)
|
||||
{
|
||||
gridEx2.SearchObj.InitSearchControl(BaseModuleImpl.GetCustomQueryFields(model.FormKey), gridEx2.SearchPanel);
|
||||
}
|
||||
splitMainControl.Panel2.Controls.Add(gridEx);
|
||||
splitMainControl.Panel2.Tag = gridEx;
|
||||
if (!string.IsNullOrWhiteSpace(model.DragExecuteSql))
|
||||
{
|
||||
existDragSql = model.DragExecuteSql;
|
||||
MainTable = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DynamicModel dyncModel = new DynamicModuleModel(new string[] { model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, "1", model.UnionModule, "0" });
|
||||
if (ProcessExists)
|
||||
{
|
||||
model.SystemModel = new ModuleModel(Lskj.Data.Caches.CacheSYSConfig.Instance().GetSystemdllTab());
|
||||
if (Model != null)
|
||||
model.SystemModel.ParmaryKey = Lskj.Data.Caches.CacheSYSConfig.Instance().GetBasePrimaryKey();
|
||||
}
|
||||
else
|
||||
{
|
||||
model.SystemModel = new ModuleModel(MainImpl.GetSystemdllTab(model.UnionModule));
|
||||
if (Model != null)
|
||||
model.SystemModel.ParmaryKey = BaseImpl.GetBasePrimaryKey(Model.ModuleCode);
|
||||
}
|
||||
|
||||
ModuleGridEx gridEx = new ModuleGridEx();
|
||||
gridEx.RightGridCallBack += OnGridAfterRightCallBack;
|
||||
if (model.BottomRefreshMain) gridEx.OnSaveGridCallBack += OnRefreshMainTable;
|
||||
gridEx.Name = "gridEx";
|
||||
gridEx.IsDetail = true;
|
||||
gridEx.Dock = DockStyle.Fill;
|
||||
gridEx.OperShortMode = Model.IsDetailSearch; // 不显示简短模式
|
||||
gridEx.VisibleSearchPanel = Model.IsDetailSearch;
|
||||
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.IsUnioDetail)
|
||||
{
|
||||
gridEx.GridControlObj.GridView.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(OnGridViewFocusedRowObjectChanged);
|
||||
gridEx.GridControlObj.GridView.RowCellClick += new RowCellClickEventHandler(OnRowCellClick);
|
||||
UnioDetail = true;
|
||||
}
|
||||
if (model.IsCheck == 1)
|
||||
{
|
||||
GridDragGrid.GridAddCheckBox(gridEx.GridControlObj.GridView);
|
||||
}
|
||||
if (model.QueryAgain)
|
||||
{
|
||||
gridEx.SearchObj.OnSearchAfterCallBack += SearchObj_OnSearchAfterCallBack;
|
||||
}
|
||||
|
||||
if (IsDragDetail && this.ParentGridEx != null && model.IsDrag)
|
||||
{
|
||||
// 拖拽模式,绑定拖拽对象
|
||||
GridDragGrid dragGrid = new GridDragGrid(gridEx.GridControlObj.GridView, this.ParentGridEx.GridView);
|
||||
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragGridCompleted);
|
||||
}
|
||||
if (model.AutoRefresh && !_UnRefresh)
|
||||
gridEx.SearchObj.SearchGrid();
|
||||
if (i == 0)
|
||||
{
|
||||
gridEx1 = gridEx;
|
||||
splitMainControl.Panel1.Controls.Add(gridEx);
|
||||
splitMainControl.Panel1.Tag = gridEx.GridControlObj;
|
||||
if (!string.IsNullOrWhiteSpace(model.DragExecuteSql))
|
||||
{
|
||||
existDragSql = model.DragExecuteSql;
|
||||
MainTable = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UnioDetail)
|
||||
{
|
||||
gridEx.ParentControlEx = this.gridEx1.SearchObj;
|
||||
gridEx.ParentGridEx = this.gridEx1.GridControlObj;
|
||||
}
|
||||
gridEx2 = gridEx;
|
||||
splitMainControl.Panel2.Controls.Add(gridEx);
|
||||
splitMainControl.Panel2.Tag = gridEx.GridControlObj;
|
||||
if (!string.IsNullOrWhiteSpace(model.DragExecuteSql))
|
||||
{
|
||||
existDragSql = model.DragExecuteSql;
|
||||
MainTable = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
//判断是否有推拽sql
|
||||
if (MainTable != 0)
|
||||
{
|
||||
if ((splitMainControl.Panel1.Tag is GridControlEx) && (splitMainControl.Panel2.Tag is GridControlEx))
|
||||
{
|
||||
GridControlEx grdExMain = (splitMainControl.Panel1.Tag as GridControlEx);
|
||||
GridControlEx grdExAdditional = (splitMainControl.Panel2.Tag as GridControlEx);
|
||||
if (MainTable == 1)
|
||||
{
|
||||
// 拖拽模式,绑定拖拽对象
|
||||
GridDragGrid dragGrid = new GridDragGrid(grdExMain.GridView, grdExAdditional.GridView);
|
||||
dragGrid.OnDragComplete += DragGrid_OnDragComplete;
|
||||
}
|
||||
else if (MainTable == 2)
|
||||
{
|
||||
// 拖拽模式,绑定拖拽对象
|
||||
GridDragGrid dragGrid = new GridDragGrid(grdExAdditional.GridView, grdExMain.GridView);
|
||||
dragGrid.OnDragComplete += DragGrid_OnDragComplete;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isInitFinish = true;
|
||||
InitializeSplitterPosition();
|
||||
}
|
||||
}
|
||||
//两个表间推拽时执行存储过程
|
||||
private void DragGrid_OnDragComplete(object sender, GridDragGridArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (DataRow item in e.GridViewSelectRows)
|
||||
{
|
||||
string sql = ReplaceHelper.ReplaceRowParam(item, existDragSql);
|
||||
BaseImpl.ExecSqlValue(sql);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (this.ParentControlEx != null) this.ParentControlEx.SearchGrid();
|
||||
//gridEx1.SearchObj.SearchLastGrid();
|
||||
//gridEx2.SearchObj.SearchLastGrid();
|
||||
DataRow rowItem = this.ParentGridEx.GetViewFocusedDataRow();
|
||||
int i = 0;
|
||||
foreach (GridDetailModel model in this._gridDetail)
|
||||
{
|
||||
if (model.QueryAgain)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
||||
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
||||
gridEx1.SearchObj.SearchGrid(sqlValue, true, false);
|
||||
}
|
||||
else if (1 == 1)
|
||||
{
|
||||
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
||||
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
||||
gridEx2.SearchObj.SearchGrid(sqlValue, true, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
gridEx1.SearchObj.SearchGrid();
|
||||
}
|
||||
else if (1 == 1)
|
||||
{
|
||||
gridEx2.SearchObj.SearchGrid();
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
#region 行点击改变事件
|
||||
/// <summary>
|
||||
/// <para>说明:数据行发生改变加载明细</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期: </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs"/> instance containing the event data.</param>
|
||||
protected void OnGridViewFocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
WaitForm.ShowForm();
|
||||
GridControlEx mainGridObj = splitMainControl.Panel1.Tag as GridControlEx;
|
||||
DataRow rowItem = mainGridObj.GetViewFocusedDataRow();
|
||||
if (rowItem != null)
|
||||
{
|
||||
if (splitMainControl.Panel2.Tag is GridControlEx)
|
||||
{
|
||||
GridControlEx DetailGridObj = splitMainControl.Panel2.Tag as GridControlEx;
|
||||
GridDetailModel gridMainModel = mainGridObj.Tag as GridDetailModel;
|
||||
GridDetailModel gridDetailModel = DetailGridObj.Tag as GridDetailModel;
|
||||
string primaryKey = BaseImpl.GetBasePrimaryKey(gridMainModel.UnionModule);
|
||||
string searchSql = this.GetSearchSql(gridDetailModel, rowItem, primaryKey);
|
||||
DetailGridObj.LastSearchSql = searchSql;
|
||||
DetailGridObj.SetGridViewDataSource(MainImpl.GetDataTableResult(searchSql));
|
||||
}
|
||||
else if (splitMainControl.Panel2.Tag is ChartControlEx)
|
||||
{
|
||||
ChartControlEx DetailGridObj = splitMainControl.Panel2.Tag as ChartControlEx;
|
||||
GridDetailModel gridMainModel = mainGridObj.Tag as GridDetailModel;
|
||||
GridDetailModel gridDetailModel = DetailGridObj.Tag as GridDetailModel;
|
||||
string primaryKey = BaseImpl.GetBasePrimaryKey(gridMainModel.UnionModule);
|
||||
string searchSql = this.GetSearchSql(gridDetailModel, rowItem, primaryKey);
|
||||
DetailGridObj.CreateChart(MainImpl.GetDataTableResult(searchSql));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show("加载明细数据失败!" + Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
WaitForm.HideForm();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:获取查询条件</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-11-22 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <param name="rowItem">The row item.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
protected string GetSearchSql(GridDetailModel model, DataRow rowItem, string ParmaryKey = "")
|
||||
{
|
||||
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : 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] + "");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.UnionCond))
|
||||
{
|
||||
string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond);
|
||||
sqlValue += UnionCond;
|
||||
}
|
||||
return sqlValue;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:多明细框下左边刷新右边的明细</para>
|
||||
/// <para>创建人:王一帆</para>
|
||||
/// <para>创建日期:2022-12-02 </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 OnRowCellClick(object sender, RowCellClickEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
WaitForm.ShowForm();
|
||||
GridControlEx mainGridObj = splitMainControl.Panel1.Tag as GridControlEx;
|
||||
DataRow rowItem = mainGridObj.GetViewFocusedDataRow();
|
||||
if (rowItem != null)
|
||||
{
|
||||
if (splitMainControl.Panel2.Tag is GridControlEx)
|
||||
{
|
||||
GridControlEx DetailGridObj = splitMainControl.Panel2.Tag as GridControlEx;
|
||||
GridDetailModel gridMainModel = mainGridObj.Tag as GridDetailModel;
|
||||
GridDetailModel gridDetailModel = DetailGridObj.Tag as GridDetailModel;
|
||||
string primaryKey = BaseImpl.GetBasePrimaryKey(gridMainModel.UnionModule);
|
||||
string searchSql = this.GetSearchSql(gridDetailModel, rowItem, primaryKey);
|
||||
DetailGridObj.LastSearchSql = searchSql;
|
||||
DetailGridObj.SetGridViewDataSource(MainImpl.GetDataTableResult(searchSql));
|
||||
}
|
||||
else if (splitMainControl.Panel2.Tag is ChartControlEx)
|
||||
{
|
||||
ChartControlEx DetailGridObj = splitMainControl.Panel2.Tag as ChartControlEx;
|
||||
GridDetailModel gridMainModel = mainGridObj.Tag as GridDetailModel;
|
||||
GridDetailModel gridDetailModel = DetailGridObj.Tag as GridDetailModel;
|
||||
string primaryKey = BaseImpl.GetBasePrimaryKey(gridMainModel.UnionModule);
|
||||
string searchSql = this.GetSearchSql(gridDetailModel, rowItem, primaryKey);
|
||||
DetailGridObj.CreateChart(MainImpl.GetDataTableResult(searchSql));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show("加载明细数据失败!" + Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
WaitForm.HideForm();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <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 (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-01-24</para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
private void InitializeSplitterPosition()
|
||||
{
|
||||
try
|
||||
{
|
||||
string splitterPosition = IniHelper.Read(string.Format("base_TabMultipledetailsMain_{0}", this.Model.ModuleCode));
|
||||
if (!string.IsNullOrEmpty(splitterPosition))
|
||||
{
|
||||
this.splitMainControl.SplitterPosition = Convert.ToInt32(splitterPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.splitMainControl.SplitterPosition = Screen.PrimaryScreen.WorkingArea.Width / 2;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Instance.WriteError(e);
|
||||
}
|
||||
}
|
||||
/// <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
|
||||
{
|
||||
if (_isInitFinish)
|
||||
{
|
||||
IniHelper.Write(string.Format("base_TabMultipledetailsMain_{0}", this.Model.ModuleCode), this.splitMainControl.SplitterPosition + "");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message, ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 下方表格执行右键后刷新
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnGridAfterRightCallBack(object sender, EventArgs e)
|
||||
{
|
||||
if (splitMainControl.Panel1.Tag != null && splitMainControl.Panel1.Tag is GridControlEx)
|
||||
{
|
||||
GridControlEx grdExMain = (splitMainControl.Panel1.Tag as GridControlEx);
|
||||
GridDetailModel MainModel = grdExMain.Tag as GridDetailModel;
|
||||
|
||||
if (MainModel.BottomRefreshMain)
|
||||
{
|
||||
//刷新主表,主表刷新后会默认刷新下方左右表
|
||||
int oldRowHandle = gridEx1.GridControlObj.GridView.FocusedRowHandle;//上一次选中行
|
||||
this.ParentControlEx.SearchLastGrid();
|
||||
if (gridEx1.SearchObj.RememberRow)
|
||||
{
|
||||
gridEx1.GridControlObj.GridView.SelectRowHandler(oldRowHandle);
|
||||
}
|
||||
}
|
||||
else if (MainModel.BottomDetailsRefresh)
|
||||
{
|
||||
gridEx1.SearchObj.SearchLastGrid();
|
||||
}
|
||||
}
|
||||
|
||||
if (splitMainControl.Panel2.Tag != null && splitMainControl.Panel2.Tag is GridControlEx)
|
||||
{
|
||||
GridControlEx grdExAdditional = (splitMainControl.Panel2.Tag as GridControlEx);
|
||||
GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel;
|
||||
if (AdditionalModel.BottomRefreshMain)
|
||||
{
|
||||
//刷新主表,主表刷新后会默认刷新下方左右表
|
||||
int oldRowHandle = gridEx2.GridControlObj.GridView.FocusedRowHandle;//上一次选中行
|
||||
this.ParentControlEx.SearchLastGrid();
|
||||
if (gridEx2.SearchObj.RememberRow)
|
||||
{
|
||||
gridEx2.GridControlObj.GridView.SelectRowHandler(oldRowHandle);
|
||||
}
|
||||
}
|
||||
else if (AdditionalModel.BottomDetailsRefresh)
|
||||
{
|
||||
gridEx2.SearchObj.SearchLastGrid();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下方表格保存或者执行右键后刷新
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnRefreshMainTable(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
//刷新主表,主表刷新后会默认刷新下方左右表
|
||||
int oldRowHandle = gridEx1.GridControlObj.GridView.FocusedRowHandle;//上一次选中行
|
||||
int oldRowHandle2 = gridEx2.GridControlObj.GridView.FocusedRowHandle;//上一次选中行
|
||||
this.ParentControlEx.SearchLastGrid();
|
||||
if (gridEx1.SearchObj.RememberRow)
|
||||
{
|
||||
gridEx1.GridControlObj.GridView.SelectRowHandler(oldRowHandle);
|
||||
}
|
||||
if (gridEx2.SearchObj.RememberRow)
|
||||
{
|
||||
gridEx2.GridControlObj.GridView.SelectRowHandler(oldRowHandle2);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//设置条件值
|
||||
public void SetConditionValues(DataRow dr)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.gridEx1.SearchObj != null)
|
||||
{
|
||||
foreach (ControlModel item in this.gridEx1.SearchObj.ControlModels)
|
||||
{
|
||||
if (dr.Table.Columns.Contains(item.FieldName))
|
||||
{
|
||||
this.gridEx1.SearchObj.SetControlValue(item, dr[item.FieldName] + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.gridEx2.SearchObj != null)
|
||||
{
|
||||
foreach (ControlModel item in this.gridEx2.SearchObj.ControlModels)
|
||||
{
|
||||
if (dr.Table.Columns.Contains(item.FieldName))
|
||||
{
|
||||
this.gridEx2.SearchObj.SetControlValue(item, dr[item.FieldName] + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//重新根据主表数据查询
|
||||
private void SearchObj_OnSearchAfterCallBack(object sender, EventArgs e)
|
||||
{
|
||||
DataRow rowItem = this.ParentGridEx.GetViewFocusedDataRow();
|
||||
int i = 0;
|
||||
foreach (GridDetailModel model in this._gridDetail)
|
||||
{
|
||||
if (model.QueryAgain)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
||||
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
||||
gridEx1.SearchObj.SearchGrid(sqlValue, true, false);
|
||||
}
|
||||
else if (1 == 1)
|
||||
{
|
||||
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
||||
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
||||
gridEx2.SearchObj.SearchGrid(sqlValue, true, false);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user