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;

namespace Project.Dialog
{
	public partial class fSelectCustInfo : Form
	{
		public string CustCode, CustName;
		public fSelectCustInfo()
		{
			InitializeComponent();
		}

		private void fSelectCustInfo_Load(object sender, EventArgs e)
		{
			this.Show();
			Application.DoEvents();

			var db = new EEEntities();
			var list = db.vCustomerList.OrderBy(t => t.CustName).ToList(); // (t => t.manu).ToList();
			this.listView1.Items.Clear();
			foreach(var item in list)
			{
				var lv = this.listView1.Items.Add(item.CustCode);
				lv.SubItems.Add(item.CustName);
			}
		}

		private void btOK_Click(object sender, EventArgs e)
		{
			if (this.listView1.FocusedItem == null)
				return;

			this.CustCode = this.listView1.FocusedItem.SubItems[0].Text;
			this.CustName = this.listView1.FocusedItem.SubItems[1].Text;
			DialogResult = DialogResult.OK;
		}
	}
}
