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

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

                CurrentShipmentDocumentForm            = new ShipmentDocumentViewModel();
                CurrentShipmentDocumentForm.Identifier = Guid.NewGuid();
                CurrentShipmentDocumentForm.ItemStatus = ItemStatus.Added;

                CurrentShipmentDocumentDG = null;

                ShipmentCreatedUpdated();

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

            ShipmentDocumentListResponse response = new ShipmentDocumentSQLiteRepository()
                                                    .GetShipmentDocumentsByShipment(MainWindow.CurrentCompanyId, CurrentShipment.Identifier);

            if (response.Success)
            {
                ShipmentDocumentsFromDB = new ObservableCollection <ShipmentDocumentViewModel>(
                    response.ShipmentDocuments ?? new List <ShipmentDocumentViewModel>());
            }
            else
            {
                ShipmentDocumentsFromDB = new ObservableCollection <ShipmentDocumentViewModel>();
            }

            ShipmentDocumentDataLoading = false;
        }
Beispiel #3
0
        private void DisplayShipmentDocumentData()
        {
            ShipmentDocumentDataLoading = true;

            ShipmentDocumentListResponse response = new ShipmentDocumentSQLiteRepository()
                                                    .GetShipmentDocumentsByShipment(MainWindow.CurrentCompanyId, CurrentShipment.Identifier);

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

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

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

            #endregion

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


                CurrentShipmentDocumentForm.Shipment = CurrentShipment;


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

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

                    CurrentShipmentDocumentForm            = new ShipmentDocumentViewModel();
                    CurrentShipmentDocumentForm.Identifier = Guid.NewGuid();
                    CurrentShipmentDocumentForm.ItemStatus = ItemStatus.Added;
                    CurrentShipmentDocumentForm.IsSynced   = false;
                    return;
                }

                CurrentShipmentDocumentForm            = new ShipmentDocumentViewModel();
                CurrentShipmentDocumentForm.Identifier = Guid.NewGuid();
                CurrentShipmentDocumentForm.ItemStatus = ItemStatus.Added;
                CurrentShipmentDocumentForm.IsSynced   = false;
                ShipmentCreatedUpdated();

                DisplayShipmentDocumentData();

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

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