Esempio n. 1
0
        private void DisplayEmailData()
        {
            var response = new LimitationEmailSQLiteRepository().GetLimitationEmailsByPage(MainWindow.CurrentCompanyId, new LimitationEmailViewModel(), 1, Int32.MaxValue);

            if (response.Success)
            {
                LimitationEmailsFromDB = new ObservableCollection <LimitationEmailViewModel>(
                    response.LimitationEmails ?? new List <LimitationEmailViewModel>());
            }
        }
Esempio n. 2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentLimitationEmailDG == null)
            {
                MainWindow.WarningMessage = "Morate odabrati LimitationEmail za brisanje!";
                return;
            }

            SirmiumERPVisualEffects.AddEffectOnDialogShow(this);

            // Create confirmation window
            DeleteConfirmation deleteConfirmationForm = new DeleteConfirmation("LimitationEmail", CurrentLimitationEmailDG.Email);
            var showDialog = deleteConfirmationForm.ShowDialog();

            if (showDialog != null && showDialog.Value)
            {
                LimitationEmailResponse response = limitationEmailService.Delete(CurrentLimitationEmailDG.Identifier);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = "Greška kod brisanja sa servera!";
                    SirmiumERPVisualEffects.RemoveEffectOnDialogShow(this);
                    return;
                }

                response = new LimitationEmailSQLiteRepository().Delete(CurrentLimitationEmailDG.Identifier);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = "Greška kod lokalnog brisanja!";
                    SirmiumERPVisualEffects.RemoveEffectOnDialogShow(this);
                    return;
                }

                MainWindow.SuccessMessage = " LimitationEmail je uspešno obrisan!";

                Thread displayThread = new Thread(() => Sync());
                displayThread.IsBackground = true;
                displayThread.Start();
            }

            SirmiumERPVisualEffects.RemoveEffectOnDialogShow(this);
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            Thread th = new Thread(() =>
            {
                SaveButtonContent = " Čuvanje u toku... ";
                SaveButtonEnabled = false;

                if (CurrentLimitationEmail.Identifier == Guid.Empty)
                {
                    CurrentLimitationEmail.Identifier = Guid.NewGuid();
                }
                CurrentLimitationEmail.Company = new CompanyViewModel()
                {
                    Id = MainWindow.CurrentCompanyId
                };
                CurrentLimitationEmail.CreatedBy = new UserViewModel()
                {
                    Id = MainWindow.CurrentUserId
                };

                CurrentLimitationEmail.IsSynced = false;

                LimitationEmailResponse response = new LimitationEmailSQLiteRepository().Delete(CurrentLimitationEmail.Identifier);
                response = new LimitationEmailSQLiteRepository().Create(CurrentLimitationEmail);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = "Greška kod lokalnog čuvanja!";
                    SaveButtonContent       = " SAČUVAJ ";
                    SaveButtonEnabled       = true;
                    return;
                }

                response = limitationEmailService.Create(CurrentLimitationEmail);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = "Podaci su sačuvani u lokalu!. Greška kod čuvanja na serveru!";
                    SaveButtonContent       = " SAČUVAJ ";
                    SaveButtonEnabled       = true;
                }

                if (response.Success)
                {
                    MainWindow.SuccessMessage = "Podaci su uspešno sačuvani!";
                    SaveButtonContent         = " SAČUVAJ ";
                    SaveButtonEnabled         = true;

                    DisplayEmailData();

                    CurrentLimitationEmail            = new LimitationEmailViewModel();
                    CurrentLimitationEmail.Identifier = Guid.NewGuid();

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

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