diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Views.Seguros/PerfilView.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Views.Seguros/PerfilView.cs | 363 |
1 files changed, 363 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Views.Seguros/PerfilView.cs b/Decompiler/Gestor.Application.Views.Seguros/PerfilView.cs new file mode 100644 index 0000000..54d6784 --- /dev/null +++ b/Decompiler/Gestor.Application.Views.Seguros/PerfilView.cs @@ -0,0 +1,363 @@ +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Text.RegularExpressions; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.Views.Seguros; + +public class PerfilView : BaseUserControl, IComponentConnector +{ + public PerfilViewModel ViewModel; + + private Controle _controle; + + internal MenuItem CancelarApoliceButton; + + internal DatePicker NascimentoBox; + + private bool _contentLoaded; + + public PerfilView(Controle controle) + { + _controle = controle; + ((FrameworkElement)this).Tag = "CADASTRO DE PERFIL"; + ViewModel = new PerfilViewModel(controle); + ((FrameworkElement)this).DataContext = ViewModel; + InitializeComponent(); + Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad)); + } + } + + private void ContentLoad() + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Expected O, but got Unknown + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_002e: Expected O, but got Unknown + ((UIElement)NascimentoBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(Funcoes.DatePicker_OnLostKeyboardFocus); + ((UIElement)NascimentoBox).PreviewKeyDown += new KeyEventHandler(Funcoes.DatePicker_PreviewKeyDown); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Incluir(); + ValidarTela(); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Alterar(alterar: true); + ValidarTela(); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Loading(isLoading: true); + List<KeyValuePair<string, string>> list = await ViewModel.Salvar(); + ((DependencyObject)(object)this).ValidateFields(list); + bool num = list == null || list.Count == 0; + ViewModel.Loading(isLoading: false); + if (!num) + { + await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK"); + } + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.CancelarAlteracao(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await ViewModel.Excluir(); + } + + private void CpfBox_OnLostFocus(object sender, RoutedEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + TextBox val = (TextBox)sender; + val.Text = ValidationHelper.FormatDocument(val.Text); + } + + private void RelacaoComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_0054: Expected O, but got Unknown + if (((Selector)(ComboBox)sender).SelectedIndex != 0) + { + return; + } + Cliente cliente = _controle.Cliente; + string text = ValidationHelper.FormatDocument(ValidationHelper.Clear((cliente != null) ? cliente.Documento : null)); + bool flag = Regex.IsMatch(text, "\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}"); + Perfil val = (Perfil)((DomainBase)ViewModel.SelectedPerfil).Clone(); + val.Cpf = (flag ? text : ""); + val.Nome = _controle.Cliente.Nome; + val.Nascimento = _controle.Cliente.Nascimento; + val.Sexo = _controle.Cliente.Sexo; + val.EstadoCivil = _controle.Cliente.EstadoCivil; + val.Habilitacao = _controle.Cliente.Habilitacao; + if (_controle.Cliente.PrimeiraHabilitacao.HasValue) + { + DateTime networkTime = Funcoes.GetNetworkTime(); + DateTime? primeiraHabilitacao = _controle.Cliente.PrimeiraHabilitacao; + TimeSpan? timeSpan = networkTime - primeiraHabilitacao; + TimeSpan? timeSpan2 = timeSpan; + if (timeSpan2.Value.Days > 3650) + { + val.TempoHabilitacao = (TempoHabilitacao)10; + } + else + { + TimeSpan? timeSpan3 = timeSpan; + if (timeSpan3.Value.Days > 3285) + { + val.TempoHabilitacao = (TempoHabilitacao)9; + } + else + { + TimeSpan? timeSpan4 = timeSpan; + if (timeSpan4.Value.Days > 2920) + { + val.TempoHabilitacao = (TempoHabilitacao)8; + } + else + { + TimeSpan? timeSpan5 = timeSpan; + if (timeSpan5.Value.Days > 2555) + { + val.TempoHabilitacao = (TempoHabilitacao)7; + } + else + { + TimeSpan? timeSpan6 = timeSpan; + if (timeSpan6.Value.Days > 2190) + { + val.TempoHabilitacao = (TempoHabilitacao)6; + } + else + { + TimeSpan? timeSpan7 = timeSpan; + if (timeSpan7.Value.Days > 1825) + { + val.TempoHabilitacao = (TempoHabilitacao)5; + } + else + { + TimeSpan? timeSpan8 = timeSpan; + if (timeSpan8.Value.Days > 1460) + { + val.TempoHabilitacao = (TempoHabilitacao)4; + } + else + { + TimeSpan? timeSpan9 = timeSpan; + if (timeSpan9.Value.Days > 1095) + { + val.TempoHabilitacao = (TempoHabilitacao)3; + } + else + { + TimeSpan? timeSpan10 = timeSpan; + if (timeSpan10.Value.Days > 730) + { + val.TempoHabilitacao = (TempoHabilitacao)2; + } + else + { + TimeSpan? timeSpan11 = timeSpan; + if (timeSpan11.Value.Days > 365) + { + val.TempoHabilitacao = (TempoHabilitacao)1; + } + else + { + val.TempoHabilitacao = (TempoHabilitacao)0; + } + } + } + } + } + } + } + } + } + } + } + ViewModel.SelectedPerfil = val; + } + + private void ValidarTela() + { + if (ViewModel.SelectedPerfil != null) + { + List<KeyValuePair<string, string>> errorMessages = ViewModel.SelectedPerfil.Validate(); + ((DependencyObject)(object)this).ValidateFields(errorMessages, focusField: false); + } + } + + private void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Expected O, but got Unknown + TextBox val = (TextBox)sender; + if (!string.IsNullOrWhiteSpace(val.Text)) + { + string text = ValidationHelper.FormatPostCode(val.Text); + if (ValidationHelper.ValidatePostCode(text)) + { + val.Text = text; + } + } + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + public void InitializeComponent() + { + if (!_contentLoaded) + { + _contentLoaded = true; + Uri uri = new Uri("/Gestor.Application;component/views/seguros/perfilview.xaml", UriKind.Relative); + Application.LoadComponent((object)this, uri); + } + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + [EditorBrowsable(EditorBrowsableState.Never)] + void IComponentConnector.Connect(int connectionId, object target) + { + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Expected O, but got Unknown + //IL_005a: Unknown result type (might be due to invalid IL or missing references) + //IL_0066: Unknown result type (might be due to invalid IL or missing references) + //IL_0070: Expected O, but got Unknown + //IL_0072: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Unknown result type (might be due to invalid IL or missing references) + //IL_0088: Expected O, but got Unknown + //IL_008b: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Expected O, but got Unknown + //IL_00a2: Unknown result type (might be due to invalid IL or missing references) + //IL_00ac: Expected O, but got Unknown + //IL_00ae: Unknown result type (might be due to invalid IL or missing references) + //IL_00ba: Unknown result type (might be due to invalid IL or missing references) + //IL_00c4: Expected O, but got Unknown + //IL_00c6: Unknown result type (might be due to invalid IL or missing references) + //IL_00d2: Unknown result type (might be due to invalid IL or missing references) + //IL_00dc: Expected O, but got Unknown + //IL_00de: Unknown result type (might be due to invalid IL or missing references) + //IL_00ea: Unknown result type (might be due to invalid IL or missing references) + //IL_00f4: Expected O, but got Unknown + //IL_00f5: Unknown result type (might be due to invalid IL or missing references) + //IL_0102: Unknown result type (might be due to invalid IL or missing references) + //IL_010c: Expected O, but got Unknown + //IL_010f: Unknown result type (might be due to invalid IL or missing references) + //IL_0119: Expected O, but got Unknown + //IL_0126: Unknown result type (might be due to invalid IL or missing references) + //IL_0130: Expected O, but got Unknown + //IL_013d: Unknown result type (might be due to invalid IL or missing references) + //IL_0147: Expected O, but got Unknown + //IL_0149: Unknown result type (might be due to invalid IL or missing references) + //IL_0156: Unknown result type (might be due to invalid IL or missing references) + //IL_0160: Expected O, but got Unknown + //IL_0162: Unknown result type (might be due to invalid IL or missing references) + //IL_016f: Unknown result type (might be due to invalid IL or missing references) + //IL_0179: Expected O, but got Unknown + //IL_017b: Unknown result type (might be due to invalid IL or missing references) + //IL_0188: Unknown result type (might be due to invalid IL or missing references) + //IL_0192: Expected O, but got Unknown + //IL_0194: Unknown result type (might be due to invalid IL or missing references) + //IL_01a0: Unknown result type (might be due to invalid IL or missing references) + //IL_01aa: Expected O, but got Unknown + //IL_01ab: Unknown result type (might be due to invalid IL or missing references) + //IL_01b8: Unknown result type (might be due to invalid IL or missing references) + //IL_01c2: Expected O, but got Unknown + //IL_01c4: Unknown result type (might be due to invalid IL or missing references) + //IL_01d0: Unknown result type (might be due to invalid IL or missing references) + //IL_01da: Expected O, but got Unknown + //IL_01db: Unknown result type (might be due to invalid IL or missing references) + //IL_01e8: Unknown result type (might be due to invalid IL or missing references) + //IL_01f2: Expected O, but got Unknown + switch (connectionId) + { + case 1: + ((MenuItem)target).Click += new RoutedEventHandler(Incluir_OnClick); + break; + case 2: + ((MenuItem)target).Click += new RoutedEventHandler(Alterar_OnClick); + break; + case 3: + ((MenuItem)target).Click += new RoutedEventHandler(Salvar_OnClick); + break; + case 4: + CancelarApoliceButton = (MenuItem)target; + CancelarApoliceButton.Click += new RoutedEventHandler(Cancelar_OnClick); + break; + case 5: + ((MenuItem)target).Click += new RoutedEventHandler(Excluir_OnClick); + break; + case 6: + ((Selector)(ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(RelacaoComboBox_OnSelectionChanged); + break; + case 7: + ((UIElement)(TextBox)target).LostFocus += new RoutedEventHandler(CpfBox_OnLostFocus); + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + case 8: + NascimentoBox = (DatePicker)target; + ((UIElement)NascimentoBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); + ((Control)NascimentoBox).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick); + break; + case 9: + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + case 10: + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + case 11: + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + case 12: + ((UIElement)(TextBox)target).LostFocus += new RoutedEventHandler(PostcodeBox_OnLostFocus); + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + case 13: + ((UIElement)(TextBox)target).LostFocus += new RoutedEventHandler(PostcodeBox_OnLostFocus); + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + default: + _contentLoaded = true; + break; + } + } +} |