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.
 
 

82 lines
2.3 KiB

using ButcherFactory.BO.LocalBL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinFormControl;
namespace ButcherFactory.Dialogs
{
public partial class SelectCustomerDialog : Form
{
public Tuple<string, long> Result;
public SelectCustomerDialog()
{
InitializeComponent();
InitKeyBoard();
}
void InitKeyBoard()
{
var chars = new char[][] {
new char[] { 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P' },
new char[] { 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L' },
new char[] { 'Z', 'X', 'C', 'V', 'B', 'N', 'M' } };
var panel = new FlowLayoutPanel[] { flowLayoutPanel2, flowLayoutPanel3, flowLayoutPanel4 };
var idx = 0;
foreach (var v in chars)
{
foreach (var c in v)
{
var btn = new UButton() { Width = 80, Height = 50, Text = c.ToString(), Font = new Font("宋体", 15), Margin = new Padding(10) };
btn.Click += CharClick;
panel[idx].Controls.Add(btn);
}
idx++;
}
}
void CharClick(object sender, EventArgs e)
{
textBox1.Text += ((UButton)sender).Text;
}
private void uButton1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0)
textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 1);
}
void InitCustomerBtn()
{
flowLayoutPanel1.Controls.Clear();
if (string.IsNullOrEmpty(textBox1.Text))
return;
var customers = DialogBL.GetCustomerList(textBox1.Text.ToLower());
foreach (var item in customers)
{
var btn = new UButton() { Width = 100, Height = 60, Text = item.StringExt1.ToString(), Tag = item.LongExt1, Font = new Font("宋体", 10), Margin = new Padding(12) };
btn.Click += CustomerClick;
flowLayoutPanel1.Controls.Add(btn);
}
}
void CustomerClick(object sender, EventArgs e)
{
var btn = sender as UButton;
Result = new Tuple<string, long>(btn.Text, Convert.ToInt64(btn.Tag));
DialogResult = DialogResult.OK;
this.Close();
}
private void searchBtn_Click(object sender, EventArgs e)
{
InitCustomerBtn();
}
}
}