예제 #1
0
        //扫描箱码
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (e.KeyChar == 13)
                {
                    String result = HttpRequest.GetTemplates(QRanalyze.QRDecod(textBox1.Text.Substring(textBox1.Text.Length - 35, 35)), Session.Id);

                    TemplateResult Result = JsonConvert.DeserializeObject <TemplateResult>(result);

                    if (Result.success)
                    {
                        hashtable.Clear();
                        comboBox.Items.Clear();
                        foreach (UnitTemp unitTemp in Result.data.unitTemps)
                        {
                            foreach (TempDel Temp in unitTemp.tempDels)
                            {
                                comboBox.Items.Add(Temp.id);
                                hashtable.Add(Temp.id, Temp);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally {
                textBox1.Text = "";
            }
        }
예제 #2
0
        private void UpData(String boxGUID, QRBean boxBean)
        {
            DBOperation dBOperation = new DBOperation();

            try
            {
                if (tbBoxID.Text == "")
                {
                    throw new Exception("请先选择未上传的箱子的ID");
                }

                DataSet dataSet = dBOperation.GetUploadCase(boxGUID);

                UploadData uploadData = new UploadData();
                uploadData.tempDelId  = BaseData.TempId;
                uploadData.parentCode = boxBean;

                foreach (DataRow Row in dataSet.Tables[0].Rows)
                {
                    uploadData.childCodes.Add(QRanalyze.QRDecod(Row["FCapData"].ToString()));
                }

                String result = HttpRequest.UploadCapData(uploadData, Session.Id);

                RelationResult Result = JsonConvert.DeserializeObject <RelationResult>(result);
                if (Result.success)
                {
                    dBOperation.UploadBoxTStatus(boxGUID);

                    tbBoxID.Text  = "";
                    tbBoxTag.Text = "";
                    boxGUID       = "";

                    dgBox.DataSource = dBOperation.QueryNoUplaodBox().Tables[0];

                    dgBox.Columns["ID"].HeaderText    = "未上传箱号ID";
                    dgBox.Columns["ID"].Width         = 300;
                    dgBox.Columns["FGuid"].HeaderText = "GUID编码";
                    dgBox.Columns["FGuid"].Width      = 300;
                }
                else
                {
                    throw new Exception(Result.message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally {
                dBOperation.Dispose();
            }
        }
예제 #3
0
 //验证上级码值是否关联
 private void button5_Click(object sender, EventArgs e)
 {
     try
     {
         String result = HttpRequest.ConfirmSuperCodeRelation(QRanalyze.QRDecod(txtSupercode.Text), Session.Id);
         //TemplateInfoResult templateInfoResult = JsonConvert.DeserializeObject<TemplateInfoResult>(result);
         Console.WriteLine(result);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #4
0
        //关联模板集合
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                String result = HttpRequest.GetTemplates(QRanalyze.QRDecod(txtTemplates.Text), Session.Id);

                TemplateResult TemplateResult = JsonConvert.DeserializeObject <TemplateResult>(result);

                Console.WriteLine(result);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
예제 #5
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 = "";
            }
        }
예제 #6
0
 private void tbBoxTag_KeyPress(object sender, KeyPressEventArgs e)
 {
     try
     {
         if (e.KeyChar == 13)
         {
             String         result = HttpRequest.ConfirmSuperCodeRelation(QRanalyze.QRDecod(tbBoxTag.Text.Substring(tbBoxTag.Text.Length - 35, 35)), Session.Id);
             RelationResult Result = JsonConvert.DeserializeObject <RelationResult>(result);
             if (Result.success)
             {
                 AccessDB.UpDataOne(tbBoxTag.Text);
             }
             else
             {
                 throw new Exception(Result.message);
             }
         }
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }
예제 #7
0
        /// <summary>
        /// 上传一个箱号
        /// </summary>
        /// <param name="boxId">箱号</param>
        /// <returns></returns>
        public static String UpDataOne(String BoxNum)
        {
            QRBean           BoxNumber   = QRanalyze.QRDecod(BoxNum.Substring(BoxNum.Length - 35, 35));
            OleDbConnection  connection  = GetConnectionOne(AccessDbHelp.GetConnectString());
            OleDbTransaction transaction = connection.BeginTransaction();

            try
            {
                //找出最小未装箱的最小箱号
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection  = connection;
                cmd.Transaction = transaction;
                String sqlBox = String.Format("SELECT FGuid from BOX where ID = (select min(ID) from BOX Where FStatus = '{0}')", BoxStatusNoUp);
                cmd.CommandText = sqlBox;
                Object boxGuid = cmd.ExecuteScalar();
                String BoxGuid;
                if (boxGuid == null)
                {
                    throw new Exception("没有可以使用箱");
                }
                else
                {
                    BoxGuid = boxGuid.ToString();
                }

                //生成装箱上传数据
                DataSet          dataSet = new DataSet();
                String           sql_box = String.Format("select [FCapData] from [Case] where [FBoxId] = '{0}'", BoxGuid);
                OleDbDataAdapter da      = new OleDbDataAdapter(sql_box, connection);
                da.SelectCommand.Transaction = transaction;
                da.Fill(dataSet);

                UploadData uploadData = new UploadData();
                uploadData.tempDelId  = BaseData.TempId;
                uploadData.parentCode = BoxNumber;

                foreach (DataRow Row in dataSet.Tables[0].Rows)
                {
                    String msg = Row["FCapData"].ToString();
                    uploadData.childCodes.Add(QRanalyze.QRDecod(msg.Substring(msg.Length - 35, 35)));
                }

                RelationResult result = JsonConvert.DeserializeObject <RelationResult>(HttpRequest.UploadCapData(uploadData, Session.Id));
                //RelationResult result = new RelationResult();
                //result.success = true;
                if (result.success)
                {
                    String sqlUp = String.Format("Update [Box] set [FStatus] = '{0}',[FBoxNumber] = '{1}' where [FGuid]  = '{2}'", BoxStatusHaveUp, BoxNum, BoxGuid);
                    cmd.CommandText = sqlUp;
                    cmd.ExecuteNonQuery();
                }
                else
                {
                    throw new Exception(result.message);
                }
                transaction.Commit();
                return(BoxGuid);
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                throw ex;
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }