From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- Gestor.Application/Views/Seguros/ClienteView.cs | 1307 +++++++++++++++++++++++ 1 file changed, 1307 insertions(+) create mode 100644 Gestor.Application/Views/Seguros/ClienteView.cs (limited to 'Gestor.Application/Views/Seguros/ClienteView.cs') diff --git a/Gestor.Application/Views/Seguros/ClienteView.cs b/Gestor.Application/Views/Seguros/ClienteView.cs new file mode 100644 index 0000000..5426996 --- /dev/null +++ b/Gestor.Application/Views/Seguros/ClienteView.cs @@ -0,0 +1,1307 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Generic; +using Gestor.Common.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +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 Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Views.Seguros +{ + public class ClienteView : BaseUserControl, IComponentConnector, IStyleConnector + { + public ClienteViewModel ViewModel; + + internal Grid MainGrid; + + internal MenuItem IncluirClienteButton; + + internal ComboBox TipoDocumentoPrincipalBox; + + internal TextBox DocumentoPrincipalBox; + + internal TextBox NomeBox; + + internal TextBox NomeSocialBox; + + internal TextBox CaepfBox; + + internal TextBox RneBox; + + internal TextBox CeiBox; + + internal TextBox IdentidadeBox; + + internal TextBox EmissorBox; + + internal TextBox EstadoEmissorBox; + + internal TextBox HabilitacaoBox; + + internal TextBox CategoriaHabilitacaooBox; + + internal ComboBox SexoBox; + + internal ComboBox EstadoCivilBox; + + internal AutoCompleteBox AutoCompleteProfissao; + + internal AutoCompleteBox AutoCompleteAtividade; + + internal TextBox ResponsavelBox; + + internal TextBox DocumentoResponsavel; + + internal TextBox EmailBox; + + internal TextBox PastaBox; + + internal AutoCompleteBox AutoCompleteBanco; + + internal TextBox AgenciaBox; + + internal TextBox TipoContaBox; + + internal TextBox ContaBox; + + internal CurrencyTextBox RendaMensalBox; + + internal ListBox TelefoneListBox; + + internal ListBox EmailListBox; + + internal ListBox EnderecoListBox; + + internal AutoCompleteBox VinculoBox; + + internal TextBox NomeOrigemBox; + + internal ListBox ContatosListBox; + + private bool _contentLoaded; + + private static int Ordem + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ClienteView(Cliente cliente = null, bool lockInsert = false, ClienteViewModel viewModel = null) + { + base.Tag = "CADASTRO DE CLIENTES"; + this.ViewModel = viewModel ?? new ClienteViewModel(cliente, !lockInsert); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + if (lockInsert) + { + this.IncluirClienteButton.IsEnabled = false; + } + if (cliente != null) + { + this.ViewModel.RegistrarAcao(string.Concat("ACESSOU CLIENTE \"", cliente.get_Nome(), "\""), cliente.get_Id(), new TipoTela?(1), string.Format("ID CLIENTE: {0}", cliente.get_Id())); + } + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 1).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedCliente.get_Id()); + filtroArquivoDigital.set_Tipo(1); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedCliente); + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", EnumHelper.GetDescription(1), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(1, this.ViewModel.SelectedCliente.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(1, this.ViewModel.SelectedCliente.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + this.ClearInputFields(); + this.ValidarTela(); + this.ViewModel.SelectedCliente.Initialize(); + this.InitializeResponsavelAssinatura(); + this.ViewModel.Salvando = false; + } + + private void AutoCompleteAtividadeBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 1) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarAtividade(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void AutoCompleteBanco_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + ClienteView.SetValid(autoCompleteBox, (string.IsNullOrWhiteSpace(autoCompleteBox.get_Text()) ? true : this.ViewModel.SelectedCliente.get_Banco() != null)); + } + + private void AutoCompleteBancoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarBanco(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void AutoCompleteParentescoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarClienteVinculo(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim()), this.ViewModel.SelectedCliente.get_Id()).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void AutoCompleteProfissaoBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 1) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarProfissao(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ClearInputFields(); + ClienteView.SetValid(this.AutoCompleteBanco, true); + this.ViewModel.CancelarAlteracao(); + } + + private void ClearInputFields() + { + object nome; + object empty; + object obj; + object nome1; + AutoCompleteBox autoCompleteBanco = this.AutoCompleteBanco; + Banco banco = this.ViewModel.SelectedCliente.get_Banco(); + if (banco != null) + { + nome = banco.get_Nome(); + } + else + { + nome = null; + } + if (nome == null) + { + nome = string.Empty; + } + autoCompleteBanco.set_Text((string)nome); + AutoCompleteBox autoCompleteProfissao = this.AutoCompleteProfissao; + Profissao profissao = this.ViewModel.SelectedCliente.get_Profissao(); + if (profissao != null) + { + empty = profissao.get_Nome(); + } + else + { + empty = null; + } + if (empty == null) + { + empty = string.Empty; + } + autoCompleteProfissao.set_Text((string)empty); + AutoCompleteBox autoCompleteBox = this.AutoCompleteProfissao; + Profissao profissao1 = this.ViewModel.SelectedCliente.get_Profissao(); + if (profissao1 != null) + { + obj = profissao1.get_Nome(); + } + else + { + obj = null; + } + if (obj == null) + { + obj = string.Empty; + } + autoCompleteBox.set_Text((string)obj); + AutoCompleteBox autoCompleteAtividade = this.AutoCompleteAtividade; + Atividade atividade = this.ViewModel.SelectedCliente.get_Atividade(); + if (atividade != null) + { + nome1 = atividade.get_Nome(); + } + else + { + nome1 = null; + } + if (nome1 == null) + { + nome1 = string.Empty; + } + autoCompleteAtividade.set_Text((string)nome1); + } + + private void ContentLoad() + { + string nome; + string str; + string nome1; + this.TelefoneListBox.DataContext = this.ViewModel; + this.EmailListBox.DataContext = this.ViewModel; + this.EnderecoListBox.DataContext = this.ViewModel; + this.ContatosListBox.DataContext = this.ViewModel; + this.DocumentoResponsavel.LostFocus += new RoutedEventHandler(this.Validar_LostFocus); + if (this.ViewModel.SelectedCliente == null) + { + return; + } + AutoCompleteBox autoCompleteBanco = this.AutoCompleteBanco; + Banco banco = this.ViewModel.SelectedCliente.get_Banco(); + if (banco != null) + { + nome = banco.get_Nome(); + } + else + { + nome = null; + } + autoCompleteBanco.set_Text(nome); + AutoCompleteBox autoCompleteAtividade = this.AutoCompleteAtividade; + Atividade atividade = this.ViewModel.SelectedCliente.get_Atividade(); + if (atividade != null) + { + str = atividade.get_Nome(); + } + else + { + str = null; + } + autoCompleteAtividade.set_Text(str); + AutoCompleteBox autoCompleteProfissao = this.AutoCompleteProfissao; + Profissao profissao = this.ViewModel.SelectedCliente.get_Profissao(); + if (profissao != null) + { + nome1 = profissao.get_Nome(); + } + else + { + nome1 = null; + } + autoCompleteProfissao.set_Text(nome1); + } + + private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e) + { + if (((TextBox)sender).IsReadOnly) + { + return; + } + TextBox textBox = (TextBox)sender; + string str = ValidationHelper.Clear(textBox.Text); + if (string.IsNullOrEmpty(str)) + { + return; + } + textBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14))); + if (textBox.Name == "DocumentoPrincipalBox") + { + this.ViewModel.JuridicaouFisica(this.DocumentoPrincipalBox.Text); + if (this.ViewModel.VisibilityFisica == System.Windows.Visibility.Visible) + { + this.ResponsavelBox.Text = string.Empty; + this.DocumentoResponsavel.Text = string.Empty; + this.EmailBox.Text = string.Empty; + } + } + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void ExcluirEmail_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(button); + ClienteEmail item = (ClienteEmail)listBox.Items[listBox.Items.IndexOf(button.DataContext)]; + this.ViewModel.ExcluirEmail(item); + } + + private void ExcluirEndereco_OnClick(object sender, RoutedEventArgs e) + { + Grid grid = Extentions.FindVisualAncestor((Button)sender); + ListBox listBox = Extentions.FindVisualAncestor(grid); + ClienteEndereco item = (ClienteEndereco)listBox.Items[listBox.Items.IndexOf(grid.DataContext)]; + this.ViewModel.ExcluirEndereco(item); + } + + private void ExcluirMaisContatos_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button == null || button.DataContext == null) + { + return; + } + MaisContato dataContext = (MaisContato)button.DataContext; + this.ViewModel.ExcluirContato(dataContext); + } + + private async void ExcluirOrigem_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button.DataContext != null) + { + this.ViewModel.Loading(true); + await this.ViewModel.ExcluirOrigem((OrigemCliente)button.DataContext); + this.ViewModel.Loading(false); + } + } + + private void ExcluirTelefone_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(button); + ClienteTelefone item = (ClienteTelefone)listBox.Items[listBox.Items.IndexOf(button.DataContext)]; + this.ViewModel.ExcluirTelefone(item); + } + + private void ExcluirVinculo_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button == null || button.DataContext == null) + { + return; + } + ClienteVinculo dataContext = (ClienteVinculo)button.DataContext; + this.ViewModel.ExcluirVinculo(dataContext); + } + + public override void FormatarDocumento(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + this.ViewModel.JuridicaouFisica(textBox.Text); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirCliente(); + this.DocumentoPrincipalBox.Text = ""; + this.AutoCompleteBanco.set_Text(""); + this.AutoCompleteProfissao.set_Text(""); + this.AutoCompleteAtividade.set_Text(""); + this.DocumentoPrincipalBox.Focus(); + this.ValidarTela(); + } + + private void IncluirEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirEmail(); + this.ValidarTela(); + } + + private void IncluirEndereco_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirEndereco(); + this.ValidarTela(); + } + + private void IncluirMaisContatos_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirContato(); + } + + private async void IncluirOrigem_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + await this.ViewModel.IncluirOrigem(this.NomeOrigemBox.Text.Trim()); + this.NomeOrigemBox.Text = string.Empty; + this.ViewModel.Loading(false); + } + + private void IncluirTelefone_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirTelefone(); + } + + private void IncluirVinculo_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.IncluirVinculo()) + { + this.VinculoBox.set_Text(""); + } + } + + [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/clienteview.xaml", UriKind.Relative)); + } + + private void InitializeResponsavelAssinatura() + { + object nomeResponsavel; + object documentoResponsavel; + object emailResponsavel; + TextBox responsavelBox = this.ResponsavelBox; + ResponsavelAssinatura responsavelAssinatura = this.ViewModel.SelectedCliente.get_ResponsavelAssinatura(); + if (responsavelAssinatura != null) + { + nomeResponsavel = responsavelAssinatura.get_NomeResponsavel(); + } + else + { + nomeResponsavel = null; + } + if (nomeResponsavel == null) + { + nomeResponsavel = string.Empty; + } + responsavelBox.Text = (string)nomeResponsavel; + TextBox textBox = this.DocumentoResponsavel; + ResponsavelAssinatura responsavelAssinatura1 = this.ViewModel.SelectedCliente.get_ResponsavelAssinatura(); + if (responsavelAssinatura1 != null) + { + documentoResponsavel = responsavelAssinatura1.get_DocumentoResponsavel(); + } + else + { + documentoResponsavel = null; + } + if (documentoResponsavel == null) + { + documentoResponsavel = string.Empty; + } + textBox.Text = (string)documentoResponsavel; + TextBox emailBox = this.EmailBox; + ResponsavelAssinatura responsavelAssinatura2 = this.ViewModel.SelectedCliente.get_ResponsavelAssinatura(); + if (responsavelAssinatura2 != null) + { + emailResponsavel = responsavelAssinatura2.get_EmailResponsavel(); + } + else + { + emailResponsavel = null; + } + if (emailResponsavel == null) + { + emailResponsavel = string.Empty; + } + emailBox.Text = (string)emailResponsavel; + } + + private void MenuItem_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogAntigo(); + } + + private void OrdemBox_OnLostFocus(object sender, RoutedEventArgs e) + { + int num; + int num1; + TextBox textBox = sender as TextBox; + if (textBox == null) + { + return; + } + if (textBox.IsReadOnly) + { + return; + } + if (!int.TryParse(textBox.Text, out num)) + { + return; + } + WrapPanel wrapPanel = Extentions.FindVisualAncestor(Extentions.FindVisualAncestor(textBox)); + ListBox listBox = Extentions.FindVisualAncestor(wrapPanel); + if (listBox != null) + { + for (int i = 0; i < listBox.Items.Count; i++) + { + if (i != listBox.Items.IndexOf(wrapPanel.DataContext)) + { + ContentPresenter contentPresenter = FindVisualChild.Find((ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(i)); + TextBox str = (TextBox)contentPresenter.ContentTemplate.FindName("OrdemBox", contentPresenter); + if (int.TryParse(str.Text, out num1) && num1 == num) + { + str.Text = ClienteView.Ordem.ToString(); + } + } + } + } + } + + private void OrdemBox_OnPreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + int num; + TextBox textBox = sender as TextBox; + if (textBox == null) + { + return; + } + if (!int.TryParse(textBox.Text, out num)) + { + return; + } + ClienteView.Ordem = num; + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + ContentPresenter contentPresenter; + DataTemplate contentTemplate; + ProgressBar progressBar; + TextBox textBox = (TextBox)sender; + if (!textBox.IsReadOnly) + { + if (!string.IsNullOrWhiteSpace(textBox.Text)) + { + string str = ValidationHelper.FormatPostCode(textBox.Text); + WrapPanel wrapPanel = Extentions.FindVisualAncestor(textBox); + ListBox listBox = Extentions.FindVisualAncestor(wrapPanel); + ListBoxItem listBoxItem = (ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(listBox.Items.IndexOf(wrapPanel.DataContext)); + contentPresenter = FindVisualChild.Find(listBoxItem); + contentTemplate = contentPresenter.ContentTemplate; + TextBox textBox1 = (TextBox)contentTemplate.FindName("CepBox", contentPresenter); + progressBar = (ProgressBar)contentTemplate.FindName("ProgressCep", contentPresenter); + progressBar.Visibility = System.Windows.Visibility.Visible; + textBox1.Text = str; + if (ValidationHelper.ValidatePostCode(str)) + { + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + TextBox endereco = (TextBox)contentTemplate.FindName("EnderecoBox", contentPresenter); + TextBox cidade = (TextBox)contentTemplate.FindName("CidadeBox", contentPresenter); + TextBox estado = (TextBox)contentTemplate.FindName("EstadoBox", contentPresenter); + TextBox bairro = (TextBox)contentTemplate.FindName("BairroBox", contentPresenter); + endereco.Text = enderecoBase.get_Endereco(); + cidade.Text = enderecoBase.get_Cidade(); + estado.Text = enderecoBase.get_Estado(); + bairro.Text = enderecoBase.get_Bairro(); + progressBar.Visibility = System.Windows.Visibility.Collapsed; + } + else + { + progressBar.Visibility = System.Windows.Visibility.Collapsed; + } + } + else + { + progressBar.Visibility = System.Windows.Visibility.Collapsed; + } + } + } + contentPresenter = null; + contentTemplate = null; + progressBar = null; + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.ViewModel.ProfissaoText = this.AutoCompleteProfissao.get_Text(); + this.ViewModel.AtividadeText = this.AutoCompleteAtividade.get_Text(); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs.Distinct>().ToList>(), this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + ClienteView.SetValid(this.AutoCompleteBanco, true); + } + } + + private static void SetValid(AutoCompleteBox autocomplete, bool valid) + { + ViewHelper.SetInvalid(autocomplete, "BANCO INVÁLIDO", valid); + } + + [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.MainGrid = (Grid)target; + return; + } + case 2: + { + this.IncluirClienteButton = (MenuItem)target; + this.IncluirClienteButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Tarefa_Click); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MenuItem_Click); + return; + } + case 12: + { + this.TipoDocumentoPrincipalBox = (ComboBox)target; + return; + } + case 13: + { + this.DocumentoPrincipalBox = (TextBox)target; + ClienteView clienteView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(clienteView.SomenteNumeros); + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + return; + } + case 14: + { + this.NomeBox = (TextBox)target; + return; + } + case 15: + { + this.NomeSocialBox = (TextBox)target; + return; + } + case 16: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewTextInput += new TextCompositionEventHandler(this.SomenteData); + return; + } + case 17: + { + this.CaepfBox = (TextBox)target; + return; + } + case 18: + { + this.RneBox = (TextBox)target; + return; + } + case 19: + { + this.CeiBox = (TextBox)target; + return; + } + case 20: + { + this.IdentidadeBox = (TextBox)target; + return; + } + case 21: + { + this.EmissorBox = (TextBox)target; + this.EmissorBox.PreviewTextInput += new TextCompositionEventHandler(this.SomenteCaracteres); + return; + } + case 22: + { + this.EstadoEmissorBox = (TextBox)target; + this.EstadoEmissorBox.PreviewTextInput += new TextCompositionEventHandler(this.SomenteCaracteres); + return; + } + case 23: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewTextInput += new TextCompositionEventHandler(this.SomenteData); + return; + } + case 24: + { + this.HabilitacaoBox = (TextBox)target; + ClienteView clienteView1 = this; + this.HabilitacaoBox.PreviewTextInput += new TextCompositionEventHandler(clienteView1.SomenteNumeros); + return; + } + case 25: + { + this.CategoriaHabilitacaooBox = (TextBox)target; + ClienteView clienteView2 = this; + this.CategoriaHabilitacaooBox.PreviewTextInput += new TextCompositionEventHandler(clienteView2.LetrasHabilitacao); + return; + } + case 26: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 27: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 28: + { + this.SexoBox = (ComboBox)target; + return; + } + case 29: + { + this.EstadoCivilBox = (ComboBox)target; + return; + } + case 30: + { + this.AutoCompleteProfissao = (AutoCompleteBox)target; + this.AutoCompleteProfissao.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteProfissaoBox_Populating)); + return; + } + case 31: + { + this.AutoCompleteAtividade = (AutoCompleteBox)target; + this.AutoCompleteAtividade.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteAtividadeBox_Populating)); + return; + } + case 32: + { + this.ResponsavelBox = (TextBox)target; + this.ResponsavelBox.LostFocus += new RoutedEventHandler(this.Validar_LostFocus); + return; + } + case 33: + { + this.DocumentoResponsavel = (TextBox)target; + ClienteView clienteView3 = this; + this.DocumentoResponsavel.PreviewTextInput += new TextCompositionEventHandler(clienteView3.SomenteNumeros); + this.DocumentoResponsavel.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + return; + } + case 34: + { + this.EmailBox = (TextBox)target; + this.EmailBox.LostFocus += new RoutedEventHandler(this.Validar_LostFocus); + return; + } + case 35: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + return; + } + case 36: + { + this.PastaBox = (TextBox)target; + return; + } + case 37: + { + this.AutoCompleteBanco = (AutoCompleteBox)target; + this.AutoCompleteBanco.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteBancoBox_Populating)); + this.AutoCompleteBanco.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.AutoCompleteBanco_OnLostKeyboardFocus); + return; + } + case 38: + { + this.AgenciaBox = (TextBox)target; + return; + } + case 39: + { + this.TipoContaBox = (TextBox)target; + return; + } + case 40: + { + this.ContaBox = (TextBox)target; + return; + } + case 41: + { + this.RendaMensalBox = (CurrencyTextBox)target; + return; + } + case 42: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTelefone_OnClick); + return; + } + case 43: + { + this.TelefoneListBox = (ListBox)target; + return; + } + case 44: + case 45: + case 46: + case 47: + case 48: + case 51: + case 52: + case 55: + case 56: + case 57: + case 60: + case 63: + { + this._contentLoaded = true; + return; + } + case 49: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirEmail_OnClick); + return; + } + case 50: + { + this.EmailListBox = (ListBox)target; + return; + } + case 53: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirEndereco_OnClick); + return; + } + case 54: + { + this.EnderecoListBox = (ListBox)target; + return; + } + case 58: + { + this.VinculoBox = (AutoCompleteBox)target; + this.VinculoBox.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteParentescoBox_Populating)); + return; + } + case 59: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirVinculo_OnClick); + return; + } + case 61: + { + this.NomeOrigemBox = (TextBox)target; + return; + } + case 62: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirOrigem_OnClick); + return; + } + case 64: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirMaisContatos_OnClick); + return; + } + case 65: + { + this.ContatosListBox = (ListBox)target; + return; + } + default: + { + this._contentLoaded = true; + return; + } + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 44: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBox_OnSelectionChanged); + return; + } + case 45: + { + ClienteView clienteView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView.SomenteNumeros); + return; + } + case 46: + { + ClienteView clienteView1 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(clienteView1.FormatarTelefone); + ClienteView clienteView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView2.SomenteNumeros); + return; + } + case 47: + { + ((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus); + ClienteView clienteView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView3.SomenteNumeros); + return; + } + case 48: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirTelefone_OnClick); + return; + } + case 49: + case 50: + case 53: + case 54: + case 58: + case 59: + case 61: + case 62: + case 64: + case 65: + { + return; + } + case 51: + { + ((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus); + ClienteView clienteView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView4.SomenteNumeros); + return; + } + case 52: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirEmail_OnClick); + return; + } + case 55: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + ClienteView clienteView5 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView5.SomenteNumeros); + return; + } + case 56: + { + ((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus); + ClienteView clienteView6 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView6.SomenteNumeros); + return; + } + case 57: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirEndereco_OnClick); + return; + } + case 60: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirVinculo_OnClick); + return; + } + case 63: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirOrigem_OnClick); + return; + } + case 66: + { + ClienteView clienteView7 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(clienteView7.FormatarDocumento); + return; + } + case 67: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).PreviewTextInput += new TextCompositionEventHandler(this.SomenteData); + return; + } + case 68: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBox_OnSelectionChanged); + return; + } + case 69: + { + ClienteView clienteView8 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView8.SomenteNumeros); + return; + } + case 70: + { + ClienteView clienteView9 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(clienteView9.FormatarTelefone); + ClienteView clienteView10 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView10.SomenteNumeros); + return; + } + case 71: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirMaisContatos_OnClick); + return; + } + default: + { + return; + } + } + } + + private void Tarefa_Click(object sender, RoutedEventArgs e) + { + Tarefa tarefa = new Tarefa(); + tarefa.set_IdCliente(this.ViewModel.SelectedCliente.get_Id()); + tarefa.set_Cliente(this.ViewModel.SelectedCliente.get_Nome()); + tarefa.set_Entidade(2); + tarefa.set_IdEntidade(this.ViewModel.SelectedCliente.get_Id()); + tarefa.set_Titulo(this.ViewModel.SelectedCliente.get_Nome()); + this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa, true), 0, false); + } + + private void TipoComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + int num; + ComboBox comboBox = (ComboBox)sender; + CustomIsReadOnlyControl customIsReadOnlyControl = Extentions.FindVisualAncestor(comboBox); + if (customIsReadOnlyControl == null) + { + return; + } + WrapPanel wrapPanel = Extentions.FindVisualAncestor(customIsReadOnlyControl); + ListBox listBox = Extentions.FindVisualAncestor(wrapPanel); + ContentPresenter contentPresenter = FindVisualChild.Find((ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(listBox.Items.IndexOf(wrapPanel.DataContext))); + DataTemplate contentTemplate = contentPresenter.ContentTemplate; + CustomItemValidation customItemValidation = (CustomItemValidation)contentTemplate.FindName("Prefixo", contentPresenter); + CustomItemValidation customItemValidation1 = (CustomItemValidation)contentTemplate.FindName("Telefone", contentPresenter); + TextBox textBox = ViewHelper.FindChildren(customItemValidation).FirstOrDefault(); + TextBox textBox1 = ViewHelper.FindChildren(customItemValidation1).FirstOrDefault(); + if (textBox == null || textBox1 == null) + { + return; + } + if ((TipoTelefone)comboBox.SelectedValue == 8) + { + customItemValidation.Visibility = System.Windows.Visibility.Collapsed; + textBox1.MaxLength = 20; + return; + } + customItemValidation.Visibility = System.Windows.Visibility.Visible; + textBox1.MaxLength = 10; + num = (textBox1.Text.Length >= 10 ? 10 : textBox1.Text.Length); + textBox1.Text = textBox1.Text.Substring(0, num); + } + + private void Validar_LostFocus(object sender, RoutedEventArgs e) + { + this.ValidarTela(); + } + + private void ValidarTela() + { + object keyValuePairs; + object obj; + object keyValuePairs1; + if (this.ViewModel.SelectedCliente == null) + { + return; + } + List> keyValuePairs2 = this.ViewModel.SelectedCliente.Validate(); + if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 29)) + { + List> keyValuePairs3 = keyValuePairs2; + ClienteEmail clienteEmail = this.ViewModel.Emails.FirstOrDefault(); + if (clienteEmail != null) + { + keyValuePairs1 = clienteEmail.Validate(); + } + else + { + keyValuePairs1 = null; + } + if (keyValuePairs1 == null) + { + keyValuePairs1 = new List>(); + } + keyValuePairs3.AddRange((IEnumerable)keyValuePairs1); + } + List> keyValuePairs4 = keyValuePairs2; + ClienteTelefone clienteTelefone = this.ViewModel.Telefones.FirstOrDefault(); + if (clienteTelefone != null) + { + keyValuePairs = clienteTelefone.Validate(); + } + else + { + keyValuePairs = null; + } + if (keyValuePairs == null) + { + keyValuePairs = new List>(); + } + keyValuePairs4.AddRange((IEnumerable)keyValuePairs); + List> keyValuePairs5 = keyValuePairs2; + ClienteEndereco clienteEndereco = this.ViewModel.Enderecos.FirstOrDefault(); + if (clienteEndereco != null) + { + obj = clienteEndereco.Validate(); + } + else + { + obj = null; + } + if (obj == null) + { + obj = new List>(); + } + keyValuePairs5.AddRange((IEnumerable)obj); + this.ValidateFields(keyValuePairs2, false); + } + } +} \ No newline at end of file -- cgit v1.2.3