#region
|
|
using System;
|
using System.Data;
|
using System.Drawing;
|
using CSFrameworkV5.Common;
|
using CSFrameworkV5.Interfaces;
|
using CSFrameworkV5.Library.CommonClass;
|
using DevExpress.XtraEditors;
|
|
#endregion
|
|
namespace CSFrameworkV5.Library
|
{
|
/// <summary>
|
/// 通用模糊查询选择窗体
|
/// </summary>
|
public partial class frmFuzzySearch : frmBaseDialog
|
{
|
//打开查询窗体的业务逻辑层
|
private IFuzzySearchSupportable _BLL;
|
|
private DataRow _ReturnRow; //返回一条记录.
|
|
//私有构造器
|
private frmFuzzySearch()
|
{
|
InitializeComponent();
|
}
|
|
/// <summary>
|
/// 取消
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnCancel_Click(object sender, EventArgs e)
|
{
|
Close();
|
}
|
|
/// <summary>
|
/// 关闭窗体返回当前选择的记录
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnOk_Click(object sender, EventArgs e)
|
{
|
try
|
{
|
if (gvSummary.FocusedRowHandle < 0) return;
|
|
//返回当前选择的记录.
|
_ReturnRow = gvSummary.GetDataRow(gvSummary.FocusedRowHandle);
|
|
Close();
|
}
|
catch (Exception ex)
|
{
|
Msg.ShowException(ex);
|
}
|
}
|
|
/// <summary>
|
/// 搜索查询
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnQuery_Click(object sender, EventArgs e)
|
{
|
DoQuery(txtValue.Text);
|
}
|
|
/// <summary>
|
/// 执行查询
|
/// </summary>
|
/// <param name="content">查询的内容</param>
|
private void DoQuery(string content)
|
{
|
if (_BLL == null) throw new CustomException("没有指定业务层,无法执行查询!");
|
|
try
|
{
|
frmWaitingEx.ShowMe(this);
|
btnQuery.Enabled = false;
|
var dt = _BLL.FuzzySearch(content);
|
gvSummary.GridControl.DataSource = dt;
|
}
|
finally
|
{
|
btnQuery.Enabled = true;
|
frmWaitingEx.HideMe(this);
|
}
|
}
|
|
/// <summary>
|
/// 打开查询窗体
|
/// </summary>
|
/// <param name="Sender">事件发起人</param>
|
/// <param name="callBack">回调函数,当选择一个条记录后关闭窗体时调用</param>
|
public static void Execute(ButtonEdit Sender,
|
IFuzzySearchSupportable BLL, SearchCallBack callBack)
|
{
|
var form = new frmFuzzySearch();
|
form._BLL = BLL;
|
form.txtValue.Text = Sender.Text;
|
form.DoQuery(form.txtValue.Text);
|
form.ShowDialog();
|
if (callBack != null) callBack(form._ReturnRow);
|
}
|
|
/// <summary>
|
/// 打开产品资料查询窗体.
|
/// </summary>
|
/// <returns></returns>
|
public static DataRow Execute(IFuzzySearchSupportable BLL)
|
{
|
var form = new frmFuzzySearch();
|
form._BLL = BLL;
|
form.ShowDialog();
|
return form._ReturnRow;
|
}
|
|
private void frmFuzzySearch_Load(object sender, EventArgs e)
|
{
|
btnOk.Location = new Point(331, 10);
|
btnCancel.Location = new Point(440, 10);
|
}
|
|
/// <summary>
|
/// 双击按钮关闭查询窗体并返回结果
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void gvSummary_DoubleClick(object sender, EventArgs e)
|
{
|
if (gvSummary.RowCount > 0) btnOk.PerformClick();
|
}
|
}
|
}
|