private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            CommunalPaymentDocument target = PaymentsList.SelectedItem as CommunalPaymentDocument;

            if (target == null)
            {
                ShowMessageBoxError("You should select item before!");
                return;
            }
            PaymentDetailedWindow paymentDetailedWindow = CreateDetailedWindow(false, target);

            paymentDetailedWindow.ShowDialog();

            if (!paymentDetailedWindow.DialogResult ?? false)
            {
                return;
            }

            target = paymentDetailedWindow.document;

            MainViewModel.UpdateOrCreateElements(paymentDetailedWindow.ServiceTypes);
            MainViewModel.UpdateOrCreateElement(target);
            PaymentsList.ItemsSource = MainViewModel.PaymentDocuments;
            PaymentsList.Items.Refresh();
        }
        private PaymentDetailedWindow CreateDetailedWindow(bool isReadOnly, CommunalPaymentDocument dataContext = null)
        {
            var serviceTypes          = MainViewModel.GetElements <ServiceType>();
            var paymentDetailedWindow = new PaymentDetailedWindow(dataContext, serviceTypes, isReadOnly);

            paymentDetailedWindow.Owner = this;

            return(paymentDetailedWindow);
        }
        private void ShowButton_Click(object sender, RoutedEventArgs e)
        {
            CommunalPaymentDocument target = PaymentsList.SelectedItem as CommunalPaymentDocument;

            if (target == null)
            {
                ShowMessageBoxError("You should select item before!");
                return;
            }
            PaymentDetailedWindow paymentDetailedWindow = CreateDetailedWindow(true, target);


            paymentDetailedWindow.ShowDialog();
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            CommunalPaymentDocument target = PaymentsList.SelectedItem as CommunalPaymentDocument;

            if (target == null)
            {
                ShowMessageBoxError("You should select item before!");
                return;
            }

            MainViewModel.DeleteElement(target);
            PaymentsList.ItemsSource = MainViewModel.PaymentDocuments;
            PaymentsList.Items.Refresh();
        }
Example #5
0
        public CommunalPaymentDocument DeepCopy()
        {
            CommunalPaymentDocument document = new CommunalPaymentDocument()
            {
                Id        = Id,
                AddressId = AddressId,
                Address   = Address.DeepCopy(),
                Date      = Date,
                DateInt   = DateInt,
                Services  = Services.ConvertAll(v => v.DeepCopy()),
                TotalSum  = TotalSum
            };

            return(document);
        }