public void DisplayVatData() { VatDataLoading = true; VatListResponse response = new VatSQLiteRepository() .GetVatsByPage(MainWindow.CurrentCompanyId, VatSearchObject, currentPage, itemsPerPage); if (response.Success) { VatsFromDB = new ObservableCollection <VatViewModel>(response.Vats ?? new List <VatViewModel>()); totalItems = response.TotalItems; } else { VatsFromDB = new ObservableCollection <VatViewModel>(); totalItems = 0; MainWindow.ErrorMessage = response.Message; } int itemFrom = totalItems != 0 ? (currentPage - 1) * itemsPerPage + 1 : 0; int itemTo = currentPage * itemsPerPage < totalItems ? currentPage * itemsPerPage : totalItems; PaginationDisplay = itemFrom + " - " + itemTo + " od " + totalItems; VatDataLoading = false; }
private void PopulateFromDb(string filterString = "") { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { new VatSQLiteRepository().Sync(vatService); VatListResponse vatResp = new VatSQLiteRepository().GetVatsForPopup(MainWindow.CurrentCompanyId, filterString); if (vatResp.Success) { VatsFromDB = new ObservableCollection <VatViewModel>(vatResp.Vats ?? new List <VatViewModel>()); } else { VatsFromDB = new ObservableCollection <VatViewModel>(); } }) ); }
private void btnDelete_Click(object sender, RoutedEventArgs e) { Thread th = new Thread(() => { VatDataLoading = true; if (CurrentVat == null) { MainWindow.WarningMessage = (string)Application.Current.FindResource("Morate_izabrati_stavku"); VatDataLoading = false; return; } VatResponse response = VatService.Delete(CurrentVat.Identifier); if (!response.Success) { MainWindow.ErrorMessage = (string)Application.Current.FindResource("Greška_kod_brisanja_sa_serveraUzvičnik"); VatDataLoading = false; return; } response = new VatSQLiteRepository().Delete(CurrentVat.Identifier); if (!response.Success) { MainWindow.ErrorMessage = (string)Application.Current.FindResource("Greška_kod_lokalnog_brisanjaUzvičnik"); VatDataLoading = false; return; } MainWindow.SuccessMessage = (string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik"); DisplayVatData(); VatDataLoading = false; }); th.IsBackground = true; th.Start(); }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (String.IsNullOrEmpty(CurrentVat.Description)) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_polje_naziv")); return; } #endregion Thread th = new Thread(() => { SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SubmitButtonEnabled = false; CurrentVat.IsSynced = false; CurrentVat.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentVat.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; VatResponse response = new VatSQLiteRepository().Delete(CurrentVat.Identifier); response = new VatSQLiteRepository().Create(CurrentVat); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_čuvanjaUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; return; } response = VatService.Create(CurrentVat); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Podaci_su_sačuvani_u_lokaluUzvičnikTačka_Greška_kod_čuvanja_na_serveruUzvičnik")) + response.Message; SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; } if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Greška_kod_čuvanja_na_serveruUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; VatCreatedUpdated(); if (IsCreateProcess) { CurrentVat = new VatViewModel(); CurrentVat.Identifier = Guid.NewGuid(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtAmount.Focus(); }) ); } else { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { if (IsPopup) { FlyoutHelper.CloseFlyoutPopup(this); } else { FlyoutHelper.CloseFlyout(this); } }) ); } } }); th.IsBackground = true; th.Start(); }