using HZH_Controls;
using HZH_Controls.Controls;
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 WinForms
{
    public partial class WorkModel : Form
    {
        public String selectValue;
        public WorkModel(string workId)
        {
            InitializeComponent();
            this.workId.Text = workId;
            ShowInfo();
        }

        private void ShowInfo()
        {
            Jpsoft.BLL.Work bllWork = new Jpsoft.BLL.Work();
            Jpsoft.Model.Work modelWork = bllWork.GetModel(this.workId.Text);
            this.oldName.Text = modelWork.name_;
            this.newName.Text = modelWork.name_;
        }

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if(String.IsNullOrEmpty(this.newName.Text))
            {
                MessageBox.Show("请填入新品种及规格！");
            }
            else
            {
                Jpsoft.BLL.Work bllWork = new Jpsoft.BLL.Work();
                Jpsoft.Model.Work modelWork = bllWork.GetModel(this.workId.Text);
                modelWork.name_ = this.newName.Text.Trim();
                bllWork.Update(modelWork);
                this.DialogResult = DialogResult.OK;
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
    }
}
