基线 SVN r240

SVN-Revision: r240
This commit is contained in:
cyf
2025-02-06 06:46:06 +00:00
commit ab56a9bcf7
5317 changed files with 902274 additions and 0 deletions
@@ -0,0 +1,36 @@
namespace Lskj.Control
{
partial class AutoTreeLookUp
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
@@ -0,0 +1,788 @@
/******************************
* 说明:自动搜索框文本框
* 创建人:龚宇超
* 创建日期: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.TreeViewExObj.tvMain_AfterCheck(_popup.TreeViewExObj, new TreeViewEventArgs(nodes[0], TreeViewAction.ByMouse));
}
}
}
}
/// <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.Enter)
{
this._popup.Focus();
}
else
{
this.RefreshPopupDataSource(this.Text.Contains(",") ? string.Empty : this.Text);
}
this.ShowPopup();
}
/// <summary>
/// <para>说明:释放时清理数据源</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-03-16 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
private void OnAutoTreeLookUp_Disposed(object sender, EventArgs e)
{
if (this.DataSourceTable != null)
{
this.DataSourceTable.Clear();
this.DataSourceTable.Dispose();
}
if (this.DataSource != null)
{
this.DataSource = null;
}
GC.Collect();
}
}
}
@@ -0,0 +1,119 @@
namespace Lskj.Control
{
partial class AutoTreePopup
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.pl_main = new DevExpress.XtraEditors.PanelControl();
this.btnAdd = new DevExpress.XtraEditors.SimpleButton();
this.pl_bottom = new DevExpress.XtraEditors.PanelControl();
this.tvMain = new Lskj.Control.TreeViewEx();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_main)).BeginInit();
this.pl_main.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_bottom)).BeginInit();
this.pl_bottom.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.tvMain);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(262, 204);
this.panel1.TabIndex = 5;
//
// pl_main
//
this.pl_main.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.pl_main.Controls.Add(this.panel1);
this.pl_main.Dock = System.Windows.Forms.DockStyle.Fill;
this.pl_main.Location = new System.Drawing.Point(0, 0);
this.pl_main.Name = "pl_main";
this.pl_main.Size = new System.Drawing.Size(262, 204);
this.pl_main.TabIndex = 3;
//
// btnAdd
//
this.btnAdd.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnAdd.Appearance.Options.UseFont = true;
this.btnAdd.Location = new System.Drawing.Point(4, 4);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(80, 28);
this.btnAdd.TabIndex = 15;
this.btnAdd.TabStop = false;
this.btnAdd.Text = "添加";
this.btnAdd.Click += new System.EventHandler(this.OnAddButtonClick);
//
// pl_bottom
//
this.pl_bottom.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.pl_bottom.Controls.Add(this.btnAdd);
this.pl_bottom.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pl_bottom.Location = new System.Drawing.Point(0, 204);
this.pl_bottom.Name = "pl_bottom";
this.pl_bottom.Size = new System.Drawing.Size(262, 36);
this.pl_bottom.TabIndex = 2;
this.pl_bottom.Visible = false;
//
// tvMain
//
this.tvMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.tvMain.Location = new System.Drawing.Point(0, 0);
this.tvMain.Name = "tvMain";
this.tvMain.Size = new System.Drawing.Size(262, 204);
this.tvMain.TabIndex = 0;
this.tvMain.KeyUp += new System.Windows.Forms.KeyEventHandler(this.OnGridViewKeyUp);
//
// AutoTreePopup
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.pl_main);
this.Controls.Add(this.pl_bottom);
this.Name = "AutoTreePopup";
this.Size = new System.Drawing.Size(262, 240);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pl_main)).EndInit();
this.pl_main.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pl_bottom)).EndInit();
this.pl_bottom.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private DevExpress.XtraEditors.PanelControl pl_main;
private DevExpress.XtraEditors.SimpleButton btnAdd;
private DevExpress.XtraEditors.PanelControl pl_bottom;
private TreeViewEx tvMain;
}
}
@@ -0,0 +1,168 @@
/******************************
* 说明:自动搜索框弹出框
* 创建人:龚宇超
* 创建日期:2018-03-15
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
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 DevExpress.XtraGrid.Views.Grid;
using DevExpress.Utils;
using DevExpress.XtraGrid;
namespace Lskj.Control
{
/// <summary>
/// 自动搜索框弹出框
/// </summary>
public partial class AutoTreePopup : UserControl
{
/// <summary>
/// 是否显示添加按钮
/// </summary>
/// <value><c>true</c> if [add visible]; otherwise, <c>false</c>.</value>
public bool AddVisible
{
get { return this.btnAdd.Visible; }
set
{
this.btnAdd.Visible = this.pl_bottom.Visible = value;
}
}
/// <summary>
/// 输入框
/// </summary>
public AutoTreeLookUp LookUp;
/// <summary>
/// Gets the TreeView object.
/// </summary>
/// <value>The TreeView object.</value>
public TreeView TreeViewObj { get { return this.tvMain.TreeView; } }
/// <summary>
/// Gets the TreeView ex object.
/// </summary>
/// <value>The TreeView ex object.</value>
public TreeViewEx TreeViewExObj { get { return this.tvMain; } }
/// <summary>
/// 弹出框回车事件
/// </summary>
public event KeyEventHandler OnGridViewEnter;
/// <summary>
/// 添加按钮点击事件
/// </summary>
public event EventHandler OnAddMouseClick;
/// <summary>
/// 弹出框鼠标点击
/// </summary>
public event EventHandler OnGridViewMouseClick;
/// <summary>
/// 弹出框是否显示
/// </summary>
/// <value><c>true</c> if this instance is show popup; otherwise, <c>false</c>.</value>
public bool IsShowPopup;
/// <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;
public AutoTreePopup()
{
InitializeComponent();
}
/// <summary>
/// 设置数据源
/// </summary>
/// <value>The data source.</value>
public object DataSource
{
get
{
return this!= null ? this.TreeViewExObj.DataSource : null;
}
set
{
if (value != null)
{
this.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>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
protected void OnGridViewKeyUp(object sender, KeyEventArgs e)
{
if (this.OnGridViewEnter != null)
this.OnGridViewEnter(this.TreeViewObj, e);
}
/// <summary>
/// <para>说明:点击GridView</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="MouseEventArgs"/> instance containing the event data.</param>
protected void OnGridViewMouseDown(object sender, MouseEventArgs e)
{
//int rowHandle = this.gridView.CalcHitInfo(e.X, e.Y).RowHandle;
//this.gridView.FocusedRowHandle = rowHandle;
//this.gridView.SelectRow(rowHandle);
//if (rowHandle > -1 && this.OnGridViewMouseClick != null)
// this.OnGridViewMouseClick(this.gridView, null);
}
/// <summary>
/// <para>说明:添加操作</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-04-03 </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 OnAddButtonClick(object sender, EventArgs e)
{
if (this.OnAddMouseClick != null)
this.OnAddMouseClick(sender, e);
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>