using MesWorkMqtt;
using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.Receiving;

using bizFacade;
using MesWorkMqtt;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MQTTnet;
using System.Threading;
using DoWhatPlc;
using MesServerWork;

namespace SyUpLoad
{
    public partial class PartLoad
    {
        private void button_barcode_Click(object sender, EventArgs e)
        {
            string opName;
            string kuweiNum;
            string barCode;
            string orderForm;
            string engineID;
            string engineType;
            int engineTypeID;
            opName = OPName01;
            barCode = textBox_barcode.Text.Replace("\r\n", "");
            kuweiNum = Get_kuweiNum();
            if (kuweiNum == "0") return;

            CreateEngineID(opName, out engineType, out engineTypeID, out engineID, out orderForm);
            if(engineID.Length<1)
            {
                MessageBox.Show("入库失败");
                return;
            }
            BaseDataSystemMES.GetUpLoadBarCode_Update(opName, kuweiNum, barCode, orderForm,
     engineID, engineType, engineTypeID);

            BaseDataSystemMES.GetUpLoadBarCode(OPName01, out DataTable dt_OPName01);
            dataGridView_OPA1001.DataSource = dt_OPName01;

        }

        private string Get_kuweiNum()
        {
            string kuweiNum = "0";

            if (radioButton1.Checked)
            {
                kuweiNum = "1";
            }
            else if (radioButton2.Checked)
            {
                kuweiNum = "2";

            }
            else if (radioButton3.Checked)
            {
                kuweiNum = "3";

            }
            else if (radioButton4.Checked)
            {
                kuweiNum = "4";

            }
            else if (radioButton5.Checked)
            {
                kuweiNum = "5";

            }
            else if (radioButton6.Checked)
            {
                kuweiNum = "6";

            }

            return kuweiNum;
        }

    }
}
