diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Views.Ferramentas/UsuarioView.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Views.Ferramentas/UsuarioView.cs | 570 |
1 files changed, 570 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Views.Ferramentas/UsuarioView.cs b/Decompiler/Gestor.Application.Views.Ferramentas/UsuarioView.cs new file mode 100644 index 0000000..e0fef14 --- /dev/null +++ b/Decompiler/Gestor.Application.Views.Ferramentas/UsuarioView.cs @@ -0,0 +1,570 @@ +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +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.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; + +namespace Gestor.Application.Views.Ferramentas; + +public class UsuarioView : BaseUserControl, IComponentConnector +{ + private bool _abrindoPermissao; + + private bool _firstTime = true; + + private bool _setting; + + internal DataGrid UsuarioGrid; + + internal MenuItem CancelarApoliceButton; + + internal TextBox NomeBox; + + internal TextBox CepBox; + + internal TextBox EnderecoBox; + + internal TextBox NumeroBox; + + internal TextBox BairroBox; + + internal TextBox CidadeBox; + + internal TextBox EstadoBox; + + private bool _contentLoaded; + + public UsuarioViewModel ViewModel { get; set; } + + public UsuarioView() + { + ((FrameworkElement)this).Tag = "CADASTRO DE USUÁRIOS"; + ViewModel = new UsuarioViewModel(); + ((FrameworkElement)this).DataContext = ViewModel; + InitializeComponent(); + Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad)); + } + } + + private void ScrollToItem() + { + if (((Selector)UsuarioGrid).SelectedItem != null) + { + ((UIElement)UsuarioGrid).UpdateLayout(); + UsuarioGrid.ScrollIntoView(((Selector)UsuarioGrid).SelectedItem); + } + } + + private async void ContentLoad() + { + ViewModel.Loading(isLoading: true); + await ViewModel.Seleciona(); + ViewModel.Loading(isLoading: false); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Incluir(); + List<KeyValuePair<string, string>> errorMessages = ViewModel.SelectedUsuario.Validate(); + ((DependencyObject)(object)this).ValidateFields(errorMessages); + ViewModel.IsExpanded = false; + ((UIElement)NomeBox).Focus(); + } + + private async void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Loading(isLoading: true); + await ViewModel.CancelarAlteracao(); + ViewModel.Loading(isLoading: false); + ScrollToItem(); + } + + 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) + { + ScrollToItem(); + } + else + { + await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK"); + } + } + + private async void Alterar_OnClick(object sender, RoutedEventArgs e) + { + if (LicenseHelper.Produtos.Any((Licenca produto) => (int)produto.Produto == 91) && ViewModel.SelectedUsuario.Login.Contains("@")) + { + await ViewModel.ShowMessage("ALTERAÇÃO DESSE USUARIO TEM QUE SER FEITO NO PAINEL DO AGGILIZADOR."); + return; + } + await ViewModel.AlterarUsuario(); + ((DomainBase)ViewModel.SelectedUsuario).Initialize(); + ViewModel.CancelUsuario = (Usuario)((DomainBase)ViewModel.SelectedUsuario).Clone(); + ViewModel.Alterar(alterar: true); + ViewModel.IsExpanded = false; + ((UIElement)NomeBox).Focus(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (LicenseHelper.Produtos.Any((Licenca produto) => (int)produto.Produto == 91) && ViewModel.SelectedUsuario.Login.Contains("@")) + { + await ViewModel.ShowMessage("EXCLUSÃO DESSE USUARIO TEM QUE SER FEITO NO PAINEL DO AGGILIZADOR."); + return; + } + await ViewModel.Excluir(); + ScrollToItem(); + } + + private void AutoCompleteBancoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.Parameter.Length < 3) + { + return; + } + e.Cancel = true; + ViewModel.BuscarBanco(ValidationHelper.RemoveDiacritics(e.Parameter.Trim())).ContinueWith(delegate(Task<List<Banco>> searchResult) + { + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + if (searchResult.Result != null) + { + AutoCompleteBox val = (AutoCompleteBox)sender; + val.ItemsSource = searchResult.Result; + val.PopulateComplete(); + } + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + string text = ValidationHelper.FormatPostCode(((TextBox)sender).Text); + CepBox.Text = text; + if (ValidationHelper.ValidatePostCode(text)) + { + EnderecoBase val = await ViewModel.BuscaCep(text); + if (val != null) + { + EnderecoBox.Text = val.Endereco; + CidadeBox.Text = val.Cidade; + EstadoBox.Text = val.Estado; + BairroBox.Text = val.Bairro; + } + } + } + + private void AutoCompleteBoxUsuario_Populating(object sender, PopulatingEventArgs e) + { + e.Cancel = true; + ViewModel.Filtrar(ValidationHelper.RemoveDiacritics(e.Parameter.Trim())).ContinueWith(delegate(Task<List<Usuario>> searchResult) + { + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + if (searchResult.Result != null) + { + AutoCompleteBox val = (AutoCompleteBox)sender; + val.ItemsSource = searchResult.Result; + val.PopulateComplete(); + } + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + if (string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).Text)) + { + ViewModel.FiltrarUsuario(""); + } + } + + private async void UsuarioGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (ViewModel.EnableGrid) + { + DataGrid val = (DataGrid)sender; + if (val == null || ((Selector)val).SelectedIndex >= 0) + { + ViewModel.EnableGrid = false; + await ViewModel.SelecionaUsuario((Usuario)((val != null) ? ((ItemsControl)val).Items[((Selector)val).SelectedIndex] : null)); + ViewModel.EnableGrid = true; + } + } + } + + private async void Permissoes_OnClick(object sender, RoutedEventArgs e) + { + if (!_abrindoPermissao) + { + PermissaoUsuario val = ((IEnumerable<PermissaoUsuario>)ViewModel.PermissaoUsuario).FirstOrDefault((Func<PermissaoUsuario, bool>)((PermissaoUsuario permissao) => (int)permissao.Tela == 43)); + int num; + if (!Recursos.Usuario.Administrador && ((DomainBase)Recursos.Usuario).Id != 0L && !Recursos.Usuario.Nome.Contains("ACESSO AGGER") && val != null) + { + _ = val.Consultar; + num = ((!val.Consultar) ? 1 : 0); + } + else + { + num = 0; + } + bool flag = (byte)num != 0; + if (flag) + { + flag = await ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR PERMISSÕES."); + } + if (!flag) + { + _abrindoPermissao = true; + await ViewModel.OpenPermissao(); + await Task.Delay(1000); + _abrindoPermissao = false; + } + } + } + + private async void Vinculo_OnClick(object sender, RoutedEventArgs e) + { + await ViewModel.OpenVinculo(); + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if (!new PermissaoArquivoDigitalServico().BuscarPermissao(Recursos.Usuario, (TipoArquivoDigital)12).Consultar) + { + await ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE " + ValidationHelper.GetDescription((Enum)(object)(TipoArquivoDigital)12) + "."); + return; + } + ViewModel.EnableAlterar = false; + FiltroArquivoDigital filtro = new FiltroArquivoDigital + { + Id = ((DomainBase)ViewModel.SelectedUsuario).Id, + Tipo = (TipoArquivoDigital)12, + Parente = ViewModel.SelectedUsuario + }; + ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtro), 0, close: false); + ViewModel.EnableAlterar = true; + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.AbrirLog((TipoTela)16, ((DomainBase)ViewModel.SelectedUsuario).Id); + } + + private async void AbrirLogAcesso_OnClick(object sender, RoutedEventArgs e) + { + await ViewModel.ShowLogAcessoDialog((TipoTela)49, ViewModel.SelectedUsuario); + } + + private async void TelaInicial_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (_setting || ((Selector)(ComboBox)sender).SelectedItem == null) + { + return; + } + if ((int)(TipoTelaInicial)((Selector)(ComboBox)sender).SelectedItem == 1 && ViewModel.Restricao((TipoRestricao)47)) + { + _setting = true; + ((Selector)(ComboBox)sender).SelectedItem = (object)(TipoTelaInicial)0; + _setting = false; + if (_firstTime) + { + _firstTime = false; + return; + } + await ViewModel.ShowMessage("FAVOR DESABILITAR A RESTRIÇÃO AO PAINEL B.I. ANTES."); + } + _firstTime = false; + } + + 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 async void CriarCartao_OnClick(object sender, RoutedEventArgs e) + { + bool dadosUsuario = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 30); + await ViewModel.CriarCartao(dadosUsuario); + } + + private async void Click_VerificaAdmCentralSegurado(object sender, RoutedEventArgs e) + { + await ViewModel.VerificaUsuarioAdmCentralSegurado(); + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + public void InitializeComponent() + { + if (!_contentLoaded) + { + _contentLoaded = true; + Uri uri = new Uri("/Gestor.Application;component/views/ferramentas/usuarioview.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_0086: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: Expected O, but got Unknown + //IL_009d: Unknown result type (might be due to invalid IL or missing references) + //IL_00a9: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: Expected O, but got Unknown + //IL_00b6: Unknown result type (might be due to invalid IL or missing references) + //IL_00c0: Expected O, but got Unknown + //IL_00c2: Unknown result type (might be due to invalid IL or missing references) + //IL_00ce: Unknown result type (might be due to invalid IL or missing references) + //IL_00d8: Expected O, but got Unknown + //IL_00da: Unknown result type (might be due to invalid IL or missing references) + //IL_00e6: Unknown result type (might be due to invalid IL or missing references) + //IL_00f0: Expected O, but got Unknown + //IL_00f2: Unknown result type (might be due to invalid IL or missing references) + //IL_00fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0108: Expected O, but got Unknown + //IL_010b: Unknown result type (might be due to invalid IL or missing references) + //IL_0115: Expected O, but got Unknown + //IL_0122: Unknown result type (might be due to invalid IL or missing references) + //IL_012c: Expected O, but got Unknown + //IL_012e: Unknown result type (might be due to invalid IL or missing references) + //IL_013a: Unknown result type (might be due to invalid IL or missing references) + //IL_0144: Expected O, but got Unknown + //IL_0146: Unknown result type (might be due to invalid IL or missing references) + //IL_0152: Unknown result type (might be due to invalid IL or missing references) + //IL_015c: Expected O, but got Unknown + //IL_015e: Unknown result type (might be due to invalid IL or missing references) + //IL_016a: Unknown result type (might be due to invalid IL or missing references) + //IL_0174: Expected O, but got Unknown + //IL_0176: Unknown result type (might be due to invalid IL or missing references) + //IL_0182: Unknown result type (might be due to invalid IL or missing references) + //IL_018c: Expected O, but got Unknown + //IL_018e: Unknown result type (might be due to invalid IL or missing references) + //IL_019a: Unknown result type (might be due to invalid IL or missing references) + //IL_01a4: Expected O, but got Unknown + //IL_01a6: Unknown result type (might be due to invalid IL or missing references) + //IL_01b2: Unknown result type (might be due to invalid IL or missing references) + //IL_01bc: Expected O, but got Unknown + //IL_01be: Unknown result type (might be due to invalid IL or missing references) + //IL_01ca: Unknown result type (might be due to invalid IL or missing references) + //IL_01d4: Expected O, but got Unknown + //IL_01d7: Unknown result type (might be due to invalid IL or missing references) + //IL_01e1: Expected O, but got Unknown + //IL_01e3: Unknown result type (might be due to invalid IL or missing references) + //IL_01f0: Unknown result type (might be due to invalid IL or missing references) + //IL_01fa: Expected O, but got Unknown + //IL_01fb: Unknown result type (might be due to invalid IL or missing references) + //IL_0207: Unknown result type (might be due to invalid IL or missing references) + //IL_0211: Expected O, but got Unknown + //IL_0213: Unknown result type (might be due to invalid IL or missing references) + //IL_021f: Unknown result type (might be due to invalid IL or missing references) + //IL_0229: Expected O, but got Unknown + //IL_022b: Unknown result type (might be due to invalid IL or missing references) + //IL_0237: Unknown result type (might be due to invalid IL or missing references) + //IL_0241: Expected O, but got Unknown + //IL_0242: Unknown result type (might be due to invalid IL or missing references) + //IL_024e: Unknown result type (might be due to invalid IL or missing references) + //IL_0258: Expected O, but got Unknown + //IL_0259: Unknown result type (might be due to invalid IL or missing references) + //IL_0265: Unknown result type (might be due to invalid IL or missing references) + //IL_026f: Expected O, but got Unknown + //IL_0271: Unknown result type (might be due to invalid IL or missing references) + //IL_027d: Unknown result type (might be due to invalid IL or missing references) + //IL_0287: Expected O, but got Unknown + //IL_0288: Unknown result type (might be due to invalid IL or missing references) + //IL_0294: Unknown result type (might be due to invalid IL or missing references) + //IL_029e: Expected O, but got Unknown + //IL_029f: Unknown result type (might be due to invalid IL or missing references) + //IL_02ab: Unknown result type (might be due to invalid IL or missing references) + //IL_02b5: Expected O, but got Unknown + //IL_02b7: Unknown result type (might be due to invalid IL or missing references) + //IL_02c3: Unknown result type (might be due to invalid IL or missing references) + //IL_02cd: Expected O, but got Unknown + //IL_02d0: Unknown result type (might be due to invalid IL or missing references) + //IL_02da: Expected O, but got Unknown + //IL_02e7: Unknown result type (might be due to invalid IL or missing references) + //IL_02f1: Expected O, but got Unknown + //IL_02ff: Unknown result type (might be due to invalid IL or missing references) + //IL_0309: Expected O, but got Unknown + //IL_030c: Unknown result type (might be due to invalid IL or missing references) + //IL_0316: Expected O, but got Unknown + //IL_0319: Unknown result type (might be due to invalid IL or missing references) + //IL_0323: Expected O, but got Unknown + //IL_0326: Unknown result type (might be due to invalid IL or missing references) + //IL_0330: Expected O, but got Unknown + //IL_0333: Unknown result type (might be due to invalid IL or missing references) + //IL_033d: Expected O, but got Unknown + //IL_0340: Unknown result type (might be due to invalid IL or missing references) + //IL_034a: Expected O, but got Unknown + //IL_034c: Unknown result type (might be due to invalid IL or missing references) + //IL_0359: Unknown result type (might be due to invalid IL or missing references) + //IL_0363: Expected O, but got Unknown + //IL_0365: Unknown result type (might be due to invalid IL or missing references) + //IL_0372: Unknown result type (might be due to invalid IL or missing references) + //IL_037c: Expected O, but got Unknown + //IL_037d: Unknown result type (might be due to invalid IL or missing references) + //IL_038a: Unknown result type (might be due to invalid IL or missing references) + //IL_0394: Expected O, but got Unknown + //IL_0396: Unknown result type (might be due to invalid IL or missing references) + //IL_03a3: Unknown result type (might be due to invalid IL or missing references) + //IL_03ad: Expected O, but got Unknown + //IL_03af: Unknown result type (might be due to invalid IL or missing references) + //IL_03bc: Unknown result type (might be due to invalid IL or missing references) + //IL_03c6: Expected O, but got Unknown + //IL_03c7: Unknown result type (might be due to invalid IL or missing references) + //IL_03d4: Unknown result type (might be due to invalid IL or missing references) + //IL_03de: Expected O, but got Unknown + //IL_03e0: Unknown result type (might be due to invalid IL or missing references) + //IL_03ec: Unknown result type (might be due to invalid IL or missing references) + //IL_03f6: Expected O, but got Unknown + switch (connectionId) + { + case 1: + ((AutoCompleteBox)target).Populating += new PopulatingEventHandler(AutoCompleteBoxUsuario_Populating); + ((AutoCompleteBox)target).TextChanged += new RoutedEventHandler(AutoCompleteBox_OnTextChanged); + break; + case 2: + UsuarioGrid = (DataGrid)target; + break; + case 3: + ((MenuItem)target).Click += new RoutedEventHandler(Incluir_OnClick); + break; + case 4: + ((MenuItem)target).Click += new RoutedEventHandler(Alterar_OnClick); + break; + case 5: + ((MenuItem)target).Click += new RoutedEventHandler(Salvar_OnClick); + break; + case 6: + CancelarApoliceButton = (MenuItem)target; + CancelarApoliceButton.Click += new RoutedEventHandler(Cancelar_OnClick); + break; + case 7: + ((MenuItem)target).Click += new RoutedEventHandler(Excluir_OnClick); + break; + case 8: + ((MenuItem)target).Click += new RoutedEventHandler(Permissoes_OnClick); + break; + case 9: + ((MenuItem)target).Click += new RoutedEventHandler(Vinculo_OnClick); + break; + case 10: + ((MenuItem)target).Click += new RoutedEventHandler(CriarCartao_OnClick); + break; + case 11: + ((MenuItem)target).Click += new RoutedEventHandler(AbrirLog_OnClick); + break; + case 12: + ((MenuItem)target).Click += new RoutedEventHandler(AbrirAquivoDigital_Click); + break; + case 13: + ((MenuItem)target).Click += new RoutedEventHandler(AbrirLogAcesso_OnClick); + break; + case 14: + NomeBox = (TextBox)target; + break; + case 15: + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + ((UIElement)(TextBox)target).LostFocus += new RoutedEventHandler(CpfBox_OnLostFocus); + break; + case 16: + ((Selector)(ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(TelaInicial_OnSelectionChanged); + break; + case 17: + ((UIElement)(DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); + ((Control)(DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick); + ((UIElement)(DatePicker)target).PreviewKeyDown += new KeyEventHandler(base.DatePicker_PreviewKeyDown); + break; + case 18: + ((UIElement)(DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); + ((Control)(DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick); + ((UIElement)(DatePicker)target).PreviewKeyDown += new KeyEventHandler(base.DatePicker_PreviewKeyDown); + break; + case 19: + ((AutoCompleteBox)target).Populating += new PopulatingEventHandler(AutoCompleteBancoBox_Populating); + break; + case 20: + CepBox = (TextBox)target; + ((UIElement)CepBox).LostFocus += new RoutedEventHandler(PostcodeBox_OnLostFocus); + ((UIElement)CepBox).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + case 21: + EnderecoBox = (TextBox)target; + break; + case 22: + NumeroBox = (TextBox)target; + break; + case 23: + BairroBox = (TextBox)target; + break; + case 24: + CidadeBox = (TextBox)target; + break; + case 25: + EstadoBox = (TextBox)target; + break; + case 26: + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + case 27: + ((UIElement)(TextBox)target).LostFocus += new RoutedEventHandler(FormatarTelefone); + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + case 28: + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + case 29: + ((UIElement)(TextBox)target).LostFocus += new RoutedEventHandler(FormatarTelefone); + ((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros); + break; + case 30: + ((ButtonBase)(ToggleButton)target).Click += new RoutedEventHandler(Click_VerificaAdmCentralSegurado); + break; + default: + _contentLoaded = true; + break; + } + } +} |