void threadhelper_WorkItemFailed(object sender, WorkItemEventArgs e)
        {
            //throw new NotImplementedException();
            MessageBox.Show(e.WorkItem.Ex.Message);
            int tag=e.WorkItem.Tag;
            if (tag == 1)
            {
                this.storerkeytxt.Clean();
                this.skutxt.Clean();
                this.desctxt.Clean();
                this.packkeytxt.Clean();

                //this.receiptkeytxt.SetFocus();
                this.asnbylinereq = null;
                this.asnskureq = null;
                this.asnskures = null;
                this.receiptLineNumbertxt.SetFocus();
            }
            if (tag == 2)
            {
                this.skutxt.SetFocus();
            }
            if (tag == 3)
            {
                this.receiptkeytxt.SetFocus();
            }
        }
        void threadhelper_WorkItemCompleted(object sender, WorkItemEventArgs e)
        {
            int tag = e.WorkItem.Tag;
            WorkItem item = e.WorkItem;
            string errormsg = item.Response.GetErrorMessage();
            if (errormsg != string.Empty)
            {
                MessageBox.Show(item.Response.GetErrorMessage());
                if (tag == 1)
                {
                    this.asnbylinereq = null;
                    this.asnskureq = null;
                    this.asnskures = null;
                    this.storerkeytxt.Clean();
                    this.skutxt.Clean();
                    this.receiptkeytxt.SetFocus();
                }
                if (tag == 2)
                {
                    this.skutxt.SetFocus();
                }
                if (tag == 3)
                {
                    if (errormsg.IndexOf("ID has already been used") >= 0)
                    {
                        this.idtxt.SetFocus();
                    }
                    else if (errormsg.IndexOf("Received Qty > Expected Qty") > 0)
                    {
                        this.qtytxt.SetFocus();
                    }
                    else
                    {
                        this.receiptkeytxt.SetFocus();
                    }
                }
                if (tag == 4)
                {
                    this.receiptkeytxt.SetFocus();
                }
                return;
            }
            if (tag == 1)
            {
                asnbylineres = e.WorkItem.Response.Deserialize<flrs1_res.Utility>();
                this.storerkeytxt.SetText(asnbylineres.UtilityHeader.StorerKey);
                this.receivelinereq.UtilityHeader.storerkey = asnbylineres.UtilityHeader.StorerKey;
                this.receivelinereq.UtilityHeader.sku = asnbylineres.UtilityHeader.Sku;
                this.receivelinereq.UtilityHeader.uom = "EA";
                //this.skutxt.SetText(asnbylineres.UtilityHeader.Sku);
                this.skutxt.Clean();
                this.desctxt.Clean();
                this.packkeytxt.Clean();
                this.idtxt.Clean();
                this.qtytxt.SetText("0");
            }
            if (tag == 2)
            {
                asnskures = e.WorkItem.Response.Deserialize<flrs2_res.Utility>();
                this.desctxt.SetText(asnskures.UtilityHeader.desc);
                this.packkeytxt.SetText(asnskures.UtilityHeader.pack);
                //this.qtytxt.SetText("");
                //this.uomtxt.SetText(asnskures.UtilityHeader.UOM);

                setLottableValue(asnskures.UtilityHeader);

                createLottableControl(asnskures.UtilityHeader);

            }
            if (tag == 3)
            {
                receivelineres = e.WorkItem.Response.Deserialize<flrs3_res.Utility>();
                string receiptkey = receivelineres.UtilityHeader.prokey;
                this.receivelinereq = new flrs3_req.Utility();

                this.receivelinereq.UtilityHeader.prokey = receivelineres.UtilityHeader.prokey;
                this.receivelinereq.UtilityHeader.receiptkey = receivelineres.UtilityHeader.prokey;
                this.receivelinereq.UtilityHeader.drid = this.dropid;
                this.asnbylinereq = null;
                this.asnbylineres = null;
                this.asnskureq = null;
                this.asnskures = null;
                this.receivelineres = null;
                this.desctxt.Clean();
                InvokeHelper.Invoke(this, "dataBinding", null);
                //MessageBox.Show("收货完成");
                this.receiptkeytxt.SetFocus();
                InvokeHelper.Invoke(this, "call_asnlist01", receiptkey);

            }
            if (tag == 4)
            {
                drid_res.Utility dridres = e.WorkItem.Response.Deserialize<drid_res.Utility>();
                this.call_NSPRFRC01E(dridres.UtilityHeader.tag, dridres.UtilityHeader.storer,dridres.UtilityHeader.Sku);

            }
            if (tag == 5)
            {
                drid_res1.Utility dridres1 = e.WorkItem.Response.Deserialize<drid_res1.Utility>();
                MessageBox.Show("载具已经提交.");
                this.receiptkeytxt.SetFocus();
            }
            if (tag == 10)
            {
                //status=9,11,15 表示收货全部完成
                asnlistres = e.WorkItem.Response.Deserialize<asnlist_res.AdvancedShipNotice>();
                if(asnlistres.AdvancedShipNoticeHeaders.Count>0){
                string status=asnlistres.AdvancedShipNoticeHeaders[0].Status;
                if (status == "9" || status == "11" || status == "15")
                {
                    MessageBox.Show("该ASN已经收货完成.");
                    this.receiptkeytxt.Clean();
                }
                else
                {
                    MessageBox.Show("该行收货完成.");
                }

                }
            }
        }
        private void receiptLineNumbertxt_LostFocus(object sender, EventArgs e)
        {
            if (this.receiptLineNumbertxt.Text == "")
            {
                this.receiptLineNumbertxt.SetFocus();
                return;
            }
            if (this.receiptLineNumbertxt.Text.Length >0 && this.receiptkeytxt.Text.Length != 10)
            {
                MessageBox.Show("ASN有误");
                this.receiptkeytxt.Focus();
                return;
            }

            if (this.receiptLineNumbertxt.Text.Length == 5 )
            {
                Regex regex = new Regex(@"\d{5}");
                if (regex.IsMatch(receiptLineNumbertxt.Text))
                {
                    int num = Convert.ToInt32(this.receiptLineNumbertxt.Text);
                    if (num > 0)
                    {
                        if (asnbylineres != null && asnbylinereq != null && asnbylinereq.UtilityHeader.receiptLineNumber == this.receiptLineNumbertxt.Text
                            && asnbylineres.UtilityHeader.ASNKey == this.receiptkeytxt.Text
                            && this.storerkeytxt.Text==asnbylineres.UtilityHeader.StorerKey)
                            return;
                        asnskureq = null;
                        asnskures = null;
                        this.call_FLGetASNByLine(this.receiptkeytxt.Text, this.receiptLineNumbertxt.Text, this.loginuser.UserName);
                    }
                    else
                    {
                        MessageBox.Show("行号有误");
                        receiptLineNumbertxt.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("行号有误");
                    receiptLineNumbertxt.Focus();
                }

            }
            else if (this.receiptLineNumbertxt.Text.Length > 0)
            {
                MessageBox.Show("行号有误");
                receiptLineNumbertxt.Focus();
            }
        }
        private void call_FLRFReceiveByLine()
        {
            string errortxt = this.Vaildate();
            if (errortxt != string.Empty)
            {
                MessageBox.Show(errortxt);
                this.focusControl.Focus();
                return;
            }
            //this.Start();
            receivelinereq.UtilityHeader.userid = this.loginuser.UserName;
            receivelinereq.UtilityHeader.drid = receivelinereq.UtilityHeader.drid.ToUpper();
            receivelinereq.UtilityHeader.prokey = receivelinereq.UtilityHeader.receiptkey;
            receivelinereq.UtilityHeader.receiptkey = "";
            if( !string.IsNullOrEmpty(receivelinereq.UtilityHeader.drid)){
                this.dropid = receivelinereq.UtilityHeader.drid;
            }

            RequestMessage receiverequest = new RequestMessage(enumRequestType.MessageProcessor,
                 enumMessageType.Utility,
                 enumRequestMethod.functionOperation, this.loginuser,
                 enumSendSysId.External,
                 receivelinereq);
            //RequestWorkItem workitem = new RequestWorkItem(receiverequest, 3);
            //threadhelper.AddWorkItem(workitem);
            ResponseMessage Response = ThreadHelper.Execute(receiverequest);
            string errormsg = Response.GetErrorMessage();
            if (errormsg != string.Empty)
            {
                MessageBox.Show(Response.GetErrorMessage());
                this.receiptLineNumbertxt.SetFocus();
                //if (errormsg.IndexOf("ID has already been used") >= 0)
                //{
                //    this.idtxt.SetFocus();
                //}
                //else if (errormsg.IndexOf("Received Qty > Expected Qty") > 0)
                //{
                //    this.qtytxt.SetFocus();
                //}
                //else
                //{
                //    this.receiptkeytxt.SetFocus();
                //}

            }
            else
            {
                receivelineres =  Response.Deserialize<flrs3_res.Utility>();
                string receiptkey = receivelineres.UtilityHeader.prokey;
                this.receivelinereq = new flrs3_req.Utility();

                this.receivelinereq.UtilityHeader.prokey = receivelineres.UtilityHeader.prokey;
                this.receivelinereq.UtilityHeader.receiptkey = receivelineres.UtilityHeader.prokey;
                this.receivelinereq.UtilityHeader.drid = this.dropid;
                this.asnbylinereq = null;
                this.asnbylineres = null;
                this.asnskureq = null;
                this.asnskures = null;
                this.receivelineres = null;
                this.desctxt.Clean();
                //InvokeHelper.Invoke(this, "dataBinding", null);
                this.storerkeytxt.Clean();
                this.skutxt.Clean();
                this.desctxt.Clean();
                this.qtytxt.Clean();
                this.loctxt.Clean();
                this.idtxt.Clean();
                this.packkeytxt.Clean();
                this.dataBinding();

                //MessageBox.Show("收货完成");
                this.receiptkeytxt.SetFocus();
                //InvokeHelper.Invoke(this, "call_asnlist01", receiptkey);
                this.call_asnlist01(receiptkey);
            }
        }
        private void call_FLGetSKUInfoByLine(flrs1_res.Utility lineres,string linenum)
        {
            //this.Start();
            asnskureq = flrs2_req.Utility.CreateByAsnSku(lineres.UtilityHeader.ASNKey, linenum, lineres.UtilityHeader.Sku, lineres.UtilityHeader.StorerKey);
            RequestMessage getskurequest = new RequestMessage(enumRequestType.MessageProcessor,
                  enumMessageType.Utility,
                  enumRequestMethod.functionOperation, this.loginuser,
                  enumSendSysId.EXceed,
                  asnskureq);
            //RequestWorkItem workitem = new RequestWorkItem(getskurequest, 2);
            //threadhelper.AddWorkItem(workitem);
            ResponseMessage Response = ThreadHelper.Execute(getskurequest);
             string errormsg = Response.GetErrorMessage();
             if (errormsg != string.Empty)
             {
                 MessageBox.Show(Response.GetErrorMessage());
                 this.skutxt.SetFocus();

             }
             else
             {
                 asnskures =  Response.Deserialize<flrs2_res.Utility>();
                 this.desctxt.SetText(asnskures.UtilityHeader.desc);
                 this.packkeytxt.SetText(asnskures.UtilityHeader.pack);
                 //this.qtytxt.SetText("");
                 //this.uomtxt.SetText(asnskures.UtilityHeader.UOM);

                 setLottableValue(asnskures.UtilityHeader);

                 createLottableControl(asnskures.UtilityHeader);
             }
        }
        private void call_FLGetASNByLine(string asn, string linenum,string username)
        {
            //this.Start();
            asnbylinereq = flrs1_req.Utility.CreateByAsnLineNum(asn, linenum, username);
            RequestMessage getasnlinenumrequest = new RequestMessage(enumRequestType.MessageProcessor,
                  enumMessageType.Utility,
                  enumRequestMethod.functionOperation, this.loginuser,
                  enumSendSysId.EXceed,
                  asnbylinereq);
            //RequestWorkItem workitem = new RequestWorkItem(getasnlinenumrequest, 1);
            //threadhelper.AddWorkItem(workitem);
            ResponseMessage Response = ThreadHelper.Execute(getasnlinenumrequest);
            string errormsg = Response.GetErrorMessage();
            if (errormsg != string.Empty)
            {
                MessageBox.Show(Response.GetErrorMessage());

                this.asnbylinereq = null;
                this.asnskureq = null;
                this.asnskures = null;
                this.storerkeytxt.Clean();
                this.skutxt.Clean();
                this.receiptkeytxt.SetFocus();
            }
            else
            {
                asnbylineres =  Response.Deserialize<flrs1_res.Utility>();
                this.storerkeytxt.SetText(asnbylineres.UtilityHeader.StorerKey);
                this.receivelinereq.UtilityHeader.storerkey = asnbylineres.UtilityHeader.StorerKey;
                this.receivelinereq.UtilityHeader.sku = asnbylineres.UtilityHeader.Sku;
                this.receivelinereq.UtilityHeader.uom = "EA";
                //this.skutxt.SetText(asnbylineres.UtilityHeader.Sku);
                this.skutxt.Clean();
                this.desctxt.Clean();
                this.packkeytxt.Clean();
                this.idtxt.Clean();
                this.qtytxt.SetText("0");
            }
        }