private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (BusinessPartnerPhonesFromDB == null || BusinessPartnerPhonesFromDB.Count == 0)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Morate_uneti_osnovne_podatkeUzvičnik"));
                return;
            }

            #endregion

            Thread td = new Thread(() => {
                SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke"));
                SubmitButtonEnabled = false;

                CurrentBusinessPartner.Phones    = BusinessPartnerPhonesFromDB;
                BusinessPartnerResponse response = businessPartnerService.Create(CurrentBusinessPartner);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_čuvanja_na_serveruUzvičnik"));
                    SubmitButtonContent     = ((string)Application.Current.FindResource("Proknjiži"));
                    SubmitButtonEnabled     = true;
                }

                if (response.Success)
                {
                    MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik"));
                    SubmitButtonContent       = ((string)Application.Current.FindResource("Proknjiži"));
                    SubmitButtonEnabled       = true;

                    BusinessPartnerCreatedUpdated();

                    Application.Current.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(() =>
                    {
                        FlyoutHelper.CloseFlyout(this);
                    })
                        );
                }
            });
            td.IsBackground = true;
            td.Start();
        }
コード例 #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (String.IsNullOrEmpty(CurrentBusinessPartner.Mobile))
            {
                MainWindow.WarningMessage = "Morate uneti mobilni!";
                return;
            }

            #endregion

            Thread th = new Thread(() =>
            {
                SaveButtonContent = " Čuvanje u toku... ";
                SaveButtonEnabled = false;

                CurrentBusinessPartner.CreatedBy = new UserViewModel()
                {
                    Id = MainWindow.CurrentUserId
                };

                CurrentBusinessPartner.IsSynced  = false;
                CurrentBusinessPartner.UpdatedAt = DateTime.Now;

                BusinessPartnerResponse response = new BusinessPartnerSQLiteRepository().Delete(CurrentBusinessPartner.Identifier);
                response = new BusinessPartnerSQLiteRepository().Create(CurrentBusinessPartner);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = "Greška kod lokalnog čuvanja!";
                    SaveButtonContent       = " Sačuvaj ";
                    SaveButtonEnabled       = true;
                    return;
                }

                response = businessPartnerService.Create(CurrentBusinessPartner);
                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)
                {
                    new BusinessPartnerSQLiteRepository().UpdateSyncStatus(response.BusinessPartner.Identifier, response.BusinessPartner.Id, true);
                    MainWindow.SuccessMessage = "Podaci su uspešno sačuvani!";
                    SaveButtonContent         = " Sačuvaj ";
                    SaveButtonEnabled         = true;

                    BusinessPartnerCreatedUpdated();

                    if (IsCreateProcess)
                    {
                        CurrentBusinessPartner            = new BusinessPartnerViewModel();
                        CurrentBusinessPartner.Identifier = Guid.NewGuid();
                        CurrentBusinessPartner.Code       = new BusinessPartnerSQLiteRepository().GetNewCodeValue();

                        Application.Current.Dispatcher.BeginInvoke(
                            System.Windows.Threading.DispatcherPriority.Normal,
                            new Action(() =>
                        {
                            txtName.Focus();
                        })
                            );
                    }
                    else
                    {
                        Application.Current.Dispatcher.BeginInvoke(
                            System.Windows.Threading.DispatcherPriority.Normal,
                            new Action(() =>
                        {
                            FlyoutHelper.CloseFlyout(this);
                        })
                            );
                    }
                }
            });
            th.IsBackground = true;
            th.Start();
        }
コード例 #3
0
        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentBusinessPartner?.InternalCode == null)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Šifra"));
                return;
            }

            #endregion

            Thread td = new Thread(() => {
                SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke"));
                SubmitButtonEnabled = false;

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

                BusinessPartnerResponse response = new BusinessPartnerSQLiteRepository().Create(CurrentBusinessPartner);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_čuvanjaUzvičnik"));
                    SubmitButtonContent     = ((string)Application.Current.FindResource("Proknjiži"));
                    SubmitButtonEnabled     = true;
                }

                response = businessPartnerService.Create(CurrentBusinessPartner);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Podaci_su_sačuvani_u_lokaluUzvičnikTačka_Greška_kod_čuvanja_na_serveruUzvičnik"));
                    SubmitButtonContent     = ((string)Application.Current.FindResource("Proknjiži"));
                    SubmitButtonEnabled     = true;
                }

                if (response.Success)
                {
                    MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik"));
                    SubmitButtonContent       = ((string)Application.Current.FindResource("Proknjiži"));
                    SubmitButtonEnabled       = true;

                    new BusinessPartnerSQLiteRepository().Sync(businessPartnerService);

                    BusinessPartnerCreatedUpdated();

                    Application.Current.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(() =>
                    {
                        FlyoutHelper.CloseFlyout(this);
                    })
                        );
                }
            });
            td.IsBackground = true;
            td.Start();
        }