using AR;
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 fSelectResult : Form
	{
		public DataSet1.K4EE_Component_Reel_ResultRow SelectedValue = null;
		public fSelectResult(DataSet1.K4EE_Component_Reel_ResultDataTable list)
		{
			InitializeComponent();
			this.lv1.Items.Clear();
			foreach (DataSet1.K4EE_Component_Reel_ResultRow item in list)
			{
				var dt = (DateTime)item.wdate;
				var lv = this.lv1.Items.Add(dt.ToString("dd HH:mm:ss"));
				var std = new StdLabelPrint.CAmkorSTDBarcode(item.QR);
				lv.SubItems.Add(item.SID);
				lv.SubItems.Add(item.RID);
				var custcode = item.RID.Substring(2, 4);
				lv.SubItems.Add(custcode);
				lv.SubItems.Add(std.VLOT);
				lv.SubItems.Add(item.VNAME);
				lv.SubItems.Add(item.QTY.ToString());
				lv.Tag = item;
			}

			this.KeyDown += FSelectDataList_KeyDown;
		}

		private void FSelectDataList_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape) this.Close();
		}

		private void fSelectDataList_Load(object sender, EventArgs e)
		{

		}

		private void button1_Click(object sender, EventArgs e)
		{
			if (this.lv1.FocusedItem == null)
			{
				UTIL.MsgE("Please select an item\n\nPress ESC key or close button to cancel");
				return;
			}
			this.SelectedValue = this.lv1.FocusedItem.Tag as DataSet1.K4EE_Component_Reel_ResultRow;
			this.DialogResult = DialogResult.OK;

		}
	}
}
