using bizFacade;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MisDataFun
{
    public partial class OrderForm : Form
    {
        public OrderForm()
        {
            InitializeComponent();
            InitiOrder();
            InitOrderOpName();
            InitOredrToOpNameList();
        }

        private void InitiOrder()
        {
            DataTable dt;
            dt = BaseDataSystemMES.GetOrder_BQ();
            dataGridView_Order.DataSource = dt;
            if(dt.Rows.Count>0)
            {
                dataGridView_Order.Rows[0].Selected = true;
            }

        }

        private void InitOrderOpName()
        {
            DataTable dt;
            dt = BaseDataSystemMES.GetOrderOpName_BQ();
            comboBox_OpName.DataSource = dt;
            comboBox_OpName.DisplayMember = "工位号";
            if(comboBox_OpName.Items.Count > 0 )
            {
                comboBox_OpName.SelectedIndex= 0;
            }
        }
        /// <summary>
        /// 下达订单到线首工位
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_LoadToOpName_Click(object sender, EventArgs e)
        {
            string orderForm;
            string opName;
            orderForm = dataGridView_Order.SelectedRows[0].Cells["订单号"].Value.ToString();
            opName = comboBox_OpName.Text;

            BaseDataSystemMES.DownOrderToOpName(orderForm, opName);
            InitOredrToOpNameList();
        }
        /// <summary>
        /// 各个工位订单列表
        /// </summary>
        private void InitOredrToOpNameList()
        {
            DataTable dt;
            dt = BaseDataSystemMES.DownOrderToOpNameMobyList("");
            dataGridView_OrderOpNameToMobyList.DataSource= dt;
        }
    }
}
