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 UniMarc
{
    public partial class Check_ISBN_ItemEdit : Form
    {
        private IsbnGridItem _item;

        public Check_ISBN_ItemEdit(IsbnGridItem item)
        {
            InitializeComponent();
            _item = item;
        }

        private void Check_ISBN_ItemEdit_Load(object sender, EventArgs e)
        {
            if (_item == null)
            {
                UTIL.MsgE("데이터가 없습니다.");
                this.Close();
                return;
            }

            tb_ISBN.Text = _item.isbn;
            tb_BookName.Text = _item.book_name;
            tb_SearchBookName.Text = _item.search_book_name;
            tb_Author.Text = _item.author;
            tb_SearchAuthor.Text = _item.search_author;
            tb_BookComp.Text = _item.book_comp;
            tb_SearchBookComp.Text = _item.search_book_comp;
            tb_Unit.Text = _item.unit;
            tb_Price.Text = _item.price;
            tb_Etc.Text = _item.etc;
            tb_PubDate.Text = _item.pubDate;
            tb_Category.Text = _item.category;
            tb_SoldOut.Text = _item.sold_out;
        }

        private void btSave_Click(object sender, EventArgs e)
        {
            _item.isbn = tb_ISBN.Text;
            _item.book_name = tb_BookName.Text;
            _item.search_book_name = tb_SearchBookName.Text;
            _item.author = tb_Author.Text;
            _item.search_author = tb_SearchAuthor.Text;
            _item.book_comp = tb_BookComp.Text;
            _item.search_book_comp = tb_SearchBookComp.Text;
            _item.unit = tb_Unit.Text;
            _item.price = tb_Price.Text;
            _item.etc = tb_Etc.Text;
            _item.pubDate = tb_PubDate.Text;
            _item.category = tb_Category.Text;
            _item.sold_out = tb_SoldOut.Text;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

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