private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var response = new InputInvoiceDocumentSQLiteRepository().SetStatusDeleted(CurrentInputInvoiceDocumentDG.Identifier);

            if (response.Success)
            {
                MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik"));

                CurrentInputInvoiceDocumentForm            = new InputInvoiceDocumentViewModel();
                CurrentInputInvoiceDocumentForm.Identifier = Guid.NewGuid();
                CurrentInputInvoiceDocumentForm.ItemStatus = ItemStatus.Added;

                CurrentInputInvoiceDocumentDG = null;

                InputInvoiceCreatedUpdated();

                Thread displayThread = new Thread(() => DisplayInputInvoiceDocumentData());
                displayThread.IsBackground = true;
                displayThread.Start();
            }
            else
            {
                MainWindow.ErrorMessage = response.Message;
            }
        }
        public void DisplayInputInvoiceDocumentData()
        {
            InputInvoiceDocumentDataLoading = true;

            InputInvoiceDocumentListResponse response = new InputInvoiceDocumentSQLiteRepository()
                                                        .GetInputInvoiceDocumentsByInputInvoice(MainWindow.CurrentCompanyId, CurrentInputInvoice.Identifier);

            if (response.Success)
            {
                InputInvoiceDocumentsFromDB = new ObservableCollection <InputInvoiceDocumentViewModel>(
                    response.InputInvoiceDocuments ?? new List <InputInvoiceDocumentViewModel>());
            }
            else
            {
                InputInvoiceDocumentsFromDB = new ObservableCollection <InputInvoiceDocumentViewModel>();
            }

            InputInvoiceDocumentDataLoading = false;
        }
Exemple #3
0
        private void DisplayInputInvoiceDocumentData()
        {
            InputInvoiceDocumentDataLoading = true;

            InputInvoiceDocumentListResponse response = new InputInvoiceDocumentSQLiteRepository()
                                                        .GetInputInvoiceDocumentsByInputInvoice(MainWindow.CurrentCompanyId, CurrentInputInvoice.Identifier);

            if (response.Success)
            {
                InputInvoiceDocumentsFromDB = new ObservableCollection <InputInvoiceDocumentViewModel>(
                    response.InputInvoiceDocuments ?? new List <InputInvoiceDocumentViewModel>());
            }
            else
            {
                InputInvoiceDocumentsFromDB = new ObservableCollection <InputInvoiceDocumentViewModel>();
                MainWindow.ErrorMessage     = ((string)Application.Current.FindResource("Greška_prilikom_učitavanja_podatakaUzvičnik"));
            }

            InputInvoiceDocumentDataLoading = false;
        }
        private void btnAddDocument_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentInputInvoiceDocumentForm.Name == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Naziv"));
                return;
            }

            #endregion

            Thread th = new Thread(() =>
            {
                SubmitButtonEnabled = false;


                CurrentInputInvoiceDocumentForm.InputInvoice = CurrentInputInvoice;


                CurrentInputInvoiceDocumentForm.Company = new CompanyViewModel()
                {
                    Id = MainWindow.CurrentCompanyId
                };
                CurrentInputInvoiceDocumentForm.CreatedBy = new UserViewModel()
                {
                    Id = MainWindow.CurrentUserId
                };

                new InputInvoiceDocumentSQLiteRepository().Delete(CurrentInputInvoiceDocumentForm.Identifier);
                var response = new InputInvoiceDocumentSQLiteRepository().Create(CurrentInputInvoiceDocumentForm);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = response.Message;

                    CurrentInputInvoiceDocumentForm            = new InputInvoiceDocumentViewModel();
                    CurrentInputInvoiceDocumentForm.Identifier = Guid.NewGuid();
                    CurrentInputInvoiceDocumentForm.ItemStatus = ItemStatus.Added;
                    CurrentInputInvoiceDocumentForm.IsSynced   = false;
                    return;
                }

                CurrentInputInvoiceDocumentForm            = new InputInvoiceDocumentViewModel();
                CurrentInputInvoiceDocumentForm.Identifier = Guid.NewGuid();
                CurrentInputInvoiceDocumentForm.ItemStatus = ItemStatus.Added;
                CurrentInputInvoiceDocumentForm.IsSynced   = false;
                InputInvoiceCreatedUpdated();

                DisplayInputInvoiceDocumentData();

                Application.Current.Dispatcher.BeginInvoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(() =>
                {
                    txtDocumentName.Focus();
                })
                    );

                SubmitButtonEnabled = true;
            });
            th.IsBackground = true;
            th.Start();
        }