diff options
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs | 2773 |
1 files changed, 2773 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs new file mode 100644 index 0000000..c04d349 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs @@ -0,0 +1,2773 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Gestor.Application.Componentes; +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.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Seguros; +using NReco.PdfGenerator; + +namespace Gestor.Application.ViewModels.Drawer; + +public class ExtratosViewModel : BaseSegurosViewModel +{ + private readonly ClienteServico _clienteServico = new ClienteServico(); + + private List<Documento> _documentos; + + private List<Prospeccao> _prospeccoes; + + private List<Cliente> _clientes; + + private bool _tipoExtratoEnabled = true; + + private bool _extratoResumido; + + private bool _segurosVigentes; + + private Visibility _clientePorPaginaVisibility; + + private bool _clientePorPagina; + + private bool _extratoPorPagina; + + private bool _clientePorPaginaEnabled = true; + + private bool _obsCliente; + + private bool _comissaoDocumento; + + private bool _premioParcela; + + private bool _obsApolice; + + private bool _beneficiariosItens; + + private bool _selecionarItens; + + private bool _endossos; + + private bool _somenteEndosso; + + private Visibility _selecionarItensVisibility; + + private Visibility _endossoVisibility; + + private Visibility _obsDocVisibility; + + private Visibility _segurosVigentesVisibility; + + private bool _obsItem; + + private bool _separarPagina; + + private bool _perfilCondutor; + + private bool _obsClienteEnabled = true; + + private bool _comissaoDocumentoEnabled; + + private bool _obsApoliceEnabled; + + private bool _beneficiariosItensEnabled; + + private bool _obsItemEnabled; + + private bool _separarPaginaEnabled; + + private bool _coberturasEnabled; + + private bool _coberturas; + + private bool _perfilCondutorEnabled; + + private bool _endossoEnabled; + + private bool _esconderResumido; + + private bool _clienteVisibility; + + private bool _documentoVisibility; + + private bool _itemVisibility; + + private bool _perfilVisibility; + + private TipoExtrato _selectedTipoExtrato; + + private bool _carregando; + + private List<Item> _itensSelecionados; + + internal Relatorio? TipoDeRelatorio; + + public List<Documento> Documentos + { + get + { + return _documentos; + } + set + { + _documentos = value; + OnPropertyChanged("Documentos"); + } + } + + public List<Prospeccao> Prospeccoes + { + get + { + return _prospeccoes; + } + set + { + _prospeccoes = value; + OnPropertyChanged("Prospeccoes"); + } + } + + public List<Cliente> Clientes + { + get + { + return _clientes; + } + set + { + _clientes = value; + OnPropertyChanged("Clientes"); + } + } + + public bool TipoExtratoEnabled + { + get + { + return _tipoExtratoEnabled; + } + set + { + _tipoExtratoEnabled = value; + OnPropertyChanged("TipoExtratoEnabled"); + } + } + + public bool ExtratoResumido + { + get + { + return _extratoResumido; + } + set + { + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + _extratoResumido = value; + if (value) + { + ClienteVisibility = false; + DocumentoVisibility = false; + ItemVisibility = CoberturasEnabled; + SelecionarItensVisibility = (Visibility)2; + BeneficiariosItensEnabled = false; + ObsItemEnabled = false; + SepararPaginaEnabled = false; + } + else + { + ClienteVisibility = true; + DocumentoVisibility = true; + ItemVisibility = true; + AjustaTipoSelecionado(SelectedTipoExtrato); + } + OnPropertyChanged("ExtratoResumido"); + } + } + + public bool SegurosVigentes + { + get + { + return _segurosVigentes; + } + set + { + _segurosVigentes = value; + OnPropertyChanged("SegurosVigentes"); + } + } + + public Visibility ClientePorPaginaVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _clientePorPaginaVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _clientePorPaginaVisibility = value; + OnPropertyChanged("ClientePorPaginaVisibility"); + } + } + + public bool ClientePorPagina + { + get + { + return _clientePorPagina; + } + set + { + _clientePorPagina = value; + OnPropertyChanged("ClientePorPagina"); + } + } + + public bool ExtratoPorPagina + { + get + { + return _extratoPorPagina; + } + set + { + _extratoPorPagina = value; + OnPropertyChanged("ExtratoPorPagina"); + } + } + + public bool ClientePorPaginaEnabled + { + get + { + return _clientePorPaginaEnabled; + } + set + { + _clientePorPaginaEnabled = value; + OnPropertyChanged("ClientePorPaginaEnabled"); + } + } + + public bool ObsCliente + { + get + { + return _obsCliente; + } + set + { + _obsCliente = value; + OnPropertyChanged("ObsCliente"); + } + } + + public bool ComissaoDocumento + { + get + { + return _comissaoDocumento; + } + set + { + _comissaoDocumento = value; + OnPropertyChanged("ComissaoDocumento"); + } + } + + public bool PremioParcela + { + get + { + return _premioParcela; + } + set + { + _premioParcela = value; + OnPropertyChanged("PremioParcela"); + } + } + + public bool ObsApolice + { + get + { + return _obsApolice; + } + set + { + _obsApolice = value; + OnPropertyChanged("ObsApolice"); + } + } + + public bool BeneficiariosItens + { + get + { + return _beneficiariosItens; + } + set + { + _beneficiariosItens = value; + OnPropertyChanged("BeneficiariosItens"); + } + } + + public bool SelecionarItens + { + get + { + return _selecionarItens; + } + set + { + _selecionarItens = value; + if (!value) + { + _itensSelecionados = new List<Item>(); + } + OnPropertyChanged("SelecionarItens"); + } + } + + public bool Endossos + { + get + { + return _endossos; + } + set + { + _endossos = value; + if (SomenteEndossos != !value) + { + SomenteEndossos = !value; + } + OnPropertyChanged("Endossos"); + } + } + + public bool SomenteEndossos + { + get + { + return _somenteEndosso; + } + set + { + _somenteEndosso = value; + if (Endossos != !value) + { + Endossos = !value; + } + OnPropertyChanged("SomenteEndossos"); + } + } + + public Visibility SelecionarItensVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _selecionarItensVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _selecionarItensVisibility = value; + OnPropertyChanged("SelecionarItensVisibility"); + } + } + + public Visibility EndossoVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _endossoVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _endossoVisibility = value; + OnPropertyChanged("EndossoVisibility"); + } + } + + public Visibility ObsDocVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _obsDocVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _obsDocVisibility = value; + OnPropertyChanged("ObsDocVisibility"); + } + } + + public Visibility SegurosVigentesVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _segurosVigentesVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _segurosVigentesVisibility = value; + OnPropertyChanged("SegurosVigentesVisibility"); + } + } + + public bool ObsItem + { + get + { + return _obsItem; + } + set + { + _obsItem = value; + OnPropertyChanged("ObsItem"); + } + } + + public bool SepararPagina + { + get + { + return _separarPagina; + } + set + { + _separarPagina = value; + OnPropertyChanged("SepararPagina"); + } + } + + public bool PerfilCondutor + { + get + { + return _perfilCondutor; + } + set + { + _perfilCondutor = value; + OnPropertyChanged("PerfilCondutor"); + } + } + + public bool ObsClienteEnabled + { + get + { + return _obsClienteEnabled; + } + set + { + _obsClienteEnabled = value; + OnPropertyChanged("ObsClienteEnabled"); + } + } + + public bool ComissaoDocumentoEnabled + { + get + { + return _comissaoDocumentoEnabled; + } + set + { + _comissaoDocumentoEnabled = value; + OnPropertyChanged("ComissaoDocumentoEnabled"); + } + } + + public bool ObsApoliceEnabled + { + get + { + return _obsApoliceEnabled; + } + set + { + _obsApoliceEnabled = value; + OnPropertyChanged("ObsApoliceEnabled"); + } + } + + public bool BeneficiariosItensEnabled + { + get + { + return _beneficiariosItensEnabled; + } + set + { + _beneficiariosItensEnabled = value; + OnPropertyChanged("BeneficiariosItensEnabled"); + } + } + + public bool ObsItemEnabled + { + get + { + return _obsItemEnabled; + } + set + { + _obsItemEnabled = value; + OnPropertyChanged("ObsItemEnabled"); + } + } + + public bool SepararPaginaEnabled + { + get + { + return _separarPaginaEnabled; + } + set + { + _separarPaginaEnabled = value; + OnPropertyChanged("SepararPaginaEnabled"); + } + } + + public bool CoberturasEnabled + { + get + { + return _coberturasEnabled; + } + set + { + _coberturasEnabled = value; + OnPropertyChanged("CoberturasEnabled"); + } + } + + public bool Coberturas + { + get + { + return _coberturas; + } + set + { + _coberturas = value; + OnPropertyChanged("Coberturas"); + } + } + + public bool PerfilCondutorEnabled + { + get + { + return _perfilCondutorEnabled; + } + set + { + _perfilCondutorEnabled = value; + OnPropertyChanged("PerfilCondutorEnabled"); + } + } + + public bool EndossoEnabled + { + get + { + return _endossoEnabled; + } + set + { + _endossoEnabled = value; + OnPropertyChanged("EndossoEnabled"); + } + } + + public bool EsconderResumido + { + get + { + return _esconderResumido; + } + set + { + _esconderResumido = value; + OnPropertyChanged("EsconderResumido"); + } + } + + public bool ClienteVisibility + { + get + { + return _clienteVisibility; + } + set + { + _clienteVisibility = value; + OnPropertyChanged("ClienteVisibility"); + } + } + + public bool DocumentoVisibility + { + get + { + return _documentoVisibility; + } + set + { + _documentoVisibility = value; + OnPropertyChanged("DocumentoVisibility"); + } + } + + public bool ItemVisibility + { + get + { + return _itemVisibility; + } + set + { + _itemVisibility = value; + OnPropertyChanged("ItemVisibility"); + } + } + + public bool PerfilVisibility + { + get + { + return _perfilVisibility; + } + set + { + _perfilVisibility = value; + OnPropertyChanged("PerfilVisibility"); + } + } + + public TipoExtrato SelectedTipoExtrato + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _selectedTipoExtrato; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + _selectedTipoExtrato = value; + AjustaTipoSelecionado(value); + OnPropertyChanged("SelectedTipoExtrato"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public void AjustaTipoSelecionado(TipoExtrato tipoExtrato) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Expected I4, but got Unknown + switch ((int)tipoExtrato) + { + case 0: + ClienteVisibility = true; + ClientePorPaginaVisibility = (Visibility)1; + DocumentoVisibility = false; + ItemVisibility = false; + PerfilVisibility = false; + EsconderResumido = true; + SelecionarItensVisibility = (Visibility)2; + SegurosVigentesVisibility = (Visibility)2; + SegurosVigentes = false; + EndossoVisibility = (Visibility)2; + ObsDocVisibility = (Visibility)2; + ExtratoCliente(); + break; + case 1: + ClienteVisibility = true; + ClientePorPaginaVisibility = (Visibility)0; + DocumentoVisibility = true; + ItemVisibility = true; + PerfilVisibility = true; + EsconderResumido = false; + SelecionarItensVisibility = (Visibility)(TipoDeRelatorio.HasValue ? 2 : 0); + SegurosVigentesVisibility = (Visibility)2; + SegurosVigentes = false; + EndossoVisibility = (Visibility)0; + ObsDocVisibility = (Visibility)0; + ApoliceSelecionada(); + break; + case 2: + ClienteVisibility = false; + ClientePorPaginaVisibility = (Visibility)2; + DocumentoVisibility = true; + ItemVisibility = false; + PerfilVisibility = true; + EsconderResumido = false; + SelecionarItensVisibility = (Visibility)2; + SegurosVigentesVisibility = (Visibility)0; + EndossoVisibility = (Visibility)2; + ObsDocVisibility = (Visibility)2; + RelacaoApolices(); + break; + } + } + + private void SetAllFalse() + { + ObsClienteEnabled = false; + ClientePorPaginaEnabled = false; + ComissaoDocumentoEnabled = false; + ObsApoliceEnabled = false; + BeneficiariosItensEnabled = false; + ObsItemEnabled = false; + SepararPaginaEnabled = false; + CoberturasEnabled = false; + PerfilCondutorEnabled = false; + EndossoEnabled = false; + } + + private void ExtratoCliente() + { + SetAllFalse(); + ObsClienteEnabled = true; + } + + private void ApoliceSelecionada() + { + SetAllFalse(); + ObsClienteEnabled = true; + ClientePorPaginaEnabled = true; + ComissaoDocumentoEnabled = true; + ObsApoliceEnabled = true; + BeneficiariosItensEnabled = true; + ObsItemEnabled = true; + SepararPaginaEnabled = true; + PerfilCondutorEnabled = true; + EndossoEnabled = true; + CoberturasEnabled = true; + } + + private void RelacaoApolices() + { + SetAllFalse(); + ComissaoDocumentoEnabled = true; + PerfilCondutorEnabled = true; + } + + public async Task Gerar(Relatorio? tipoRelatorio = null, bool pdf = false) + { + string html = ""; + string title; + if (Clientes != null && Documentos == null) + { + html += "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><meta http-equiv='Content-Language' content='pt-br'><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'><link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'><style type='text/css' media='print'>@page{ size: A4;} body; -webkit-print-color-adjust: exact; }</style><title>"; + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE"; + html += title; + html += "</title></head><body bgcolor='#FFFFFF'><div align='center'>"; + html += "<style> td > p { margin: 2px; }</style>"; + long idCli = 0L; + Clientes.ForEach(delegate(Cliente x) + { + //IL_0353: Unknown result type (might be due to invalid IL or missing references) + //IL_0359: Invalid comparison between Unknown and I4 + //IL_080c: Unknown result type (might be due to invalid IL or missing references) + //IL_0812: Invalid comparison between Unknown and I4 + //IL_0988: Unknown result type (might be due to invalid IL or missing references) + //IL_098e: Invalid comparison between Unknown and I4 + //IL_0bb7: Unknown result type (might be due to invalid IL or missing references) + //IL_0bbd: Invalid comparison between Unknown and I4 + //IL_0d17: Unknown result type (might be due to invalid IL or missing references) + //IL_0d1d: Invalid comparison between Unknown and I4 + //IL_0d97: Unknown result type (might be due to invalid IL or missing references) + //IL_0d9d: Invalid comparison between Unknown and I4 + //IL_1351: Unknown result type (might be due to invalid IL or missing references) + //IL_12a2: Unknown result type (might be due to invalid IL or missing references) + //IL_12a8: Invalid comparison between Unknown and I4 + //IL_0a09: Unknown result type (might be due to invalid IL or missing references) + //IL_0a0e: Unknown result type (might be due to invalid IL or missing references) + //IL_11e8: Unknown result type (might be due to invalid IL or missing references) + //IL_11ee: Invalid comparison between Unknown and I4 + //IL_0ea0: Unknown result type (might be due to invalid IL or missing references) + //IL_0ea5: Unknown result type (might be due to invalid IL or missing references) + //IL_1030: Unknown result type (might be due to invalid IL or missing references) + //IL_1035: Unknown result type (might be due to invalid IL or missing references) + int num6 = 0; + if (idCli != ((DomainBase)x).Id) + { + idCli = ((DomainBase)x).Id; + html += ((ClientePorPagina && ClientePorPaginaEnabled) ? "<div style='page-break-before:always;'>" : ""); + html += "<table border='0' width='999'><td height='20' width='999' bgcolor='black'><h4 style='text-align: center; color: white; background-color: black'>"; + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE: " + x.Nome; + html = html + title + "</h4></td></table><br>"; + string text25 = ((x.Atividade == null) ? "NASCIMENTO" : "ABERTURA"); + bool pessoaFisica3 = x.PessoaFisica; + html = html + "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td width='333' bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "' " + (pessoaFisica3 ? "" : "colspan='1'") + "><p align='left'><b>CLIENTE: </b>" + x.Nome + "</p></td><td width='222' bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "' " + (pessoaFisica3 ? "" : "colspan='2'") + "><p align='left' x-ms-format-detection='none'><b>CPF/CNPJ: </b>" + x.Documento + "</p></td><td width='222' bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "' " + (pessoaFisica3 ? "" : "colspan='3'") + "><p align='left'><b>" + text25 + ": </b>" + x.Nascimento?.ToShortDateString() + "</p></td>"; + if (pessoaFisica3) + { + html = html + "<td width='222' bgcolor='" + ((num6++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>FALECIDO: </b>" + (x.Falecido ? "SIM" : "NÃO") + "</p></td>"; + } + else + { + num6++; + } + html += "</tr>"; + if (x.Atividade != null) + { + html = html + "<tr><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left'><b>RAMO DE ATIVIDADE: </b>" + x.Atividade.Nome + "</p></td></tr>"; + if (!pessoaFisica3) + { + num6++; + } + } + if ((int)SelectedTipoExtrato != 2) + { + html += "<tr>"; + if (pessoaFisica3) + { + html = html + "<td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ESTADO CIVIL: </b>" + (x.EstadoCivil.HasValue ? x.EstadoCivil.ToString().ToUpper() : "-") + "</p></td><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>SEXO: </b>" + (x.Sexo.HasValue ? x.Sexo.ToString().ToUpper() : "-") + "</p></td>"; + } + html = html + "<td bgcolor='" + ((num6++ % 2 == 0) ? "WhiteSmoke" : "White") + "' " + (pessoaFisica3 ? "colspan='2'" : "colspan='4'") + "><p align='left'><b>CLIENTE DESDE: </b>" + ((!x.ClienteDesde.HasValue) ? "-" : x.ClienteDesde?.ToShortDateString()) + "</p></td></tr>"; + } + if (pessoaFisica3) + { + html = html + "<tr><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>HABILITAÇÃO: </b>" + ((!string.IsNullOrWhiteSpace(x.Habilitacao)) ? x.Habilitacao : "-") + "</p></td><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>CATEGORIA: </b>" + ((!string.IsNullOrWhiteSpace(x.CategoriaHabilitacao)) ? x.CategoriaHabilitacao : "-") + "</p></td><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>1ª HAB.: </b>" + ((!x.PrimeiraHabilitacao.HasValue) ? "-" : x.PrimeiraHabilitacao?.ToShortDateString()) + "</p></td><td bgcolor='" + ((num6++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>VENCIMENTO: </b>" + ((!x.VencimentoHabilitacao.HasValue) ? "-" : x.VencimentoHabilitacao?.ToShortDateString()) + "</p></td></tr>"; + } + if (!string.IsNullOrWhiteSpace(x.Identidade)) + { + html = html + "<tr><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>RG: </b>" + ((!string.IsNullOrWhiteSpace(x.Identidade)) ? x.Identidade : "-") + "</p></td><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ORGÃO EMISSOR: </b>" + ((!string.IsNullOrWhiteSpace(x.Emissor)) ? x.Emissor : "-") + "</p></td><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ESTADO EMISSOR: </b>" + ((!string.IsNullOrWhiteSpace(x.EstadoEmissor)) ? x.EstadoEmissor : "-") + "</p></td><td bgcolor='" + ((num6++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>EXPEDIÇÃO: </b>" + ((!x.Expedicao.HasValue) ? "-" : x.Expedicao?.ToShortDateString()) + "</p></td></tr>"; + } + if ((int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + "<tr><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>BANCO: </b>" + ((x.Banco != null) ? x.Banco.Nome : "-") + "</p></td><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>AGÊNCIA: </b>" + ((!string.IsNullOrWhiteSpace(x.Agencia)) ? x.Agencia : "-") + "</p></td><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>CONTA: </b>" + ((!string.IsNullOrWhiteSpace(x.Conta)) ? x.Conta : "-") + "</p></td><td bgcolor='" + ((num6++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>TIPO: </b>" + ((!string.IsNullOrWhiteSpace(x.TipoConta)) ? x.TipoConta : "-") + "</p></td></tr>"; + } + TipoTelefone valueOrDefault3; + if ((x.Telefones != null || x.Emails != null) && (int)SelectedTipoExtrato != 2) + { + html += "<tr>"; + if (x.Telefones != null) + { + string text26 = ""; + foreach (ClienteTelefone telefone in x.Telefones) + { + string[] obj32 = new string[7] { text26, "<br>", null, null, null, null, null }; + TipoTelefone? tipo2 = ((TelefoneBase)telefone).Tipo; + object obj33; + if (!tipo2.HasValue) + { + obj33 = null; + } + else + { + valueOrDefault3 = tipo2.GetValueOrDefault(); + obj33 = ((object)(TipoTelefone)(ref valueOrDefault3)).ToString().ToUpper(); + } + obj32[2] = (string)obj33; + obj32[3] = " ("; + obj32[4] = ((TelefoneBase)telefone).Prefixo; + obj32[5] = ") "; + obj32[6] = ((TelefoneBase)telefone).Numero; + text26 = string.Concat(obj32); + } + html = html + "<td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>CONTATOS: </b>" + text26 + "</p></td>"; + } + if (x.Emails != null && !ExtratoResumido) + { + string text27 = ""; + foreach (ClienteEmail email in x.Emails) + { + text27 = text27 + "<br>" + ((EmailBase)email).Email; + } + html = html + "<td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>EMAILS: </b>" + text27 + "</p></td>"; + } + num6++; + html += "</tr>"; + } + if (x.Enderecos != null && (int)SelectedTipoExtrato != 2) + { + string text28 = ""; + foreach (ClienteEndereco endereco in x.Enderecos) + { + text28 = text28 + "<br>" + ((EnderecoBase)endereco).Endereco + ", " + ((EnderecoBase)endereco).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco).Complemento) ? "" : (((EnderecoBase)endereco).Complemento + ", ")) + ((EnderecoBase)endereco).Bairro + " - " + ((EnderecoBase)endereco).Cidade + " - " + ((EnderecoBase)endereco).Estado + " - " + ((EnderecoBase)endereco).Cep; + } + html = html + "<tr><td bgcolor='" + ((num6++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left'><b>ENDEREÇOS: </b>" + text28 + "</p></td></tr>"; + } + if (x.Profissao != null && (int)SelectedTipoExtrato != 2) + { + html = html + "<tr><td bgcolor='" + ((num6++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left'><b>PROFISSÃO: </b>" + x.Profissao.Nome + "</p></td></tr>"; + } + if (x.Contatos != null && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + string text29 = ""; + foreach (MaisContato contato in x.Contatos) + { + string[] obj34 = new string[15] + { + text29, + "<br>NOME: ", + contato.Nome, + (!string.IsNullOrWhiteSpace(contato.Documento)) ? (", DOCUMENTO: " + contato.Documento) : "", + contato.Nascimento.HasValue ? (", NASCIMENTO: " + contato.Nascimento?.ToShortDateString()) : "", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + object obj35; + if (!contato.Parentesco.HasValue) + { + obj35 = ""; + } + else + { + Parentesco? parentesco2 = contato.Parentesco; + object obj36; + if (!parentesco2.HasValue) + { + obj36 = null; + } + else + { + Parentesco valueOrDefault4 = parentesco2.GetValueOrDefault(); + obj36 = ((object)(Parentesco)(ref valueOrDefault4)).ToString().ToUpper(); + } + obj35 = ", PARENTESCO: " + (string?)obj36; + } + obj34[5] = (string)obj35; + obj34[6] = ((!string.IsNullOrWhiteSpace(contato.Banco) || !string.IsNullOrWhiteSpace(contato.Agencia) || !string.IsNullOrWhiteSpace(contato.Conta)) ? "<br>" : ""); + obj34[7] = ((!string.IsNullOrWhiteSpace(contato.Banco)) ? ("BANCO: " + contato.Banco) : ""); + obj34[8] = ((!string.IsNullOrWhiteSpace(contato.Agencia)) ? (((!string.IsNullOrWhiteSpace(contato.Banco)) ? ", AGÊNCIA: " : "AGÊNCIA: ") + contato.Agencia) : ""); + obj34[9] = ((!string.IsNullOrWhiteSpace(contato.Conta)) ? (((!string.IsNullOrWhiteSpace(contato.Banco) || !string.IsNullOrWhiteSpace(contato.Agencia)) ? ", CONTA: " : "CONTA: ") + contato.Conta) : ""); + obj34[10] = ((contato.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato.Prefixo) && !string.IsNullOrWhiteSpace(contato.Telefone)) || !string.IsNullOrWhiteSpace(contato.Email)) ? "<br>" : ""); + object obj37; + if (!contato.Tipo.HasValue) + { + obj37 = ""; + } + else + { + TipoTelefone? tipo2 = contato.Tipo; + object obj38; + if (!tipo2.HasValue) + { + obj38 = null; + } + else + { + valueOrDefault3 = tipo2.GetValueOrDefault(); + obj38 = ((object)(TipoTelefone)(ref valueOrDefault3)).ToString().ToUpper(); + } + obj37 = "TIPO DO TELEFONE: " + (string?)obj38; + } + obj34[11] = (string)obj37; + obj34[12] = ((!string.IsNullOrWhiteSpace(contato.Prefixo) && !string.IsNullOrWhiteSpace(contato.Telefone)) ? ((contato.Tipo.HasValue ? ", TELEFONE: (" : "TELEFONE: (") + contato.Prefixo + ") " + contato.Telefone) : ""); + obj34[13] = ((!string.IsNullOrWhiteSpace(contato.Email)) ? (((contato.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato.Prefixo) && !string.IsNullOrWhiteSpace(contato.Telefone))) ? ", EMAIL: " : "EMAIL: ") + contato.Email) : ""); + obj34[14] = "<br>"; + text29 = string.Concat(obj34); + } + html = html + "<tr><td bgcolor='" + ((num6++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left'><b>MAIS CONTATOS: </b>" + text29 + "</p></td></tr>"; + } + if (ObsCliente && ClienteVisibility && ObsClienteEnabled && !string.IsNullOrWhiteSpace(x.Observacao) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + x.Observacao = "<br>" + x.Observacao.Replace("\r\n", "<br>"); + html = html + "<tr><td bgcolor='" + ((num6++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left' x-ms-format-detection='none'><b>OBSERVAÇÕES: </b>" + x.Observacao + "</p></td></tr>"; + } + if (!string.IsNullOrWhiteSpace(x.Pasta) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + "<tr><td bgcolor='" + ((num6 % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left' x-ms-format-detection='none'><b>PASTA: </b>" + x.Pasta + "</p></td></tr>"; + } + html += "</font></table>"; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "</div>" : ""); + } + }); + DateTime networkTime = Funcoes.GetNetworkTime(); + html = html + "<br><font face='Verdana' size='1'><br>" + Recursos.Usuario.Nome + " - " + networkTime.Date.ToShortDateString() + "</font></div><script src='https://code.jquery.com/jquery-3.3.1.slim.min.js' integrity='sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo' crossorigin='anonymous'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js' integrity='sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1' crossorigin='anonymous'></script><script src='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js' integrity='sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM' crossorigin='anonymous'></script></body></html>"; + string tempPath = Path.GetTempPath(); + string text = $"{tempPath}{(object)(TipoExtrato)0}_{networkTime:ddMMyyyyhhmmss}.html"; + if (pdf) + { + text = $"{tempPath}{(object)(TipoExtrato)0}_{networkTime:ddMMyyyyhhmmss}.pdf"; + byte[] bytes = ((HtmlToPdfConverter)new NRecoHtmlToPdfConverter()).GeneratePdf(html); + File.WriteAllBytes(text, bytes); + } + else + { + StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8); + streamWriter.Write(html); + streamWriter.Close(); + } + Process.Start(text); + RegistrarAcao("GEROU O EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " " + ((Clientes == null) ? "" : ((Clientes.Count > 1) ? $"DE {Clientes.Count} CLIENTES" : ("DO CLIENTE " + Clientes[0].Nome))), 0L, (TipoTela)23, "NOMES DOS CLIENTES:\n" + string.Join("\n", Clientes.Select((Cliente x) => x.Nome)) + GerarOpcoes()); + Documentos = null; + Clientes = null; + } + else + { + if ((Documentos == null && Prospeccoes == null) || Clientes != null) + { + return; + } + html = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><meta http-equiv='Content-Language' content='pt-br'><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'><link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'><style type='text/css' media='print'>@page{ size: A4;} body; -webkit-print-color-adjust: exact; }</style><title>"; + title = ""; + TipoExtrato selectedTipoExtrato = SelectedTipoExtrato; + switch ((int)selectedTipoExtrato) + { + case 0: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE"; + break; + case 1: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DA APÓLICE SELECIONADA"; + if (tipoRelatorio.HasValue && (int)tipoRelatorio.GetValueOrDefault() == 4) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO RELATÓRIO DE RENOVAÇÕES"; + } + break; + case 2: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DE RELAÇÃO DE APÓLICES"; + break; + } + html += title; + html += "</title></head><body bgcolor='#FFFFFF'><div align='center'>"; + List<long> sDocumento = new List<long>(); + if (Documentos != null && Documentos.Count > 0) + { + bool configEndosso = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 42); + foreach (Documento documento2 in Documentos) + { + Documento val = documento2; + val.Parcelas = await new ParcelaServico().BuscarParcelasAsync(((DomainBase)documento2).Id); + Controle controle = documento2.Controle; + controle.Cliente = await _clienteServico.BuscarCliente(((DomainBase)documento2.Controle.Cliente).Id); + Cliente cliente = documento2.Controle.Cliente; + cliente.Enderecos = await _clienteServico.BuscarEnderecosAsync(((DomainBase)documento2.Controle.Cliente).Id); + cliente = documento2.Controle.Cliente; + cliente.Emails = await _clienteServico.BuscarEmailsAsync(((DomainBase)documento2.Controle.Cliente).Id); + cliente = documento2.Controle.Cliente; + cliente.Telefones = await _clienteServico.BuscarTelefonesAsync(((DomainBase)documento2.Controle.Cliente).Id); + cliente = documento2.Controle.Cliente; + cliente.Contatos = await _clienteServico.BuscarContatosAsync(((DomainBase)documento2.Controle.Cliente).Id); + } + bool primeiro = true; + foreach (Documento documento in Documentos) + { + List<Item> itensDocumentos = new List<Item>(); + List<Item> list = ((!Endossos) ? (await new ItemServico().BuscarItens(((DomainBase)documento.Controle).Id, (StatusItem)0)).ToList() : (await new ItemServico().BuscarItens(((DomainBase)documento).Id, (StatusItem)2)).ToList()); + List<Item> list2 = list; + if (_itensSelecionados != null && _itensSelecionados.Count > 0) + { + list2.ForEach(delegate(Item x) + { + if (_itensSelecionados.Any((Item y) => ((DomainBase)y).Id == ((DomainBase)x).Id)) + { + itensDocumentos.Add(x); + } + }); + } + else + { + itensDocumentos.AddRange(list2); + } + List<Perfil> source = await new PerfilServico().BuscarPerfis(((DomainBase)documento.Controle).Id); + long num = 0L; + int color = 0; + if (!primeiro) + { + html += (ExtratoPorPagina ? "<div style='page-break-before:always;'>" : ""); + } + if (num != ((DomainBase)documento.Controle.Cliente).Id) + { + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled && !ExtratoPorPagina) ? "<div style='page-break-before:always;'>" : ""); + html += "<table border='0' width='999'><td height='20' width='999' bgcolor='black'><h4 style='text-align: center; color: white; background-color: black'>"; + selectedTipoExtrato = SelectedTipoExtrato; + switch ((int)selectedTipoExtrato) + { + case 0: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE: " + documento.Controle.Cliente.Nome; + break; + case 1: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DA APÓLICE SELECIONADA: " + documento.Apolice; + if (tipoRelatorio.HasValue && (int)tipoRelatorio.GetValueOrDefault() == 4) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DA APÓLICE: " + documento.Apolice; + } + if (!string.IsNullOrEmpty(documento.Endosso) && !documento.Endosso.Equals("0")) + { + title = title + " E DO ENDOSSO: " + documento.Endosso; + } + if (SomenteEndossos) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO ENDOSSO: " + documento.Endosso; + } + break; + case 2: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DE RELAÇÃO DE APÓLICES"; + break; + } + html = html + title + "</h4></td></table><br>"; + html += "<style>td > p {margin: 2px;}</style>"; + TipoTelefone valueOrDefault; + if (ExtratoResumido) + { + bool pessoaFisica = documento.Controle.Cliente.PessoaFisica; + if ((!Endossos || !SomenteEndossos) && !sDocumento.Any((long x) => x == ((DomainBase)documento.Controle).Id)) + { + html = html + "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td width='333' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' " + (pessoaFisica ? "" : "colspan='2'") + "><p align='left'><b>CLIENTE: </b>" + documento.Controle.Cliente.Nome + "</p></td>"; + if (pessoaFisica) + { + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>RG: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "</p></td>"; + } + html = html + "<td width='222' bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left' x-ms-format-detection='none'><b>CPF/CNPJ: </b>" + documento.Controle.Cliente.Documento + "</p></td></tr>"; + if ((int)SelectedTipoExtrato != 2) + { + string text2 = ((documento.Controle.Cliente.Atividade == null) ? "NASCIMENTO" : "ABERTURA"); + html = html + "<tr><td width='222' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' " + (pessoaFisica ? "" : "colspan='2'") + "><p align='left'><b>" + text2 + ": " + documento.Controle.Cliente.Nascimento?.ToShortDateString() + "</b></p>"; + if (pessoaFisica) + { + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'colspan='2'><p align='left'><b>ESTADO CIVIL: </b>" + (documento.Controle.Cliente.EstadoCivil.HasValue ? documento.Controle.Cliente.EstadoCivil.ToString().ToUpper() : "-") + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>SEXO: </b>" + (documento.Controle.Cliente.Sexo.HasValue ? documento.Controle.Cliente.Sexo.ToString().ToUpper() : "-") + "</p></td></td></tr>"; + } + else + { + color++; + } + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>BANCO: </b>" + ((documento.Controle.Cliente.Banco != null) ? documento.Controle.Cliente.Banco.Nome : "-") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>AGÊNCIA: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Agencia)) ? documento.Controle.Cliente.Agencia : "-") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>CONTA: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Conta)) ? documento.Controle.Cliente.Conta : "-") + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>TIPO: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.TipoConta)) ? documento.Controle.Cliente.TipoConta : "-") + "</p></td></tr>"; + } + if ((int)SelectedTipoExtrato != 2) + { + html += "<tr>"; + string text3 = ""; + if (documento.Controle.Cliente.Telefones != null) + { + foreach (ClienteTelefone telefone2 in documento.Controle.Cliente.Telefones) + { + string[] obj = new string[7] { text3, "<br>", null, null, null, null, null }; + TipoTelefone? tipo = ((TelefoneBase)telefone2).Tipo; + object obj2; + if (!tipo.HasValue) + { + obj2 = null; + } + else + { + valueOrDefault = tipo.GetValueOrDefault(); + obj2 = ((object)(TipoTelefone)(ref valueOrDefault)).ToString().ToUpper(); + } + obj[2] = (string)obj2; + obj[3] = " ("; + obj[4] = ((TelefoneBase)telefone2).Prefixo; + obj[5] = ") "; + obj[6] = ((TelefoneBase)telefone2).Numero; + text3 = string.Concat(obj); + } + } + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' ><p align='left'><b>CONTATOS: </b>" + (string.IsNullOrEmpty(text3) ? "-" : text3) + "</p></td>"; + string text4 = ""; + if (documento.Controle.Cliente.Emails != null) + { + foreach (ClienteEmail email2 in documento.Controle.Cliente.Emails) + { + text4 = text4 + "<br>" + ((EmailBase)email2).Email; + } + } + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>EMAILS: </b>" + (string.IsNullOrEmpty(text4) ? "-" : text4) + "</p></td>"; + string text5 = ""; + if (documento.Controle.Cliente.Enderecos != null) + { + foreach (ClienteEndereco endereco2 in documento.Controle.Cliente.Enderecos) + { + text5 = text5 + "<br>" + ((EnderecoBase)endereco2).Endereco + ", " + ((EnderecoBase)endereco2).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco2).Complemento) ? "" : (((EnderecoBase)endereco2).Complemento + ", ")) + ((EnderecoBase)endereco2).Bairro + " - " + ((EnderecoBase)endereco2).Cidade + " - " + ((EnderecoBase)endereco2).Estado + " - " + ((EnderecoBase)endereco2).Cep; + } + } + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>ENDEREÇOS: </b>" + (string.IsNullOrEmpty(text5) ? "-" : text5) + "</p></td>"; + html += "</tr>"; + } + html += "</font></table>"; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "</div>" : ""); + } + else + { + html = html + "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td width='333' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>CLIENTE: </b>" + documento.Controle.Cliente.Nome + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>RG: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "</p></td><td width='222' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left' x-ms-format-detection='none'><b>CPF/CNPJ: </b>" + documento.Controle.Cliente.Documento + "</p></td></tr></font></table>"; + } + if ((int)SelectedTipoExtrato == 0) + { + return; + } + color = 0; + Documento val2 = documento.Controle.Documentos?.LastOrDefault((Func<Documento, bool>)((Documento x) => !x.Excluido && x.Ordem != 0)); + html = html + "<hr style='width:999; border-top: 3px solid #000'><table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>RAMO: </b>" + documento.Controle.Ramo.Nome + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>VIGÊNCIA INICIAL: </b>" + documento.Vigencia1.ToShortDateString() + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>VIGÊNCIA FINAL: </b>" + ((!documento.Vigencia2.HasValue) ? "-" : documento.Vigencia2?.ToShortDateString()) + "</p></td></tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>CONTRATO: </b>" + (string.IsNullOrWhiteSpace(documento.Apolice) ? "-" : documento.Apolice) + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>POSSUI ENDOSSO? </b>" + (documento.TemEndosso ? "SIM" : "NÃO") + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>ADITAMENTO: </b>" + ((!string.IsNullOrWhiteSpace(documento.Endosso)) ? documento.Endosso : ((configEndosso && val2 != null) ? val2.Endosso : "-")) + "</p></td></tr><tr>"; + if (!documento.NegocioCorretora.HasValue) + { + documento.NegocioCorretora = (NegocioCorretora)(((int)documento.Situacao == 2 && documento.Negocio.HasValue && (int)documento.Negocio.GetValueOrDefault() == 1) ? 1 : 0); + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>NEGÓCIO CORRETORA: </b>" + ValidationHelper.GetDescription((Enum)(object)documento.NegocioCorretora) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>STATUS DO SEGURO: </b>" + ValidationHelper.GetDescription((Enum)(object)documento.Situacao) + "</p></td>"; + } + html = html + "</tr><tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>VENDEDOR: </b>" + ((documento.VendedorPrincipal == null) ? "-" : documento.VendedorPrincipal.Nome) + "</p></td></tr>"; + if ((int)SelectedTipoExtrato != 2) + { + html += "<tr>"; + string text6 = ""; + if (documento.Estipulante1 != null) + { + text6 = text6 + documento.Estipulante1.Nome + ", "; + } + if (documento.Estipulante2 != null) + { + text6 = text6 + documento.Estipulante2.Nome + ", "; + } + if (documento.Estipulante3 != null) + { + text6 = text6 + documento.Estipulante3.Nome + ", "; + } + if (documento.Estipulante4 != null) + { + text6 = text6 + documento.Estipulante4.Nome + ", "; + } + if (documento.Estipulante5 != null) + { + text6 = text6 + documento.Estipulante5.Nome + ", "; + } + if (!string.IsNullOrWhiteSpace(text6)) + { + int startIndex = text6.LastIndexOf(", ", StringComparison.Ordinal); + text6 = text6.Remove(startIndex, 2).Insert(startIndex, "."); + } + html = html + "<td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>ESTIPULANTE(S): </b>" + (string.IsNullOrWhiteSpace(text6) ? "-" : text6) + "</p></td></tr>"; + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>SEGURADORA: </b>" + documento.Controle.Seguradora.Nome + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>APÓLICE SINISTRADA: </b>" + (documento.Sinistro ? "SIM" : "NÃO") + "</p></td></tr>"; + } + else + { + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>SEGURADORA: </b>" + documento.Controle.Seguradora.Nome + "</p></td></tr>"; + } + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>FORMA PAGAMENTO: </b>" + ValidationHelper.GetDescription((Enum)(object)documento.FormaPagamento) + "</p></td></tr>"; + html += "</font></table>"; + if (PremioParcela || ExtratoResumido) + { + html += "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr>"; + if ((ComissaoDocumento && ComissaoDocumentoEnabled) || ExtratoResumido) + { + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>COMISSÃO: </b>" + $"{Math.Round(documento.Comissao, 2):n2}%" + "</p></td>"; + } + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>PRÊMIO LÍQUIDO: </b>" + $"{Math.Round(documento.PremioLiquido, 2):c}" + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ADICIONAL: </b>" + $"{Math.Round(documento.PremioAdicional, 2):c}" + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>CUSTO APÓLICE: </b>" + $"{Math.Round(documento.Custo, 2):c}" + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>I.O.F.: </b>" + $"{Math.Round(documento.Iof, 2):c}" + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>PRÊMIO TOTAL: </b>" + $"{Math.Round(documento.PremioTotal, 2):c}" + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>Nº PARCELAS: </b>" + documento.NumeroParcelas + "</p></td></tr>"; + html += "</font></table>"; + } + if (PerfilCondutor && PerfilVisibility && ((DomainBase)documento.Controle.Ramo).Id == 5 && PerfilCondutorEnabled) + { + List<Perfil> list3 = source.ToList(); + foreach (Perfil item3 in list3) + { + color = 0; + if (!string.IsNullOrEmpty(item3.Nome)) + { + html = html + "<hr style='width:999; border-top: 2px solid #ccc'><table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>" + $"CONDUTOR {list3.IndexOf(item3) + 1}: " + "</b>" + item3.Nome + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>CPF: </b>" + (string.IsNullOrWhiteSpace(item3.Cpf) ? "-" : item3.Cpf) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>NASCIMENTO: </b>" + ((!item3.Nascimento.HasValue) ? "-" : item3.Nascimento?.ToShortDateString()) + "</p></td></tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ESTADO CIVIL: </b>" + ((!item3.EstadoCivil.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.EstadoCivil)) + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>SEXO: </b>" + ((!item3.Sexo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.Sexo)) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>RELAÇÃO SEGURADO/CONDUTOR: </b>" + ValidationHelper.GetDescription((Enum)(object)item3.Relacao) + "</p></td></tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>GARAGEM NA RESIDÊNCIA: </b>" + ((!item3.GaragemResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.GaragemResidencia)) + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>GARAGEM NO TRABALHO: </b>" + ((!item3.GaragemTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.GaragemTrabalho)) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>GARAGEM NO ESTUDO: </b>" + ((!item3.GaragemEstudo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.GaragemEstudo)) + "</p></td></tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>TIPO DE RESIDÊNCIA: </b>" + ((!item3.TipoResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.TipoResidencia)) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>DISTÂNCIA ATÉ O TRABALHO: </b>" + ((!item3.DistanciaResidenciaTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.DistanciaResidenciaTrabalho)) + "</p></td></tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>USO PROFISSIONAL: </b>" + ((item3.UsoProfissional.HasValue && item3.UsoProfissional.Value) ? "SIM" : "NÃO") + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>USO POR DEPENDENTES: </b>" + ((!item3.UsoDependentes.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.UsoDependentes)) + "</p></td></tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>ISENÇÃO DE IMPOSTOS: </b>" + ((item3.Isencao.HasValue && item3.Isencao.Value) ? "SIM" : "NÃO") + "</p></td></tr></font></table>"; + } + } + } + List<Item> itens2 = itensDocumentos.ToList(); + if (itens2.Count == 0) + { + html += "<br><p align='center'><b>ESTA APÓLICE NÃO POSSUI ITENS</b></p>"; + } + else + { + color = 0; + foreach (Item item2 in itens2) + { + if (item2.Sinistros.Count > 0) + { + Item val3 = item2; + val3.Sinistros = await new SinistroServico().BuscarControles(((DomainBase)item2).Id); + } + html += ((SepararPagina && SepararPaginaEnabled) ? "<div style='page-break-before:always;'>" : ""); + html += (((int)SelectedTipoExtrato != 2 || itens2.IndexOf(item2) == 0) ? "<br>" : ""); + html += "<table border='1' bordercolor='#ededed' width='999'>"; + html += "<style> td > p { margin: 2px; }</style>"; + html += "<font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr>"; + if ((int)SelectedTipoExtrato == 2) + { + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>" + $"ITEM {item2.Ordem}: " + "</b>" + item2.Descricao + "</p></td>"; + } + else + { + switch (((DomainBase)documento.Controle.Ramo).Id) + { + case 1L: + case 2L: + case 3L: + case 15L: + case 18L: + { + Item val3 = item2; + val3.Patrimonial = await new ItemServico().BuscaPatrimonial(((DomainBase)item2).Id); + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='4'><p align='left'><b>" + $"ITEM {item2.Ordem}: " + "</b>" + ((EnderecoBase)item2.Patrimonial).Endereco + ", " + ((EnderecoBase)item2.Patrimonial).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)item2.Patrimonial).Complemento) ? "" : (((EnderecoBase)item2.Patrimonial).Complemento + ", ")) + ((EnderecoBase)item2.Patrimonial).Bairro + " - " + ((EnderecoBase)item2.Patrimonial).Cidade + " - " + ((EnderecoBase)item2.Patrimonial).Estado + " - " + ((EnderecoBase)item2.Patrimonial).Cep + "</p></td>"; + break; + } + case 5L: + case 37L: + { + Item val3 = item2; + val3.Auto = await new ItemServico().BuscaAuto(((DomainBase)item2).Id); + string[] obj3 = new string[26] + { + html, + "<td bgcolor='", + (color % 2 == 0) ? "WhiteSmoke" : "White", + "' colspan='4'><p align='left'><b>", + $"ITEM {item2.Ordem}: ", + "</b><br>", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + Fabricante fabricante = item2.Auto.Fabricante; + obj3[6] = ((fabricante != null) ? fabricante.Descricao : null); + obj3[7] = " "; + obj3[8] = item2.Auto.Modelo; + obj3[9] = " ("; + obj3[10] = item2.Auto.AnoFabricacao; + obj3[11] = "/"; + obj3[12] = item2.Auto.AnoModelo; + obj3[13] = ")<br>PLACA: "; + obj3[14] = item2.Auto.Placa; + obj3[15] = ", CHASSI: "; + obj3[16] = item2.Auto.Chassi; + obj3[17] = "<br>C.I.: "; + obj3[18] = item2.Auto.Ci; + obj3[19] = ", RENAVAM: "; + obj3[20] = item2.Auto.Renavam; + obj3[21] = ", CEP PERNOITE: "; + obj3[22] = item2.Auto.CepPernoite; + obj3[23] = "<br>FINANCIADO: "; + obj3[24] = (item2.Auto.Financiado.GetValueOrDefault() ? "SIM" : "NÃO"); + obj3[25] = "</p></td>"; + html = string.Concat(obj3); + break; + } + default: + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='4'><p align='left'><b>" + $"ITEM {item2.Ordem}: " + "</b>" + item2.Descricao + "</p></td>"; + break; + } + } + if (item2.Sinistros.Count > 0) + { + Item obj4 = item2; + DateTime? obj5; + if (obj4 == null) + { + obj5 = null; + } + else + { + IList<ControleSinistro> sinistros = obj4.Sinistros; + if (sinistros == null) + { + obj5 = null; + } + else + { + ControleSinistro? obj6 = sinistros.LastOrDefault(); + if (obj6 == null) + { + obj5 = null; + } + else + { + List<Sinistro> sinistros2 = obj6.Sinistros; + if (sinistros2 == null) + { + obj5 = null; + } + else + { + Sinistro? obj7 = sinistros2.LastOrDefault(); + obj5 = ((obj7 != null) ? obj7.DataReclamacao : null); + } + } + } + } + DateTime? dateTime = obj5; + string text7 = (dateTime.HasValue ? dateTime.Value.ToShortDateString() : "-"); + string[] obj8 = new string[14] + { + html, "</tr><td bgcolor='", null, null, null, null, null, null, null, null, + null, null, null, null + }; + int num2 = color + 1; + color = num2; + obj8[2] = ((num2 % 2 == 0) ? "WhiteSmoke" : "White"); + obj8[3] = "' colspan='2'><p align='left'><b>SINISTRO STATUS: </b>"; + obj8[4] = ValidationHelper.GetDescription((Enum)(object)item2.Sinistros.LastOrDefault().Sinistros.LastOrDefault().StatusSinistro); + obj8[5] = "</p></td><td bgcolor='"; + obj8[6] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + obj8[7] = "'><p align='left'><b>DATA: </b>"; + obj8[8] = text7; + obj8[9] = "</p></td><td bgcolor='"; + obj8[10] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + obj8[11] = "'><p align='left'><b>VALOR: </b>"; + obj8[12] = ValidationHelper.ToCurrency<decimal>(item2.Sinistros.LastOrDefault().Sinistros.LastOrDefault().Valor, "pt-BR"); + obj8[13] = "</p></td>"; + html = string.Concat(obj8); + } + html += "</tr>"; + if ((int)SelectedTipoExtrato != 2) + { + string[] obj9 = new string[6] { html, "<tr><td bgcolor='", null, null, null, null }; + int num2 = color + 1; + color = num2; + obj9[2] = ((num2 % 2 == 0) ? "WhiteSmoke" : "White"); + obj9[3] = "' colspan='4'><p align='left'><b>ATIVO: </b>"; + obj9[4] = ((!item2.Substituido.HasValue) ? "SIM" : "NÃO"); + obj9[5] = "</p></td></tr>"; + html = string.Concat(obj9); + long id = ((DomainBase)documento.Controle.Ramo).Id; + long num3 = id - 1; + if ((ulong)num3 <= 58uL) + { + switch (num3) + { + case 0L: + case 1L: + case 2L: + case 14L: + case 17L: + if (ObsItem && ObsItemEnabled) + { + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.Patrimonial.Bens) ? "-" : item2.Patrimonial.Bens) + "</p></td></tr>"; + } + break; + case 4L: + case 36L: + { + if (ObsItem && ObsItemEnabled) + { + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.Auto.Observacao) ? "-" : item2.Auto.Observacao) + "</p></td></tr>"; + } + string[] array = new string[26]; + array[0] = html; + array[1] = "<tr><td bgcolor='"; + num2 = color + 1; + color = num2; + array[2] = ((num2 % 2 == 0) ? "WhiteSmoke" : "White"); + array[3] = "' colspan='2'><p align='left'><b>COBERTURA PADRÃO: </b>"; + TipoCobertura? tipoCobertura = item2.Auto.TipoCobertura; + array[4] = (tipoCobertura.HasValue ? ValidationHelper.GetDescription((Enum)(object)tipoCobertura.GetValueOrDefault()) : null); + array[5] = "</p></td><td bgcolor='"; + array[6] = ((color++ % 2 == 0) ? "WhiteSmoke" : "White"); + array[7] = "' colspan='2'><p align='left'><b>BÔNUS: </b>"; + array[8] = item2.Auto.Bonus.ToString(); + array[9] = "</p></td></tr><tr><td bgcolor='"; + array[10] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + array[11] = "'><p align='left'><b>REGIÃO DE CIRCULAÇÃO: </b>"; + array[12] = (string.IsNullOrWhiteSpace(item2.Auto.RegiaoCirculacao) ? "-" : item2.Auto.RegiaoCirculacao); + array[13] = "</p></td><td bgcolor='"; + array[14] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + array[15] = "'><p align='left'><b>TABELA DE REFERÊNCIA: </b>"; + TabelaReferencia? tabelaReferencia = item2.Auto.TabelaReferencia; + array[16] = (tabelaReferencia.HasValue ? ValidationHelper.GetDescription((Enum)(object)tabelaReferencia.GetValueOrDefault()) : null); + array[17] = "</p></td><td bgcolor='"; + array[18] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + array[19] = "'><p align='left'><b>FIPE: </b>"; + array[20] = (string.IsNullOrWhiteSpace(item2.Auto.Fipe) ? "-" : item2.Auto.Fipe); + array[21] = "</p></td><td bgcolor='"; + array[22] = ((color++ % 2 == 0) ? "WhiteSmoke" : "White"); + array[23] = "'><p align='left'><b>% DE REFERÊNCIA: </b>"; + array[24] = $"{item2.Auto.PorcentagemReferencia}%"; + array[25] = "</p></td></tr></tr>"; + html = string.Concat(array); + break; + } + case 5L: + case 6L: + case 8L: + case 9L: + case 52L: + { + Item val3 = item2; + val3.Vida = await new ItemServico().BuscaVida(((DomainBase)item2).Id); + if (!item2.Sinistrado || !BeneficiariosItens || !BeneficiariosItensEnabled) + { + break; + } + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>BENEFICIÁRIOS: </b>"; + string text8 = ""; + foreach (ControleSinistro sinistro in item2.Sinistros) + { + if (sinistro.Sinistros == null) + { + continue; + } + foreach (Sinistro sinistro2 in sinistro.Sinistros) + { + if (!string.IsNullOrWhiteSpace(sinistro2.SinistroVida.Beneficiario)) + { + text8 = text8 + sinistro2.SinistroVida.Beneficiario + ", "; + } + } + } + if (!string.IsNullOrWhiteSpace(text8)) + { + int startIndex2 = text8.LastIndexOf(", ", StringComparison.Ordinal); + text8 = text8.Remove(startIndex2, 2).Insert(startIndex2, "."); + } + html = html + text8 + "</p></td></tr>"; + break; + } + case 3L: + case 7L: + case 15L: + case 16L: + case 18L: + case 22L: + case 23L: + case 25L: + case 27L: + case 30L: + case 32L: + case 38L: + case 40L: + case 43L: + case 48L: + case 58L: + { + Item val3 = item2; + val3.RiscosDiversos = await new ItemServico().BuscaRiscosDiversos(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.RiscosDiversos.Observacao) ? "-" : item2.RiscosDiversos.Observacao) + "</p></td></tr>"; + } + break; + } + case 12L: + { + Item val3 = item2; + val3.Aeronautico = await new ItemServico().BuscaAeronautico(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.Aeronautico.Observacao) ? "-" : item2.Aeronautico.Observacao) + "</p></td></tr>"; + } + break; + } + case 19L: + { + Item val3 = item2; + val3.Granizo = await new ItemServico().BuscaGranizo(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.Granizo.Observacao) ? "-" : item2.Granizo.Observacao) + "</p></td></tr>"; + } + break; + } + } + } + } + html += "</font></table>"; + if ((int)SelectedTipoExtrato != 2) + { + ObservableCollection<Cobertura> observableCollection = await new ItemServico().BuscarCoberturasPorItemAsync(((DomainBase)item2).Id); + if (observableCollection.Count > 0 && Coberturas) + { + html += "<br><table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td bgcolor='WhiteSmoke'><p align='left'><b><div align='left'>COBERTURA</div></b></p></td><td bgcolor='WhiteSmoke'><p align='left'><b><div align='left'>FRANQUIA</div></b></p></td><td bgcolor='WhiteSmoke'><p align='left'><b><div align='left'>LMI</div></b></p></td><td bgcolor='WhiteSmoke'><p align='left'><b><div align='left'>PRÊMIO</div></b></p></td></tr>"; + foreach (Cobertura item4 in observableCollection) + { + color++; + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><div align='left'>" + item4.Observacao + "</div></p></td><td style='white-space:nowrap; bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><div align='left'>" + $"{item4.Franquia:c}" + "</div></p></td><td style='white-space:nowrap; bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><div align='left'>" + $"{item4.Lmi:c}" + "</div></p></td><td style='white-space:nowrap; bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><div align='left'>" + $"{item4.Premio:c}" + "</div></p></td></tr>"; + } + html += "</font></table>"; + } + html += ((SepararPagina && SepararPaginaEnabled) ? "</div>" : ""); + } + if ((int)SelectedTipoExtrato != 2) + { + color = 0; + } + } + } + } + else + { + if ((!Endossos || !SomenteEndossos) && !sDocumento.Any((long x) => x == ((DomainBase)documento.Controle).Id)) + { + string text9 = ((documento.Controle.Cliente.Atividade == null) ? "NASCIMENTO" : "ABERTURA"); + bool pessoaFisica2 = documento.Controle.Cliente.PessoaFisica; + html = html + "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td width='" + (pessoaFisica2 ? "222" : "2500") + "' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' " + (pessoaFisica2 ? "" : "colspan='2'") + "><p align='left'><b>CLIENTE: </b>" + documento.Controle.Cliente.Nome + "</p></td><td width='" + (pessoaFisica2 ? "222" : "200") + "' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>CPF/CNPJ: </b>" + documento.Controle.Cliente.Documento + "</p></td><td width='" + (pessoaFisica2 ? "222" : "300") + "' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>" + text9 + ": </b>" + documento.Controle.Cliente.Nascimento?.ToShortDateString() + "</p></td>"; + if (pessoaFisica2) + { + html = html + "<td width='222' bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>FALECIDO: </b>" + (documento.Controle.Cliente.Falecido ? "SIM" : "NÃO") + "</p></td>"; + } + else + { + color++; + } + html += "</tr>"; + if (documento.Controle.Cliente.Atividade != null) + { + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' " + (pessoaFisica2 ? "" : "colspan='4'") + "><p align='left'><b>RAMO DE ATIVIDADE: </b>" + documento.Controle.Cliente.Atividade.Nome + "</p></td></tr>"; + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' " + (pessoaFisica2 ? "" : "colspan='4'") + ">"; + if (pessoaFisica2) + { + html = html + "<b>ESTADO CIVIL: </b>" + (documento.Controle.Cliente.EstadoCivil.HasValue ? documento.Controle.Cliente.EstadoCivil.ToString().ToUpper() : "-") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>SEXO: </b>" + (documento.Controle.Cliente.Sexo.HasValue ? documento.Controle.Cliente.Sexo.ToString().ToUpper() : "-") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'>"; + } + html = html + "<p align='left'><b>CLIENTE DESDE: </b>" + ((!documento.Controle.Cliente.ClienteDesde.HasValue) ? "-" : documento.Controle.Cliente.ClienteDesde?.ToShortDateString()) + "</p></td>"; + if (documento.Controle.Cliente.Profissao != null && (int)SelectedTipoExtrato != 2) + { + html = html + "<td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' > <p align='left'><b>PROFISSÃO: </b>" + documento.Controle.Cliente.Profissao.Nome + "</p></td>"; + } + else + { + color++; + } + html += "</tr>"; + } + if (pessoaFisica2) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>HABILITAÇÃO: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Habilitacao)) ? documento.Controle.Cliente.Habilitacao : "-") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>CATEGORIA: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.CategoriaHabilitacao)) ? documento.Controle.Cliente.CategoriaHabilitacao : "-") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>1ª HAB.: </b>" + ((!documento.Controle.Cliente.PrimeiraHabilitacao.HasValue) ? "-" : documento.Controle.Cliente.PrimeiraHabilitacao?.ToShortDateString()) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>VENCIMENTO: </b>" + ((!documento.Controle.Cliente.VencimentoHabilitacao.HasValue) ? "-" : documento.Controle.Cliente.VencimentoHabilitacao?.ToShortDateString()) + "</p></td></tr>"; + } + if (!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>RG: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ORGÃO EMISSOR: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Emissor)) ? documento.Controle.Cliente.Emissor : "-") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ESTADO EMISSOR: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.EstadoEmissor)) ? documento.Controle.Cliente.EstadoEmissor : "-") + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>EXPEDIÇÃO: </b>" + ((!documento.Controle.Cliente.Expedicao.HasValue) ? "-" : documento.Controle.Cliente.Expedicao?.ToShortDateString()) + "</p></td></tr>"; + } + if ((int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>BANCO: </b>" + ((documento.Controle.Cliente.Banco != null) ? documento.Controle.Cliente.Banco.Nome : "-") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>AGÊNCIA: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Agencia)) ? documento.Controle.Cliente.Agencia : "-") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>CONTA: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Conta)) ? documento.Controle.Cliente.Conta : "-") + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>TIPO: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.TipoConta)) ? documento.Controle.Cliente.TipoConta : "-") + "</p></td></tr>"; + } + if ((documento.Controle.Cliente.Telefones != null || documento.Controle.Cliente.Emails != null) && (int)SelectedTipoExtrato != 2) + { + html += "<tr>"; + if (documento.Controle.Cliente.Telefones != null) + { + string text10 = ""; + foreach (ClienteTelefone telefone3 in documento.Controle.Cliente.Telefones) + { + string[] obj10 = new string[10] { text10, "<br>", null, null, null, null, null, null, null, null }; + TipoTelefone? tipo = ((TelefoneBase)telefone3).Tipo; + object obj11; + if (!tipo.HasValue) + { + obj11 = null; + } + else + { + valueOrDefault = tipo.GetValueOrDefault(); + obj11 = ((object)(TipoTelefone)(ref valueOrDefault)).ToString().ToUpper(); + } + obj10[2] = (string)obj11; + obj10[3] = " ("; + obj10[4] = ((TelefoneBase)telefone3).Prefixo; + obj10[5] = ") "; + obj10[6] = ((TelefoneBase)telefone3).Numero; + obj10[7] = " ("; + obj10[8] = telefone3.Observacao; + obj10[9] = ") "; + text10 = string.Concat(obj10); + } + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>CONTATOS: </b>" + text10 + "</p></td>"; + } + if (documento.Controle.Cliente.Emails != null && !ExtratoResumido) + { + string text11 = ""; + foreach (ClienteEmail email3 in documento.Controle.Cliente.Emails) + { + text11 = text11 + "<br>" + ((EmailBase)email3).Email; + } + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>EMAILS: </b>" + text11 + "</p></td>"; + } + else if (documento.Controle.Cliente.Enderecos != null && (int)SelectedTipoExtrato != 2) + { + string text12 = ""; + foreach (ClienteEndereco endereco3 in documento.Controle.Cliente.Enderecos) + { + text12 = text12 + "<br>" + ((EnderecoBase)endereco3).Endereco + ", " + ((EnderecoBase)endereco3).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco3).Complemento) ? "" : (((EnderecoBase)endereco3).Complemento + ", ")) + ((EnderecoBase)endereco3).Bairro + " - " + ((EnderecoBase)endereco3).Cidade + " - " + ((EnderecoBase)endereco3).Estado + " - " + ((EnderecoBase)endereco3).Cep; + } + html = html + "<td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left'><b>ENDEREÇOS: </b>" + text12 + "</p></td>"; + } + color++; + html += "</tr>"; + } + if (documento.Controle.Cliente.Enderecos != null && (int)SelectedTipoExtrato != 2 && documento.Controle.Cliente.Emails == null && ExtratoResumido) + { + string text13 = ""; + foreach (ClienteEndereco endereco4 in documento.Controle.Cliente.Enderecos) + { + text13 = text13 + "<br>" + ((EnderecoBase)endereco4).Endereco + ", " + ((EnderecoBase)endereco4).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco4).Complemento) ? "" : (((EnderecoBase)endereco4).Complemento + ", ")) + ((EnderecoBase)endereco4).Bairro + " - " + ((EnderecoBase)endereco4).Cidade + " - " + ((EnderecoBase)endereco4).Estado + " - " + ((EnderecoBase)endereco4).Cep; + } + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left'><b>ENDEREÇOS: </b>" + text13 + "</p></td></tr>"; + } + if (documento.Controle.Cliente.Contatos != null && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + string text14 = ""; + foreach (MaisContato contato2 in documento.Controle.Cliente.Contatos) + { + string[] obj12 = new string[15] + { + text14, + "<br>NOME: ", + contato2.Nome, + (!string.IsNullOrWhiteSpace(contato2.Documento)) ? (", DOCUMENTO: " + contato2.Documento) : "", + contato2.Nascimento.HasValue ? (", NASCIMENTO: " + contato2.Nascimento?.ToShortDateString()) : "", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + object obj13; + if (!contato2.Parentesco.HasValue) + { + obj13 = ""; + } + else + { + Parentesco? parentesco = contato2.Parentesco; + object obj14; + if (!parentesco.HasValue) + { + obj14 = null; + } + else + { + Parentesco valueOrDefault2 = parentesco.GetValueOrDefault(); + obj14 = ((object)(Parentesco)(ref valueOrDefault2)).ToString().ToUpper(); + } + obj13 = ", PARENTESCO: " + (string?)obj14; + } + obj12[5] = (string)obj13; + obj12[6] = ((!string.IsNullOrWhiteSpace(contato2.Banco) || !string.IsNullOrWhiteSpace(contato2.Agencia) || !string.IsNullOrWhiteSpace(contato2.Conta)) ? "<br>" : ""); + obj12[7] = ((!string.IsNullOrWhiteSpace(contato2.Banco)) ? ("BANCO: " + contato2.Banco) : ""); + obj12[8] = ((!string.IsNullOrWhiteSpace(contato2.Agencia)) ? (((!string.IsNullOrWhiteSpace(contato2.Banco)) ? ", AGÊNCIA: " : "AGÊNCIA: ") + contato2.Agencia) : ""); + obj12[9] = ((!string.IsNullOrWhiteSpace(contato2.Conta)) ? (((!string.IsNullOrWhiteSpace(contato2.Banco) || !string.IsNullOrWhiteSpace(contato2.Agencia)) ? ", CONTA: " : "CONTA: ") + contato2.Conta) : ""); + obj12[10] = ((contato2.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato2.Prefixo) && !string.IsNullOrWhiteSpace(contato2.Telefone)) || !string.IsNullOrWhiteSpace(contato2.Email)) ? "<br>" : ""); + object obj15; + if (!contato2.Tipo.HasValue) + { + obj15 = ""; + } + else + { + TipoTelefone? tipo = contato2.Tipo; + object obj16; + if (!tipo.HasValue) + { + obj16 = null; + } + else + { + valueOrDefault = tipo.GetValueOrDefault(); + obj16 = ((object)(TipoTelefone)(ref valueOrDefault)).ToString().ToUpper(); + } + obj15 = "TIPO DO TELEFONE: " + (string?)obj16; + } + obj12[11] = (string)obj15; + obj12[12] = ((!string.IsNullOrWhiteSpace(contato2.Prefixo) && !string.IsNullOrWhiteSpace(contato2.Telefone)) ? ((contato2.Tipo.HasValue ? ", TELEFONE: (" : "TELEFONE: (") + contato2.Prefixo + ") " + contato2.Telefone) : ""); + obj12[13] = ((!string.IsNullOrWhiteSpace(contato2.Email)) ? (((contato2.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato2.Prefixo) && !string.IsNullOrWhiteSpace(contato2.Telefone))) ? ", EMAIL: " : "EMAIL: ") + contato2.Email) : ""); + obj12[14] = "<br>"; + text14 = string.Concat(obj12); + } + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left'><b>MAIS CONTATOS: </b>" + text14 + "</p></td></tr>"; + } + if (documento.Controle.Cliente.Enderecos != null && !ExtratoResumido) + { + string text15 = ""; + foreach (ClienteEndereco endereco5 in documento.Controle.Cliente.Enderecos) + { + text15 = text15 + "<br>" + ((EnderecoBase)endereco5).Endereco + ", " + ((EnderecoBase)endereco5).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco5).Complemento) ? "" : (((EnderecoBase)endereco5).Complemento + ", ")) + ((EnderecoBase)endereco5).Bairro + " - " + ((EnderecoBase)endereco5).Cidade + " - " + ((EnderecoBase)endereco5).Estado + " - " + ((EnderecoBase)endereco5).Cep; + } + html = html + "<td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left'><b>ENDEREÇOS: </b>" + text15 + "</p></td>"; + } + if (ObsCliente && ClienteVisibility && ObsClienteEnabled && !string.IsNullOrWhiteSpace(documento.Controle.Cliente.Observacao) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + documento.Controle.Cliente.Observacao = "<br>" + documento.Controle.Cliente.Observacao.Replace("\r\n", "<br>"); + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left' x-ms-format-detection='none'><b>OBSERVAÇÕES: </b>" + documento.Controle.Cliente.Observacao + "</p></td></tr>"; + } + if (!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Pasta) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left' x-ms-format-detection='none'><b>PASTA: </b>" + documento.Controle.Cliente.Pasta + "</p></td></tr>"; + } + html += "</font></table>"; + if (!primeiro) + { + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "</div>" : ""); + } + } + else + { + html = html + "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td width='333' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>CLIENTE: </b>" + documento.Controle.Cliente.Nome + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>RG: </b>" + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "</p></td><td width='222' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left' x-ms-format-detection='none'><b>CPF/CNPJ: </b>" + documento.Controle.Cliente.Documento + "</p></td></tr></font></table>"; + } + if ((int)SelectedTipoExtrato == 0) + { + return; + } + color = 0; + html = html + "<hr style='width:999; border-top: 3px solid #000'><table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>RAMO: </b>" + documento.Controle.Ramo.Nome + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>VIGÊNCIA INICIAL: </b>" + documento.Vigencia1.ToShortDateString() + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>VIGÊNCIA FINAL: </b>" + ((!documento.Vigencia2.HasValue) ? "-" : documento.Vigencia2?.ToShortDateString()) + "</p></td></tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>CONTRATO: </b>" + (string.IsNullOrWhiteSpace(documento.Apolice) ? "-" : documento.Apolice) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>POSSUI ENDOSSO? </b>" + (documento.TemEndosso ? "SIM" : "NÃO") + "</p></td></tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left' x-ms-format-detection='none'><b>ADITAMENTO: </b>" + ((!string.IsNullOrWhiteSpace(documento.Endosso)) ? documento.Endosso : ((configEndosso && documento.Controle.Documentos.Where((Documento x) => !x.Excluido && x.Ordem != 0).ToList().Count > 0) ? documento.Controle.Documentos.Last((Documento x) => !x.Excluido && x.Ordem != 0).Endosso : "-")) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>APÓLICE ANTERIOR: </b>" + (string.IsNullOrWhiteSpace(documento.ApoliceAnterior) ? "-" : documento.ApoliceAnterior) + "</p></td></tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>BANCO: </b>" + ((documento.Banco == null) ? "-" : documento.Banco.Nome) + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>AGÊNCIA: </b>" + (string.IsNullOrWhiteSpace(documento.Agencia) ? "-" : documento.Agencia) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>CONTA: </b>" + (string.IsNullOrWhiteSpace(documento.Conta) ? "-" : documento.Conta) + "</p></td></tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>NUMERO CARTÃO: </b>" + (string.IsNullOrWhiteSpace(documento.NumeroCartao) ? "-" : documento.NumeroCartao) + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>VENCIMENTO: </b>" + (string.IsNullOrWhiteSpace(documento.VencimentoCartao) ? "-" : documento.VencimentoCartao) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>BANDEIRA: </b>" + ((!documento.Bandeira.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)documento.Bandeira)) + "</p></td></tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left' x-ms-format-detection='none'><b>TITULAR/PROPONENTE: </b>" + (string.IsNullOrWhiteSpace(documento.NomeProponente) ? "-" : documento.NomeProponente) + "</p></td></tr>"; + if (!documento.NegocioCorretora.HasValue) + { + documento.NegocioCorretora = (NegocioCorretora)(((int)documento.Situacao == 2 && documento.Negocio.HasValue && (int)documento.Negocio.GetValueOrDefault() == 1) ? 1 : 0); + } + if (ComissaoDocumento && ComissaoDocumentoEnabled) + { + if ((int)SelectedTipoExtrato != 2) + { + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>NEGÓCIO CORRETORA: </b>" + ValidationHelper.GetDescription((Enum)(object)documento.NegocioCorretora) + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>STATUS DO SEGURO: </b>" + ValidationHelper.GetDescription((Enum)(object)documento.Situacao) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>COMISSÃO: </b>" + $"{documento.Comissao}%" + "</p></td>"; + } + else + { + html = html + "<td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>COMISSÃO: </b>" + $"{documento.Comissao}%" + "</p></td>"; + } + } + else if ((int)SelectedTipoExtrato != 2) + { + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>NEGÓCIO CORRETORA: </b>" + ValidationHelper.GetDescription((Enum)(object)documento.NegocioCorretora) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>STATUS DO SEGURO: </b>" + ValidationHelper.GetDescription((Enum)(object)documento.Situacao) + "</p></td>"; + } + html = html + "</tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>VENDEDOR: </b>" + ((documento.VendedorPrincipal == null) ? "-" : documento.VendedorPrincipal.Nome) + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>REMESSA: </b>" + ((!documento.Remessa.HasValue) ? "-" : documento.Remessa?.ToShortDateString()) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>EMISSÃO: </b>" + ((!documento.Emissao.HasValue) ? "-" : documento.Emissao?.ToShortDateString()) + "</p></td></tr>"; + if ((int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html += "<tr>"; + string text16 = ""; + if (documento.Estipulante1 != null) + { + text16 = text16 + documento.Estipulante1.Nome + ", "; + } + if (documento.Estipulante2 != null) + { + text16 = text16 + documento.Estipulante2.Nome + ", "; + } + if (documento.Estipulante3 != null) + { + text16 = text16 + documento.Estipulante3.Nome + ", "; + } + if (documento.Estipulante4 != null) + { + text16 = text16 + documento.Estipulante4.Nome + ", "; + } + if (documento.Estipulante5 != null) + { + text16 = text16 + documento.Estipulante5.Nome + ", "; + } + if (!string.IsNullOrWhiteSpace(text16)) + { + int startIndex3 = text16.LastIndexOf(", ", StringComparison.Ordinal); + text16 = text16.Remove(startIndex3, 2).Insert(startIndex3, "."); + } + html = html + "<td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>ESTIPULANTE(S): </b>" + (string.IsNullOrWhiteSpace(text16) ? "-" : text16) + "</p></td></tr>"; + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>SEGURADORA: </b>" + documento.Controle.Seguradora.Nome + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>APÓLICE SINISTRADA: </b>" + (documento.Sinistro ? "SIM" : "NÃO") + "</p></td></tr>"; + if (documento.Controle.SeguradoraAnterior != null && !ExtratoResumido) + { + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>SEGURADORA ANTERIOR: </b>" + documento.Controle.SeguradoraAnterior.Nome + "</p></td></tr>"; + } + } + else + { + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>SEGURADORA: </b>" + documento.Controle.Seguradora.Nome + "</p></td></tr>"; + } + html += "</font></table>"; + if (!ExtratoResumido && (PremioParcela || ObsApoliceEnabled)) + { + html += "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'>"; + if (PremioParcela) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>PRÊMIO LÍQUIDO: </b><br/>" + documento.PremioLiquido.ToString("c") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ADICIONAL: </b><br/>" + documento.PremioAdicional.ToString("c") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>CUSTO APÓLICE: </b><br/>" + documento.Custo.ToString("c") + "</p></td><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>I.O.F.: </b><br/>" + documento.Iof.ToString("c") + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'" + ((ComissaoDocumento && ComissaoDocumentoEnabled) ? "" : " colspan='2'") + "><p align='left'><b>PRÊMIO TOTAL: </b><br/>" + documento.PremioTotal.ToString("c") + "</p></td>"; + html += "</tr>"; + html += "</font></table><br>"; + ObservableCollection<Parcela> parcelas = documento.Parcelas; + if (parcelas != null && parcelas.Count > 0) + { + html += "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td bgcolor='WhiteSmoke'><p align='left'><b><div align='center'>PARCELA</div></b></p></td><td bgcolor='WhiteSmoke'><p align='left'><b><div align='center'>VENCIMENTO</div></b></p></td><td bgcolor='WhiteSmoke'><p align='left'><b><div align='center'>VALOR</div></b></p></td><td bgcolor='WhiteSmoke'><p align='left'><b><div align='center'>FORMA DE PAGAMENTO</div></b></p></td></tr>"; + foreach (Parcela parcela in documento.Parcelas) + { + html = html + "<tr><td bgcolor='White'><p align='left'><div align='center'>" + parcela.NumeroParcela + "</div></p></td><td bgcolor='White'><p align='left'><div align='center'>" + parcela.Vencimento.ToShortDateString() + "</div></p></td><td bgcolor='White'><p align='left'><div align='center'>" + $"{parcela.Valor:c}" + "</div></p></td><td bgcolor='White'><p align='left'><div align='center'>" + ValidationHelper.GetDescription((Enum)(object)documento.FormaPagamento) + "</div></p></td></tr>"; + } + } + } + if (ObsApolice && ObsApoliceEnabled) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='6'><p align='left' x-ms-format-detection='none'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(documento.Observacao) ? "-" : documento.Observacao) + "</p></td></tr>"; + } + html += "</font></table>"; + } + if (PerfilCondutor && PerfilVisibility && ((DomainBase)documento.Controle.Ramo).Id == 5 && PerfilCondutorEnabled) + { + List<Perfil> list4 = source.ToList(); + foreach (Perfil item5 in list4) + { + color = 0; + if (!string.IsNullOrEmpty(item5.Nome)) + { + html = html + "<hr style='width:999; border-top: 2px solid #ccc'><table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td width='333' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>" + $"CONDUTOR {list4.IndexOf(item5) + 1}: " + "</b>" + item5.Nome + "</p></td><td width='222' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>CPF: </b>" + (string.IsNullOrWhiteSpace(item5.Cpf) ? "-" : item5.Cpf) + "</p></td><td width='222' bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>NASCIMENTO: </b>" + ((!item5.Nascimento.HasValue) ? "-" : item5.Nascimento?.ToShortDateString()) + "</p></td></tr><tr><td width='333' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ESTADO CIVIL: </b>" + ((!item5.EstadoCivil.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.EstadoCivil)) + "</p></td><td width='222' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>SEXO: </b>" + ((!item5.Sexo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.Sexo)) + "</p></td><td width='222' bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>RELAÇÃO SEGURADO/CONDUTOR: </b>" + ValidationHelper.GetDescription((Enum)(object)item5.Relacao) + "</p></td></tr><tr><td width='333' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>HABILITAÇÃO: </b>" + (string.IsNullOrWhiteSpace(item5.Habilitacao) ? "-" : item5.Habilitacao) + "</p></td><td width='222' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>TEMPO DE HABILITAÇÃO: </b>" + ((!item5.TempoHabilitacao.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.TempoHabilitacao)) + "</p></td><td width='222' bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>QUATIDADE DE VEÍCULOS: </b>" + ((!item5.VeiculoResidencia.HasValue) ? "-" : item5.VeiculoResidencia.Value.ToString()) + "</p></td></tr><tr><td width='333' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>GARAGEM NA RESIDÊNCIA: </b>" + ((!item5.GaragemResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.GaragemResidencia)) + "</p></td><td width='222' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>GARAGEM NO TRABALHO: </b>" + ((!item5.GaragemTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.GaragemTrabalho)) + "</p></td><td width='222' bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>GARAGEM NO ESTUDO: </b>" + ((!item5.GaragemEstudo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.GaragemEstudo)) + "</p></td></tr><tr><td width='333' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>TIPO DE RESIDÊNCIA: </b>" + ((!item5.TipoResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.TipoResidencia)) + "</p></td><td width='222' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>QUILOMETRAGEM MENSAL: </b>" + (string.IsNullOrWhiteSpace(item5.KmMensal) ? "-" : item5.KmMensal) + "</p></td><td width='222' bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>DISTÂNCIA ATÉ O TRABALHO: </b>" + ((!item5.DistanciaResidenciaTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.DistanciaResidenciaTrabalho)) + "</p></td></tr><tr><td width='333' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>USO PROFISSIONAL: </b>" + ((item5.UsoProfissional.HasValue && item5.UsoProfissional.Value) ? "SIM" : "NÃO") + "</p></td><td width='222' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>USO POR DEPENDENTES: </b>" + ((!item5.UsoDependentes.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.UsoDependentes)) + "</p></td><td width='222' bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>OCUPAÇÃO: </b>" + ((!item5.Ocupacao.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.Ocupacao)) + "</p></td></tr><tr><td width='333' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>SEGURO VIDA: </b>" + ((item5.SeguroVida.HasValue && item5.SeguroVida.Value) ? "SIM" : "NÃO") + "</p></td><td width='222' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ISENÇÃO DE IMPOSTOS: </b>" + ((item5.Isencao.HasValue && item5.Isencao.Value) ? "SIM" : "NÃO") + "</p></td><td width='222' bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>ANTIFURTO: </b>" + (item5.AntiFurto.HasValue ? ValidationHelper.GetDescription((Enum)(object)item5.AntiFurto) : "") + "</p></td></tr><tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>COBERTURA ESTENDIDA PARA RESIDENTES HABILITADOS: </b>" + ((item5.EstenderCobertura.HasValue && item5.EstenderCobertura.Value) ? "SIM" : "NÃO") + "</p></td></tr></font></table>"; + } + } + } + List<Item> itens2 = itensDocumentos.ToList(); + if (itens2.Count == 0) + { + html += "<br><p align='center'><b>ESTA APÓLICE NÃO POSSUI ITENS</b></p>"; + } + else + { + color = 0; + foreach (Item item2 in itens2) + { + if (item2.Sinistros.Count > 0) + { + Item val3 = item2; + val3.Sinistros = await new SinistroServico().BuscarControles(((DomainBase)item2).Id); + } + html += ((SepararPagina && SepararPaginaEnabled) ? "<div style='page-break-before:always;'>" : ""); + html += (((int)SelectedTipoExtrato != 2 || itens2.IndexOf(item2) == 0) ? "<br>" : ""); + html += "<table border='1' bordercolor='#ededed' width='999'>"; + html += "<style> td > p { margin: 2px; }</style>"; + html += "<font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr>"; + if ((int)SelectedTipoExtrato == 2) + { + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>" + $"ITEM {item2.Ordem}: " + "</b>" + item2.Descricao + "</p></td>"; + } + else + { + switch (((DomainBase)documento.Controle.Ramo).Id) + { + case 1L: + case 2L: + case 3L: + case 15L: + case 18L: + { + Item val3 = item2; + val3.Patrimonial = await new ItemServico().BuscaPatrimonial(((DomainBase)item2).Id); + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='4'><p align='left'><b>" + $"ITEM {item2.Ordem}: " + "</b>" + ((EnderecoBase)item2.Patrimonial).Endereco + ", " + ((EnderecoBase)item2.Patrimonial).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)item2.Patrimonial).Complemento) ? "" : (((EnderecoBase)item2.Patrimonial).Complemento + ", ")) + ((EnderecoBase)item2.Patrimonial).Bairro + " - " + ((EnderecoBase)item2.Patrimonial).Cidade + " - " + ((EnderecoBase)item2.Patrimonial).Estado + " - " + ((EnderecoBase)item2.Patrimonial).Cep + "</p></td>"; + break; + } + case 5L: + case 37L: + { + Item val3 = item2; + val3.Auto = await new ItemServico().BuscaAuto(((DomainBase)item2).Id); + string[] obj17 = new string[26] + { + html, + "<td bgcolor='", + (color % 2 == 0) ? "WhiteSmoke" : "White", + "' colspan='4'><p align='left'><b>", + $"ITEM {item2.Ordem}: ", + "</b><br>", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + Fabricante fabricante2 = item2.Auto.Fabricante; + obj17[6] = ((fabricante2 != null) ? fabricante2.Descricao : null); + obj17[7] = " "; + obj17[8] = item2.Auto.Modelo; + obj17[9] = " ("; + obj17[10] = item2.Auto.AnoFabricacao; + obj17[11] = "/"; + obj17[12] = item2.Auto.AnoModelo; + obj17[13] = ")<br>PLACA: "; + obj17[14] = item2.Auto.Placa; + obj17[15] = ", CHASSI: "; + obj17[16] = item2.Auto.Chassi; + obj17[17] = "<br>C.I.: "; + obj17[18] = item2.Auto.Ci; + obj17[19] = ", RENAVAM: "; + obj17[20] = item2.Auto.Renavam; + obj17[21] = ", CEP PERNOITE: "; + obj17[22] = item2.Auto.CepPernoite; + obj17[23] = "<br>FINANCIADO: "; + obj17[24] = (item2.Auto.Financiado.GetValueOrDefault() ? "SIM" : "NÃO"); + obj17[25] = "</p></td>"; + html = string.Concat(obj17); + break; + } + default: + html = html + "<td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='4'><p align='left'><b>" + $"ITEM {item2.Ordem}: " + "</b>" + item2.Descricao + "</p>QTDE SINISTRO(S): </b>" + item2.Sinistros.Count + "</p></td>"; + break; + } + } + if (item2.Sinistros.Count > 0) + { + Item obj18 = item2; + DateTime? obj19; + if (obj18 == null) + { + obj19 = null; + } + else + { + IList<ControleSinistro> sinistros3 = obj18.Sinistros; + if (sinistros3 == null) + { + obj19 = null; + } + else + { + ControleSinistro? obj20 = sinistros3.LastOrDefault(); + if (obj20 == null) + { + obj19 = null; + } + else + { + List<Sinistro> sinistros4 = obj20.Sinistros; + if (sinistros4 == null) + { + obj19 = null; + } + else + { + Sinistro? obj21 = sinistros4.LastOrDefault(); + obj19 = ((obj21 != null) ? obj21.DataReclamacao : null); + } + } + } + } + DateTime? dateTime2 = obj19; + string text17 = (dateTime2.HasValue ? dateTime2.Value.ToShortDateString() : "-"); + string[] obj22 = new string[18] + { + html, "</tr><td bgcolor='", null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null + }; + int num2 = color + 1; + color = num2; + obj22[2] = ((num2 % 2 == 0) ? "WhiteSmoke" : "White"); + obj22[3] = "'><p align='left'><b>SINISTRO STATUS: </b>"; + Item obj23 = item2; + object obj24; + if (obj23 == null) + { + obj24 = null; + } + else + { + IList<ControleSinistro> sinistros5 = obj23.Sinistros; + if (sinistros5 == null) + { + obj24 = null; + } + else + { + ControleSinistro? obj25 = sinistros5.LastOrDefault(); + if (obj25 == null) + { + obj24 = null; + } + else + { + List<Sinistro> sinistros6 = obj25.Sinistros; + if (sinistros6 == null) + { + obj24 = null; + } + else + { + Sinistro? obj26 = sinistros6.LastOrDefault(); + obj24 = ((obj26 != null) ? ValidationHelper.GetDescription((Enum)(object)obj26.StatusSinistro) : null); + } + } + } + } + obj22[4] = (string)obj24; + obj22[5] = "</p></td><td bgcolor='"; + obj22[6] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + obj22[7] = "'><p align='left'><b>DATA: </b>"; + obj22[8] = text17; + obj22[9] = "</p></td><td bgcolor='"; + obj22[10] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + obj22[11] = "'><p align='left'><b>VALOR: </b>"; + Item obj27 = item2; + object obj28; + if (obj27 == null) + { + obj28 = null; + } + else + { + IList<ControleSinistro> sinistros7 = obj27.Sinistros; + if (sinistros7 == null) + { + obj28 = null; + } + else + { + ControleSinistro? obj29 = sinistros7.LastOrDefault(); + if (obj29 == null) + { + obj28 = null; + } + else + { + List<Sinistro> sinistros8 = obj29.Sinistros; + if (sinistros8 == null) + { + obj28 = null; + } + else + { + Sinistro? obj30 = sinistros8.LastOrDefault(); + obj28 = ((obj30 != null) ? ValidationHelper.ToCurrency<decimal>(obj30.Valor, "pt-BR") : null); + } + } + } + } + obj22[12] = (string)obj28; + obj22[13] = "</p></td><td bgcolor='"; + obj22[14] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + obj22[15] = "' colspan='3'><p align='left'><b>QTDE SINISTRO(S): </b>"; + obj22[16] = item2.Sinistros.Count.ToString(); + obj22[17] = "</p></td>"; + html = string.Concat(obj22); + } + html += "</tr>"; + if ((int)SelectedTipoExtrato != 2) + { + string[] obj31 = new string[10] { html, "<tr><td bgcolor='", null, null, null, null, null, null, null, null }; + int num2 = color + 1; + color = num2; + obj31[2] = ((num2 % 2 == 0) ? "WhiteSmoke" : "White"); + obj31[3] = "' colspan='3'><p align='left'><b>STATUS: </b>"; + obj31[4] = (string.IsNullOrWhiteSpace(item2.Status) ? item2.StatusInclusao : item2.Status); + obj31[5] = "</p></td><td bgcolor='"; + obj31[6] = ((color++ % 2 == 0) ? "WhiteSmoke" : "White"); + obj31[7] = "'><p align='left'><b>ATIVO: </b>"; + obj31[8] = ((!item2.Substituido.HasValue) ? "SIM" : "NÃO"); + obj31[9] = "</p></td></tr>"; + html = string.Concat(obj31); + long id = ((DomainBase)documento.Controle.Ramo).Id; + long num4 = id - 1; + if ((ulong)num4 <= 58uL) + { + switch (num4) + { + case 0L: + case 1L: + case 2L: + case 14L: + case 17L: + if (ObsItem && ObsItemEnabled) + { + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.Patrimonial.Item.Observacao) ? "-" : item2.Patrimonial.Item.Observacao) + "</p></td><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>BENS E INFORMAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.Patrimonial.Bens) ? "-" : item2.Patrimonial.Bens) + "</p></td></tr>"; + } + break; + case 4L: + case 36L: + { + if (ObsItem && ObsItemEnabled) + { + html = html + "<tr><td bgcolor='" + ((color++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.Auto.Observacao) ? "-" : item2.Auto.Observacao) + "</p></td></tr>"; + } + string[] array2 = new string[30]; + array2[0] = html; + array2[1] = "<tr><td bgcolor='"; + array2[2] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + array2[3] = "' colspan='3'><p align='left'><b>COBERTURA PADRÃO: </b>"; + TipoCobertura? tipoCobertura = item2.Auto.TipoCobertura; + array2[4] = (tipoCobertura.HasValue ? ValidationHelper.GetDescription((Enum)(object)tipoCobertura.GetValueOrDefault()) : null); + array2[5] = "</p></td><td bgcolor='"; + array2[6] = ((color++ % 2 == 0) ? "WhiteSmoke" : "White"); + array2[7] = "'><p align='left'><b>BÔNUS: </b>"; + array2[8] = item2.Auto.Bonus.ToString(); + array2[9] = "</p></td></tr><tr><td bgcolor='"; + array2[10] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + array2[11] = "'colspan='2'><p align='left'><b>REGIÃO DE CIRCULAÇÃO: </b>"; + array2[12] = (string.IsNullOrWhiteSpace(item2.Auto.RegiaoCirculacao) ? "-" : item2.Auto.RegiaoCirculacao); + array2[13] = "</p></td><td bgcolor='"; + array2[14] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + array2[15] = "'><p align='left'><b>TABELA DE REFERÊNCIA: </b>"; + TabelaReferencia? tabelaReferencia = item2.Auto.TabelaReferencia; + array2[16] = (tabelaReferencia.HasValue ? ValidationHelper.GetDescription((Enum)(object)tabelaReferencia.GetValueOrDefault()) : null); + array2[17] = "</p></td><td bgcolor='"; + array2[18] = ((color++ % 2 == 0) ? "WhiteSmoke" : "White"); + array2[19] = "'><p align='left'><b>% DE REFERÊNCIA: </b>"; + array2[20] = $"{item2.Auto.PorcentagemReferencia}%"; + array2[21] = "</p></td></tr><tr><td bgcolor='"; + array2[22] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + array2[23] = "' colspan='3'><p align='left'><b>CÓDIGO FIPE: </b>"; + array2[24] = (string.IsNullOrWhiteSpace(item2.Auto.Fipe) ? "-" : item2.Auto.Fipe); + array2[25] = "</p></td><td bgcolor='"; + array2[26] = ((color % 2 == 0) ? "WhiteSmoke" : "White"); + array2[27] = "'><p align='left'><b>COR DO VEÍCULO: </b>"; + array2[28] = ((!item2.Auto.Cor.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item2.Auto.Cor)); + array2[29] = "</p></td></tr>"; + html = string.Concat(array2); + break; + } + case 5L: + case 6L: + case 8L: + case 9L: + case 52L: + { + Item val3 = item2; + val3.Vida = await new ItemServico().BuscaVida(((DomainBase)item2).Id); + if (!item2.Sinistrado || !BeneficiariosItens || !BeneficiariosItensEnabled) + { + break; + } + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>BENEFICIÁRIOS: </b>"; + string text18 = ""; + foreach (ControleSinistro sinistro3 in item2.Sinistros) + { + if (sinistro3.Sinistros == null) + { + continue; + } + foreach (Sinistro sinistro4 in sinistro3.Sinistros) + { + if (!string.IsNullOrWhiteSpace(sinistro4.SinistroVida.Beneficiario)) + { + text18 = text18 + sinistro4.SinistroVida.Beneficiario + ", "; + } + } + } + if (!string.IsNullOrWhiteSpace(text18)) + { + int startIndex4 = text18.LastIndexOf(", ", StringComparison.Ordinal); + text18 = text18.Remove(startIndex4, 2).Insert(startIndex4, "."); + } + html = html + text18 + "</p></td></tr>"; + break; + } + case 3L: + case 7L: + case 15L: + case 16L: + case 18L: + case 22L: + case 23L: + case 25L: + case 27L: + case 30L: + case 32L: + case 38L: + case 40L: + case 43L: + case 48L: + case 58L: + { + Item val3 = item2; + val3.RiscosDiversos = await new ItemServico().BuscaRiscosDiversos(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.RiscosDiversos.Observacao) ? "-" : item2.RiscosDiversos.Observacao) + "</p></td></tr>"; + } + break; + } + case 12L: + { + Item val3 = item2; + val3.Aeronautico = await new ItemServico().BuscaAeronautico(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.Aeronautico.Observacao) ? "-" : item2.Aeronautico.Observacao) + "</p></td></tr>"; + } + break; + } + case 19L: + { + Item val3 = item2; + val3.Granizo = await new ItemServico().BuscaGranizo(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + "<tr><td bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>OBSERVAÇÕES: </b>" + (string.IsNullOrWhiteSpace(item2.Granizo.Observacao) ? "-" : item2.Granizo.Observacao) + "</p></td></tr>"; + } + break; + } + } + } + } + html += "</font></table>"; + if ((int)SelectedTipoExtrato != 2) + { + ObservableCollection<Cobertura> observableCollection2 = await new ItemServico().BuscarCoberturasPorItemAsync(((DomainBase)item2).Id); + if (observableCollection2.Count > 0 && Coberturas) + { + html += "<br><table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td bgcolor='WhiteSmoke'><p align='left'><b><div align='center'>COBERTURA</div></b></p></td><td bgcolor='WhiteSmoke'><p align='left'><b><div align='center'>FRANQUIA</div></b></p></td><td bgcolor='WhiteSmoke'><p align='left'><b><div align='center'>L.M.I.</div></b></p></td><td bgcolor='WhiteSmoke'><p align='left'><b><div align='center'>PRÊMIO</div></b></p></td></tr>"; + foreach (Cobertura item6 in observableCollection2) + { + html = html + "<tr><td bgcolor='White'><p align='left'><div align='center'>" + item6.Observacao + "</div></p></td><td bgcolor='White'><p align='left'><div align='center'>" + $"{item6.Franquia:c}" + "</div></p></td><td bgcolor='White'><p align='left'><div align='center'>" + $"{item6.Lmi:c}" + "</div></p></td><td bgcolor='White'><p align='left'><div align='center'>" + $"{item6.Premio:c}" + "</div></p></td></tr>"; + } + html += "</font></table>"; + } + html += ((SepararPagina && SepararPaginaEnabled) ? "</div>" : ""); + } + if ((int)SelectedTipoExtrato != 2) + { + color = 0; + } + } + } + } + } + sDocumento.Add(((DomainBase)documento.Controle).Id); + primeiro = false; + } + } + if (Prospeccoes != null && Prospeccoes.Count > 0) + { + foreach (Prospeccao prospecco in Prospeccoes) + { + int num5 = 0; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "<div style='page-break-before:always;'>" : ""); + html += "<table border='0' width='999'><td height='20' width='999' bgcolor='black'><h4 style='text-align: center; color: white; background-color: black'>"; + if ((int)SelectedTipoExtrato == 0) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE: " + prospecco.Nome; + } + html = html + title + "</h4></td></table><br>"; + html += "<style>td > p {margin: 2px;}</style>"; + if (ExtratoResumido) + { + html = html + "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td width='333' bgcolor='" + ((num5 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>CLIENTE: </b>" + prospecco.Nome + "</p></td><td width='222' bgcolor='" + ((num5++ % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left' x-ms-format-detection='none'><b>CPF/CNPJ: </b>" + prospecco.Documento + "</p></td></tr>"; + if ((int)SelectedTipoExtrato != 2) + { + html += "<tr>"; + string text19 = ""; + if (prospecco.Telefone1 != null) + { + text19 = text19 + "<br> (" + prospecco.Prefixo1 + ") " + prospecco.Telefone1; + } + if (prospecco.Telefone2 != null) + { + text19 = text19 + "<br> (" + prospecco.Prefixo2 + ") " + prospecco.Telefone2; + } + html = html + "<td bgcolor='" + ((num5 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>CONTATOS: </b>" + (string.IsNullOrEmpty(text19) ? "-" : text19) + "</p></td>"; + string text20 = ""; + if (prospecco.Email != null) + { + text20 = "<br>" + prospecco.Email; + } + html = html + "<td bgcolor='" + ((num5 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>EMAILS: </b>" + (string.IsNullOrEmpty(text20) ? "-" : text20) + "</p></td>"; + } + html += "</font></table>"; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "</div>" : ""); + if ((int)SelectedTipoExtrato == 0) + { + return; + } + num5 = 0; + html = html + "<hr style='width:999; border-top: 3px solid #000'><table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td width='222' bgcolor='" + ((num5++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>VIGÊNCIA FINAL: </b>" + ((!prospecco.VigenciaFinal.HasValue) ? "-" : prospecco.VigenciaFinal?.ToShortDateString()) + "</p></td></tr>"; + html = html + "</tr><tr><td bgcolor='" + ((num5 % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='3'><p align='left'><b>VENDEDOR: </b>" + ((prospecco.Vendedor == null) ? "-" : prospecco.Vendedor.Nome) + "</p></td></tr>"; + html += "</font></table>"; + continue; + } + string text21 = "NASCIMENTO"; + html = html + "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td width='333' bgcolor='" + ((num5 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>CLIENTE: </b>" + prospecco.Nome + "</p></td><td width='222' bgcolor='" + ((num5 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left' x-ms-format-detection='none'><b>CPF/CNPJ: </b>" + prospecco.Documento + "</p></td><td width='222' bgcolor='" + ((num5 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>" + text21 + ": </b>" + prospecco.Nascimento?.ToShortDateString() + "</p></td></tr>"; + if ((prospecco.Telefone1 != null || prospecco.Email != null) && (int)SelectedTipoExtrato != 2) + { + html += "<tr>"; + if (prospecco.Telefone1 != null) + { + string text22 = ""; + text22 = text22 + "<br> (" + prospecco.Prefixo1 + ") " + prospecco.Telefone1; + if (prospecco.Telefone2 != null) + { + text22 = text22 + "<br> (" + prospecco.Prefixo2 + ") " + prospecco.Telefone2; + } + html = html + "<td bgcolor='" + ((num5 % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>CONTATOS: </b>" + text22 + "</p></td>"; + } + if (prospecco.Email != null && !ExtratoResumido) + { + string text23 = ""; + text23 = text23 + "<br>" + prospecco.Email; + html = html + "<td bgcolor='" + ((num5 % 2 == 0) ? "WhiteSmoke" : "White") + "' colspan='2'><p align='left'><b>EMAILS: </b>" + text23 + "</p></td>"; + } + html += "</font></tr>"; + } + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "</div>" : ""); + if ((int)SelectedTipoExtrato == 0) + { + return; + } + num5 = 0; + html = html + "<hr style='width:999; border-top: 3px solid #000'><table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'><tr><td width='222' bgcolor='" + ((num5++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>VIGÊNCIA FINAL: </b>" + ((!prospecco.VigenciaFinal.HasValue) ? "-" : prospecco.VigenciaFinal?.ToShortDateString()) + "</p></td></tr>"; + html = html + "</tr><tr><td bgcolor='" + ((num5 % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>VENDEDOR: </b>" + ((prospecco.Vendedor == null) ? "-" : prospecco.Vendedor.Nome) + "</p></td></tr>"; + html += "</font></table>"; + } + } + DateTime networkTime2 = Funcoes.GetNetworkTime(); + html = html + "<br><font face='Verdana' size='1'><br>" + Recursos.Usuario.Nome + " - " + networkTime2.Date.ToShortDateString() + "</font></div><script src='https://code.jquery.com/jquery-3.3.1.slim.min.js' integrity='sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo' crossorigin='anonymous'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js' integrity='sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1' crossorigin='anonymous'></script><script src='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js' integrity='sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM' crossorigin='anonymous'></script></body></html>"; + string tempPath2 = Path.GetTempPath(); + string text24 = $"{tempPath2}{(object)(TipoExtrato)0}_{networkTime2:ddMMyyyyhhmmss}.html"; + if (pdf) + { + text24 = $"{tempPath2}{(object)(TipoExtrato)0}_{networkTime2:ddMMyyyyhhmmss}.pdf"; + byte[] bytes2 = ((HtmlToPdfConverter)new NRecoHtmlToPdfConverter()).GeneratePdf(html); + File.WriteAllBytes(text24, bytes2); + } + else + { + StreamWriter streamWriter2 = new StreamWriter(text24, append: true, Encoding.UTF8); + streamWriter2.Write(html); + streamWriter2.Close(); + } + Process.Start(text24); + if (Documentos != null && Documentos.Count > 1) + { + RegistrarAcao("GEROU O EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " " + ((Documentos == null) ? "" : ((Documentos.Count > 1) ? $"DE {Documentos.Count} DOCUMENTOS" : $"DO DOCUMENTO {((DomainBase)Documentos[0]).Id}")), 0L, (TipoTela)23, "IDS DOS DOCUMENTOS:\n" + string.Join("\n", Documentos.Select((Documento x) => ((DomainBase)x).Id)) + GerarOpcoes()); + } + if (Prospeccoes != null && Prospeccoes.Count > 1) + { + RegistrarAcao("GEROU O EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " " + ((Prospeccoes == null) ? "" : ((Prospeccoes.Count > 1) ? $"DE {Prospeccoes.Count} PROSPECÇÕES" : $"DA PROSPÇÃO{((DomainBase)Prospeccoes[0]).Id}")), 0L, (TipoTela)23, "IDS DOS DOCUMENTOS:\n" + string.Join("\n", Prospeccoes.Select((Prospeccao x) => ((DomainBase)x).Id)) + GerarOpcoes()); + } + Documentos = null; + Clientes = null; + Prospeccoes = null; + } + } + + public string GerarOpcoes() + { + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: Unknown result type (might be due to invalid IL or missing references) + //IL_008f: Unknown result type (might be due to invalid IL or missing references) + string text = ""; + if (ClienteVisibility && ObsCliente && ObsClienteEnabled) + { + text += "\nOBSERVAÇÕES DO CLIENTE"; + } + if ((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) + { + text += "\nSEPARAR CLIENTES POR PÁGINA"; + } + if (DocumentoVisibility) + { + if (ComissaoDocumentoEnabled && ComissaoDocumento) + { + text += "\nCOMISSÕES DO DOCUMENTO"; + } + if (ObsApoliceEnabled && ObsApolice) + { + text += "\nOBSERVAÇÕES DA APÓLICE"; + } + if ((int)SegurosVigentesVisibility == 0 && SegurosVigentes) + { + text += "\nAPENAS SEGUROS VIGENTES"; + } + } + if (ItemVisibility) + { + if ((int)SelecionarItensVisibility == 0 && SelecionarItens) + { + text += "\nSELECIONAR ITENS"; + } + if (BeneficiariosItensEnabled && BeneficiariosItens) + { + text += "\nBENEFICIÁRIOS DOS ITENS"; + } + if (ObsItemEnabled && ObsItem) + { + text += "\nOBSERVAÇÕES DO ITEM"; + } + if (SepararPaginaEnabled && SepararPagina) + { + text += "\nSEPARAR ITENS POR PÁGINA"; + } + } + if (PerfilCondutor && PerfilVisibility && PerfilCondutorEnabled) + { + text += "\nPERFIL DO CONDUTOR"; + } + if (string.IsNullOrWhiteSpace(text)) + { + return ""; + } + return "\n\nOPÇÕES:" + text; + } + + public async Task PrepararExtrato(List<ClientesAtivosInativos> clientes, List<Documento> documentos, List<Prospeccao> prospeccoes, Relatorio? tipoRelatorio = null, List<long> selecionadosDoc = null, List<long> selecionadosPros = null, bool pdf = false) + { + Carregando = true; + if (tipoRelatorio == (Relatorio?)0 || (int)tipoRelatorio.GetValueOrDefault() == 1) + { + if (clientes == null || clientes.Count == 0) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM CLIENTE"); + Carregando = false; + return; + } + if (clientes.Count > 200 && !(await ShowMessage("A SELEÇÃO DE MUITOS EXTRATOS PODE DEMORAR MAIS DE 30 MINUTOS! CONTINUAR?", "SIM", "NÃO"))) + { + Carregando = false; + return; + } + List<Cliente> listaCli = new List<Cliente>(); + foreach (ClientesAtivosInativos item2 in clientes.Where((ClientesAtivosInativos x) => x.Selecionado)) + { + Cliente cli = await new ClienteServico().BuscarCliente(item2.Id); + Cliente val = cli; + val.Enderecos = await _clienteServico.BuscarEnderecosAsync(((DomainBase)cli).Id); + val = cli; + val.Emails = await _clienteServico.BuscarEmailsAsync(((DomainBase)cli).Id); + val = cli; + val.Telefones = await _clienteServico.BuscarTelefonesAsync(((DomainBase)cli).Id); + val = cli; + val.Contatos = await _clienteServico.BuscarContatosAsync(((DomainBase)cli).Id); + val = cli; + val.Vinculos = await _clienteServico.BuscarVinculosAsync(((DomainBase)cli).Id); + listaCli.Add(cli); + } + Clientes = listaCli; + goto IL_16a4; + } + if ((documentos == null || documentos.Count == 0) && (prospeccoes == null || prospeccoes.Count == 0)) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO OU PROSPECÇÃO"); + Carregando = false; + return; + } + if (documentos == null || documentos.Count <= 200) + { + if (prospeccoes == null || prospeccoes.Count <= 200) + { + goto IL_0741; + } + } + if (!(await ShowMessage("A SELEÇÃO DE MUITOS EXTRATOS PODE DEMORAR MAIS DE 30 MINUTOS! CONTINUAR?", "SIM", "NÃO"))) + { + Carregando = false; + return; + } + goto IL_0741; + IL_16a4: + if ((int)SegurosVigentesVisibility == 0 && SegurosVigentes) + { + Documentos = Documentos.Where((Documento x) => (x.Vigencia2 > Funcoes.GetNetworkTime().Date.AddDays(-5.0) || !x.Vigencia2.HasValue) && (int)x.Situacao != 7).ToList(); + } + await Gerar(tipoRelatorio, pdf); + Carregando = false; + return; + IL_0741: + TipoExtrato selectedTipoExtrato = SelectedTipoExtrato; + switch ((int)selectedTipoExtrato) + { + case 2: + { + List<Documento> listaEndossos = new List<Documento>(); + ApoliceServico apoliceServico = new ApoliceServico(); + long id = ((DomainBase)documentos.First().Controle.Cliente).Id; + FiltroStatusDocumento statusSelecionado = MainViewModel.StatusSelecionado; + Documentos = new List<Documento>(await apoliceServico.BuscarApolicesAsync(id, statusSelecionado, await VerificaVinculoVendedor(Recursos.Usuario))); + foreach (Documento documento in Documentos) + { + foreach (Documento documento2 in documento.Controle.Documentos) + { + if (documento2.Tipo == 1) + { + listaEndossos.Add(documento2); + documento.TemEndosso = true; + } + } + } + Documentos.AddRange(listaEndossos); + break; + } + case 1: + if ((selecionadosDoc == null || selecionadosDoc.Count == 0) && (selecionadosPros == null || selecionadosPros.Count == 0)) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO SELECIONADO"); + Carregando = false; + return; + } + Documentos = new List<Documento>(); + Prospeccoes = new List<Prospeccao>(); + if (selecionadosDoc != null) + { + foreach (long item3 in selecionadosDoc) + { + Documento doc = await new ApoliceServico().BuscarApoliceAsync(item3, itens: false, sinistrosPorControle: true); + List<Documento> listDoc = ((SomenteEndossos && doc.Ordem != 1) ? new List<Documento>() : new List<Documento> { doc }); + if (SomenteEndossos) + { + IEnumerable<Documento> enumerable = doc.Controle.Documentos.Where((Documento x) => !x.Excluido && x.Ordem != 0 && !listDoc.Any((Documento y) => ((DomainBase)y).Id == ((DomainBase)x).Id)); + foreach (Documento item4 in enumerable) + { + item4.Sinistro = doc.Sinistro; + } + listDoc.AddRange(enumerable); + } + else if (Endossos) + { + IEnumerable<Documento> enumerable2 = doc.Controle.Documentos.Where((Documento x) => ((DomainBase)x).Id != ((DomainBase)doc).Id && !x.Excluido); + foreach (Documento item5 in enumerable2) + { + item5.Sinistro = doc.Sinistro; + } + listDoc.AddRange(enumerable2); + } + if (doc.Controle.Documentos.Any((Documento x) => ((DomainBase)x).Id != ((DomainBase)doc).Id && !x.Excluido && x.Ordem > doc.Ordem)) + { + doc.TemEndosso = true; + } + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 31) && doc.TemEndosso) + { + doc.PremioTotal = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.PremioTotal); + doc.Iof = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.Iof); + doc.Custo = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.Custo); + doc.PremioLiquido = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.PremioLiquido); + doc.PremioAdicional = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.PremioAdicional); + } + Documentos.AddRange(listDoc.OrderBy((Documento x) => x.Ordem).ToList()); + } + } + if (selecionadosPros != null) + { + foreach (long selecionadosPro in selecionadosPros) + { + Prospeccao item = await new ProspeccaoServico().BuscarProspeccao(selecionadosPro); + Prospeccoes.Add(item); + } + } + if ((int)SelecionarItensVisibility == 0 && SelecionarItens && Documentos != null && Documentos.Count > 0) + { + _itensSelecionados = (await ShowSelecionarItensDialog(((DomainBase)Documentos.First().Controle).Id)).Where((Item x) => x.Selecionado).ToList(); + } + if ((Documentos == null || Documentos.Count == 0) && (Prospeccoes == null || Prospeccoes.Count == 0)) + { + if (!SomenteEndossos) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO OU PROSPECÇÃO SELECIONADO"); + } + else + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM ENDOSSO OU PROSPECÇÃO SELECIONADO"); + } + Carregando = false; + return; + } + break; + case 0: + { + if (selecionadosDoc == null || selecionadosDoc.Count == 0) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO SELECIONADO"); + Carregando = false; + return; + } + List<Cliente> listaCli = new List<Cliente>(); + foreach (Documento documento3 in documentos) + { + Cliente cli = await new ClienteServico().BuscarCliente(((DomainBase)documento3.Controle.Cliente).Id); + Cliente val = cli; + val.Enderecos = await _clienteServico.BuscarEnderecosAsync(((DomainBase)cli).Id); + val = cli; + val.Emails = await _clienteServico.BuscarEmailsAsync(((DomainBase)cli).Id); + val = cli; + val.Telefones = await _clienteServico.BuscarTelefonesAsync(((DomainBase)cli).Id); + val = cli; + val.Contatos = await _clienteServico.BuscarContatosAsync(((DomainBase)cli).Id); + val = cli; + val.Vinculos = await _clienteServico.BuscarVinculosAsync(((DomainBase)cli).Id); + listaCli.Add(cli); + } + Clientes = listaCli; + Prospeccoes = prospeccoes; + break; + } + } + goto IL_16a4; + } +} |