/// <summary>
        /// 绑定包装产品信息--绑定扫描箱号与产品信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (BrCodeTxt.Text.Trim().Length > 0 && NumCodeTxt.Text.Trim().Length > 0)
            {
                if (App.ProductListView.View.CanFilter && App.ProductListView.View.IsEmpty)
                {
                    BeepUP.Beep(1800, 1000);
                    MessageBox.Show("请检查当前扫描的商品是否正确");

                    return;
                }
                UpdateUIView(BrCodeTxt.Text.Trim(), NumCodeTxt.Text.Trim());
            }
            else
            {
                MessageBox.Show("请输入完整 箱标条码与商品码");
                return;
            }
        }
        /// <summary>
        /// 解散包装
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            TextBox textbox = sender as TextBox;
            string  code    = "";

            if (textbox != null)
            {
                code = textbox.Text.Trim();
            }
            else
            {
                code = Tools.ReplaceScanWord(deletetext.Text);
                if (code.Length != 12)
                {
                    deletetext.Focus();
                    BeepUP.Beep(1500, 500);
                    //BeepUP.player.PlaySync();
                    MessageBox.Show("该枚标签长度不是12位,请检查扫描的标签是否正确");
                    return;
                }
            }
            PackDataDelete packdata = new PDAServer().MarketReturn2(new PackDataDelete(code, App.UserReadonly.UserId));

            _PackDataDelete.Insert(0, packdata);
            deletetext.Text = "";

            Retextcount.Text = _PackDataDelete.GetSendStatusPackDataDelete("成功").ToString();

            if (packdata.STATUS.Contains("成功"))
            {
                Checkout_Simpl.RemoveCheckout(packdata.NUMBER);

                // Checkout_Simpl.GetSendStatusCheckout("成功");
                YSFCount       = Checkout_Simpl.GetSendStatusCheckout("成功");
                Codelable.Text = YSFCount.ToString();
            }

            //SendTaskstring = new Task<string>(() => SendDataDelete(code));
            //SendTaskstring.Start();
            //SendTaskstring.ContinueWith(TaskEndedDelete);
        }
        /// <summary>
        /// _code 箱码,numcode产品编号
        /// </summary>
        /// <param name="_code"></param>
        /// <param name="numcode"></param>
        private void UpdateUIView(string _code, string numcode)
        {
            System.Collections.IEnumerator item = App.ProductListView.View.GetEnumerator();

            item.MoveNext();

            if (PackData_Simpl.Count == int.Parse(XCounttextbox.Text.Trim()))
            {
                btnBind_Click(null, null);
                return;
            }

            if (PackData_Simpl.VerifyData(_code))
            {
                BeepUP.Beep(2000, 500);
                WringText.Content = "重复箱号";
                //MessageBox.Show("请勿重复包装");
                return;
            }
            WringText.Content = "";
            Checkin_ltjy _Checkin_ltjy = new Checkin_ltjy();

            _Checkin_ltjy.barcode = _code;
            // _Checkin_ltjy.status = ((Product)item.Current).PRODUCTNAME.Trim();
            _Checkin_ltjy.productid = ((Product)item.Current).ID.ToString().Trim();
            _Checkin_ltjy.userid    = App.UserReadonly.UserNunber;

            PackData_Simpl.Insert(0, _Checkin_ltjy);

            Tools.SerializeShared(PackData_Simpl);

            PackCountTxt.Content = PackData_Simpl.Count.ToString();

            BrCodeTxt.Text = "";
            txbBarcode     = "";
            txbCKD         = "";
        }
        /// <summary>
        /// 绑定垛号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBind_Click(object sender, RoutedEventArgs e)
        {
            if (CribTxt.Text.Trim().Length > 0 && PackData_Simpl.Count > 0)
            {
                string _code = this.CribTxt.Text.Trim();

                if (App.ListCheckin_ltjyStack.VerifyDataD(_code))
                {
                    BeepUP.Beep(2000, 500);
                    WringText.Content = "重复垛号";
                    return;
                }

                Checkin_ltjyStack _Checkin_ltjyD = new Checkin_ltjyStack();
                _Checkin_ltjyD.LISTPD_SIMPLE = new List <Checkin_ltjy>(PackData_Simpl.Count);
                _Checkin_ltjyD.CRIB          = this.CribTxt.Text.Trim();

                _Checkin_ltjyD.LISTPD_SIMPLE.AddRange(PackData_Simpl);

                App.ListCheckin_ltjyStack.Insert(0, _Checkin_ltjyD);

                PackData_Simpl.Clear();
                Tools.SerializeShared(PackData_Simpl);

                CribTxt.Text          = "";
                PackCountTxtD.Content = App.ListCheckin_ltjyStack.Count.ToString();

                SendTask = new Task <Checkin_ltjyStack>(() => SendDataServerD(_Checkin_ltjyD));
                SendTask.Start();
                SendTask.ContinueWith(TaskEndedByCatchD);
            }
            else
            {
                MessageBox.Show(CribTxt.Text.Trim().Length > 0 ? "请输入完整 箱标条码与商品码" : "请输入完整的垛号");
                return;
            }
        }
        private void ComPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort _SerialPort = sender as SerialPort;

            byte[] _buf = new byte[_SerialPort.BytesToRead];

            _SerialPort.Read(_buf, 0, _buf.Length);
            if (_buf.Length != 0)
            {
                string _Code = Encoding.UTF8.GetString(_buf);

                _Code = _Code.TrimEnd('\n');
                _Code = _Code.TrimEnd('\r');

                if (_Code.ToUpper().Contains("HTTP"))
                {
                    txbBarcode = Tools.ReplaceScanWord(_Code.ToString());

                    //string _temp = txbCKD;

                    ThreadDelegate _ThreadDelegate = delegate()
                    {
                        BrCodeTxt.Text = txbBarcode;
                        if (NumCodeTxt.Text.Trim() != "")
                        {
                            if (App.ProductListView.View.CanFilter && App.ProductListView.View.IsEmpty)
                            {
                                BeepUP.Beep(1800, 1000);
                                MessageBox.Show("请检查当前扫描的商品是否正确");
                                NumCodeTxt.Text = "";
                                return;
                            }
                        }
                        if (NumCodeTxt.Text.Length > 0 && txbBarcode.Length > 0)
                        {
                            UpdateUIView(txbBarcode, NumCodeTxt.Text);
                        }
                    };
                    this.Dispatcher.BeginInvoke(DispatcherPriority.Send, _ThreadDelegate);
                }
                else if (_Code.Length == 13 && _Code.Contains("69322758"))
                {
                    txbCKD = "";
                    txbCKD = _Code.ToString();
                    ThreadDelegate _ThreadDelegate = delegate()
                    {
                        NumCodeTxt.Text = txbCKD;
                        if (App.ProductListView.View.CanFilter && App.ProductListView.View.IsEmpty)
                        {
                            BeepUP.Beep(1800, 1000);
                            MessageBox.Show("请检查当前扫描的商品是否正确");
                            NumCodeTxt.Text = "";
                            return;
                        }
                        if (txbBarcode.Length > 0 && txbCKD.Length > 0)
                        {
                            UpdateUIView(txbBarcode, txbCKD);
                        }
                    };
                    this.Dispatcher.BeginInvoke(DispatcherPriority.Send, _ThreadDelegate);
                }
                else
                {
                    ThreadDelegate _ThreadDelegate = delegate()
                    {
                        CribTxt.Text = _Code;
                        UpdateUIView(txbBarcode, txbCKD);
                    };
                    this.Dispatcher.BeginInvoke(DispatcherPriority.Send, _ThreadDelegate);
                }
            }
            //throw new NotImplementedException();
        }