From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Views/Seguros/ApoliceView.cs | 3609 ++++++++++++++++++++ .../Views/Seguros/ClienteView.cs | 1307 +++++++ .../Views/Seguros/ComissaoView.cs | 1336 ++++++++ .../Views/Seguros/ConsultaOriginalView.cs | 1502 ++++++++ .../Views/Seguros/CriticaApoliceView.cs | 2010 +++++++++++ .../Views/Seguros/Itens/AeronauticoView.cs | 373 ++ .../Views/Seguros/Itens/AutoView.cs | 718 ++++ .../Views/Seguros/Itens/BuscarModeloView.cs | 85 + .../Views/Seguros/Itens/ConsorcioView.cs | 320 ++ .../Views/Seguros/Itens/GranizoView.cs | 383 +++ .../Views/Seguros/Itens/PatrimonialView.cs | 466 +++ .../Views/Seguros/Itens/RiscosDiversosView.cs | 683 ++++ .../Views/Seguros/Itens/VidaView.cs | 705 ++++ .../Views/Seguros/PerfilEmpresaView.cs | 267 ++ .../Gestor.Application/Views/Seguros/PerfilView.cs | 320 ++ .../Views/Seguros/SinistroView.cs | 1003 ++++++ .../Views/Seguros/TrocarClienteView.cs | 154 + 17 files changed, 15241 insertions(+) create mode 100644 Codemerx/Gestor.Application/Views/Seguros/ApoliceView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/ClienteView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/ComissaoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/ConsultaOriginalView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/CriticaApoliceView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/AeronauticoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/AutoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/BuscarModeloView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/ConsorcioView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/GranizoView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/PatrimonialView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/RiscosDiversosView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/Itens/VidaView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/PerfilEmpresaView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/PerfilView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/SinistroView.cs create mode 100644 Codemerx/Gestor.Application/Views/Seguros/TrocarClienteView.cs (limited to 'Codemerx/Gestor.Application/Views/Seguros') diff --git a/Codemerx/Gestor.Application/Views/Seguros/ApoliceView.cs b/Codemerx/Gestor.Application/Views/Seguros/ApoliceView.cs new file mode 100644 index 0000000..60dd854 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/ApoliceView.cs @@ -0,0 +1,3609 @@ +using CurrencyTextBoxControl; +using Gestor.Application.Actions; +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; +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; + +namespace Gestor.Application.Views.Seguros +{ + public class ApoliceView : BaseUserControl, IComponentConnector, IStyleConnector + { + private string _vencimentoCartaoOld = ""; + + private bool _calculando; + + internal DockPanel MenuApolice; + + internal MenuItem IncluirpoliceButton; + + internal MenuItem AlterarApoliceButton; + + internal MenuItem SalvarApoliceButton; + + internal MenuItem CancelarApoliceButton; + + internal MenuItem ExcluirpoliceButton; + + internal Button ButtonImportado; + + internal MenuItem ArquivoDigitalButton; + + internal MenuItem MaisOpcoesButton; + + internal MenuItem EditarParcelasButton; + + internal WrapPanel ApoliceControl1; + + internal ComboBox ProdutoBox; + + internal ComboBox SituacaoBox; + + internal ComboBox NegocioCorretoraBox; + + internal ComboBox TipoRecebimentoBox; + + internal ComboBox TipoEndossoBox; + + internal TextBox ApoliceBox; + + internal TextBox EndossoBox; + + internal DatePicker Vigencia2Box; + + internal DatePicker TransmissaoBox; + + internal DatePicker EmissaoBox; + + internal ComboBox FormaPagamentoBox; + + internal Grid PremiosBox; + + internal ToggleButton AdicionalBox; + + internal CustomIsReadOnlyControl Comissao; + + internal CurrencyTextBox ComissaoBox; + + internal CurrencyTextBox PremioLiquidoBox; + + internal CurrencyTextBox PremioAdicionalBox; + + internal CurrencyTextBox IofBox; + + internal CurrencyTextBox DiferencaBox; + + internal CurrencyTextBox PremioTotalBox; + + internal CurrencyTextBox ParcelasBox; + + internal CustomIsReadOnlyControl ComissaoOriginal; + + internal CustomIsReadOnlyControl Gerada; + + internal CustomIsReadOnlyControl Recebida; + + internal CustomIsReadOnlyControl Pendente; + + internal CustomIsReadOnlyControl Repasse; + + internal Menu BaixarParcelaButton; + + internal Menu SalvarParcelaButton; + + internal StackPanel EditarParcelasFields; + + internal CustomItemValidation TipoParcelaField; + + internal ComboBox TipoParcelaBox; + + internal CustomItemControl QuantidadeFaturaField; + + internal CurrencyTextBox QuantidadeFaturaBox; + + internal CustomItemValidation FaturaField; + + internal TextBox FaturaBox; + + internal CustomItemValidation VigenciaInicialField; + + internal CustomItemValidation VigenciaFinalField; + + internal DatePicker VigenciaFinalParcelaBox; + + internal CustomItemValidation VencimentoField; + + internal CustomItemControl EmissaoField; + + internal DatePicker EmissaoParcelaBox; + + internal CustomItemValidation PercentualComissaoField; + + internal CurrencyTextBox ComissaoParcelaBox; + + internal TextBlock ComissaoIcon; + + internal CustomItemControl ValorLiquidoField; + + internal CurrencyTextBox ValorLiquidoParcelaBox; + + internal CustomItemControl ValorField; + + internal CurrencyTextBox ValorParcelaBox; + + internal CustomItemValidation RecebimentoField; + + internal DatePicker RecebimentoParcelaBox; + + internal CustomItemControl QuitacaoField; + + internal CustomItemControl DataControleParcelaField; + + internal CustomItemValidation CreditoField; + + internal DatePicker CreditoParcelaBox; + + internal CustomItemValidation ValorRealizadoField; + + internal CurrencyTextBox ValorRealizadoParcelaBox; + + internal CustomItemValidation ValorComissaoField; + + internal CurrencyTextBox ValorComissaoParcelaBox; + + internal WrapPanel ImpostosField; + + internal CustomItemControl PorcentagemIrField; + + internal CurrencyTextBox PorcentagemIrBox; + + internal CustomItemControl ValorIrField; + + internal CurrencyTextBox ValorIrBox; + + internal CustomItemControl PorcentagemIssField; + + internal CurrencyTextBox PorcentagemIssBox; + + internal CustomItemControl ValorIssField; + + internal CurrencyTextBox ValorIssBox; + + internal CustomItemControl ValorOutrosField; + + internal CurrencyTextBox ValorOutrosBox; + + internal CustomItemControl ValorDescontoField; + + internal CurrencyTextBox ValorDescontoBox; + + internal CustomItemControl ValorComDescField; + + internal CurrencyTextBox ValorComDescBox; + + internal DataGrid ParcelaGrid; + + internal DataGridTextColumn ParcelaColumn; + + internal DataGridTextColumn FaturaColumn; + + internal DataGridTextColumn VigenciaInicialColumn; + + internal DataGridTextColumn VigenciaFinalColumn; + + internal DataGridTextColumn ParcelasComissaoColumn; + + internal DataGridTextColumn ParcelasValorComissaoColumn; + + internal DataGridTextColumn ParcelasValorComissaoDescColumn; + + internal DataGridTemplateColumn MaisInformacoesColumn; + + internal MenuItem EditarVendedorButton; + + internal MenuItem SalvarVendedorButton; + + internal MenuItem CancelarVendedorButton; + + internal WrapPanel EditarVendedorFields; + + internal ToggleButton CoCorretagemToogle; + + internal ComboBox TipoVendedorBox; + + internal ComboBox VendedorBox; + + internal CustomItemValidation ComissaoNovoBox; + + internal ComboBox ComissaoNovoComboBox; + + internal CustomItemValidation ComissaoRenovacaoBox; + + internal ComboBox ComissaoRenovacaoComboBox; + + internal CurrencyTextBox ValorRepasseBox; + + internal TextBox FormaRecebidaBox; + + internal TextBox FormaIncidenciaBox; + + internal DataGrid VendedorGrid; + + internal DataGridTextColumn VendedorGridColumn; + + internal DataGridTextColumn PagamentosPorcentagemRepasseColumn; + + internal DataGridTextColumn PagamentosValorRepasseColumn; + + internal TextBox ProponenteBox; + + internal AutoCompleteBox AutoCompleteBanco; + + internal TextBox AgenciaBox; + + internal TextBox ContaBox; + + internal TextBox CartaoBox; + + internal ComboBox BandeiraBox; + + internal TextBox VencimentoCartaoBox; + + internal DatePicker DataBox; + + internal TextBox PastaBox; + + private bool _contentLoaded; + + private Gestor.Model.Common.AcessoApolice AcessoApolice + { + get; + } + + private int EditarParcelaTipo + { + get; + set; + } + + public ApoliceViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ApoliceView(Documento documentoSelecionado, bool lockInsert = false, bool invoke = true, Gestor.Model.Common.AcessoApolice acesso = 0, long idparcela = 0L, bool consultaTela = false) + { + string str; + base.Tag = "CADASTRO DE APÓLICE"; + this.AcessoApolice = acesso; + Gestor.Application.Actions.Actions.Redimencionar = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.Redimencionar, new Action(this.Redimencionar)); + this.ViewModel = new ApoliceViewModel(acesso, documentoSelecionado, invoke, idparcela); + 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 + { + } + this.ParcelaGrid.DataContext = this.ViewModel; + if (consultaTela) + { + this.ExcluirpoliceButton.IsEnabled = false; + } + this.Restricao(false); + if (lockInsert) + { + this.IncluirpoliceButton.IsEnabled = false; + } + if (documentoSelecionado != null) + { + if (documentoSelecionado.get_Tipo() == 0 && string.IsNullOrEmpty(documentoSelecionado.get_Apolice())) + { + str = string.Concat("PROPOSTA \"", documentoSelecionado.get_Proposta(), "\""); + } + else if (documentoSelecionado.get_Tipo() != 0 || string.IsNullOrEmpty(documentoSelecionado.get_Apolice())) + { + str = (string.IsNullOrEmpty(documentoSelecionado.get_Endosso()) ? string.Concat("PROPOSTA DE ENDOSSO \"", documentoSelecionado.get_PropostaEndosso(), "\"") : string.Concat("ENDOSSO \"", documentoSelecionado.get_Endosso(), "\"")); + } + else + { + str = string.Concat("APÓLICE \"", documentoSelecionado.get_Apolice(), "\""); + } + string str1 = str; + this.ViewModel.RegistrarAcao(string.Concat("ACESSOU ", str1), documentoSelecionado.get_Id(), new TipoTela?(2), this.ViewModel.GerarObs(documentoSelecionado)); + } + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + FiltroArquivoDigital filtroArquivoDigital = null; + string name = ""; + Button button = sender as Button; + if (button != null) + { + name = button.Name; + } + else + { + MenuItem menuItem = sender as MenuItem; + if (menuItem != null) + { + name = menuItem.Name; + } + } + if (name != "ArquivoDigitalButton") + { + if (name == "Parcela") + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 3).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital1 = new FiltroArquivoDigital(); + filtroArquivoDigital1.set_Id(this.ViewModel.SelectedParcela.get_Id()); + filtroArquivoDigital1.set_IdApolice(this.ViewModel.SelectedParcela.get_Documento().get_Id()); + filtroArquivoDigital1.set_Tipo(3); + filtroArquivoDigital1.set_Parente(this.ViewModel.SelectedParcela); + filtroArquivoDigital = filtroArquivoDigital1; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)3), "."), "OK", "", false); + return; + } + } + } + else if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital2 = new FiltroArquivoDigital(); + filtroArquivoDigital2.set_Id(this.ViewModel.SelectedDocumento.get_Id()); + filtroArquivoDigital2.set_Tipo(2); + filtroArquivoDigital2.set_Parente(this.ViewModel.SelectedDocumento); + filtroArquivoDigital = filtroArquivoDigital2; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)2), "."), "OK", "", false); + return; + } + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + } + + private async void AbrirImportacao() + { + await this.ViewModel.Importacao(); + ((System.Windows.Controls.ToolTip)this.ButtonImportado.ToolTip).PlacementTarget = this.ButtonImportado; + ((System.Windows.Controls.ToolTip)this.ButtonImportado.ToolTip).Placement = PlacementMode.Center; + ((System.Windows.Controls.ToolTip)this.ButtonImportado.ToolTip).IsOpen = true; + await Task.Run(async () => await Task.Delay(5000)); + ((System.Windows.Controls.ToolTip)this.ButtonImportado.ToolTip).IsOpen = false; + } + + private void AbrirInfo_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirInfo(); + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Id() != 0) + { + this.ViewModel.AbrirLog(2, this.ViewModel.SelectedDocumento.get_Id()); + } + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Id() != 0) + { + this.ViewModel.AbrirLogEmail(2, this.ViewModel.SelectedDocumento.get_Id()); + } + } + + private void AbrirLogEmailPF_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedParcela != null && this.ViewModel.SelectedParcela.get_Id() != 0) + { + this.ViewModel.AbrirLogEmail(5, this.ViewModel.SelectedParcela.get_Id()); + } + } + + private void AbrirLogParcelaAntigo_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogAntigoParcela(); + } + + private async void AbrirLogParcelas_OnClick(object sender, RoutedEventArgs e) + { + bool count; + ApoliceView apoliceView = this; + if (apoliceView.ViewModel.SelectedDocumento != null) + { + ApoliceViewModel viewModel = apoliceView.ViewModel; + if (viewModel != null) + { + count = viewModel.Parcelas.Count > 0; + } + else + { + count = false; + } + if (count) + { + List nums = new List(); + apoliceView.ViewModel.Parcelas.ToList().ForEach((Parcela x) => nums.Add(x.get_Id())); + apoliceView.ViewModel.AbrirLogParcela(nums, apoliceView.ViewModel.SelectedDocumento.get_Id(), 0); + } + } + } + + private void AbrirLogParcelaSelecionada_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedParcela != null && this.ViewModel.SelectedParcela.get_Id() != 0) + { + List nums = new List() + { + this.ViewModel.SelectedParcela.get_Id() + }; + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Id() != 0) + { + this.ViewModel.AbrirLogParcela(nums, this.ViewModel.SelectedDocumento.get_Id(), this.ViewModel.SelectedParcela.get_NumeroParcela()); + } + } + } + + private void AbrirLogTrocaCliente_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Id() != 0) + { + this.ViewModel.AbrirLog(41, this.ViewModel.SelectedDocumento.get_Id()); + } + } + + private void AbrirLogVendedor_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedParcela != null && this.ViewModel.SelectedParcela.get_Id() != 0) + { + this.ViewModel.AbrirLog(37, this.ViewModel.SelectedParcela.get_Id()); + } + } + + private async void AbrirPerfil_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.VerificarPermissao(32, false)) + { + if (this.ViewModel.SelectedDocumento.get_Controle().get_Ramo().get_Id() != (long)5) + { + (new HosterWindow(new PerfilEmpresaView(this.ViewModel.SelectedDocumento.get_Controle()), "QUESTIONÁRIO EMPRESA", new double?((double)900), new double?((double)500), false)).ShowDialog(); + } + else + { + (new HosterWindow(new PerfilView(this.ViewModel.SelectedDocumento.get_Controle()), "PERFIL", new double?((double)900), new double?((double)500), false)).ShowDialog(); + } + this.ViewModel.Alterar(false); + } + } + + private async Task AbrirProspeccao(Prospeccao data) + { + do + { + Label1: + if (await this.ViewModel.ShowProspeccaoDialog(data) != null) + { + List> keyValuePairs = await this.ViewModel.SalvarProspeccao(data); + if (keyValuePairs == null || keyValuePairs.Count == 0) + { + this.ViewModel.ToggleSnackBar("PROSPECÇÃO SALVA COM SUCESSO.", true); + return; + } + else + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + goto Label1; + } + } + else + { + } + } + while (!await this.ViewModel.ShowMessage("DESEJA REALMENTE NÃO CADASTRAR UMA PROSPECÇÃO PARA ESSE DOCUMENTO?", "SIM", "NÃO", false)); + } + + private void AcessarApolice(Gestor.Model.Common.AcessoApolice acesso) + { + if (acesso == 2) + { + this.Endossar_OnClick(this, new RoutedEventArgs()); + this.Restricao(true); + return; + } + if (acesso != 3) + { + return; + } + this.Renovar_OnClick(this, new RoutedEventArgs()); + this.Restricao(true); + } + + private void AdicionalBox_OnChecked(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + this.AlteracaoDePremio_LostFocus(this.PremioAdicionalBox, new RoutedEventArgs()); + } + + private void AdicionarCoCorretagem_OnClick(object sender, RoutedEventArgs e) + { + bool valueOrDefault; + bool selectedItem; + bool flag; + ToggleButton toggleButton = (ToggleButton)sender; + if (toggleButton != null) + { + valueOrDefault = toggleButton.IsChecked.GetValueOrDefault(); + } + else + { + valueOrDefault = false; + } + bool flag1 = valueOrDefault; + ComboBox comissaoNovoComboBox = this.ComissaoNovoComboBox; + if (comissaoNovoComboBox != null) + { + selectedItem = comissaoNovoComboBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (selectedItem) + { + this.ComissaoNovoComboBox.SelectedItem = null; + } + if (flag1) + { + this.TipoVendedorBox.SelectedIndex = 0; + } + else if (this.TipoVendedorBox.SelectedItem != null) + { + this.TipoVendedorBox.SelectedItem = null; + } + ComboBox vendedorBox = this.VendedorBox; + if (vendedorBox != null) + { + flag = vendedorBox.SelectedItem; + } + else + { + flag = false; + } + if (flag) + { + this.VendedorBox.SelectedItem = null; + } + if (ValidationHelper.IsNotNullOrEmpty(this.ValorRepasseBox.Text)) + { + this.ValorRepasseBox.Text = ""; + } + this.ViewModel.VendedorCoCorretagem(flag1); + } + + private void AlteracaoDePremio_LostFocus(object sender, RoutedEventArgs e) + { + decimal iof; + if (!this.ViewModel.AllowEditApolice) + { + return; + } + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + CurrencyTextBox currencyTextBox = (CurrencyTextBox)sender; + if (currencyTextBox == null) + { + return; + } + string name = currencyTextBox.Name; + if ((name == "PremioLiquidoBox" || name == "PremioAdicionalBox") && this.IofBox.get_Number() == decimal.Zero) + { + decimal number = this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number(); + Ramo ramo = this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(); + if (ramo != null) + { + iof = ramo.get_Iof(); + } + else + { + iof = decimal.Zero; + } + decimal num = number * iof; + this.IofBox.set_Number(num); + CurrencyTextBox premioTotalBox = this.PremioTotalBox; + premioTotalBox.set_Number(premioTotalBox.get_Number() + num); + } + this.PremioTotalBox.set_Number(((this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number()) + this.IofBox.get_Number()) + this.DiferencaBox.get_Number()); + name = currencyTextBox.Name; + if ((name == "PremioLiquidoBox" || name == "PremioAdicionalBox" || name == "ComissaoBox") && this.ViewModel.HabilitarVendedor(0).Count == 0) + { + this.ViewModel.RecalculaRepasses(); + } + this.ValidarDocumento(); + } + + private void AlteracaoParcela_LostFocus(object sender, RoutedEventArgs e) + { + this.ValidarDocumento(); + } + + public void AlterandoDocumento(bool alterando) + { + PermissaoUsuario permissaoUsuario = this.ViewModel.ServicoPermissUsuario.BuscarPermissao(Recursos.Usuario, 2); + this.EditarVendedorButton.IsEnabled = ((permissaoUsuario != null ? permissaoUsuario.get_Incluir() : true) ? !alterando : false); + } + + private async void Alterar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.UpdatePremio = false; + this.Restricao(false); + ApoliceViewModel viewModel = this.ViewModel; + List configuracoes = Recursos.Configuracoes; + if (configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 34)) + { + flag = true; + } + else + { + List repasses = this.ViewModel.Repasses; + flag = repasses.All((VendedorParcela x) => !x.get_DataPagamento().HasValue); + } + viewModel.EnableControle = flag; + ApoliceViewModel apoliceViewModel = this.ViewModel; + List vendedorParcelas = this.ViewModel.Repasses; + apoliceViewModel.CoCorretagem = vendedorParcelas.Any((VendedorParcela x) => { + Gestor.Model.Domain.Seguros.Repasse repasse = x.get_Repasse(); + if (repasse == null) + { + return false; + } + return repasse.get_Tipo().GetValueOrDefault() == 3; + }); + this.ViewModel.VerificaCoCorretagem(); + await this.ViewModel.Alteracao(true); + this.ViewModel.Alterar(true); + this.ValidarTela(); + this.AlterandoDocumento(true); + this.ExcluirpoliceButton.IsEnabled = false; + this.IncluirpoliceButton.IsEnabled = false; + this.AlterarApoliceButton.IsEnabled = false; + this.ViewModel.Inclusao = false; + } + + private void AlterarParcela() + { + this.FaturaField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.QuantidadeFaturaField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaInicialField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaFinalField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ValorLiquidoField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.PercentualComissaoField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ComissaoIcon.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.EmissaoField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.RecebimentoField.Visibility = System.Windows.Visibility.Collapsed; + this.QuitacaoField.Visibility = System.Windows.Visibility.Visible; + this.DataControleParcelaField.Visibility = System.Windows.Visibility.Visible; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Collapsed; + this.CreditoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.VencimentoField.Visibility = System.Windows.Visibility.Visible; + this.ValorField.Visibility = System.Windows.Visibility.Visible; + this.TipoParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.VencimentoField.Visibility = System.Windows.Visibility.Visible; + this.ValorField.Visibility = System.Windows.Visibility.Visible; + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Visible; + this.ValidarParcela(); + } + + private void AlterarParcela_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.QuantidadeFaturas = 1; + if (this.ViewModel.Parcelas.Count == 0) + { + return; + } + this.ToggleBotoesParcela(true); + this.EditarParcelaTipo = 1; + this.ViewModel.SelecionaPrimeiraParcela(); + this.AlterarParcela(); + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.AllowEditVendedor = this.ViewModel.IsFatura; + } + + private void ApoliceControl_SizeChanged(object sender, SizeChangedEventArgs e) + { + bool flag; + if (e != null) + { + Size newSize = e.NewSize; + flag = false; + } + else + { + flag = true; + } + if (flag) + { + return; + } + this.Redimencionar(e.NewSize.Width); + } + + private async void ApoliceView_OnLoaded(object sender, RoutedEventArgs e) + { + while (!this.ViewModel.Loaded) + { + await Task.Delay(100); + } + this.AcessarApolice(this.AcessoApolice); + } + + private void AutoCompleteBanco_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + ApoliceView.SetValid(autoCompleteBox, (string.IsNullOrWhiteSpace(autoCompleteBox.get_Text()) ? true : this.ViewModel.SelectedDocumento.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 BaixarParcelas() + { + this.FaturaField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaInicialField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaFinalField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.PercentualComissaoField.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ComissaoIcon.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.QuantidadeFaturaField.Visibility = System.Windows.Visibility.Collapsed; + this.QuitacaoField.Visibility = System.Windows.Visibility.Collapsed; + this.DataControleParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.EmissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorLiquidoField.Visibility = System.Windows.Visibility.Visible; + this.VencimentoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorField.Visibility = System.Windows.Visibility.Collapsed; + this.TipoParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.RecebimentoField.Visibility = System.Windows.Visibility.Visible; + this.CreditoField.Visibility = System.Windows.Visibility.Visible; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Visible; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Visible; + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Visible; + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5)) + { + this.ImpostosField.Visibility = System.Windows.Visibility.Visible; + } + this.ParcelaGrid.IsEnabled = false; + this.ValidarParcela(); + this.RecebimentoParcelaBox.Focus(); + } + + private async void BaixarParcelas_Click(object sender, RoutedEventArgs e) + { + this.ParcelaGrid.IsEnabled = false; + ((MenuItem)sender).Click -= new RoutedEventHandler(this.BaixarParcelas_Click); + this.ViewModel.QuantidadeFaturas = 1; + if (await this.ViewModel.SelecionarParcelaBaixa()) + { + this.ToggleBotoesParcela(true); + this.ViewModel.BaixarParcelas = true; + await this.ViewModel.CarregarImposto(); + this.EditarParcelaTipo = 2; + this.BaixarParcelas(); + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarParcelas_Click); + this.ViewModel.AllowEditVendedor = false; + } + } + + private async void Button_Click(object sender, RoutedEventArgs e) + { + bool flag = this.ViewModel.Restricao(97); + if (!flag) + { + Documento documento = this.ViewModel.AbrirDetalhes(); + this.ViewModel.ShowDrawer(new ValoresApoliceDrawer(documento), 0, true); + } + if (flag) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR MAIS INFORMAÇÕES.", "OK", "", false); + } + } + + private void CalculoComissao_OnNumberChanged(object sender, EventArgs e) + { + bool id; + bool flag; + bool id1; + bool flag1; + bool id2; + bool flag2; + if (!this.ViewModel.BaixarParcelas || this._calculando) + { + return; + } + this._calculando = true; + decimal number = this.ValorComissaoParcelaBox.get_Number(); + this.PorcentagemIrBox.remove_NumberChanged(new EventHandler(this.PorcentagemIrBox_OnNumberChanged)); + this.PorcentagemIssBox.remove_NumberChanged(new EventHandler(this.PorcentagemIssBox_OnNumberChanged)); + Imposto imposto = this.ViewModel.Imposto; + if (imposto != null) + { + id = imposto.get_Id() > (long)0; + } + else + { + id = false; + } + if (id) + { + this.PorcentagemIrBox.set_Number(this.ViewModel.Imposto.get_Ir() * new decimal(100)); + } + Imposto imposto1 = this.ViewModel.Imposto; + if (imposto1 != null) + { + flag = imposto1.get_Id() > (long)0; + } + else + { + flag = false; + } + if (flag) + { + this.PorcentagemIssBox.set_Number(this.ViewModel.Imposto.get_Iss() * new decimal(100)); + } + this.PorcentagemIrBox.add_NumberChanged(new EventHandler(this.PorcentagemIrBox_OnNumberChanged)); + this.PorcentagemIssBox.add_NumberChanged(new EventHandler(this.PorcentagemIssBox_OnNumberChanged)); + Imposto imposto2 = this.ViewModel.Imposto; + if (imposto2 != null) + { + id1 = imposto2.get_Id() > (long)0; + } + else + { + id1 = false; + } + decimal num = (id1 ? number * this.ViewModel.Imposto.get_Ir() : this.ValorIrBox.get_Number()); + if (this.ValorIrBox.get_Number() != num) + { + this.ViewModel.SelectedParcela.set_Irr(num); + } + Imposto imposto3 = this.ViewModel.Imposto; + if (imposto3 != null) + { + flag1 = imposto3.get_Id() > (long)0; + } + else + { + flag1 = false; + } + decimal num1 = (flag1 ? number * this.ViewModel.Imposto.get_Iss() : this.ValorIssBox.get_Number()); + if (this.ValorIssBox.get_Number() != num1) + { + this.ViewModel.SelectedParcela.set_Iss(num1); + } + Imposto imposto4 = this.ViewModel.Imposto; + if (imposto4 != null) + { + id2 = imposto4.get_Id() > (long)0; + } + else + { + id2 = false; + } + decimal num2 = (id2 ? number * this.ViewModel.Imposto.get_Outros() : this.ValorOutrosBox.get_Number()); + if (this.ValorOutrosBox.get_Number() != num2) + { + this.ViewModel.SelectedParcela.set_Outros(num2); + } + Imposto imposto5 = this.ViewModel.Imposto; + if (imposto5 != null) + { + flag2 = imposto5.get_Id() > (long)0; + } + else + { + flag2 = false; + } + decimal num3 = (flag2 ? number * this.ViewModel.Imposto.get_Desconto() : this.ValorDescontoBox.get_Number()); + if (this.ValorDescontoBox.get_Number() != num3) + { + this.ViewModel.SelectedParcela.set_Desconto(num3); + } + this.ValorComDescBox.set_Number((((number - num) - num1) - num2) - num3); + this.ViewModel.OnPropertyChanged("SelectedParcela"); + this._calculando = false; + } + + private void CancelarAlteracao() + { + ApoliceView.SetValid(this.AutoCompleteBanco, true); + this.AutoCompleteBanco.set_Text(string.Empty); + this.ViewModel.BotoesParcelaEnabled = true; + this.ViewModel.AlteracaoEnabled = true; + this.EditarVendedor(false); + this.ValidarDocumento(); + } + + private async void CancelarApolice_OnClick(object sender, RoutedEventArgs e) + { + this.CancelarAlteracao(); + await this.ViewModel.CancelarAlteracao(); + this.AlterandoDocumento(false); + this.EditandoVendedor(false); + this.Restricao(false); + } + + private void CancelarParcela_Click(object sender, RoutedEventArgs e) + { + this.ToggleBotoesParcela(false); + this.ViewModel.BaixarParcelas = false; + this.ViewModel.CancelPagamento(); + this.ValidarDocumento(); + this.EditarVendedor(false); + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(true); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(true); + } + else + { + } + this.EditandoParcela(false); + } + + private void CancelarVendedor_Click(object sender, RoutedEventArgs e) + { + this.EditarVendedor(false); + this.ViewModel.SelectedPagamento = null; + this.ViewModel.AllowEditParcela = true; + this.EditandoVendedor(false); + } + + private void ComissaoVendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + decimal? valorRepasse; + bool valueOrDefault; + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + Gestor.Model.Domain.Seguros.Repasse selectedItem = (Gestor.Model.Domain.Seguros.Repasse)comboBox.SelectedItem; + if (selectedItem != null && selectedItem.get_Tipo().GetValueOrDefault() == 3) + { + this.ViewModel.SelectedPagamento.set_ValorRepasse(new decimal?(new decimal(0, 0, 0, false, 2))); + CurrencyTextBox valorRepasseBox = this.ValorRepasseBox; + valorRepasse = this.ViewModel.SelectedPagamento.get_ValorRepasse(); + valorRepasseBox.set_Number(valorRepasse.Value); + return; + } + if (this.ViewModel.SelectedDocumento.get_NegocioCorretora().HasValue) + { + NegocioCorretora? negocioCorretora = this.ViewModel.SelectedDocumento.get_NegocioCorretora(); + valueOrDefault = negocioCorretora.GetValueOrDefault() == 1; + } + else if (this.ViewModel.SelectedDocumento.get_Situacao() != 2 || !this.ViewModel.SelectedDocumento.get_Negocio().HasValue) + { + valueOrDefault = false; + } + else + { + Negocio? negocio = this.ViewModel.SelectedDocumento.get_Negocio(); + valueOrDefault = negocio.GetValueOrDefault() == 1; + } + bool flag = valueOrDefault; + this.ViewModel.SelectedPagamento.set_Repasse(selectedItem); + this.ViewModel.SelectedPagamento.set_PorcentagemRepasse(new decimal?((flag ? selectedItem.get_ValorRenovacao() : selectedItem.get_ValorNovo()))); + if (this.ViewModel.SelectedParcela == null) + { + ApoliceViewModel viewModel = this.ViewModel; + Parcela parcela = new Parcela(); + parcela.set_SubTipo(1); + viewModel.SelectedParcela = parcela; + } + this.ViewModel.SelectedParcela.set_Documento(this.ViewModel.SelectedDocumento); + this.ViewModel.SelectedPagamento.set_ValorRepasse(new decimal?(Funcoes.CalculaRepasse(selectedItem, this.ViewModel.SelectedParcela, (this.ViewModel.SelectedParcela == null ? true : this.ViewModel.SelectedParcela.get_SubTipo() == 1)))); + this.ViewModel.SelectedPagamento.set_ValorTotal(this.ViewModel.SelectedPagamento.get_ValorRepasse()); + CurrencyTextBox currencyTextBox = this.ValorRepasseBox; + valorRepasse = this.ViewModel.SelectedPagamento.get_ValorRepasse(); + currencyTextBox.set_Number(valorRepasse.Value); + this.FormaRecebidaBox.Text = ValidationHelper.GetDescription(selectedItem.get_Forma()); + this.FormaIncidenciaBox.Text = ValidationHelper.GetDescription(selectedItem.get_Incidencia()); + } + + private void ContentLoad() + { + string nome; + this.ParcelaGrid.SelectionChanged += new SelectionChangedEventHandler(this.ParcelaGrid_OnSelectionChanged); + this.ApoliceBox.LostFocus += new RoutedEventHandler(this.ValidacaoDocumento); + this.EndossoBox.LostFocus += new RoutedEventHandler(this.ValidacaoDocumento); + this.TipoEndossoBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoEndossoBox_OnSelectionChanged); + this.TipoRecebimentoBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoRecebimentoBox_OnSelectionChanged); + this.SituacaoBox.SelectionChanged += new SelectionChangedEventHandler(this.SituacaoBox_OnSelectionChanged); + this.PremioLiquidoBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.PremioAdicionalBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.IofBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.DiferencaBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.AdicionalBox.Unchecked += new RoutedEventHandler(this.AdicionalBox_OnChecked); + this.AdicionalBox.Checked += new RoutedEventHandler(this.AdicionalBox_OnChecked); + this.ParcelasBox.LostFocus += new RoutedEventHandler(this.AlteracaoParcela_LostFocus); + this.NegocioCorretoraBox.SelectionChanged += new SelectionChangedEventHandler(this.NegocioCorretoraBox_OnSelectionChanged); + this.ComissaoBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.DataBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.DataBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.VendedorBox.SelectionChanged += new SelectionChangedEventHandler(this.VendedorBox_OnSelectionChanged); + this.TipoVendedorBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoVendedorBox_OnSelectionChanged); + this.ValorLiquidoParcelaBox.LostFocus += new RoutedEventHandler(this.ValorParcelaBox_OnLostFocus); + this.ComissaoParcelaBox.LostFocus += new RoutedEventHandler(this.Recalcula); + this.ValorLiquidoParcelaBox.LostFocus += new RoutedEventHandler(this.Recalcula); + this.ValorComissaoParcelaBox.LostFocus += new RoutedEventHandler(this.Recalcula); + this.ValorRealizadoParcelaBox.LostFocus += new RoutedEventHandler(this.Recalcula); + this.ValorParcelaBox.LostFocus += new RoutedEventHandler(this.Recalcula); + bool flag = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5); + this.ValorDescontoField.Visibility = (flag ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + base.SizeChanged += new SizeChangedEventHandler(this.ApoliceControl_SizeChanged); + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + AutoCompleteBox autoCompleteBanco = this.AutoCompleteBanco; + Banco banco = this.ViewModel.SelectedDocumento.get_Banco(); + if (banco != null) + { + nome = banco.get_Nome(); + } + else + { + nome = null; + } + autoCompleteBanco.set_Text(nome); + ApoliceViewModel viewModel = this.ViewModel; + TipoRecebimento? tipoRecebimento = this.ViewModel.SelectedDocumento.get_TipoRecebimento(); + viewModel.IsFatura = tipoRecebimento.GetValueOrDefault(1) == 2; + this.Parcelas(!this.ViewModel.IsFatura); + } + + public void EditandoParcela(bool enable) + { + PermissaoUsuario permissaoUsuario = this.ViewModel.ServicoPermissUsuario.BuscarPermissao(Recursos.Usuario, 2); + this.ViewModel.AllowEditVendedor = ((permissaoUsuario != null ? permissaoUsuario.get_Incluir() : true) ? !enable : false); + } + + public void EditandoVendedor(bool enable) + { + PermissaoUsuario permissaoUsuario = this.ViewModel.ServicoPermissUsuario.BuscarPermissao(Recursos.Usuario, 2); + this.IncluirpoliceButton.IsEnabled = ((permissaoUsuario != null ? permissaoUsuario.get_Incluir() : true) ? !enable : false); + this.AlterarApoliceButton.IsEnabled = ((permissaoUsuario != null ? permissaoUsuario.get_Alterar() : true) ? !enable : false); + this.ExcluirpoliceButton.IsEnabled = ((permissaoUsuario != null ? permissaoUsuario.get_Excluir() : true) ? !enable : false); + } + + private async void EditarParcelas_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.EditarParcelas(); + } + + private void EditarVendedor(bool editar) + { + bool valueOrDefault; + bool flag; + this.SalvarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.CancelarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.EditarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.EditarVendedorFields.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VendedorGrid.IsEnabled = !editar; + if (editar) + { + if (Recursos.Configuracoes.Any((ConfiguracaoSistema config) => config.get_Configuracao() == 56)) + { + if (this.ViewModel.Pagamentos.Count == 1) + { + if (!this.ViewModel.Pagamentos.Any((VendedorParcela vendedor) => vendedor.get_Repasse() == null)) + { + goto Label1; + } + flag = !this.IsFatura(); + goto Label0; + } + Label1: + flag = false; + Label0: + this.CoCorretagemToogle.IsEnabled = flag; + } + } + if (this.ViewModel.SelectedDocumento.get_NegocioCorretora().HasValue) + { + NegocioCorretora? negocioCorretora = this.ViewModel.SelectedDocumento.get_NegocioCorretora(); + valueOrDefault = negocioCorretora.GetValueOrDefault() == 1; + } + else if (this.ViewModel.SelectedDocumento.get_Situacao() != 2 || !this.ViewModel.SelectedDocumento.get_Negocio().HasValue) + { + valueOrDefault = false; + } + else + { + Negocio? negocio = this.ViewModel.SelectedDocumento.get_Negocio(); + valueOrDefault = negocio.GetValueOrDefault() == 1; + } + bool flag1 = valueOrDefault; + this.ComissaoNovoBox.Visibility = (!editar || flag1 ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ComissaoRenovacaoBox.Visibility = (editar & flag1 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.CoCorretagemToogle.IsChecked = new bool?(false); + } + + private void Endossar() + { + this.ViewModel.AlteracaoEnabled = false; + this.ViewModel.Situacao.Add(3); + this.ValidarDocumento(); + } + + private async void Endossar_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.Restricao(33)) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ENDOSSAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + else if (!this.ViewModel.EnableEndossar) + { + List> keyValuePairs = this.ViewModel.SelectedDocumento.ValidateEndossar(); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (await this.ViewModel.IncluirEndosso()) + { + this.ViewModel.BotoesParcelaEnabled = false; + this.Endossar(); + this.Restricao(true); + } + } + + private async void ExcluirDocumento_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.ExcluirApolice(); + } + + private async void ExcluirParcela_Click(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.PagamentoVendedor(this.ViewModel.SelectedParcela)) + { + bool? nullable = await this.ViewModel.ShowSenha("HÁ PAGAMENTOS DE VENDEDORES REALIZADOS PARA ESSA PARCELA. DESEJA PROSSEGUIR COM A EXCLUSÃO?"); + if (!nullable.HasValue) + { + return; + } + else if (!nullable.GetValueOrDefault()) + { + await this.ViewModel.ShowMessage("SENHA INVÁLIDA", "OK", "", false); + return; + } + } + if (!this.ViewModel.SelectedParcela.get_DataRecebimento().HasValue) + { + await this.ViewModel.ExcluirParcela(); + } + else + { + await this.ViewModel.ExcluirBaixa(); + } + this.EditandoParcela(true); + } + + private async void ExcluirVendedor_Click(object sender, RoutedEventArgs e) + { + TipoRepasse? nullable; + TipoRepasse? tipo; + bool flag; + System.Windows.Visibility visibility; + bool flag1; + VendedorParcela dataContext; + ((Button)sender).Click -= new RoutedEventHandler(this.ExcluirVendedor_Click); + Button button = (Button)sender; + if (button != null && button.DataContext != null) + { + dataContext = (VendedorParcela)button.DataContext; + VendedorParcela vendedorParcela = dataContext; + if (vendedorParcela != null) + { + Gestor.Model.Domain.Seguros.Repasse repasse1 = vendedorParcela.get_Repasse(); + if (repasse1 != null) + { + tipo = repasse1.get_Tipo(); + } + else + { + nullable = null; + tipo = nullable; + } + nullable = tipo; + flag = nullable.GetValueOrDefault() == 3; + } + else + { + flag = false; + } + bool flag2 = flag; + if (this.AlterarApoliceButton.IsEnabled || !this.SalvarApoliceButton.IsEnabled) + { + if (dataContext != null && !dataContext.get_DataPagamento().HasValue) + { + if (this.ViewModel._excluirPermissEnabled) + { + if (dataContext.get_CoCorretagem()) + { + ObservableCollection pagamentos = this.ViewModel.Pagamentos; + IEnumerable vendedorParcelas = pagamentos.Where((VendedorParcela pgt) => { + bool valueOrDefault; + Gestor.Model.Domain.Seguros.Repasse repasse = pgt.get_Repasse(); + valueOrDefault = (repasse != null ? repasse.get_Tipo().GetValueOrDefault() != 3 : true); + if (!valueOrDefault) + { + return false; + } + return !pgt.get_Vendedor().get_Corretora(); + }); + if (vendedorParcelas != null) + { + flag1 = vendedorParcelas.Count() >= 1; + } + else + { + flag1 = false; + } + if (flag1) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL EXCLUIR O VENDEDOR CO-CORRETAGEM. HÁ VENDEDORES CADASTRADOS NO DOCUMENTO", "OK", "", false); + dataContext = null; + return; + } + } + await this.ViewModel.ExcluirVendedor(dataContext, true); + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA EXCLUIR VENDEDORES. ENTRE EM CONTATO COM O ADMINISTRADOR DO SISTEMA.", "OK", "", false); + dataContext = null; + return; + } + } + else if (await this.ViewModel.ShowSenha(string.Format("DESEJA REALMENTE EXCLUIR O PAGAMENTO DO VENDEDOR {0} {1:d}?\nESSE PROCEDIMENTO É IRREVERSÍVEL.", dataContext.get_Vendedor().get_Nome(), dataContext.get_DataPagamento())).GetValueOrDefault()) + { + await this.ViewModel.ExcluirPagamento(dataContext); + } + this.ComissaoBox.IsReadOnly = this.ViewModel.VerificaCoCorretagem(); + ApoliceViewModel viewModel = this.ViewModel; + visibility = (this.ComissaoBox.IsReadOnly ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + viewModel.ComissOriginalVisibility = visibility; + if (flag2) + { + await this.ViewModel.AjusteComissãoCoCorretagem(true); + } + ((Button)sender).Click += new RoutedEventHandler(this.ExcluirVendedor_Click); + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL EXCLUIR VENDEDOR DURANTE ALTERAÇÃO DE DOCUMENTO.", "OK", "", false); + } + } + dataContext = null; + } + + private void ExecutarValidacaoDataApolice() + { + DateTime dateTime; + DateTime? nullable; + DateTime? nullable1; + DateTime? nullable2; + DateTime? nullable3; + DateTime? nullable4; + Documento selectedDocumento = this.ViewModel.SelectedDocumento; + if (DateTime.TryParse(ValidationHelper.FormatDate(this.Vigencia2Box.Text), out dateTime)) + { + nullable1 = new DateTime?(dateTime); + } + else + { + nullable = null; + nullable1 = nullable; + } + selectedDocumento.set_Vigencia2(nullable1); + Documento documento = this.ViewModel.SelectedDocumento; + if (DateTime.TryParse(ValidationHelper.FormatDate(this.TransmissaoBox.Text), out dateTime)) + { + nullable2 = new DateTime?(dateTime); + } + else + { + nullable = null; + nullable2 = nullable; + } + documento.set_Remessa(nullable2); + Documento selectedDocumento1 = this.ViewModel.SelectedDocumento; + if (DateTime.TryParse(ValidationHelper.FormatDate(this.EmissaoBox.Text), out dateTime)) + { + nullable3 = new DateTime?(dateTime); + } + else + { + nullable = null; + nullable3 = nullable; + } + selectedDocumento1.set_Emissao(nullable3); + Documento documento1 = this.ViewModel.SelectedDocumento; + if (DateTime.TryParse(ValidationHelper.FormatDate(this.DataBox.Text), out dateTime)) + { + nullable4 = new DateTime?(dateTime); + } + else + { + nullable = null; + nullable4 = nullable; + } + documento1.set_DataControle(nullable4); + } + + private void FocusPremios(object sender, RoutedEventArgs e) + { + this.ViewModel.UpdatePremio = true; + } + + private void Importacao_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Id() != 0) + { + this.AbrirImportacao(); + } + } + + private async void IncluirApolice_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.IncluirApolice(false); + this.ViewModel.BotoesParcelaEnabled = false; + this.ViewModel.AllowEditEmissao = true; + this.ValidarDocumento(); + this.Restricao(true); + this.ValidarTela(); + this.IncluirpoliceButton.IsEnabled = false; + this.AlterarApoliceButton.IsEnabled = false; + this.ExcluirpoliceButton.IsEnabled = false; + this.AlterandoDocumento(true); + } + + private async void IncluirNovaFatura_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.QuantidadeFaturas = 1; + bool flag = this.IsFatura(); + if (!flag || this.ViewModel.SelectedDocumento.get_Ordem() <= 0) + { + this.ToggleBotoesParcela(true); + this.EditarParcelaTipo = 3; + this.ViewModel.QuantidadeFaturas = 1; + this.NovaFatura(); + this.ViewModel.AllowEditVendedor = flag; + this.ViewModel.BaixarParcelas = true; + this.ViewModel.VisibilityAlterarVencimento = System.Windows.Visibility.Visible; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ADICIONAR FATURAS AO ENDOSSO, TODAS AS FATURAS DEVEM SER ADICIONADAS SOBRE A APÓLICE.", "OK", "", false); + } + } + + private void IncluirParcelaEspecial_Click(object sender, RoutedEventArgs e) + { + ((MenuItem)sender).Click -= new RoutedEventHandler(this.IncluirParcelaEspecial_Click); + this.ViewModel.QuantidadeFaturas = 1; + this.ToggleBotoesParcela(true); + this.EditarParcelaTipo = 4; + this.NovaParcelaEspecial(); + this.ViewModel.EditarParcelaEspecial(); + this.ViewModel.BaixarParcelas = true; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + ((MenuItem)sender).Click += new RoutedEventHandler(this.IncluirParcelaEspecial_Click); + this.EditandoParcela(true); + } + + private async void IncluirVendedor_Click(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.AllowEditParcela = false; + List> keyValuePairs = this.ViewModel.HabilitarVendedor(this.EditarParcelaTipo); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag) + { + this.ViewModel.IncluirVendedor(); + this.EditarVendedor(true); + this.ValidarVendedor(); + this.EditandoVendedor(true); + this.ViewModel.VendedorCoCorretagem(false); + } + else + { + this.ValidateFields(keyValuePairs, true); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + private void Initial_DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DateTime now; + bool flag; + base.DatePicker_OnLostKeyboardFocus(sender, e); + if (string.IsNullOrEmpty(((DatePicker)sender).Text)) + { + ((DatePicker)sender).SelectedDate = new DateTime?(DateTime.MinValue); + this.ViewModel.SelectedDocumento.set_Vigencia1(DateTime.MinValue); + Documento selectedDocumento = this.ViewModel.SelectedDocumento; + if (selectedDocumento != null) + { + selectedDocumento.get_Vigencia1(); + flag = true; + } + else + { + flag = false; + } + if (flag && this.ViewModel.SelectedDocumento.get_Vigencia1() == DateTime.MinValue) + { + DatePicker nullable = (DatePicker)sender; + now = DateTime.Now; + nullable.SelectedDate = new DateTime?(now.Date); + this.ViewModel.SelectedDocumento.set_Vigencia1(DateTime.Now.Date); + } + } + if (string.IsNullOrWhiteSpace(this.Vigencia2Box.Text)) + { + DatePicker vigencia2Box = this.Vigencia2Box; + now = ValidationHelper.ToDateTime(((DatePicker)sender).Text); + vigencia2Box.DisplayDate = now.AddYears(1); + DatePicker shortDateString = this.Vigencia2Box; + now = this.Vigencia2Box.DisplayDate; + shortDateString.Text = now.ToShortDateString(); + } + } + + [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/apoliceview.xaml", UriKind.Relative)); + } + + private bool IsFatura() + { + TipoRecebimento? tipoRecebimento = this.ViewModel.SelectedDocumento.get_TipoRecebimento(); + return tipoRecebimento.GetValueOrDefault() == 2; + } + + private void LostFocusValorRealizado() + { + if (this.ValorRealizadoParcelaBox.get_Number() == decimal.Zero || this.ViewModel.SelectedParcela == null || !this.ValorRealizadoParcelaBox.IsFocused) + { + return; + } + decimal number = this.ValorRealizadoParcelaBox.get_Number(); + decimal comissao = this.ViewModel.SelectedParcela.get_Comissao() * new decimal(1, 0, 0, false, 2); + this.ValorComissaoParcelaBox.set_Number(number * comissao); + } + + private void ManutecaoItens_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ManutecaoItens(); + } + + private void MenuItem_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogAntigo(); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + Tarefa tarefa = new Tarefa(); + tarefa.set_IdCliente(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Id()); + tarefa.set_Cliente(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()); + tarefa.set_Entidade(0); + tarefa.set_IdEntidade(this.ViewModel.SelectedDocumento.get_Id()); + tarefa.set_Titulo(string.Concat(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome(), " APÓLICE ", this.ViewModel.SelectedDocumento.get_Apolice())); + Tarefa tarefa1 = tarefa; + this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa1, true), 0, false); + } + + private void NegocioCorretoraBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool selectedItem; + if (!this.ViewModel.EnableFields) + { + return; + } + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null) + { + selectedItem = comboBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (!selectedItem) + { + return; + } + this.AlteracaoDePremio_LostFocus(this.PremioLiquidoBox, new RoutedEventArgs()); + if (this.SalvarVendedorButton.Visibility != System.Windows.Visibility.Visible) + { + return; + } + this.EditarVendedor(true); + this.ComissaoVendedorBox_OnSelectionChanged((this.ComissaoNovoBox.Visibility == System.Windows.Visibility.Visible ? this.ComissaoNovoComboBox : this.ComissaoRenovacaoComboBox), e); + } + + private void NovaFatura() + { + this.VigenciaInicialField.Visibility = System.Windows.Visibility.Visible; + this.VigenciaFinalField.Visibility = System.Windows.Visibility.Visible; + this.EmissaoField.Visibility = System.Windows.Visibility.Visible; + this.ValorLiquidoField.Visibility = System.Windows.Visibility.Visible; + this.QuantidadeFaturaField.Visibility = System.Windows.Visibility.Visible; + this.RecebimentoField.Visibility = System.Windows.Visibility.Visible; + this.QuitacaoField.Visibility = System.Windows.Visibility.Visible; + this.DataControleParcelaField.Visibility = System.Windows.Visibility.Visible; + this.CreditoField.Visibility = System.Windows.Visibility.Visible; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Visible; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Visible; + this.VencimentoField.Visibility = System.Windows.Visibility.Visible; + this.ValorField.Visibility = System.Windows.Visibility.Visible; + this.TipoParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.PercentualComissaoField.Visibility = System.Windows.Visibility.Visible; + this.ComissaoIcon.Visibility = System.Windows.Visibility.Visible; + this.FaturaField.Visibility = System.Windows.Visibility.Visible; + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Visible; + this.ParcelaGrid.IsEnabled = false; + if (this.ViewModel.Restricao(15)) + { + this.RecebimentoField.Visibility = System.Windows.Visibility.Collapsed; + this.QuitacaoField.Visibility = System.Windows.Visibility.Collapsed; + this.CreditoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Collapsed; + } + this.ViewModel.IncluirFatura(); + this.ValidarParcela(); + this.QuantidadeFaturaBox.Focus(); + this.EditandoParcela(true); + } + + private void NovaParcelaEspecial() + { + this.FaturaField.Visibility = System.Windows.Visibility.Collapsed; + this.VigenciaInicialField.Visibility = System.Windows.Visibility.Collapsed; + this.VigenciaFinalField.Visibility = System.Windows.Visibility.Collapsed; + this.EmissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorLiquidoField.Visibility = System.Windows.Visibility.Collapsed; + this.QuantidadeFaturaField.Visibility = (this.ViewModel.SelectedDocumento.get_TipoRecebimento().GetValueOrDefault() == 2 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.TipoParcelaField.Visibility = System.Windows.Visibility.Visible; + this.VencimentoField.Visibility = System.Windows.Visibility.Visible; + this.ValorField.Visibility = System.Windows.Visibility.Visible; + this.RecebimentoField.Visibility = System.Windows.Visibility.Visible; + this.QuitacaoField.Visibility = System.Windows.Visibility.Visible; + this.CreditoField.Visibility = System.Windows.Visibility.Visible; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Visible; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Visible; + this.PercentualComissaoField.Visibility = System.Windows.Visibility.Visible; + this.ComissaoIcon.Visibility = System.Windows.Visibility.Visible; + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Visible; + this.ParcelaGrid.IsEnabled = false; + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5)) + { + this.ImpostosField.Visibility = System.Windows.Visibility.Visible; + } + this.ViewModel.IncluirParcelaEspecial(); + this.ValidarParcela(); + this.ValorParcelaBox.Focus(); + } + + private async void ParcelaGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + ApoliceViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaParcela((Parcela)obj); + } + } + + private void Parcelas(bool premios) + { + DateTime? selectedDate; + this.ViewModel.AllowEditVendedor = this.ViewModel.SelectedDocumento.get_Id() == (long)0; + this.PremiosBox.Visibility = (premios ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.FaturaColumn.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaInicialColumn.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VigenciaFinalColumn.Visibility = (this.ViewModel.IsFatura ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ValidarDocumento(); + if (premios) + { + return; + } + this.ParcelasBox.set_Number(decimal.Zero); + this.ComissaoBox.set_Number(decimal.Zero); + this.PremioLiquidoBox.set_Number(decimal.Zero); + this.PremioTotalBox.set_Number(decimal.Zero); + this.IofBox.set_Number(decimal.Zero); + this.DiferencaBox.set_Number(decimal.Zero); + this.PremioAdicionalBox.set_Number(decimal.Zero); + this.FormaPagamentoBox.SelectedItem = (FormaPagamento)4; + DatePicker vigencia2Box = this.Vigencia2Box; + if (this.ViewModel.SelectedDocumento.get_Id() != 0 || this.ViewModel.SelectedDocumento.get_Tipo() != 0) + { + selectedDate = this.Vigencia2Box.SelectedDate; + } + else + { + selectedDate = null; + } + vigencia2Box.SelectedDate = selectedDate; + this.ViewModel.AllowEditVendedor = this.ViewModel.SelectedDocumento.get_Id() != (long)0; + } + + private async void Perdido_OnClick(object sender, RoutedEventArgs e) + { + object prefixo; + object numero; + string str; + string numero1; + object email; + DateTime dateTime; + string descricao; + bool count; + Cliente cliente; + ObservableCollection observableCollection; + if (this.ViewModel.SelectedDocumento.get_Situacao() == 7) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ALTERAR O STATUS PARA PERDIDO DE UM DOCUMENTO RECUSADO.", "OK", "", false); + } + else if (await this.ViewModel.ShowMessage("DESEJA REALMENTE ALTERAR O STATUS DO SEGURO PARA PERDIDO?", "SIM", "NÃO", false)) + { + this.ViewModel.Loading(true); + cliente = await (new ClienteServico()).BuscarCliente(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Id()); + Cliente cliente1 = cliente; + ObservableCollection observableCollection1 = await (new ClienteServico()).BuscarTelefonesAsync(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Id()); + cliente1.set_Telefones(observableCollection1); + cliente1 = null; + cliente1 = cliente; + ObservableCollection observableCollection2 = await (new ClienteServico()).BuscarEmailsAsync(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Id()); + cliente1.set_Emails(observableCollection2); + cliente1 = null; + observableCollection = await (new ItemServico()).BuscarItems(this.ViewModel.SelectedDocumento.get_Controle().get_Id(), 0, false); + if (await (new ApoliceServico()).Perdido(this.ViewModel.SelectedDocumento.get_Controle().get_Id())) + { + Prospeccao prospeccao = new Prospeccao(); + prospeccao.set_Nome(cliente.get_Nome()); + prospeccao.set_Documento(cliente.get_Documento()); + prospeccao.set_Nascimento(cliente.get_Nascimento()); + ObservableCollection telefones = cliente.get_Telefones(); + if (telefones != null) + { + ClienteTelefone clienteTelefone = telefones.FirstOrDefault(); + if (clienteTelefone != null) + { + prefixo = clienteTelefone.get_Prefixo(); + } + else + { + prefixo = null; + } + } + else + { + prefixo = null; + } + if (prefixo == null) + { + prefixo = ""; + } + prospeccao.set_Prefixo1((string)prefixo); + ObservableCollection telefones1 = cliente.get_Telefones(); + if (telefones1 != null) + { + ClienteTelefone clienteTelefone1 = telefones1.FirstOrDefault(); + if (clienteTelefone1 != null) + { + numero = clienteTelefone1.get_Numero(); + } + else + { + numero = null; + } + } + else + { + numero = null; + } + if (numero == null) + { + numero = ""; + } + prospeccao.set_Telefone1((string)numero); + str = (cliente.get_Telefones() == null || cliente.get_Telefones().Count <= 1 ? "" : cliente.get_Telefones()[1].get_Prefixo()); + prospeccao.set_Prefixo2(str); + if (cliente.get_Telefones() != null) + { + ObservableCollection telefones2 = cliente.get_Telefones(); + if (telefones2 != null) + { + count = telefones2.Count > 1; + } + else + { + count = false; + } + if (!count) + { + goto Label1; + } + numero1 = cliente.get_Telefones()[1].get_Numero(); + goto Label0; + } + Label1: + numero1 = ""; + Label0: + prospeccao.set_Telefone2(numero1); + ObservableCollection emails = cliente.get_Emails(); + if (emails != null) + { + ClienteEmail clienteEmail = emails.FirstOrDefault(); + if (clienteEmail != null) + { + email = clienteEmail.get_Email(); + } + else + { + email = null; + } + } + else + { + email = null; + } + if (email == null) + { + email = ""; + } + prospeccao.set_Email((string)email); + DateTime? vigencia2 = this.ViewModel.SelectedDocumento.get_Vigencia2(); + dateTime = (vigencia2.HasValue ? vigencia2.GetValueOrDefault() : Funcoes.GetNetworkTime().Date); + prospeccao.set_VigenciaFinal(new DateTime?(dateTime.AddYears(1))); + prospeccao.set_Vendedor(this.ViewModel.SelectedDocumento.get_VendedorPrincipal()); + Item item = observableCollection.FirstOrDefault(); + if (item != null) + { + descricao = item.get_Descricao(); + } + else + { + descricao = null; + } + prospeccao.set_Item(descricao); + prospeccao.set_Tipo("SEGURO PERDIDO"); + prospeccao.set_Observacao(string.Concat("SEGURO PERDIDO: PROPOSTA: ", this.ViewModel.SelectedDocumento.get_Proposta(), ", APÓLICE: ", this.ViewModel.SelectedDocumento.get_Apolice())); + prospeccao.set_Status(new StatusProspeccao?(1)); + prospeccao.set_Renovacao(true); + await this.AbrirProspeccao(prospeccao); + await this.ViewModel.SelecionaDocumento(this.ViewModel.SelectedDocumento); + this.ViewModel.Loading(false); + } + else + { + this.ViewModel.Loading(false); + } + } + cliente = null; + observableCollection = null; + } + + private void PorcentagemIrBox_OnNumberChanged(object sender, EventArgs e) + { + if (!this.ViewModel.BaixarParcelas || this._calculando) + { + return; + } + this._calculando = true; + this.ValorIrBox.set_Number(this.ValorComissaoParcelaBox.get_Number() * (this.PorcentagemIrBox.get_Number() / new decimal(100))); + this._calculando = false; + this.ValorImposto_OnNumberChanged(this.ValorIrBox, new EventArgs()); + } + + private void PorcentagemIssBox_OnNumberChanged(object sender, EventArgs e) + { + if (!this.ViewModel.BaixarParcelas || this._calculando) + { + return; + } + this._calculando = true; + this.ValorIssBox.set_Number(this.ValorComissaoParcelaBox.get_Number() * (this.PorcentagemIssBox.get_Number() / new decimal(100))); + this._calculando = false; + this.ValorImposto_OnNumberChanged(this.ValorIssBox, new EventArgs()); + } + + private async void Ramo_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + List configuracoes = Recursos.Configuracoes; + if (!configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 20) && this.ViewModel.SelectedDocumento != null) + { + this.EditarVendedor(false); + this.ViewModel.SelectedPagamento = null; + await this.ViewModel.BuscarVendedores(true); + await this.ViewModel.LimparRepasses(); + } + } + + private void Recalcula(object sender, RoutedEventArgs e) + { + this.ViewModel.RecalculaRepasse(); + } + + private async void RecusarDocumento_OnClick(object sender, RoutedEventArgs e) + { + if (!this.ViewModel.Restricao(18)) + { + await this.ViewModel.RecusarApolice(); + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA RECUSAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + } + + private void Redimencionar(bool invoke) + { + double actualWidth; + object obj; + Window window = System.Windows.Application.Current.Windows.OfType().SingleOrDefault((Window x) => x.IsActive); + if (window != null) + { + actualWidth = window.ActualWidth; + } + else + { + actualWidth = 1366; + } + double num = actualWidth; + if (invoke) + { + obj = 40; + } + else + { + obj = null; + } + this.Redimencionar(num - (double)obj); + Gestor.Application.Actions.Actions.Redimencionar = (Action)Delegate.Remove(Gestor.Application.Actions.Actions.Redimencionar, new Action(this.Redimencionar)); + } + + private void Redimencionar(double width) + { + this.ViewModel.TamanhoGrid = (width - 17) / 2; + if (this.ViewModel.TamanhoGrid < (double)((this.ViewModel.IsFatura ? 620 : 450))) + { + this.ViewModel.TamanhoGrid = width; + } + } + + private async void Renovar_OnClick(object sender, RoutedEventArgs e) + { + if (!this.ViewModel.Restricao(17)) + { + if (!this.ViewModel.EnableRenovar) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL RENOVAR UM DOCUMENTO SEM EMISSÃO OU SEM FINAL DE VIGÊNCIA.", "OK", "", false); + } + if (await this.ViewModel.IncluirApolice(true)) + { + this.ViewModel.BotoesParcelaEnabled = false; + this.ViewModel.AllowEditEmissao = true; + this.Restricao(true); + } + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA RENOVAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + } + + private void ReplicarFatura() + { + this.VigenciaInicialField.Visibility = System.Windows.Visibility.Visible; + this.VigenciaFinalField.Visibility = System.Windows.Visibility.Visible; + this.EmissaoField.Visibility = System.Windows.Visibility.Visible; + this.ValorLiquidoField.Visibility = System.Windows.Visibility.Visible; + this.QuantidadeFaturaField.Visibility = System.Windows.Visibility.Visible; + this.RecebimentoField.Visibility = System.Windows.Visibility.Visible; + this.QuitacaoField.Visibility = System.Windows.Visibility.Visible; + this.DataControleParcelaField.Visibility = System.Windows.Visibility.Visible; + this.CreditoField.Visibility = System.Windows.Visibility.Visible; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Visible; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Visible; + this.VencimentoField.Visibility = System.Windows.Visibility.Visible; + this.ValorField.Visibility = System.Windows.Visibility.Visible; + this.TipoParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.PercentualComissaoField.Visibility = System.Windows.Visibility.Visible; + this.ComissaoIcon.Visibility = System.Windows.Visibility.Visible; + this.FaturaField.Visibility = System.Windows.Visibility.Visible; + if (!this.ViewModel.Restricao(15)) + { + this.ViewModel.BaixarParcelas = true; + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5)) + { + this.ImpostosField.Visibility = System.Windows.Visibility.Visible; + } + } + if (( + from x in this.ViewModel.Parcelas + orderby x.get_NumeroParcela() + select x).LastOrDefault((Parcela x) => x.get_SubTipo() == 1).get_NumeroParcela() != 999) + { + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Visible; + this.ParcelaGrid.IsEnabled = false; + } + this.ViewModel.ReplicarFatura(); + this.ValidarParcela(); + this.QuantidadeFaturaBox.Focus(); + } + + private void ReplicarFatura_Click(object sender, RoutedEventArgs e) + { + this.ViewModel.QuantidadeFaturas = 1; + this.ToggleBotoesParcela(true); + this.EditarParcelaTipo = 3; + this.ReplicarFatura(); + this.ViewModel.QuantidadeFaturas = 1; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu == null) + { + return; + } + enableMenu(false); + } + + private void Restricao(bool insert = false) + { + bool flag = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5); + if (insert) + { + this.Comissao.Visibility = System.Windows.Visibility.Visible; + this.Gerada.Visibility = System.Windows.Visibility.Visible; + this.Recebida.Visibility = System.Windows.Visibility.Visible; + this.Pendente.Visibility = System.Windows.Visibility.Visible; + this.Repasse.Visibility = System.Windows.Visibility.Visible; + this.ParcelasComissaoColumn.Visibility = System.Windows.Visibility.Visible; + this.ParcelasValorComissaoColumn.Visibility = (flag ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ParcelasValorComissaoDescColumn.Visibility = (flag ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.PagamentosPorcentagemRepasseColumn.Visibility = System.Windows.Visibility.Visible; + this.PagamentosValorRepasseColumn.Visibility = System.Windows.Visibility.Visible; + return; + } + System.Windows.Visibility visibility = (this.ViewModel.Restricao(14) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + bool flag1 = this.ViewModel.Restricao(95); + this.Comissao.Visibility = (flag1 ? System.Windows.Visibility.Visible : visibility); + this.Gerada.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.Recebida.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.Pendente.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.Repasse.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.ParcelasComissaoColumn.Visibility = (flag1 ? System.Windows.Visibility.Visible : visibility); + this.ParcelasValorComissaoColumn.Visibility = (flag | flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.ParcelasValorComissaoDescColumn.Visibility = (flag ? visibility : System.Windows.Visibility.Collapsed); + this.MaisInformacoesColumn.Visibility = visibility; + this.PagamentosPorcentagemRepasseColumn.Visibility = visibility; + this.PagamentosValorRepasseColumn.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + } + + private async void SalvarApolice_OnClick(object sender, RoutedEventArgs e) + { + this.SalvarApoliceButton.Click -= new RoutedEventHandler(this.SalvarApolice_OnClick); + if (this.ViewModel.CompararValores()) + { + this.PremioTotalBox.set_Number(((this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number()) + this.IofBox.get_Number()) + this.DiferencaBox.get_Number()); + } + this.ExecutarValidacaoDataApolice(); + if (await this.SalvarDocumento()) + { + try + { + await this.ViewModel.CreateLinkAssistencia(this.ViewModel.SelectedDocumento, null, false); + } + catch (Exception exception) + { + } + this.AlterandoDocumento(false); + this.EditandoVendedor(false); + this.ViewModel.BotoesParcelaEnabled = true; + this.Restricao(false); + this.SalvarApoliceButton.Click += new RoutedEventHandler(this.SalvarApolice_OnClick); + } + else + { + this.SalvarApoliceButton.Click += new RoutedEventHandler(this.SalvarApolice_OnClick); + } + } + + private async Task SalvarDocumento() + { + bool flag; + bool flag1; + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(false); + flag1 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + if (!flag1) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + flag = false; + } + else + { + this.EditarVendedor(false); + ApoliceView.SetValid(this.AutoCompleteBanco, true); + flag = true; + } + return flag; + } + + private async Task SalvarParcela() + { + bool flag; + bool flag1; + flag = (this.EditarParcelaTipo != 3 ? false : this.ViewModel.QuantidadeFaturas > 1); + bool flag2 = flag; + if (flag2) + { + flag2 = !await this.ViewModel.ShowMessage(string.Format("O SISTEMA IRÁ INCLUIR/REPLICAR A FATURA {0} VEZES. DESEJA PROSSEGUIR?", this.ViewModel.QuantidadeFaturas), "SIM", "NÃO", false); + } + if (!flag2) + { + List> keyValuePairs = await this.ViewModel.SalvarParcelas(this.EditarParcelaTipo); + this.ValidateFields(keyValuePairs, true); + flag1 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag1) + { + this.EditarVendedor(false); + this.SalvarParcelaButton.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.EditandoParcela = false; + this.BaixarParcelaButton.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.BaixarParcelas = false; + this.EditarParcelaTipo = 0; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(true); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(true); + } + else + { + } + this.ToggleBotoesParcela(false); + if (this.ViewModel.UltimaFatura) + { + this.ViewModel.UltimaFatura = false; + this.ToggleBotoesParcela(true); + this.EditarParcelaTipo = 3; + this.ReplicarFatura(); + this.ViewModel.QuantidadeFaturas = 0; + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(false); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(false); + } + else + { + } + this.EditandoParcela(!this.ViewModel.UltimaFatura); + } + } + else + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + } + + private async void SalvarParcela_Click(object sender, RoutedEventArgs e) + { + ((MenuItem)this.SalvarParcelaButton.Items[0]).Click -= new RoutedEventHandler(this.SalvarParcela_Click); + this.LostFocusValorRealizado(); + this.ViewModel.Loading(true); + if (!this.ViewModel.CriandoParcelaEspecial) + { + await this.SalvarParcela(); + } + this.ViewModel.Loading(false); + this.SalvarParcelaButton.IsEnabled = true; + ((MenuItem)this.SalvarParcelaButton.Items[0]).Click += new RoutedEventHandler(this.SalvarParcela_Click); + } + + private async void SalvarVendedor_Click(object sender, RoutedEventArgs e) + { + bool? isChecked; + List> keyValuePairs; + bool valueOrDefault; + bool flag; + bool valueOrDefault1; + bool? nullable; + this.ViewModel.Loading(true); + if (this.ViewModel.SelectedParcela == null) + { + valueOrDefault = true; + } + else if (this.ViewModel.SelectedParcela.get_SubTipo() != 1) + { + valueOrDefault = false; + } + else + { + TipoRecebimento? tipoRecebimento = this.ViewModel.SelectedDocumento.get_TipoRecebimento(); + valueOrDefault = tipoRecebimento.GetValueOrDefault() == 1; + } + List configuracoes = Recursos.Configuracoes; + if (configuracoes.Any((ConfiguracaoSistema config) => config.get_Configuracao() == 56)) + { + ToggleButton coCorretagemToogle = this.CoCorretagemToogle; + if (coCorretagemToogle != null) + { + isChecked = coCorretagemToogle.IsChecked; + valueOrDefault1 = isChecked.GetValueOrDefault(); + } + else + { + valueOrDefault1 = false; + } + if (valueOrDefault1) + { + VendedorParcela selectedPagamento = this.ViewModel.SelectedPagamento; + ToggleButton toggleButton = this.CoCorretagemToogle; + if (toggleButton != null) + { + nullable = toggleButton.IsChecked; + } + else + { + isChecked = null; + nullable = isChecked; + } + isChecked = nullable; + selectedPagamento.set_CoCorretagem(isChecked.GetValueOrDefault(true)); + } + } + keyValuePairs = (!valueOrDefault ? await this.ViewModel.AdicionarVendedorParcelaEspecial() : await this.ViewModel.AdicionarVendedor()); + List> keyValuePairs1 = keyValuePairs; + flag = (keyValuePairs1 == null ? true : keyValuePairs1.Count == 0); + bool flag1 = flag; + this.ViewModel.Loading(false); + if (!flag1) + { + this.ViewModel.AllowEditParcela = flag1; + await this.ViewModel.ShowMessage(keyValuePairs1, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.EditarVendedor(false); + this.EditandoVendedor(false); + if (this.ViewModel.VerificaCoCorretagem()) + { + this.ComissaoBox.IsReadOnly = true; + this.ViewModel.ComissOriginalVisibility = System.Windows.Visibility.Visible; + } + this.ViewModel.AllowEditParcela = flag1; + } + } + + private static void SetValid(AutoCompleteBox autocomplete, bool valid) + { + ViewHelper.SetInvalid(autocomplete, "BANCO INVÁLIDO", valid); + } + + private void SituacaoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + TipoSeguro selectedItem = (TipoSeguro)comboBox.SelectedItem; + this.ViewModel.ToggleSeguradoraAnterior(selectedItem); + } + + [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.MenuApolice = (DockPanel)target; + return; + } + case 2: + { + this.IncluirpoliceButton = (MenuItem)target; + this.IncluirpoliceButton.Click += new RoutedEventHandler(this.IncluirApolice_OnClick); + return; + } + case 3: + { + this.AlterarApoliceButton = (MenuItem)target; + this.AlterarApoliceButton.Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 4: + { + this.SalvarApoliceButton = (MenuItem)target; + this.SalvarApoliceButton.Click += new RoutedEventHandler(this.SalvarApolice_OnClick); + return; + } + case 5: + { + this.CancelarApoliceButton = (MenuItem)target; + this.CancelarApoliceButton.Click += new RoutedEventHandler(this.CancelarApolice_OnClick); + return; + } + case 6: + { + this.ExcluirpoliceButton = (MenuItem)target; + this.ExcluirpoliceButton.Click += new RoutedEventHandler(this.ExcluirDocumento_OnClick); + return; + } + case 7: + { + this.ButtonImportado = (Button)target; + this.ButtonImportado.Click += new RoutedEventHandler(this.Importacao_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirPerfil_OnClick); + return; + } + case 9: + { + this.ArquivoDigitalButton = (MenuItem)target; + this.ArquivoDigitalButton.Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 10: + { + this.MaisOpcoesButton = (MenuItem)target; + return; + } + case 11: + { + this.EditarParcelasButton = (MenuItem)target; + this.EditarParcelasButton.Click += new RoutedEventHandler(this.EditarParcelas_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Renovar_OnClick); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Perdido_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Endossar_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.RecusarDocumento_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ManutecaoItens_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick); + return; + } + case 19: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 20: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmailPF_OnClick); + return; + } + case 21: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogTrocaCliente_OnClick); + return; + } + case 22: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MenuItem_Click); + return; + } + case 23: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirInfo_OnClick); + return; + } + case 24: + { + this.ApoliceControl1 = (WrapPanel)target; + return; + } + case 25: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Ramo_OnSelectionChanged); + return; + } + case 26: + { + this.ProdutoBox = (ComboBox)target; + return; + } + case 27: + { + this.SituacaoBox = (ComboBox)target; + return; + } + case 28: + { + this.NegocioCorretoraBox = (ComboBox)target; + return; + } + case 29: + { + this.TipoRecebimentoBox = (ComboBox)target; + return; + } + case 30: + { + this.TipoEndossoBox = (ComboBox)target; + return; + } + case 31: + { + this.ApoliceBox = (TextBox)target; + return; + } + case 32: + { + this.EndossoBox = (TextBox)target; + return; + } + case 33: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Initial_DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + ((DatePicker)target).SelectedDateChanged += new EventHandler(this.ValidacaoDocumento); + return; + } + case 34: + { + this.Vigencia2Box = (DatePicker)target; + this.Vigencia2Box.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.Vigencia2Box.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.Vigencia2Box.SelectedDateChanged += new EventHandler(this.ValidacaoDocumento); + return; + } + case 35: + { + this.TransmissaoBox = (DatePicker)target; + this.TransmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.TransmissaoBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.TransmissaoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 36: + { + this.EmissaoBox = (DatePicker)target; + this.EmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.EmissaoBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.EmissaoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.EmissaoBox.SelectedDateChanged += new EventHandler(this.ValidacaoDocumento); + return; + } + case 37: + { + this.FormaPagamentoBox = (ComboBox)target; + return; + } + case 38: + { + this.PremiosBox = (Grid)target; + return; + } + case 39: + { + this.AdicionalBox = (ToggleButton)target; + return; + } + case 40: + { + this.Comissao = (CustomIsReadOnlyControl)target; + return; + } + case 41: + { + this.ComissaoBox = (CurrencyTextBox)target; + return; + } + case 42: + { + this.PremioLiquidoBox = (CurrencyTextBox)target; + return; + } + case 43: + { + this.PremioAdicionalBox = (CurrencyTextBox)target; + this.PremioAdicionalBox.GotFocus += new RoutedEventHandler(this.FocusPremios); + return; + } + case 44: + { + this.IofBox = (CurrencyTextBox)target; + return; + } + case 45: + { + this.DiferencaBox = (CurrencyTextBox)target; + return; + } + case 46: + { + this.PremioTotalBox = (CurrencyTextBox)target; + return; + } + case 47: + { + this.ParcelasBox = (CurrencyTextBox)target; + return; + } + case 48: + { + this.ComissaoOriginal = (CustomIsReadOnlyControl)target; + return; + } + case 49: + { + this.Gerada = (CustomIsReadOnlyControl)target; + return; + } + case 50: + { + this.Recebida = (CustomIsReadOnlyControl)target; + return; + } + case 51: + { + this.Pendente = (CustomIsReadOnlyControl)target; + return; + } + case 52: + { + this.Repasse = (CustomIsReadOnlyControl)target; + return; + } + case 53: + { + ((Button)target).Click += new RoutedEventHandler(this.Button_Click); + return; + } + case 54: + { + this.BaixarParcelaButton = (Menu)target; + return; + } + case 55: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.BaixarParcelas_Click); + return; + } + case 56: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AlterarParcela_Click); + return; + } + case 57: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirNovaFatura_Click); + return; + } + case 58: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ReplicarFatura_Click); + return; + } + case 59: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirParcelaEspecial_Click); + return; + } + case 60: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirParcela_Click); + return; + } + case 61: + { + this.SalvarParcelaButton = (Menu)target; + return; + } + case 62: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.SalvarParcela_Click); + return; + } + case 63: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CancelarParcela_Click); + return; + } + case 64: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogParcelas_OnClick); + return; + } + case 65: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogParcelaSelecionada_OnClick); + return; + } + case 66: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogParcelaAntigo_OnClick); + return; + } + case 67: + { + this.EditarParcelasFields = (StackPanel)target; + return; + } + case 68: + { + this.TipoParcelaField = (CustomItemValidation)target; + return; + } + case 69: + { + this.TipoParcelaBox = (ComboBox)target; + return; + } + case 70: + { + this.QuantidadeFaturaField = (CustomItemControl)target; + return; + } + case 71: + { + this.QuantidadeFaturaBox = (CurrencyTextBox)target; + return; + } + case 72: + { + this.FaturaField = (CustomItemValidation)target; + return; + } + case 73: + { + this.FaturaBox = (TextBox)target; + return; + } + case 74: + { + this.VigenciaInicialField = (CustomItemValidation)target; + return; + } + case 75: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Vigencia_DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 76: + { + this.VigenciaFinalField = (CustomItemValidation)target; + return; + } + case 77: + { + this.VigenciaFinalParcelaBox = (DatePicker)target; + this.VigenciaFinalParcelaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.VigenciaFinalParcelaBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.VigenciaFinalParcelaBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 78: + { + this.VencimentoField = (CustomItemValidation)target; + return; + } + case 79: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Vencimento_DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 80: + { + this.EmissaoField = (CustomItemControl)target; + return; + } + case 81: + { + this.EmissaoParcelaBox = (DatePicker)target; + this.EmissaoParcelaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.EmissaoParcelaBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.EmissaoParcelaBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 82: + { + this.PercentualComissaoField = (CustomItemValidation)target; + return; + } + case 83: + { + this.ComissaoParcelaBox = (CurrencyTextBox)target; + return; + } + case 84: + { + this.ComissaoIcon = (TextBlock)target; + return; + } + case 85: + { + this.ValorLiquidoField = (CustomItemControl)target; + return; + } + case 86: + { + this.ValorLiquidoParcelaBox = (CurrencyTextBox)target; + return; + } + case 87: + { + this.ValorField = (CustomItemControl)target; + return; + } + case 88: + { + this.ValorParcelaBox = (CurrencyTextBox)target; + return; + } + case 89: + { + this.RecebimentoField = (CustomItemValidation)target; + return; + } + case 90: + { + this.RecebimentoParcelaBox = (DatePicker)target; + this.RecebimentoParcelaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Vencimento_OnLostKeyboardFocus); + this.RecebimentoParcelaBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.RecebimentoParcelaBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.RecebimentoParcelaBox.SelectedDateChanged += new EventHandler(this.ValidacaoParcela); + return; + } + case 91: + { + this.QuitacaoField = (CustomItemControl)target; + return; + } + case 92: + { + ((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).SelectedDateChanged += new EventHandler(this.ValidacaoParcela); + return; + } + case 93: + { + this.DataControleParcelaField = (CustomItemControl)target; + return; + } + case 94: + { + ((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).SelectedDateChanged += new EventHandler(this.ValidacaoParcela); + return; + } + case 95: + { + this.CreditoField = (CustomItemValidation)target; + return; + } + case 96: + { + this.CreditoParcelaBox = (DatePicker)target; + this.CreditoParcelaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.CreditoParcelaBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.CreditoParcelaBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + this.CreditoParcelaBox.SelectedDateChanged += new EventHandler(this.ValidacaoParcela); + return; + } + case 97: + { + this.ValorRealizadoField = (CustomItemValidation)target; + return; + } + case 98: + { + this.ValorRealizadoParcelaBox = (CurrencyTextBox)target; + this.ValorRealizadoParcelaBox.LostFocus += new RoutedEventHandler(this.ValorRealizadoParcelaBox_OnLostFocus); + return; + } + case 99: + { + this.ValorComissaoField = (CustomItemValidation)target; + return; + } + case 100: + { + this.ValorComissaoParcelaBox = (CurrencyTextBox)target; + this.ValorComissaoParcelaBox.add_NumberChanged(new EventHandler(this.CalculoComissao_OnNumberChanged)); + return; + } + case 101: + { + this.ImpostosField = (WrapPanel)target; + return; + } + case 102: + { + this.PorcentagemIrField = (CustomItemControl)target; + return; + } + case 103: + { + this.PorcentagemIrBox = (CurrencyTextBox)target; + this.PorcentagemIrBox.add_NumberChanged(new EventHandler(this.PorcentagemIrBox_OnNumberChanged)); + return; + } + case 104: + { + this.ValorIrField = (CustomItemControl)target; + return; + } + case 105: + { + this.ValorIrBox = (CurrencyTextBox)target; + this.ValorIrBox.add_NumberChanged(new EventHandler(this.ValorImposto_OnNumberChanged)); + return; + } + case 106: + { + this.PorcentagemIssField = (CustomItemControl)target; + return; + } + case 107: + { + this.PorcentagemIssBox = (CurrencyTextBox)target; + this.PorcentagemIssBox.add_NumberChanged(new EventHandler(this.PorcentagemIssBox_OnNumberChanged)); + return; + } + case 108: + { + this.ValorIssField = (CustomItemControl)target; + return; + } + case 109: + { + this.ValorIssBox = (CurrencyTextBox)target; + this.ValorIssBox.add_NumberChanged(new EventHandler(this.ValorImposto_OnNumberChanged)); + return; + } + case 110: + { + this.ValorOutrosField = (CustomItemControl)target; + return; + } + case 111: + { + this.ValorOutrosBox = (CurrencyTextBox)target; + this.ValorOutrosBox.add_NumberChanged(new EventHandler(this.ValorImposto_OnNumberChanged)); + return; + } + case 112: + { + this.ValorDescontoField = (CustomItemControl)target; + return; + } + case 113: + { + this.ValorDescontoBox = (CurrencyTextBox)target; + this.ValorDescontoBox.add_NumberChanged(new EventHandler(this.ValorImposto_OnNumberChanged)); + return; + } + case 114: + { + this.ValorComDescField = (CustomItemControl)target; + return; + } + case 115: + { + this.ValorComDescBox = (CurrencyTextBox)target; + this.ValorComDescBox.add_NumberChanged(new EventHandler(this.ValorImposto_OnNumberChanged)); + return; + } + case 116: + { + this.ParcelaGrid = (DataGrid)target; + return; + } + case 117: + { + this.ParcelaColumn = (DataGridTextColumn)target; + return; + } + case 118: + { + this.FaturaColumn = (DataGridTextColumn)target; + return; + } + case 119: + { + this.VigenciaInicialColumn = (DataGridTextColumn)target; + return; + } + case 120: + { + this.VigenciaFinalColumn = (DataGridTextColumn)target; + return; + } + case 121: + { + this.ParcelasComissaoColumn = (DataGridTextColumn)target; + return; + } + case 122: + { + this.ParcelasValorComissaoColumn = (DataGridTextColumn)target; + return; + } + case 123: + { + this.ParcelasValorComissaoDescColumn = (DataGridTextColumn)target; + return; + } + case 124: + { + this.MaisInformacoesColumn = (DataGridTemplateColumn)target; + return; + } + case 125: + case 126: + case 146: + { + this._contentLoaded = true; + return; + } + case 127: + { + this.EditarVendedorButton = (MenuItem)target; + this.EditarVendedorButton.Click += new RoutedEventHandler(this.IncluirVendedor_Click); + return; + } + case 128: + { + this.SalvarVendedorButton = (MenuItem)target; + this.SalvarVendedorButton.Click += new RoutedEventHandler(this.SalvarVendedor_Click); + return; + } + case 129: + { + this.CancelarVendedorButton = (MenuItem)target; + this.CancelarVendedorButton.Click += new RoutedEventHandler(this.CancelarVendedor_Click); + return; + } + case 130: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogVendedor_OnClick); + return; + } + case 131: + { + this.EditarVendedorFields = (WrapPanel)target; + return; + } + case 132: + { + this.CoCorretagemToogle = (ToggleButton)target; + this.CoCorretagemToogle.Click += new RoutedEventHandler(this.AdicionarCoCorretagem_OnClick); + return; + } + case 133: + { + this.TipoVendedorBox = (ComboBox)target; + return; + } + case 134: + { + this.VendedorBox = (ComboBox)target; + return; + } + case 135: + { + this.ComissaoNovoBox = (CustomItemValidation)target; + return; + } + case 136: + { + this.ComissaoNovoComboBox = (ComboBox)target; + this.ComissaoNovoComboBox.SelectionChanged += new SelectionChangedEventHandler(this.ComissaoVendedorBox_OnSelectionChanged); + return; + } + case 137: + { + this.ComissaoRenovacaoBox = (CustomItemValidation)target; + return; + } + case 138: + { + this.ComissaoRenovacaoComboBox = (ComboBox)target; + this.ComissaoRenovacaoComboBox.SelectionChanged += new SelectionChangedEventHandler(this.ComissaoVendedorBox_OnSelectionChanged); + return; + } + case 139: + { + this.ValorRepasseBox = (CurrencyTextBox)target; + this.ValorRepasseBox.add_NumberChanged(new EventHandler(this.CalculoComissao_OnNumberChanged)); + return; + } + case 140: + { + this.FormaRecebidaBox = (TextBox)target; + return; + } + case 141: + { + this.FormaIncidenciaBox = (TextBox)target; + return; + } + case 142: + { + this.VendedorGrid = (DataGrid)target; + return; + } + case 143: + { + this.VendedorGridColumn = (DataGridTextColumn)target; + return; + } + case 144: + { + this.PagamentosPorcentagemRepasseColumn = (DataGridTextColumn)target; + return; + } + case 145: + { + this.PagamentosValorRepasseColumn = (DataGridTextColumn)target; + return; + } + case 147: + { + this.ProponenteBox = (TextBox)target; + return; + } + case 148: + { + this.AutoCompleteBanco = (AutoCompleteBox)target; + this.AutoCompleteBanco.add_Populating(new PopulatingEventHandler(this, ApoliceView.AutoCompleteBancoBox_Populating)); + this.AutoCompleteBanco.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.AutoCompleteBanco_OnLostKeyboardFocus); + return; + } + case 149: + { + this.AgenciaBox = (TextBox)target; + return; + } + case 150: + { + this.ContaBox = (TextBox)target; + return; + } + case 151: + { + this.CartaoBox = (TextBox)target; + return; + } + case 152: + { + this.BandeiraBox = (ComboBox)target; + return; + } + case 153: + { + this.VencimentoCartaoBox = (TextBox)target; + ApoliceView apoliceView = this; + this.VencimentoCartaoBox.PreviewTextInput += new TextCompositionEventHandler(apoliceView.SomenteNumeros); + this.VencimentoCartaoBox.TextChanged += new TextChangedEventHandler(this.VencimentoCartaoBox_OnTextChanged); + this.VencimentoCartaoBox.GotFocus += new RoutedEventHandler(this.VencimentoCartaoBox_OnGotFocus); + return; + } + case 154: + { + this.DataBox = (DatePicker)target; + this.DataBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 155: + { + this.PastaBox = (TextBox)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) + { + if (connectionId == 125) + { + ((Button)target).Click += new RoutedEventHandler(this.ValoresParcelaInfo_OnClick); + return; + } + if (connectionId == 126) + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + if (connectionId != 146) + { + return; + } + ((Button)target).Click += new RoutedEventHandler(this.ExcluirVendedor_Click); + } + + private void TipoEndossoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + decimal comissao; + if (this.ViewModel.SelectedDocumento != null && this.ViewModel.SelectedDocumento.get_Tipo() == 0) + { + return; + } + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + bool flag = (this.ViewModel.IsFatura ? false : (TipoEndosso)comboBox.SelectedItem != 1); + if (this.ViewModel.EnableFields) + { + if ((TipoEndosso)comboBox.SelectedItem != null && (TipoEndosso)comboBox.SelectedItem != 4) + { + if (this.ViewModel.SelectedDocumento != null) + { + this.ViewModel.SelectedDocumento.set_Comissao(decimal.Zero); + } + } + else if (this.ViewModel.SelectedDocumento != null) + { + Documento selectedDocumento = this.ViewModel.SelectedDocumento; + Documento cancelDocumento = this.ViewModel.CancelDocumento; + if (cancelDocumento != null) + { + comissao = cancelDocumento.get_Comissao(); + } + else + { + comissao = decimal.Zero; + } + selectedDocumento.set_Comissao(comissao); + } + this.ViewModel.OnPropertyChanged("SelectedDocumento"); + } + this.Parcelas(flag); + } + + private void TipoRecebimentoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + this.ViewModel.IsFatura = (TipoRecebimento)comboBox.SelectedItem == 2; + this.Parcelas(!this.ViewModel.IsFatura); + if (!this.ViewModel.EnableFields) + { + return; + } + this.FormaPagamentoBox.SelectedItem = (this.ViewModel.IsFatura ? new FormaPagamento?(5) : this.ViewModel.SelectedDocumento.get_FormaPagamento()); + } + + private void TipoVendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + if (this.ViewModel.SelectedPagamento == null) + { + this.ViewModel.SelectedPagamento = new VendedorParcela(); + } + this.ViewModel.SelectedPagamento.set_TipoVendedor((TipoVendedor)comboBox.SelectedItem); + } + + private void ToggleBotoesParcela(bool habilitar) + { + this.SalvarParcelaButton.Visibility = (habilitar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ViewModel.EditandoParcela = habilitar; + this.BaixarParcelaButton.Visibility = (habilitar ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.MenuApolice.IsEnabled = !habilitar; + this.ViewModel.IsEnabled = !habilitar; + this.PremiosBox.IsEnabled = !habilitar; + this.DataControleParcelaField.Visibility = System.Windows.Visibility.Collapsed; + if (habilitar) + { + return; + } + this.QuantidadeFaturaField.Visibility = System.Windows.Visibility.Collapsed; + this.TipoParcelaField.Visibility = System.Windows.Visibility.Collapsed; + this.VencimentoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorField.Visibility = System.Windows.Visibility.Collapsed; + this.RecebimentoField.Visibility = System.Windows.Visibility.Collapsed; + this.QuitacaoField.Visibility = System.Windows.Visibility.Collapsed; + this.CreditoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorRealizadoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorComissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.PercentualComissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.ComissaoIcon.Visibility = System.Windows.Visibility.Collapsed; + this.EmissaoField.Visibility = System.Windows.Visibility.Collapsed; + this.ValorLiquidoField.Visibility = System.Windows.Visibility.Collapsed; + this.FaturaField.Visibility = System.Windows.Visibility.Collapsed; + this.VigenciaInicialField.Visibility = System.Windows.Visibility.Collapsed; + this.VigenciaFinalField.Visibility = System.Windows.Visibility.Collapsed; + this.EditarParcelasFields.Visibility = System.Windows.Visibility.Collapsed; + this.ImpostosField.Visibility = System.Windows.Visibility.Collapsed; + this.ParcelaGrid.IsEnabled = true; + } + + private void ValidacaoDocumento(object sender, RoutedEventArgs e) + { + this.ValidarDocumento(); + } + + private void ValidacaoParcela(object sender, RoutedEventArgs e) + { + this.ValidarParcela(); + } + + private void ValidarDocumento() + { + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedDocumento.Validate(this.ViewModel.IsEndosso, Recursos.Configuracoes.Any((ConfiguracaoSistema c) => c.get_Configuracao() == 11)); + this.ValidateFields(keyValuePairs, false); + } + + private void ValidarParcela() + { + if (this.ViewModel.SelectedParcela == null) + { + return; + } + if (this.ViewModel.SelectedParcela.get_Documento() == null) + { + this.ViewModel.SelectedParcela.set_Documento(this.ViewModel.SelectedDocumento); + } + this.ViewModel.SelectedParcela.get_Documento().set_Parcelas(this.ViewModel.Parcelas); + List> keyValuePairs = this.ViewModel.SelectedParcela.Validate(Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 9), Recursos.Configuracoes.Any((ConfiguracaoSistema y) => y.get_Configuracao() == 11), this.ViewModel.EditandoParcela, Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 16)); + this.ValidateFields(keyValuePairs, false); + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedDocumento.Validate(); + this.ValidateFields(keyValuePairs, false); + } + + private void ValidarVendedor() + { + if (this.ViewModel.SelectedPagamento == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedPagamento.Validate(); + this.ValidateFields(keyValuePairs, false); + } + + private void ValoresParcelaInfo_OnClick(object sender, RoutedEventArgs e) + { + Parcela parcela = this.ViewModel.AbrirDetalhesParcela(); + this.ViewModel.ShowDrawer(new ValoresParcelaDrawer(parcela, this.ViewModel.SelectedDocumento), 0, true); + } + + private void ValorImposto_OnNumberChanged(object sender, EventArgs e) + { + if (!this.ViewModel.BaixarParcelas || this._calculando) + { + return; + } + this._calculando = true; + CurrencyTextBox currencyTextBox = (CurrencyTextBox)sender; + decimal num = (this.ValorComissaoParcelaBox.get_Number() == decimal.Zero ? decimal.One : this.ValorComissaoParcelaBox.get_Number()); + decimal number = this.ValorComissaoParcelaBox.get_Number(); + string name = currencyTextBox.Name; + if (name == "ValorIrBox") + { + this.PorcentagemIrBox.set_Number((this.ValorIrBox.get_Number() * new decimal(100)) / num); + number = (((num - currencyTextBox.get_Number()) - this.ValorIssBox.get_Number()) - this.ValorOutrosBox.get_Number()) - this.ValorDescontoBox.get_Number(); + } + else if (name == "ValorIssBox") + { + this.PorcentagemIssBox.set_Number((this.ValorIssBox.get_Number() * new decimal(100)) / num); + number = (((num - currencyTextBox.get_Number()) - this.ValorIrBox.get_Number()) - this.ValorOutrosBox.get_Number()) - this.ValorDescontoBox.get_Number(); + } + else if (name == "ValorOutrosBox") + { + number = (((num - currencyTextBox.get_Number()) - this.ValorIrBox.get_Number()) - this.ValorIrBox.get_Number()) - this.ValorDescontoBox.get_Number(); + } + else if (name == "ValorDescontoBox") + { + number = (((num - currencyTextBox.get_Number()) - this.ValorIrBox.get_Number()) - this.ValorIrBox.get_Number()) - this.ValorOutrosBox.get_Number(); + } + this.ValorComDescBox.set_Number(number); + this._calculando = false; + } + + private void ValorParcelaBox_OnLostFocus(object sender, RoutedEventArgs e) + { + decimal iof; + if (!this.ViewModel.IsFatura) + { + return; + } + CurrencyTextBox currencyTextBox = (CurrencyTextBox)sender; + if (this.ValorParcelaBox.get_Number() > decimal.Zero) + { + return; + } + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 46)) + { + Ramo ramo = this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(); + if (ramo != null) + { + iof = ramo.get_Iof(); + } + else + { + iof = decimal.Zero; + } + } + else + { + iof = decimal.Zero; + } + decimal one = iof + decimal.One; + this.ValorParcelaBox.set_Number(currencyTextBox.get_Number() * one); + this.ValorParcelaBox.Focus(); + } + + private void ValorRealizadoParcelaBox_OnLostFocus(object sender, RoutedEventArgs e) + { + CurrencyTextBox currencyTextBox = (CurrencyTextBox)sender; + if (currencyTextBox != null && currencyTextBox.get_Number() != decimal.Zero && this.ViewModel.SelectedParcela != null) + { + decimal number = currencyTextBox.get_Number(); + decimal comissao = this.ViewModel.SelectedParcela.get_Comissao() * new decimal(1, 0, 0, false, 2); + this.ValorComissaoParcelaBox.set_Number(number * comissao); + } + } + + private void Vencimento_DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + base.DatePicker_OnLostKeyboardFocus(sender, e); + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + if (string.IsNullOrEmpty(((DatePicker)sender).Text)) + { + ((DatePicker)sender).SelectedDate = new DateTime?(this.ViewModel.SelectedDocumento.get_Vigencia1()); + DatePicker str = (DatePicker)sender; + DateTime vigencia1 = this.ViewModel.SelectedDocumento.get_Vigencia1(); + str.Text = vigencia1.ToString("dd/MM/yyyy"); + } + base.DatePicker_OnLostKeyboardFocus(sender, e); + } + + private void Vencimento_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DateTime dateTime; + base.DatePicker_OnLostKeyboardFocus(sender, e); + DatePicker datePicker = (DatePicker)sender; + if (string.IsNullOrEmpty(datePicker.Text)) + { + return; + } + if (!DateTime.TryParse(ValidationHelper.FormatDate(datePicker.Text), out dateTime)) + { + return; + } + this.CreditoParcelaBox.SelectedDate = new DateTime?(dateTime); + } + + private void VencimentoCartaoBox_OnGotFocus(object sender, RoutedEventArgs e) + { + string str = ((TextBox)sender).Text.Replace("/", ""); + this._vencimentoCartaoOld = str.Substring(0, (str.Length > 4 ? 4 : str.Length)); + } + + private void VencimentoCartaoBox_OnTextChanged(object sender, TextChangedEventArgs e) + { + int caretIndex = ((TextBox)sender).CaretIndex; + TextBox textBox = (TextBox)sender; + if (textBox.Text.Contains("/") && (new Regex("/")).Match(textBox.Text).Index < caretIndex) + { + caretIndex--; + } + string str = textBox.Text.Replace("/", ""); + string str1 = str.Substring(0, (str.Length > 4 ? 4 : str.Length)); + if ((new Regex("^0")).IsMatch(str1)) + { + if ((new Regex("^00")).IsMatch(str1)) + { + textBox.Text = this._vencimentoCartaoOld; + textBox.CaretIndex = caretIndex; + return; + } + } + else if ((new Regex("^1")).IsMatch(str1)) + { + if ((new Regex("^1[^0-2]")).IsMatch(str1)) + { + textBox.Text = this._vencimentoCartaoOld; + textBox.CaretIndex = caretIndex; + return; + } + } + else if ((new Regex("^[^01]")).IsMatch(str1)) + { + textBox.Text = this._vencimentoCartaoOld; + textBox.CaretIndex = caretIndex; + return; + } + if (str1.Length > 2) + { + textBox.Text = str1.Insert(2, "/"); + caretIndex++; + } + else if (textBox.Text.Contains("/")) + { + textBox.Text = str1; + } + textBox.CaretIndex = caretIndex; + this._vencimentoCartaoOld = str1; + } + + private void VendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + this.ViewModel.FiltrarRepasse((Vendedor)comboBox.SelectedItem); + if (this.ViewModel.CoCorretagem) + { + this.ComissaoNovoBox.Visibility = System.Windows.Visibility.Visible; + this.ComissaoRenovacaoBox.Visibility = System.Windows.Visibility.Collapsed; + } + } + + private void Vigencia_DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DateTime dateTime; + base.DatePicker_OnLostKeyboardFocus(sender, e); + DatePicker datePicker = (DatePicker)sender; + if (string.IsNullOrEmpty(datePicker.Text)) + { + return; + } + if (!DateTime.TryParse(ValidationHelper.FormatDate(datePicker.Text), out dateTime)) + { + return; + } + this.VigenciaFinalParcelaBox.SelectedDate = new DateTime?(dateTime.AddMonths(1)); + this.EmissaoParcelaBox.SelectedDate = new DateTime?(dateTime); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/ClienteView.cs b/Codemerx/Gestor.Application/Views/Seguros/ClienteView.cs new file mode 100644 index 0000000..5426996 --- /dev/null +++ b/Codemerx/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 diff --git a/Codemerx/Gestor.Application/Views/Seguros/ComissaoView.cs b/Codemerx/Gestor.Application/Views/Seguros/ComissaoView.cs new file mode 100644 index 0000000..7bbf613 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/ComissaoView.cs @@ -0,0 +1,1336 @@ +using Gestor.Application.Actions; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Comissao; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +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.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Text; +using System.Text.RegularExpressions; +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 ComissaoView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal ComboBox UsuarioBox; + + internal ComboBox StatusBox; + + internal ComboBox SeguradoraBox; + + internal ComboBox Seguradora2Box; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal DataGrid ExtratoGrid; + + internal Card ProgressBar2; + + internal Card ProgressBar; + + internal MenuItem DesfazerExtratoButton; + + internal DatePicker DataBaixaBox; + + internal TextBox FiltroDetalhes; + + internal DataGrid DetalhesGrid; + + internal Grid PainelCritica; + + internal AutoCompleteBox AutoCompleteCliente; + + internal TextBox TipoDocumentoPrincipalBox; + + internal TextBox DocumentoPrincipalBox; + + internal TextBox FiltroApoliceBox; + + internal DataGrid ApoliceGrid; + + internal DataGrid ParcelaGrid; + + internal DataGridTextColumn ParcelaColumn; + + internal DataGrid FaturaGrid; + + private bool _contentLoaded; + + public SubTipo _previousSubTipo { get; set; } = 2; + + public ComissaoViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ComissaoView() + { + base.Tag = "COMISSÃO AUTOMÁTICA"; + this.ViewModel = new ComissaoViewModel(); + 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 + { + } + this.ExtratoGrid.DataContext = base.DataContext; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if (!(new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 7).get_Consultar()) + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)7), "."), "OK", "", false); + } + else if (this.ViewModel.SelectedExtrato != null) + { + List indiceArquivoDigitals = await (new ArquivoDigitalServico()).BuscarPorTipo(7, this.ViewModel.SelectedExtrato.get_Id()); + if (indiceArquivoDigitals.Count != 1) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedExtrato.get_Id()); + filtroArquivoDigital.set_Tipo(7); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedExtrato); + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + } + else + { + this.ViewModel.Download(indiceArquivoDigitals.First(), true); + } + } + else + { + await this.ViewModel.ShowMessage("SELECIONE ALGUM EXTRATO PARA VISUALIZAR O ARQUIVO DIGITAL", "OK", "", false); + } + } + + private async Task AbrirCritica(DetalheExtrato detalhe) + { + List statusParcelas = new List() + { + 1, + 10, + 12, + 13 + }; + if (!detalhe.get_Status().HasValue || !statusParcelas.Contains(detalhe.get_Status().Value)) + { + this.ViewModel.FiltrarDetalheExtrato(detalhe.get_Id()); + await this.ViewModel.BuscarCriticado(detalhe); + if (!detalhe.get_Parcela().HasValue && !detalhe.get_Documento().HasValue) + { + this.AutoCompleteCliente.set_Text(detalhe.get_Cliente().Trim()); + } + this.ViewModel.Criticando = true; + this.PainelCritica.Visibility = System.Windows.Visibility.Visible; + this.FiltroDetalhes.Visibility = System.Windows.Visibility.Collapsed; + this.DetalhesGrid.Visibility = System.Windows.Visibility.Collapsed; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.FiltroApolice = string.Empty; + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL CRITICAR UMA PARCELA JÁ BAIXADA", "OK", "", false); + } + } + + private async void AbrirCritica_OnClick(object sender, RoutedEventArgs e) + { + object item; + if (this.DetalhesGrid.SelectedIndex >= 0) + { + DataGrid detalhesGrid = this.DetalhesGrid; + if (detalhesGrid != null) + { + item = detalhesGrid.Items[this.DetalhesGrid.SelectedIndex]; + } + else + { + item = null; + } + DetalheExtrato detalheExtrato = (DetalheExtrato)item; + if (detalheExtrato != null) + { + this.ViewModel.Loading(true); + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + await this.AbrirCritica(detalheExtrato); + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.Loading(false); + } + } + else + { + await this.ViewModel.ShowMessage("PARA CRITICAR O DOCUMENTO É NECESSÁRIO SELECIONAR UMA PARCELA", "OK", "", false); + } + } + + private async void AcessarApolice_OnClick(object sender, RoutedEventArgs e) + { + long? parcela; + Documento documento; + Documento documento1; + bool flag; + bool flag1; + Button button = (Button)sender; + if (button.DataContext != null && button.DataContext.GetType().Name.Equals("DetalheExtrato")) + { + DetalheExtrato dataContext = (DetalheExtrato)button.DataContext; + flag = (dataContext != null ? !dataContext.get_Documento().HasValue : true); + if (flag) + { + flag1 = (dataContext != null ? !dataContext.get_Parcela().HasValue : true); + if (flag1) + { + return; + } + } + if (!dataContext.get_Documento().HasValue) + { + if (!dataContext.get_Parcela().HasValue) + { + documento1 = null; + } + else + { + ComissaoViewModel viewModel = this.ViewModel; + parcela = dataContext.get_Parcela(); + documento1 = await viewModel.CarregaApoliceParcela(parcela.Value); + } + documento = documento1; + } + else + { + ComissaoViewModel comissaoViewModel = this.ViewModel; + parcela = dataContext.get_Documento(); + documento = await comissaoViewModel.CarregaApolice(parcela.Value); + } + Documento documento2 = documento; + if (documento2 != null) + { + if (!documento2.get_Excluido()) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ApoliceView(documento2, true, false, 0, (long)0, true), string.Concat("CADASTRO DE APÓLICE - ", documento2.get_Controle().get_Cliente().get_Nome(), " - ", documento2.get_Apolice()), nullable1, nullable, false)).Show(); + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSIVE VISUALIZAR UM DOCUMENTO EXCLUIDO.", "OK", "", false); + } + } + } + } + + private async void AcessarApoliceCritica_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ApoliceView(await this.ViewModel.CarregaApolice(this.ViewModel.SelectedDocumento.get_Id()), true, false, 0, (long)0, false), string.Concat("CADASTRO DE APÓLICE - ", this.ViewModel.SelectedCliente.get_Nome(), " - ", this.ViewModel.SelectedDocumento.get_Apolice()), nullable1, nullable, false)).Show(); + } + + private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdcionarFiltro(); + } + + private async void ApoliceGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + ComissaoViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaDocumento((Documento)obj); + } + } + + private async void ArquivoDigitalButton_OnClick(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + this.ViewModel.SelectedDocumento.get_Controle().set_Cliente(this.ViewModel.SelectedCliente); + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedDocumento.get_Id()); + filtroArquivoDigital.set_Tipo(2); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedDocumento); + 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 ", ValidationHelper.GetDescription((TipoArquivoDigital)2), "."), "OK", "", false); + } + } + + private void Atualizar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.SelecionaSeguradora(this.ViewModel.SelectedSeguradora, this.ViewModel.SelectedStatusExtrato, this.ViewModel.SelectedExtrato); + } + + private async void AtualizarExtrato_OnClick(object sender, RoutedEventArgs e) + { + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.EnableButtons = false; + await this.ViewModel.AtualizarExtrato(); + await this.ViewModel.SelecionaExtrato(this.ViewModel.SelectedExtrato); + this.ViewModel.EnableButtons = true; + Action action = Gestor.Application.Actions.Actions.EnableMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMainMenu1 = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu1 != null) + { + enableMainMenu1(true); + } + else + { + } + } + + 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> searchResult) => { + if (searchResult.Result == null) + { + return; + } + AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private async void AutoCompleteBoxDetalhe_OnTextChanged(object sender, RoutedEventArgs e) + { + object text; + TextBox textBox = (TextBox)sender; + ComissaoViewModel viewModel = this.ViewModel; + if (textBox != null) + { + text = textBox.Text; + } + else + { + text = null; + } + if (text == null) + { + text = ""; + } + await viewModel.FiltrarDetalhe((string)text); + } + + private async void AutoCompleteBoxDocumento_OnTextChanged(object sender, RoutedEventArgs e) + { + object text; + TextBox textBox = (TextBox)sender; + ComissaoViewModel viewModel = this.ViewModel; + if (textBox != null) + { + text = textBox.Text; + } + else + { + text = null; + } + if (text == null) + { + text = ""; + } + await viewModel.FiltrarApolices((string)text); + } + + private async void BaixarParcelasSelecionadas_OnClick(object sender, RoutedEventArgs e) + { + ((MenuItem)sender).Click -= new RoutedEventHandler(this.BaixarParcelasSelecionadas_OnClick); + if (this.ViewModel.SelectedExtrato == null) + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarParcelasSelecionadas_OnClick); + } + else if (await this.ViewModel.ShowMessage(string.Concat("DESEJA BAIXAR TODAS AS PARCELAS SELECIONADAS DO EXTRATO ", this.ViewModel.SelectedExtrato.get_Numero(), "?"), "SIM", "NÃO", false)) + { + this.ViewModel.IsVisible = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.EnableButtons = false; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.EnableButtons = false; + await this.ViewModel.BaixarExtrato(true); + this.ViewModel.EnableButtons = true; + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ViewModel.EnableButtons = true; + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + this.ViewModel.WorkOnSelectedStatus(); + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarParcelasSelecionadas_OnClick); + } + else + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarParcelasSelecionadas_OnClick); + } + } + + private async void BaixarSelecionado_OnClick(object sender, RoutedEventArgs e) + { + ((MenuItem)sender).Click -= new RoutedEventHandler(this.BaixarSelecionado_OnClick); + if (this.ViewModel.SelectedExtrato == null) + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarSelecionado_OnClick); + } + else if (await this.ViewModel.ShowMessage(string.Concat("DESEJA BAIXAR TODAS AS PARCELAS PENDENTES DO EXTRATO ", this.ViewModel.SelectedExtrato.get_Numero(), "?"), "SIM", "NÃO", false)) + { + this.ViewModel.IsVisible = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.EnableButtons = false; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.EnableButtons = false; + await this.ViewModel.BaixarExtrato(false); + this.ViewModel.EnableButtons = true; + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ViewModel.EnableButtons = true; + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarSelecionado_OnClick); + } + else + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.BaixarSelecionado_OnClick); + } + } + + private void CancelarCritica_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDetalhe != null) + { + this.ViewModel.SelectedDetalhe.set_Corrigir(false); + } + this.LimparFiltros(); + } + + private void ContentLoad() + { + this.DataBaixaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.DataBaixaBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.SelectedDateChanged += new EventHandler(this.FiltroDataBox_OnSelectedDateChanged); + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.FimBox.SelectedDateChanged += new EventHandler(this.FiltroDataBox_OnSelectedDateChanged); + this.ExtratoGrid.SelectionChanged += new SelectionChangedEventHandler(this.Grid_OnSelectionChanged); + this.ExtratoGrid.MouseDoubleClick += new MouseButtonEventHandler((object sender, MouseButtonEventArgs args) => { + }); + this.DetalhesGrid.MouseDoubleClick += new MouseButtonEventHandler(this.DetalhesGrid_OnMouseDoubleClick); + this.ApoliceGrid.SelectionChanged += new SelectionChangedEventHandler(this.ApoliceGrid_OnSelectionChanged); + } + + private async void CriticarDocumento_OnClick(object sender, RoutedEventArgs e) + { + DetalheExtrato selectedDetalhe; + int? nullable; + object item; + if (this.DetalhesGrid.SelectedIndex >= 0) + { + SubTipo? subTipo = this.ViewModel.SelectedDetalhe.get_SubTipo(); + if (subTipo.HasValue && subTipo.GetValueOrDefault() == 1) + { + if (this.ViewModel.SelectedParcela == null || this.ViewModel.SelectedParcela.get_Id() == 0) + { + await this.ViewModel.ShowMessage("PARA CRITICAR ESSE DOCUMENTO É NECESSÁRIO SELECIONAR UMA PARCELA", "OK", "", false); + return; + } + } + else if (this.ViewModel.SelectedDocumento == null || this.ViewModel.SelectedDocumento.get_Id() == 0) + { + await this.ViewModel.ShowMessage("PARA CRITICAR ESSE DOCUMENTO É NECESSÁRIO SELECIONAR UM DOCUMENTO", "OK", "", false); + return; + } + if (this.DetalhesGrid.SelectedIndex < 0) + { + DataGrid detalhesGrid = this.DetalhesGrid; + if (detalhesGrid != null) + { + nullable = new int?(detalhesGrid.Items.Count); + } + else + { + nullable = null; + } + int? nullable1 = nullable; + int selectedIndex = this.DetalhesGrid.SelectedIndex; + if (nullable1.GetValueOrDefault() < selectedIndex | !nullable1.HasValue) + { + goto Label2; + } + DataGrid dataGrid = this.DetalhesGrid; + if (dataGrid != null) + { + item = dataGrid.Items[this.DetalhesGrid.SelectedIndex]; + } + else + { + item = null; + } + selectedDetalhe = (DetalheExtrato)item; + goto Label1; + } + Label2: + selectedDetalhe = this.ViewModel.SelectedDetalhe; + Label1: + DetalheExtrato detalheExtrato = selectedDetalhe; + if (detalheExtrato != null) + { + await this.ViewModel.Criticar(detalheExtrato, true); + this.LimparFiltros(); + } + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR UMA PARCELA PARA CRITICAR.", "OK", "", false); + } + } + + private async void Desconsiderar_OnClick(object sender, RoutedEventArgs e) + { + object item; + if (this.DetalhesGrid.SelectedIndex >= 0) + { + DataGrid detalhesGrid = this.DetalhesGrid; + if (detalhesGrid != null) + { + item = detalhesGrid.Items[this.DetalhesGrid.SelectedIndex]; + } + else + { + item = null; + } + DetalheExtrato detalheExtrato = (DetalheExtrato)item; + if (detalheExtrato != null) + { + await this.ViewModel.Criticar(detalheExtrato, false); + this.LimparFiltros(); + } + } + else + { + await this.ViewModel.ShowMessage("PARA DESCONSIDERAR O DOCUMENTO É NECESSÁRIO SELECIONAR UMA PARCELA", "OK", "", false); + } + } + + private async void DesconsiderarSelacionadas_Click(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.ShowMessage(string.Concat("ESSA OPÇÃO DESCONSIDERA TODAS AS PARCELAS QUE FORAM SELECIONADAS, COLOCANDO STATUS DE DESCONSIDERADA PELO USUÁRIO", Environment.NewLine, "DESEJA CONTINUAR?"), "SIM", "NÃO", false)) + { + await this.ViewModel.DesconsiderarSelecionadas(); + } + } + + private async void DesconsiderarTodas_Click(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.ShowMessage(string.Concat("ESSA OPÇÃO DESCONSIDERA TODAS AS PARCELAS COM O STATUS DE DOCUMENTO NÃO ENCONTRADO OU PARCELA NÃO ENCONTRADA DO EXTRATO.", Environment.NewLine, "DESEJA CONTINUAR?"), "SIM", "NÃO", false)) + { + await this.ViewModel.CriticarTodos(this.ViewModel.SelectedExtrato.get_Id()); + this.LimparFiltros(); + } + } + + private async void DesfazerExtrato_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedExtrato != null) + { + if (await this.ViewModel.ShowMessage(string.Concat("DESEJA DESFAZER A BAIXA DO EXTRATO ", this.ViewModel.SelectedExtrato.get_Numero(), "?"), "SIM", "NÃO", false)) + { + this.ViewModel.IsVisible = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.EnableButtons = false; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + await this.ViewModel.DesfazerExtrato(); + this.ViewModel.EnableButtons = true; + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + } + } + } + + private async void DesfazerParcela_OnClick(object sender, RoutedEventArgs e) + { + object item; + DataGrid detalhesGrid = this.DetalhesGrid; + if (detalhesGrid != null) + { + item = detalhesGrid.Items[this.DetalhesGrid.SelectedIndex]; + } + else + { + item = null; + } + DetalheExtrato detalheExtrato = (DetalheExtrato)item; + if (detalheExtrato != null) + { + if (await this.ViewModel.ShowMessage(string.Concat("DESEJA DESFAZER A BAIXA DA PARCELA DO CLIENTE ", detalheExtrato.get_Cliente(), "?"), "SIM", "NÃO", false)) + { + this.ViewModel.Loading(true); + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.EnableButtons = false; + bool flag = await this.ViewModel.DesfazerParcela(detalheExtrato); + await this.ViewModel.CarregaDetalhes(this.ViewModel.SelectedExtrato); + ComissaoViewModel viewModel = this.ViewModel; + viewModel.ToggleSnackBar((flag ? "PARCELA DESFEITA COM SUCESSO" : "NÃO FOI POSSÍVEL DESFAZER A BAIXA DA PARCELA"), true); + if (flag && detalheExtrato.get_Parcela().HasValue) + { + ComissaoViewModel comissaoViewModel = this.ViewModel; + string str = string.Format("DESFEZ PARCELA DE ID \"{0}\"", detalheExtrato.get_Parcela()); + long? parcela = detalheExtrato.get_Parcela(); + comissaoViewModel.RegistrarAcao(str, parcela.Value, new TipoTela?(35), null); + } + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ViewModel.EnableButtons = true; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.Loading(false); + } + } + detalheExtrato = null; + } + + private async void DetalhesGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + this.ViewModel.Loading(true); + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + DetalheExtrato detalheExtrato = (DetalheExtrato)obj; + if (detalheExtrato != null) + { + await this.AbrirCritica(detalheExtrato); + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.Loading(false); + } + } + } + + private async void ExcluirExtrato_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedExtrato != null) + { + if (await this.ViewModel.ShowMessage(string.Concat("DESEJA EXCLUIR O EXTRATO ", this.ViewModel.SelectedExtrato.get_Numero(), "?"), "SIM", "NÃO", false)) + { + this.ViewModel.IsVisible = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.EnableButtons = false; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + await this.ViewModel.ExcluirExtrato(); + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ViewModel.EnableButtons = true; + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + } + } + } + + private void ExcluirFiltro_onClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(chip); + string item = (string)listBox.Items[listBox.Items.IndexOf(chip.DataContext)]; + if (item == null) + { + return; + } + this.ViewModel.ExcluirFiltro(item); + } + + private void FiltroDataBox_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + bool hasValue; + DatePicker datePicker = (DatePicker)sender; + if (datePicker != null) + { + hasValue = !datePicker.SelectedDate.HasValue; + } + else + { + hasValue = true; + } + if (hasValue) + { + return; + } + this.ViewModel.SelecionaSeguradora(this.ViewModel.SelectedSeguradora, this.ViewModel.SelectedStatusExtrato, null); + } + + private async void FinalizarSelecionado_OnClick(object sender, RoutedEventArgs e) + { + ((MenuItem)sender).Click -= new RoutedEventHandler(this.FinalizarSelecionado_OnClick); + if (this.ViewModel.SelectedExtrato != null) + { + ComissaoViewModel viewModel = this.ViewModel; + string[] numero = new string[] { "DESEJA FINALIZAR O EXTRATO ", this.ViewModel.SelectedExtrato.get_Numero(), "?", Environment.NewLine, "O EXTRATO SERÁ MARCADO COMO BAIXADO." }; + if (await viewModel.ShowMessage(string.Concat(numero), "SIM", "NÃO", false)) + { + this.ViewModel.IsVisible = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + this.ViewModel.EnableButtons = false; + await this.ViewModel.FinalizarExtrato(); + this.ViewModel.EnableButtons = true; + Action action = Gestor.Application.Actions.Actions.EnableMainMenu; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + this.ViewModel.IsVisibleDetalhes = System.Windows.Visibility.Visible; + this.ViewModel.IsVisible = System.Windows.Visibility.Visible; + ((MenuItem)sender).Click += new RoutedEventHandler(this.FinalizarSelecionado_OnClick); + } + else + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.FinalizarSelecionado_OnClick); + } + } + else + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.FinalizarSelecionado_OnClick); + } + } + + private async void Grid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null) + { + if (dataGrid.SelectedIndex >= 0) + { + await this.ViewModel.SelecionaExtrato((Extrato)dataGrid.Items[dataGrid.SelectedIndex]); + } + } + } + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedExtrato != null) + { + string str = await this.ViewModel.GerarHtml(); + if (!string.IsNullOrEmpty(str)) + { + string tempPath = Path.GetTempPath(); + string str1 = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, (new Regex(string.Concat("[", Regex.Escape(string.Concat(new string(Path.GetInvalidFileNameChars()), new string(Path.GetInvalidPathChars()))), "]"))).Replace("EXTRATO COMISSÃO", ""), Funcoes.GetNetworkTime()); + StreamWriter streamWriter = new StreamWriter(str1, true, Encoding.UTF8); + streamWriter.Write(str); + streamWriter.Close(); + Process.Start(str1); + this.ViewModel.RegistrarAcao(string.Format("IMPRIMIU EXTRATO DE ID \"{0}\"", this.ViewModel.SelectedExtrato.get_Id()), this.ViewModel.SelectedExtrato.get_Id(), new TipoTela?(35), null); + } + } + } + + [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/comissaoview.xaml", UriKind.Relative)); + } + + private void LimparFiltros() + { + this.ViewModel.Criticando = false; + this.ViewModel.FiltrarDetalheExtrato(""); + this.PainelCritica.Visibility = System.Windows.Visibility.Collapsed; + this.FiltroDetalhes.Visibility = System.Windows.Visibility.Visible; + this.AutoCompleteCliente.set_Text(string.Empty); + this.DetalhesGrid.Visibility = System.Windows.Visibility.Visible; + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(true); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu == null) + { + return; + } + enableMenu(true); + } + + private void Subtipo_OnDropDownOpened(object sender, EventArgs e) + { + this._previousSubTipo = (SubTipo)((ComboBox)sender).SelectedItem; + } + + private void Subtipo_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (!this.ViewModel.IsEnabled) + { + return; + } + ComboBox comboBox = (ComboBox)sender; + if ((SubTipo)comboBox.SelectedItem != 1) + { + return; + } + DetalheExtrato dataContext = (DetalheExtrato)comboBox.DataContext; + if ((SubTipo)comboBox.SelectedItem == 1 && dataContext.get_NumeroParcela() == "999" || !dataContext.IsNormal && dataContext.get_SubTipo().GetValueOrDefault() == 1) + { + comboBox.SelectedItem = this._previousSubTipo; + } + } + + [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.UsuarioBox = (ComboBox)target; + return; + } + case 2: + { + this.StatusBox = (ComboBox)target; + return; + } + case 3: + { + this.SeguradoraBox = (ComboBox)target; + return; + } + case 4: + { + this.Seguradora2Box = (ComboBox)target; + return; + } + case 5: + { + this.InicioBox = (DatePicker)target; + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + return; + } + case 6: + { + this.FimBox = (DatePicker)target; + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + return; + } + case 7: + { + ((Button)target).Click += new RoutedEventHandler(this.Atualizar_OnClick); + return; + } + case 8: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltro_OnClick); + return; + } + case 9: + case 29: + case 30: + case 31: + case 32: + case 33: + case 40: + case 41: + { + this._contentLoaded = true; + return; + } + case 10: + { + this.ExtratoGrid = (DataGrid)target; + return; + } + case 11: + { + this.ProgressBar2 = (Card)target; + return; + } + case 12: + { + this.ProgressBar = (Card)target; + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AtualizarExtrato_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.FinalizarSelecionado_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.BaixarParcelasSelecionadas_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.BaixarSelecionado_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.DesconsiderarTodas_Click); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.DesconsiderarSelacionadas_Click); + return; + } + case 19: + { + this.DesfazerExtratoButton = (MenuItem)target; + this.DesfazerExtratoButton.Click += new RoutedEventHandler(this.DesfazerExtrato_OnClick); + return; + } + case 20: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirExtrato_OnClick); + return; + } + case 21: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CriticarDocumento_OnClick); + return; + } + case 22: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Desconsiderar_OnClick); + return; + } + case 23: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.CancelarCritica_OnClick); + return; + } + case 24: + { + this.DataBaixaBox = (DatePicker)target; + this.DataBaixaBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + return; + } + case 25: + { + this.FiltroDetalhes = (TextBox)target; + this.FiltroDetalhes.TextChanged += new TextChangedEventHandler(this.AutoCompleteBoxDetalhe_OnTextChanged); + return; + } + case 26: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + case 27: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 28: + { + this.DetalhesGrid = (DataGrid)target; + return; + } + case 34: + { + this.PainelCritica = (Grid)target; + return; + } + case 35: + { + this.AutoCompleteCliente = (AutoCompleteBox)target; + this.AutoCompleteCliente.add_Populating(new PopulatingEventHandler(this, ComissaoView.AutoCompleteBox_Populating)); + return; + } + case 36: + { + this.TipoDocumentoPrincipalBox = (TextBox)target; + return; + } + case 37: + { + this.DocumentoPrincipalBox = (TextBox)target; + return; + } + case 38: + { + this.FiltroApoliceBox = (TextBox)target; + this.FiltroApoliceBox.TextChanged += new TextChangedEventHandler(this.AutoCompleteBoxDocumento_OnTextChanged); + return; + } + case 39: + { + this.ApoliceGrid = (DataGrid)target; + return; + } + case 42: + { + this.ParcelaGrid = (DataGrid)target; + return; + } + case 43: + { + this.ParcelaColumn = (DataGridTextColumn)target; + return; + } + case 44: + { + this.FaturaGrid = (DataGrid)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) + { + if (connectionId == 9) + { + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_onClick)); + return; + } + switch (connectionId) + { + case 29: + { + ((Button)target).Click += new RoutedEventHandler(this.AcessarApolice_OnClick); + return; + } + case 30: + { + ((ComboBox)target).DropDownOpened += new EventHandler(this.Subtipo_OnDropDownOpened); + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Subtipo_OnSelectionChanged); + return; + } + case 31: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirCritica_OnClick); + return; + } + case 32: + { + ((Button)target).Click += new RoutedEventHandler(this.Desconsiderar_OnClick); + return; + } + case 33: + { + ((Button)target).Click += new RoutedEventHandler(this.DesfazerParcela_OnClick); + return; + } + case 34: + case 35: + case 36: + case 37: + case 38: + case 39: + { + return; + } + case 40: + { + ((Button)target).Click += new RoutedEventHandler(this.AcessarApoliceCritica_OnClick); + return; + } + case 41: + { + ((Button)target).Click += new RoutedEventHandler(this.ArquivoDigitalButton_OnClick); + return; + } + default: + { + return; + } + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/ConsultaOriginalView.cs b/Codemerx/Gestor.Application/Views/Seguros/ConsultaOriginalView.cs new file mode 100644 index 0000000..0e5096d --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/ConsultaOriginalView.cs @@ -0,0 +1,1502 @@ +using Gestor.Application.Actions; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.MalaDireta; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Seguros; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Collections.ObjectModel; +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.Media; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros +{ + public class ConsultaOriginalView : BaseUserControl, IComponentConnector, IStyleConnector + { + public ConsultaViewModel ViewModel; + + private bool _carregarDocumetos = true; + + internal RadioButton ApoliceRadioButton; + + internal RadioButton EndossoRadioButton; + + internal MenuItem AcessarDocumentoMenuItem; + + internal DataGrid ApoliceGrid; + + internal DataGridTextColumn NomeField; + + internal DataGridTextColumn ApelidoField; + + internal DataGridTextColumn ApolicesComissaoColumn; + + internal DataGrid EndossoGrid; + + internal DataGridTextColumn EndossosComissaoColumn; + + internal WrapPanel Comissao; + + internal DataGrid ParcelaGrid; + + internal DataGridTextColumn ParcelasTotalColumn; + + internal DataGridTextColumn ParcelasRealizadoColumn; + + internal DataGridTextColumn ParcelasComissaoColumn; + + internal DataGridTextColumn ParcelasReciboColumn; + + internal DataGridTextColumn ParcelasValorComissaoDescColumn; + + internal DataGridTemplateColumn MaisInformacoesColumn; + + internal RadioButton AtivosRadioButton; + + internal RadioButton ApoliceItensRadioButton; + + internal RadioButton EndossoItensRadioButton; + + internal RadioButton InativosRadioButton; + + internal DataGrid ItemGrid; + + private bool _contentLoaded; + + private Documento _documentoAssistencia + { + get; + set; + } + + private string _linkAssistencia + { + get; + set; + } + + public ConsultaOriginalView(ConsultaViewModel viewModel) + { + base.Tag = "CONSULTA DE DOCUMENTOS"; + this.ViewModel = viewModel ?? new ConsultaViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + Gestor.Application.Actions.Actions.UpdateRadioApolice = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.UpdateRadioApolice, new Action(this.SelecionarRadios)); + Gestor.Application.Actions.Actions.ScrollDocumento = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.ScrollDocumento, new Action(this.ScrollDocumento)); + Gestor.Application.Actions.Actions.ScrollToItem = new Action(this.ScrollToItem); + Gestor.Application.Actions.Actions.ScrollToItem = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.ScrollToItem, new Action(this.ScrollToItem)); + this.ItemGrid.DataContext = this.ViewModel; + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + FiltroArquivoDigital filtroArquivoDigital = null; + ConsultaViewModel.DocumentoSelecionado.get_Controle().set_Cliente(this.ViewModel.SelectedCliente); + string name = ((Button)sender).Name; + if (name == "Apolice") + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + this.ViewModel.SelectedControle.get_Controle().set_Cliente(this.ViewModel.SelectedCliente); + FiltroArquivoDigital filtroArquivoDigital1 = new FiltroArquivoDigital(); + filtroArquivoDigital1.set_Id(this.ViewModel.SelectedControle.get_Id()); + filtroArquivoDigital1.set_Tipo(2); + filtroArquivoDigital1.set_Parente(this.ViewModel.SelectedControle); + filtroArquivoDigital = filtroArquivoDigital1; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)2), "."), "OK", "", false); + return; + } + } + else if (name == "Endosso") + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + this.ViewModel.SelectedEndosso.get_Controle().set_Cliente(this.ViewModel.SelectedCliente); + FiltroArquivoDigital filtroArquivoDigital2 = new FiltroArquivoDigital(); + filtroArquivoDigital2.set_Id(this.ViewModel.SelectedEndosso.get_Id()); + filtroArquivoDigital2.set_Tipo(2); + filtroArquivoDigital2.set_Parente(this.ViewModel.SelectedEndosso); + filtroArquivoDigital = filtroArquivoDigital2; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)2), "."), "OK", "", false); + return; + } + } + else if (name != "Parcela") + { + if (name == "Item") + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + this.ViewModel.SelectedItem.set_Documento(ConsultaViewModel.DocumentoSelecionado); + FiltroArquivoDigital filtroArquivoDigital3 = new FiltroArquivoDigital(); + filtroArquivoDigital3.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital3.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital3.set_Tipo(4); + filtroArquivoDigital3.set_Parente(this.ViewModel.SelectedItem); + filtroArquivoDigital = filtroArquivoDigital3; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)4), "."), "OK", "", false); + return; + } + } + } + else if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 3).get_Consultar()) + { + this.ViewModel.SelectedParcela.set_Documento(ConsultaViewModel.DocumentoSelecionado); + FiltroArquivoDigital filtroArquivoDigital4 = new FiltroArquivoDigital(); + filtroArquivoDigital4.set_Id(this.ViewModel.SelectedParcela.get_Id()); + filtroArquivoDigital4.set_IdApolice(this.ViewModel.SelectedParcela.get_Documento().get_Id()); + filtroArquivoDigital4.set_Tipo(3); + filtroArquivoDigital4.set_Parente(this.ViewModel.SelectedParcela); + filtroArquivoDigital = filtroArquivoDigital4; + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)3), "."), "OK", "", false); + return; + } + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + } + + private async Task AbrirProspeccao(Prospeccao data) + { + do + { + Label1: + if (await this.ViewModel.ShowProspeccaoDialog(data) != null) + { + List> keyValuePairs = await this.ViewModel.SalvarProspeccao(data); + if (keyValuePairs == null || keyValuePairs.Count == 0) + { + this.ViewModel.ToggleSnackBar("PROSPECÇÃO SALVA COM SUCESSO.", true); + return; + } + else + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + goto Label1; + } + } + else + { + } + } + while (!await this.ViewModel.ShowMessage("DESEJA REALMENTE NÃO CADASTRAR UMA PROSPECÇÃO PARA ESSE DOCUMENTO?", "SIM", "NÃO", false)); + } + + private void AjustaItem() + { + this.AtivosRadioButton.IsChecked = new bool?(this.ViewModel.FilterItens == 0); + this.ApoliceItensRadioButton.IsChecked = new bool?(this.ViewModel.FilterItens == 1); + this.EndossoItensRadioButton.IsChecked = new bool?(this.ViewModel.FilterItens == 2); + this.InativosRadioButton.IsChecked = new bool?(this.ViewModel.FilterItens == 3); + } + + private async void ApoliceGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + object obj; + long? nullable; + object obj1; + DataGridRow dataGridRow = (DataGridRow)sender; + if (dataGridRow != null) + { + if (dataGridRow.DataContext.GetType() == typeof(Documento)) + { + this.AtivosRadioButton.IsChecked = new bool?(true); + obj = (dataGridRow != null ? dataGridRow.Item : null); + Documento documento = (Documento)obj; + if (documento != null) + { + nullable = new long?(documento.get_Id()); + } + else + { + nullable = null; + } + long? nullable1 = nullable; + long id = this.ViewModel.SelectedControle.get_Id(); + if (nullable1.GetValueOrDefault() != id | !nullable1.HasValue) + { + ConsultaViewModel viewModel = this.ViewModel; + obj1 = (dataGridRow != null ? dataGridRow.Item : null); + await viewModel.SelecionaDocumento(0, (Documento)obj1); + } + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela != null) + { + acessaTela(2, ""); + } + else + { + } + } + } + } + + private async void ApoliceGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + ConsultaViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaDocumento(0, (Documento)obj); + this.VisibilityValorPago(); + } + } + + private void ApoliceView_Click(object sender, RoutedEventArgs e) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(2, ""); + } + + private void ClienteView_Click(object sender, RoutedEventArgs e) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(1, ""); + } + + private void ContentLoad() + { + if (ConsultaViewModel.DocumentoSelecionado != null && ConsultaViewModel.DocumentoSelecionado.get_Tipo() != 0) + { + this.ViewModel.FilterDocumento = 1; + } + this.NomeField.Visibility = (this.ViewModel.Apelido ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ApelidoField.Visibility = (!this.ViewModel.Apelido ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ApoliceRadioButton.IsChecked = new bool?(this.ViewModel.FilterDocumento == 0); + this.EndossoRadioButton.IsChecked = new bool?(this.ViewModel.FilterDocumento == 1); + this.AjustaItem(); + this.ApoliceGrid.SelectionChanged += new SelectionChangedEventHandler(this.ApoliceGrid_OnSelectionChanged); + this.ParcelaGrid.MouseDoubleClick += new MouseButtonEventHandler(ConsultaOriginalView.ParcelaGrid_OnMouseDoubleClick); + this.EndossoGrid.SelectionChanged += new SelectionChangedEventHandler(this.EndossoGrid_OnSelectionChanged); + this.EndossoGrid.MouseDoubleClick += new MouseButtonEventHandler(this.EndossoGrid_OnMouseDoubleClick); + this.AtivosRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.ApoliceItensRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.EndossoItensRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.InativosRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.ApoliceRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.EndossoRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.ItemGrid.SelectionChanged += new SelectionChangedEventHandler(this.ItemGrid_OnSelectionChanged); + this.ItemGrid.MouseDoubleClick += new MouseButtonEventHandler(this.ItemGrid_OnMouseDoubleClick); + System.Windows.Visibility visibility = (this.ViewModel.Restricao(14) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ViewModel.ComissaoValorVisibility = (this.ViewModel.Restricao(14) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + bool flag = this.ViewModel.Restricao(95); + this.ApolicesComissaoColumn.Visibility = (flag ? System.Windows.Visibility.Visible : visibility); + this.EndossosComissaoColumn.Visibility = (flag ? System.Windows.Visibility.Visible : visibility); + this.Comissao.Visibility = visibility; + bool flag1 = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 5); + this.ParcelasRealizadoColumn.Visibility = visibility; + this.ParcelasComissaoColumn.Visibility = (flag ? System.Windows.Visibility.Visible : visibility); + this.ParcelasReciboColumn.Visibility = (flag1 ? System.Windows.Visibility.Collapsed : visibility); + this.ParcelasValorComissaoDescColumn.Visibility = (flag1 ? visibility : System.Windows.Visibility.Collapsed); + this.MaisInformacoesColumn.Visibility = visibility; + } + + private async void Documento_OnChecked(object sender, RoutedEventArgs e) + { + object obj; + object obj1; + MenuItem acessarDocumentoMenuItem = this.AcessarDocumentoMenuItem; + obj = (this.ViewModel.FilterDocumento == 0 ? "ACESSAR APÓLICE" : "ACESSAR ENDOSSO"); + acessarDocumentoMenuItem.Header = obj; + MenuItem menuItem = this.AcessarDocumentoMenuItem; + obj1 = (this.ViewModel.FilterDocumento == 0 ? "CLIQUE PARA ACESSAR A TELA DA APÓLICE" : "CLIQUE PARA ACESSAR A TELA DE ENDOSSO"); + menuItem.ToolTip = obj1; + RadioButton radioButton = (RadioButton)sender; + if (!string.IsNullOrEmpty(radioButton.GroupName)) + { + string groupName = radioButton.GroupName; + if (groupName != "Apolices") + { + if (groupName == "Itens") + { + string name = radioButton.Name; + if (name == "ApoliceItensRadioButton") + { + await this.ViewModel.SelecionaItens(1, null, (long)0, false); + } + else if (name == "EndossoItensRadioButton") + { + await this.ViewModel.SelecionaItens(2, null, (long)0, false); + } + else if (name == "InativosRadioButton") + { + await this.ViewModel.SelecionaItens(3, null, (long)0, false); + } + else + { + await this.ViewModel.SelecionaItens(0, null, (long)0, false); + } + } + } + else if (!this._carregarDocumetos) + { + return; + } + else if (radioButton.Name == "EndossoRadioButton") + { + this.AcessarDocumentoMenuItem.Header = "ACESSAR ENDOSSO"; + this.AcessarDocumentoMenuItem.ToolTip = "CLIQUE PARA ACESSAR A TELA DE ENDOSSO"; + this.ViewModel.CarregaDocumentos(1); + if (this.EndossoGrid.SelectedItem == null && this.EndossoGrid.Items.Count > 0) + { + this.EndossoGrid.SelectedItem = this.EndossoGrid.Items[0]; + } + if (this.EndossoGrid.SelectedItem != null) + { + await this.ViewModel.SelecionaDocumento(1, (Documento)this.EndossoGrid.SelectedItem); + } + } + else + { + this.AcessarDocumentoMenuItem.Header = "ACESSAR APÓLICE"; + this.AcessarDocumentoMenuItem.ToolTip = "CLIQUE PARA ACESSAR A TELA DA APÓLICE"; + this.ViewModel.CarregaDocumentos(0); + if (this.ApoliceGrid.SelectedItem == null && this.ApoliceGrid.Items.Count > 0) + { + this.ApoliceGrid.SelectedItem = this.ApoliceGrid.Items[0]; + } + if (this.ApoliceGrid.SelectedItem != null) + { + await this.ViewModel.SelecionaDocumento(0, (Documento)this.ApoliceGrid.SelectedItem); + } + } + } + } + + private async void EditarParcelas_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.EditarParcelas(); + } + + private async void Endossar_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.Restricao(33)) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ENDOSSAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + else if (!this.ViewModel.EnableEndossar) + { + List> keyValuePairs = this.ViewModel.SelectedControle.ValidateEndossar(); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (ConsultaViewModel.DocumentoSelecionado.get_Situacao() != 7) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela != null) + { + acessaTela(2, "Endossar"); + } + else + { + } + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ENDOSSAR UM DOCUMENTO RECUSADO.", "OK", "", false); + } + } + + private async void EndossoGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + this.AtivosRadioButton.IsChecked = new bool?(true); + ConsultaViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaDocumento(1, (Documento)obj); + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela != null) + { + acessaTela(2, ""); + } + else + { + } + } + } + + private async void EndossoGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + object obj; + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid == null || dataGrid.SelectedIndex >= 0) + { + ConsultaViewModel viewModel = this.ViewModel; + obj = (dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null); + await viewModel.SelecionaDocumento(1, (Documento)obj); + this.VisibilityValorPago(); + } + } + + private void EnviarPorEmail_OnClick(object sender, RoutedEventArgs e) + { + if (this._documentoAssistencia == null) + { + return; + } + MalaDireta malaDiretum = new MalaDireta(); + malaDiretum.set_Cliente(this.ViewModel.SelectedCliente); + malaDiretum.set_Apolice(this._documentoAssistencia); + MalaDireta malaDiretum1 = malaDiretum; + if (Funcoes.IsWindowOpen("ENVIO DE E-MAIL")) + { + Funcoes.Destroy("ENVIO DE E-MAIL"); + } + (new HosterWindow(new MalaDiretaView(new List() + { + malaDiretum1 + }, string.Concat("CARTÃO ASSISTÊNCIA 24 HORAS - ", malaDiretum1.get_Cliente().get_Nome(), " ", malaDiretum1.get_Apolice().get_Apolice()), string.Concat(new string[] { "

Prezado(a) ", ValidationHelper.Captalize(this.ViewModel.SelectedCliente.get_Nome()), ", segue o link do seu Cartão Assistência 24 horas.

LINK CARTÃO ASSITÊNCIA

" }), null), "ENVIO DE E-MAIL", new double?((double)1200), new double?((double)600), true)).ShowDialog(); + } + + private async void EnviarPorWhatsApp_OnClick(object sender, RoutedEventArgs e) + { + string str; + if (!this.ViewModel.Restricao(32)) + { + Button button = (Button)sender; + if (button.DataContext != null) + { + ClienteTelefone dataContext = button.DataContext as ClienteTelefone; + if (dataContext != null) + { + str = (!dataContext.get_Tipo().HasValue || dataContext.get_Tipo().GetValueOrDefault() != 8 ? string.Concat("55", dataContext.get_Prefixo(), dataContext.get_Numero().Clear()) : string.Concat(dataContext.get_Prefixo(), dataContext.get_Numero()).Clear()); + if (!str.EnviarWhatsapp(this.ViewModel.Anotacoes)) + { + await this.ViewModel.ShowMessage("HOUVE UM PROBLEMA AO ABRIR LINK DO WHATSAPP, O LINK FOI COPIADO EM SUA MAQUINA, BASTA ABRIR O NAVEGADOR DE INTERNET E COLAR NA BARRA DE ENDEREÇOS", "OK", "", false); + } + return; + } + } + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR O WHATSAPP", "OK", "", false); + } + } + + private async void ExpedicaoInfo_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.VerificarPermissao(46, false)) + { + if (ConsultaViewModel.DocumentoSelecionado != null) + { + this.ViewModel.ShowDrawer(new ExpedicaoDrawer(ConsultaViewModel.DocumentoSelecionado), 0, false); + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR UM DOCUMENTO PARA EXIBIR AS INFORMAÇÕES DE EXPEDIÇÃO.", "OK", "", false); + } + } + } + + private async void Extratos_OnClick(object sender, RoutedEventArgs e) + { + Relatorio? nullable; + if (await this.ViewModel.VerificarRestricao(13, false, true) && this.ViewModel.SelectedCliente.get_Id() != 0) + { + this.ViewModel.Loading(true); + if (this.ViewModel.SelectedControle != null) + { + int filterDocumento = this.ViewModel.FilterDocumento; + if (filterDocumento != 0) + { + if (filterDocumento == 1) + { + if (this.ViewModel.SelectedEndosso != null) + { + ConsultaViewModel viewModel = this.ViewModel; + List documentos = new List() + { + this.ViewModel.SelectedEndosso + }; + nullable = null; + List nums = new List() + { + this.ViewModel.SelectedEndosso.get_Id() + }; + viewModel.ShowDrawer(new ExtratosDrawer(null, documentos, nullable, nums, null, null), 0, false); + } + } + } + else if (this.ViewModel.SelectedControle != null) + { + ConsultaViewModel consultaViewModel = this.ViewModel; + List documentos1 = new List() + { + this.ViewModel.SelectedControle + }; + nullable = null; + List nums1 = new List() + { + this.ViewModel.SelectedControle.get_Id() + }; + consultaViewModel.ShowDrawer(new ExtratosDrawer(null, documentos1, nullable, nums1, null, null), 0, false); + } + this.ViewModel.Loading(false); + } + else + { + ConsultaViewModel viewModel1 = this.ViewModel; + List clientesAtivosInativos = new List(); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Selecionado(true); + clientesAtivosInativo.set_EntidadeCliente(this.ViewModel.SelectedCliente); + clientesAtivosInativo.set_Id(this.ViewModel.SelectedCliente.get_Id()); + clientesAtivosInativo.set_Nome(this.ViewModel.SelectedCliente.get_Nome()); + clientesAtivosInativo.set_Documento(this.ViewModel.SelectedCliente.get_Documento()); + clientesAtivosInativos.Add(clientesAtivosInativo); + viewModel1.ShowDrawer(new ExtratosDrawer(clientesAtivosInativos, null, new Relatorio?(0), null, null, null), 0, false); + this.ViewModel.Loading(false); + } + } + } + + public Visual GetDescendantByType(Visual element, Type type) + { + if (element == null) + { + return null; + } + if (element.GetType() == type) + { + return element; + } + Visual descendantByType = null; + FrameworkElement frameworkElement = element as FrameworkElement; + if (frameworkElement != null) + { + frameworkElement.ApplyTemplate(); + } + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++) + { + Visual child = VisualTreeHelper.GetChild(element, i) as Visual; + descendantByType = this.GetDescendantByType(child, type); + if (descendantByType != null) + { + break; + } + } + return descendantByType; + } + + [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/consultaoriginalview.xaml", UriKind.Relative)); + } + + private void Item_Click(object sender, RoutedEventArgs e) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(3, ""); + } + + private void ItemGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaItem((Item)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(3, ""); + } + + private void ItemGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + Item selectedItem = (Item)dataGrid.SelectedItem; + if (!selectedItem.get_Cancelado() && !selectedItem.get_Substituido().HasValue && selectedItem.get_Status() != null) + { + this.AjustaItem(); + } + this.ViewModel.SelecionaItem((Item)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private async void ManutecaoItens_OnClick(object sender, RoutedEventArgs e) + { + if ((this.ViewModel.FilterDocumento != 0 || this.ViewModel.SelectedControle.get_Situacao() != 7) && (this.ViewModel.FilterDocumento != 1 || this.ViewModel.SelectedEndosso.get_Situacao() != 7)) + { + this.ViewModel.ManutecaoItens(); + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL FAZER A MANUTENÇÃO DE ITENS DE UM DOCUMENTO RECUSADO.", "OK", "", false); + } + } + + private void MenuItem_OnClick(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(0); + tarefa.set_IdEntidade(this.ViewModel.SelectedControle.get_Id()); + tarefa.set_Titulo(string.Concat(this.ViewModel.SelectedCliente.get_Nome(), " APÓLICE ", this.ViewModel.SelectedControle.get_Apolice())); + this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa, true), 0, false); + } + + private async void MostrarItens_Click(object sender, RoutedEventArgs e) + { + bool valueOrDefault; + bool flag; + int num = 0; + if (!this.ApoliceRadioButton.IsFocused) + { + RadioButton apoliceItensRadioButton = this.ApoliceItensRadioButton; + if (apoliceItensRadioButton != null) + { + flag = apoliceItensRadioButton.IsChecked.GetValueOrDefault(); + } + else + { + flag = false; + } + if (!flag) + { + goto Label0; + } + } + num = 1; + Label0: + if (!this.EndossoRadioButton.IsFocused) + { + RadioButton endossoItensRadioButton = this.EndossoItensRadioButton; + if (endossoItensRadioButton != null) + { + valueOrDefault = endossoItensRadioButton.IsChecked.GetValueOrDefault(); + } + else + { + valueOrDefault = false; + } + if (!valueOrDefault) + { + if (this.InativosRadioButton.IsFocused) + { + num = 3; + } + await this.ViewModel.MostrarItens(num); + return; + } + } + num = 2; + if (this.InativosRadioButton.IsFocused) + { + num = 3; + } + await this.ViewModel.MostrarItens(num); + } + + private void Observacoes_OnClick(object sender, RoutedEventArgs e) + { + long id = (long)0; + TipoTela tipoTela = 0; + string name = ((Button)sender).Name; + if (name == "ObservacaoApolice") + { + id = this.ViewModel.SelectedControle.get_Id(); + tipoTela = 2; + } + else if (name == "EndossoInfo") + { + id = this.ViewModel.SelectedEndosso.get_Id(); + tipoTela = 2; + } + else if (name == "ObservacaoParcela") + { + id = this.ViewModel.SelectedParcela.get_Id(); + tipoTela = 5; + } + this.ViewModel.ShowDrawer(new ObservacoesDrawer(id, tipoTela), 0, true); + } + + private void Parcela_Click(object sender, RoutedEventArgs e) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(2, "Parcela"); + } + + private static void ParcelaGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + ConsultaViewModel.ParcelaSelecionada = (Parcela)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null)); + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(2, "Parcela"); + } + + private async void Perdido_OnClick(object sender, RoutedEventArgs e) + { + object prefixo; + object numero; + string str; + string numero1; + object email; + DateTime dateTime; + string descricao; + object selectedItem; + bool count; + Cliente cliente; + if (ConsultaViewModel.DocumentoSelecionado.get_Situacao() == 7) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ALTERAR O STATUS PARA PERDIDO DE UM DOCUMENTO RECUSADO.", "OK", "", false); + } + else if (await this.ViewModel.ShowMessage("DESEJA REALMENTE ALTERAR O STATUS DO SEGURO PARA PERDIDO?", "SIM", "NÃO", false)) + { + this.ViewModel.Loading(true); + cliente = await (new ClienteServico()).BuscarCliente(this.ViewModel.SelectedControle.get_Controle().get_Cliente().get_Id()); + Cliente cliente1 = cliente; + ObservableCollection observableCollection = await (new ClienteServico()).BuscarTelefonesAsync(this.ViewModel.SelectedControle.get_Controle().get_Cliente().get_Id()); + cliente1.set_Telefones(observableCollection); + cliente1 = null; + cliente1 = cliente; + ObservableCollection observableCollection1 = await (new ClienteServico()).BuscarEmailsAsync(this.ViewModel.SelectedControle.get_Controle().get_Cliente().get_Id()); + cliente1.set_Emails(observableCollection1); + cliente1 = null; + if (await (new ApoliceServico()).Perdido(this.ViewModel.SelectedControle.get_Controle().get_Id())) + { + Prospeccao prospeccao = new Prospeccao(); + prospeccao.set_Nome(cliente.get_Nome()); + prospeccao.set_Documento(cliente.get_Documento()); + prospeccao.set_Nascimento(cliente.get_Nascimento()); + ObservableCollection telefones = cliente.get_Telefones(); + if (telefones != null) + { + ClienteTelefone clienteTelefone = telefones.FirstOrDefault(); + if (clienteTelefone != null) + { + prefixo = clienteTelefone.get_Prefixo(); + } + else + { + prefixo = null; + } + } + else + { + prefixo = null; + } + if (prefixo == null) + { + prefixo = ""; + } + prospeccao.set_Prefixo1((string)prefixo); + ObservableCollection telefones1 = cliente.get_Telefones(); + if (telefones1 != null) + { + ClienteTelefone clienteTelefone1 = telefones1.FirstOrDefault(); + if (clienteTelefone1 != null) + { + numero = clienteTelefone1.get_Numero(); + } + else + { + numero = null; + } + } + else + { + numero = null; + } + if (numero == null) + { + numero = ""; + } + prospeccao.set_Telefone1((string)numero); + str = (cliente.get_Telefones() == null || cliente.get_Telefones().Count <= 1 ? "" : cliente.get_Telefones()[1].get_Prefixo()); + prospeccao.set_Prefixo2(str); + if (cliente.get_Telefones() != null) + { + ObservableCollection telefones2 = cliente.get_Telefones(); + if (telefones2 != null) + { + count = telefones2.Count > 1; + } + else + { + count = false; + } + if (!count) + { + goto Label1; + } + numero1 = cliente.get_Telefones()[1].get_Numero(); + goto Label0; + } + Label1: + numero1 = ""; + Label0: + prospeccao.set_Telefone2(numero1); + ObservableCollection emails = cliente.get_Emails(); + if (emails != null) + { + ClienteEmail clienteEmail = emails.FirstOrDefault(); + if (clienteEmail != null) + { + email = clienteEmail.get_Email(); + } + else + { + email = null; + } + } + else + { + email = null; + } + if (email == null) + { + email = ""; + } + prospeccao.set_Email((string)email); + DateTime? vigencia2 = this.ViewModel.SelectedControle.get_Vigencia2(); + dateTime = (vigencia2.HasValue ? vigencia2.GetValueOrDefault() : Funcoes.GetNetworkTime().Date); + prospeccao.set_VigenciaFinal(new DateTime?(dateTime.AddYears(1))); + prospeccao.set_Vendedor(this.ViewModel.SelectedControle.get_VendedorPrincipal()); + Item item = this.ViewModel.Itens.FirstOrDefault(); + if (item != null) + { + descricao = item.get_Descricao(); + } + else + { + descricao = null; + } + prospeccao.set_Item(descricao); + prospeccao.set_Tipo("SEGURO PERDIDO"); + prospeccao.set_Observacao(string.Concat("SEGURO PERDIDO: PROPOSTA: ", this.ViewModel.SelectedControle.get_Proposta(), ", APÓLICE: ", this.ViewModel.SelectedControle.get_Apolice())); + prospeccao.set_Status(new StatusProspeccao?(1)); + prospeccao.set_Renovacao(true); + await this.AbrirProspeccao(prospeccao); + this.ViewModel.CarregaDocumentos(0); + await this.ViewModel.SelecionaCliente(this.ViewModel.SelectedCliente, true); + this.ApoliceItensRadioButton.IsChecked = new bool?(true); + if (this.ApoliceGrid != null && this.ApoliceGrid.Items.Count > 0 && this.ApoliceGrid.SelectedItem == null) + { + this.ApoliceGrid.SelectedItem = this.ApoliceGrid.Items[0]; + ConsultaViewModel viewModel = this.ViewModel; + DataGrid apoliceGrid = this.ApoliceGrid; + if (apoliceGrid != null) + { + selectedItem = apoliceGrid.SelectedItem; + } + else + { + selectedItem = null; + } + await viewModel.SelecionaDocumento(0, (Documento)selectedItem); + } + this.ViewModel.Loading(false); + } + else + { + this.ViewModel.Loading(false); + } + } + cliente = null; + } + + public async void Pesquisar(PesquisaAvancada pesquisa) + { + await this.ViewModel.Pesquisar(pesquisa); + if (this.ViewModel.SelectedControle != null) + { + this.ScrollToIndex(this.ApoliceGrid, this.ApoliceGrid.SelectedIndex); + } + if (this.ViewModel.SelectedEndosso != null) + { + this.ScrollToIndex(this.EndossoGrid, this.EndossoGrid.SelectedIndex); + } + if (this.ViewModel.SelectedItem != null) + { + this.ScrollToIndex(this.ItemGrid, this.ItemGrid.SelectedIndex); + } + if (this.ViewModel.SelectedParcela != null) + { + this.ScrollToIndex(this.ParcelaGrid, this.ParcelaGrid.SelectedIndex); + } + } + + private void PopupBox_OnClosed(object sender, RoutedEventArgs e) + { + this._documentoAssistencia = null; + this.ViewModel.Anotacoes = ""; + this._linkAssistencia = ""; + } + + private async void PopupBox_OnOpened(object sender, RoutedEventArgs e) + { + this._documentoAssistencia = (Documento)((PopupBox)sender).DataContext; + this._linkAssistencia = await this.ViewModel.CreateLink(this._documentoAssistencia); + if (!string.IsNullOrEmpty(this._linkAssistencia)) + { + string[] strArrays = new string[] { "Prezado(a) ", ValidationHelper.Captalize(this.ViewModel.SelectedCliente.get_Nome()), ", segue o link do seu Cartão Assistência 24 horas.", Environment.NewLine, Environment.NewLine, "LINK CARTÃO ASSISTÊNCIA 24 HORAS", Environment.NewLine, this._linkAssistencia }; + string str = string.Concat(strArrays); + this.ViewModel.Anotacoes = str; + } + } + + private async void Recusar_OnClick(object sender, RoutedEventArgs e) + { + if (!this.ViewModel.Restricao(18)) + { + await this.ViewModel.RecusarDocumento(); + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA RECUSAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + } + + private async void RelacaoItens_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.GerarExcel(this.ViewModel.FilterItens); + } + + private async void Renovar_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.Restricao(17)) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA RENOVAR. PROCURE O ADMINSTRADOR DO SISTEMA.", "OK", "", false); + } + else if (!this.ViewModel.EnableRenovar) + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL RENOVAR UM DOCUMENTO SEM EMISSÃO OU SEM FINAL DE VIGÊNCIA.", "OK", "", false); + } + else if (ConsultaViewModel.DocumentoSelecionado.get_Situacao() != 7) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela != null) + { + acessaTela(2, "Renovar"); + } + else + { + } + } + else + { + await this.ViewModel.ShowMessage("NÃO É POSSÍVEL RENOVAR UM DOCUMENTO RECUSADO.", "OK", "", false); + } + } + + private async void ReordenarItem_Click(object sender, RoutedEventArgs e) + { + ObservableCollection itens = this.ViewModel.Itens; + List list = ( + from x in itens + select x.get_Id()).ToList(); + ConsultaViewModel viewModel = this.ViewModel; + viewModel.SalvarOrdem(await this.ViewModel.ShowReordenarItensDialog(list)); + viewModel = null; + } + + private void ScrollDocumento() + { + if (this.ViewModel.UpdatingScroll && this.ApoliceGrid.SelectedItem != null) + { + this.ApoliceGrid.ScrollIntoView(this.ApoliceGrid.SelectedItem); + } + this.ViewModel.UpdatingScroll = false; + } + + public void ScrollToIndex(DataGrid grid, int index) + { + ScrollViewer descendantByType = this.GetDescendantByType(grid, typeof(ScrollViewer)) as ScrollViewer; + int num = (index - 5 > 0 ? index - 5 : 0); + if (descendantByType == null) + { + return; + } + descendantByType.ScrollToVerticalOffset((double)num); + } + + private void ScrollToItem() + { + if (this.ItemGrid.SelectedItem == null) + { + return; + } + this.ScrollToIndex(this.ItemGrid, this.ItemGrid.SelectedIndex); + } + + private void SelecionarRadios(int filter) + { + this._carregarDocumetos = false; + this.ApoliceRadioButton.IsChecked = new bool?(filter == 0); + this.EndossoRadioButton.IsChecked = new bool?(filter == 1); + this._carregarDocumetos = true; + } + + private void Sinistros_OnClick(object sender, RoutedEventArgs e) + { + Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; + if (acessaTela == null) + { + return; + } + acessaTela(7, ""); + } + + [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.ApoliceRadioButton = (RadioButton)target; + return; + } + case 2: + { + this.EndossoRadioButton = (RadioButton)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ClienteView_Click); + return; + } + case 4: + { + this.AcessarDocumentoMenuItem = (MenuItem)target; + this.AcessarDocumentoMenuItem.Click += new RoutedEventHandler(this.ApoliceView_Click); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Renovar_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Perdido_OnClick); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Endossar_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Recusar_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MenuItem_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Extratos_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.TrocarCliente_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.EditarParcelas_OnClick); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExpedicaoInfo_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ValoresInfo_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ManutecaoItens_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.RelacaoItens_OnClick); + return; + } + case 17: + { + this.ApoliceGrid = (DataGrid)target; + return; + } + case 18: + case 22: + case 23: + case 24: + case 25: + case 26: + case 29: + case 30: + case 40: + case 41: + case 42: + { + this._contentLoaded = true; + return; + } + case 19: + { + this.NomeField = (DataGridTextColumn)target; + return; + } + case 20: + { + this.ApelidoField = (DataGridTextColumn)target; + return; + } + case 21: + { + this.ApolicesComissaoColumn = (DataGridTextColumn)target; + return; + } + case 27: + { + this.EndossoGrid = (DataGrid)target; + return; + } + case 28: + { + this.EndossosComissaoColumn = (DataGridTextColumn)target; + return; + } + case 31: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Parcela_Click); + return; + } + case 32: + { + this.Comissao = (WrapPanel)target; + return; + } + case 33: + { + this.ParcelaGrid = (DataGrid)target; + return; + } + case 34: + { + this.ParcelasTotalColumn = (DataGridTextColumn)target; + return; + } + case 35: + { + this.ParcelasRealizadoColumn = (DataGridTextColumn)target; + return; + } + case 36: + { + this.ParcelasComissaoColumn = (DataGridTextColumn)target; + return; + } + case 37: + { + this.ParcelasReciboColumn = (DataGridTextColumn)target; + return; + } + case 38: + { + this.ParcelasValorComissaoDescColumn = (DataGridTextColumn)target; + return; + } + case 39: + { + this.MaisInformacoesColumn = (DataGridTemplateColumn)target; + return; + } + case 43: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Item_Click); + return; + } + case 44: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Sinistros_OnClick); + return; + } + case 45: + { + this.AtivosRadioButton = (RadioButton)target; + return; + } + case 46: + { + this.ApoliceItensRadioButton = (RadioButton)target; + return; + } + case 47: + { + this.EndossoItensRadioButton = (RadioButton)target; + return; + } + case 48: + { + this.InativosRadioButton = (RadioButton)target; + return; + } + case 49: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.MostrarItens_Click); + return; + } + case 50: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ReordenarItem_Click); + return; + } + case 51: + { + this.ItemGrid = (DataGrid)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 18: + { + EventSetter eventSetter = new EventSetter() + { + Event = Control.MouseDoubleClickEvent, + Handler = new MouseButtonEventHandler(this.ApoliceGrid_OnMouseDoubleClick) + }; + ((System.Windows.Style)target).Setters.Add(eventSetter); + return; + } + case 19: + case 20: + case 21: + case 27: + case 28: + { + return; + } + case 22: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 23: + { + ((Button)target).Click += new RoutedEventHandler(this.Observacoes_OnClick); + return; + } + case 24: + { + ((PopupBox)target).add_Opened(new RoutedEventHandler(this.PopupBox_OnOpened)); + ((PopupBox)target).add_Closed(new RoutedEventHandler(this.PopupBox_OnClosed)); + return; + } + case 25: + { + ((Button)target).Click += new RoutedEventHandler(this.EnviarPorWhatsApp_OnClick); + return; + } + case 26: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.EnviarPorEmail_OnClick); + return; + } + case 29: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 30: + { + ((Button)target).Click += new RoutedEventHandler(this.Observacoes_OnClick); + return; + } + default: + { + switch (connectionId) + { + case 40: + { + ((Button)target).Click += new RoutedEventHandler(this.ValoresParcelaInfo_OnClick); + return; + } + case 41: + { + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 42: + { + ((Button)target).Click += new RoutedEventHandler(this.Observacoes_OnClick); + return; + } + default: + { + if (connectionId != 52) + { + return; + } + ((Button)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + } + break; + } + } + } + + private async void TrocarCliente_OnClick(object sender, RoutedEventArgs e) + { + (new HosterWindow(new TrocarClienteView(this.ViewModel.SelectedControle), "TROCAR CLIENTE", new double?((double)500), new double?((double)200), false)).ShowDialog(); + await this.ViewModel.SelecionaCliente(MainViewModel.ClienteSelecionado, true); + Action recarregarDocumentos = Gestor.Application.Actions.Actions.RecarregarDocumentos; + if (recarregarDocumentos != null) + { + recarregarDocumentos(null); + } + else + { + } + } + + private async void ValoresInfo_OnClick(object sender, RoutedEventArgs e) + { + bool flag = this.ViewModel.Restricao(97); + if (!flag) + { + Documento documento = await this.ViewModel.AbrirDetalhes(); + this.ViewModel.ShowDrawer(new ValoresApoliceDrawer(documento), 0, true); + } + if (flag) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR MAIS INFORMAÇÕES.", "OK", "", false); + } + } + + private async void ValoresParcelaInfo_OnClick(object sender, RoutedEventArgs e) + { + Parcela parcela = await this.ViewModel.AbrirDetalhesParcela(); + this.ViewModel.ShowDrawer(new ValoresParcelaDrawer(parcela, this.ViewModel.SelectedControle), 0, true); + } + + private void VisibilityValorPago() + { + bool flag; + DataGridTextColumn parcelasTotalColumn = this.ParcelasTotalColumn; + ObservableCollection parcelas = this.ViewModel.Parcelas; + if (parcelas != null) + { + flag = parcelas.Sum((Parcela p) => p.get_ValorPago()) > new decimal(); + } + else + { + flag = false; + } + parcelasTotalColumn.Visibility = (flag ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/CriticaApoliceView.cs b/Codemerx/Gestor.Application/Views/Seguros/CriticaApoliceView.cs new file mode 100644 index 0000000..9c8b3ec --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/CriticaApoliceView.cs @@ -0,0 +1,2010 @@ +using CsQuery.ExtensionMethods; +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.Application.Views.Seguros.Itens; +using Gestor.Common.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Collections.ObjectModel; +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 CriticaApoliceView : BaseUserControl, IComponentConnector, IStyleConnector + { + internal ComboBox UsuarioBox; + + internal ComboBox SeguradoraBox; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal ToggleButton CriticadoBox; + + internal DataGrid CriticaGrid; + + internal MenuItem ConcluirCriticaButton; + + internal MenuItem CancelarDocumento; + + internal ComboBox ProdutoBox; + + internal ComboBox NegocioCorretoraBox; + + internal ComboBox SituacaoBox; + + internal DatePicker TransmissaoBox; + + internal TextBox ApoliceBox; + + internal TextBox EndossoBox; + + internal DatePicker EmissaoBox; + + internal DatePicker Vigencia1Box; + + internal DatePicker Vigencia2Box; + + internal ToggleButton AdicionalBox; + + internal CustomIsReadOnlyControl Comissao; + + internal CurrencyTextBox ComissaoBox; + + internal CurrencyTextBox PremioLiquidoBox; + + internal CurrencyTextBox PremioAdicionalBox; + + internal CurrencyTextBox IofBox; + + internal CurrencyTextBox DiferencaBox; + + internal CurrencyTextBox PremioTotalBox; + + internal CurrencyTextBox ParcelasBox; + + internal ToggleButton SeguroCombinadoBox; + + internal MenuItem EditarVendedorButton; + + internal MenuItem SalvarVendedorButton; + + internal MenuItem CancelarVendedorButton; + + internal WrapPanel VendedorFields; + + internal ToggleButton CoCorretagemToogle; + + internal ComboBox TipoVendedorBox; + + internal ComboBox VendedorBox; + + internal CustomItemValidation ComissaoNovoBox; + + internal ComboBox ComissaoNovoComboBox; + + internal CustomItemValidation ComissaoRenovacaoBox; + + internal ComboBox ComissaoRenovacaoComboBox; + + internal CurrencyTextBox ValorRepasseBox; + + internal TextBox FormaRecebidaBox; + + internal DataGrid VendedorGrid; + + internal DataGridTextColumn RepasseVendedor; + + internal TextBox NomeBox; + + internal ComboBox TipoDocumentoPrincipalBox; + + internal TextBox DocumentoPrincipalBox; + + internal DatePicker NascimentoBox; + + internal TextBox IdentidadeBox; + + internal TextBox EmissorBox; + + internal TextBox EstadoEmissorBox; + + internal ListBox TelefoneListBox; + + internal ListBox EmailListBox; + + internal DataGrid ItemGrid; + + private bool _contentLoaded; + + private bool AdicionandoVendedor + { + get; + set; + } + + private int Ordem { get; set; } = 1; + + public CriticaApoliceViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public CriticaApoliceView() + { + base.Tag = "CRÍTICA DE IMPORTAÇÃO"; + this.ViewModel = new CriticaApoliceViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedCritica.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(2); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedCritica.get_Documento()); + 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(2), "."), "OK", "", false); + } + } + + private void AdicionalBox_OnChecked(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + this.AlteracaoDePremio_LostFocus(this.PremioAdicionalBox, new RoutedEventArgs()); + } + + private void AdicionarCoCorretagem_OnClick(object sender, RoutedEventArgs e) + { + bool valueOrDefault; + bool selectedItem; + bool flag; + ToggleButton toggleButton = (ToggleButton)sender; + if (toggleButton != null) + { + valueOrDefault = toggleButton.IsChecked.GetValueOrDefault(); + } + else + { + valueOrDefault = false; + } + bool flag1 = valueOrDefault; + ComboBox comissaoNovoComboBox = this.ComissaoNovoComboBox; + if (comissaoNovoComboBox != null) + { + selectedItem = comissaoNovoComboBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (selectedItem) + { + this.ComissaoNovoComboBox.SelectedItem = null; + } + if (flag1) + { + this.TipoVendedorBox.SelectedIndex = 0; + } + else if (this.TipoVendedorBox.SelectedItem != null) + { + this.TipoVendedorBox.SelectedItem = null; + } + ComboBox vendedorBox = this.VendedorBox; + if (vendedorBox != null) + { + flag = vendedorBox.SelectedItem; + } + else + { + flag = false; + } + if (flag) + { + this.VendedorBox.SelectedItem = null; + } + if (ValidationHelper.IsNotNullOrEmpty(this.ValorRepasseBox.Text)) + { + this.ValorRepasseBox.Text = ""; + } + this.ViewModel.VendedorCoCorretagem(flag1); + } + + private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdcionarFiltro(); + } + + private void AlteracaoDePremio_LostFocus(object sender, RoutedEventArgs e) + { + decimal iof; + if (!this.ViewModel.AllowEditApolice) + { + return; + } + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + CurrencyTextBox currencyTextBox = (CurrencyTextBox)sender; + if (currencyTextBox == null) + { + return; + } + string name = currencyTextBox.Name; + if ((name == "PremioLiquidoBox" || name == "PremioAdicionalBox") && this.IofBox.get_Number() == decimal.Zero) + { + decimal number = this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number(); + Ramo ramo = this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(); + if (ramo != null) + { + iof = ramo.get_Iof(); + } + else + { + iof = decimal.Zero; + } + decimal num = number * iof; + this.IofBox.set_Number(num); + CurrencyTextBox premioTotalBox = this.PremioTotalBox; + premioTotalBox.set_Number(premioTotalBox.get_Number() + num); + } + this.PremioTotalBox.set_Number(((this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number()) + this.IofBox.get_Number()) + this.DiferencaBox.get_Number()); + name = currencyTextBox.Name; + if ((name == "PremioLiquidoBox" || name == "PremioAdicionalBox" || name == "ComissaoBox") && this.ViewModel.HabilitarVendedor(0).Count == 0) + { + this.ViewModel.RecalculaRepasses(); + } + this.ValidarDocumento(); + } + + private async void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + this.ViewModel.EnableGrid = false; + List configuracoes = Recursos.Configuracoes; + if (configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 3)) + { + this.SituacaoBox.SelectedIndex = -1; + } + await this.ViewModel.SelecionaCritica(this.ViewModel.SelectedCritica); + this.ValidarDocumento(); + } + + private async void Apolice_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedDocumento != null) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ApoliceView(this.ViewModel.SelectedDocumento, true, false, 0, (long)0, true), string.Concat("CADASTRO DE APÓLICES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome(), " - ", this.ViewModel.SelectedDocumento.get_Apolice()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaDocumento(this.ViewModel.SelectedDocumento); + } + } + + private async void Atualizar_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.CarregaCritica(this.ViewModel.SelectedUsuario.get_Id(), this.ViewModel.SelectedSeguradora.get_Id(), this.ViewModel.Criticado); + } + + private async void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + List repasses = this.ViewModel.Repasses; + if (!( + from repasse in repasses + where !repasse.get_Vendedor().get_Corretora() + select repasse).Any()) + { + if (!this.ViewModel.HasChange && (this.ViewModel.SelectedDocumento == null || !this.ViewModel.SelectedDocumento.HasChange()) && (this.ViewModel.SelectedCliente == null || !this.ViewModel.SelectedCliente.HasChange())) + { + if (this.ViewModel.Telefones != null) + { + ObservableCollection telefones = this.ViewModel.Telefones; + if (!telefones.Any((ClienteTelefone x) => x.HasChange())) + { + goto Label0; + } + } + else + { + goto Label0; + } + } + if (!await this.ViewModel.ShowMessage(string.Concat("HÁ ALTERAÇÕES PENDENTES AINDA NÃO SALVAS, DESEJA CONTINUAR? ", Environment.NewLine, "O PROCEDIMENTO IRÁ CANCELAR AS ALTERAÇÕES REALIZADAS."), "SIM", "NÃO", false)) + { + return; + } + Label0: + await this.ViewModel.SelecionaCritica(this.ViewModel.SelectedCritica); + this.ViewModel.Alterar(false); + this.ViewModel.EnableGrid = true; + } + else + { + await this.ViewModel.ShowMessage("PARA CANCELAR AS ALTERAÇÕES É NECESSÁRIO REMOVER OS VENDEDORES COM REPASSE CONFIGURADO.", "OK", "", false); + } + } + + private void CancelarVendedor_Click(object sender, RoutedEventArgs e) + { + this.EditarVendedor(false); + this.ViewModel.SelectedPagamento = null; + this.ViewModel.SelecionarVendedor(); + } + + private async void Cliente_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new ClienteView(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente(), true, null), string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + CriticaApoliceViewModel viewModel = this.ViewModel; + Cliente cliente = await this.ViewModel.CarregaCliente(this.ViewModel.SelectedCliente.get_Id()); + viewModel.SelectedCliente = cliente; + viewModel = null; + await this.ViewModel.SelecionaCliente(this.ViewModel.SelectedCliente); + } + + private void ComissaoVendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + decimal? valorRepasse; + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + Repasse selectedItem = (Repasse)comboBox.SelectedItem; + if (selectedItem != null && selectedItem.get_Tipo().GetValueOrDefault() == 3) + { + decimal comissao = (this.ViewModel.SelectedDocumento.get_Comissao() * selectedItem.get_ValorNovo() * new decimal(1, 0, 0, false, 2)) * new decimal(1, 0, 0, false, 2); + this.ViewModel.SelectedPagamento.set_ValorRepasse(new decimal?(this.ViewModel.SelectedDocumento.get_PremioTotal() * comissao)); + CurrencyTextBox valorRepasseBox = this.ValorRepasseBox; + valorRepasse = this.ViewModel.SelectedPagamento.get_ValorRepasse(); + valorRepasseBox.set_Number(valorRepasse.Value); + return; + } + this.ViewModel.SelectedPagamento.set_Repasse(selectedItem); + this.ViewModel.SelectedPagamento.set_PorcentagemRepasse(new decimal?((this.ViewModel.SelectedDocumento.get_Situacao() != 2 || this.ViewModel.SelectedDocumento.get_Negocio().GetValueOrDefault() != 1 ? selectedItem.get_ValorNovo() : selectedItem.get_ValorRenovacao()))); + if (this.ViewModel.SelectedParcela == null) + { + CriticaApoliceViewModel viewModel = this.ViewModel; + Parcela parcela = new Parcela(); + parcela.set_SubTipo(1); + viewModel.SelectedParcela = parcela; + } + this.ViewModel.SelectedParcela.set_Documento(this.ViewModel.SelectedDocumento); + this.ViewModel.SelectedPagamento.set_ValorRepasse(new decimal?(Funcoes.CalculaRepasse(selectedItem, this.ViewModel.SelectedParcela, (this.ViewModel.SelectedParcela == null ? true : this.ViewModel.SelectedParcela.get_SubTipo() == 1)))); + this.ViewModel.SelectedPagamento.set_ValorTotal(this.ViewModel.SelectedPagamento.get_ValorRepasse()); + CurrencyTextBox currencyTextBox = this.ValorRepasseBox; + valorRepasse = this.ViewModel.SelectedPagamento.get_ValorRepasse(); + currencyTextBox.set_Number(valorRepasse.Value); + this.FormaRecebidaBox.Text = EnumHelper.GetDescription(selectedItem.get_Forma()); + } + + private async void ConcluirCritica_OnClick(object sender, RoutedEventArgs e) + { + this.ConcluirCriticaButton.Click -= new RoutedEventHandler(this.ConcluirCritica_OnClick); + this.ViewModel.EnableGrid = false; + this.ExecutarValidacaoData(); + this.NomeBox.Focus(); + if (this.ViewModel.CompararValores()) + { + this.PremioTotalBox.set_Number(((this.PremioLiquidoBox.get_Number() + this.PremioAdicionalBox.get_Number()) + this.IofBox.get_Number()) + this.DiferencaBox.get_Number()); + } + await this.SalvarDocumento(); + this.ConcluirCriticaButton.Click += new RoutedEventHandler(this.ConcluirCritica_OnClick); + } + + private async void ContentLoad() + { + System.Windows.Visibility visibility; + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_OnLostFocus); + CriticaApoliceView criticaApoliceView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView.SomenteNumeros); + this.CriticadoBox.Checked += new RoutedEventHandler(this.Criticado_OnChecked); + this.CriticadoBox.Unchecked += new RoutedEventHandler(this.Criticado_OnChecked); + this.UsuarioBox.SelectionChanged += new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.SelectedDateChanged += new EventHandler(this.FiltroDataBox_OnSelectedDateChanged); + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.FimBox.SelectedDateChanged += new EventHandler(this.FiltroDataBox_OnSelectedDateChanged); + this.TransmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.TransmissaoBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.EmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.EmissaoBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.Vigencia1Box.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.Vigencia1Box.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.Vigencia2Box.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.Vigencia2Box.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.NegocioCorretoraBox.SelectionChanged += new SelectionChangedEventHandler(this.NegocioCorretoraBox_OnSelectionChanged); + this.PremioLiquidoBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.PremioAdicionalBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.IofBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.DiferencaBox.LostFocus += new RoutedEventHandler(this.AlteracaoDePremio_LostFocus); + this.AdicionalBox.Unchecked += new RoutedEventHandler(this.AdicionalBox_OnChecked); + this.AdicionalBox.Checked += new RoutedEventHandler(this.AdicionalBox_OnChecked); + this.VendedorBox.SelectionChanged += new SelectionChangedEventHandler(this.VendedorBox_OnSelectionChanged); + this.TipoVendedorBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoVendedorBox_OnSelectionChanged); + this.TipoDocumentoPrincipalBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoDocumentoPrincipalBox_OnSelectionChanged); + this.CriticaGrid.SelectionChanged += new SelectionChangedEventHandler(this.Grid_OnSelectionChanged); + DataGridTextColumn repasseVendedor = this.RepasseVendedor; + visibility = (this.ViewModel.Restricao(95) ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + repasseVendedor.Visibility = visibility; + await this.ViewModel.InitialLoad(); + } + + private async void Criticado_OnChecked(object sender, RoutedEventArgs e) + { + bool flag; + bool selectedItem; + ToggleButton toggleButton = (ToggleButton)sender; + flag = (toggleButton != null ? !toggleButton.IsChecked.HasValue : true); + if (!flag) + { + ComboBox usuarioBox = this.UsuarioBox; + if (usuarioBox != null) + { + selectedItem = usuarioBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (selectedItem) + { + if (!this.ViewModel.IsLoading) + { + bool value = toggleButton.IsChecked.Value; + this.SeguradoraBox.SelectionChanged -= new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged -= new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked -= new RoutedEventHandler(this.Criticado_OnChecked); + await this.ViewModel.CarregarUsuarios(((Usuario)this.UsuarioBox.SelectedItem).get_Id(), value); + await this.ViewModel.CarregaCritica(this.ViewModel.SelectedUsuario.get_Id(), this.ViewModel.SelectedSeguradora.get_Id(), value); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged += new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked += new RoutedEventHandler(this.Criticado_OnChecked); + } + } + } + } + + private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e) + { + if (((TextBox)sender).IsReadOnly) + { + return; + } + string str = ValidationHelper.Clear(this.DocumentoPrincipalBox.Text); + if (string.IsNullOrEmpty(str)) + { + return; + } + this.DocumentoPrincipalBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14))); + this.ViewModel.JuridicaouFisica(this.DocumentoPrincipalBox.Text); + } + + private void DocumentoPrincipalBox_OnLostFocus(object sender, RoutedEventArgs e) + { + if (this.TipoDocumentoPrincipalBox.SelectedItem == null) + { + this.TipoDocumentoPrincipalBox.SelectedItem = (TipoDocumento)0; + } + if ((TipoDocumento)this.TipoDocumentoPrincipalBox.SelectedItem == null) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + } + } + + private void EditarVendedor(bool editar) + { + bool count; + ObservableCollection pagamentos; + bool flag; + ObservableCollection observableCollection; + this.AdicionandoVendedor = editar; + this.SalvarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.CancelarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.EditarVendedorButton.Visibility = (editar ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.VendedorFields.Visibility = (editar ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.VendedorGrid.IsEnabled = !editar; + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + if (editar) + { + if (Recursos.Configuracoes.Any((ConfiguracaoSistema config) => config.get_Configuracao() == 56)) + { + ObservableCollection pagamentos1 = this.ViewModel.Pagamentos; + if (pagamentos1 != null) + { + count = pagamentos1.Count == 1; + } + else + { + count = false; + } + if (count) + { + if (!this.ViewModel.Pagamentos.Any((VendedorParcela vendedor) => vendedor.get_Repasse() == null)) + { + pagamentos = this.ViewModel.Pagamentos; + if (pagamentos != null) + { + flag = pagamentos.Count == 0; + } + else + { + observableCollection = pagamentos; + flag = false; + } + this.CoCorretagemToogle.IsEnabled = flag; + this.ComissaoNovoBox.Visibility = System.Windows.Visibility.Visible; + this.ComissaoRenovacaoBox.Visibility = System.Windows.Visibility.Collapsed; + this.CoCorretagemToogle.IsChecked = new bool?(false); + return; + } + flag = true; + this.CoCorretagemToogle.IsEnabled = flag; + this.ComissaoNovoBox.Visibility = System.Windows.Visibility.Visible; + this.ComissaoRenovacaoBox.Visibility = System.Windows.Visibility.Collapsed; + this.CoCorretagemToogle.IsChecked = new bool?(false); + return; + } + pagamentos = this.ViewModel.Pagamentos; + if (pagamentos != null) + { + flag = pagamentos.Count == 0; + } + else + { + observableCollection = pagamentos; + flag = false; + } + this.CoCorretagemToogle.IsEnabled = flag; + this.ComissaoNovoBox.Visibility = System.Windows.Visibility.Visible; + this.ComissaoRenovacaoBox.Visibility = System.Windows.Visibility.Collapsed; + this.CoCorretagemToogle.IsChecked = new bool?(false); + return; + } + } + NegocioCorretora? negocioCorretora = this.ViewModel.SelectedDocumento.get_NegocioCorretora(); + bool valueOrDefault = negocioCorretora.GetValueOrDefault() == 1; + this.ComissaoNovoBox.Visibility = (!editar || valueOrDefault ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible); + this.ComissaoRenovacaoBox.Visibility = (editar & valueOrDefault ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private async void EditarVendedorButton_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + bool hasValue; + List> keyValuePairs = this.ViewModel.SelectedDocumento.Validate(); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + bool flag1 = flag; + if (flag1) + { + Parcela selectedParcela = this.ViewModel.SelectedParcela; + if (selectedParcela != null) + { + hasValue = selectedParcela.get_DataRecebimento().HasValue; + } + else + { + hasValue = false; + } + if (hasValue) + { + await this.ViewModel.ShowMessage("DOCUMENTO COM PARCELA(S) JÁ BAIXADA(S), NÃO É POSSÍVEL ALTERAR VENDEDORES!", "OK", "", false); + return; + } + } + if (flag1) + { + this.ViewModel.IncluirVendedor(); + this.EditarVendedor(true); + this.ViewModel.VendedorCoCorretagem(false); + } + else + { + this.ValidateFields(keyValuePairs, true); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + private void ExcluirEmail_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + ClienteEmail dataContext = (ClienteEmail)button.DataContext; + this.ViewModel.ExcluirEmail(dataContext); + } + + private void ExcluirFiltro_OnClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip == null) + { + return; + } + ListBox listBox = Extentions.FindVisualAncestor(chip); + string item = (string)listBox.Items[listBox.Items.IndexOf(chip.DataContext)]; + if (item == null) + { + return; + } + this.ViewModel.PesquisaCritica.Remove(item); + this.ViewModel.Pesquisar(); + } + + private void ExcluirTelefone_OnClick(object sender, RoutedEventArgs e) + { + Button button = sender as Button; + if (button == null) + { + return; + } + if (button.DataContext == null) + { + return; + } + ClienteTelefone dataContext = (ClienteTelefone)button.DataContext; + this.ViewModel.ExcluirTelefone(dataContext); + } + + private async void ExcluirVendedor_OnClick(object sender, RoutedEventArgs e) + { + TipoRepasse? nullable; + bool selectedIndex; + object item; + TipoRepasse? tipo; + bool valueOrDefault; + object obj; + System.Windows.Visibility visibility; + DataGrid vendedorGrid = this.VendedorGrid; + if (vendedorGrid != null) + { + selectedIndex = vendedorGrid.SelectedIndex < 0; + } + else + { + selectedIndex = false; + } + if (!selectedIndex) + { + DataGrid dataGrid = this.VendedorGrid; + if (dataGrid != null) + { + item = dataGrid.Items[this.VendedorGrid.SelectedIndex]; + } + else + { + item = null; + } + VendedorParcela vendedorParcela = (VendedorParcela)item; + if (vendedorParcela != null) + { + Repasse repasse = vendedorParcela.get_Repasse(); + if (repasse != null) + { + tipo = repasse.get_Tipo(); + } + else + { + nullable = null; + tipo = nullable; + } + nullable = tipo; + valueOrDefault = nullable.GetValueOrDefault() == 3; + } + else + { + valueOrDefault = false; + } + bool flag = valueOrDefault; + CriticaApoliceViewModel viewModel = this.ViewModel; + DataGrid vendedorGrid1 = this.VendedorGrid; + if (vendedorGrid1 != null) + { + obj = vendedorGrid1.Items[this.VendedorGrid.SelectedIndex]; + } + else + { + obj = null; + } + await viewModel.ExcluirVendedor((VendedorParcela)obj, true); + await this.ViewModel.SelecionaParcela(this.ViewModel.Parcelas.FirstOrDefault()); + this.ComissaoBox.IsReadOnly = this.ViewModel.VerificaCoCorretagem(); + CriticaApoliceViewModel criticaApoliceViewModel = this.ViewModel; + visibility = (this.ComissaoBox.IsReadOnly ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + criticaApoliceViewModel.ComissOriginalVisibility = visibility; + if (flag) + { + await this.ViewModel.AjusteComissãoCoCorretagem(true); + } + } + } + + private void ExecutarValidacaoData() + { + DateTime dateTime; + DateTime? nullable; + DateTime? nullable1; + DateTime? nullable2; + DateTime? nullable3; + DateTime? nullable4; + Cliente selectedCliente = this.ViewModel.SelectedCliente; + if (this.NascimentoBox.Text == null || !DateTime.TryParse(ValidationHelper.FormatDate(this.NascimentoBox.Text), out dateTime)) + { + nullable = null; + nullable1 = nullable; + } + else + { + nullable1 = new DateTime?(dateTime); + } + selectedCliente.set_Nascimento(nullable1); + Documento selectedDocumento = this.ViewModel.SelectedDocumento; + if (this.TransmissaoBox.Text == null || !DateTime.TryParse(ValidationHelper.FormatDate(this.TransmissaoBox.Text), out dateTime)) + { + nullable = null; + nullable2 = nullable; + } + else + { + nullable2 = new DateTime?(dateTime); + } + selectedDocumento.set_Remessa(nullable2); + Documento documento = this.ViewModel.SelectedDocumento; + if (this.EmissaoBox.Text == null || !DateTime.TryParse(ValidationHelper.FormatDate(this.EmissaoBox.Text), out dateTime)) + { + nullable = null; + nullable3 = nullable; + } + else + { + nullable3 = new DateTime?(dateTime); + } + documento.set_Emissao(nullable3); + this.ViewModel.SelectedDocumento.set_Vigencia1((this.Vigencia1Box.Text == null || !DateTime.TryParse(ValidationHelper.FormatDate(this.Vigencia1Box.Text), out dateTime) ? Funcoes.GetNetworkTime().Date : dateTime)); + Documento selectedDocumento1 = this.ViewModel.SelectedDocumento; + if (this.Vigencia2Box.Text == null || !DateTime.TryParse(ValidationHelper.FormatDate(this.Vigencia2Box.Text), out dateTime)) + { + nullable = null; + nullable4 = nullable; + } + else + { + nullable4 = new DateTime?(dateTime); + } + selectedDocumento1.set_Vigencia2(nullable4); + } + + private async void FiltroDataBox_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + bool hasValue; + bool selectedItem; + DatePicker datePicker = (DatePicker)sender; + if (datePicker != null) + { + hasValue = !datePicker.SelectedDate.HasValue; + } + else + { + hasValue = true; + } + if (!hasValue) + { + ComboBox usuarioBox = this.UsuarioBox; + if (usuarioBox != null) + { + selectedItem = usuarioBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (selectedItem) + { + this.SeguradoraBox.SelectionChanged -= new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged -= new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked -= new RoutedEventHandler(this.Criticado_OnChecked); + await this.ViewModel.CarregarUsuarios(((Usuario)this.UsuarioBox.SelectedItem).get_Id(), this.ViewModel.Criticado); + await this.ViewModel.CarregaCritica(this.ViewModel.SelectedUsuario.get_Id(), this.ViewModel.SelectedSeguradora.get_Id(), this.ViewModel.Criticado); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged += new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked += new RoutedEventHandler(this.Criticado_OnChecked); + } + } + } + + private async void Grid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (this.ViewModel.EnableGrid) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null) + { + if (dataGrid.SelectedIndex >= 0) + { + this.ViewModel.EnableGrid = false; + this.ViewModel.Index = dataGrid.SelectedIndex; + await this.ViewModel.SelecionaCritica((CriticaApolice)dataGrid.Items[dataGrid.SelectedIndex]); + this.ViewModel.EnableGrid = true; + } + } + } + } + + private void Initial_DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + base.DatePicker_OnLostKeyboardFocus(sender, e); + if (string.IsNullOrEmpty(this.Vigencia1Box.Text)) + { + this.Vigencia1Box.SelectedDate = new DateTime?(DateTime.MinValue); + this.ViewModel.SelectedDocumento.set_Vigencia1(DateTime.MinValue); + } + if (string.IsNullOrWhiteSpace(this.Vigencia2Box.Text)) + { + DatePicker vigencia2Box = this.Vigencia2Box; + DateTime dateTime = ValidationHelper.ToDateTime(this.Vigencia1Box.Text); + vigencia2Box.DisplayDate = dateTime.AddYears(1); + DatePicker shortDateString = this.Vigencia2Box; + dateTime = this.Vigencia2Box.DisplayDate; + shortDateString.Text = dateTime.ToShortDateString(); + } + } + + [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/criticaapoliceview.xaml", UriKind.Relative)); + } + + private async void Item_Click(object sender, RoutedEventArgs e) + { + Item dataContext; + UserControl patrimonialView; + double? nullable; + double? nullable1; + bool? nullable2; + Button button = (Button)sender; + if (button.DataContext != null) + { + dataContext = (Item)button.DataContext; + dataContext.set_Documento(this.ViewModel.SelectedDocumento); + long id = this.ViewModel.SelectedDocumento.get_Controle().get_Ramo().get_Id(); + long num = id - (long)1; + if (num <= (long)19) + { + switch ((uint)num) + { + case 0: + case 1: + case 2: + case 14: + case 17: + { + patrimonialView = new PatrimonialView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 3: + case 7: + case 10: + case 11: + case 13: + case 15: + case 16: + case 18: + { + patrimonialView = new RiscosDiversosView(null, false, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 4: + { + patrimonialView = new AutoView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 5: + case 6: + case 8: + case 9: + { + patrimonialView = new VidaView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 12: + { + patrimonialView = new AeronauticoView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 19: + { + patrimonialView = new GranizoView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + } + } + else + { + } + long num1 = id - (long)36; + if (num1 <= (long)2) + { + switch ((uint)num1) + { + case 0: + { + patrimonialView = new ConsorcioView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 1: + { + patrimonialView = new AutoView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + case 2: + { + patrimonialView = new PatrimonialView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + } + } + else + { + } + if (id != (long)53) + { + patrimonialView = new RiscosDiversosView(null, false, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + patrimonialView = new VidaView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + } + return; + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + patrimonialView = new PatrimonialView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + patrimonialView = new RiscosDiversosView(null, false, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + patrimonialView = new AutoView(null, true, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + return; + patrimonialView = new RiscosDiversosView(null, false, false, null, dataContext, this.ViewModel.SelectedDocumento.get_Controle().get_Ramo(), false); + nullable = null; + nullable1 = nullable; + nullable = null; + nullable2 = (new HosterWindow(patrimonialView, string.Concat("CADASTRO DE CLIENTES - ", this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).ShowDialog(); + await this.ViewModel.SelecionaItens(this.ViewModel.SelectedDocumento.get_Controle().get_Id()); + } + + private void NegocioCorretoraBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool selectedItem; + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null) + { + selectedItem = comboBox.SelectedItem; + } + else + { + selectedItem = false; + } + if (!selectedItem) + { + return; + } + this.AlteracaoDePremio_LostFocus(this.PremioLiquidoBox, new RoutedEventArgs()); + if (this.SalvarVendedorButton.Visibility != System.Windows.Visibility.Visible) + { + return; + } + this.EditarVendedor(true); + this.ComissaoVendedorBox_OnSelectionChanged((this.ComissaoNovoBox.Visibility == System.Windows.Visibility.Visible ? this.ComissaoNovoComboBox : this.ComissaoRenovacaoComboBox), e); + } + + 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 = this.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; + } + this.Ordem = num; + } + + private async void Perfil_OnClick(object sender, RoutedEventArgs e) + { + PerfilView perfilView = new PerfilView(this.ViewModel.SelectedDocumento.get_Controle()); + if (await this.ViewModel.VerificarPermissao(32, false)) + { + (new HosterWindow(perfilView, "PERFIL", new double?((double)800), new double?((double)370), false)).ShowDialog(); + } + perfilView = null; + } + + private void Pesquisa_OnPreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key != Key.Return) + { + return; + } + this.ViewModel.AdcionarFiltro(); + } + + private async Task SalvarDocumento() + { + bool flag; + bool flag1; + bool flag2; + bool flag3; + this.ViewModel.Loading(true); + List> keyValuePairs = null; + if (this.AdicionandoVendedor) + { + keyValuePairs = await this.ViewModel.AdicionarVendedor(); + } + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag) + { + keyValuePairs = await this.ViewModel.SalvarCliente(); + flag1 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag1) + { + if (!this.ViewModel.StatusDocumento.HasValue) + { + keyValuePairs = new List>() + { + new KeyValuePair("STATUS DO SEGURO", "OBRIGATÓRIO") + }; + } + flag2 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag2) + { + if (!this.ViewModel.StatusDocumento.HasValue) + { + this.ViewModel.SelectedDocumento.set_Situacao(1); + } + keyValuePairs = await this.ViewModel.Salvar(true); + flag3 = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + if (flag3) + { + await this.ViewModel.ConcluirCritica(); + this.EditarVendedor(false); + this.ViewModel.EnableGrid = true; + this.SeguroCombinadoBox.IsChecked = new bool?(false); + } + else + { + List> keyValuePairs1 = keyValuePairs; + if (!keyValuePairs1.Any>((KeyValuePair x) => x.Value == "VIGENCIANAOACEITA")) + { + this.ViewModel.Loading(false); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.ViewModel.Loading(false); + } + } + } + else + { + this.ViewModel.Loading(false); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + else + { + this.ViewModel.Loading(false); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + else + { + this.ViewModel.Loading(false); + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + private async void SalvarVendedor_Click(object sender, RoutedEventArgs e) + { + TipoRepasse? nullable; + List> keyValuePairs; + bool valueOrDefault; + TipoRepasse? tipo; + bool flag; + decimal num; + bool flag1; + ((MenuItem)sender).Click -= new RoutedEventHandler(this.SalvarVendedor_Click); + bool coCorretagem = this.ViewModel.CoCorretagem; + if (coCorretagem) + { + coCorretagem = !await this.ViewModel.ShowMessage("AO ADICIONAR CO-CORRETAGEM COMO VENDEDOR, O DOCUMENTO ACIMA SERÁ SALVO.\nDESEJÁ CONTINUAR?", "SIM", "NÃO", false); + } + if (!coCorretagem) + { + if (this.ViewModel.SelectedParcela == null) + { + valueOrDefault = true; + } + else if (this.ViewModel.SelectedParcela.get_SubTipo() != 1) + { + valueOrDefault = false; + } + else + { + TipoRecebimento? tipoRecebimento = this.ViewModel.SelectedDocumento.get_TipoRecebimento(); + valueOrDefault = tipoRecebimento.GetValueOrDefault() == 1; + } + bool flag2 = valueOrDefault; + NegocioCorretora? negocioCorretora = this.ViewModel.SelectedDocumento.get_NegocioCorretora(); + bool valueOrDefault1 = negocioCorretora.GetValueOrDefault() == 1; + if (this.ComissaoRenovacaoComboBox.SelectedItem != null || this.ComissaoNovoComboBox.SelectedItem != null) + { + VendedorParcela selectedPagamento = this.ViewModel.SelectedPagamento; + if (selectedPagamento != null) + { + Repasse repasse = selectedPagamento.get_Repasse(); + if (repasse != null) + { + tipo = repasse.get_Tipo(); + } + else + { + nullable = null; + tipo = nullable; + } + nullable = tipo; + flag = nullable.GetValueOrDefault() == 3; + } + else + { + flag = false; + } + if (flag) + { + valueOrDefault1 = false; + } + object selectedItem = this.ComissaoRenovacaoComboBox.SelectedItem; + if (selectedItem == null) + { + selectedItem = this.ComissaoNovoComboBox.SelectedItem; + } + object obj = selectedItem; + VendedorParcela vendedorParcela = this.ViewModel.SelectedPagamento; + num = (valueOrDefault1 ? ((Repasse)obj).get_ValorRenovacao() : ((Repasse)obj).get_ValorNovo()); + vendedorParcela.set_PorcentagemRepasse(new decimal?(num)); + keyValuePairs = (!flag2 ? await this.ViewModel.AdicionarVendedorParcelaEspecial() : await this.ViewModel.AdicionarVendedor()); + List> keyValuePairs1 = keyValuePairs; + flag1 = (keyValuePairs1 == null ? true : keyValuePairs1.Count == 0); + if (!flag1) + { + await this.ViewModel.ShowMessage(keyValuePairs1, this.ViewModel.ErroCamposInvalidos, "OK", ""); + ((MenuItem)sender).Click += new RoutedEventHandler(this.SalvarVendedor_Click); + } + else + { + this.EditarVendedor(false); + if (this.ViewModel.VerificaCoCorretagem()) + { + this.ComissaoBox.IsReadOnly = true; + this.ViewModel.ComissOriginalVisibility = System.Windows.Visibility.Visible; + } + ((MenuItem)sender).Click += new RoutedEventHandler(this.SalvarVendedor_Click); + } + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIOS ESCOLHER O VALOR DE REPASSE ANTES DE ADICIONAR O VENDEDOR", "OK", "", false); + ((MenuItem)sender).Click += new RoutedEventHandler(this.SalvarVendedor_Click); + } + } + else + { + ((MenuItem)sender).Click += new RoutedEventHandler(this.SalvarVendedor_Click); + } + } + + private async void Seguradora_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool hasValue; + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null && comboBox.SelectedItem != null) + { + ToggleButton criticadoBox = this.CriticadoBox; + if (criticadoBox != null) + { + hasValue = !criticadoBox.IsChecked.HasValue; + } + else + { + hasValue = true; + } + if (!hasValue) + { + this.SeguradoraBox.SelectionChanged -= new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged -= new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked -= new RoutedEventHandler(this.Criticado_OnChecked); + this.ViewModel.SelectedSeguradora = (Seguradora)comboBox.SelectedItem; + await this.ViewModel.CarregaCritica(this.ViewModel.SelectedUsuario.get_Id(), ((Seguradora)comboBox.SelectedItem).get_Id(), this.ViewModel.Criticado); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged += new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked += new RoutedEventHandler(this.Criticado_OnChecked); + } + } + } + + private void SituacaoBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (this.ViewModel.EnableFields) + { + this.ViewModel.StatusDocumento = (TipoSeguro?)comboBox.SelectedItem; + } + } + + [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.UsuarioBox = (ComboBox)target; + return; + } + case 2: + { + this.SeguradoraBox = (ComboBox)target; + return; + } + case 3: + { + this.InicioBox = (DatePicker)target; + this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.InicioBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.InicioBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 4: + { + this.FimBox = (DatePicker)target; + this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.FimBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + this.FimBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 5: + { + this.CriticadoBox = (ToggleButton)target; + return; + } + case 6: + { + ((Button)target).Click += new RoutedEventHandler(this.Atualizar_OnClick); + return; + } + case 7: + { + ((TextBox)target).PreviewKeyDown += new KeyEventHandler(this.Pesquisa_OnPreviewKeyDown); + return; + } + case 8: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltro_OnClick); + return; + } + case 9: + case 53: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 70: + { + this._contentLoaded = true; + return; + } + case 10: + { + this.CriticaGrid = (DataGrid)target; + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 12: + { + this.ConcluirCriticaButton = (MenuItem)target; + this.ConcluirCriticaButton.Click += new RoutedEventHandler(this.ConcluirCritica_OnClick); + return; + } + case 13: + { + this.CancelarDocumento = (MenuItem)target; + this.CancelarDocumento.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cliente_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Apolice_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Tarefa_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Perfil_OnClick); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 19: + { + this.ProdutoBox = (ComboBox)target; + return; + } + case 20: + { + this.NegocioCorretoraBox = (ComboBox)target; + return; + } + case 21: + { + this.SituacaoBox = (ComboBox)target; + this.SituacaoBox.SelectionChanged += new SelectionChangedEventHandler(this.SituacaoBox_SelectionChanged); + return; + } + case 22: + { + this.TransmissaoBox = (DatePicker)target; + this.TransmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.TransmissaoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 23: + { + this.ApoliceBox = (TextBox)target; + return; + } + case 24: + { + this.EndossoBox = (TextBox)target; + return; + } + case 25: + { + this.EmissaoBox = (DatePicker)target; + this.EmissaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.EmissaoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 26: + { + this.Vigencia1Box = (DatePicker)target; + this.Vigencia1Box.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Initial_DatePicker_OnLostKeyboardFocus); + this.Vigencia1Box.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 27: + { + this.Vigencia2Box = (DatePicker)target; + this.Vigencia2Box.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.Vigencia2Box.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 28: + { + this.AdicionalBox = (ToggleButton)target; + return; + } + case 29: + { + this.Comissao = (CustomIsReadOnlyControl)target; + return; + } + case 30: + { + this.ComissaoBox = (CurrencyTextBox)target; + return; + } + case 31: + { + this.PremioLiquidoBox = (CurrencyTextBox)target; + return; + } + case 32: + { + this.PremioAdicionalBox = (CurrencyTextBox)target; + return; + } + case 33: + { + this.IofBox = (CurrencyTextBox)target; + return; + } + case 34: + { + this.DiferencaBox = (CurrencyTextBox)target; + return; + } + case 35: + { + this.PremioTotalBox = (CurrencyTextBox)target; + return; + } + case 36: + { + this.ParcelasBox = (CurrencyTextBox)target; + return; + } + case 37: + { + this.SeguroCombinadoBox = (ToggleButton)target; + return; + } + case 38: + { + this.EditarVendedorButton = (MenuItem)target; + this.EditarVendedorButton.Click += new RoutedEventHandler(this.EditarVendedorButton_OnClick); + return; + } + case 39: + { + this.SalvarVendedorButton = (MenuItem)target; + this.SalvarVendedorButton.Click += new RoutedEventHandler(this.SalvarVendedor_Click); + return; + } + case 40: + { + this.CancelarVendedorButton = (MenuItem)target; + this.CancelarVendedorButton.Click += new RoutedEventHandler(this.CancelarVendedor_Click); + return; + } + case 41: + { + this.VendedorFields = (WrapPanel)target; + return; + } + case 42: + { + this.CoCorretagemToogle = (ToggleButton)target; + this.CoCorretagemToogle.Click += new RoutedEventHandler(this.AdicionarCoCorretagem_OnClick); + return; + } + case 43: + { + this.TipoVendedorBox = (ComboBox)target; + return; + } + case 44: + { + this.VendedorBox = (ComboBox)target; + return; + } + case 45: + { + this.ComissaoNovoBox = (CustomItemValidation)target; + return; + } + case 46: + { + this.ComissaoNovoComboBox = (ComboBox)target; + this.ComissaoNovoComboBox.SelectionChanged += new SelectionChangedEventHandler(this.ComissaoVendedorBox_OnSelectionChanged); + return; + } + case 47: + { + this.ComissaoRenovacaoBox = (CustomItemValidation)target; + return; + } + case 48: + { + this.ComissaoRenovacaoComboBox = (ComboBox)target; + this.ComissaoRenovacaoComboBox.SelectionChanged += new SelectionChangedEventHandler(this.ComissaoVendedorBox_OnSelectionChanged); + return; + } + case 49: + { + this.ValorRepasseBox = (CurrencyTextBox)target; + return; + } + case 50: + { + this.FormaRecebidaBox = (TextBox)target; + return; + } + case 51: + { + this.VendedorGrid = (DataGrid)target; + return; + } + case 52: + { + this.RepasseVendedor = (DataGridTextColumn)target; + return; + } + case 54: + { + this.NomeBox = (TextBox)target; + return; + } + case 55: + { + this.TipoDocumentoPrincipalBox = (ComboBox)target; + return; + } + case 56: + { + this.DocumentoPrincipalBox = (TextBox)target; + CriticaApoliceView criticaApoliceView = this; + this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView.SomenteNumeros); + this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus); + return; + } + case 57: + { + this.NascimentoBox = (DatePicker)target; + this.NascimentoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.NascimentoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 58: + { + this.IdentidadeBox = (TextBox)target; + return; + } + case 59: + { + this.EmissorBox = (TextBox)target; + return; + } + case 60: + { + this.EstadoEmissorBox = (TextBox)target; + return; + } + case 61: + { + ((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 62: + { + this.TelefoneListBox = (ListBox)target; + return; + } + case 68: + { + this.EmailListBox = (ListBox)target; + return; + } + case 71: + { + this.ItemGrid = (DataGrid)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) + { + if (connectionId == 9) + { + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_OnClick)); + return; + } + if (connectionId == 53) + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirVendedor_OnClick); + return; + } + switch (connectionId) + { + case 63: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBox_OnSelectionChanged); + return; + } + case 64: + { + CriticaApoliceView criticaApoliceView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView.SomenteNumeros); + return; + } + case 65: + { + CriticaApoliceView criticaApoliceView1 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(criticaApoliceView1.FormatarTelefone); + CriticaApoliceView criticaApoliceView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView2.SomenteNumeros); + return; + } + case 66: + { + ((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus); + CriticaApoliceView criticaApoliceView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView3.SomenteNumeros); + return; + } + case 67: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirTelefone_OnClick); + return; + } + case 68: + case 71: + { + return; + } + case 69: + { + ((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus); + CriticaApoliceView criticaApoliceView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(criticaApoliceView4.SomenteNumeros); + return; + } + case 70: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirEmail_OnClick); + return; + } + case 72: + { + ((Button)target).Click += new RoutedEventHandler(this.Item_Click); + return; + } + default: + { + return; + } + } + } + + private void Tarefa_OnClick(object sender, RoutedEventArgs e) + { + Tarefa tarefa = new Tarefa(); + tarefa.set_IdCliente(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Id()); + tarefa.set_Cliente(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome()); + tarefa.set_Entidade(0); + tarefa.set_IdEntidade(this.ViewModel.SelectedDocumento.get_Id()); + tarefa.set_Titulo(string.Concat(this.ViewModel.SelectedDocumento.get_Controle().get_Cliente().get_Nome(), " APÓLICE ", this.ViewModel.SelectedDocumento.get_Apolice())); + Tarefa tarefa1 = tarefa; + this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa1, 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 TipoDocumentoPrincipalBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + this.ViewModel.AlteraDocumentoPrincipal(); + } + + private void TipoVendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + if (this.ViewModel.SelectedPagamento == null) + { + this.ViewModel.SelectedPagamento = new VendedorParcela(); + } + this.ViewModel.SelectedPagamento.set_TipoVendedor((TipoVendedor)comboBox.SelectedItem); + } + + private async void Usuario_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool hasValue; + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null && comboBox.SelectedItem != null) + { + ToggleButton criticadoBox = this.CriticadoBox; + if (criticadoBox != null) + { + hasValue = !criticadoBox.IsChecked.HasValue; + } + else + { + hasValue = true; + } + if (!hasValue) + { + if (this.ViewModel.SelectedSeguradora != null) + { + this.SeguradoraBox.SelectionChanged -= new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged -= new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked -= new RoutedEventHandler(this.Criticado_OnChecked); + this.ViewModel.SelectedUsuario = (Usuario)comboBox.SelectedItem; + await this.ViewModel.CarregaCritica(((Usuario)comboBox.SelectedItem).get_Id(), this.ViewModel.SelectedSeguradora.get_Id(), this.ViewModel.Criticado); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Seguradora_OnSelectionChanged); + this.UsuarioBox.SelectionChanged += new SelectionChangedEventHandler(this.Usuario_OnSelectionChanged); + this.CriticadoBox.Checked += new RoutedEventHandler(this.Criticado_OnChecked); + } + } + } + } + + private void ValidarDocumento() + { + if (this.ViewModel.SelectedDocumento == null) + { + return; + } + List> keyValuePairs1 = this.ViewModel.SelectedDocumento.Validate(); + if (this.ViewModel.Telefones != null) + { + ExtensionMethods.ForEach(this.ViewModel.Telefones, (ClienteTelefone x) => { + List> keyValuePairs = x.Validate(); + keyValuePairs1.AddRange(keyValuePairs); + }); + } + this.ValidateFields(keyValuePairs1, false); + ExtensionMethods.ForEach(Extentions.FindVisualChildren(this.TelefoneListBox), (DependencyObject child) => child.ValidateFields(keyValuePairs1, false)); + } + + private void VendedorBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + this.ViewModel.FiltrarRepasse((Vendedor)comboBox.SelectedItem); + NegocioCorretora? negocioCorretora = this.ViewModel.SelectedDocumento.get_NegocioCorretora(); + bool valueOrDefault = negocioCorretora.GetValueOrDefault() == 1; + if (valueOrDefault && this.ViewModel.CoCorretagem) + { + this.ComissaoNovoBox.Visibility = System.Windows.Visibility.Visible; + this.ComissaoRenovacaoBox.Visibility = System.Windows.Visibility.Collapsed; + return; + } + this.ComissaoNovoBox.Visibility = (!valueOrDefault ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.ComissaoRenovacaoBox.Visibility = (valueOrDefault ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/AeronauticoView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/AeronauticoView.cs new file mode 100644 index 0000000..d0bef66 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/AeronauticoView.cs @@ -0,0 +1,373 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.Common; +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.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; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class AeronauticoView : BaseUserControl, IComponentConnector + { + public AeronauticoViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + private string _lastCategory = ""; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal CustomItemValidation MaisInformacoes; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public AeronauticoView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new AeronauticoViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + 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) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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 ", ValidationHelper.GetDescription((TipoArquivoDigital)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name == "MaisInformacoesRadioButton") + { + this.MaisInformacoes.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Excluir(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + [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/itens/aeronauticoview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + 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, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + 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: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Tipo_OnSelectionChanged); + return; + } + case 12: + { + AeronauticoView aeronauticoView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(aeronauticoView.SomenteNumeros); + return; + } + case 13: + { + AeronauticoView aeronauticoView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(aeronauticoView1.SomenteNumeros); + return; + } + case 14: + { + AeronauticoView aeronauticoView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(aeronauticoView2.SomenteNumeros); + return; + } + case 15: + { + AeronauticoView aeronauticoView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(aeronauticoView3.SomenteNumeros); + 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); + return; + } + case 17: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 18: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 19: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 20: + { + this.MaisInformacoes = (CustomItemValidation)target; + return; + } + } + this._contentLoaded = true; + } + + private void Tipo_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (((ComboBox)sender).SelectedItem == null) + { + return; + } + if (ValidationHelper.GetCategory((TipoAeronautico)((ComboBox)sender).SelectedItem) == this._lastCategory) + { + return; + } + this.ViewModel.SelectedItem.get_Aeronautico().set_Tipo((TipoAeronautico)((ComboBox)sender).SelectedItem); + this.ViewModel.UpdateAero(); + this.ValidateFields(this.ViewModel.SelectedItem.Validate(), true); + this._lastCategory = ValidationHelper.GetCategory(this.ViewModel.SelectedItem.get_Aeronautico().get_Tipo()); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/AutoView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/AutoView.cs new file mode 100644 index 0000000..4a9c3be --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/AutoView.cs @@ -0,0 +1,718 @@ +using Gestor.Application.Actions; +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +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.Helper; +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.Text.RegularExpressions; +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; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class AutoView : BaseUserControl, IComponentConnector + { + public AutoViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal WrapPanel PainelDadosAuto; + + internal TextBox FipeBox; + + internal AutoCompleteBox AutoCompleteFabricacao; + + internal TextBox ModeloBox; + + internal TextBox AnoModeloBox; + + internal TextBox CepCirculacaoBox; + + internal TextBox CepPernoiteBox; + + internal ComboBox ComboBoxTipoCorrecao; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal CustomItemValidation MaisInformacoes; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public AutoView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new AutoViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + 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) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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 ", Gestor.Common.Validation.ValidationHelper.GetDescription((TipoArquivoDigital)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void AutoCompleteFabricanteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscaFabricante(Gestor.Common.Validation.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 BaixarXls_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.BaixarXls(); + } + + private async void BuscarModelo_OnClick(object sender, RoutedEventArgs e) + { + Fipe fipe = await this.ViewModel.ShowBuscaModeloDialog(this.ModeloBox.Text, this.AnoModeloBox.Text); + Fipe fipe1 = fipe; + if (fipe1 != null) + { + this.FipeBox.Text = fipe1.get_Codigo(); + this.ModeloBox.Text = fipe1.get_Modelo(); + this.AutoCompleteFabricacao.set_Text(fipe1.get_Marca()); + this.ViewModel.SelectedItem.get_Auto().set_Fabricante(this.ViewModel.Fabricantes.FirstOrDefault((Fabricante x) => x.get_Descricao() == fipe1.get_Marca())); + } + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void Cep_OnLostFocus(object sender, RoutedEventArgs e) + { + bool auto; + TextBox textBox = (TextBox)sender; + Item selectedItem = this.ViewModel.SelectedItem; + if (selectedItem != null) + { + auto = selectedItem.get_Auto(); + } + else + { + auto = false; + } + if (!auto) + { + return; + } + if (string.IsNullOrWhiteSpace(textBox.Text)) + { + return; + } + if ((textBox.Name == "CepCirculacaoBox" || textBox.Name == "CepPernoiteBox") && Gestor.Common.Validation.ValidationHelper.ValidaCep(textBox.Text)) + { + return; + } + if (!Gestor.Model.Helper.ValidationHelper.ValidacaoCep(Gestor.Common.Validation.ValidationHelper.FormatPostCode(textBox.Text))) + { + return; + } + textBox.Text = Gestor.Common.Validation.ValidationHelper.FormatPostCode(textBox.Text); + } + + private void Ci_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = Gestor.Common.Validation.ValidationHelper.FormatCi(textBox.Text); + } + + private void ComboBoxTipoCorrecao_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (this.ComboBoxTipoCorrecao.SelectedItem == null) + { + return; + } + this.ViewModel.Atualiza(this.ComboBoxTipoCorrecao.SelectedItem.ToString().ToUpper()); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name == "MaisInformacoesRadioButton") + { + this.MaisInformacoes.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.Excluir()) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + } + + private async void Fipe_LostFocus(object sender, RoutedEventArgs e) + { + int num; + bool auto; + object obj; + TextBox textBox = (TextBox)sender; + Item selectedItem = this.ViewModel.SelectedItem; + if (selectedItem != null) + { + auto = selectedItem.get_Auto(); + } + else + { + auto = false; + } + if (auto) + { + if (!string.IsNullOrWhiteSpace(textBox.Text)) + { + string str = Gestor.Model.Helper.ValidationHelper.FormataFipe(textBox.Text.Replace("-", "")); + if (Gestor.Model.Helper.ValidationHelper.ValidaFipe(str)) + { + textBox.Text = str; + if (!int.TryParse(Gestor.Model.Helper.ValidationHelper.OnlyNumber(str), out num) || num != 0) + { + Fipe fipe = await this.ViewModel.BuscaModelo(textBox.Text); + if (fipe != null) + { + this.ModeloBox.Text = fipe.get_Modelo(); + AutoCompleteBox autoCompleteFabricacao = this.AutoCompleteFabricacao; + List fabricantes = this.ViewModel.Fabricantes; + if (fabricantes != null) + { + obj = fabricantes.FirstOrDefault((Fabricante x) => x.get_Descricao() == fipe.get_Marca()); + } + else + { + obj = null; + } + autoCompleteFabricacao.set_SelectedItem(obj); + } + else + { + this.ViewModel.ToggleSnackBar(string.Concat("MODELO NÃO ENCONTRADO PARA O CÓDIGO FIPE ", textBox.Text), true); + } + } + } + } + } + textBox = null; + } + + private async void ImportarXls_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + Action enablePesquisarClientes = Gestor.Application.Actions.Actions.EnablePesquisarClientes; + if (enablePesquisarClientes != null) + { + enablePesquisarClientes(false); + } + else + { + } + Action enableMenu = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu != null) + { + enableMenu(false); + } + else + { + } + Action enableMainMenu = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu != null) + { + enableMainMenu(false); + } + else + { + } + List> keyValuePairs = await this.ViewModel.ImportarXls(); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + Action action = Gestor.Application.Actions.Actions.EnablePesquisarClientes; + if (action != null) + { + action(true); + } + else + { + } + Action enableMenu1 = Gestor.Application.Actions.Actions.EnableMenu; + if (enableMenu1 != null) + { + enableMenu1(true); + } + else + { + } + Action enableMainMenu1 = Gestor.Application.Actions.Actions.EnableMainMenu; + if (enableMainMenu1 != null) + { + enableMainMenu1(true); + } + else + { + } + this.ViewModel.Loading(false); + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + Item selectedItem = this.ViewModel.SelectedItem; + List configuracoes = Recursos.Configuracoes; + bool flag = configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 18); + List configuracaoSistemas = Recursos.Configuracoes; + List> keyValuePairs = selectedItem.Validate(flag, configuracaoSistemas.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 27)); + this.ValidateFields(keyValuePairs, true); + } + + [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/itens/autoview.xaml", UriKind.Relative)); + } + + private void KeyUpBase_OnKeyUp(object sender, KeyEventArgs e) + { + TextBox textBox = (TextBox)sender; + if (!Regex.IsMatch(textBox.Text.Replace(".", ""), "^[0-9.]{11}$")) + { + textBox.Text = Regex.Replace(textBox.Text, "[^\\d]*", ""); + } + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + private void Placa(object sender, KeyEventArgs e) + { + Gestor.Model.Helper.ValidationHelper.FormataPlaca(((TextBox)sender).Text); + } + + private void Renavam_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = Gestor.Common.Validation.ValidationHelper.FormatRenavam(textBox.Text); + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.FipeBox.Focus(); + 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, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + private void SelecionaUsoVeiculo(object sender, SelectionChangedEventArgs e) + { + if (this.ViewModel.UsoVeiculo.GetValueOrDefault() == 2 || this.ViewModel.UsoVeiculo.GetValueOrDefault() == 3) + { + this.ViewModel.SelectedItem.get_Auto().set_Categoria(new Categoria?(3)); + } + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + 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.ImportarXls_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.BaixarXls_OnClick); + return; + } + case 13: + { + this.PainelDadosAuto = (WrapPanel)target; + return; + } + case 14: + { + this.FipeBox = (TextBox)target; + AutoView autoView = this; + this.FipeBox.PreviewTextInput += new TextCompositionEventHandler(autoView.SomenteNumeros); + this.FipeBox.LostFocus += new RoutedEventHandler(this.Fipe_LostFocus); + return; + } + case 15: + { + AutoView autoView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView1.Placa); + ((TextBox)target).PreviewKeyDown += new KeyEventHandler(this.Placa); + return; + } + case 16: + { + this.AutoCompleteFabricacao = (AutoCompleteBox)target; + this.AutoCompleteFabricacao.add_Populating(new PopulatingEventHandler(this, AutoView.AutoCompleteFabricanteBox_Populating)); + return; + } + case 17: + { + this.ModeloBox = (TextBox)target; + return; + } + case 18: + { + ((Button)target).Click += new RoutedEventHandler(this.BuscarModelo_OnClick); + return; + } + case 19: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.SelecionaUsoVeiculo); + return; + } + case 20: + { + AutoView autoView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView2.SomenteNumeros); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.Renavam_OnLostFocus); + ((TextBox)target).PreviewKeyUp += new KeyEventHandler(this.KeyUpBase_OnKeyUp); + return; + } + case 21: + { + ((ToggleButton)target).Checked += new RoutedEventHandler(this.ZeroKmToggleButton_Changed); + ((ToggleButton)target).Unchecked += new RoutedEventHandler(this.ZeroKmToggleButton_Changed); + return; + } + case 22: + { + AutoView autoView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView3.SomenteNumeros); + return; + } + case 23: + { + this.AnoModeloBox = (TextBox)target; + AutoView autoView4 = this; + this.AnoModeloBox.PreviewTextInput += new TextCompositionEventHandler(autoView4.SomenteNumeros); + return; + } + case 24: + { + AutoView autoView5 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView5.SomenteNumeros); + return; + } + case 25: + { + AutoView autoView6 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView6.SomenteNumeros); + return; + } + case 26: + { + this.CepCirculacaoBox = (TextBox)target; + this.CepCirculacaoBox.LostFocus += new RoutedEventHandler(this.Cep_OnLostFocus); + AutoView autoView7 = this; + this.CepCirculacaoBox.PreviewTextInput += new TextCompositionEventHandler(autoView7.SomenteNumeros); + return; + } + case 27: + { + this.CepPernoiteBox = (TextBox)target; + this.CepPernoiteBox.LostFocus += new RoutedEventHandler(this.Cep_OnLostFocus); + AutoView autoView8 = this; + this.CepPernoiteBox.PreviewTextInput += new TextCompositionEventHandler(autoView8.SomenteNumeros); + return; + } + case 28: + { + this.ComboBoxTipoCorrecao = (ComboBox)target; + this.ComboBoxTipoCorrecao.SelectionChanged += new SelectionChangedEventHandler(this.ComboBoxTipoCorrecao_SelectionChanged); + return; + } + case 29: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.Ci_OnLostFocus); + AutoView autoView9 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView9.SomenteNumeros); + return; + } + case 30: + { + AutoView autoView10 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(autoView10.SomenteNumeros); + return; + } + case 31: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 32: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 33: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 34: + { + this.MaisInformacoes = (CustomItemValidation)target; + return; + } + } + this._contentLoaded = true; + } + + private void ZeroKmToggleButton_Changed(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedItem == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/BuscarModeloView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/BuscarModeloView.cs new file mode 100644 index 0000000..1f89612 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/BuscarModeloView.cs @@ -0,0 +1,85 @@ +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Markup; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class BuscarModeloView : BaseUserControl, IComponentConnector + { + internal DataGrid BuscaModeloGrid; + + private bool _contentLoaded; + + public BuscarModeloViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public BuscarModeloView(BuscarModeloViewModel viewModel) + { + this.ViewModel = viewModel; + base.DataContext = this.ViewModel; + this.InitializeComponent(); + } + + [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/itens/buscarmodeloview.xaml", UriKind.Relative)); + } + + private void Pesquisar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Pesquisar(); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + BuscarModeloView buscarModeloView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(buscarModeloView.SomenteNumeros); + return; + } + case 2: + { + ((Button)target).Click += new RoutedEventHandler(this.Pesquisar_OnClick); + return; + } + case 3: + { + this.BuscaModeloGrid = (DataGrid)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/ConsorcioView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/ConsorcioView.cs new file mode 100644 index 0000000..3b14a0c --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/ConsorcioView.cs @@ -0,0 +1,320 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.Common; +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.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class ConsorcioView : BaseUserControl, IComponentConnector + { + public ConsorcioViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + private bool _salvando; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal CustomItemValidation MaisInformacoes; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ConsorcioView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new ConsorcioViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + 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) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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 ", ValidationHelper.GetDescription((TipoArquivoDigital)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name == "MaisInformacoesRadioButton") + { + this.MaisInformacoes.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Excluir(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + [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/itens/consorcioview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + 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, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + 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: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 12: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 13: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 14: + { + this.MaisInformacoes = (CustomItemValidation)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/GranizoView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/GranizoView.cs new file mode 100644 index 0000000..9382fe6 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/GranizoView.cs @@ -0,0 +1,383 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.Common; +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.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class GranizoView : BaseUserControl, IComponentConnector + { + public GranizoViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal TextBox CepBox; + + internal TextBox EnderecoBox; + + internal TextBox BairroBox; + + internal TextBox CidadeBox; + + internal TextBox EstadoBox; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal CustomItemValidation MaisInformacoes; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public GranizoView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new GranizoViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + 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) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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 ", ValidationHelper.GetDescription((TipoArquivoDigital)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name == "MaisInformacoesRadioButton") + { + this.MaisInformacoes.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.Excluir()) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.IncluirItem(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + [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/itens/granizoview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + if (!string.IsNullOrWhiteSpace(textBox.Text)) + { + string str = ValidationHelper.FormatPostCode(textBox.Text); + this.CepBox.Text = str; + if (ValidationHelper.ValidatePostCode(str)) + { + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + this.EnderecoBox.Text = enderecoBase.get_Endereco(); + this.CidadeBox.Text = enderecoBase.get_Cidade(); + this.EstadoBox.Text = enderecoBase.get_Estado(); + this.BairroBox.Text = enderecoBase.get_Bairro(); + } + } + } + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + 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, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + 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: + { + this.CepBox = (TextBox)target; + this.CepBox.LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + return; + } + case 12: + { + this.EnderecoBox = (TextBox)target; + return; + } + case 13: + { + GranizoView granizoView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(granizoView.SomenteNumeros); + return; + } + case 14: + { + this.BairroBox = (TextBox)target; + return; + } + case 15: + { + this.CidadeBox = (TextBox)target; + return; + } + case 16: + { + this.EstadoBox = (TextBox)target; + return; + } + case 17: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 18: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 19: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 20: + { + this.MaisInformacoes = (CustomItemValidation)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/PatrimonialView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/PatrimonialView.cs new file mode 100644 index 0000000..42e03ce --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/PatrimonialView.cs @@ -0,0 +1,466 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.Common; +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.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class PatrimonialView : BaseUserControl, IComponentConnector + { + public PatrimonialViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal TextBox CepBox; + + internal TextBox EnderecoBox; + + internal TextBox BairroBox; + + internal TextBox CidadeBox; + + internal TextBox EstadoBox; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal CustomItemValidation MaisInformacoes; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public PatrimonialView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new PatrimonialViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + 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) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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 ", ValidationHelper.GetDescription((TipoArquivoDigital)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void CpfBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.MaisInformacoes.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name == "MaisInformacoesRadioButton") + { + this.MaisInformacoes.Visibility = System.Windows.Visibility.Visible; + return; + } + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.Excluir()) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + [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/itens/patrimonialview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + if (!string.IsNullOrWhiteSpace(textBox.Text)) + { + string str = ValidationHelper.FormatPostCode(textBox.Text); + if (ValidationHelper.ValidatePostCode(str)) + { + this.CepBox.Text = str; + EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str); + if (enderecoBase != null) + { + this.EnderecoBox.Text = enderecoBase.get_Endereco(); + this.CidadeBox.Text = enderecoBase.get_Cidade(); + this.EstadoBox.Text = enderecoBase.get_Estado(); + this.BairroBox.Text = enderecoBase.get_Bairro(); + } + } + } + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + 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, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + 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: + { + this.CepBox = (TextBox)target; + this.CepBox.LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + return; + } + case 12: + { + this.EnderecoBox = (TextBox)target; + return; + } + case 13: + { + PatrimonialView patrimonialView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView.SomenteNumeros); + return; + } + case 14: + { + this.BairroBox = (TextBox)target; + return; + } + case 15: + { + this.CidadeBox = (TextBox)target; + return; + } + case 16: + { + this.EstadoBox = (TextBox)target; + return; + } + case 17: + { + PatrimonialView patrimonialView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView1.SomenteNumeros); + return; + } + case 18: + { + PatrimonialView patrimonialView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView2.SomenteNumeros); + PatrimonialView patrimonialView3 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(patrimonialView3.FormatarTelefone); + return; + } + case 19: + { + PatrimonialView patrimonialView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView4.SomenteNumeros); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.CpfBox_OnLostFocus); + return; + } + case 20: + { + PatrimonialView patrimonialView5 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView5.SomenteNumeros); + return; + } + case 21: + { + PatrimonialView patrimonialView6 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(patrimonialView6.FormatarTelefone); + PatrimonialView patrimonialView7 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView7.SomenteNumeros); + return; + } + case 22: + { + PatrimonialView patrimonialView8 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView8.SomenteNumeros); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.CpfBox_OnLostFocus); + return; + } + case 23: + { + PatrimonialView patrimonialView9 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView9.SomenteNumeros); + return; + } + case 24: + { + PatrimonialView patrimonialView10 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(patrimonialView10.FormatarTelefone); + PatrimonialView patrimonialView11 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView11.SomenteNumeros); + return; + } + case 25: + { + PatrimonialView patrimonialView12 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView12.SomenteNumeros); + ((TextBox)target).LostFocus += new RoutedEventHandler(this.CpfBox_OnLostFocus); + return; + } + case 26: + { + PatrimonialView patrimonialView13 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView13.SomenteNumeros); + return; + } + case 27: + { + PatrimonialView patrimonialView14 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(patrimonialView14.FormatarTelefone); + PatrimonialView patrimonialView15 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(patrimonialView15.SomenteNumeros); + return; + } + case 28: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 29: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 30: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 31: + { + this.MaisInformacoes = (CustomItemValidation)target; + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/RiscosDiversosView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/RiscosDiversosView.cs new file mode 100644 index 0000000..70a30b9 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/RiscosDiversosView.cs @@ -0,0 +1,683 @@ +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Collections.ObjectModel; +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.Data; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class RiscosDiversosView : BaseUserControl, IComponentConnector, IStyleConnector + { + public RiscosDiversosViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + private bool _salvando; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal Menu BotoesTitulares; + + internal Separator SeparadorMaisInformacoes; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal DataGrid DataGridTitulares; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public RiscosDiversosView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new RiscosDiversosViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + 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) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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 ", ValidationHelper.GetDescription((TipoArquivoDigital)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void AlterarTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AlterarTitular(); + } + + private void AplicarTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AplicarTitular(); + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Trim().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarTitulares(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 BotoesTitulares_OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) + { + bool flag; + if (!((Menu)sender).IsEnabled) + { + this.ViewModel.AlteracaoTitularesVisibility = System.Windows.Visibility.Collapsed; + } + DataGrid dataGridTitulares = this.DataGridTitulares; + if (dataGridTitulares != null) + { + flag = dataGridTitulares.Columns.First(); + } + else + { + flag = false; + } + if (!flag) + { + return; + } + this.DataGridTitulares.Columns.First().Visibility = (((Menu)sender).IsEnabled ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void DataGridTitulares_OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e) + { + string text; + string str; + string text1; + if (!(e.EditingElement is TextBox)) + { + return; + } + TextBox editingElement = e.EditingElement as TextBox; + string stringFormat = e.Column.ClipboardContentBinding.StringFormat; + if (stringFormat == "d") + { + if (editingElement != null) + { + text = editingElement.Text; + } + else + { + text = null; + } + if (!string.IsNullOrEmpty(text)) + { + editingElement.Text = ValidationHelper.FormatDate(editingElement.Text); + return; + } + if (editingElement != null) + { + editingElement.Text = null; + return; + } + } + else if (stringFormat == "c") + { + if (editingElement != null) + { + str = editingElement.Text; + } + else + { + str = null; + } + if (!string.IsNullOrEmpty(str)) + { + editingElement.Text = ValidationHelper.FormatCurrency(editingElement.Text); + return; + } + if (editingElement != null) + { + editingElement.Text = null; + } + } + else + { + if (editingElement != null) + { + text1 = editingElement.Text; + } + else + { + text1 = null; + } + if (!string.IsNullOrEmpty(text1)) + { + if (e.Column.SortMemberPath == "Cpf") + { + editingElement.Text = ValidationHelper.FormatDocument(editingElement.Text); + return; + } + } + else if (editingElement != null) + { + editingElement.Text = null; + return; + } + } + } + + private void Dependente_CellLoaded(object sender, RoutedEventArgs e) + { + bool valueOrDefault; + if (sender == null) + { + return; + } + DataGridCell dataGridCell = (DataGridCell)sender; + TitularesVida dataContext = (TitularesVida)((DataGridCell)sender).DataContext; + if (dataContext != null) + { + valueOrDefault = dataContext.get_Tipo().GetValueOrDefault() == 2; + } + else + { + valueOrDefault = false; + } + dataGridCell.Visibility = (valueOrDefault ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.DataGridTitulares.Visibility = System.Windows.Visibility.Collapsed; + this.SeparadorMaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.BotoesTitulares.Visibility = System.Windows.Visibility.Collapsed; + this.DataGridTitulares.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name != "MaisInformacoesRadioButton") + { + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + return; + } + this.SeparadorMaisInformacoes.Visibility = System.Windows.Visibility.Visible; + this.DataGridTitulares.Visibility = System.Windows.Visibility.Visible; + this.BotoesTitulares.Visibility = System.Windows.Visibility.Visible; + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.Excluir()) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + } + + private void ExcluirTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ExcluirTitular(); + } + + private async void ImportarTitulares_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.ImportarTitulares(); + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + private void IncluirTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.IncluirTitular(); + this.UpdateAutocompleteDependente(this.DataGridTitulares.Items.Cast().First()); + } + + [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/itens/riscosdiversosview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this._salvando = true; + this.ViewModel.Loading(true); + this.DataGridTitulares.Focus(); + List> keyValuePairs = await this.ViewModel.Salvar(this.DataGridTitulares.Items.Cast().ToList()); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + this._salvando = false; + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + 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: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 12: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 13: + { + this.BotoesTitulares = (Menu)target; + this.BotoesTitulares.IsEnabledChanged += new DependencyPropertyChangedEventHandler(this.BotoesTitulares_OnIsEnabledChanged); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTitular_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AlterarTitular_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirTitular_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ImportarTitulares_OnClick); + return; + } + case 18: + { + this.SeparadorMaisInformacoes = (Separator)target; + return; + } + case 19: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 20: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 21: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 22: + { + RiscosDiversosView riscosDiversosView = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(riscosDiversosView.FormatarDocumento); + RiscosDiversosView riscosDiversosView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(riscosDiversosView1.SomenteNumeros); + return; + } + case 23: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AplicarTitular_OnClick); + return; + } + case 24: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 25: + { + this.DataGridTitulares = (DataGrid)target; + this.DataGridTitulares.CellEditEnding += new EventHandler(this.DataGridTitulares_OnCellEditEnding); + return; + } + } + this._contentLoaded = true; + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 26: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 27: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 28: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 29: + { + RiscosDiversosView riscosDiversosView = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(riscosDiversosView.FormatarDocumento); + RiscosDiversosView riscosDiversosView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(riscosDiversosView1.SomenteNumeros); + return; + } + case 30: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBoxSelectionChanged); + return; + } + case 31: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, RiscosDiversosView.AutoCompleteBox_Populating)); + return; + } + case 32: + { + EventSetter eventSetter = new EventSetter() + { + Event = FrameworkElement.LoadedEvent, + Handler = new RoutedEventHandler(this.Dependente_CellLoaded) + }; + ((System.Windows.Style)target).Setters.Add(eventSetter); + return; + } + default: + { + return; + } + } + } + + private async void TipoComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool dataContext; + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null) + { + dataContext = comboBox.DataContext; + } + else + { + dataContext = false; + } + if (dataContext) + { + TipoTitular? nullable = ((TitularesVida)((ComboBox)sender).DataContext).get_Tipo(); + if (nullable.GetValueOrDefault() == 2 && !this._salvando) + { + ObservableCollection titulares = this.ViewModel.Titulares; + if (!titulares.Any((TitularesVida x) => { + TipoTitular? tipo = x.get_Tipo(); + if (tipo.GetValueOrDefault() == 1) + { + return true; + } + tipo = x.get_Tipo(); + return tipo.GetValueOrDefault() == 0 & tipo.HasValue; + })) + { + ((ComboBox)sender).SelectedIndex = -1; + nullable = null; + ((TitularesVida)((ComboBox)sender).DataContext).set_Tipo(nullable); + await this.ViewModel.ShowMessage("É NECESSÁRIO ADICIONAR PELO MENOS UM TITULAR DO TIPO SÓCIO OU FUNCIONÁRIO\nANTES DE ADICIONAR UM DEPENDENTE.", "OK", "", false); + return; + } + } + this.UpdateAutocompleteDependente((TitularesVida)((ComboBox)sender).DataContext); + } + } + + private void UpdateAutocompleteDependente(TitularesVida item) + { + this.DataGridTitulares.ScrollIntoView(item, this.DataGridTitulares.Columns.First((DataGridColumn x) => (string)x.Header == "TITULAR DEPENDENTE")); + this.DataGridTitulares.UpdateLayout(); + DataGridRow dataGridRow = (DataGridRow)this.DataGridTitulares.ItemContainerGenerator.ContainerFromItem(item); + if (dataGridRow == null) + { + return; + } + ((DataGridCell)DataGridExtensions.GetVisualChild(dataGridRow).ItemContainerGenerator.ContainerFromIndex(12)).Visibility = (item.get_Tipo().GetValueOrDefault() == 2 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + this.DataGridTitulares.ScrollIntoView(item, this.DataGridTitulares.Columns.First()); + this.DataGridTitulares.UpdateLayout(); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/Itens/VidaView.cs b/Codemerx/Gestor.Application/Views/Seguros/Itens/VidaView.cs new file mode 100644 index 0000000..afb86b5 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/Itens/VidaView.cs @@ -0,0 +1,705 @@ +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.ViewModels.Seguros.Itens; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Collections.ObjectModel; +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.Data; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Views.Seguros.Itens +{ + public class VidaView : BaseUserControl, IComponentConnector, IStyleConnector + { + public VidaViewModel ViewModel; + + private readonly MenuItemViewModel _menuItemViewModel; + + private bool _salvando; + + internal MenuItem IncluirItemButton; + + internal MenuItem SinistroButton; + + internal TextBox PlanoBox; + + internal RadioButton CoberturasRadioButton; + + internal RadioButton MaisInformacoesRadioButton; + + internal Menu BotoesTitulares; + + internal Separator SeparadorMaisInformacoes; + + internal System.Windows.Controls.ContentControl ContentControl; + + internal DataGrid DataGridTitulares; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public VidaView(MenuItemViewModel menuItemViewModel, bool lockInsert = false, bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Ramo ramo = null, bool endossoRenovacao = false) + { + this._menuItemViewModel = menuItemViewModel; + this.ViewModel = new VidaViewModel(substituir, manutencao, itemSelecionado, ramo, endossoRenovacao); + 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) + { + return; + } + this.IncluirItemButton.IsEnabled = false; + this.SinistroButton.Visibility = System.Windows.Visibility.Collapsed; + } + + private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 4).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedItem.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedItem.get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(4); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedItem); + 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 ", ValidationHelper.GetDescription((TipoArquivoDigital)4), "."), "OK", "", false); + } + } + + private void AbrirLog_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLogEmail(3, this.ViewModel.SelectedItem.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void AlterarTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AlterarTitular(); + } + + private void AplicarTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AplicarTitular(); + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Trim().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.BuscarTitulares(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 BotoesTitulares_OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) + { + bool flag; + if (!((Menu)sender).IsEnabled) + { + this.ViewModel.AlteracaoTitularesVisibility = System.Windows.Visibility.Collapsed; + } + DataGrid dataGridTitulares = this.DataGridTitulares; + if (dataGridTitulares != null) + { + flag = dataGridTitulares.Columns.First(); + } + else + { + flag = false; + } + if (!flag) + { + return; + } + this.DataGridTitulares.Columns.First().Visibility = (((Menu)sender).IsEnabled ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.CoberturasRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + this.MaisInformacoesRadioButton.Checked += new RoutedEventHandler(this.Documento_OnChecked); + } + + private void CopyCodItem(object sender, MouseButtonEventArgs e) + { + this.ViewModel.CodigoItem.CopyToClipboard(); + this.ViewModel.ToggleSnackBar(string.Concat("COPIADO - ", this.ViewModel.CodigoItem), true); + } + + private void DataGridTitulares_OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e) + { + string text; + string str; + string text1; + if (!(e.EditingElement is TextBox)) + { + return; + } + TextBox editingElement = e.EditingElement as TextBox; + string stringFormat = e.Column.ClipboardContentBinding.StringFormat; + if (stringFormat == "d") + { + if (editingElement != null) + { + text = editingElement.Text; + } + else + { + text = null; + } + if (!string.IsNullOrEmpty(text)) + { + editingElement.Text = ValidationHelper.FormatDate(editingElement.Text); + return; + } + if (editingElement != null) + { + editingElement.Text = null; + return; + } + } + else if (stringFormat == "c") + { + if (editingElement != null) + { + str = editingElement.Text; + } + else + { + str = null; + } + if (!string.IsNullOrEmpty(str)) + { + editingElement.Text = ValidationHelper.FormatCurrency(editingElement.Text); + return; + } + if (editingElement != null) + { + editingElement.Text = null; + } + } + else + { + if (editingElement != null) + { + text1 = editingElement.Text; + } + else + { + text1 = null; + } + if (!string.IsNullOrEmpty(text1)) + { + if (e.Column.SortMemberPath == "Cpf") + { + editingElement.Text = ValidationHelper.FormatDocument(editingElement.Text); + return; + } + } + else if (editingElement != null) + { + editingElement.Text = null; + return; + } + } + } + + private void Dependente_CellLoaded(object sender, RoutedEventArgs e) + { + bool valueOrDefault; + if (sender == null) + { + return; + } + DataGridCell dataGridCell = (DataGridCell)sender; + TitularesVida dataContext = (TitularesVida)((DataGridCell)sender).DataContext; + if (dataContext != null) + { + valueOrDefault = dataContext.get_Tipo().GetValueOrDefault() == 2; + } + else + { + valueOrDefault = false; + } + dataGridCell.Visibility = (valueOrDefault ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + } + + private void Documento_OnChecked(object sender, RoutedEventArgs e) + { + RadioButton radioButton = (RadioButton)sender; + if (string.IsNullOrEmpty(radioButton.GroupName)) + { + return; + } + this.ViewModel.Descarregar(); + this.ContentControl.Visibility = System.Windows.Visibility.Collapsed; + this.DataGridTitulares.Visibility = System.Windows.Visibility.Collapsed; + this.SeparadorMaisInformacoes.Visibility = System.Windows.Visibility.Collapsed; + this.BotoesTitulares.Visibility = System.Windows.Visibility.Collapsed; + this.DataGridTitulares.ClearInvalid(); + this.ContentControl.ClearInvalid(); + if (radioButton.Name != "MaisInformacoesRadioButton") + { + this.ContentControl.Visibility = System.Windows.Visibility.Visible; + this.ViewModel.CarregaCobertura(); + return; + } + this.SeparadorMaisInformacoes.Visibility = System.Windows.Visibility.Visible; + this.DataGridTitulares.Visibility = System.Windows.Visibility.Visible; + this.BotoesTitulares.Visibility = System.Windows.Visibility.Visible; + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + if (await this.ViewModel.Excluir()) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(null); + } + else + { + } + } + } + + private void ExcluirTitular_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ExcluirTitular(); + } + + private async void ImportarTitulares_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.ImportarTitulares(); + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Incluir(false); + List> keyValuePairs = this.ViewModel.SelectedItem.Validate(); + this.ValidateFields(keyValuePairs, true); + } + + private async void IncluirTitular_OnClick(object sender, RoutedEventArgs e) + { + TitularesVida titularesVida = this.DataGridTitulares.Items.Cast().FirstOrDefault(); + if (titularesVida == null || titularesVida.get_Inicio().HasValue || titularesVida.get_Fim().HasValue || titularesVida.get_Nome() != null || titularesVida.get_Fatura() != null || titularesVida.get_Cpf() != null || titularesVida.get_Tipo().HasValue || titularesVida.get_Observacao() != null) + { + this.ViewModel.IncluirTitular(); + this.UpdateAutocompleteDependente(this.DataGridTitulares.Items.Cast().First(), false); + } + else + { + await this.ViewModel.ShowMessage("JÁ EXISTE UM CAMPO DE CADASTRO DE TITULAR CRIADO", "OK", "", 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/itens/vidaview.xaml", UriKind.Relative)); + } + + public void Manter(ManutencaoItem manutencao) + { + this.ViewModel.Manter(ConsultaViewModel.ItemSelecionado, manutencao); + } + + private void MenuItem_OnClick(object sender, RoutedEventArgs e) + { + double? nullable = null; + double? nullable1 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(this.ViewModel.SelectedItem, false), string.Concat("CADASTRO DE SINISTROS - ", this.ViewModel.SelectedItem.get_Descricao()), nullable1, nullable, false)).ShowDialog(); + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel == null) + { + return; + } + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + + public async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this._salvando = true; + this.ViewModel.Loading(true); + this.ViewModel.SelectedItem.get_Vida().set_Plano(this.PlanoBox.Text); + this.DataGridTitulares.Focus(); + List> keyValuePairs = await this.ViewModel.Salvar(this.DataGridTitulares.Items.Cast().ToList()); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Loading(false); + this._salvando = false; + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else if (this.ViewModel.SelectedItem.get_Id() > (long)0) + { + MenuItemViewModel menuItemViewModel = this._menuItemViewModel; + if (menuItemViewModel != null) + { + menuItemViewModel.RecarregarItens(this.ViewModel.SelectedItem); + } + else + { + } + } + } + + public async Task Selecionar(Item item) + { + await this.ViewModel.SelecionaItem(item, true); + } + + public void Substituir() + { + this.ViewModel.Substituir(ConsultaViewModel.ItemSelecionado); + } + + [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.IncluirItemButton = (MenuItem)target; + this.IncluirItemButton.Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((TextBox)target).MouseDoubleClick += new MouseButtonEventHandler(this.CopyCodItem); + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click); + return; + } + case 8: + { + this.SinistroButton = (MenuItem)target; + this.SinistroButton.Click += new RoutedEventHandler(this.MenuItem_OnClick); + 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: + { + this.PlanoBox = (TextBox)target; + return; + } + case 12: + { + this.CoberturasRadioButton = (RadioButton)target; + return; + } + case 13: + { + this.MaisInformacoesRadioButton = (RadioButton)target; + return; + } + case 14: + { + this.BotoesTitulares = (Menu)target; + this.BotoesTitulares.IsEnabledChanged += new DependencyPropertyChangedEventHandler(this.BotoesTitulares_OnIsEnabledChanged); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTitular_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AlterarTitular_OnClick); + return; + } + case 17: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ExcluirTitular_OnClick); + return; + } + case 18: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ImportarTitulares_OnClick); + return; + } + case 19: + { + this.SeparadorMaisInformacoes = (Separator)target; + return; + } + case 20: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 21: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 22: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 23: + { + VidaView vidaView = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(vidaView.FormatarDocumento); + VidaView vidaView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(vidaView1.SomenteNumeros); + return; + } + case 24: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AplicarTitular_OnClick); + return; + } + case 25: + { + this.ContentControl = (System.Windows.Controls.ContentControl)target; + return; + } + case 26: + { + this.DataGridTitulares = (DataGrid)target; + this.DataGridTitulares.CellEditEnding += new EventHandler(this.DataGridTitulares_OnCellEditEnding); + return; + } + } + this._contentLoaded = true; + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 27: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 28: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 29: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 30: + { + VidaView vidaView = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(vidaView.FormatarDocumento); + VidaView vidaView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(vidaView1.SomenteNumeros); + return; + } + case 31: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBoxSelectionChanged); + return; + } + case 32: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, VidaView.AutoCompleteBox_Populating)); + return; + } + case 33: + { + EventSetter eventSetter = new EventSetter() + { + Event = FrameworkElement.LoadedEvent, + Handler = new RoutedEventHandler(this.Dependente_CellLoaded) + }; + ((System.Windows.Style)target).Setters.Add(eventSetter); + return; + } + default: + { + return; + } + } + } + + private async void TipoComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool dataContext; + ComboBox comboBox = (ComboBox)sender; + if (comboBox != null) + { + dataContext = comboBox.DataContext; + } + else + { + dataContext = false; + } + if (dataContext) + { + TipoTitular? nullable = ((TitularesVida)((ComboBox)sender).DataContext).get_Tipo(); + if (nullable.GetValueOrDefault() == 2 && !this._salvando && this.ViewModel.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Id() != (long)6) + { + ObservableCollection titulares = this.ViewModel.Titulares; + if (!titulares.Any((TitularesVida x) => { + TipoTitular? tipo = x.get_Tipo(); + if (tipo.GetValueOrDefault() == 1) + { + return true; + } + tipo = x.get_Tipo(); + return tipo.GetValueOrDefault() == 0 & tipo.HasValue; + })) + { + ((ComboBox)sender).SelectedIndex = -1; + nullable = null; + ((TitularesVida)((ComboBox)sender).DataContext).set_Tipo(nullable); + await this.ViewModel.ShowMessage("É NECESSÁRIO ADICIONAR PELO MENOS UM TITULAR DO TIPO SÓCIO OU FUNCIONÁRIO\nANTES DE ADICIONAR UM DEPENDENTE.", "OK", "", false); + return; + } + } + this.UpdateAutocompleteDependente((TitularesVida)((ComboBox)sender).DataContext, false); + } + } + + private void UpdateAutocompleteDependente(TitularesVida item, bool scroll = true) + { + if (scroll) + { + this.DataGridTitulares.ScrollIntoView(item, this.DataGridTitulares.Columns.First((DataGridColumn x) => (string)x.Header == "TITULAR DEPENDENTE")); + } + this.DataGridTitulares.UpdateLayout(); + DataGridRow dataGridRow = (DataGridRow)this.DataGridTitulares.ItemContainerGenerator.ContainerFromItem(item); + if (dataGridRow == null) + { + return; + } + ((DataGridCell)DataGridExtensions.GetVisualChild(dataGridRow).ItemContainerGenerator.ContainerFromIndex(12)).Visibility = (item.get_Tipo().GetValueOrDefault() == 2 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed); + if (scroll) + { + this.DataGridTitulares.ScrollIntoView(item, this.DataGridTitulares.Columns.First()); + } + this.DataGridTitulares.UpdateLayout(); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/PerfilEmpresaView.cs b/Codemerx/Gestor.Application/Views/Seguros/PerfilEmpresaView.cs new file mode 100644 index 0000000..3d80f8c --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/PerfilEmpresaView.cs @@ -0,0 +1,267 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Generic; +using Gestor.Common.Helpers; +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.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 Xceed.Wpf.Toolkit; + +namespace Gestor.Application.Views.Seguros +{ + public class PerfilEmpresaView : BaseUserControl, IComponentConnector + { + public PerfilEmpresaViewModel ViewModel; + + private Controle _controle; + + internal MenuItem CancelarApoliceButton; + + internal TextBox TextAtividade; + + internal CustomIsReadOnlyControl ComboSegurancaControl; + + internal CheckComboBox ComboSeguranca; + + internal CustomIsReadOnlyControl ComboIncendioControl; + + internal CheckComboBox ComboIncendio; + + internal CheckBox ExclusivoDeposito; + + internal CheckBox DivisaTerrenoBaldio; + + internal CheckBox PatrimonioHistorio; + + internal CheckBox PossuiTelhado; + + internal CheckBox CaixasEletronicos; + + internal CheckBox Isopainel; + + internal CheckBox ConstrucaoReforma; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public PerfilEmpresaView(Controle controle) + { + this._controle = controle; + base.Tag = "CADASTRO DE PERFIL"; + this.ViewModel = new PerfilEmpresaViewModel(controle); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + this.LoadData(); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + bool id; + this.ViewModel.CancelarAlteracao(); + PerfilEmpresa selectedPerfilEmpresa = this.ViewModel.SelectedPerfilEmpresa; + if (selectedPerfilEmpresa != null) + { + id = selectedPerfilEmpresa.get_Id() == (long)0; + } + else + { + id = false; + } + if (id || this.ViewModel.SelectedPerfilEmpresa == null) + { + this.ViewModel.EnableIncluirPerfil = true; + } + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EnableIncluirPerfil = false; + this.ViewModel.Incluir(); + } + + [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/perfilempresaview.xaml", UriKind.Relative)); + } + + private void LoadData() + { + this.ComboSeguranca.BindData(false, true, "", false); + this.ComboIncendio.BindData(false, true, "", false); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Loading(true); + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ViewModel.Loading(false); + if (keyValuePairs != null) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + this.CancelarApoliceButton = (MenuItem)target; + this.CancelarApoliceButton.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + PerfilEmpresaView perfilEmpresaView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilEmpresaView.SomenteNumeros); + return; + } + case 7: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.VerificaOnSelected); + return; + } + case 8: + { + this.TextAtividade = (TextBox)target; + return; + } + case 9: + { + this.ComboSegurancaControl = (CustomIsReadOnlyControl)target; + return; + } + case 10: + { + this.ComboSeguranca = (CheckComboBox)target; + return; + } + case 11: + { + this.ComboIncendioControl = (CustomIsReadOnlyControl)target; + return; + } + case 12: + { + this.ComboIncendio = (CheckComboBox)target; + return; + } + case 13: + { + this.ExclusivoDeposito = (CheckBox)target; + return; + } + case 14: + { + this.DivisaTerrenoBaldio = (CheckBox)target; + return; + } + case 15: + { + this.PatrimonioHistorio = (CheckBox)target; + return; + } + case 16: + { + this.PossuiTelhado = (CheckBox)target; + return; + } + case 17: + { + this.CaixasEletronicos = (CheckBox)target; + return; + } + case 18: + { + this.Isopainel = (CheckBox)target; + return; + } + case 19: + { + this.ConstrucaoReforma = (CheckBox)target; + return; + } + } + this._contentLoaded = true; + } + + private void VerificaOnSelected(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox.SelectedItem == null) + { + return; + } + if (EnumHelper.GetDescription(comboBox.SelectedItem) == EnumHelper.GetDescription(0)) + { + this.ViewModel.AtivaCampos = System.Windows.Visibility.Visible; + return; + } + if (this.ViewModel.AtivaCampos == System.Windows.Visibility.Visible) + { + this.TextAtividade.Text = ""; + this.ViewModel.AtivaCampos = System.Windows.Visibility.Collapsed; + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/PerfilView.cs b/Codemerx/Gestor.Application/Views/Seguros/PerfilView.cs new file mode 100644 index 0000000..2a23628 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/PerfilView.cs @@ -0,0 +1,320 @@ +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Generic; +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; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; +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; + +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; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public PerfilView(Controle controle) + { + this._controle = controle; + base.Tag = "CADASTRO DE PERFIL"; + this.ViewModel = new PerfilViewModel(controle); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Alterar(true); + this.ValidarTela(); + } + + private void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CancelarAlteracao(); + } + + private void ContentLoad() + { + this.NascimentoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(Funcoes.DatePicker_OnLostKeyboardFocus); + this.NascimentoBox.PreviewKeyDown += new KeyEventHandler(Funcoes.DatePicker_PreviewKeyDown); + } + + private void CpfBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + textBox.Text = ValidationHelper.FormatDocument(textBox.Text); + } + + private async void Excluir_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Excluir(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + this.ValidarTela(); + } + + [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/perfilview.xaml", UriKind.Relative)); + } + + private void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e) + { + TextBox textBox = (TextBox)sender; + if (string.IsNullOrWhiteSpace(textBox.Text)) + { + return; + } + string str = ValidationHelper.FormatPostCode(textBox.Text); + if (!ValidationHelper.ValidatePostCode(str)) + { + return; + } + textBox.Text = str; + } + + private void RelacaoComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + string documento; + TimeSpan? nullable; + if (((ComboBox)sender).SelectedIndex == 0) + { + Cliente cliente = this._controle.get_Cliente(); + if (cliente != null) + { + documento = cliente.get_Documento(); + } + else + { + documento = null; + } + string str = ValidationHelper.FormatDocument(ValidationHelper.Clear(documento)); + bool flag = Regex.IsMatch(str, "\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}"); + Perfil perfil = (Perfil)this.ViewModel.SelectedPerfil.Clone(); + perfil.set_Cpf((flag ? str : "")); + perfil.set_Nome(this._controle.get_Cliente().get_Nome()); + perfil.set_Nascimento(this._controle.get_Cliente().get_Nascimento()); + perfil.set_Sexo(this._controle.get_Cliente().get_Sexo()); + perfil.set_EstadoCivil(this._controle.get_Cliente().get_EstadoCivil()); + perfil.set_Habilitacao(this._controle.get_Cliente().get_Habilitacao()); + DateTime? primeiraHabilitacao = this._controle.get_Cliente().get_PrimeiraHabilitacao(); + if (primeiraHabilitacao.HasValue) + { + DateTime networkTime = Funcoes.GetNetworkTime(); + primeiraHabilitacao = this._controle.get_Cliente().get_PrimeiraHabilitacao(); + if (primeiraHabilitacao.HasValue) + { + nullable = new TimeSpan?(networkTime - primeiraHabilitacao.GetValueOrDefault()); + } + else + { + nullable = null; + } + TimeSpan? nullable1 = nullable; + if (nullable1.Value.Days > 3650) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(10)); + } + else if (nullable1.Value.Days > 3285) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(9)); + } + else if (nullable1.Value.Days > 2920) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(8)); + } + else if (nullable1.Value.Days > 2555) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(7)); + } + else if (nullable1.Value.Days > 2190) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(6)); + } + else if (nullable1.Value.Days > 1825) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(5)); + } + else if (nullable1.Value.Days > 1460) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(4)); + } + else if (nullable1.Value.Days > 1095) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(3)); + } + else if (nullable1.Value.Days > 730) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(2)); + } + else if (nullable1.Value.Days <= 365) + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(0)); + } + else + { + perfil.set_TempoHabilitacao(new TempoHabilitacao?(1)); + } + } + this.ViewModel.SelectedPerfil = perfil; + } + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + 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, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 2: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 4: + { + this.CancelarApoliceButton = (MenuItem)target; + this.CancelarApoliceButton.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 6: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.RelacaoComboBox_OnSelectionChanged); + return; + } + case 7: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.CpfBox_OnLostFocus); + PerfilView perfilView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView.SomenteNumeros); + return; + } + case 8: + { + this.NascimentoBox = (DatePicker)target; + this.NascimentoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.NascimentoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 9: + { + PerfilView perfilView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView1.SomenteNumeros); + return; + } + case 10: + { + PerfilView perfilView2 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView2.SomenteNumeros); + return; + } + case 11: + { + PerfilView perfilView3 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView3.SomenteNumeros); + return; + } + case 12: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + PerfilView perfilView4 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView4.SomenteNumeros); + return; + } + case 13: + { + ((TextBox)target).LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus); + PerfilView perfilView5 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(perfilView5.SomenteNumeros); + return; + } + } + this._contentLoaded = true; + } + + private void ValidarTela() + { + if (this.ViewModel.SelectedPerfil == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedPerfil.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Views/Seguros/SinistroView.cs b/Codemerx/Gestor.Application/Views/Seguros/SinistroView.cs new file mode 100644 index 0000000..6bd6e00 --- /dev/null +++ b/Codemerx/Gestor.Application/Views/Seguros/SinistroView.cs @@ -0,0 +1,1003 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.Collections.ObjectModel; +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; + +namespace Gestor.Application.Views.Seguros +{ + public class SinistroView : BaseUserControl, IComponentConnector + { + public SinistroViewModel ViewModel; + + internal DataGrid ControleGrid; + + internal MenuItem SalvarSinistroButton; + + internal MenuItem CancelarApoliceButton; + + internal CustomIsReadOnlyControl TipoSinistroBox; + + internal ComboBox ParceiroMecanica; + + internal ComboBox ParceiroFunilaria; + + internal RadioButton AnotacoesButton; + + internal RadioButton AnotacoesInternasButton; + + internal CustomItemControl AnotacoesHoster; + + internal WebEditor Anotacoes; + + internal CustomItemControl ObservacoesHoster; + + internal WebEditor Observacoes; + + internal CustomItemControl AnotacoesInternasHoster; + + internal WebEditor AnotacoesInternas; + + internal CustomItemControl ObservacoesInternasHoster; + + internal WebEditor ObservacoesInternas; + + 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 SinistroView(Item item = null, bool attached = true) + { + item = item ?? ConsultaViewModel.ItemSelecionado; + base.Tag = "CADASTRO DE SINISTRO"; + this.ViewModel = new SinistroViewModel(item, attached); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + + private void AbrirInfo_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirInfo(); + } + + private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedSinistro == null) + { + return; + } + this.ViewModel.AbrirLogEmail(7, this.ViewModel.SelectedSinistro.get_Id()); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + bool? nullable; + bool valueOrDefault; + bool flag; + if (this.ViewModel.SelectedSinistro == null) + { + return; + } + this.ViewModel.Alterar(true); + CustomIsReadOnlyControl tipoSinistroBox = this.TipoSinistroBox; + ControleSinistro selectedControle = this.ViewModel.SelectedControle; + if (selectedControle != null) + { + List sinistros = selectedControle.get_Sinistros(); + if (sinistros != null) + { + nullable = new bool?(sinistros.Any((Sinistro x) => { + TipoSinistro? tipoSinistro = x.get_TipoSinistro(); + return tipoSinistro.GetValueOrDefault() == 0 & tipoSinistro.HasValue; + })); + } + else + { + nullable = null; + } + bool? nullable1 = nullable; + bool flag1 = false; + valueOrDefault = nullable1.GetValueOrDefault() == flag1 & nullable1.HasValue; + } + else + { + valueOrDefault = false; + } + if (valueOrDefault) + { + flag = true; + } + else + { + Sinistro selectedSinistro = this.ViewModel.SelectedSinistro; + if (selectedSinistro != null) + { + TipoSinistro? nullable2 = selectedSinistro.get_TipoSinistro(); + TipoSinistro tipoSinistro1 = 0; + flag = nullable2.GetValueOrDefault() == tipoSinistro1 & nullable2.HasValue; + } + else + { + flag = false; + } + } + tipoSinistroBox.IsEnabled = flag; + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, false); + Sinistro sinistro = this.ViewModel.SelectedSinistro; + if (sinistro == null) + { + return; + } + sinistro.Initialize(); + } + + private void Anotacoes_OnChecked(object sender, RoutedEventArgs e) + { + this.ToggleAnotacoes(true, false); + } + + private void AnotacoesInternas_OnChecked(object sender, RoutedEventArgs e) + { + this.ToggleAnotacoes(false, false); + } + + private async void ArquivoDigital_OnClick(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 5).get_Consultar()) + { + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(this.ViewModel.SelectedSinistro.get_Id()); + filtroArquivoDigital.set_IdApolice(this.ViewModel.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Id()); + filtroArquivoDigital.set_Tipo(5); + filtroArquivoDigital.set_Parente(this.ViewModel.SelectedSinistro); + 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 ", ValidationHelper.GetDescription((TipoArquivoDigital)5), "."), "OK", "", false); + } + } + + private void AutoCompleteBoxItem_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarItem(""); + } + + private void AutoCompleteBoxItem_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.ItemFiltrar(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 AutoCompleteBoxSinistro_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarSinistro(""); + } + + private void AutoCompleteBoxSinistro_Populating(object sender, PopulatingEventArgs e) + { + e.set_Cancel(true); + this.ViewModel.SinistroFiltrar(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.ViewModel.CancelarAlteracao(); + this.Anotacoes.Initialize(null); + this.AnotacoesInternas.Initialize(null); + this.ViewModel.EnableFields = false; + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, false); + } + + private void ContentLoad() + { + this.ControleGrid.SelectionChanged += new SelectionChangedEventHandler(this.SinistroGrid_OnSelectionChanged); + this.AnotacoesButton.IsChecked = new bool?(this.ViewModel.IsAnotacoes); + this.AnotacoesInternasButton.IsChecked = new bool?(!this.ViewModel.IsAnotacoes); + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, false); + this.AnotacoesButton.Checked += new RoutedEventHandler(this.Anotacoes_OnChecked); + this.AnotacoesInternasButton.Checked += new RoutedEventHandler(this.AnotacoesInternas_OnChecked); + } + + private void EnviarHistorico_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EnviarLogEmail(); + } + + private void Excluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Excluir(); + } + + private void FunilariaButton_OnClick(object sender, RoutedEventArgs e) + { + Parceiro parceiroFunilaria; + long num; + object obj; + object obj1; + if (this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Id() == 0) + { + parceiroFunilaria = null; + } + else + { + parceiroFunilaria = this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroFunilaria(); + } + CadastroParceiroView cadastroParceiroView = new CadastroParceiroView(parceiroFunilaria); + (new HosterWindow(cadastroParceiroView, "CADASTRO DE PARCEIROS", new double?((double)1000), new double?((double)600), false)).ShowDialog(); + Parceiro selectedItem = (Parceiro)this.ParceiroMecanica.SelectedItem; + if (selectedItem != null) + { + num = selectedItem.get_Id(); + } + else + { + num = (long)0; + } + long num1 = num; + this.ViewModel.CarregarParceiros(); + ComboBox parceiroMecanica = this.ParceiroMecanica; + if (num1 > (long)0) + { + ObservableCollection parceiros = this.ViewModel.Parceiros; + if (parceiros != null) + { + obj = parceiros.FirstOrDefault((Parceiro x) => x.get_Id() == num1); + } + else + { + obj = null; + } + } + else + { + obj = null; + } + parceiroMecanica.SelectedItem = obj; + ComboBox comboBox = this.ParceiroFunilaria; + ObservableCollection observableCollection = this.ViewModel.Parceiros; + if (observableCollection != null) + { + obj1 = observableCollection.FirstOrDefault((Parceiro x) => { + long? nullable; + long id = x.get_Id(); + Parceiro selectedParceiro = cadastroParceiroView.ViewModel.SelectedParceiro; + if (selectedParceiro != null) + { + nullable = new long?(selectedParceiro.get_Id()); + } + else + { + nullable = null; + } + long? nullable1 = nullable; + return id == nullable1.GetValueOrDefault() & nullable1.HasValue; + }); + } + else + { + obj1 = null; + } + comboBox.SelectedItem = obj1; + } + + private void ImprimirHistorico_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedSinistro.get_Id() == 0) + { + return; + } + this.ViewModel.ImprimirHistorico(); + } + + private async void Incluir_OnClick(object sender, RoutedEventArgs e) + { + if (this.ViewModel.SelectedItem != null) + { + await this.ViewModel.IncluirSinistro(); + List> keyValuePairs = this.ViewModel.SelectedSinistro.Validate(); + this.ValidateFields(keyValuePairs, true); + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, false); + } + else + { + await this.ViewModel.ShowMessage("NECESSÁRIO INCLUIR O ITEM ANTES DE INCLUIR UM SINISTRO.", "OK", "", false); + } + } + + private void IncluirEnvolvido_OnClick(object sender, RoutedEventArgs e) + { + bool? nullable; + bool valueOrDefault; + bool flag; + List> keyValuePairs; + this.ViewModel.IncluirEnvolvido(); + CustomIsReadOnlyControl tipoSinistroBox = this.TipoSinistroBox; + ControleSinistro selectedControle = this.ViewModel.SelectedControle; + if (selectedControle != null) + { + List sinistros = selectedControle.get_Sinistros(); + if (sinistros != null) + { + nullable = new bool?(sinistros.Any((Sinistro x) => { + TipoSinistro? tipoSinistro = x.get_TipoSinistro(); + return tipoSinistro.GetValueOrDefault() == 0 & tipoSinistro.HasValue; + })); + } + else + { + nullable = null; + } + bool? nullable1 = nullable; + bool flag1 = false; + valueOrDefault = nullable1.GetValueOrDefault() == flag1 & nullable1.HasValue; + } + else + { + valueOrDefault = false; + } + if (valueOrDefault) + { + flag = true; + } + else + { + Sinistro selectedSinistro = this.ViewModel.SelectedSinistro; + if (selectedSinistro != null) + { + TipoSinistro? nullable2 = selectedSinistro.get_TipoSinistro(); + TipoSinistro tipoSinistro1 = 0; + flag = nullable2.GetValueOrDefault() == tipoSinistro1 & nullable2.HasValue; + } + else + { + flag = false; + } + } + tipoSinistroBox.IsEnabled = flag; + Sinistro sinistro = this.ViewModel.SelectedSinistro; + if (sinistro != null) + { + keyValuePairs = sinistro.Validate(); + } + else + { + keyValuePairs = null; + } + this.ValidateFields(keyValuePairs, true); + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, true); + } + + [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/sinistroview.xaml", UriKind.Relative)); + } + + private void ItemGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaItem((Item)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private void Log_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(7, this.ViewModel.SelectedSinistro.get_Id()); + } + + private void MecanicaButton_OnClick(object sender, RoutedEventArgs e) + { + Parceiro parceiroMecanica; + long num; + object obj; + object obj1; + if (this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroMecanica() == null || this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroMecanica().get_Id() == 0) + { + parceiroMecanica = null; + } + else + { + parceiroMecanica = this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroMecanica(); + } + CadastroParceiroView cadastroParceiroView = new CadastroParceiroView(parceiroMecanica); + (new HosterWindow(cadastroParceiroView, "CADASTRO DE PARCEIROS", new double?((double)1000), new double?((double)600), false)).ShowDialog(); + Parceiro selectedItem = (Parceiro)this.ParceiroFunilaria.SelectedItem; + if (selectedItem != null) + { + num = selectedItem.get_Id(); + } + else + { + num = (long)0; + } + long num1 = num; + this.ViewModel.CarregarParceiros(); + ComboBox parceiroFunilaria = this.ParceiroFunilaria; + if (num1 > (long)0) + { + ObservableCollection parceiros = this.ViewModel.Parceiros; + if (parceiros != null) + { + obj = parceiros.FirstOrDefault((Parceiro x) => x.get_Id() == num1); + } + else + { + obj = null; + } + } + else + { + obj = null; + } + parceiroFunilaria.SelectedItem = obj; + ComboBox comboBox = this.ParceiroMecanica; + ObservableCollection observableCollection = this.ViewModel.Parceiros; + if (observableCollection != null) + { + obj1 = observableCollection.FirstOrDefault((Parceiro x) => { + long? nullable; + long id = x.get_Id(); + Parceiro selectedParceiro = cadastroParceiroView.ViewModel.SelectedParceiro; + if (selectedParceiro != null) + { + nullable = new long?(selectedParceiro.get_Id()); + } + else + { + nullable = null; + } + long? nullable1 = nullable; + return id == nullable1.GetValueOrDefault() & nullable1.HasValue; + }); + } + else + { + obj1 = null; + } + comboBox.SelectedItem = obj1; + } + + private void ParceiroBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + SinistroViewModel viewModel; + ComboBox comboBox = (ComboBox)sender; + if (comboBox == null || comboBox.SelectedItem == null) + { + return; + } + Parceiro selectedItem = (Parceiro)comboBox.SelectedItem; + if (comboBox.Name != "ParceiroMecanica") + { + if (this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroFunilaria() == null) + { + this.ViewModel.SelectedSinistro.get_SinistroAuto().set_ParceiroFunilaria(selectedItem); + } + this.ParceiroFunilaria.Text = selectedItem.get_Nome(); + this.ViewModel.TelefonesFunileiro = ""; + bool flag = true; + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd1()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone1())) + { + flag = false; + viewModel = this.ViewModel; + viewModel.TelefonesFunileiro = string.Concat(new string[] { viewModel.TelefonesFunileiro, "TELEFONE 1: (", selectedItem.get_Ddd1(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone1()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd2()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone2())) + { + flag = false; + viewModel = this.ViewModel; + viewModel.TelefonesFunileiro = string.Concat(new string[] { viewModel.TelefonesFunileiro, "\nTELEFONE 2: (", selectedItem.get_Ddd2(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone2()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd3()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone3())) + { + flag = false; + viewModel = this.ViewModel; + viewModel.TelefonesFunileiro = string.Concat(new string[] { viewModel.TelefonesFunileiro, "\nTELEFONE 3: (", selectedItem.get_Ddd3(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone3()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Endereco()) || !string.IsNullOrWhiteSpace(selectedItem.get_Cidade()) || !string.IsNullOrWhiteSpace(selectedItem.get_Uf()) || !string.IsNullOrWhiteSpace(selectedItem.get_Bairro()) || !string.IsNullOrWhiteSpace(selectedItem.get_Cep()) || !string.IsNullOrWhiteSpace(selectedItem.get_Numero()) || !string.IsNullOrWhiteSpace(selectedItem.get_Complemento())) + { + flag = false; + viewModel = this.ViewModel; + SinistroViewModel sinistroViewModel = viewModel; + string[] telefonesFunileiro = new string[] { viewModel.TelefonesFunileiro, "\nENDEREÇO: ", selectedItem.get_Endereco(), ", ", selectedItem.get_Numero(), ", ", null, null, null, null, null, null, null, null, null }; + telefonesFunileiro[6] = (string.IsNullOrWhiteSpace(selectedItem.get_Complemento()) ? "-" : selectedItem.get_Complemento() ?? ""); + telefonesFunileiro[7] = ", "; + telefonesFunileiro[8] = selectedItem.get_Bairro(); + telefonesFunileiro[9] = ", "; + telefonesFunileiro[10] = selectedItem.get_Cidade(); + telefonesFunileiro[11] = "/"; + telefonesFunileiro[12] = selectedItem.get_Uf(); + telefonesFunileiro[13] = " - "; + telefonesFunileiro[14] = selectedItem.get_Cep(); + sinistroViewModel.TelefonesFunileiro = string.Concat(telefonesFunileiro); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Email())) + { + flag = false; + SinistroViewModel viewModel1 = this.ViewModel; + viewModel1.TelefonesFunileiro = string.Concat(viewModel1.TelefonesFunileiro, "\nEMAIL: ", selectedItem.get_Email()); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Cgccpf())) + { + flag = false; + SinistroViewModel sinistroViewModel1 = this.ViewModel; + sinistroViewModel1.TelefonesFunileiro = string.Concat(sinistroViewModel1.TelefonesFunileiro, "\nDOCUMENTO: ", selectedItem.get_Cgccpf()); + } + if (flag) + { + this.ViewModel.TelefonesFunileiro = "PARCEIRO SEM MAIS INFORMAÇÕES"; + } + } + else + { + if (this.ViewModel.SelectedSinistro.get_SinistroAuto().get_ParceiroMecanica() == null) + { + this.ViewModel.SelectedSinistro.get_SinistroAuto().set_ParceiroMecanica(selectedItem); + } + this.ParceiroMecanica.Text = selectedItem.get_Nome(); + this.ViewModel.TelefonesMecanica = ""; + bool flag1 = true; + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd1()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone1())) + { + flag1 = false; + viewModel = this.ViewModel; + viewModel.TelefonesMecanica = string.Concat(new string[] { viewModel.TelefonesMecanica, "TELEFONE 1: (", selectedItem.get_Ddd1(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone1()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd2()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone2())) + { + flag1 = false; + viewModel = this.ViewModel; + viewModel.TelefonesMecanica = string.Concat(new string[] { viewModel.TelefonesMecanica, "\nTELEFONE 2: (", selectedItem.get_Ddd2(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone2()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Ddd3()) || !string.IsNullOrWhiteSpace(selectedItem.get_Telefone3())) + { + flag1 = false; + viewModel = this.ViewModel; + viewModel.TelefonesMecanica = string.Concat(new string[] { viewModel.TelefonesMecanica, "\nTELEFONE 3: (", selectedItem.get_Ddd3(), ") ", ValidationHelper.FormatarTelefone(selectedItem.get_Telefone3()) }); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Endereco()) || !string.IsNullOrWhiteSpace(selectedItem.get_Cidade()) || !string.IsNullOrWhiteSpace(selectedItem.get_Uf()) || !string.IsNullOrWhiteSpace(selectedItem.get_Bairro()) || !string.IsNullOrWhiteSpace(selectedItem.get_Cep()) || !string.IsNullOrWhiteSpace(selectedItem.get_Numero()) || !string.IsNullOrWhiteSpace(selectedItem.get_Complemento())) + { + flag1 = false; + viewModel = this.ViewModel; + SinistroViewModel sinistroViewModel2 = viewModel; + string[] telefonesMecanica = new string[] { viewModel.TelefonesMecanica, "\nENDEREÇO: ", selectedItem.get_Endereco(), ", ", selectedItem.get_Numero(), ", ", null, null, null, null, null, null, null, null, null }; + telefonesMecanica[6] = (string.IsNullOrWhiteSpace(selectedItem.get_Complemento()) ? "-" : selectedItem.get_Complemento() ?? ""); + telefonesMecanica[7] = ", "; + telefonesMecanica[8] = selectedItem.get_Bairro(); + telefonesMecanica[9] = ", "; + telefonesMecanica[10] = selectedItem.get_Cidade(); + telefonesMecanica[11] = "/"; + telefonesMecanica[12] = selectedItem.get_Uf(); + telefonesMecanica[13] = " - "; + telefonesMecanica[14] = selectedItem.get_Cep(); + sinistroViewModel2.TelefonesMecanica = string.Concat(telefonesMecanica); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Email())) + { + flag1 = false; + SinistroViewModel viewModel2 = this.ViewModel; + viewModel2.TelefonesMecanica = string.Concat(viewModel2.TelefonesMecanica, "\nEMAIL: ", selectedItem.get_Email()); + } + if (!string.IsNullOrWhiteSpace(selectedItem.get_Cgccpf())) + { + flag1 = false; + SinistroViewModel viewModel3 = this.ViewModel; + viewModel3.TelefonesMecanica = string.Concat(viewModel3.TelefonesMecanica, "\nDOCUMENTO: ", selectedItem.get_Cgccpf()); + } + if (flag1) + { + this.ViewModel.TelefonesMecanica = "PARCEIRO SEM MAIS INFORMAÇÕES"; + return; + } + } + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Loading(true); + this.ViewModel.Anotacoes = this.Anotacoes.GetHtml(); + this.ViewModel.AnotacoesInternas = this.AnotacoesInternas.GetHtml(); + if (this.ViewModel.EditarObservacao) + { + this.ViewModel.SelectedSinistro.set_ObservacaoInterna(this.ObservacoesInternas.GetHtml()); + this.ViewModel.SelectedSinistro.set_Observacao(this.Observacoes.GetHtml()); + } + 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, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.Anotacoes.Initialize(null); + this.AnotacoesInternas.Initialize(null); + this.ToggleAnotacoes(this.ViewModel.IsAnotacoes, false); + } + } + + private void SinistroGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + DataGrid dataGrid = (DataGrid)sender; + if (dataGrid != null && dataGrid.SelectedIndex < 0) + { + return; + } + this.ViewModel.SelecionaControle((ControleSinistro)((dataGrid != null ? dataGrid.Items[dataGrid.SelectedIndex] : null))); + } + + private void SituacaoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox == null || comboBox.SelectedItem == null) + { + return; + } + if ((StatusSinistro)comboBox.SelectedItem == 1) + { + this.ViewModel.SelectedSinistro.set_DataLiquidacao(null); + this.ViewModel.LiquidacaoVisibility = System.Windows.Visibility.Collapsed; + } + else + { + this.ViewModel.LiquidacaoVisibility = System.Windows.Visibility.Visible; + } + this.Validar(); + } + + 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: + { + ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, SinistroView.AutoCompleteBoxSinistro_Populating)); + ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBoxSinistro_OnTextChanged)); + return; + } + case 2: + { + this.ControleGrid = (DataGrid)target; + return; + } + case 3: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 4: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 5: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirEnvolvido_OnClick); + return; + } + case 6: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 7: + { + this.SalvarSinistroButton = (MenuItem)target; + this.SalvarSinistroButton.Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 8: + { + this.CancelarApoliceButton = (MenuItem)target; + this.CancelarApoliceButton.Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Tarefas_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ArquivoDigital_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.ImprimirHistorico_OnClick); + return; + } + case 13: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.EnviarHistorico_OnClick); + return; + } + case 14: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Log_OnClick); + return; + } + case 15: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick); + return; + } + case 16: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.AbrirInfo_OnClick); + return; + } + case 17: + { + this.TipoSinistroBox = (CustomIsReadOnlyControl)target; + return; + } + case 18: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 19: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 20: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 21: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.SituacaoBox_OnSelectionChanged); + return; + } + case 22: + { + ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + ((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown); + ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 23: + { + SinistroView sinistroView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(sinistroView.SomenteNumeros); + return; + } + case 24: + { + SinistroView sinistroView1 = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(sinistroView1.SomenteNumeros); + SinistroView sinistroView2 = this; + ((TextBox)target).LostFocus += new RoutedEventHandler(sinistroView2.FormatarTelefone); + return; + } + case 25: + { + this.ParceiroMecanica = (ComboBox)target; + this.ParceiroMecanica.SelectionChanged += new SelectionChangedEventHandler(this.ParceiroBox_OnSelectionChanged); + return; + } + case 26: + { + ((Button)target).Click += new RoutedEventHandler(this.MecanicaButton_OnClick); + return; + } + case 27: + { + this.ParceiroFunilaria = (ComboBox)target; + this.ParceiroFunilaria.SelectionChanged += new SelectionChangedEventHandler(this.ParceiroBox_OnSelectionChanged); + return; + } + case 28: + { + ((Button)target).Click += new RoutedEventHandler(this.FunilariaButton_OnClick); + return; + } + case 29: + { + this.AnotacoesButton = (RadioButton)target; + return; + } + case 30: + { + this.AnotacoesInternasButton = (RadioButton)target; + return; + } + case 31: + { + this.AnotacoesHoster = (CustomItemControl)target; + return; + } + case 32: + { + this.Anotacoes = (WebEditor)target; + return; + } + case 33: + { + this.ObservacoesHoster = (CustomItemControl)target; + return; + } + case 34: + { + this.Observacoes = (WebEditor)target; + return; + } + case 35: + { + this.AnotacoesInternasHoster = (CustomItemControl)target; + return; + } + case 36: + { + this.AnotacoesInternas = (WebEditor)target; + return; + } + case 37: + { + this.ObservacoesInternasHoster = (CustomItemControl)target; + return; + } + case 38: + { + this.ObservacoesInternas = (WebEditor)target; + return; + } + case 39: + { + this.Snackbar = (MaterialDesignThemes.Wpf.Snackbar)target; + return; + } + case 40: + { + ((SnackbarMessage)target).add_ActionClick(new RoutedEventHandler(this.SnackbarMessage_ActionClick)); + return; + } + } + this._contentLoaded = true; + } + + private async void Tarefas_OnClick(object sender, RoutedEventArgs e) + { + Cliente cliente = await this.ViewModel.BuscarClienteSinistro(); + Tarefa tarefa = new Tarefa(); + tarefa.set_IdCliente(this.ViewModel.SelectedSinistro.get_Id()); + tarefa.set_Cliente(cliente.get_Nome()); + tarefa.set_Entidade(4); + tarefa.set_IdEntidade(this.ViewModel.SelectedSinistro.get_Id()); + tarefa.set_Titulo(string.Concat("SINISTRO ", this.ViewModel.SelectedSinistro.get_Numero(), " ITEM ", this.ViewModel.SelectedSinistro.get_ItemSinistrado())); + this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa, true), 0, false); + } + + private void ToggleAnotacoes(bool anotacoes, bool inclusao = false) + { + if (anotacoes) + { + this.ViewModel.IsAnotacoes = true; + if (this.ViewModel.EnableFields | inclusao) + { + this.AnotacoesHoster.Visibility = System.Windows.Visibility.Visible; + this.AnotacoesInternasHoster.Visibility = System.Windows.Visibility.Collapsed; + return; + } + this.AnotacoesHoster.Visibility = System.Windows.Visibility.Collapsed; + this.AnotacoesInternasHoster.Visibility = System.Windows.Visibility.Collapsed; + return; + } + this.ViewModel.IsAnotacoes = false; + if (this.ViewModel.EnableFields | inclusao) + { + this.AnotacoesHoster.Visibility = System.Windows.Visibility.Collapsed; + this.AnotacoesInternasHoster.Visibility = System.Windows.Visibility.Visible; + return; + } + this.AnotacoesHoster.Visibility = System.Windows.Visibility.Collapsed; + this.AnotacoesInternasHoster.Visibility = System.Windows.Visibility.Collapsed; + } + + private void Validar() + { + if (this.ViewModel.SelectedSinistro == null) + { + return; + } + List> keyValuePairs = this.ViewModel.SelectedSinistro.Validate(); + this.ValidateFields(keyValuePairs, false); + } + } +} \ No newline at end of file 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> 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 -- cgit v1.2.3