ab56a9bcf7
SVN-Revision: r240
395 lines
16 KiB
C#
395 lines
16 KiB
C#
/******************************
|
|
* 说明:多标签界面
|
|
* 创建人:龚宇超
|
|
* 创建日期:2018-04-04
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
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;
|
|
using Lskj.Control;
|
|
using Lskj.Model;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Util;
|
|
using Lskj.Data;
|
|
using Lskj.Business.Impl;
|
|
using DevExpress.XtraTab;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.Utils;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
|
|
namespace Lskj.PubPageDetail2
|
|
{
|
|
/// <summary>
|
|
/// 多标签界面
|
|
/// </summary>
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
public DynamicPageDetailModel Model;
|
|
/// <summary>
|
|
/// 顶部表格控件
|
|
/// </summary>
|
|
public ModuleGridEx ModuleGridObj;
|
|
/// <summary>
|
|
/// 底部多标签控件
|
|
/// </summary>
|
|
public XtraTabControl TabObj;
|
|
/// <summary>
|
|
/// 底部多标签控件
|
|
/// </summary>
|
|
public TabControlEx TabIntoObj;
|
|
/// <summary>
|
|
/// 基础档案基础参数
|
|
/// </summary>
|
|
public ModuleModel SysModel;
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">一个包含事件数据的 <see cref="T:System.EventArgs" />。</param>
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
this.TabDetail.TabControlObj.ShowTabHeader = DefaultBoolean.False;//隐藏明细标签
|
|
this.Model.Privilege = this.Model.Privilege.Equals("3") ? "1" : Model.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(Model.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(Model.ModuleCode) + "";
|
|
this.tabContainer.ControlSql = Model.ControlSql;
|
|
this.tabContainer.Model = this.Model;
|
|
this.tabContainer.InitTabPages(GetDetails(Model.ModuleCode), this.Model.PrimaryValue);
|
|
this.tabContainer.TabControlObj.SelectedPageChanged += new TabPageChangedEventHandler(OnTabMainSelectedPageChanged);
|
|
this.InitPageDetails();
|
|
this.SetTabPageStyle();
|
|
this.BindPageData();
|
|
}
|
|
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
|
|
{
|
|
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
|
// 加载完统一显示控件
|
|
this.tabContainer.Visible = true;
|
|
}
|
|
|
|
WaitForm.HideForm();
|
|
}
|
|
|
|
#region 设置动态TabPage的样式
|
|
/// <summary>
|
|
/// <para>说明:设置动态的TabPage的样式隐藏页签标题</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-27</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetTabPageStyle()
|
|
{
|
|
if (TabDetail.TabControlObj.TabPages.Count == 0)
|
|
{
|
|
this.scc_container.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
}
|
|
tabContainer.TabControlObj.ShowTabHeader = tabContainer.TabControlObj.TabPages.Count == 1 ? DefaultBoolean.False : DefaultBoolean.Default;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:绑定完后刷新当前表格</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-07-02</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void BindPageData()
|
|
{
|
|
this.TabObj = this.TabIntoObj.TabControlObj;
|
|
foreach (XtraTabPage tabPage in this.tabContainer.TabControlObj.TabPages)
|
|
{
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
GridControlEx gridControl = tabPage.Tag as GridControlEx;
|
|
gridControl.GridView.RowCellClick += new RowCellClickEventHandler(GridView_RowCellClick);
|
|
//gridControl.GridView.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(OnGridViewFocusedRowObjectChanged);
|
|
//gridControl.SetGridViewDataSource(MainImpl.GetDataTableResult(gridControl.LastSearchSql));
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 设置底部page的数据
|
|
/// <summary>
|
|
/// <para>说明:初始化页面明细标签</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-12-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitPageDetails()
|
|
{
|
|
foreach (XtraTabPage tabPage in this.tabContainer.TabControlObj.TabPages)
|
|
{
|
|
GridDetailModel detailModel = this.tabContainer.GetGridDetailModel(tabPage);
|
|
DataRow modelRow = MainImpl.GetSystemdllTab(detailModel.UnionModule);
|
|
XtraTabPage detailpage = new XtraTabPage();//明细page
|
|
this.SysModel = new ModuleModel(modelRow);
|
|
if (!string.IsNullOrEmpty(detailModel.UnionModule))
|
|
{
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
GridControlEx gridControl = tabPage.Tag as GridControlEx;
|
|
this.TabDetail.ParentGridEx = gridControl;
|
|
XtraTabPage page = new XtraTabPage();
|
|
TabControlEx tabintoControl = new TabControlEx();
|
|
tabintoControl.Model = (tabPage.Tag as GridControlEx).Model;
|
|
tabintoControl.DrgaParentPrimaryKey = SysModel.ParmaryKey;
|
|
//tabintoControl.IsDragDetail = this.IsDragDetail;
|
|
tabintoControl.ParentGridEx = gridControl;
|
|
tabintoControl.InitTabPages(GetDetails(tabintoControl.Model.ModuleCode));
|
|
tabintoControl.Dock = DockStyle.Fill;
|
|
detailpage.Controls.Add(tabintoControl);
|
|
detailpage.Tag = tabintoControl;
|
|
this.TabDetail.TabControlObj.TabPages.Add(detailpage);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:加载明细数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="DevExpress.Data.SelectionChangedEventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewFocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
GridView grid = sender as GridView;
|
|
DataRow rowItem = grid.GetFocusedDataRow();
|
|
this.SetDetailGridDataSource(null, rowItem);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
//MessageUtil.Show("加载明细数据失败!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:加载明细数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-09-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
protected void GridView_RowCellClick(object sender, RowCellClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
GridView grid = sender as GridView;
|
|
DataRow rowItem = grid.GetFocusedDataRow();
|
|
this.SetDetailGridDataSource(null, rowItem);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
//MessageUtil.Show("加载明细数据失败!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
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(XtraTabPage tabPage = null, DataRow rowItem = null)
|
|
{
|
|
if (tabPage != null)
|
|
{
|
|
this.SetTabPageDataSource(tabPage, rowItem);
|
|
}
|
|
else
|
|
{
|
|
foreach (XtraTabPage page in this.TabObj.TabPages)
|
|
{
|
|
if (rowItem != null && page != null)
|
|
{
|
|
this.SetTabPageDataSource(page, rowItem);
|
|
}
|
|
else
|
|
{
|
|
SetTabPageDataSource(page, rowItem, 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="gridControl">The grid control.</param>
|
|
protected void SetTabPageDataSource(XtraTabPage tabPage, DataRow rowItem = null, bool isNull = false)
|
|
{
|
|
if (isNull)
|
|
{
|
|
this.TabIntoObj.SetGridDataSource(tabPage, new DataTable());
|
|
return;
|
|
}
|
|
GridDetailModel model = this.TabIntoObj.GetGridDetailModel(tabPage);
|
|
if (rowItem != null && model != null)
|
|
{
|
|
string searchSql = this.GetSearchSql(model, rowItem);
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
(tabPage.Tag as GridControlEx).LastSearchSql = searchSql;
|
|
}
|
|
this.TabIntoObj.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(searchSql));
|
|
}
|
|
else if (rowItem != null && 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;
|
|
string searchMainSql = this.GetSearchSql(MainModel, rowItem);
|
|
string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem);
|
|
grdExMain.LastSearchSql = searchMainSql;
|
|
grdExAdditional.LastSearchSql = searchAddSql;
|
|
grdExMain.SetGridViewDataSource(MainImpl.GetDataTableResult(searchMainSql));
|
|
grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql));
|
|
}
|
|
}
|
|
/// <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.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>创建日期:2017-11-21 </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, true));
|
|
}
|
|
|
|
return details;
|
|
}
|
|
#endregion
|
|
#region 设置顶部数据切换多标签
|
|
/// <summary>
|
|
/// 切换顶部数据同时切换下面明细
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnTabMainSelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
XtraTabPage item = tabContainer.TabControlObj.TabPages[tabContainer.TabControlObj.SelectedTabPageIndex];
|
|
XtraTabPage tabPage = this.tabContainer.TabControlObj.SelectedTabPage;
|
|
TabDetail.TabControlObj.SelectedTabPage = item;
|
|
this.ModuleGridObj = tabPage.Tag as ModuleGridEx;
|
|
this.TabIntoObj = item.Tag as TabControlEx;
|
|
this.TabObj = TabIntoObj.TabControlObj;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|