Beispiel #1
0
        public void AddtransitItem(orderSorte obj)
        {
            List <string> idStr = new List <string>();
            string        sql1  = "insert into ZC_ORDERS_SORTE (id, CREATETIME, UPDATETIME, ADDRESS, GOODS_ID, GOODS_NAME, ORDERSNUM, SORTENUM, WEIGHT, sorteId) values "
                                  + " (:id ,:createTime, :updateTime, :ADDRESS , :GOODS_ID, :GOODS_NAME, :ORDERSNUM, :SORTENUM , :weight, :sorteId)";
            OracleConnection  conn = null;
            OracleCommand     cmd  = new OracleCommand();
            OracleTransaction tran = null;

            try
            {
                conn = OracleUtil.OpenConn();
                tran = conn.BeginTransaction();

                cmd.Connection  = conn;
                cmd.CommandText = sql1;
                cmd.Parameters.Add(":id", obj.id);
                cmd.Parameters.Add(":createTime", obj.createTime);
                cmd.Parameters.Add(":updateTime", obj.updateTime);
                cmd.Parameters.Add(":ADDRESS", obj.address);
                cmd.Parameters.Add(":GOODS_ID", obj.goods_id);
                cmd.Parameters.Add(":GOODS_NAME", obj.goods_name);
                cmd.Parameters.Add(":ORDERSNUM", obj.orderNum);
                cmd.Parameters.Add(":SORTENUM", obj.sorteNum);
                cmd.Parameters.Add(":weight", obj.weight);
                cmd.Parameters.Add(":sorteId", ConstantUtil.sorte_id);
                cmd.ExecuteNonQuery();
                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                Console.WriteLine(ex.Message);
            }
            finally
            {
                cmd.Dispose();
                OracleUtil.CloseConn(conn);
            }
        }
Beispiel #2
0
        //扫码
        private void AddGoods()
        {
            SpeechVoiceSpeakFlags speakflag = SpeechVoiceSpeakFlags.SVSFlagsAsync;
            SpVoice voice = new SpVoice();
            string  num   = numberTextBox.Text;

            ///18位条码和13位条码混合
            if (string.IsNullOrEmpty(num) || (num.Length != 13 && num.Length != 18))
            {
                voice.Speak("错误", speakflag);
                MessageBox.Show("请确认扫码的条码是否正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                numberTextBox.Text = "";
                return;
            }
            ///以后的13的条码
            //if(string.IsNullOrEmpty(num) || num.Length != 13)
            //{
            //    MessageBox.Show("请确认扫码的条码是否正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    numberTextBox.Text = "";
            //    return;
            //}
            ///扫码扫出来的结果
            string serialNumber = "";
            float  weigth       = 0;

            if (num.StartsWith("28"))
            {
                ///13位的条码
                //serialNumber = num.Substring(2, 5);
                //string weightString = num.Substring(7, 5);
                //weigth = float.Parse(weightString.Insert(2, "."));

                ///18位的条码和13位码都有
                if (num.Length == 18)
                {
                    serialNumber = num.Substring(2, 5);
                    string weightString = num.Substring(12, 5);
                    weigth = float.Parse(weightString.Insert(2, "."));
                }
                else     //肉类的13位码
                {
                    serialNumber = num.Substring(2, 5);
                    string weightString = num.Substring(7, 5);
                    weigth = float.Parse(weightString.Insert(2, "."));
                }
            }
            else
            {
                serialNumber = num;
            }

            DataSet ds   = (DataSet)this.goodDataGridView.DataSource;
            bool    flag = false;

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string serialNum = this.goodDataGridView[0, i].Value == null ? "" : this.goodDataGridView[0, i].Value.ToString();
                if (serialNum.Equals(serialNumber))
                {
                    string nums      = this.goodDataGridView[4, i].Value == null || "".Equals(this.goodDataGridView[4, i].Value) ? "0" : this.goodDataGridView[4, i].Value.ToString();
                    string orderNums = this.goodDataGridView[3, i].Value.ToString();

                    flag = true;
                    ///start 减去判断
                    if ((string.IsNullOrEmpty(nums) || "0".Equals(nums)) && !calFlag)
                    {
                        voice.Speak("错误", speakflag);
                        MessageBox.Show("此商品份数为0无法进行减去操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        numberTextBox.Text   = "";
                        calFlag              = true;
                        calculateButton.Text = "加(F1)";
                        return;
                    }
                    else
                    {
                        orderSorte orderSorte = new orderSorte();
                        orderSorte.createTime = DateTime.Now;
                        orderSorte.updateTime = DateTime.Now;
                        orderSorte.address    = ConstantUtil.street;
                        orderSorte.goods_id   = this.goodDataGridView.Rows[i].Cells[5].Value == null ? "" : this.goodDataGridView.Rows[i].Cells[5].Value.ToString();
                        orderSorte.id         = Guid.NewGuid().ToString();
                        orderSorte.goods_name = this.goodDataGridView.Rows[i].Cells[2].Value == null ? "" : this.goodDataGridView.Rows[i].Cells[2].Value.ToString();
                        //订单份数
                        orderSorte.orderNum = this.goodDataGridView.Rows[i].Cells[3].Value == null ? "" : this.goodDataGridView.Rows[i].Cells[3].Value.ToString();

                        orderSorte.weight = weigth.ToString();
                        sorteDao sortedao = new sorteDao();
                        if (calFlag)
                        {
                            orderSorte.sorteNum = "1";
                            sortedao.AddtransitItem(orderSorte);
                        }
                        else
                        {
                            List <string> list = sortedao.FindBy(orderSorte.goods_id, weigth.ToString(), ConstantUtil.street);
                            if (list.Count == 0)
                            {
                                voice.Speak("错误", speakflag);
                                MessageBox.Show("没有此商品对应得分拣记录,无需进行减去操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                numberTextBox.Text = "";
                                return;
                            }
                            sortedao.DeleteBy(list[0]);
                            calFlag = true;
                            calculateButton.Text = "加(F1)";
                        }
                    }
                    numberTextBox.Text = "";
                }
                else
                {
                }
            }
            if (!flag)
            {
                voice.Speak("错误", speakflag);
                MessageBox.Show("没有此商品,请确认商品或者货号是否正确", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                numberTextBox.Text = "";
                return;
            }
        }