예제 #1
0
        /// <summary>
        /// Create or update OutputInvoice
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            CustomPrincipal customPrincipal = Thread.CurrentPrincipal as CustomPrincipal;

            CurrentOutputInvoice.CreatedBy = new UserViewModel()
            {
                Id = customPrincipal.Identity.Id
            };

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

            //int PIB = 0;
            //Int32.TryParse(CurrentOutputInvoice.PIB, out PIB);

            OutputInvoiceResponse response;

            //// If by any chance PIB exists in the database
            //if (response.Success == false)
            //{
            //    if (CurrentOutputInvoice.Id != response.OutputInvoice.Id)
            //    {
            //        notifier.ShowError("PIB mora biti jedinstven!");
            //        return;
            //    }
            //}
            if (CurrentOutputInvoice.Id > 0)
            {
                response = outputInvoiceService.Update(CurrentOutputInvoice);
            }
            else
            {
                response = outputInvoiceService.Create(CurrentOutputInvoice);
            }

            if (response.Success)
            {
                OutputInvoiceCreatedUpdated(response.OutputInvoice);
                FlyoutHelper.CloseFlyout(this);
            }
            else
            {
                notifier.ShowError(response.Message);
            }
        }
        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (OutputInvoiceDocumentsFromDB == null || OutputInvoiceDocumentsFromDB.Count == 0)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Ne_postoje_stavke_za_proknjižavanje"));
                return;
            }

            #endregion

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

                CurrentOutputInvoice.OutputInvoiceDocuments = OutputInvoiceDocumentsFromDB;
                OutputInvoiceResponse response = outputInvoiceService.Create(CurrentOutputInvoice);
                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;

                    OutputInvoiceCreatedUpdated();

                    Application.Current.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(() =>
                    {
                        FlyoutHelper.CloseFlyout(this);
                    })
                        );
                }
            });
            td.IsBackground = true;
            td.Start();
        }
예제 #3
0
        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentOutputInvoice?.BusinessPartner == null)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_polje_poslovni_partner"));
                return;
            }

            #endregion

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

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

                OutputInvoiceResponse response = new OutputInvoiceSQLiteRepository().Create(CurrentOutputInvoice);
                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 = outputInvoiceService.Create(CurrentOutputInvoice);
                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("Podaci_su_uspešno_sačuvaniUzvičnik"));
                    SubmitButtonContent       = ((string)Application.Current.FindResource("Proknjiži"));
                    SubmitButtonEnabled       = true;

                    new OutputInvoiceSQLiteRepository().Sync(outputInvoiceService);

                    OutputInvoiceCreatedUpdated();

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