public FrmMaterialAdd() { InitializeComponent(); dgvOrderlist.SelectionChanged -= dgvOrderlist_SelectionChanged; SetUserControl(Program.objCurrentUser.UserId); //领料界面 this.dgvOrderlist.AutoGenerateColumns = false; this.dgvOrderlist.DataSource = _dgvBindingSource; MultiThreadingLoadOrderData(); //获取今日完成数量 var unitOfWork = new UnitOfWork(); var datFinishedService = new DayFinishedService(unitOfWork, unitOfWork.DayFinishedRepository); this.DayCollectionCount.Text = datFinishedService.GetTodayFinishedInfo(DateTime.Now).CollectionCount.ToString(); }
/// <summary> /// 领取物料 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMaterialCollection_Click(object sender, EventArgs e) { if (this.dgvOrderlist.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 collectionNumber = Convert.ToInt32(this.txtboxMaterialNumber.Text.Trim()); var dgvRow = this.dgvOrderlist.CurrentRow; if (dgvRow == null) { return; } var order = (dgvRow.DataBoundItem as OrderPlacing); //获取Id var orderId = order.OrderId; var onlineCount = order.OnLineQuantity; //当前已经领取数量 var hasCount = Convert.ToInt32(this.lbMaterialCount.Text); //现在领取后的数量大于 订单计划做的数量 不允许 if (onlineCount < (hasCount + collectionNumber)) { MessageBox.Show("领取物料后的数量 怎么能大于下单数量呢?请核对"); return; } try { var unitOfWork = new UnitOfWork(); var collectionService = new CollectionService(unitOfWork, unitOfWork.CollectionRepository, unitOfWork.OrderRepository, unitOfWork.DayFinishedRepository); collectionService.MaterialCollection(orderId, collectionNumber); this.lbMaterialCount.Text = (hasCount + collectionNumber).ToString(); var datFinishedService = new DayFinishedService(unitOfWork, unitOfWork.DayFinishedRepository); this.DayCollectionCount.Text = datFinishedService.GetTodayFinishedInfo(DateTime.Now).CollectionCount.ToString(); (this.dgvOrderlist.CurrentRow.DataBoundItem as OrderPlacing).OrderCollectionCount = (hasCount + collectionNumber); _dgvBindingSource.ResetBindings(true); txtboxMaterialNumber.Text = ""; } catch (Exception ex) { MessageBox.Show("异常:" + ex.Message); } }