基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Lskj.Core;
|
||||
using DevExpress.XtraEditors;
|
||||
using DevExpress.XtraEditors.Controls;
|
||||
using System.Reflection;
|
||||
using DevExpress.XtraGrid.Views.Grid;
|
||||
using DevExpress.Data.Filtering;
|
||||
|
||||
namespace CsHospital.UserControls
|
||||
{
|
||||
|
||||
public partial class UserZdmc : UserControl
|
||||
{
|
||||
|
||||
|
||||
public UserZdmc()
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
public string gid = "";
|
||||
public delegate void BindTextCode(string data,bool flag);
|
||||
public event BindTextCode bindTextCode;
|
||||
|
||||
/// <summary>
|
||||
/// 下拉框对象
|
||||
/// </summary>
|
||||
public DevExpress.XtraEditors.GridLookUpEdit GridLookUpEditObj { get { return GridLookUpEdit1; } }
|
||||
|
||||
private void gridLookUpEdit1_Popup(object sender, EventArgs e)
|
||||
{
|
||||
GridLookUpEdit edit = sender as GridLookUpEdit;
|
||||
FilterLookup(sender, new string[] { "micd10", "cdise", "dnamepy" });//中文,全拼英,简拼
|
||||
}
|
||||
|
||||
|
||||
private void gridLEdit1_EditValueChanging(object sender, ChangingEventArgs e)
|
||||
{
|
||||
this.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate
|
||||
{
|
||||
FilterLookup(sender, new string[] { "micd10", "cdise", "dnamepy" });
|
||||
}));
|
||||
}
|
||||
private void gridLUpEdit1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
GridLookUpEdit edit = sender as GridLookUpEdit;
|
||||
edit.SelectionStart = edit.Text.Length;
|
||||
string gname = edit.Text;
|
||||
DataRow[] dtZdmcRows = ((DataTable)edit.Properties.DataSource).Select(string.Format("cdise='{0}'", gname));
|
||||
if (dtZdmcRows.Length == 0) {
|
||||
bindTextCode("", false);
|
||||
return;
|
||||
}
|
||||
gid=dtZdmcRows[0]["micd10"].ToString();
|
||||
bindTextCode(gid, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拼英模糊查询的关键方法
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="arrFilterField"></param>
|
||||
private void FilterLookup(object sender, string[] arrFilterField)
|
||||
{
|
||||
GridLookUpEdit edit = sender as GridLookUpEdit;
|
||||
GridView gridView = edit.Properties.View as GridView;
|
||||
FieldInfo fi = gridView.GetType().GetField("extraFilter", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
CriteriaOperator[] arrCriteriaOperator = new CriteriaOperator[arrFilterField.Length];
|
||||
for (int i = 0; i < arrFilterField.Length; i++)
|
||||
{
|
||||
arrCriteriaOperator[i] = new BinaryOperator(arrFilterField[i], "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
|
||||
}
|
||||
string filterCondition = new GroupOperator(GroupOperatorType.Or, arrCriteriaOperator).ToString();
|
||||
fi.SetValue(gridView, filterCondition);
|
||||
MethodInfo mi = gridView.GetType().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
mi.Invoke(gridView, null);
|
||||
}
|
||||
/// <summary>
|
||||
/// 回车触发事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void textBox_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
bool isnull = false;
|
||||
GridLookUpEdit gu=sender as GridLookUpEdit;
|
||||
if (e.KeyChar == (char)Keys.Enter)
|
||||
{
|
||||
|
||||
if (string.IsNullOrWhiteSpace(gu.Text))
|
||||
{
|
||||
isnull = true;
|
||||
bindTextCode(gid, isnull);
|
||||
}
|
||||
else {
|
||||
SendKeys.Send("{tab}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GridLookUpEdit1_ProcessNewValue(object sender, ProcessNewValueEventArgs e)
|
||||
{
|
||||
GridLookUpEdit GU = sender as GridLookUpEdit;
|
||||
DataRow dr = ((DataTable)GU.Properties.DataSource).NewRow();
|
||||
dr["cdise"] = e.DisplayValue.ToString();
|
||||
((DataTable)GU.Properties.DataSource).Rows.Add(dr);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
//private void GridLookUpEdit1_Enter(object sender, EventArgs e)
|
||||
//{
|
||||
// binddb();
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user