89 lines
2.9 KiB
C#
89 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using GZTW.AyaNova.BLL;
|
|
|
|
namespace AyaNovaOL
|
|
{
|
|
public partial class SearchForAyaNovaItem : Form
|
|
{
|
|
|
|
|
|
private RootObjectTypes mRootObjectType;
|
|
public SearchForAyaNovaItem(string sEmailText, RootObjectTypes rootObjectType)
|
|
{
|
|
InitializeComponent();
|
|
if (!string.IsNullOrEmpty(sEmailText))
|
|
edEmail.Text = sEmailText;
|
|
mRootObjectType = rootObjectType;
|
|
edEmail.SelectionStart = 0;
|
|
edEmail.SelectionLength = 0;
|
|
}
|
|
|
|
private void edEmail_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
if (edEmail.SelectionLength > 0)
|
|
edSearchText.Text = edEmail.SelectedText.Trim().Replace("\r\n", " ");
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
Dictionary<Guid, string> dictItemList { get; set; }
|
|
private void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
if (dictItemList == null)
|
|
{
|
|
dictItemList = new Dictionary<Guid, string>();
|
|
}
|
|
else
|
|
dictItemList.Clear();
|
|
|
|
cbItems.DataSource = null;
|
|
if (!string.IsNullOrEmpty(edSearchText.Text))
|
|
{
|
|
SearchResultList srl = SearchResultList.GetPickListForObjectType(edSearchText.Text, mRootObjectType);
|
|
if (srl.ListPickListID.Count != 0)
|
|
{
|
|
foreach (Guid g in srl.ListPickListID)
|
|
{
|
|
dictItemList.Add(g, NameFetcher.GetItem(new TypeAndID(mRootObjectType, g)).RecordName);
|
|
}
|
|
|
|
cbItems.DataSource = new BindingSource(dictItemList, "");
|
|
cbItems.ValueMember = "Key";
|
|
cbItems.DisplayMember = "Value";
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
|
|
public Guid SelectedItemID { get; set; }
|
|
private void cbItems_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (cbItems.DataSource != null && cbItems.SelectedItem!=null)
|
|
{
|
|
// MessageBox.Show(((KeyValuePair<Guid, string>)cbItems.SelectedItem).Value);
|
|
SelectedItemID = ((KeyValuePair<Guid, string>)cbItems.SelectedItem).Key;
|
|
btnOK.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btnOK.Enabled = false;
|
|
}
|
|
}
|
|
}
|
|
}
|