SVN-Revision: r282
This commit is contained in:
cyf
2025-02-25 01:54:47 +00:00
parent 90e6885779
commit 645ed54877
7 changed files with 594 additions and 408 deletions
+313 -40
View File
@@ -90,6 +90,18 @@ namespace Lskj.Control
#region public property
/// <summary>
/// 底部操作控件面板
/// </summary>
public TabControlEx TcButtom { get { return tcButtom; } }
/// <summary>
/// 底部操作控件面板
/// </summary>
public SplitContainerControl SplitContainerControl { get { return scc_container; } }
/// <summary>
/// 下方显示的明细数据
/// </summary>
public DataRow[] DetailsData;
/// <summary>
/// 是否是新增保存
/// </summary>
public bool SavaState;
@@ -215,6 +227,17 @@ namespace Lskj.Control
{
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
InitializeComponent();
this.scc_container.PanelVisibility = SplitPanelVisibility.Panel1;
this.simpleButton1.Click += simpleButton1_Click;
this.btnClear.Click += OnBtnClearClick;
this.btnCopyNew.Click += OnBtnCopyNewClick;
this.btnAdd.Click += OnAddClick;
this.btnUpdate.Click += OnUpdateClick;
this.btnApply.Click += OnApplyClick;
this.btnAttach.Click += OnBtnAttachClick;
this.btnClose.Click += OnCloseClick;
this.BtnMesSave.Click += OnMesSaveClick;
this.BtnMesClose.Click += OnBtnMesCloseClick;
}
#region private method
@@ -739,6 +762,14 @@ namespace Lskj.Control
}
// 重排按钮位置
this.SetControlLocation();
//设置下方页签
if (DetailsData != null && DetailsData.Length > 0)
{
this.CreateTabDetail();
this.tcButtom.TabControlObj.SelectedPageChanged += this.OnSelectedPageChanged;
//this.tcButtom.TabControlObj.SelectedPageChanging += this.OnSelectedPageChanging;
this.scc_container.PanelVisibility = SplitPanelVisibility.Both;
}
}
}
catch (Exception ex)
@@ -750,6 +781,282 @@ namespace Lskj.Control
}
/// <summary>
/// <para>说明:切换标签刷新主键值</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-04-09 </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="TabPageChangedEventArgs"/> instance containing the event data.</param>
private void OnSelectedPageChanged(object sender, TabPageChangedEventArgs e)
{
try
{
XtraTabPage tabPage = null;
if (e == null)
{
tabPage = this.tcButtom.TabControlObj.SelectedTabPage;
}
else
{
tabPage=e.Page;
}
OperatePanelControlObj.Visible = true;
if (tabPage.Tag is ModuleGridEx) OperatePanelControlObj.Visible = false;
if (!(tabPage.Tag is GridDetailModel)) return;
OperatePanelControlObj.Visible = false;
if (tabPage.Controls.Count == 0)
{
GridDetailModel detailModel = tabPage.Tag as GridDetailModel;
ModuleModel moduleModel = null;
DynamicAddModel addModel = new DynamicAddModel(new string[] {
detailModel.DetailName,
ERPInfo.Instance.UserId,
ERPInfo.Instance.UserName,
"1",detailModel.UnionModule,"","",""
});
if (string.IsNullOrEmpty(detailModel.UnionModule))
{
PanelControl plBottom = new PanelControl();
plBottom.Dock = DockStyle.Bottom;
plBottom.Visible = false;
PanelControl plMain = new PanelControl();
plMain.Dock = DockStyle.Fill;
GridControlEx gridEx = detailModel.AutoMultiHeader == 1 ? new BandedGridControlEx() : new GridControlEx();
gridEx.Dock = DockStyle.Fill;
gridEx.Tag = detailModel;
gridEx.Parent = plMain;
gridEx.Model = this.Model;
gridEx.SetReadOnlyColumns(detailModel.GridColumns, detailModel.GridCustomColumnKey);
gridEx.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(detailModel.FormKey), this.Model);
gridEx.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(detailModel.FormKey));
if (detailModel.IsCheck == 1)//加载复选框
{
GridDragGrid.GridAddCheckBox(gridEx.GridView);
}
// 加载配置查询条件
if (Model != null && Model.IsDetailSearch)
{
plBottom.Visible = true;
MyControl searchObj = new MyControl(detailModel.DetailSql, gridEx);
plBottom.Height = searchObj.InitSearchControl(BaseModuleImpl.GetCustomQueryFields(detailModel.FormKey), plBottom);
}
tabPage.Tag = gridEx;
tabPage.Controls.AddRange(new PanelControl[] { plBottom, plMain });
if (detailModel.AutoRefresh)
{
if (!string.IsNullOrWhiteSpace(this.ParentKey))
{
string codeSql = "select";
codeSql += string.Format(" '{0}' as {1}", this.PrimaryValue, this.PrimaryKey);
gridEx.SetGridViewDataSource(SqlHelper.ExecuteDataTable(ReplaceHelper.ReplaceRowParam(BaseImpl.GetDataRowResult(codeSql), ReplaceHelper.ReplaceWhereCond(detailModel.DetailSql))));
}
// 自动刷新
}
}
else
{
moduleModel = new ModuleModel(MainImpl.GetSystemdllTab(detailModel.UnionModule));
ModuleGridEx moduleGrid = new ModuleGridEx();
moduleGrid.IsDetail = true;
moduleGrid.Dock = DockStyle.Fill;
moduleGrid.Tag = detailModel;
moduleGrid.ParentKeyField = string.IsNullOrEmpty(detailModel.UnionParentField) ? SysModel.ParmaryKey : detailModel.UnionParentField;
//直接在控件数据源中取值,控件可能是禁显状态(没用控件获取不到值)
if (!string.IsNullOrWhiteSpace(moduleGrid.ParentKeyField) && this.ControlObj.CurrentData.Table.Columns.Contains(moduleGrid.ParentKeyField))
{
moduleGrid.ParentKeyValue = moduleGrid.UnionValue = this.ControlObj.CurrentData[moduleGrid.ParentKeyField] + "";
}
//moduleGrid.ParentKeyValue = this.ModuleAddControl.ControlObj.GetControlValue(moduleGrid.ParentKeyField);
moduleGrid.DetailKeyField = detailModel.UnionValue;
moduleGrid.UnionKey = detailModel.UnionValue;
//moduleGrid.UnionValue = this.ModuleAddControl.ControlObj.GetControlValue(moduleGrid.ParentKeyField); //Model.ObjectId;
//moduleGrid.SearchControlSql = Model.ControlSql;
moduleGrid.InitializeControl(moduleModel, addModel);
moduleGrid.SearchObj.OnSearchBeforeCallBack += new SearchEventHandler(OnSearchBefore);
moduleGrid.SearchObj.OnSearchAfterCallBack += new EventHandler(OnSearchAfter);
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(moduleGrid);
tabPage.Controls.Add(moduleGrid);
tabPage.Tag = moduleGrid;
if (detailModel.AutoRefresh)
{
moduleGrid.SearchObj.OnDataSourceBindCallBack += new EventHandler(OnMainSearchDataSourceBindCallBack);
}
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <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="EventArgs"/> instance containing the event data.</param>
protected void OnMainSearchDataSourceBindCallBack(object sender, EventArgs e)
{
try
{
MyControl searchobj = sender as MyControl;
searchobj.SearchGrid();
OnSearchAfter(null, null);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:查询条件执行前</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-11-10 </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 OnSearchBefore(object sender, SearchArgs e)
{
try
{
XtraTabPage tabPage = this.tcButtom.TabControlObj.SelectedTabPage;
if (plMainControlObj.Tag is XtraTabControl)
{
XtraTabControl xtr = plMainControlObj.Tag as XtraTabControl;
tabPage = xtr.SelectedTabPage;
}
if (tabPage != null)
{
ModuleGridEx moduleGrid = tabPage.Tag as ModuleGridEx;
GridDetailModel detailModel = moduleGrid.Tag as GridDetailModel;
moduleGrid.SearchObj.SearchGrid(detailModel.DetailSql + string.Format(" and {0}='{1}'", moduleGrid.DetailKeyField, moduleGrid.UnionValue));
}
e.Continue = false;
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:查询条件执行后</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-11-10 </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>
protected void OnSearchAfter(object sender, EventArgs e)
{
try
{
XtraTabPage tabPage = this.tcButtom.TabControlObj.SelectedTabPage;
if (plMainControlObj.Tag is XtraTabControl)
{
XtraTabControl xtr = plMainControlObj.Tag as XtraTabControl;
tabPage = xtr.SelectedTabPage;
}
if (tabPage != null)
{
if (tabPage.Tag is ModuleGridEx)
{
ModuleGridEx moduleGrid = tabPage.Tag as ModuleGridEx;
GridDetailModel detailModel = moduleGrid.Tag as GridDetailModel;
tabPage.Text = detailModel.DetailName + "(" + moduleGrid.SearchObj.GridRowCount + "条)";
}
else if (tabPage.Tag is GridControlEx)
{
GridControlEx moduleGrid = tabPage.Tag as GridControlEx;
GridDetailModel detailModel = moduleGrid.Tag as GridDetailModel;
tabPage.Text = detailModel.DetailName + "(" + moduleGrid.DataRowCount() + "条)";
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:初始化多标签</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-11-10 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
private void CreateTabDetail()
{
bool isInside = false;
foreach (DataRow item in this.DetailsData)
{
XtraTabPage tabPage = new XtraTabPage();
GridDetailModel detailModel = new GridDetailModel(item, null, GridCustomColumnStruct.BaseDetailGridView);
if (!string.IsNullOrEmpty(detailModel.UnionModule))
{
ModuleModel moduleModel = new ModuleModel(MainImpl.GetSystemdllTab(detailModel.UnionModule));
if (string.IsNullOrWhiteSpace(moduleModel.FormKey))
{
MessageUtil.Show(detailModel.DetailName + "模块配置错误");
return;
}
detailModel.DetailSql = moduleModel.MenuSql;
}
detailModel.GridColumns = ReportImpl.GetReportDetailColumns(Model.ModuleCode, item["id"] + "");
tabPage.Text = detailModel.DetailName;
tabPage.Tag = detailModel;
this.tcButtom.TabControlObj.TabPages.Add(tabPage);
}
}
/// <summary>
/// 获取数据源缓存
/// </summary>
@@ -843,6 +1150,11 @@ namespace Lskj.Control
try
{
this.SetUpdateData();
if (this.scc_container.PanelVisibility == SplitPanelVisibility.Both)
{
this.tcButtom.TabControlObj.SelectedTabPageIndex = 0;
this.OnSelectedPageChanged(null,null);
}
}
catch (Exception ex)
{
@@ -2107,43 +2419,4 @@ namespace Lskj.Control
if (this.OnCopyRecordCallBack != null)
{
this.OnCopyRecordCallBack(sender, e);
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
private void simpleButton1_Click(object sender, EventArgs e)
{
try
{
WebBrowserUtil.StartWebBrowser(this.Model.ModuleCode, this.SysModel.MenuText);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}
}
}