1147 lines
51 KiB
C#
1147 lines
51 KiB
C#
using DevExpress.Utils;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Columns;
|
|
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.PubMrpAnalyze.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.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.PubMrpAnalyze
|
|
{
|
|
public partial class MrpAnalyzeMain : UserControl
|
|
{
|
|
#region 公共变量
|
|
/// <summary>
|
|
/// 主程序的基础模型
|
|
/// </summary>
|
|
public ModuleModel MoudleMainObj;
|
|
/// <summary>
|
|
/// 主程序明细的基础模型
|
|
/// </summary>
|
|
public ModuleModel MoudleDetailObj;
|
|
public GridDetailModel GridDetailModel;
|
|
/// <summary>
|
|
/// 主程序明细的明细基础模型
|
|
/// </summary>
|
|
public ModuleModel MoudleDetailBottomObj;
|
|
public GridDetailModel GridDetailBottomModel;
|
|
/// <summary>
|
|
/// mrp动态链接库
|
|
/// </summary>
|
|
public DynamicMrpAnalyzeModel Model;
|
|
#endregion
|
|
|
|
#region 私有变量
|
|
#region 主表控件私有变量
|
|
/// <summary>
|
|
/// 主表明细key值
|
|
/// </summary>
|
|
private string _primaryMainKey;
|
|
/// <summary>
|
|
/// 主表明细keyvalue值
|
|
/// </summary>
|
|
private string _keyMainValue;
|
|
/// <summary>
|
|
///主表条件控件
|
|
/// </summary>
|
|
public MyControl SearchMainObj;
|
|
#endregion
|
|
#region 主表明细私有变量
|
|
/// <summary>
|
|
/// 主表明细key值
|
|
/// </summary>
|
|
private string _primaryDetailKey;
|
|
/// <summary>
|
|
/// 主表明细keyvalue值
|
|
/// </summary>
|
|
private string _keyDetailValue;
|
|
/// <summary>
|
|
///主表明细条件控件
|
|
/// </summary>
|
|
public MyControl SearchDetailObj;
|
|
#endregion
|
|
#region 主表明细的明细私有变量
|
|
/// <summary>
|
|
/// 主表明细key值
|
|
/// </summary>
|
|
private string _primaryDetailBottomKey;
|
|
/// <summary>
|
|
/// 主表明细keyvalue值
|
|
/// </summary>
|
|
private string _keyDetailBottomValue;
|
|
/// <summary>
|
|
///主表条件控件
|
|
/// </summary>
|
|
public MyControl SearchDetailBottomObj;
|
|
#endregion
|
|
/// <summary>
|
|
/// 主表明细
|
|
/// </summary>
|
|
private List<GridDetailModel> gridDetailModels;
|
|
/// <summary>
|
|
/// 明细拖拽行
|
|
/// </summary>
|
|
private Dictionary<DataRow, List<DataRow>> gridDragRows = new Dictionary<DataRow, List<DataRow>>();
|
|
/// <summary>
|
|
/// 明细不包含对象
|
|
/// </summary>
|
|
private List<DataRow> mainNotInRows = new List<DataRow>();
|
|
/// <summary>
|
|
/// 是否已经执行行改变事件并刷新明细数据
|
|
/// </summary>
|
|
private bool isFocusedRowChanged = true;
|
|
private HashSet<GridView> mrpDragCopyViews = new HashSet<GridView>();
|
|
#endregion
|
|
public MrpAnalyzeMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
#region 方法
|
|
/// <summary>
|
|
/// <para>说明:窗口加载</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-08 </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(DynamicMrpAnalyzeModel _model)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
this.Model = _model;
|
|
if (this.Model != null)
|
|
{
|
|
this.Model.IsDetailSearch = true;
|
|
}
|
|
if (SystemInfo.Instance.MrpTabPageType.Equals("1"))
|
|
{
|
|
this.Tab_Left_main.TabPages.Clear();
|
|
this.Tab_Left_main.TabPages.Add(this.xtraTabpageDeatil);
|
|
this.Tab_Left_main.TabPages.Add(this.xtraTabpageMain);
|
|
ERPInfo.Instance.MrpTag = "1";
|
|
}
|
|
else
|
|
{
|
|
ERPInfo.Instance.MrpTag = "0";
|
|
}
|
|
InitlizeTabControlEvent();
|
|
InitilizeSplitEvent();
|
|
InitilizeSplitPostion();
|
|
//初始化主表数据
|
|
this.InitilizeGridViewEvent();
|
|
this.InitializeMain();
|
|
//this.InitializeGridDragGrid();
|
|
//this.InitializeDeleteRightMenu();
|
|
}
|
|
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
|
|
{
|
|
|
|
}
|
|
WaitForm.HideForm();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:主界面模块构造</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitializeMain()
|
|
{
|
|
this.MoudleMainObj = new ModuleModel(MainImpl.GetSystemdllTab(Model.ModuleCode));//获取主模块构建类
|
|
if (!string.IsNullOrEmpty(this.MoudleMainObj.MenuText)) this.xtraTabpageMain.Text = this.MoudleMainObj.MenuText;
|
|
DataTable moduleDetailTable = BaseModuleImpl.GetBaseDetailPages(this.Model.ModuleCode);//获取所有主表配置明细
|
|
string queryTableCacheKey = this.MoudleMainObj.CondKey + "_queryTable";
|
|
DataTable queryTable = Manager.cacheDic.ContainsKey(queryTableCacheKey) ? Manager.cacheDic[queryTableCacheKey] : BaseModuleImpl.GetCustomQueryFields(this.MoudleMainObj.CondKey);//获取主模块构建的条件
|
|
DataTable gridColumns = BaseModuleImpl.GetBaseGridColumns(this.Model.ModuleCode);
|
|
this.gm_Control.SetReadOnlyColumns(gridColumns, GridCustomColumnStruct.BaseMainGridView + this.MoudleMainObj.FormKey);
|
|
this.MoudleMainObj.ParmaryKey = _primaryMainKey = BaseImpl.GetBasePrimaryKey(Model.ModuleCode);
|
|
this.SearchMainObj = new MyControl(this.MoudleMainObj.MenuSql, gm_Control, null, null, null);//替换sql语句中的bmp字段
|
|
this.SearchMainObj.OnDataSourceBindCallBack += OnSearchMainObjDataSourceBindCallBack;
|
|
this.gm_Control.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(MoudleMainObj.ModeCode), this.Model, OnRefreshMainData, this.SearchMainObj);
|
|
this.SearchMainObj.OnSearchAfterCallBack += new EventHandler(OnSearchAfterRefreshDetail);
|
|
//this.SearchMainObj.OnSearchBeforeCallBack += new SearchEventHandler(OnSearchMainBefore);
|
|
//配置设置模块自动搜索
|
|
this.SearchMainObj.OnDataSourceBindCallBack += new EventHandler(OnControlObjOnDataSourceBindCallBack);
|
|
if (queryTable != null && queryTable.Rows.Count > 0)
|
|
{
|
|
// 加载自定义查询条件
|
|
this.plm_top_cond.Controls.Clear();
|
|
this.SearchMainObj.InitSearchControl(queryTable, this.plm_top_cond, null);
|
|
}
|
|
else
|
|
{
|
|
// 加载固定查询条件
|
|
DataTable table = BaseModuleImpl.GetFixedQueryFields(this.Model.ModuleCode);//加载固定查询条件
|
|
this.plm_top_cbField.DisplayMember = "fieldText";
|
|
this.plm_top_cbField.ValueMember = "fieldName";
|
|
this.plm_top_cbField.DataSource = table;
|
|
this.SearchMainObj.InitDefaultSearchControl(table, this.plm_top_cond, this.plm_top_cbField.Name, this.plm_top_txtFixKey.Name, this.plm_top_btnFixSearch.Name);
|
|
}
|
|
InitializeDeatil(moduleDetailTable);
|
|
}
|
|
/// <summary>
|
|
/// 主条件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnSearchMainObjDataSourceBindCallBack(object sender, EventArgs e)
|
|
{
|
|
this.SearchMainObj.SearchGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:明细模块构造</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitializeDeatil(DataTable dataTable)
|
|
{
|
|
if (dataTable == null) return;
|
|
gridDetailModels = new List<GridDetailModel>();//表格明细对象的集合
|
|
foreach (DataRow item in dataTable.Rows)
|
|
{
|
|
GridDetailModel gridDetailModel = new GridDetailModel(item);
|
|
this.GridDetailModel = gridDetailModel;
|
|
if (int.Parse(item["orderId"] + "") == 0)//任务一:加载明细应用池(检查是否有明细并绑定事件)
|
|
{
|
|
string moduleCode = gridDetailModel.UnionModule;
|
|
this.MoudleDetailObj = new ModuleModel(MainImpl.GetSystemdllTab(moduleCode));//获取模块构建类
|
|
if (!string.IsNullOrEmpty(this.MoudleDetailObj.MenuText)) this.xtraTabpageDeatil.Text = this.MoudleDetailObj.MenuText;
|
|
this.tcMain.MrpParentGridEx = this.gd_LeftTop;
|
|
this.tcMain.MrpParentGridEx.GridView.Tag = this.MoudleDetailObj;
|
|
DataTable moduleDetailTable = BaseModuleImpl.GetBaseDetailPages(moduleCode);//获取配置明细
|
|
string queryTableCacheKey = this.MoudleDetailObj.CondKey + "_queryTable";
|
|
DataTable queryTable = Manager.cacheDic.ContainsKey(queryTableCacheKey) ? Manager.cacheDic[queryTableCacheKey] : BaseModuleImpl.GetCustomQueryFields(this.MoudleDetailObj.CondKey);//获取模块构建的条件
|
|
DataTable detailGridColumns = BaseModuleImpl.GetBaseGridColumns(moduleCode);
|
|
this.gd_LeftTop.SetReadOnlyColumns(detailGridColumns, gridDetailModel.GridCustomColumnKey);
|
|
this.MoudleDetailObj.ParmaryKey = _primaryDetailKey = BaseImpl.GetBasePrimaryKey(moduleCode);
|
|
this.SearchDetailObj = new MyControl(this.MoudleDetailObj.MenuSql, gd_LeftTop, null, null, null);//替换sql语句中的bmp字段
|
|
this.SearchDetailObj.OnDataSourceBindCallBack += OnSearchDetailObjDataSourceBindCallBack;
|
|
this.gd_LeftTop.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(MoudleDetailObj.ModeCode), this.Model, OnRefreshDetailData, this.SearchDetailObj);
|
|
this.gd_LeftTop.GridView.FocusedRowObjectChanged += GridView_FocusedRowObjectChanged;
|
|
this.SearchDetailObj.OnDataSourceBindCallBack += new EventHandler(OnControlObjOnDataSourceBindCallBack);
|
|
//this.SearchDetailObj.OnSearchBeforeCallBack += new SearchEventHandler(OnSearchDetailBefore);
|
|
if (queryTable != null && queryTable.Rows.Count > 0)
|
|
{
|
|
// 加载自定义查询条件
|
|
this.pld_top_cond.Controls.Clear();
|
|
this.SearchDetailObj.InitSearchControl(queryTable, this.pld_top_cond, null);
|
|
}
|
|
else
|
|
{
|
|
// 加载固定查询条件
|
|
DataTable table = BaseModuleImpl.GetFixedQueryFields(gridDetailModel.UnionModule);//加载固定查询条件
|
|
this.pld_top_cbField.DisplayMember = "fieldText";
|
|
this.pld_top_cbField.ValueMember = "fieldName";
|
|
this.pld_top_cbField.DataSource = table;
|
|
this.SearchDetailObj.InitDefaultSearchControl(table, this.pld_top_cond, this.pld_top_cbField.Name, this.pld_top_txtFixKey.Name, this.pld_top_btnFixSearch.Name);
|
|
}
|
|
InitializeDetailBottom(moduleDetailTable, moduleCode);
|
|
}
|
|
else
|
|
{
|
|
gridDetailModels.Add(gridDetailModel);
|
|
}
|
|
}
|
|
InitializePages(gridDetailModels);//构建右边的明细数据
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
|
|
private void OnSearchDetailObjDataSourceBindCallBack(object sender, EventArgs e)
|
|
{
|
|
this.SearchDetailObj.SearchGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:明细的明细模块构造</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitializeDetailBottom(DataTable dataTable, string _moduleCode)
|
|
{
|
|
if (dataTable == null || dataTable.Rows.Count == 0)
|
|
{
|
|
this.pld_Bottom.Visible = false;
|
|
this.splitLeftTopControl.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
return;
|
|
}
|
|
if (dataTable.Rows.Count > 0)
|
|
{
|
|
DataRow item = dataTable.Rows[0];
|
|
GridDetailModel gridDetailModel = new GridDetailModel(item);
|
|
DynamicModel dyncModel = new DynamicModuleModel(new string[] { gridDetailModel.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.Model.Privilege, gridDetailModel.UnionModule, "0" });
|
|
DataRow moduleInformation = MainImpl.GetSystemdllTab(gridDetailModel.UnionModule);
|
|
if (moduleInformation == null)
|
|
{
|
|
MessageUtil.Show("没有找到编号为" + gridDetailModel.UnionModule + "的模块信息");
|
|
return;
|
|
}
|
|
gridDetailModel.SystemModel = new ModuleModel(moduleInformation);
|
|
this.GridDetailBottomModel = gridDetailModel;
|
|
string moduleCode = gridDetailModel.UnionModule;
|
|
this.MoudleDetailBottomObj = new ModuleModel(MainImpl.GetSystemdllTab(moduleCode));//获取模块构建类
|
|
this.tcMain.MrpDetailGridEx = this.gd_LeftBottom;
|
|
this.tcMain.MrpDetailGridEx.GridView.Tag = MoudleDetailBottomObj;
|
|
string queryTableCacheKey = this.MoudleDetailBottomObj.CondKey + "_queryTable";
|
|
DataTable queryTable = Manager.cacheDic.ContainsKey(queryTableCacheKey) ? Manager.cacheDic[queryTableCacheKey] : BaseModuleImpl.GetCustomQueryFields(this.MoudleDetailBottomObj.CondKey);//获取模块构建的条件
|
|
DataTable detailGridColumns = BaseModuleImpl.GetBaseGridColumns(moduleCode);
|
|
this.gd_LeftBottom.SetReadOnlyColumns(detailGridColumns, gridDetailModel.GridCustomColumnKey);
|
|
this.MoudleDetailBottomObj.ParmaryKey = _keyDetailBottomValue = BaseImpl.GetBasePrimaryKey(moduleCode);
|
|
this.SearchDetailBottomObj = new MyControl(this.MoudleDetailBottomObj.MenuSql, this.gd_LeftBottom, null, null, null);
|
|
this.gd_LeftBottom.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(MoudleDetailBottomObj.ModeCode), this.Model, OnRefreshDetailBottomData, this.SearchDetailBottomObj);
|
|
//this.SearchDetailBottomObj.OnSearchBeforeCallBack += new SearchEventHandler(OnSearchDetailBottomBefore);
|
|
if (queryTable != null && queryTable.Rows.Count > 0)
|
|
{
|
|
// 加载自定义查询条件
|
|
this.pld_top_detail_cond.Controls.Clear();
|
|
this.SearchDetailBottomObj.InitSearchControl(queryTable, this.pld_top_detail_cond, null);
|
|
}
|
|
else
|
|
{
|
|
// 加载固定查询条件
|
|
DataTable table = BaseModuleImpl.GetFixedQueryFields(gridDetailModel.UnionModule);//加载固定查询条件
|
|
this.pld_top_detail_cbField.DisplayMember = "fieldText";
|
|
this.pld_top_detail_cbField.ValueMember = "fieldName";
|
|
this.pld_top_detail_cbField.DataSource = table;
|
|
this.SearchDetailBottomObj.InitDefaultSearchControl(table, this.pld_top_detail_cond, this.pld_top_detail_cbField.Name, this.pld_top_detail_txtFixKey.Name, this.pld_top_detail_btnFixSearch.Name);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:初始化底部多标签数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void InitializePages(List<GridDetailModel> details)
|
|
{
|
|
if (details == null || details.Count == 0)
|
|
{
|
|
this.splitLeftControl.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
}
|
|
else
|
|
{
|
|
//this.InitlizeSpiltLocation();
|
|
this.tcMain.Model = this.Model;
|
|
this.tcMain.DrgaParentPrimaryKey = this.MoudleMainObj.ParmaryKey;
|
|
this.tcMain.IsDragDetail = false;
|
|
this.tcMain.ParentGridEx = this.gm_Control;
|
|
this.tcMain.OnMrpBtnClickCallback += new EventHandler(OnGridEx_RightGridCallBack);
|
|
this.tcMain.InitTabPages(details);
|
|
this.tcMain.OnRightCallback += new EventHandler(OnGridViewRightCallBack);
|
|
this.tcMain.OnMrpDragCallback += new EventHandler(OnTcMain_OnMrpDragCallBack);
|
|
|
|
//明细只有一个选项卡时是否隐藏
|
|
if (SystemInfo.Instance.HidingIndividualDetails)
|
|
{
|
|
this.tcMain.TabControlObj.ShowTabHeader = this.tcMain.TabControlObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取底部多标签数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void SetDetailGridDataSource(XtraTabPage tabPage = null, DataRow rowItem = null, bool isNull = false)
|
|
{
|
|
//任务二:获取明细数据源刷新(仿照ModuleGridDetailEx)
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
for (int i = 0; i < this.gridDetailModels.Count; i++)
|
|
{
|
|
XtraTabPage page = this.tcMain.TabControlObj.TabPages[i];
|
|
SetTabPageDataSource(page, isNull);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("加载明细数据失败!" + Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-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>
|
|
private void SetTabPageDataSource(XtraTabPage tabPage, bool isNull = false)
|
|
{
|
|
if (isNull)
|
|
{
|
|
this.tcMain.SetGridDataSource(tabPage, new DataTable());
|
|
return;
|
|
}
|
|
GridDetailModel model = this.tcMain.GetGridDetailModel(tabPage);
|
|
DataRow rowItem = this.gm_Control.GetViewFocusedDataRow();
|
|
Object moduleObject = tabPage.Controls.Cast<Object>().FirstOrDefault();
|
|
ModuleGridEx moduleGridEx = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (moduleObject is ModuleGridEx)
|
|
{
|
|
moduleGridEx = moduleObject as ModuleGridEx;
|
|
//if (this.MoudleMainObj.RefreshTheInterface)
|
|
//{
|
|
// moduleGridEx.OnSaveGridCallBack -= ModuleGridEx_OnSaveGridCallBack;
|
|
// moduleGridEx.OnSaveGridCallBack += ModuleGridEx_OnSaveGridCallBack;
|
|
//}
|
|
}
|
|
|
|
|
|
if (model != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(model.UnionModule) && (string.IsNullOrEmpty(model.UnionValue) && string.IsNullOrEmpty(model.UnionCond))) return;
|
|
if (tabPage.Tag is FrmWebBrowser)
|
|
{
|
|
// 加载网页
|
|
string url = model.DetailSql.StartsWith("http") ? model.DetailSql : SystemInfo.Instance.OAUrl + model.DetailSql;
|
|
FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser;
|
|
webView.LoadUrl(ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(url)));
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
}
|
|
else
|
|
{
|
|
//if (rowItem != null)
|
|
//{
|
|
// string searchSql = this.GetSearchSql(model, rowItem);
|
|
// if (tabPage.Tag is GridControlEx)
|
|
// {
|
|
// (tabPage.Tag as GridControlEx).LastSearchSql = searchSql;
|
|
// }
|
|
// GridView view = this.gm_Control.GridView;
|
|
// this.tcMain.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(searchSql), view);
|
|
//}
|
|
string searchSql = this.GetSearchSql(model, rowItem);
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
(tabPage.Tag as GridControlEx).LastSearchSql = searchSql;
|
|
}
|
|
GridView view = this.gm_Control.GridView;
|
|
this.tcMain.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);
|
|
}
|
|
else if (tabPage.Tag is TabMultipledetails)
|
|
{
|
|
TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails;
|
|
GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx);
|
|
GridControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx);
|
|
GridDetailModel MainModel = grdExMain.Tag as GridDetailModel;
|
|
GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel;
|
|
//if (rowItem != null)
|
|
//{
|
|
// string searchMainSql = this.GetSearchSql(MainModel, rowItem);
|
|
// DataTable firstTable = MainImpl.GetDataTableResult(searchMainSql);
|
|
// grdExMain.SetGridViewDataSource(firstTable);
|
|
// grdExMain.LastSearchSql = searchMainSql;
|
|
//}
|
|
string searchMainSql = this.GetSearchSql(MainModel, rowItem);
|
|
DataTable firstTable = MainImpl.GetDataTableResult(searchMainSql);
|
|
grdExMain.SetGridViewDataSource(firstTable);
|
|
grdExMain.LastSearchSql = searchMainSql;
|
|
//if (rowItem != null)
|
|
//{
|
|
// string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem);
|
|
// grdExAdditional.LastSearchSql = searchAddSql;
|
|
// //tabPage.Text = MainModel.DetailName + "(" + firstTable.Rows.Count + "条)";
|
|
// if (!MainModel.IsUnioDetail)
|
|
// {
|
|
// grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql));
|
|
// }
|
|
//}
|
|
string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem);
|
|
grdExAdditional.LastSearchSql = searchAddSql;
|
|
//tabPage.Text = MainModel.DetailName + "(" + firstTable.Rows.Count + "条)";
|
|
if (!MainModel.IsUnioDetail)
|
|
{
|
|
grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql));
|
|
}
|
|
}
|
|
|
|
if (tcMain.ReplaceControlEx != null)
|
|
{
|
|
DataRow dataRow = tcMain.ReplaceControlEx.GetViewFocusedDataRow();
|
|
if (moduleObject is ModuleGridDetailEx)
|
|
{
|
|
ModuleGridDetailEx moduleGridDetailEx = moduleObject as ModuleGridDetailEx;
|
|
|
|
|
|
foreach (ControlModel item in moduleGridDetailEx.SearchObj.ControlModels)
|
|
{
|
|
if (tcMain.ReplaceControlEx.GridView.Columns.ColumnByFieldName(item.FieldName) != null)
|
|
{
|
|
string value = dataRow != null && dataRow.Table.Columns.Contains(item.FieldName) ? dataRow[item.FieldName] + "" : "";
|
|
moduleGridDetailEx.SearchObj.SetControlValue(item, value);
|
|
}
|
|
}
|
|
|
|
}
|
|
if (moduleGridEx != null)
|
|
{
|
|
|
|
|
|
foreach (ControlModel item in moduleGridEx.SearchObj.ControlModels)
|
|
{
|
|
if (tcMain.ReplaceControlEx.GridView.Columns.ColumnByFieldName(item.FieldName) != null)
|
|
{
|
|
string value = dataRow != null && dataRow.Table.Columns.Contains(item.FieldName) ? dataRow[item.FieldName] + "" : "";
|
|
moduleGridEx.SearchObj.SetControlValue(item, value);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <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>
|
|
private string GetSearchSql(GridDetailModel model, DataRow rowItem)
|
|
{
|
|
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem != null && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : _primaryMainKey;
|
|
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);
|
|
if (rowItem != null)
|
|
{
|
|
sqlValue += string.Format(" and {0}='{1}'", model.UnionValue, rowItem[fieldName] + "");
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(model.UnionCond))
|
|
{
|
|
string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond);
|
|
sqlValue += UnionCond;
|
|
}
|
|
if (!string.IsNullOrEmpty(ERPInfo.Instance.MrpTag))//替换mrp切换标记
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceUserInfo(sqlValue);
|
|
}
|
|
return sqlValue;
|
|
}
|
|
#endregion
|
|
|
|
#region 事件
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-06 </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
|
|
{
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// mrp拖拽完成后刷新数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnTcMain_OnMrpDragCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridControlEx gridControlEx = (GridControlEx)sender;
|
|
int index = 0;
|
|
DataRow focusedRow = this.gd_LeftTop.GridView.GetFocusedDataRow();
|
|
DataTable dataTable = this.gd_LeftTop.GridView.GetGridViewFilteredAndSortedDataToDataTable();
|
|
if (focusedRow != null)
|
|
{
|
|
string parmaryValue = focusedRow[_primaryDetailKey] + "";
|
|
this.SearchDetailObj.SearchGrid();
|
|
dataTable = this.gd_LeftTop.GridView.GetGridViewFilteredAndSortedDataToDataTable();
|
|
DataRow dataRow = dataTable.Select(string.Format("{0}='{1}'", _primaryDetailKey, parmaryValue)).FirstOrDefault();
|
|
if (dataRow != null)
|
|
{
|
|
index = dataTable.Rows.IndexOf(dataRow);
|
|
}
|
|
}
|
|
this.gd_LeftTop.GridView.SelectRowHandler(index);
|
|
if (dataTable == null || (dataTable != null && dataTable.Rows.Count == 0))
|
|
{
|
|
DataTable detailTable = this.gd_LeftBottom.gridControl.DataSourceTable().Clone();
|
|
this.gd_LeftBottom.SetGridViewDataSource(detailTable);
|
|
}
|
|
this.SetDetailGridDataSource();
|
|
this.EnsureRightGridFocusedCellCopy(gridControlEx);
|
|
this.RestoreRightGridCellSelection(gridControlEx);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void EnsureRightGridFocusedCellCopy(GridControlEx gridControlEx)
|
|
{
|
|
try
|
|
{
|
|
if (gridControlEx == null || gridControlEx.GridView == null) return;
|
|
|
|
GridView view = gridControlEx.GridView;
|
|
if (mrpDragCopyViews.Contains(view)) return;
|
|
|
|
view.KeyDown += OnRightGridViewKeyDown;
|
|
mrpDragCopyViews.Add(view);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
private void OnRightGridViewKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (!e.Control || e.KeyCode != Keys.C) return;
|
|
|
|
GridView view = sender as GridView;
|
|
if (view == null || view.OptionsSelection.MultiSelectMode != GridMultiSelectMode.CellSelect) return;
|
|
|
|
var cells = view.GetSelectedCells();
|
|
if (cells.Length != 0 || view.GetSelectedRows().Length == 0) return;
|
|
if (view.FocusedRowHandle < 0 || view.FocusedColumn == null) return;
|
|
|
|
object obj = view.GetFocusedRowCellDisplayText(view.FocusedColumn);
|
|
Clipboard.SetDataObject(obj == null ? string.Empty : obj + "");
|
|
e.Handled = true;
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
private void RestoreRightGridCellSelection(GridControlEx gridControlEx)
|
|
{
|
|
try
|
|
{
|
|
if (gridControlEx == null || gridControlEx.GridView == null || gridControlEx.IsDisposed || !gridControlEx.IsHandleCreated) return;
|
|
|
|
gridControlEx.BeginInvoke(new Action(() =>
|
|
{
|
|
try
|
|
{
|
|
if (gridControlEx.IsDisposed || gridControlEx.GridView == null) return;
|
|
|
|
GridView view = gridControlEx.GridView;
|
|
if (view.RowCount <= 0) return;
|
|
|
|
int rowHandle = view.FocusedRowHandle >= 0 ? view.FocusedRowHandle : 0;
|
|
GridColumn column = view.FocusedColumn ?? view.VisibleColumns.FirstOrDefault();
|
|
if (column == null) return;
|
|
|
|
view.ClearSelection();
|
|
view.FocusedRowHandle = rowHandle;
|
|
view.FocusedColumn = column;
|
|
view.SelectCell(rowHandle, column);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}));
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:数据行发生改变加载明细</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-06 </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 OnGridViewRowClick(object sender, RowClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
this.SetDetailGridDataSource();
|
|
this.isFocusedRowChanged = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("加载明细数据失败!" + Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:加载明细数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2022-12-06 </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();
|
|
if (this.isFocusedRowChanged)
|
|
{
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
this.isFocusedRowChanged = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show("加载明细数据失败!" + Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:绑定表格事件</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-06 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void InitilizeGridViewEvent()
|
|
{
|
|
this.gm_Control.GridView.RowClick += new RowClickEventHandler(OnGridViewRowClick);
|
|
this.gm_Control.GridView.RowCellClick += new RowCellClickEventHandler(OnRowCellClick);
|
|
}
|
|
/// <summary>
|
|
/// 初始化分隔条位置
|
|
/// </summary>
|
|
private void InitilizeSplitPostion()
|
|
{
|
|
string spliterLeftPosition = IniHelper.Read(string.Format("Step_spliterPositionLeft_{0}", this.Model.ModuleCode));
|
|
if (!string.IsNullOrEmpty(spliterLeftPosition)) this.splitLeftControl.SplitterPosition = Convert.ToInt32(spliterLeftPosition);
|
|
string spliterLeftTopPosition = IniHelper.Read(string.Format("Step_spliterPositionLeftTop_{0}", this.Model.ModuleCode));
|
|
if (!string.IsNullOrEmpty(spliterLeftTopPosition)) this.splitLeftTopControl.SplitterPosition = Convert.ToInt32(spliterLeftTopPosition);
|
|
}
|
|
/// <summary>
|
|
/// 绑定分隔条事件
|
|
/// </summary>
|
|
private void InitilizeSplitEvent()
|
|
{
|
|
this.splitLeftControl.SplitterPositionChanged += new EventHandler(OnSplit_SplitterPositionChanged);
|
|
this.splitLeftTopControl.SplitterPositionChanged += new EventHandler(OnSplit_SplitterPositionChanged);
|
|
}
|
|
/// <summary>
|
|
/// 绑定多标签控件事件
|
|
/// </summary>
|
|
private void InitlizeTabControlEvent()
|
|
{
|
|
this.Tab_Left_main.SelectedPageChanging += new TabPageChangingEventHandler(OnSelectedPageChanging);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:数据绑定完成后加载数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
void OnControlObjOnDataSourceBindCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
MyControl myControl = (MyControl)sender;
|
|
if (myControl != null && myControl.MainGridEx != null)
|
|
{
|
|
if (myControl.MainGridEx.GridView == this.gm_Control.GridView)
|
|
{
|
|
OnSearchMainBefore(null, null);
|
|
}
|
|
else if (myControl.MainGridEx.GridView == this.gd_LeftTop.GridView)
|
|
{
|
|
OnSearchDetailBefore(null, null);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化自定义搜索</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-06</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnSearchMainBefore(object sender, SearchArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
DataRow dataRow = MainImpl.GetDataRowResult(this.SearchMainObj.SetSearchSqlValue(ReplaceHelper.ReplaceUserInfo(this.MoudleMainObj.MenuSql)));
|
|
//GridDetailModel model = this.gm_Control.Tag as GridDetailModel;
|
|
//string parentValue = this.SearchMainObj.GetControlValue(model.UnionValue);
|
|
if (dataRow != null)
|
|
{
|
|
this._keyMainValue = dataRow[this._primaryMainKey] + "";
|
|
//左侧上下结构刷新
|
|
gm_Control.LastSearchSql = this.SearchMainObj.SetSearchSqlValue(ReplaceHelper.ReplaceUserInfo(this.MoudleMainObj.MenuSql));
|
|
gm_Control.SetGridViewDataSource(MainImpl.GetDataTableResult(gm_Control.LastSearchSql));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
private void OnSearchDetailBefore(object sender, SearchArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow dataRow = MainImpl.GetDataRowResult(this.SearchDetailObj.SetSearchSqlValue(this.MoudleDetailObj.MenuSql));
|
|
//GridDetailModel model = this.gd_LeftTop.Tag as GridDetailModel;
|
|
//string parentValue = this.SearchMainObj.GetControlValue(model.UnionValue);
|
|
if (dataRow != null)
|
|
{
|
|
this._keyDetailValue = dataRow[this._primaryDetailKey] + "";
|
|
//左侧上下结构刷新
|
|
gd_LeftTop.LastSearchSql = this.SearchDetailObj.SetSearchSqlValue(this.MoudleDetailObj.MenuSql);
|
|
gd_LeftTop.SetGridViewDataSource(MainImpl.GetDataTableResult(gd_LeftTop.LastSearchSql));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:刷新明细数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2022-12-06</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void OnSearchAfterRefreshDetail(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Object moduleObject = this.tcMain.TabControlObj.TabPages[0].Controls.Cast<Object>().FirstOrDefault();
|
|
ModuleGridEx moduleGridEx = null;
|
|
if (moduleObject != null && moduleObject is ModuleGridEx)
|
|
{
|
|
moduleGridEx = moduleObject as ModuleGridEx;
|
|
}
|
|
if (moduleGridEx != null)
|
|
{
|
|
DataTable sourceTab = moduleGridEx.GridControlObj.GridControl.DataSource as DataTable;
|
|
string detailSelectStr = "{0} not in ({1})";
|
|
string cond = "";
|
|
string parmaryKey = "";
|
|
if (this.MoudleDetailBottomObj != null)
|
|
{
|
|
parmaryKey = this._primaryDetailBottomKey;
|
|
}
|
|
else
|
|
{
|
|
parmaryKey = this._primaryDetailKey;
|
|
foreach (DataRow sourceRow in sourceTab.Rows)
|
|
{
|
|
cond += string.Format("'{0}',", sourceRow[parmaryKey] + "");
|
|
}
|
|
}
|
|
|
|
DataTable setSourceTab = Lskj.Core.SqlHelper.ExecuteDataTable(this.gd_LeftTop.LastSearchSql);
|
|
if (!string.IsNullOrEmpty(cond))
|
|
{
|
|
setSourceTab = setSourceTab.Select(cond).CopyToDataTable();
|
|
}
|
|
this.gd_LeftTop.SetGridViewDataSource(setSourceTab);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 明细行切换刷新明细
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void GridView_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow mainRow = this.gd_LeftTop.GetViewFocusedDataRow();
|
|
//if (mainRow == null)
|
|
//{
|
|
// this.gd_LeftBottom.LastSearchSql = "";
|
|
// this.gd_LeftBottom.SetGridViewDataSource(new DataTable());
|
|
// return;
|
|
//}
|
|
//if (mainRow != null)
|
|
//{
|
|
// string searchSql = this.GetSearchSql(GridDetailBottomModel, mainRow);
|
|
// DataTable sourceTab = Lskj.Core.SqlHelper.ExecuteDataTable(searchSql);
|
|
// this.gd_LeftBottom.LastSearchSql = searchSql;
|
|
// this.gd_LeftBottom.SetGridViewDataSource(sourceTab);
|
|
//}
|
|
if (SearchDetailBottomObj!=null)
|
|
{
|
|
string searchSql = this.GetSearchSql(GridDetailBottomModel, mainRow);
|
|
DataTable sourceTab = Lskj.Core.SqlHelper.ExecuteDataTable(searchSql);
|
|
this.gd_LeftBottom.LastSearchSql = searchSql;
|
|
this.gd_LeftBottom.SetGridViewDataSource(sourceTab);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 分隔条位置改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnSplit_SplitterPositionChanged(object sender, EventArgs e)
|
|
{
|
|
SplitContainerControl splitContainerControl = (SplitContainerControl)sender;
|
|
if (splitContainerControl == this.splitLeftControl)
|
|
{
|
|
IniHelper.Write(string.Format("Step_spliterPositionLeft_{0}", this.Model.ModuleCode), this.splitLeftControl.SplitterPosition + "");
|
|
}
|
|
else if (splitContainerControl == this.splitLeftTopControl)
|
|
{
|
|
IniHelper.Write(string.Format("Step_spliterPositionLeftTop_{0}", this.Model.ModuleCode), this.splitLeftTopControl.SplitterPosition + "");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// mrp模块右键执行完成后刷新左侧数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnGridEx_RightGridCallBack(object sender, EventArgs e)
|
|
{
|
|
if (this.SearchDetailObj != null)
|
|
{
|
|
this.SearchDetailObj.SearchGrid();
|
|
}
|
|
if (this.SearchDetailBottomObj != null)
|
|
{
|
|
DataTable detailTab = this.gd_LeftTop.gridControl.DataSourceTable();
|
|
if ((detailTab != null && detailTab.Rows.Count == 0) || detailTab == null)
|
|
{
|
|
this.gd_LeftBottom.SetGridViewDataSource(this.gd_LeftBottom.gridControl.DataSourceTable().Clone());
|
|
}
|
|
else
|
|
{
|
|
DataRow mainRow = this.gd_LeftTop.GetViewFocusedDataRow();
|
|
//if (mainRow != null)
|
|
//{
|
|
// string searchSql = this.GetSearchSql(GridDetailBottomModel, mainRow);
|
|
// DataTable sourceTab = Lskj.Core.SqlHelper.ExecuteDataTable(searchSql);
|
|
// this.gd_LeftBottom.LastSearchSql = searchSql;
|
|
// this.gd_LeftBottom.SetGridViewDataSource(sourceTab);
|
|
//}
|
|
string searchSql = this.GetSearchSql(GridDetailBottomModel, mainRow);
|
|
DataTable sourceTab = Lskj.Core.SqlHelper.ExecuteDataTable(searchSql);
|
|
this.gd_LeftBottom.LastSearchSql = searchSql;
|
|
this.gd_LeftBottom.SetGridViewDataSource(sourceTab);
|
|
}
|
|
}
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
/// <summary>
|
|
/// 多标签切换事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnSelectedPageChanging(object sender, TabPageChangingEventArgs e)
|
|
{
|
|
if (e.Page == this.xtraTabpageMain)
|
|
{
|
|
ERPInfo.Instance.MrpTag = "0";
|
|
DataRow focusedRow = this.gm_Control.GridView.GetFocusedDataRow();
|
|
int index = 0;
|
|
if (focusedRow != null)
|
|
{
|
|
string parmaryValue = focusedRow[_primaryMainKey] + "";
|
|
DataTable dataTable = this.gm_Control.GridView.GetGridViewFilteredAndSortedDataToDataTable();
|
|
DataRow dataRow = dataTable.Select(string.Format("{0}='{1}'", _primaryMainKey, parmaryValue)).FirstOrDefault();
|
|
if (dataRow != null)
|
|
{
|
|
index = dataTable.Rows.IndexOf(dataRow);
|
|
}
|
|
}
|
|
this.SearchMainObj.SearchGrid();
|
|
this.gm_Control.GridView.SelectRowHandler(index);
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
else if (e.Page == this.xtraTabpageDeatil)
|
|
{
|
|
ERPInfo.Instance.MrpTag = "1";
|
|
this.SearchDetailObj.SearchGrid();
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
}
|
|
private void OnRefreshMainData(object sender, EventArgs e)
|
|
{
|
|
if (this.SearchMainObj != null)
|
|
{
|
|
this.SearchMainObj.SearchGrid();
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
}
|
|
private void OnRefreshDetailData(object sender, EventArgs e)
|
|
{
|
|
if (this.SearchDetailObj != null)
|
|
{
|
|
this.SearchDetailObj.SearchGrid();
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
}
|
|
private void OnRefreshDetailBottomData(object sender, EventArgs e)
|
|
{
|
|
if (this.SearchDetailBottomObj != null)
|
|
{
|
|
this.SearchDetailBottomObj.SearchGrid();
|
|
this.SetDetailGridDataSource();
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|