public ConfirmQuantityFm(PLC plc, SerialPortManager spManager, ConfirmQuantityDTO sourceModel, bool canEditQuantity) { _sourceModel = sourceModel; _plc = plc; _spManager = spManager; _canEditQuantity = canEditQuantity; _maxQuantity = sourceModel.Quantity; quantityBS.DataSource = _sourceModel; InitializeComponent(); articleLbl.Text = _sourceModel.Article; materialLbl.Text = _sourceModel.MaterialName; unitLocalNameLbl.Text = _sourceModel.UnitLocalName; maxQuantityLbl.Text = _sourceModel.Quantity.ToString(); quantityEdit.DataBindings.Add("EditValue", quantityBS, "Quantity", true, DataSourceUpdateMode.OnPropertyChanged); currentWeightTBox.DataBindings.Add("EditValue", quantityBS, "CurrentWeight", true, DataSourceUpdateMode.OnPropertyChanged); oldWeightTBox.DataBindings.Add("EditValue", quantityBS, "OldWeight", true, DataSourceUpdateMode.OnPropertyChanged); quantityEdit.ReadOnly = (canEditQuantity) ? false : true; ConditionValidationRule rule = new ConditionValidationRule(); rule.ConditionOperator = ConditionOperator.Between; rule.ErrorText = "Введенное количество превышает доступное, либо равно 0"; rule.ErrorType = ErrorType.Critical; rule.Value1 = 0.01m; rule.Value2 = _maxQuantity; confirmValidationProvider.SetValidationRule(quantityEdit, rule); StartTimer(); }
private bool TakeKeeping(KeepingMaterialsDTO model) { receiptsService = Program.kernel.Get <IReceiptsService>(); receiptAcceptancesService = Program.kernel.Get <IReceiptAcceptancesService>(); ordersService = Program.kernel.Get <IOrdersService>(); keepingsService = Program.kernel.Get <IKeepingsService>(); expendituresService = Program.kernel.Get <IExpendituresService>(); int wareHouseId = model.WareHouseId; if (wareHouseId > 0) { firstWindDefaultCell = wareHouseId; if ((int)barEditItem1.EditValue == 0) { if (cellPresenceList == null) { cellPresenceList = wareHousesService.GetCellPresence(wareHouseId).ToList(); } keepingsFirtWndBS.DataSource = cellPresenceList; keepingsFirstWindGrid.DataSource = keepingsFirtWndBS; WareHousesDTO cellInfo = wareHousesService.GetCellInfo(wareHouseId); numberCellFirstLbl.Text = cellInfo.NumberCell.ToString(); cellCompletedFirstChk.EditValue = (cellInfo.LoadingStatusId == 3 ? true : false); bool canEdit = true; ConfirmQuantityDTO kdto = new ConfirmQuantityDTO { Quantity = (decimal)model.QuantityStore, Article = model.Article, MaterialName = model.MaterialName, KeepingId = model.KeepingId }; //using (ConfirmQuantityFm confirmQuantityFm = new ConfirmQuantityFm(kdto, canEdit)) //{ // if (confirmQuantityFm.ShowDialog() == System.Windows.Forms.DialogResult.OK) // { // kdto = confirmQuantityFm.Return(); // keepingsFirstWindGridView.BeginDataUpdate(); // cellPresenceList.Where(c => c.KeepingId == (int)kdto.KeepingId).Select(c => { c.QuantityStore = (c.QuantityStore - kdto.Quantity); c.QuantityChanged = c.QuantityChanged + kdto.Quantity; return c; }).ToList(); // keepingsFirstWindGridView.EndDataUpdate(); // expendituresGridView.BeginDataUpdate(); // keepingMaterials.Where(c => c.KeepingId == (int)kdto.KeepingId).Select(k => { k.QuantityStore = (k.QuantityStore - kdto.Quantity); return k; }).ToList(); // expendituresGridView.EndDataUpdate(); // int rowHandle = keepingsFirstWindGridView.LocateByValue("KeepingId", model.KeepingId); // keepingsFirstWindGridView.FocusedRowHandle = rowHandle; // } //} } return(true); } else { return(false); } }