ab56a9bcf7
SVN-Revision: r240
623 lines
28 KiB
C#
623 lines
28 KiB
C#
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.Model;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Util;
|
|
using Lskj.Data;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control;
|
|
using Lskj.Business;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.XtraTab;
|
|
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraEditors;
|
|
|
|
namespace Lskj.PubModelAdd
|
|
{
|
|
public partial class BaseModelAdd : UserControl
|
|
{
|
|
public BaseModelAdd()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
#region 私有变量
|
|
/// <summary>
|
|
/// 模块初始化完成
|
|
/// </summary>
|
|
private bool _isInitFinish;
|
|
/// <summary>
|
|
/// 表格列
|
|
/// </summary>
|
|
private DataTable _gridColumns = new DataTable();
|
|
/// <summary>
|
|
/// 主键名
|
|
/// </summary>
|
|
private string _primaryLeftKey;
|
|
/// <summary>
|
|
/// 左侧表格查询条件
|
|
/// </summary>
|
|
private MyControl _leftGridSearchObj;
|
|
#endregion
|
|
#region 公共变量
|
|
/// <summary>
|
|
/// 左侧树数据
|
|
/// </summary>
|
|
public DataRow LeftRowObj;
|
|
/// <summary>
|
|
/// 基础添加模块的入口参数
|
|
/// </summary>
|
|
public DynamicPubModelAdd Model;
|
|
/// <summary>
|
|
/// 基础添加模块的入口参数
|
|
/// </summary>
|
|
public DynamicPubModelAdd BandModel;
|
|
/// <summary>
|
|
/// 明细集合
|
|
/// </summary>
|
|
List<GridDetailModel> details = new List<GridDetailModel>();//表格明细对象的集合
|
|
/// <summary>
|
|
/// 明细集合
|
|
/// </summary>
|
|
List<GridDetailModel> detailChildren = new List<GridDetailModel>();//表格明细子明细对象的集合
|
|
/// <summary>
|
|
///左上方查询条件控件
|
|
/// </summary>
|
|
public MyControl SearchLeftObj;
|
|
/// <summary>
|
|
/// 顶部表格控件
|
|
/// </summary>
|
|
public ModuleGridEx ModuleGridObj;
|
|
|
|
/// <summary>
|
|
/// 左侧明细类型
|
|
/// </summary>
|
|
public GridDetailModel LeftgridDetail;
|
|
/// <summary>
|
|
/// 系统模块实体对象
|
|
/// </summary>
|
|
/// <value>The system model.</value>
|
|
public ModuleModel SysModel { get; private set; }
|
|
/// <summary>
|
|
/// 主表模块明细数据源
|
|
/// </summary>
|
|
/// <value>The system model.</value>
|
|
public DataTable moduleDetailTable { get; private set; }
|
|
/// <summary>
|
|
/// 系统模块下部分实体对象
|
|
/// </summary>
|
|
/// <value>The system model.</value>
|
|
public ModuleModel BottomModel { get; private set; }
|
|
/// <summary>
|
|
/// 左侧条件
|
|
/// </summary>
|
|
public string LeftCond;
|
|
|
|
/// <summary>
|
|
/// 是否第一次点击加载
|
|
/// </summary>
|
|
public bool isFirstCilk;
|
|
#endregion
|
|
/// <summary>
|
|
/// <para>说明:窗口加载</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-28 </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(DynamicPubModelAdd Model)
|
|
{
|
|
WaitForm.ShowForm();
|
|
try
|
|
{
|
|
this.sccLeft_container.SplitterPositionChanged += OnSplitterPositionChanged;
|
|
this.sccMain_container.SplitterPositionChanged += OnSplitterPositionChanged;
|
|
this._isInitFinish = false;
|
|
this.Model = Model;
|
|
InitlizeSpiltLocation();
|
|
DataRow modelRow = MainImpl.GetSystemdllTab(this.Model.ModuleCode);
|
|
if (modelRow == null)
|
|
{
|
|
MessageUtil.Show("模块编号[" + this.Model.ModuleCode + "],配置错误!\r\n该模块信息未找到!");
|
|
return;
|
|
}
|
|
this.SysModel = new ModuleModel(modelRow);//主模块参数
|
|
this.moduleDetailTable = BaseModuleImpl.GetBaseDetailPages(this.Model.ModuleCode);//通过明细获取动态表格
|
|
foreach (DataRow item in moduleDetailTable.Rows)
|
|
{
|
|
if (item["orderId"].ToString() == "-1") continue;
|
|
DataTable gridColumns = ReportImpl.GetReportDetailColumns(this.Model.ModuleCode, item["id"] + "");//获取报表明细列
|
|
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
InitializeGrid();//初始化主表和-1明细模块
|
|
InitializeDetail();//初始化主表明细
|
|
this.mg_control.SearchObj.OnDataSourceBindCallBack += new EventHandler(OnDataSourceBindCallBack);//主模块条件绑定完成后触发查询操作
|
|
//this.mg_BottomControl.SearchObj.OnDataSourceBindCallBack += new EventHandler(OnleftBindCallBack);//主模块条件绑定完成后触发查询操作
|
|
|
|
}
|
|
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
|
|
{
|
|
this._isInitFinish = true;
|
|
|
|
}
|
|
|
|
WaitForm.HideForm();
|
|
}
|
|
#region 方法
|
|
#region 数据源绑定完成后执行
|
|
/// <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 OnDataSourceBindCallBack(object sender, EventArgs e)
|
|
{
|
|
string sqlValue = ReplaceHelper.ReplaceWhereCond(this.SysModel.MenuSql);
|
|
this.ModuleGridObj.GridControlObj.LastSearchSql = this.ModuleGridObj.SearchObj.SetSearchSqlValue(sqlValue, true, false);
|
|
this.ModuleGridObj.SearchObj.SearchLastGrid();
|
|
}
|
|
/// <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 OnleftBindCallBack(object sender, EventArgs e)
|
|
{
|
|
string sqlValue = ReplaceHelper.ReplaceWhereCond(this.mg_BottomControl.SysModel.MenuSql);
|
|
this.mg_BottomControl.GridControlObj.LastSearchSql = this.mg_BottomControl.SearchObj.SetSearchSqlValue(sqlValue, true, false);
|
|
this.mg_BottomControl.SearchObj.SearchLastGrid();
|
|
}
|
|
#endregion
|
|
#region 初始化配置表格表
|
|
/// <summary>
|
|
/// <para>说明:加载下部分表格</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-09-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeGrid()
|
|
{
|
|
mg_control.InitializeControl(SysModel, Model);
|
|
this.ModuleGridObj = mg_control;
|
|
this.ModuleGridObj.GridControlObj.GridView.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(OnGridViewRowClick);//单击主表刷新所有数据
|
|
DataRow LeftItem = moduleDetailTable.Rows.Cast<DataRow>().FirstOrDefault(x => int.Parse(x["orderId"] + "") == -1);//获取所有明细为1的集合数据
|
|
if (LeftItem != null)
|
|
{
|
|
DataTable gridColumns = ReportImpl.GetReportDetailColumns(this.Model.ModuleCode, LeftItem["id"] + "");//获取报表明细列
|
|
this.LeftgridDetail = new GridDetailModel(LeftItem, gridColumns, GridCustomColumnStruct.BaseDetailGridView);
|
|
if (LeftgridDetail != null)
|
|
{
|
|
this.BottomModel = new ModuleModel(MainImpl.GetSystemdllTab(LeftgridDetail.UnionModule));
|
|
LeftgridDetail.SystemModel = BottomModel;
|
|
DynamicModel dynamicPubModelAdd = new DynamicPubModelAdd(new string[] { BottomModel.MenuText, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.Model.Privilege, LeftgridDetail.UnionModule, "0" });
|
|
//this.mg_BottomControl.OperShortMode = true; // 不显示简短模式
|
|
this.mg_BottomControl.ParentGridEx = mg_control.GridControlObj;
|
|
this.mg_BottomControl.ParentKeyField = string.IsNullOrEmpty(LeftgridDetail.UnionParentField) ? LeftgridDetail.SystemModel.ParmaryKey : LeftgridDetail.UnionParentField;
|
|
this.mg_BottomControl.DetailKeyField = LeftgridDetail.UnionValue;
|
|
this.mg_BottomControl.VisibleSearchPanel = false;
|
|
//this.mg_BottomControl.VisibleOperPanel = false;
|
|
this.mg_BottomControl.InitializeControl(BottomModel, dynamicPubModelAdd);
|
|
group.Text = LeftgridDetail.DetailName;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.sccLeft_container.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 单击主表数据刷新所有明细数据源
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnGridViewRowClick(object sender, RowClickEventArgs e)
|
|
{
|
|
//左下数据源刷新
|
|
if (this.BottomModel != null)
|
|
{
|
|
string sqlValue = ReplaceHelper.ReplaceWhereCond(this.BottomModel.MenuSql);
|
|
DataRow rowItem = this.mg_control.GridControlObj.GetViewFocusedDataRow();
|
|
sqlValue = this.GetSearchSql(LeftgridDetail, rowItem);//关联主表
|
|
this.mg_BottomControl.GridControlObj.LastSearchSql = sqlValue;
|
|
this.mg_BottomControl.SearchObj.SearchLastGrid();
|
|
}
|
|
Refresh(this.mg_DetailPage.TabControlObj);
|
|
isFirstCilk = true;
|
|
}
|
|
/// <summary>
|
|
/// 递归父结构让他以gridcontrlEx展示
|
|
/// </summary>
|
|
public ModuleGridEx isParentModelCtrEx(System.Windows.Forms.Control myControl)
|
|
{
|
|
if (myControl == null) return null;
|
|
if (myControl.Parent is ModuleGridEx)
|
|
{
|
|
return myControl.Parent as ModuleGridEx;
|
|
}
|
|
return isParentModelCtrEx(myControl);
|
|
}
|
|
public void Refresh(XtraTabControl xtraTabControl, bool isUnionCode = true)
|
|
{
|
|
//右侧所有明细刷新
|
|
foreach (XtraTabPage tabPage in xtraTabControl.TabPages)
|
|
{
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
GridControlEx gridControlEx = tabPage.Tag as GridControlEx;
|
|
GridDetailModel model = gridControlEx.Tag as GridDetailModel;
|
|
string DetailSql = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
|
|
|
if (model.IsDrag && !isFirstCilk)
|
|
{
|
|
gridControlEx.LastSearchSql = DetailSql;
|
|
DataTable dataTable = MainImpl.GetDataTableResult(DetailSql);//明细数据源
|
|
gridControlEx.SetGridViewDataSource(dataTable);
|
|
}
|
|
if (!model.IsDrag && isUnionCode)
|
|
{
|
|
DataRow rowItem = this.mg_control.GridControlObj.GetViewFocusedDataRow();
|
|
DetailSql = this.GetSearchSql(model, rowItem);
|
|
gridControlEx.LastSearchSql = DetailSql;
|
|
DataTable dataTable = MainImpl.GetDataTableResult(DetailSql);//明细数据源
|
|
gridControlEx.SetGridViewDataSource(dataTable);
|
|
}
|
|
|
|
//配置明细直接根据条件加载
|
|
if (model.SystemModel != null)
|
|
{
|
|
tabPage.Text = model.DetailName + "(" + gridControlEx.DataRowCount() + "条)";
|
|
}
|
|
if (model.DetailType == 4)
|
|
{
|
|
if (tabPage.Controls[0] is ModuleGridDetailEx)
|
|
{
|
|
ModuleGridDetailEx moduleGridDetailEx = tabPage.Controls[0] as ModuleGridDetailEx;
|
|
Refresh(moduleGridDetailEx.TabObj, false);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <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, bool isLeft = false)
|
|
{
|
|
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);
|
|
DataRow row = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow();
|
|
if (row != null && isLeft)
|
|
{
|
|
//先替换左侧选中行,在替换主表
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(row, sqlValue);
|
|
}
|
|
|
|
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
|
{
|
|
string Conditions = string.Empty;
|
|
//是左侧选中行,并且没有替换字段,则使用主表选中行
|
|
Conditions = isLeft ? rowItem.Table.Columns.Contains(fieldName) ? rowItem[fieldName] + "" : row[fieldName] + "" : rowItem[fieldName] + "";
|
|
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, Conditions);
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(model.UnionCond))
|
|
{
|
|
string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond);
|
|
sqlValue += UnionCond;
|
|
}
|
|
return sqlValue;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:加载下部分表格</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-09-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeDetail()
|
|
{
|
|
this.mg_DetailPage.Model = this.Model;
|
|
this.mg_DetailPage.DrgaParentPrimaryKey = this.SysModel.ParmaryKey;
|
|
//this.mg_DetailPage.IsDragDetail = true;
|
|
this.mg_DetailPage.ParentControlEx = this.mg_control.SearchObj;
|
|
this.mg_DetailPage.ParentGridEx = this.mg_control.GridControlObj;
|
|
this.mg_DetailPage.OnDragCompleteCallback += OnDetailPageDragCompleteCallback;
|
|
this.mg_DetailPage.OnDetailViewDoubleClickCallBack += OnDetailPageViewDoubleClickCallBack;
|
|
this.mg_DetailPage.InitTabPages(details);
|
|
}
|
|
private void InitlizeSpiltLocation()
|
|
{
|
|
try
|
|
{
|
|
string mainWidth = IniHelper.Read(string.Format("PubMultipleTabsMain_{0}", this.Model.ModuleCode));//通过Key获取Value值
|
|
string leftWidth = IniHelper.Read(string.Format("PubMultipleTabsLeft_{0}", this.Model.ModuleCode));//通过Key获取Value值
|
|
if (!string.IsNullOrEmpty(mainWidth))
|
|
{
|
|
this.sccMain_container.SplitterPosition = Convert.ToInt32(mainWidth);
|
|
}
|
|
if (!string.IsNullOrEmpty(leftWidth))
|
|
{
|
|
this.sccLeft_container.SplitterPosition = Convert.ToInt32(leftWidth);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定完成后加载数据
|
|
/// <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>
|
|
protected void OnLeftControlObjDataSourceBindCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this._leftGridSearchObj.SearchGrid();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 事件
|
|
|
|
#endregion
|
|
|
|
#region 右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-09-09 </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
|
|
{
|
|
DataRow item = this.ModuleGridObj.GridControlObj.GridView.GetFocusedDataRow();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 明细拖拽回调
|
|
/// <summary>
|
|
/// 明细拖拽回调
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnDetailPageDragCompleteCallback(object sender, GridDragGridArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
XtraTabPage selectPage = mg_DetailPage.TabControlObj.SelectedTabPage;
|
|
ModuleGridDetailEx moduleGridDetail = (ModuleGridDetailEx)selectPage.Controls[0];
|
|
ModuleGridEx mainModuleGridEx = moduleGridDetail.ModuleGridObj;
|
|
DataRow[] rowItems = e.GridViewSelectRows;
|
|
//if (!ValidateDetailCond(rowItems, BottomModel.DoubleClickAddCond)) return;//不满足条件则退出该方法
|
|
DataRow GridLeftItem = this.mg_control.GridControlObj.GridView.GetFocusedDataRow();
|
|
GridColumnCollection gridColumns = e.TargetGridViewObj.Columns;
|
|
DataTable table = e.TargetGridViewObj.GridControl.DataSourceTable();
|
|
foreach (DataRow rowItem in rowItems)
|
|
{
|
|
if (rowItem == null) continue;
|
|
DataRow newRow = table.NewRow();
|
|
foreach (GridColumn col in gridColumns)
|
|
{
|
|
if ("id".Equals(col.FieldName)) continue;
|
|
string ConditionValue = "";
|
|
//string ConditionValue = this.MoudleBottomObj.SearchObj.GetControlValue(col.FieldName);//获取同它条件的替换值
|
|
if (rowItem.Table.Columns.Contains(col.FieldName))
|
|
{
|
|
// 列中是否包含对应字段,包含则使用值
|
|
newRow[col.FieldName] = string.IsNullOrWhiteSpace(ConditionValue) ? rowItem[col.FieldName] : ConditionValue;
|
|
}
|
|
else if (GridLeftItem != null && GridLeftItem.Table.Columns.Contains(col.FieldName))
|
|
{
|
|
newRow[col.FieldName] = GridLeftItem[col.FieldName];
|
|
}
|
|
else
|
|
{
|
|
// 未包含字段,则使用控件默认值.
|
|
GridColumnModel model = col.Tag as GridColumnModel;
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
if (!string.IsNullOrEmpty(model.DefaultValue) || !string.IsNullOrEmpty(ConditionValue))
|
|
{
|
|
newRow[col.FieldName] = string.IsNullOrWhiteSpace(ConditionValue) ? fieldValue : ConditionValue;
|
|
}
|
|
}
|
|
}
|
|
table.Rows.Add(newRow);
|
|
}
|
|
e.TargetGridViewObj.ClearSelection();
|
|
e.TargetGridViewObj.UpdateCurrentRow();
|
|
e.TargetGridViewObj.ShowEditor();
|
|
mainModuleGridEx.SaveGridRecord(false);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 双击回调
|
|
/// <summary>
|
|
/// 双击回调
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnDetailPageViewDoubleClickCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
XtraTabPage selectPage = mg_DetailPage.TabControlObj.SelectedTabPage;
|
|
if (selectPage != null && selectPage.Controls[0] is ModuleGridDetailEx)
|
|
{
|
|
ModuleGridDetailEx moduleGridDetail = (ModuleGridDetailEx)selectPage.Controls[0];
|
|
ModuleGridEx mainModuleGridEx = moduleGridDetail.ModuleGridObj;
|
|
ModuleGridEx detailModuleGridEx = (ModuleGridEx)moduleGridDetail.TabObj.SelectedTabPage.Controls[0];
|
|
ModuleGridEx sourceModuleGridEx = null;
|
|
ModuleGridEx targetModuleGridEx = null;
|
|
if ((sender + "").Equals("Main"))
|
|
{
|
|
sourceModuleGridEx = mainModuleGridEx;
|
|
targetModuleGridEx = detailModuleGridEx;
|
|
}
|
|
else if ((sender + "").Equals("Detail"))
|
|
{
|
|
sourceModuleGridEx = detailModuleGridEx;
|
|
targetModuleGridEx = mainModuleGridEx;
|
|
}
|
|
Point mouseDowmPoint = sourceModuleGridEx.GridControlObj.gridControl.PointToClient(MousePosition);
|
|
GridHitInfo info = sourceModuleGridEx.GridControlObj.GridView.CalcHitInfo(mouseDowmPoint);
|
|
//在列标题栏内则退出该方法
|
|
if (info.InColumnPanel) return;
|
|
DataRow[] rowItems = new DataRow[] { sourceModuleGridEx.GridControlObj.GridView.GetFocusedDataRow() };
|
|
//if (!ValidateDetailCond(rowItems, BottomModel.DoubleClickAddCond)) return;//不满足条件则退出该方法
|
|
DataRow GridLeftItem = this.mg_control.GridControlObj.GridView.GetFocusedDataRow();
|
|
GridColumnCollection gridColumns = targetModuleGridEx.GridControlObj.GridView.Columns;
|
|
DataTable table = targetModuleGridEx.GridControlObj.GridControl.DataSourceTable();
|
|
foreach (DataRow rowItem in rowItems)
|
|
{
|
|
if (rowItem == null) continue;
|
|
DataRow newRow = table.NewRow();
|
|
foreach (GridColumn col in gridColumns)
|
|
{
|
|
if ("id".Equals(col.FieldName)) continue;
|
|
string ConditionValue = "";
|
|
//string ConditionValue = this.MoudleBottomObj.SearchObj.GetControlValue(col.FieldName);//获取同它条件的替换值
|
|
if (rowItem.Table.Columns.Contains(col.FieldName))
|
|
{
|
|
// 列中是否包含对应字段,包含则使用值
|
|
newRow[col.FieldName] = string.IsNullOrWhiteSpace(ConditionValue) ? rowItem[col.FieldName] : ConditionValue;
|
|
}
|
|
else if (GridLeftItem != null && GridLeftItem.Table.Columns.Contains(col.FieldName))
|
|
{
|
|
newRow[col.FieldName] = GridLeftItem[col.FieldName];
|
|
}
|
|
else
|
|
{
|
|
// 未包含字段,则使用控件默认值.
|
|
GridColumnModel model = col.Tag as GridColumnModel;
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
if (!string.IsNullOrEmpty(model.DefaultValue) || !string.IsNullOrEmpty(ConditionValue))
|
|
{
|
|
newRow[col.FieldName] = string.IsNullOrWhiteSpace(ConditionValue) ? fieldValue : ConditionValue;
|
|
}
|
|
}
|
|
}
|
|
table.Rows.Add(newRow);
|
|
}
|
|
targetModuleGridEx.GridControlObj.GridView.ClearSelection();
|
|
targetModuleGridEx.GridControlObj.GridView.UpdateCurrentRow();
|
|
targetModuleGridEx.GridControlObj.GridView.ShowEditor();
|
|
targetModuleGridEx.SaveGridRecord(false);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
}
|
|
#endregion
|
|
private void OnSplitterPositionChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SplitContainerControl splitContainerControl = (SplitContainerControl)sender;
|
|
if (this.Model != null)
|
|
{
|
|
if (splitContainerControl == sccMain_container)
|
|
{
|
|
IniHelper.Write(string.Format("PubMultipleTabsMain_{0}", this.Model.ModuleCode), this.sccMain_container.SplitterPosition + "");
|
|
}
|
|
else if (splitContainerControl == sccLeft_container)
|
|
{
|
|
IniHelper.Write(string.Format("PubMultipleTabsLeft_{0}", this.Model.ModuleCode), this.sccLeft_container.SplitterPosition + "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|