天肉客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

81 lines
1.8 KiB

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using BLUtil;
namespace BWPClientForTianRou {
public partial class SelectGoodsForm : Form {
private bool _isStore = false;
public SelectGoodsForm(bool isStore)
: this() {
if (isStore)
Text = "选择仓库";
_isStore = isStore;
}
public SelectGoodsForm() {
InitializeComponent();
listView1.Columns[1].Width = 800;
listView1.Columns[2].Width = 300;
}
private void SelectGoodsForm_Load(object sender, EventArgs e) {
Query();
}
private void btnQuery_Click(object sender, EventArgs e)
{
Query();
}
private void Query()
{
var searchKey = textBoxSearch.Text.Trim();
List<BaseInforObj> list;
if (_isStore)
{
list = DbUtil.SelectStore(searchKey);
}
else
{
list = DbUtil.SelectGoods(searchKey);
}
listView1.BeginUpdate();
listView1.Items.Clear();
foreach (var detail in list)
{
AddItem(detail);
}
listView1.EndUpdate();
listView1.Focus();
}
private void AddItem(BaseInforObj goods) {
var item = new ListViewItem(goods.ID.ToString());
item.Tag = goods;
item.SubItems.Add(goods.Name);
item.SubItems.Add(goods.Code);
listView1.Items.Add(item);
}
private void button1_Click(object sender, EventArgs e) {
textBoxSearch.Text = "";
listView1.BeginUpdate();
listView1.Items.Clear();
listView1.EndUpdate();
}
private void listView1_ItemActivate(object sender, EventArgs e) {
DbUtil.DialogReturnValue = listView1.FocusedItem.Tag;
DialogResult = DialogResult.OK;
Close();
}
}
}