1235 lines
51 KiB
C#
1235 lines
51 KiB
C#
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using Lskj.Business;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Data;
|
|
using Lskj.Model;
|
|
using Lskj.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text.RegularExpressions;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.Control.MultiModelLookUp
|
|
{
|
|
public partial class FrmModelLookUp2 : BaseForm
|
|
{
|
|
#region 私有字段
|
|
|
|
#endregion
|
|
#region 公有字段
|
|
/// <summary>
|
|
/// 数据源
|
|
/// </summary>
|
|
/// <value>The data source.</value>
|
|
public DataTable DataSource
|
|
{
|
|
get
|
|
{
|
|
return this.gcMain.gridControl.DataSourceTable();
|
|
}
|
|
set
|
|
{
|
|
this.gcMain.gridControl.DataSource = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 控件类型
|
|
/// </summary>
|
|
/// <value>The type.</value>
|
|
public int IsType { get; set; }
|
|
/// <summary>
|
|
/// 绑定ValueMember
|
|
/// </summary>
|
|
public string ValueMember { get; set; }
|
|
/// <summary>
|
|
/// 隐藏值字段
|
|
/// </summary>
|
|
public string ValueField { get; set; }
|
|
/// <summary>
|
|
/// 显示值字段
|
|
/// </summary>
|
|
public string TextField { get; set; }
|
|
/// <summary>
|
|
/// 备注字段
|
|
/// </summary>
|
|
public string RemarkField = "remark";
|
|
/// <summary>
|
|
/// 数据源(初始)
|
|
/// </summary>
|
|
/// <value>The source SQL.</value>
|
|
public string SourceSQL { get; set; }
|
|
/// <summary>
|
|
/// 隐藏值
|
|
/// </summary>
|
|
/// <value>The edit value.</value>
|
|
public string EditValue { get; set; }
|
|
/// <summary>
|
|
/// 显示值
|
|
/// </summary>
|
|
/// <value>The edit text.</value>
|
|
public string EditText { get; set; }
|
|
/// <summary>
|
|
/// CurrentOperColumnKey值
|
|
/// </summary>
|
|
/// <value>The data source.</value>
|
|
public string CurrentOperColumnKey = string.Empty;
|
|
/// <summary>
|
|
/// CurrentOperModel值
|
|
/// </summary>
|
|
/// <value>The data source.</value>
|
|
public GridColumnModel CurrentOperModel = null;
|
|
/// <summary>
|
|
/// 配置的关联ModuleCodel值
|
|
/// </summary>
|
|
/// <value>The Union ModuleCodel.</value>
|
|
public string UnionModuleCodel;
|
|
/// <summary>
|
|
/// 左侧树数据
|
|
/// </summary>
|
|
public DataRow LeftRowObj;
|
|
/// <summary>
|
|
/// 系统模块实体对象
|
|
/// </summary>
|
|
/// <value>The system model.</value>
|
|
public ModuleModel SysModel { get; private set; }
|
|
/// <summary>
|
|
/// 自定义查询条件
|
|
/// </summary>
|
|
public MyControl SearchObj { get; private set; }
|
|
/// <summary>
|
|
/// 分割条位置
|
|
/// </summary>
|
|
public int PositionSplitter;
|
|
/// <summary>
|
|
/// 分割条位置
|
|
/// </summary>
|
|
public int WindowHeight;
|
|
/// <summary>
|
|
/// 单选模式
|
|
/// </summary>
|
|
public bool SingleChoiceMode;
|
|
/// <summary>
|
|
/// 表格列根据配置加载(默认是加载sql数据源中的中文列,目前只支持单选模式)
|
|
/// </summary>
|
|
public bool ConfigureColumnMode = false;
|
|
/// <summary>
|
|
/// 第一次进入
|
|
/// </summary>
|
|
private bool isFirst = true;
|
|
/// <summary>
|
|
/// 第一次进入
|
|
/// </summary>
|
|
private bool isFirstSearch = true;
|
|
/// <summary>
|
|
/// 左侧树结构
|
|
/// </summary>
|
|
public TreeViewEx LeftTreeViewEx;
|
|
/// <summary>
|
|
/// 左侧表格
|
|
/// </summary>
|
|
public GridControlEx LeftGridEx;
|
|
/// <summary>
|
|
/// 左侧结构关联字段
|
|
/// </summary>
|
|
public string ParentUnionField;
|
|
/// <summary>
|
|
/// 左侧树结构、表格主键
|
|
/// </summary>
|
|
public string ParentKeyField;
|
|
/// <summary>
|
|
/// 数据源(替换参数后)
|
|
/// </summary>
|
|
/// <value>The source SQL.</value>
|
|
public string NewSourceSQL;
|
|
/// <summary>
|
|
/// 关联返回参数的字段组合
|
|
/// </summary>
|
|
public string AddModuleResult;
|
|
/// <summary>
|
|
/// 返回关联的字典
|
|
/// </summary>
|
|
public Dictionary<string, string> ModuleResultDic = new Dictionary<string, string>();
|
|
/// <summary>
|
|
/// 单选模式最后选中的原始数据行,供需要按动态列名返回多字段的调用方使用。
|
|
/// </summary>
|
|
public DataRow SelectedResultRow { get; private set; }
|
|
public DataRow GetSelectedResultRow()
|
|
{
|
|
return SelectedResultRow ?? this.gcMain.GridView.GetFocusedDataRow();
|
|
}
|
|
/// <summary>
|
|
/// 返回多行的集合(模块返回添加行 167 168)
|
|
/// </summary>
|
|
public List<string> EditValueList = new List<string>();
|
|
public List<string> EditTextList = new List<string>();
|
|
/// <summary>
|
|
/// 是否返回集合
|
|
/// </summary>
|
|
public bool ReturnCollection;
|
|
|
|
#endregion
|
|
public FrmModelLookUp2(string ModuleCodel)
|
|
{
|
|
InitializeComponent();
|
|
this.UnionModuleCodel = ModuleCodel;
|
|
this.Disposed += new EventHandler(OnFrmModelLookUp_Disposed);
|
|
this.gcMain.GridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown;
|
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing);
|
|
this.gcMain.GridControl.ContextMenuStrip = contextMenuStrip1;
|
|
this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClick);
|
|
this.gcDetail.GridView.DoubleClick += new EventHandler(OnDoubleClick);
|
|
GridDragGrid dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView);
|
|
GridDragGrid backdragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView);
|
|
//设置关联模块
|
|
bool result = SetAssociatedModules();
|
|
this.pl_top.Height = 0;
|
|
this.gcDetail.GridView.OptionsSelection.EnableAppearanceFocusedCell = false;
|
|
this.Resize += new System.EventHandler(maximization);
|
|
this.splitMain_Right.SplitterMoved += new EventHandler(PositionChange);
|
|
this.gcDetail.GridView.OptionsView.ColumnAutoWidth = true;
|
|
this.gcMain.GridView.OptionsView.ColumnAutoWidth = true;
|
|
}
|
|
|
|
//关联模块号;是否为单选模式
|
|
public FrmModelLookUp2(string ModuleCodel, bool singleChoiceMode)
|
|
{
|
|
InitializeComponent();
|
|
this.UnionModuleCodel = ModuleCodel;
|
|
this.SingleChoiceMode = singleChoiceMode;
|
|
this.Disposed += new EventHandler(OnFrmModelLookUp_Disposed);
|
|
this.gcMain.GridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown;
|
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing);
|
|
this.gcMain.GridControl.ContextMenuStrip = contextMenuStrip1;
|
|
GridDragGrid dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView);
|
|
GridDragGrid backdragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView);
|
|
//设置关联模块
|
|
bool result = SetAssociatedModules();
|
|
|
|
|
|
|
|
//单选模式,不显示明细表,主表双击选中后退出选择界面
|
|
if (SingleChoiceMode)
|
|
{
|
|
this.splitMain_Right.PanelVisibility = SplitPanelVisibility.Panel1;
|
|
this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClickRadio);
|
|
}
|
|
else
|
|
{
|
|
this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClick);
|
|
this.gcDetail.GridView.DoubleClick += new EventHandler(OnDoubleClick);
|
|
this.Resize += new System.EventHandler(maximization);
|
|
this.splitMain_Right.SplitterMoved += new EventHandler(PositionChange);
|
|
}
|
|
|
|
//右键
|
|
DataTable dt = BaseModuleImpl.GetBaseGridRightMenus(this.UnionModuleCodel);
|
|
string[] obj = new string[]{
|
|
"",
|
|
ERPInfo.Instance.UserId,
|
|
ERPInfo.Instance.UserName,
|
|
"3",
|
|
this.UnionModuleCodel,
|
|
}; ;
|
|
DynamicModel dynamicModel = new DynamicModel(obj);
|
|
this.gcMain.SetGridRightMenus(dt, dynamicModel, this.OnGridViewRightCallBack, this.SearchObj, null);
|
|
|
|
|
|
this.SourceSQL = this.SysModel.MenuSql;
|
|
this.gcDetail.GridView.OptionsSelection.EnableAppearanceFocusedCell = false;
|
|
|
|
this.gcDetail.GridView.OptionsView.ColumnAutoWidth = true;
|
|
this.gcMain.GridView.OptionsView.ColumnAutoWidth = true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 方法
|
|
#region 设置分割条位置
|
|
/// <summary>
|
|
/// <para>说明:设置分割条位置</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void InitlizeSpiltLocation()
|
|
{
|
|
try
|
|
{
|
|
string width = IniHelper.Read(string.Format("FrmModelLookUp2_width_{0}", this.UnionModuleCodel));//通过Key获取Value值
|
|
if (!string.IsNullOrEmpty(width))
|
|
{
|
|
this.splitMain.SplitterPosition = Convert.ToInt32(width);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 保存表格属性
|
|
/// <summary>
|
|
/// <para>说明:保存表格属性</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </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 virtual void SaveItemClick(object sender, EventArgs e)
|
|
{
|
|
DataRow rowItem = null;
|
|
bool success = BaseImpl.HasExistsDataRow(ResourceKeys.SettingTableName, "formKey", CurrentOperColumnKey, string.Format(" and OperatorId='{0}' ", ERPInfo.Instance.UserId), out rowItem);
|
|
if (!success)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NotFoundSettingColumnTable);
|
|
return;
|
|
}
|
|
|
|
if (MessageUtil.Show(ResourceKeys.IsSaveColumn, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
try
|
|
{
|
|
if (rowItem == null)
|
|
{
|
|
success = this.gcMain.GridView.SaveCustomColumnToDatabase(this.CurrentOperColumnKey);
|
|
}
|
|
else
|
|
{
|
|
success = this.gcMain.GridView.UpdateCustomColumnToDatabase(this.CurrentOperColumnKey);
|
|
}
|
|
//this.SetDetailDataSource();
|
|
MessageUtil.Show(success ? ResourceKeys.SaveSuccess : ResourceKeys.SaveFault);
|
|
}
|
|
catch (SqlException sex)
|
|
{
|
|
if (sex.Message.Contains(ResourceKeys.FieldLenIsShort) &&
|
|
MessageUtil.Show(ResourceKeys.SaveFault + "\r\n" + ResourceKeys.CanUpgradeTable, MessageBoxButtons.YesNo) == DialogResult.Yes &&
|
|
BaseImpl.UpdateTableField(ResourceKeys.SettingTableName, "formKey", "varchar(200)"))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UpdateSuccess);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError("保存表格属性出错", ex);
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 设置明细数据源
|
|
/// <summary>
|
|
/// <para>说明:设置明细数据源</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetDetailDataSource()
|
|
{
|
|
//return;
|
|
//DataTable table = this.DataSource.Copy();
|
|
//DataRow[] rows = table.Select(_checkFieldName + "=True");
|
|
|
|
//if (rows != null && rows.Length > 0)
|
|
// this.gcDetail.GridControl.DataSource = rows.CopyToDataTable();
|
|
//else
|
|
//{
|
|
// this.gcDetail.GridControl.DataSource = table;
|
|
// this.gcDetail.GridControl.DataSourceTable().Clear();
|
|
//}
|
|
}
|
|
#endregion
|
|
|
|
#region 设置默认选中
|
|
/// <summary>
|
|
/// <para>说明:设置默认选中</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetDefaultValue()
|
|
{
|
|
this.gcDetail.gridControl.DataSourceTable().Clear();
|
|
if (!string.IsNullOrEmpty(EditValue) && this.IsType == ControlType.LabSelectReturnIdNew)
|
|
{
|
|
this.UpdateChecked(EditValue.Trim().Replace(", ", ",").TrimEnd(',').Split(','), ValueMember, true);
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(EditText))
|
|
{
|
|
this.UpdateChecked(EditText.Trim().Replace(", ", ",").TrimEnd(',').Split(','), TextField, false);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 设置只读列
|
|
/// <summary>
|
|
/// <para>说明:设置只读列</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetReadOnlyColumns()
|
|
{
|
|
if (true)//this.ConfigureColumnMode&& SingleChoiceMode
|
|
{
|
|
//默认以模块配置列为准(点击搜索时,固定写的列会清空)
|
|
DataTable _gridColumns = BaseModuleImpl.GetBaseGridColumns(this.UnionModuleCodel);
|
|
this.gcMain.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey);
|
|
this.gcDetail.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey);
|
|
}
|
|
else
|
|
{
|
|
this.gcMain.GridView.Columns.Clear();
|
|
this.gcDetail.GridView.Columns.Clear();
|
|
|
|
|
|
GridColumn valueColumn = new GridColumn();
|
|
valueColumn.FieldName = valueColumn.Name = ValueField;
|
|
valueColumn.Caption = "编码";
|
|
valueColumn.Width = 150;
|
|
//valueColumn.Visible = true;
|
|
valueColumn.Visible = ValueMember.Substring(0, 1) != "_";
|
|
valueColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
GridColumn textColumn = new GridColumn();
|
|
textColumn.FieldName = textColumn.Name = TextField;
|
|
textColumn.Caption = "名称";
|
|
textColumn.Width = 150;
|
|
//textColumn.Visible = true;
|
|
textColumn.Visible = TextField.Substring(0, 1) != "_";
|
|
textColumn.OptionsColumn.AllowEdit = false;
|
|
|
|
|
|
|
|
this.gcMain.GridView.Columns.AddRange(new GridColumn[] { valueColumn, textColumn });
|
|
this.gcDetail.GridView.Columns.AddRange(new GridColumn[] { valueColumn, textColumn });
|
|
|
|
if (DataSource.Columns.IndexOf("remark") != -1)
|
|
{
|
|
DataColumn column = DataSource.Columns.Cast<DataColumn>().FirstOrDefault(x => x.ColumnName.ToLower() == RemarkField);
|
|
if (column != null) RemarkField = column.ColumnName;
|
|
|
|
GridColumn remarkColumn = new GridColumn();
|
|
remarkColumn.Name = remarkColumn.FieldName = RemarkField;
|
|
remarkColumn.Caption = "备注";
|
|
remarkColumn.Visible = true;
|
|
remarkColumn.Width = 400;//this.gcMain.Width-300;
|
|
|
|
//字段第一个字符为下划线代表不显示
|
|
if (RemarkField.Substring(0, 1) == "_")
|
|
remarkColumn.Visible = false;
|
|
|
|
this.gcMain.GridView.Columns.Add(remarkColumn);
|
|
this.gcDetail.GridView.Columns.Add(remarkColumn);
|
|
}
|
|
|
|
DataTable DT = this.gcMain.gridControl.DataSource == null ? new DataTable() : this.gcMain.gridControl.DataSource as DataTable;
|
|
foreach (DataColumn dcol in DT.Columns)
|
|
{
|
|
if ((dcol.ColumnName.Substring(0, 1) != "_") && (dcol.ColumnName.ToLower() != ValueField.ToLower()) && (dcol.ColumnName.ToLower() != TextField.ToLower()) && ((int)dcol.ColumnName[0] > 127))
|
|
{
|
|
GridColumn otherColumn = new GridColumn();
|
|
otherColumn.Name = otherColumn.FieldName = otherColumn.Caption = dcol.ColumnName;
|
|
otherColumn.Visible = true;
|
|
otherColumn.Width = 150;
|
|
this.gcMain.GridView.Columns.Add(otherColumn);
|
|
this.gcDetail.GridView.Columns.Add(otherColumn);
|
|
}
|
|
}
|
|
}
|
|
SetCustomColumns();
|
|
}
|
|
#endregion
|
|
#region 加载自定义列
|
|
/// <summary>
|
|
/// <para>说明:加载自定义列</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2019-9-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetCustomColumns()
|
|
{
|
|
if (string.IsNullOrEmpty(this.CurrentOperColumnKey) || !BaseImpl.HasExistsTable(ResourceKeys.SettingTableName)) return;
|
|
|
|
DataTable customTable = this.gcMain.GridView.GetCustomColumnByDatabase(this.CurrentOperColumnKey);
|
|
if (customTable != null && customTable.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow rowItem in customTable.Rows)
|
|
{
|
|
string fieldName = rowItem["fieldName"] + "";
|
|
int fieldWidth = Convert.ToInt32(rowItem["fieldWidth"]);
|
|
int index = Convert.ToInt32(rowItem["orderid"]);
|
|
bool visible = "1".Equals(rowItem["isVisible"] + "") && fieldWidth > 0;
|
|
bool isFix = "True".Equals(rowItem["IfFixColumn"] + "", StringComparison.OrdinalIgnoreCase);
|
|
|
|
GridColumn gridColumn = this.gcMain.GridView.Columns.ColumnByName(fieldName);
|
|
if (gridColumn != null && gridColumn.Visible && gridColumn.Width > 0)
|
|
{
|
|
GridColumn colObj = this.gcMain.GridView.Columns[fieldName];
|
|
colObj.VisibleIndex = index;
|
|
colObj.Width = fieldWidth;
|
|
colObj.Visible = visible;
|
|
colObj.Fixed = isFix ? FixedStyle.Left : FixedStyle.None;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 获取选中行数据
|
|
/// <summary>
|
|
/// <para>说明:获取选中行数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataRow[].</returns>
|
|
public DataRow[] GetViewFocusedDataRows(GridView gridView)
|
|
{
|
|
int[] rows = gridView.GetSelectedRows();
|
|
DataRow[] dataRows = new DataRow[rows.Length];
|
|
for (int i = 0; i < rows.Length; i++)
|
|
{
|
|
dataRows[i] = gridView.GetDataRow(rows[i]);
|
|
}
|
|
return dataRows;
|
|
}
|
|
#endregion
|
|
#region 刷新左侧树数据
|
|
/// <summary>
|
|
/// <para>说明:设置左侧树数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void SetLeftTreeView()
|
|
{
|
|
this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(this.UnionModuleCodel);//获取表格左侧树字段
|
|
if (this.LeftRowObj != null)
|
|
{
|
|
//this.ModuleGridObj.ParentUnionField = this.LeftRowObj["fieldname"] + "";
|
|
this.ParentUnionField = this.LeftRowObj["fieldname"] + "";
|
|
this.ParentKeyField = this.LeftRowObj["fieldsqlid"] + "";
|
|
this.treeLeft.TreeNodeKeyField = this.LeftRowObj["fieldsqlid"] + "";
|
|
this.treeLeft.TreeNodeTextField = this.LeftRowObj["fieldsqlname"] + "";
|
|
this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeLeftTreeNodeSelected);
|
|
this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(this.LeftRowObj["fieldsql"] + ""));
|
|
}
|
|
else
|
|
{
|
|
// 根据模块上配置的sql加载树
|
|
if (this.SysModel != null && !string.IsNullOrEmpty(this.SysModel.TreeSQL))
|
|
{
|
|
this.ParentUnionField = "SpeciesNo";
|
|
this.ParentKeyField = "SpeciesNo";
|
|
this.treeLeft.TreeNodeKeyField = "SpeciesNo";
|
|
this.treeLeft.TreeNodeTextField = "SpeciesName";
|
|
this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeLeftTreeNodeSelected);
|
|
this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(this.SysModel.TreeSQL));
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:树节点点击后刷新数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-26 </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="TreeViewEventArgs"/> instance containing the event data.</param>
|
|
protected void OnTreeLeftTreeNodeSelected(object sender, TreeViewEventArgs e)
|
|
{
|
|
string where = string.Format(" and {0} like '{1}%' ", this.treeLeft.TreeNodeKeyField, e.Node.Name);
|
|
|
|
string sqlValue = ReplaceHelper.IsProcedure(NewSourceSQL) ?
|
|
ReplaceHelper.ReplaceTreeViewParentKeyCond(NewSourceSQL, treeLeft.GetSelectNodeValue()) :
|
|
ReplaceHelper.ReplaceWhereCond(this.NewSourceSQL) + where;
|
|
this.DataSource = MainImpl.GetDataTableResult(sqlValue);
|
|
//this.SetSelectionBox();
|
|
//this.SetDefaultValue();
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:加载主表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-31 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="where">The where key.</param>
|
|
protected void SetMainGridView(string where = "")
|
|
{
|
|
//string sqlValue = ReplaceHelper.ReplaceWhereCond(this.SysModel.MenuSql);
|
|
//sqlValue = this.SysModel.MenuSql.StartsWith("select", StringComparison.OrdinalIgnoreCase) ? sqlValue + where : sqlValue;
|
|
//if (IsExcel && !string.IsNullOrEmpty(this._labPicName))
|
|
//{
|
|
// string sql = MainImpl.GetDefaultValue(sqlValue, this.ModuleGridObj.ParentKeyField, Model.OtherParams());
|
|
// DataTable dt = MainImpl.GetDataTableResult(ReplaceLeftOrGridValue(sql));
|
|
// if (dt.Rows.Count > 0)
|
|
// {
|
|
// this._currentRow = dt.Rows[0];
|
|
// Byte[] file = (byte[])this._currentRow[this._labPicName];
|
|
// if (file.Length <= 0)
|
|
// {
|
|
// this.excelControlEx1.SpreadSheetBarObj.Control.CreateNewDocument();
|
|
// }
|
|
// else
|
|
// {
|
|
// if (!string.IsNullOrEmpty(this.excelControlEx1.CurrentPath) && File.Exists(this.excelControlEx1.CurrentPath))
|
|
// {
|
|
// File.Delete(this.excelControlEx1.CurrentPath);
|
|
// }
|
|
// this.excelControlEx1.LoadFileSteam(file);
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// this.excelControlEx1.SpreadSheetBarObj.Control.CreateNewDocument();
|
|
// MessageUtil.Show(ResourceKeys.NotConfigExcel);
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// // 左侧gridView时,需要替换sql参数(包含查询条件、表格选中行).
|
|
// if (this.gridLeft.Visible)
|
|
// {
|
|
// sqlValue = this._leftGridSearchObj != null ? this._leftGridSearchObj.ReplaceParentControlValue(sqlValue) : sqlValue;
|
|
// sqlValue = ReplaceHelper.ReplaceRowParam(this.gridLeft.GridView.GetFocusedDataRow(), sqlValue);
|
|
// }
|
|
|
|
// this.ModuleGridObj.SearchObj.SearchGrid(sqlValue);
|
|
// if (!this.IsDragDetail)
|
|
// this.ModuleGridDetailObj.SetDetailGridDataSource();
|
|
//}
|
|
}
|
|
#endregion
|
|
#region 创建界面
|
|
/// <summary>
|
|
/// <para>说明:创建界面</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="menuCode">The menu code.</param>
|
|
public void InitControls(string UnionModuleCodel)
|
|
{
|
|
|
|
//this.SysModel.MenuSql = this.NewSourceSQL;
|
|
//设置上方条件
|
|
this.pl_top.Controls.Clear();
|
|
DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.SysModel.CondKey);//加载自定义配置字段
|
|
this.SearchObj = new MyControl(this.NewSourceSQL, this.gcMain, LeftTreeViewEx, LeftGridEx);
|
|
this.SearchObj.ParentUnionField = this.ParentUnionField;
|
|
this.pl_top.Height = 0;
|
|
this.pl_top.Height = this.SearchObj.InitSearchControl(queryTable, this.pl_top);
|
|
//this.SearchObj.OnSearchAfterCallBack += SearchObj_OnSearchAfterCallBack;
|
|
|
|
if (LeftTreeViewEx != null && LeftTreeViewEx.TreeView.Nodes.Count > 0)
|
|
{
|
|
LeftTreeViewEx.TreeView.SelectedNode = LeftTreeViewEx.TreeView.Nodes[0];//重新打开时默认选中第一条
|
|
LeftTreeViewEx.TreeView.Nodes[0].Expand();
|
|
}
|
|
else if (LeftGridEx != null)
|
|
{
|
|
LeftGridEx.GridView.SelectRow(0);
|
|
}
|
|
|
|
this.DataSource = BaseImpl.GetDataTableResult(this.NewSourceSQL + " and 1<>1");
|
|
this.gcDetail.GridControl.DataSource = this.gcMain.gridControl.DataSourceTable().Clone();
|
|
//创建表格列
|
|
if (isFirst)
|
|
{
|
|
this.SetReadOnlyColumns();
|
|
this.isFirst = false;
|
|
}
|
|
this.SetDefaultValue();
|
|
|
|
//查询
|
|
if (this.SysModel.CsHasDefultSearch) this.SearchObj.SearchGrid();
|
|
|
|
//单选模式不需要设置下方表中选中行
|
|
//if (!SingleChoiceMode) this.SetDefaultValue();
|
|
|
|
}
|
|
|
|
|
|
private void SearchObj_OnSearchAfterCallBack(object sender, EventArgs e)
|
|
{
|
|
if (isFirstSearch)
|
|
{
|
|
this.SetDefaultValue();
|
|
}
|
|
isFirstSearch = false;
|
|
}
|
|
|
|
#endregion
|
|
#region 设置左侧表格数据
|
|
/// <summary>
|
|
/// <para>说明:设置左侧表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-10-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void SetLeftGridView()
|
|
{
|
|
this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(UnionModuleCodel);//获取表格左侧树字段
|
|
if (this.LeftRowObj != null)
|
|
{
|
|
DataTable dtTable = BaseModuleImpl.GetBaseLeftGridField(UnionModuleCodel);
|
|
DataTable dtColorTable = BaseModuleImpl.GetBaseGridRowColors(this.LeftRowObj["fieldKey"] + "");
|
|
this.gridLeft.GridView.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(OnGridViewRowClick);
|
|
this.gridLeft.SetGridRowColors(dtColorTable);
|
|
this.gridLeft.SetReadOnlyColumns(dtTable, GridCustomColumnStruct.BaseLeftGridView + UnionModuleCodel);
|
|
this.ParentUnionField = this.LeftRowObj["fieldname"] + "";
|
|
this.ParentKeyField = this.LeftRowObj["fieldname"] + "";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 更新选中状态
|
|
/// <summary>
|
|
/// <para>说明:更新选中状态</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="spilts">The spilts.</param>
|
|
/// <param name="fieldName">Name of the field.</param>
|
|
/// <param name="check">if set to <c>true</c> [check].</param>
|
|
private void UpdateChecked(string[] spilts, string fieldName, bool isValue, bool check = true)
|
|
{
|
|
if (spilts == null || spilts.Length == 0 || string.IsNullOrEmpty(fieldName) || this.DataSource == null)
|
|
return;
|
|
|
|
for (int i = 0; i < spilts.Length; i++)
|
|
{
|
|
string detileRowSql = string.Format(@"SELECT * FROM({0}) AS t WHERE {1} = '{2}';", this.NewSourceSQL, isValue ? ValueMember : TextField, spilts[i].Trim());
|
|
DataRow rowItem = rowItem = BaseImpl.GetDataRowResult(detileRowSql);
|
|
if (rowItem != null)
|
|
{
|
|
(this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(rowItem.ItemArray);
|
|
}
|
|
}
|
|
this.SetDetailDataSource();
|
|
}
|
|
#endregion
|
|
#region 刷新右侧表格数据
|
|
/// <summary>
|
|
/// <para>说明:刷新右侧表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-19 </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 OnGridViewRowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.SetMainGridView();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 事件
|
|
#region 分割条位置改变
|
|
/// <summary>
|
|
/// <para>说明:分割条位置包含时记录位置</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2021-08-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void PositionChange(object sender, EventArgs e)
|
|
{
|
|
PositionSplitter = this.splitMain_Right.SplitterPosition;
|
|
IniHelper.Write(string.Format("FrmModelLookUp2_height_{0}", this.UnionModuleCodel), PositionSplitter + "");
|
|
}
|
|
#endregion
|
|
#region 窗口大小改变
|
|
/// <summary>
|
|
/// <para>说明:窗口大小改变时改变分割条位置</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2021-08-25 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void maximization(object sender, EventArgs e)
|
|
{
|
|
//double a = (double)PositionSplitter / (double)WindowHeight;
|
|
//this.splitMain_Right.SplitterPosition = Convert.ToInt32(Math.Round((double)this.Height * a));
|
|
//WindowHeight = this.Height;
|
|
}
|
|
#endregion
|
|
#region 选中行
|
|
/// <summary>
|
|
/// <para>说明:选中行</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </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.XtraGrid.Views.Grid.RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
private void OnRowCellClick(object sender, EventArgs e)
|
|
{
|
|
DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
|
|
if (rowItem != null)
|
|
{
|
|
DataRow Item = (this.gcDetail.GridControl.DataSource as DataTable).Rows.Cast<DataRow>().FirstOrDefault(x => x[ValueMember] + "" == rowItem[ValueMember] + "");
|
|
if (Item == null) (this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(rowItem.ItemArray);
|
|
rowItem.AcceptChanges();
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:选中行(单选模式)</para>
|
|
/// <para>创建人:曹屹峰</para>
|
|
/// <para>创建日期:2024-01-02 </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.XtraGrid.Views.Grid.RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
private void OnRowCellClickRadio(object sender, EventArgs e)
|
|
{
|
|
EditValue = string.Empty;
|
|
EditText = string.Empty;
|
|
SelectedResultRow = null;
|
|
ModuleResultDic.Clear();
|
|
DataRow dr = this.gcMain.GridView.GetFocusedDataRow();
|
|
if (dr != null)
|
|
{
|
|
SelectedResultRow = dr;
|
|
this.EditValue = dr[ValueMember] + "";
|
|
this.EditText = dr[TextField] + "";
|
|
|
|
if (!string.IsNullOrEmpty(AddModuleResult))
|
|
{
|
|
string[] resultFields = AddModuleResult.Split(',');
|
|
foreach (string resultField in resultFields)
|
|
{
|
|
Match match = Regex.Match(resultField, @"^\s*([^\s]+)\s+AS\s+([^\s]+)\s*$", RegexOptions.IgnoreCase);
|
|
if (match.Success)
|
|
{
|
|
string beforeAs = match.Groups[1].Value.Trim();
|
|
string afterAs = match.Groups[2].Value.Trim();
|
|
string value = "";
|
|
|
|
if (dr.Table.Columns.Contains(beforeAs))
|
|
{
|
|
value += dr[beforeAs] + "";
|
|
}
|
|
|
|
ModuleResultDic.Add(afterAs, value);
|
|
}
|
|
else
|
|
{
|
|
string value = "";
|
|
|
|
if (dr.Table.Columns.Contains(resultField))
|
|
{
|
|
value += dr[resultField] + "";
|
|
}
|
|
|
|
ModuleResultDic.Add(resultField, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
#region 取消选择
|
|
/// <summary>
|
|
/// <para>说明:取消选择</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </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>
|
|
private void OnDoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (this.gcDetail.GridView.RowCount == 0) return;
|
|
DataRow rowItem = this.gcDetail.GridView.GetFocusedDataRow();
|
|
(this.gcDetail.GridControl.DataSource as DataTable).Rows.Remove(rowItem);
|
|
}
|
|
#endregion
|
|
#region 关闭时清空唯一键
|
|
/// <summary>
|
|
/// <para>说明:关闭时清空唯一键</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-20 </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="PopupMenuShowingEventArgs"/> instance containing the event data.</param>
|
|
private void OnFormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
CurrentOperColumnKey = "";
|
|
CurrentOperModel = null;
|
|
}
|
|
#endregion
|
|
|
|
#region 确定
|
|
/// <summary>
|
|
/// <para>说明:确定</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-20 </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>
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
EditValue = string.Empty;
|
|
EditText = string.Empty;
|
|
this.EditValueList.Clear();
|
|
this.EditTextList.Clear();
|
|
ModuleResultDic.Clear();
|
|
DataTable sourceTable = this.gcDetail.GridControl.DataSource as DataTable;
|
|
|
|
if (ReturnCollection)
|
|
{
|
|
int i = 0;
|
|
foreach (DataRow item in sourceTable.Rows)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
this.EditValue = item[ValueMember] + "";
|
|
this.EditText = item[TextField] + "";
|
|
}
|
|
else
|
|
{
|
|
this.EditValueList.Add(item[ValueMember] + "");
|
|
this.EditTextList.Add(item[TextField] + "");
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (DataRow item in sourceTable.Rows)
|
|
{
|
|
this.EditValue += item[ValueMember] + ",";
|
|
this.EditText += item[TextField] + ",";
|
|
}
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AddModuleResult))
|
|
{
|
|
string[] resultFields = AddModuleResult.Split(',');
|
|
foreach (string resultField in resultFields)
|
|
{
|
|
Match match = Regex.Match(resultField, @"^\s*([^\s]+)\s+AS\s+([^\s]+)\s*$", RegexOptions.IgnoreCase);
|
|
if (match.Success)
|
|
{
|
|
string beforeAs = match.Groups[1].Value.Trim();
|
|
string afterAs = match.Groups[2].Value.Trim();
|
|
string value = "";
|
|
foreach (DataRow item in sourceTable.Rows)
|
|
{
|
|
if (item.Table.Columns.Contains(beforeAs))
|
|
{
|
|
value += item[beforeAs] + ",";
|
|
}
|
|
}
|
|
ModuleResultDic.Add(afterAs, value);
|
|
}
|
|
else
|
|
{
|
|
string value = "";
|
|
foreach (DataRow item in sourceTable.Rows)
|
|
{
|
|
if (item.Table.Columns.Contains(resultField))
|
|
{
|
|
value += item[resultField] + ",";
|
|
}
|
|
}
|
|
ModuleResultDic.Add(resultField, value);
|
|
}
|
|
}
|
|
}
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region 取消
|
|
/// <summary>
|
|
/// <para>说明:取消</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-20 </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>
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
}
|
|
#endregion
|
|
|
|
#region 全选所有数据
|
|
/// <summary>
|
|
/// 全选所有数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btn_selectAll_Click(object sender, EventArgs e)
|
|
{
|
|
DataTable DataSource = this.gcMain.GridView.GetGridViewFilteredAndSortedDataToDataTable();
|
|
foreach (DataRow item in DataSource.Rows)
|
|
{
|
|
//DataRow rowItem = this.DataSource.Select("1=1").FirstOrDefault(x => (item[_id] + "").Equals(x[_id] + ""));
|
|
(this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(item.ItemArray);
|
|
}
|
|
this.SetDetailDataSource();
|
|
}
|
|
#endregion
|
|
|
|
#region 取消全选
|
|
/// <summary>
|
|
/// 取消全选
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btn_cancelAll_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
(this.gcDetail.GridControl.DataSource as DataTable).Clear();
|
|
}
|
|
#endregion
|
|
|
|
#region 释放时清理数据源
|
|
/// <summary>
|
|
/// <para>说明:释放时清理数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
private void OnFrmModelLookUp_Disposed(object sender, EventArgs e)
|
|
{
|
|
if (this.DataSource != null)
|
|
{
|
|
this.DataSource = null;
|
|
}
|
|
GC.Collect();
|
|
}
|
|
#endregion
|
|
|
|
#region 设置关联模块
|
|
/// <summary>
|
|
/// <para>说明:设置管理模块</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-20 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private bool SetAssociatedModules()
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(this.UnionModuleCodel))
|
|
{
|
|
DataRow modelRow = MainImpl.GetSystemdllTab(this.UnionModuleCodel);//获取单个模块信息
|
|
if (modelRow == null)
|
|
{
|
|
MessageUtil.Show("模块编号[" + UnionModuleCodel + "],配置错误!\r\n该模块信息未找到!");
|
|
return false;
|
|
}
|
|
this.SysModel = new ModuleModel(modelRow);// 系统模块实体对象
|
|
if (this.SysModel != null)
|
|
{
|
|
if (this.SysModel.ModuleFrameHeight > 0 && this.SysModel.ModuleFrameWidth > 0)
|
|
{
|
|
this.Height = this.SysModel.ModuleFrameHeight;
|
|
this.Width = this.SysModel.ModuleFrameWidth;
|
|
}
|
|
|
|
string height = IniHelper.Read(string.Format("FrmModelLookUp2_height_{0}", this.UnionModuleCodel));//通过Key获取Value值
|
|
if (!string.IsNullOrEmpty(height))
|
|
{
|
|
this.splitMain_Right.SplitterPosition = Convert.ToInt32(height);
|
|
}
|
|
else if (this.SysModel.BottomHeight > 0)
|
|
{
|
|
this.splitMain_Right.SplitterPosition = Convert.ToInt32(this.splitMain_Right.Height - this.SysModel.BottomHeight);
|
|
}
|
|
|
|
switch (this.SysModel.MenuType)
|
|
{
|
|
case 1: // 左侧为树节点
|
|
this.pl_left_top.Visible = false;
|
|
this.gridLeft.Visible = false;
|
|
this.treeLeft.Visible = true;
|
|
this.InitlizeSpiltLocation();//设置分割条位置
|
|
this.SetLeftTreeView();//设置左侧树数据
|
|
this.LeftTreeViewEx = this.treeLeft;
|
|
break;
|
|
case 2: // 左侧为表格
|
|
this.gridLeft.Visible = true;
|
|
this.treeLeft.Visible = false;
|
|
this.InitlizeSpiltLocation();
|
|
this.SetLeftGridView();
|
|
//this.ModuleGridObj.SaveEvent += new Lskj.Control.ModuleGridEx.SaveEventHander(SetDetailGridView);
|
|
this.LeftGridEx = this.gridLeft;
|
|
break;
|
|
case 3: // 左侧为空
|
|
default:
|
|
this.splitMain.PanelVisibility = SplitPanelVisibility.Panel2;
|
|
break;
|
|
}
|
|
this.splitMain.SplitterPositionChanged += SplitMain_SplitterPositionChanged;
|
|
}
|
|
else
|
|
{
|
|
this.splitMain.PanelVisibility = SplitPanelVisibility.Panel2;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void SplitMain_SplitterPositionChanged(object sender, EventArgs e)
|
|
{
|
|
IniHelper.Write(string.Format("FrmModelLookUp2_width_{0}", this.UnionModuleCodel), this.splitMain.SplitterPosition + "");
|
|
}
|
|
#endregion
|
|
|
|
//设置选中框的值
|
|
private void SetSelectionBox()
|
|
{
|
|
this.gcDetail.GridControl.DataSource = this.gcMain.gridControl.DataSourceTable().Clone();
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-02 </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
|
|
{
|
|
//int oldRowHandle = gcMain.GridView.FocusedRowHandle;
|
|
//if (!(gcMain is TreeGridControlEx) && oldRowHandle < 0) return;
|
|
//DataTable dt = this.gcMain.GridView.GetGridViewFilteredAndSortedDataToDataTable();
|
|
//if (gcMain is TreeGridControlEx) dt = (gcMain as TreeGridControlEx).GetGridViewDataSource();
|
|
//if (dt == null || dt.Rows.Count == 0) return;
|
|
//DataRow SelectTheLine = gcMain is TreeGridControlEx ? (gcMain as TreeGridControlEx).GetViewFocusedDataRow() : dt.Rows[oldRowHandle];
|
|
//this.SearchObj.RememberRow = (this.SysModel.AccordingNameSelected == 0);
|
|
this.SearchObj.SearchLastGrid();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|