e86a29f85e
SVN-Revision: r254
758 lines
30 KiB
C#
758 lines
30 KiB
C#
/******************************
|
|
* 说明:自动搜索框文本框
|
|
* 创建人:龚宇超
|
|
* 创建日期:2018-03-15
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using DevExpress.XtraEditors;
|
|
using System.Drawing;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using System.Windows.Forms;
|
|
using System.Data;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control.Model;
|
|
using System.Threading;
|
|
using Lskj.Util;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Lskj.Control
|
|
{
|
|
public partial class AutoTreeLookUp : TextEdit
|
|
{
|
|
/// <summary>
|
|
/// 是否处理过计算
|
|
/// </summary>
|
|
private bool _Handed;
|
|
/// <summary>
|
|
/// 弹出框最大宽度
|
|
/// </summary>
|
|
private int _maxPopupWidth = 800;
|
|
private string _value;
|
|
private AutoTreePopup _popup = null;
|
|
|
|
/// <summary>
|
|
/// 弹出框是否显示
|
|
/// </summary>
|
|
/// <value><c>true</c> if this instance is show popup; otherwise, <c>false</c>.</value>
|
|
public bool IsShowPopup;
|
|
/// <summary>
|
|
/// 是否需要自动匹配列宽度
|
|
/// </summary>
|
|
[Description("是否需要自动匹配列宽度")]
|
|
public bool IsBestFitColumns = true;
|
|
/// <summary>
|
|
/// The minimum popup width
|
|
/// </summary>
|
|
[Description("弹出框最小宽度")]
|
|
public int MinPopupWidth;
|
|
/// <summary>
|
|
/// The minimum popup height
|
|
/// </summary>
|
|
[Description("弹出框最小高度")]
|
|
public int MinPopupHeight;
|
|
/// <summary>
|
|
/// The value field
|
|
/// </summary>
|
|
public string ValueField = string.Empty;
|
|
/// <summary>
|
|
/// The value member
|
|
/// </summary>
|
|
[Description("设置ValueMember")]
|
|
public string ValueMember = string.Empty;
|
|
/// <summary>
|
|
/// The text field
|
|
/// </summary>
|
|
[Description("设置TextMember")]
|
|
public string TextMember = string.Empty;
|
|
/// <summary>
|
|
/// The remark text
|
|
/// </summary>
|
|
[Description("设置备注")]
|
|
public string RemarkField = "remark";
|
|
/// <summary>
|
|
/// 数据源
|
|
/// </summary>
|
|
public string SourceSQL = string.Empty;
|
|
/// <summary>
|
|
/// 带参数数据源sql
|
|
/// </summary>
|
|
public string sourceParamSql = string.Empty;
|
|
public string SpeciesValue;
|
|
/// <summary>
|
|
/// 控件对象
|
|
/// </summary>
|
|
public ControlModel Model;
|
|
/// <summary>
|
|
/// The contro object
|
|
/// </summary>
|
|
public MyControl ControlObj;
|
|
/// <summary>
|
|
/// 数据源(用于匹配数据)
|
|
/// </summary>
|
|
public DataTable DataSourceTable;
|
|
/// <summary>
|
|
/// 隐藏值
|
|
/// </summary>
|
|
public string EditValue = string.Empty;
|
|
/// <summary>
|
|
/// 是否是多选值
|
|
/// </summary>
|
|
public bool isMultiClick;
|
|
/// <summary>
|
|
/// 根节点是否可以选中
|
|
/// </summary>
|
|
public bool isRootNode = true;
|
|
/// <summary>
|
|
/// 是否执行刷新
|
|
/// </summary>
|
|
public bool isRefresh = false;
|
|
/// <summary>
|
|
/// 隐藏值
|
|
/// </summary>
|
|
/// <value>The value.</value>
|
|
//public new string EditValue
|
|
//{
|
|
// get
|
|
// {
|
|
// BaseUserControl control = null;
|
|
// if (this.Model != null) control = ControlObj.FindControl(this.Model.FieldName);
|
|
|
|
// if (this.Model != null && (this.Model.FieldType == ControlType.LabAutoCompleteText || this.Model.FieldType == ControlType.LabAutoCompleteTextParam))
|
|
// {
|
|
// // 自动搜索框显示名称、自动搜索框显示名称带参数时,直接显示与保存值,此时值可以任意输入,无需匹配数据源.
|
|
// if (this.DataSource != null && this.DataSource is DataTable)
|
|
// {
|
|
// DataTable table = this.DataSourceTable != null ? this.DataSourceTable : this.DataSource as DataTable;
|
|
// DataRow rowItem = table.Select("1=1").FirstOrDefault(x => control.EditText == x[TextMember] + "");
|
|
// if (rowItem == null)
|
|
// {
|
|
// rowItem = (this.DataSource as DataTable).Select("1=1").FirstOrDefault(x => control.EditText == x[TextMember] + "");
|
|
// if (rowItem == null)
|
|
// return "";
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// if (this.Model != null && (this.Model.FieldType == ControlType.LabAutoCompleteValue || this.Model.FieldType == ControlType.LabAutoCompleteValueParam))
|
|
// {
|
|
// // 存在名称并且没有value值则
|
|
// if (control != null && string.IsNullOrEmpty(_value) && !string.IsNullOrEmpty(control.EditText))
|
|
// {
|
|
// if (this.DataSource != null && this.DataSource is DataTable)
|
|
// {
|
|
// DataTable table = this.DataSourceTable != null ? this.DataSourceTable : this.DataSource as DataTable;
|
|
// DataRow rowItem = table.Select("1=1").FirstOrDefault(x => control.EditText == x[TextMember] + "");
|
|
// if (rowItem != null)
|
|
// {
|
|
// return rowItem[ValueMember] + "";
|
|
// }
|
|
// else
|
|
// {
|
|
// rowItem = (this.DataSource as DataTable).Select("1=1").FirstOrDefault(x => control.EditText == x[TextMember] + "");
|
|
// if (rowItem != null)
|
|
// {
|
|
// return rowItem[ValueMember] + "";
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// return control != null && string.IsNullOrEmpty(control.EditText) ? "" : _value;
|
|
// }
|
|
// set
|
|
// {
|
|
// if (this.Model != null && (this.Model.FieldType == ControlType.LabTreeLookText || this.Model.FieldType == ControlType.LabAutoCompleteTextParam))
|
|
// {
|
|
// // 自动搜索框显示名称、自动搜索框显示名称带参数时,直接显示与保存值,此时值可以任意输入,无需匹配数据源.
|
|
// this.Text = this._value = value;
|
|
// }
|
|
// else
|
|
// {
|
|
// if (this.DataSource != null && this.DataSource is DataTable)
|
|
// {
|
|
// DataTable table = this.DataSourceTable != null && this.DataSourceTable.Rows.Count > 0 && !SourceSQL.ToLower().StartsWith("exec") ? this.DataSourceTable : this.DataSource as DataTable;
|
|
// DataRow rowItem = table.Select("1=1").FirstOrDefault(x => value == x[ValueMember] + "");
|
|
// if (rowItem != null)
|
|
// {
|
|
// this._value = rowItem[ValueMember] + "";
|
|
// this.Text = rowItem[TextMember] + "";
|
|
// this.SelectionStart = this.Text.Length;
|
|
// }
|
|
// else
|
|
// {
|
|
// rowItem = (this.DataSource as DataTable).Select("1=1").FirstOrDefault(x => value == x[ValueMember] + "");
|
|
// if (rowItem != null)
|
|
// {
|
|
// this._value = rowItem[ValueMember] + "";
|
|
// this.Text = rowItem[TextMember] + "";
|
|
// this.SelectionStart = this.Text.Length;
|
|
// }
|
|
// else
|
|
// {
|
|
// this._value = string.Empty;
|
|
// this.Text = string.Empty;
|
|
// }
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// this._value = string.Empty;
|
|
// this.Text = string.Empty;
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
/// <summary>
|
|
/// <para>说明:设置控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public new string EditText
|
|
{
|
|
get
|
|
{
|
|
return this.Text;
|
|
}
|
|
set
|
|
{
|
|
if (!string.IsNullOrEmpty(value) && _popup != null && _popup.DataSource != null)
|
|
{
|
|
string[] values = value.Trim(',').Split(',');
|
|
string text = string.Empty;
|
|
this.EditValue = string.Empty;
|
|
foreach (string item in values)
|
|
{
|
|
DataRow rowItem = _popup.TreeViewExObj.DataSource.Rows.Cast<DataRow>().FirstOrDefault(x => x[ValueMember] + "" == item);
|
|
DataRow rowItemText = _popup.TreeViewExObj.DataSource.Rows.Cast<DataRow>().FirstOrDefault(x => x[TextMember] + "" == item);
|
|
if (rowItem != null)
|
|
{
|
|
text += rowItem[TextMember] + ",";
|
|
this.EditValue += rowItem[ValueMember] + ",";
|
|
}
|
|
if (rowItemText != null)
|
|
{
|
|
text += rowItemText[TextMember] + ",";
|
|
this.EditValue += rowItemText[ValueMember] + ",";
|
|
}
|
|
}
|
|
this.Text = text.Trim(',');
|
|
this.EditValue = EditValue.Trim(',');
|
|
}
|
|
else
|
|
{
|
|
this.Text = "";
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 设置数据源
|
|
/// </summary>
|
|
/// <value>The data source.</value>
|
|
public object DataSource
|
|
{
|
|
get
|
|
{
|
|
return this._popup != null ? this._popup.TreeViewExObj.DataSource : null;
|
|
}
|
|
set
|
|
{
|
|
if (value != null)
|
|
{
|
|
this._popup.TreeViewObj.CheckBoxes = isMultiClick;
|
|
this._popup.TreeViewExObj.TreeNodeKeyField = ValueMember;
|
|
this._popup.TreeViewExObj.TreeNodeTextField = TextMember;
|
|
this._popup.TreeViewExObj.BindTreeView(value as DataTable);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:隐藏弹出框</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void HidePopup()
|
|
{
|
|
if (this.IsShowPopup)
|
|
{
|
|
this.IsShowPopup = false;
|
|
this._popup.Hide();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:显示弹出框</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void ShowPopup()
|
|
{
|
|
if (!this.Properties.ReadOnly && this.Enabled && !this.IsShowPopup)
|
|
{
|
|
this.IsShowPopup = true;
|
|
this._popup.Show();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 弹出框
|
|
/// </summary>
|
|
/// <value>The popup.</value>
|
|
[Description("自动搜索弹出框")]
|
|
public AutoTreePopup Popup { get { return this._popup; } private set { _popup = value; } }
|
|
|
|
/// <summary>
|
|
/// 界面关闭时
|
|
/// </summary>
|
|
public event EventHandler OnPopupClosed;
|
|
|
|
public AutoTreeLookUp()
|
|
{
|
|
InitializeComponent();
|
|
InitializePopup();
|
|
InitializeEvent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:初始化事件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeEvent()
|
|
{
|
|
this.Disposed += new EventHandler(OnAutoTreeLookUp_Disposed);
|
|
this.MouseDown += new MouseEventHandler(OnAutoGridLookUpGotFocus);
|
|
this.LostFocus += new EventHandler(OnAutoGridLookUpLostFocus);
|
|
this.KeyUp += new KeyEventHandler(OnAutoGridLookUpKeyUp);
|
|
|
|
this._popup.TreeViewObj.LostFocus += new EventHandler(OnAutoGridLookUpPopupLostFocus);
|
|
if (isMultiClick) this._popup.TreeViewExObj.OnGridViewEnter += new KeyEventHandler(OnPopupGridViewEnter);
|
|
//if (!isMultiClick) this._popup.TreeViewExObj.OnTreeNodeMouseClick += new TreeNodeMouseClickEventHandler(OnPopupNodeMouseClick);
|
|
if (!isMultiClick) this._popup.TreeViewExObj.TreeNodeSelectAfter += new TreeViewEventHandler(OnPopupNodeSelectAfter);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:初始化弹出框</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializePopup()
|
|
{
|
|
this._popup = new AutoTreePopup();
|
|
this._popup.LookUp = this;
|
|
this._popup.Hide();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:计算弹出控件位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void CalcPopupLocation()
|
|
{
|
|
this._popup.Parent = this.GetParent(this.Parent);
|
|
|
|
Form form = this._popup.Parent as Form;
|
|
if (form != null)
|
|
{
|
|
int iTop = this.Top + this.Height;
|
|
int iLeft = this.Left;
|
|
System.Windows.Forms.Control ctr = this.Parent;
|
|
|
|
while (ctr != form)
|
|
{
|
|
iTop += ctr.Top;
|
|
iLeft += ctr.Left;
|
|
ctr = ctr.Parent;
|
|
}
|
|
|
|
if (iTop + this.Height + this._popup.Height > ctr.Height)
|
|
{
|
|
if (iTop - this.Height > ctr.Height - iTop)
|
|
{
|
|
if (this._popup.Height > iTop - this.Height)
|
|
{
|
|
this._popup.Height = iTop - this.Height;
|
|
iTop = 0;
|
|
}
|
|
else
|
|
{
|
|
iTop = iTop - this.Height - this._popup.Height;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this._popup.Height = ctr.Height - iTop - 30;
|
|
}
|
|
}
|
|
if (iLeft + this._popup.Width > ctr.Width)
|
|
{
|
|
if (iLeft + this.Width > ctr.Width - iLeft)
|
|
{
|
|
if (this._popup.Width > iLeft + this.Width)
|
|
{
|
|
this._popup.Width = iLeft + this.Width;
|
|
iLeft = 0;
|
|
}
|
|
else
|
|
iLeft = iLeft + this.Width - this._popup.Width;
|
|
}
|
|
else
|
|
this._popup.Width = ctr.Width - iLeft - 30;
|
|
}
|
|
|
|
this._popup.Left = iLeft;
|
|
this._popup.Top = iTop;
|
|
}
|
|
this._popup.BringToFront();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void RefreshPopupDataSource(string searchText)
|
|
{
|
|
if (string.IsNullOrEmpty(SourceSQL))
|
|
{
|
|
// 本地搜索
|
|
}
|
|
else
|
|
{
|
|
isRefresh = !string.IsNullOrEmpty(searchText);
|
|
// 数据库搜索
|
|
string sqlValue = string.Format("select * from ({0}\r\n) temp where {1} like '%{3}%' or {2} like '%{3}%' or dbo.P_getpy({2}) like '%{3}%'", string.IsNullOrEmpty(sourceParamSql) ? SourceSQL : sourceParamSql, ValueField, TextMember, searchText);
|
|
this.DataSource = MainImpl.GetDataTableResult(sqlValue);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取顶层窗口</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>Control.</returns>
|
|
private Form GetParent(System.Windows.Forms.Control ctr)
|
|
{
|
|
if (ctr == null) return null;
|
|
|
|
return ctr is Form ? ctr as Form : GetParent(ctr.Parent);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void SetValue()
|
|
{
|
|
string ids = "";
|
|
if (this.isMultiClick)
|
|
{
|
|
ids = Model.TreeCheckModel.Equals("1") ? this._popup.TreeViewExObj.GetCheckValues(true) : this._popup.TreeViewExObj.GetCheckValues();
|
|
}
|
|
else
|
|
{
|
|
ids = this._popup.TreeViewExObj.GetSelectNodeValue();
|
|
}
|
|
if (ids != null)
|
|
{
|
|
ids = ids.Replace("'", "");
|
|
this.EditText = ids;
|
|
this.Focus();
|
|
}
|
|
|
|
if (this.OnPopupClosed != null)
|
|
this.OnPopupClosed(this, null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:值为空时弹出搜索界面</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </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 OnAutoGridLookUpGotFocus(object sender, EventArgs e)
|
|
{
|
|
this.CalcPopupLocation();
|
|
// 带参数sql,处理
|
|
if (this.ControlObj != null && Regex.IsMatch(SourceSQL, ReplaceHelper.ReplaceParamKey))
|
|
{
|
|
sourceParamSql = SourceSQL;
|
|
// Step 1:替换SpeciesNo
|
|
List<string> condition = ReplaceHelper.GetParamFields(sourceParamSql);
|
|
if (!string.IsNullOrEmpty(SpeciesValue))
|
|
{
|
|
foreach (string item in condition)
|
|
{
|
|
string field = item.Replace("{", "").Replace("}", "");
|
|
if ("speciesno".Equals(field, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
sourceParamSql = sourceParamSql.Replace(item, SpeciesValue);
|
|
}
|
|
}
|
|
}
|
|
// Step 2:替换SpeciesNo
|
|
if (this.ControlObj.CurrentData != null && this.ControlObj.CurrentData.Table.Columns.Contains("SpeciesNo"))
|
|
{
|
|
foreach (string item in condition)
|
|
{
|
|
string field = item.Replace("{", "").Replace("}", "");
|
|
if ("speciesno".Equals(field, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
sourceParamSql = sourceParamSql.Replace(item, this.ControlObj.CurrentData["SpeciesNo"] + "");
|
|
}
|
|
}
|
|
}
|
|
|
|
sourceParamSql = ControlObj.ReplaceControlValue(sourceParamSql.Replace("#", ""));
|
|
this._popup.TreeViewExObj.BindTreeView(MainImpl.GetDataTableResult(sourceParamSql));
|
|
}
|
|
this.ShowPopup();
|
|
if (isRefresh) this.RefreshPopupDataSource("");
|
|
_popup.TreeViewExObj.UnCheckAllNodes();//取消勾选所有节点
|
|
if (!string.IsNullOrWhiteSpace(this.EditValue))
|
|
{
|
|
string[] spilts = this.EditValue.Trim().Replace(", ", ",").TrimEnd(',').Split(',');
|
|
for (int i = 0; i < spilts.Length; i++)
|
|
{
|
|
string keyValue = spilts[i].Trim();
|
|
TreeNode[] nodes = _popup.TreeViewObj.Nodes.Find(keyValue, true);
|
|
if (nodes.Count() > 0)
|
|
{
|
|
if (nodes[0].Parent != null) nodes[0].Parent.Expand();
|
|
nodes[0].Checked = true;
|
|
_popup.TreeViewObj.SelectedNode = nodes[0];
|
|
_popup.TreeViewExObj.tvMain_AfterCheck(_popup.TreeViewExObj, new TreeViewEventArgs(nodes[0], TreeViewAction.ByMouse));
|
|
}
|
|
|
|
}
|
|
}
|
|
_popup.TreeViewObj.Focus();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-15 </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 OnPopupGridViewEnter(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
this.SetValue();
|
|
this.HidePopup();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-03-29 </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 OnPopupDoubleEnter(object sender, TreeNodeMouseClickEventArgs e)
|
|
{
|
|
if (e.Node != null && e.Node.Bounds.Contains(e.Location))
|
|
{
|
|
if (e.Node.Nodes.Count > 0 && !this.isRootNode)
|
|
{
|
|
return;
|
|
}
|
|
this.EditText = e.Node.Name;
|
|
this.Focus();
|
|
this.HidePopup();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:鼠标回调</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-15 </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 OnPopupNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
|
{
|
|
this.SetValue();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:选中回调</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-15 </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 OnPopupNodeSelectAfter(object sender, TreeViewEventArgs e)
|
|
{
|
|
this.SetValue();
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:当前控件失去焦点关闭界面</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </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 OnAutoGridLookUpLostFocus(object sender, EventArgs e)
|
|
{
|
|
if (this._popup.Visible && !this._popup.Focused && !this._popup.TreeViewObj.Focused && !this.Focused)
|
|
{
|
|
this.HidePopup();
|
|
}
|
|
if (isRootNode) return;
|
|
//if (isRefresh) this.RefreshPopupDataSource("");
|
|
string text = string.Empty;
|
|
string keyValue = this.EditValue + "";
|
|
if (!string.IsNullOrEmpty(keyValue))
|
|
{
|
|
string[] values = keyValue.Trim(',').Split(',');
|
|
foreach (string item in values)
|
|
{
|
|
DataRow rowItem = _popup.TreeViewExObj.DataSource.Rows.Cast<DataRow>().FirstOrDefault(x => x[ValueMember] + "" == item);
|
|
if (rowItem != null)
|
|
{
|
|
text += rowItem[TextMember] + ",";
|
|
}
|
|
}
|
|
}
|
|
text = text.TrimEnd(',');
|
|
if (!text.Equals(this.Text))
|
|
{
|
|
this.EditText = this.Text;
|
|
}
|
|
TreeNode[] nodes = _popup.TreeViewObj.Nodes.Find(keyValue, true);
|
|
if (nodes.Length > 0 && nodes[0].Nodes.Count > 0)
|
|
{
|
|
this.EditText = string.Empty;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:弹出框失去焦点关闭界面</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </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 OnAutoGridLookUpPopupLostFocus(object sender, EventArgs e)
|
|
{
|
|
if (this._popup.Visible && !this._popup.Focused && !this._popup.TreeViewObj.Focused && !this.Focused)
|
|
{
|
|
this.HidePopup();
|
|
}
|
|
if (isRootNode) return;
|
|
if (isRefresh) this.RefreshPopupDataSource("");
|
|
string text = string.Empty;
|
|
string keyValue = this.EditValue + "";
|
|
if (!string.IsNullOrEmpty(keyValue))
|
|
{
|
|
string[] values = keyValue.Trim(',').Split(',');
|
|
foreach (string item in values)
|
|
{
|
|
DataRow rowItem = _popup.TreeViewExObj.DataSource.Rows.Cast<DataRow>().FirstOrDefault(x => x[ValueMember] + "" == item);
|
|
if (rowItem != null)
|
|
{
|
|
text += rowItem[TextMember] + ",";
|
|
}
|
|
}
|
|
}
|
|
text = text.Trim(',');
|
|
if (!text.Equals(this.Text))
|
|
{
|
|
this.EditText = this.Text;
|
|
}
|
|
TreeNode[] nodes = _popup.TreeViewObj.Nodes.Find(keyValue, true);
|
|
if (nodes.Length > 0 && nodes[0].Nodes.Count > 0)
|
|
{
|
|
this.EditText = string.Empty;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:鼠标弹起时刷新数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-16 </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="KeyEvnentArgs"/> instance containing the event data.</param>
|
|
protected void OnAutoGridLookUpKeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Ent |