private void BtnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (InvoiceItemsFromDB == null || InvoiceItemsFromDB.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; CurrentInvoice.TotalPrice = (double)InvoiceItemsFromDB.Sum(x => x.Amount); CurrentInvoice.TotalPDV = (double)InvoiceItemsFromDB.Sum(x => x.PDV); CurrentInvoice.TotalRebate = (double)InvoiceItemsFromDB.Sum(x => x.TotalDiscount); var response = new InvoiceSQLiteRepository().Create(CurrentInvoice); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_čuvanjaUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; } CurrentInvoice.InvoiceItems = InvoiceItemsFromDB; response = invoiceService.Create(CurrentInvoice); 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; InvoiceCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }
private void btnCancel_Click(object sender, RoutedEventArgs e) { if (IsPopup) { FlyoutHelper.CloseFlyoutPopup(this); } else { FlyoutHelper.CloseFlyout(this); } }
private void HandleKeyDownEvent(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { FlyoutHelper.CloseFlyout(this); } if (e.Key == Key.S && (Keyboard.Modifiers & (ModifierKeys.Control)) == (ModifierKeys.Control)) { btnSave_Click(sender, e); } }
/// <summary> /// Create or update Individual /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, RoutedEventArgs e) { CustomPrincipal customPrincipal = Thread.CurrentPrincipal as CustomPrincipal; CurrentIndividual.CreatedBy = new UserViewModel() { Id = customPrincipal.Identity.Id }; //if (String.IsNullOrEmpty(CurrentIndividual.Mobile)) //{ // MainWindow.WarningMessage = "Morate uneti mobilni!"; // return; //} //int PIB = 0; //Int32.TryParse(CurrentIndividual.PIB, out PIB); IndividualResponse response; //// If by any chance PIB exists in the database //if (response.Success == false) //{ // if (CurrentIndividual.Id != response.Individual.Id) // { // notifier.ShowError("PIB mora biti jedinstven!"); // return; // } //} if (CurrentIndividual.Id > 0) { response = individualService.Update(CurrentIndividual); } else { response = individualService.Create(CurrentIndividual); } if (response.Success) { IndividualCreatedUpdated(response.Individual); FlyoutHelper.CloseFlyout(this); } else { notifier.ShowError(response.Message); } }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (ConstructionSiteCalculationsFromDB == null || ConstructionSiteCalculationsFromDB.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; CurrentConstructionSite.ConstructionSiteCalculations = ConstructionSiteCalculationsFromDB; var test = CurrentConstructionSite; ConstructionSiteResponse response = constructionSiteService.Create(CurrentConstructionSite); 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; ConstructionSiteCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (ShipmentDocumentsFromDB == null || ShipmentDocumentsFromDB.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; CurrentShipment.ShipmentDocuments = ShipmentDocumentsFromDB; ShipmentResponse response = ShipmentService.Create(CurrentShipment); 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; ShipmentCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }
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(); }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (String.IsNullOrEmpty(CurrentToDoStatus.Name)) { 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; CurrentToDoStatus.IsSynced = false; CurrentToDoStatus.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentToDoStatus.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; ToDoStatusResponse response = new ToDoStatusSQLiteRepository().Delete(CurrentToDoStatus.Identifier); response = new ToDoStatusSQLiteRepository().Create(CurrentToDoStatus); 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; return; } response = ToDoStatusService.Create(CurrentToDoStatus); 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; ToDoStatusCreatedUpdated(); if (IsCreateProcess) { CurrentToDoStatus = new ToDoStatusViewModel(); CurrentToDoStatus.Identifier = Guid.NewGuid(); 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(() => { if (IsPopup) { FlyoutHelper.CloseFlyoutPopup(this); } else { FlyoutHelper.CloseFlyout(this); } }) ); } } }); th.IsBackground = true; th.Start(); }
private void BtnCancel_Click(object sender, RoutedEventArgs e) { EmployeeCreatedUpdated(); FlyoutHelper.CloseFlyout(this); }
private void BtnCancel_Click(object sender, RoutedEventArgs e) { FlyoutHelper.CloseFlyout(this); }
private void BtnCancel_Click(object sender, RoutedEventArgs e) { PhysicalPersonCreatedUpdated(); FlyoutHelper.CloseFlyout(this); }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (currentInputInvoice?.BusinessPartner == null) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Poslovni_partner")); return; } #endregion Thread td = new Thread(() => { SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SubmitButtonEnabled = false; currentInputInvoice.IsSynced = false; currentInputInvoice.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; currentInputInvoice.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; InputInvoiceResponse response = new InputInvoiceSQLiteRepository().Create(currentInputInvoice); 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 = InputInvoiceService.Create(currentInputInvoice); 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 InputInvoiceSQLiteRepository().Sync(InputInvoiceService); InputInvoiceCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { #region Validation //if (CurrentAgency.Code == null) //{ // MainWindow.WarningMessage = "Obavezno polje: Šifra"; // return; //} if (String.IsNullOrEmpty(CurrentAgency.Name)) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Naziv_delatnosti")); return; } if (CurrentAgency.Country == null) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Ime_drzave")); return; } if (CurrentAgency.Sector == null) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Naziv_sektora")); return; } #endregion Thread th = new Thread(() => { SaveButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SaveButtonEnabled = false; CurrentAgency.IsSynced = false; CurrentAgency.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentAgency.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; AgencyResponse response = AgencyService.Create(CurrentAgency); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_čuvanja_na_serveruUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; } if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; AgencyCreatedUpdated(); if (IsCreateProcess) { CurrentAgency = new AgencyViewModel(); CurrentAgency.Identifier = Guid.NewGuid(); 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(() => { if (IsPopup) { FlyoutHelper.CloseFlyoutPopup(this); } else { FlyoutHelper.CloseFlyout(this); } }) ); } } }); th.IsBackground = true; th.Start(); }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { SirmiumERPVisualEffects.AddEffectOnDialogShow(this); // Save header for any new change btnSaveHeader_Click(sender, e); #region Validation if (!IsHeaderCreated) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Zaglavlje_nije_sačuvano")); return; } #endregion Thread th = new Thread(() => { SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SubmitButtonEnabled = false; CurrentUser.CompanyUsers = CompanyUsersFromDB.ToList(); UserResponse response = userService.Create(CurrentUser); 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; UserCreatedUpdated(); CurrentUser = new UserViewModel(); CurrentUser.Identifier = Guid.NewGuid(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { if (IsPopup) { FlyoutHelper.CloseFlyoutPopup(this); } else { FlyoutHelper.CloseFlyout(this); } }) ); } else { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_čuvanja_na_serveruUzvičnik")); SubmitButtonContent = ((string)Application.Current.FindResource("Proknjiži")); SubmitButtonEnabled = true; } }); th.IsBackground = true; th.Start(); SirmiumERPVisualEffects.RemoveEffectOnDialogShow(this); }
private void BtnCancel_Click(object sender, RoutedEventArgs e) { BusinessPartnerCreatedUpdated(); FlyoutHelper.CloseFlyout(this); }
private void BtnCancel_Click(object sender, RoutedEventArgs e) { ConstructionSiteCreatedUpdated(); FlyoutHelper.CloseFlyout(this); }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { ConstructionSiteListResponse constructionSiteList = new ConstructionSiteSQLiteRepository() .GetConstructionSites(MainWindow.CurrentCompanyId, ""); var ConstructionSitesFromDB = new ObservableCollection <ConstructionSiteViewModel>(constructionSiteList.ConstructionSites ?? new List <ConstructionSiteViewModel>()); #region Validation if (CurrentConstructionSite?.Name == null) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Naziv_gradilista")); return; } if (ConstructionSitesFromDB.Any(p => p.InternalCode == CurrentConstructionSite?.InternalCode) && CurrentConstructionSite.Code == null) { MainWindow.WarningMessage = (string)Application.Current.FindResource("Šifra_već_postoji_uzvičnik"); return; } #endregion Thread td = new Thread(() => { SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SubmitButtonEnabled = false; CurrentConstructionSite.IsSynced = false; CurrentConstructionSite.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentConstructionSite.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; ConstructionSiteResponse response = new ConstructionSiteSQLiteRepository().Create(CurrentConstructionSite); 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 = constructionSiteService.Create(CurrentConstructionSite); 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 ConstructionSiteSQLiteRepository().Sync(constructionSiteService); ConstructionSiteCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { #region Validation if (CurrentBusinessPartnerInvoice == 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; CurrentInvoice.Buyer = CurrentBusinessPartnerInvoice; CurrentInvoice.IsSynced = false; CurrentInvoice.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentInvoice.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; var itemsResponse = new InvoiceItemSQLiteRepository().GetInvoiceItemsByInvoice(MainWindow.CurrentCompanyId, CurrentInvoice.Identifier); if (itemsResponse.InvoiceItems != null) { CurrentInvoice.InvoiceItems = new ObservableCollection <InvoiceItemViewModel>(itemsResponse?.InvoiceItems ?? new List <InvoiceItemViewModel>()); foreach (var item in CurrentInvoice.InvoiceItems) { item.PDVPercent = CurrentInvoice.Vat?.Amount ?? 0; item.ItemStatus = ItemStatus.Edited; new InvoiceItemSQLiteRepository().Delete(item.Identifier); new InvoiceItemSQLiteRepository().Create(item); } } CurrentInvoice.TotalPrice = CurrentInvoice.InvoiceItems.Sum(x => (double)x.PriceWithPDV); InvoiceResponse response = new InvoiceSQLiteRepository().Create(CurrentInvoice); 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(CurrentInvoice); 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 InvoiceSQLiteRepository().Sync(outputInvoiceService); InvoiceCreatedUpdated(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } }); td.IsBackground = true; td.Start(); }