コード例 #1
0
 private void txtAssister_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 27)
     {
         this.txtAssister.Text    = "";
         this.txtAssister.Enabled = false;
         //this.txtslid.Enabled = true;
         //this.txtslid.Text = "";
         //this.txtslid.Focus();
         this.labmaterialname.Text = "物料描述";
         this.labneedqty.Text      = "";
         this.labSlname.Text       = "";
         this.cbxrr.Enabled        = true;
         this.txtAssister.Enabled  = false;
         this.cbxrr.Focus();
         //this.cbxrr.Enabled = true;
         //this.cbxrr.Focus();
         return;
     }
     if (e.KeyChar != 13)
     {
         return;
     }
     if (this.txtAssister.Text == "")
     {
         ma = null;
         this.txtAssister.Enabled = false;
         this.txttraycode.Enabled = true;
         this.txttraycode.Focus();
         return;
     }
     try
     {
         string x = HttpHelper.HttpPost("getAssisterInfo", @"lcCode=" + Comm.lcCode + "&assisterCode=" + this.txtAssister.Text);
         msg = (Model.Mmsg)JsonConvert.DeserializeObject(x, typeof(Model.Mmsg));
         if (msg == null)
         {
             throw new Exception("错误信息捕捉失败");
         }
         if (!msg.success)
         {
             throw new Exception(msg.msg);
         }
         ma = (Model.MAssisterInfo)JsonConvert.DeserializeObject(x, typeof(Model.MAssisterInfo));
         if (ma == null)
         {
             throw new Exception("getAssisterInfo捕捉失败");
         }
         this.txtAssister.Text = ma.data.name;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         this.txtAssister.SelectAll();
         return;
     }
     this.txtAssister.Enabled = false;
     this.txttraycode.Enabled = true;
     this.txttraycode.Focus();
 }
コード例 #2
0
        private void txtAssister_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 27)
            {
                this.labinfo.Text = "";

                this.txtAssister.Enabled = false;
                this.txtAssister.Text    = "";
                this.cmbunit.Enabled     = true;
                this.cmbunit.Focus();

                return;
            }
            if (e.KeyChar != 13)
            {
                return;
            }
            if (this.txtAssister.Text == "")
            {
                return;
            }
            try
            {
                string x = HttpHelper.HttpPost("getAssisterInfo", @"lcCode=" + Comm.lcCode + "&assisterCode=" + this.txtAssister.Text);
                msg = (Model.Mmsg)JsonConvert.DeserializeObject(x, typeof(Model.Mmsg));
                if (msg == null)
                {
                    throw new Exception("错误信息捕捉失败");
                }
                if (!msg.success)
                {
                    throw new Exception(msg.msg);
                }
                ma = (Model.MAssisterInfo)JsonConvert.DeserializeObject(x, typeof(Model.MAssisterInfo));
                if (ma == null)
                {
                    throw new Exception("getAssisterInfo捕捉失败");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.txtAssister.SelectAll();
                return;
            }
            //if()
            bool badd = true;

            foreach (Model.Assisters v in malist.data)
            {
                if (v.code == ma.data.code)
                {
                    malist.data.Remove(v);
                    badd = false;
                    break;
                }
            }
            if (badd)
            {
                malist.data.Add(ma.data);
            }
            ShowInfo();
            this.txtAssister.Text = "";
        }