diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs')
| -rw-r--r-- | Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs b/Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs new file mode 100644 index 0000000..61be59b --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs @@ -0,0 +1,154 @@ +using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.ViewModels.Seguros;
+using Gestor.Application.Views.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Domain.Seguros;
+using MaterialDesignThemes.Wpf;
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Markup;
+using System.Windows.Threading;
+
+namespace Gestor.Application.Views.Seguros
+{
+ public class TrocarClienteView : BaseUserControl, IComponentConnector
+ {
+ public TrocarClienteViewModel ViewModel;
+
+ internal System.Windows.Controls.ProgressBar ProgressBar;
+
+ internal MaterialDesignThemes.Wpf.Snackbar Snackbar;
+
+ private bool _contentLoaded;
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ internal Delegate _CreateDelegate(Type delegateType, string handler)
+ {
+ return Delegate.CreateDelegate(delegateType, this, handler);
+ }
+
+ public TrocarClienteView(Documento documento)
+ {
+ this.ViewModel = new TrocarClienteViewModel()
+ {
+ SelectedDocumento = documento
+ };
+ base.DataContext = this.ViewModel;
+ this.InitializeComponent();
+ }
+
+ private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e)
+ {
+ if (e.get_Parameter().Length < 3)
+ {
+ return;
+ }
+ e.set_Cancel(true);
+ this.ViewModel.BuscarCliente(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim()), null, 2).ContinueWith((Task<List<Cliente>> searchResult) => {
+ if (searchResult.Result == null)
+ {
+ return;
+ }
+ AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender;
+ autoCompleteBox.set_ItemsSource(searchResult.Result);
+ autoCompleteBox.PopulateComplete();
+ }, TaskScheduler.FromCurrentSynchronizationContext());
+ }
+
+ private void CloseSlackBar()
+ {
+ Thread.Sleep(5000);
+ System.Windows.Threading.Dispatcher dispatcher = this.ProgressBar.Dispatcher;
+ if (dispatcher == null)
+ {
+ return;
+ }
+ dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => this.ToggleSnackBar("", false)));
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent()
+ {
+ if (this._contentLoaded)
+ {
+ return;
+ }
+ this._contentLoaded = true;
+ System.Windows.Application.LoadComponent(this, new Uri("/Gestor.Application;component/views/seguros/trocarclienteview.xaml", UriKind.Relative));
+ }
+
+ private async void Salvar_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (!await this.ViewModel.Salvar())
+ {
+ this.ToggleSnackBar("ERRO AO TROCAR CLIENTE.", true);
+ }
+ else
+ {
+ this.ToggleSnackBar("CLIENTE TROCADO COM SUCESSO.", true);
+ }
+ }
+
+ private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e)
+ {
+ this.Snackbar.set_IsActive(false);
+ }
+
+ [DebuggerNonUserCode]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
+ {
+ switch (connectionId)
+ {
+ case 1:
+ {
+ this.ProgressBar = (System.Windows.Controls.ProgressBar)target;
+ return;
+ }
+ case 2:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick);
+ return;
+ }
+ case 3:
+ {
+ ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, TrocarClienteView.AutoCompleteBox_Populating));
+ return;
+ }
+ case 4:
+ {
+ this.Snackbar = (MaterialDesignThemes.Wpf.Snackbar)target;
+ return;
+ }
+ case 5:
+ {
+ ((SnackbarMessage)target).add_ActionClick(new RoutedEventHandler(this.SnackbarMessage_ActionClick));
+ return;
+ }
+ }
+ this._contentLoaded = true;
+ }
+
+ public void ToggleSnackBar(string message, bool active = true)
+ {
+ this.Snackbar.get_Message().Content = message;
+ this.Snackbar.set_IsActive(active);
+ if (!active)
+ {
+ return;
+ }
+ Task.Factory.StartNew(new Action(this.CloseSlackBar));
+ }
+ }
+}
\ No newline at end of file |