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 JtkManagerClient {
    public partial class OrderInfoForm : Form {
        public (string id, int number)[] Result { get; private set; }
        WeakReference<ListViewItem> lvItem;
        int pcNumber;
        public OrderInfoForm(IEnumerable<Dictionary<string, string>> orderList, int pcNumber, string paymentMethod, ListViewItem lvItem) {
            InitializeComponent();
            this.pcNumber = pcNumber;
            groupBox1.Text = $"{pcNumber}번 PC의 주문 정보";
            lblTime.Text = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            lblMethod.Text = paymentMethod;

            foreach (var item in orderList) {
                listView1.Items.Add(new ListViewItem(new string[] { item["name"], item["quantity"] }));
            }
            this.lvItem = new WeakReference<ListViewItem>(lvItem);
        }

        private void button1_Click(object sender, EventArgs e) {
            lvItem.TryGetTarget(out var item);
            if (item != null) {
                item.SubItems[1].Text = $"{pcNumber}번 PC 주문 [완료]";
            }
            Close();
        }

        private void button2_Click(object sender, EventArgs e) {
            Close();
        }


        private void OrderInfoForm_Load(object sender, EventArgs e) {

        }
    }
}
