基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,414 @@
|
||||
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.Control.Model;
|
||||
using Lskj.Util;
|
||||
using Lskj.Model;
|
||||
using Lskj.Business.Impl;
|
||||
using DevExpress.XtraEditors;
|
||||
using Lskj.Business;
|
||||
|
||||
namespace Lskj.PubMultipleDetail
|
||||
{
|
||||
public partial class FrmMain : BaseForm
|
||||
{
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
#region 公共变量
|
||||
/// <summary>
|
||||
/// 入口参数
|
||||
/// </summary>
|
||||
public DynamicReportModel Model;
|
||||
/// <summary>
|
||||
/// 自定义查询条件
|
||||
/// </summary>
|
||||
public MyControl SearchObj { get; private set; }
|
||||
/// <summary>
|
||||
/// 底部多标签表格数据
|
||||
/// </summary>
|
||||
public List<GridDetailModel> _gridDetail;
|
||||
/// <summary>
|
||||
/// 右键菜单执行后调用
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
public event EventHandler OnRightCallback;
|
||||
#endregion
|
||||
|
||||
#region 私有变量
|
||||
/// <summary>
|
||||
/// 明细模块所有表集合
|
||||
/// </summary>
|
||||
/// <value>The system model.</value>
|
||||
public List<GridControlEx> gcExList = new List<GridControlEx>();
|
||||
/// <summary>
|
||||
/// 系统模块实体对象
|
||||
/// </summary>
|
||||
/// <value>The system model.</value>
|
||||
private ModuleModel SysModel;
|
||||
/// <summary>
|
||||
/// 搜索条件表
|
||||
/// </summary>
|
||||
private DataTable _queryTable;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:窗口加载</para>
|
||||
/// <para>创建人:王一帆</para>
|
||||
/// <para>创建日期:2021-01-25 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
WaitForm.ShowForm();
|
||||
try
|
||||
{
|
||||
this.InitializeControl();
|
||||
this.InitializeSearch();
|
||||
this.InitializeDeatil();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
//MessageUtil.Show(ex.StackTrace);
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
||||
WaitForm.HideForm();
|
||||
}
|
||||
}
|
||||
#region 方法
|
||||
#region 初始化绑定控件
|
||||
/// <summary>
|
||||
/// <para>说明:初始化控件</para>
|
||||
/// <para>创建人:王一帆</para>
|
||||
/// <para>创建日期:2021-01-25 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
public void InitializeControl()
|
||||
{
|
||||
DataRow modelRow = MainImpl.GetSystemdllTab(this.Model.ModuleCode);
|
||||
if (modelRow == null)
|
||||
{
|
||||
MessageUtil.Show("模块编号[" + this.Model.ModuleCode + "],配置错误!\r\n该模块信息未找到!");
|
||||
return;
|
||||
}
|
||||
this.SysModel = new ModuleModel(modelRow);
|
||||
this._queryTable = BaseModuleImpl.GetCustomQueryFields(this.SysModel.CondKey);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 初始化查询控件
|
||||
/// <summary>
|
||||
/// <para>说明:初始化查询控件</para>
|
||||
/// <para>创建人:王一帆</para>
|
||||
/// <para>创建日期:2021-01-25 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
public void InitializeSearch()
|
||||
{
|
||||
bool fixedQuery = _queryTable == null || _queryTable.Rows.Count == 0;
|
||||
this.SearchObj = new MyControl(this.SysModel.MenuSql, null);
|
||||
this.SearchObj.OnSearchAfterCallBack += new EventHandler(OnSearchAfterCallBack);
|
||||
//this.SearchObj.ModuleId = Model.ModuleId;
|
||||
//this.SearchObj.ParentKeyField = this.ParentKeyField;
|
||||
//this.SearchObj.ParentUnionField = this.ParentUnionField;
|
||||
|
||||
//// 明细表格默认不查询
|
||||
//this.SearchObj.OnDataSourceBindCallBack += new EventHandler(OnMainSearchDataSourceBindCallBack);
|
||||
//if (!string.IsNullOrEmpty(ParentKeyValue) && !string.IsNullOrEmpty(DetailKeyField))
|
||||
// this.SearchObj.WhereCond = string.Format(" and {0}='{1}'", DetailKeyField, ParentKeyValue);
|
||||
|
||||
if (fixedQuery)
|
||||
{
|
||||
this.pl_top_fix_search.Visible = true;
|
||||
// 加载固定查询条件
|
||||
DataTable table = BaseModuleImpl.GetFixedQueryFields(this.Model.ModuleCode);
|
||||
this.cbField.DisplayMember = "fieldText";
|
||||
this.cbField.ValueMember = "fieldName";
|
||||
this.cbField.DataSource = table;
|
||||
this.SearchObj.InitDefaultSearchControl(table, this.pl_top_master);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pl_top_fix_search.Visible = false;
|
||||
// 加载配置查询条件
|
||||
this.SearchObj.OtherParams = Model.OtherParams();
|
||||
this.pl_top_master.Height = this.SearchObj.InitSearchControl(_queryTable, this.pl_top_master, null);
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取明细
|
||||
/// <summary>
|
||||
/// <para>说明:获取明细</para>
|
||||
/// <para>创建人:王一帆</para>
|
||||
/// <para>创建日期:2021-01-25 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>List<GridDetailModel>.</returns>
|
||||
private List<GridDetailModel> GetDetails()
|
||||
{
|
||||
List<GridDetailModel> details = new List<GridDetailModel>();
|
||||
|
||||
DataTable table = BaseModuleImpl.GetBaseDetailPages(Model.ModuleCode);
|
||||
foreach (DataRow item in table.Rows)
|
||||
{
|
||||
DataTable gridColumns = ReportImpl.GetReportDetailColumns(Model.ModuleCode, item["id"] + "");
|
||||
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
||||
}
|
||||
|
||||
return details;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 加载明细列表
|
||||
/// <summary>
|
||||
/// <para>说明:加载明细列表</para>
|
||||
/// <para>创建人:王一帆</para>
|
||||
/// <para>创建日期:2021-01-25 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The e.</param>
|
||||
public void InitializeDeatil()
|
||||
{
|
||||
this.gcExList.Clear();
|
||||
this._gridDetail = GetDetails();
|
||||
string DetaiName = string.Empty;
|
||||
int index = 1; int splitCount = 1; int detailCount = _gridDetail.Count;
|
||||
int width = this.Width / detailCount;
|
||||
SplitContainerControl splitMain = new SplitContainerControl();
|
||||
SplitContainerControl SeletsplitMain = splitMain;//当前操作的分割框
|
||||
splitMain.Dock = DockStyle.Fill;
|
||||
this.pl_Main.Controls.Add(splitMain);
|
||||
foreach (GridDetailModel model in this._gridDetail)
|
||||
{
|
||||
MultiplePage pl = new MultiplePage();
|
||||
//page.Text = model.DetailName;
|
||||
pl.TitleLabelObj.Text = model.DetailName;
|
||||
if (model.IsChart)
|
||||
{
|
||||
ChartControlEx chartEx = new ChartControlEx();
|
||||
chartEx.Dock = DockStyle.Fill;
|
||||
chartEx.SetCharts(BaseModuleImpl.GetChartParams(model.FormKey));
|
||||
chartEx.SetChartRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
||||
chartEx.Tag = model;
|
||||
|
||||
pl.Tag = chartEx;
|
||||
pl.CenterPabelObj.Controls.Add(chartEx);
|
||||
}
|
||||
else if (model.IsExcel)
|
||||
{
|
||||
ExcelControlEx excelEx = new ExcelControlEx();
|
||||
excelEx.Dock = DockStyle.Fill;
|
||||
excelEx.Tag = model;
|
||||
|
||||
pl.Tag = excelEx;
|
||||
pl.CenterPabelObj.Controls.Add(excelEx);
|
||||
}
|
||||
else if (model.IsWebView)
|
||||
{
|
||||
// 加载网页
|
||||
string url = model.DetailSql.StartsWith("http") ? model.DetailSql : SystemInfo.Instance.OAUrl + model.DetailSql;
|
||||
|
||||
ModuleWebView webView = new ModuleWebView();
|
||||
webView.Dock = DockStyle.Fill;
|
||||
webView.Tag = model;
|
||||
webView.Navigate(ReplaceHelper.ReplaceUserInfo(url));
|
||||
|
||||
pl.Tag = webView;
|
||||
pl.CenterPabelObj.Controls.Add(webView);
|
||||
}
|
||||
else if (model.IsAddPanel)
|
||||
{
|
||||
// 加载添加界面
|
||||
ModulePanelEx modulePanel = new ModulePanelEx();
|
||||
modulePanel.Dock = DockStyle.Fill;
|
||||
modulePanel.PrimaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);
|
||||
modulePanel.InitializeControl(new ModuleModel(MainImpl.GetSystemdllTab(this.Model.ModuleCode)), this.Model);
|
||||
//modulePanel.OnAddRecordCallBack += new EventHandler(OnAddRecordCallBack);
|
||||
//modulePanel.OnCloseCallback += new EventHandler(OnAddRecordCallBack);
|
||||
modulePanel.OperatePanelControlObj.Visible = false;
|
||||
modulePanel.SpeciesPanelControlObj.Visible = false;
|
||||
modulePanel.Tag = model;
|
||||
|
||||
pl.Tag = modulePanel;
|
||||
pl.CenterPabelObj.Controls.Add(modulePanel);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.IsReadOnly)
|
||||
{
|
||||
|
||||
PanelControl plBottom = new PanelControl();
|
||||
plBottom.Dock = DockStyle.Bottom;
|
||||
plBottom.Visible = false;
|
||||
|
||||
PanelControl plMain = new PanelControl();
|
||||
plMain.Dock = DockStyle.Fill;
|
||||
|
||||
GridControlEx gridEx = new GridControlEx();
|
||||
gridEx.Dock = DockStyle.Fill;
|
||||
gridEx.Tag = model;
|
||||
gridEx.Parent = plMain;
|
||||
|
||||
gridEx.Model = this.Model;
|
||||
gridEx.SetReadOnlyColumns(model.GridColumns, model.GridCustomColumnKey);
|
||||
|
||||
gridEx.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
||||
gridEx.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(model.FormKey));
|
||||
|
||||
// 加载配置查询条件
|
||||
if (Model.IsDetailSearch)
|
||||
{
|
||||
plBottom.Visible = true;
|
||||
MyControl searchObj = new MyControl(model.DetailSql, gridEx);
|
||||
plBottom.Height = searchObj.InitSearchControl(BaseModuleImpl.GetCustomQueryFields(model.FormKey), plBottom);
|
||||
}
|
||||
pl.Tag = gridEx;
|
||||
pl.CenterPabelObj.Controls.AddRange(new PanelControl[] { plBottom, plMain });
|
||||
}
|
||||
else
|
||||
{
|
||||
DynamicModel dyncModel = new DynamicModuleModel(new string[] { model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.Model.Privilege, model.UnionModule, "0" });
|
||||
model.SystemModel = new ModuleModel(MainImpl.GetSystemdllTab(model.UnionModule));
|
||||
if (Model != null)
|
||||
model.SystemModel.ParmaryKey = BaseImpl.GetBasePrimaryKey(Model.ModuleCode);
|
||||
ModuleGridEx gridEx = new ModuleGridEx();
|
||||
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.ParentKeyField = string.IsNullOrEmpty(model.UnionParentField) ? model.SystemModel.ParmaryKey : model.UnionParentField;
|
||||
gridEx.DetailKeyField = model.UnionValue;
|
||||
gridEx.GridControlObj.ParentControl = gridEx.SearchObj;
|
||||
if (model.AutoRefresh)
|
||||
gridEx.SearchObj.SearchGrid();
|
||||
pl.Tag = gridEx.GridControlObj;
|
||||
pl.CenterPabelObj.Controls.Add(gridEx);
|
||||
}
|
||||
pl.Dock = DockStyle.Fill;
|
||||
if (index - splitCount == 1)
|
||||
{
|
||||
SeletsplitMain.Panel2.Controls.Add(pl);
|
||||
}
|
||||
else
|
||||
{
|
||||
SeletsplitMain.Panel1.Controls.Add(pl);
|
||||
}
|
||||
SeletsplitMain.SplitterPosition = width;
|
||||
gcExList.Add(pl.Tag as GridControlEx);
|
||||
if (detailCount - splitCount > 1)
|
||||
{
|
||||
SplitContainerControl newSplitMain = new SplitContainerControl();//新建分隔框
|
||||
newSplitMain.Dock = DockStyle.Fill;
|
||||
SeletsplitMain.Panel2.Controls.Add(newSplitMain);
|
||||
SeletsplitMain = newSplitMain;
|
||||
splitCount++;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region
|
||||
/// <summary>
|
||||
/// <para>说明:</para>
|
||||
/// <para>创建人:王一帆</para>
|
||||
/// <para>创建日期:2021-01-25 </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)
|
||||
{
|
||||
if (this.OnRightCallback != null)
|
||||
this.OnRightCallback(sender, e);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
#region 搜索之前
|
||||
/// <summary>
|
||||
/// <para>说明:搜索之前</para>
|
||||
/// <para>创建人:王一帆</para>
|
||||
/// <para>创建日期:2021-01-25 </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 OnSearchAfterCallBack(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (GridControlEx gcMain in gcExList)
|
||||
{
|
||||
GridDetailModel model = gcMain.Tag as GridDetailModel;
|
||||
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
||||
sqlValue = this.SearchObj.ReplaceControlValue(sqlValue);
|
||||
// 左侧gridView时,需要替换sql参数(包含查询条件、表格选中行).
|
||||
DataTable dt = MainImpl.GetDataTableResult(sqlValue);
|
||||
gcMain.LastSearchSql = sqlValue;
|
||||
gcMain.SetGridViewDataSource(dt);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void btnFixSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user