예제 #1
0
        /// <summary>
        /// Редактирование элемента накладной
        /// </summary>
        private void DoEditItem_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            InvoiceItem item = dataGrid.SelectedItem as InvoiceItem;

            EditItemCountWindow view = (CurrentInvoice.IsPurchase) ? new EditItemCountWindow(item.Count, item.Product.ProductCode, item.Product.Nomination, true, item.ProductCost, item.ProductCoupon) : new EditItemCountWindow(item.Count, item.Product.ProductCode, item.Product.Nomination, item.Product.AllowedCount, false);

            view.Owner = this;

            if ((bool)view.ShowDialog())
            {
                Mouse.OverrideCursor = Cursors.Wait;

                item.Count = view.NewCount;

                if (CurrentInvoice.IsPurchase)
                {
                    item.ProductCost   = view.NewCost;
                    item.ProductCoupon = view.NewCoupon;
                }

                view.Close();

                if (item.EditItem(CurrentInvoice.IsPurchase))
                {
                    CurrentInvoice.Calc();

                    CurrentInvoice.EditInvoice();

                    dataGrid.Items.Refresh();

                    Dialog.TransparentMessage(this, "Операция выполнена");
                }

                Mouse.OverrideCursor = null;
            }
            else
            {
                view.Close();
            }
        }