/// <summary> /// Добавление элемента накладной /// </summary> private void DoAddItem_Execute(object sender, ExecutedRoutedEventArgs e) { if (dataGridAllowed.SelectedItem == null) { //Dialog.WarningMessage(this, "Не выбран товар"); return; } Product product = dataGridAllowed.SelectedItem as Product; if (product == null) { Dialog.WarningMessage(this, "Не удалось получить выбранный товар"); return; } double count = 0; if (!double.TryParse(tbCount.Text.Trim().Replace('.', ','), out count)) { Dialog.WarningMessage(this, "Ошибка получения количества товара"); return; } if (count <= 0) { Dialog.WarningMessage(this, "Не корректное количество количество товара"); return; } if (!CurrentInvoice.IsPurchase && count > product.AllowedCount) { Dialog.WarningMessage(this, "Указанное количество превышает допустимое количество товара"); return; } Mouse.OverrideCursor = Cursors.Wait; // определение стоимости и купона double _cost = (CurrentInvoice.IsPurchase) ? product.CostPurchase : product.Cost; double _coupon = (CurrentInvoice.IsPurchase) ? product.CouponPurchase : product.Coupon; CurrentInvoice.Items.Add(InvoiceItem.CreateItem(CurrentInvoice.ID, product.ID, _cost, _coupon, count, CurrentInvoice.IsPurchase)); GetFreeProductList(); CurrentInvoice.Calc(); CurrentInvoice.EditInvoice(); dataGrid.Items.Refresh(); tbCount.Text = ""; Dialog.TransparentMessage(this, "Операция выполнена"); Mouse.OverrideCursor = null; }