Beispiel #1
0
        /// <summary>
        /// 领取物料
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMateriaCollection_Click(object sender, EventArgs e)
        {
            if (this.OrderGridView.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选中一个订单,再进行物料领取!");
                return;
            }


            if (this.txtboxMaterialNumber.Text.Length == 0)
            {
                MessageBox.Show("请输入领取物料数量,别瞎几把乱搞!!");
                return;
            }
            if (!RegexHelper.regExpNumber.IsMatch(this.txtboxMaterialNumber.Text))
            {
                MessageBox.Show("物料数量是数字,长点心 ok?");
                return;
            }
            var number = Convert.ToInt32(this.txtboxMaterialNumber.Text.Trim());

            using (_dbcontext = new FlowManageSystemEntities())
            {
                collectionRepository = new CollectionRepository(_dbcontext);

                var order = (this.OrderGridView.CurrentRow.DataBoundItem as OrderPlacing);
                //获取Id
                var id          = order.OrderId;
                var onlineCount = order.OnLineQuantity;

                //当前已经领取数量
                var hasCount = Convert.ToInt32(this.lbMaterialCount.Text);

                //现在领取后的数量大于 订单计划做的数量 不允许
                if (onlineCount < (hasCount + number))
                {
                    MessageBox.Show("领取物料后的数量 怎么能大于下单数量呢?请核对");
                    return;
                }

                try
                {
                    collectionRepository.AddCollection(id, number);
                    collectionRepository.SaveChanges();
                    this.lbMaterialCount.Text = (hasCount + number).ToString();
                    txtboxMaterialNumber.Text = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show("异常:" + ex.Message);
                }
            }
        }