Esempio n. 1
0
        //数据采集触发
        private void tbCaseNumber_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (e.KeyChar == 13)
                {
                    String         result = HttpRequest.ConfirmLowerCodeRelation(QRanalyze.QRDecod(tbCaseNumber.Text.Substring(tbCaseNumber.Text.Length - 35, 35)), Session.Id);
                    RelationResult Result = JsonConvert.DeserializeObject <RelationResult>(result);
                    if (!Result.success)
                    {
                        throw new Exception(Result.message);
                    }

                    if (Datas.Add(tbCaseNumber.Text.Substring(tbCaseNumber.Text.Length - 35, 35)))
                    {
                        capsum++;
                        tbCapSum.Text = capsum.ToString();
                        DataSource.Rows.Add(capsum.ToString(), tbCaseNumber.Text.Substring(tbCaseNumber.Text.Length - 35, 35), DateTime.Now.ToString());
                    }
                    else
                    {
                        MessageBox.Show(tbCaseNumber.Text + "重复扫描");
                    }

                    //一箱数据采集完毕
                    if (Datas.Count == BaseData.CapSum)
                    {
                        DBOperation dBOperation = new DBOperation();
                        Guid        BoxId       = Guid.NewGuid();
                        dBOperation.AddBoxs(BoxId);
                        dBOperation.CreatBoxOrder(BoxId, Datas);
                        dBOperation.Dispose();
                        Datas.Clear();
                        DataSource.Clear();
                        capsum        = 0;
                        tbCapSum.Text = capsum.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally {
                tbCaseNumber.Text = "";
            }
        }