summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Seguros
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Seguros')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Seguros/ApoliceViewModel.cs73
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Seguros/ClienteViewModel.cs1343
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Seguros/ConsultaViewModel.cs1685
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Seguros/CriticaApoliceViewModel.cs1109
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Seguros/PerfilEmpresaViewModel.cs256
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Seguros/PerfilViewModel.cs168
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Seguros/SinistroViewModel.cs1337
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Seguros/TrocarClienteViewModel.cs75
8 files changed, 6046 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Seguros/ApoliceViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Seguros/ApoliceViewModel.cs
new file mode 100644
index 0000000..15c8dba
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Seguros/ApoliceViewModel.cs
@@ -0,0 +1,73 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Drawers;
+using Gestor.Application.Helpers;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Seguros;
+
+public class ApoliceViewModel : BaseApoliceViewModel
+{
+ private bool _documentoExcluido;
+
+ public bool DocumentoExcluido
+ {
+ get
+ {
+ return _documentoExcluido;
+ }
+ set
+ {
+ _documentoExcluido = value;
+ OnPropertyChanged("DocumentoExcluido");
+ }
+ }
+
+ public ApoliceViewModel(AcessoApolice acesso, Documento documentoSelecionado, bool invoke = true, long idparcela = 0L)
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ base.Invoke = invoke;
+ base.Acesso = acesso;
+ base.DocumentoSelecionado = documentoSelecionado;
+ long parcelaSelecionada;
+ if (!invoke)
+ {
+ parcelaSelecionada = idparcela;
+ }
+ else
+ {
+ Parcela parcelaSelecionada2 = ConsultaViewModel.ParcelaSelecionada;
+ parcelaSelecionada = ((parcelaSelecionada2 != null) ? ((DomainBase)parcelaSelecionada2).Id : 0);
+ }
+ base.ParcelaSelecionada = parcelaSelecionada;
+ DocumentoExcluido = base.DocumentoSelecionado != null && base.DocumentoSelecionado.Excluido;
+ Seleciona(base.DocumentoSelecionado);
+ }
+
+ public async Task Alteracao(bool alterar)
+ {
+ if (!base.AllowEditApolice || base.Parcelas.Any((Parcela x) => x.DataRecebimento.HasValue) || base.Repasses.Any((VendedorParcela x) => x.DataPagamento.HasValue))
+ {
+ await ShowMessage("DOCUMENTO POSSUI BAIXAS DE COMISSÃO OU PAGAMENTO DE VENDEDORES.\nNÃO SERÁ POSSÍVEL ALTERAR ALGUMAS INFORMAÇÕES DO DOCUMENTO.\nPARA ISSO, EXCLUA AS BAIXAS E O PAGAMENTO DO VENDEDOR");
+ return;
+ }
+ List<Seguradora> seguradoras = Recursos.Seguradoras.Where((Seguradora x) => x.Ativo || ((DomainBase)x).Id == ((DomainBase)base.SelectedDocumento.Controle.Seguradora).Id).ToList();
+ base.Seguradoras = seguradoras;
+ base.SeguradorasAnteriores = Recursos.Seguradoras;
+ List<Ramo> ramos = Recursos.Ramos.Where((Ramo x) => x.Ativo || ((DomainBase)x).Id == ((DomainBase)base.SelectedDocumento.Controle.Ramo).Id).ToList();
+ base.Ramos = ramos;
+ List<Produto> produtos = Recursos.Produtos.Where((Produto x) => x.Ativo || (base.SelectedDocumento.Controle.Produto != null && ((DomainBase)x).Id == ((DomainBase)base.SelectedDocumento.Controle.Produto).Id)).ToList();
+ base.Produtos = produtos;
+ List<Status> status = Recursos.Status.Where((Status x) => x.Ativo || (base.SelectedDocumento.Status != null && ((DomainBase)x).Id == ((DomainBase)base.SelectedDocumento.Status).Id)).ToList();
+ base.Status = status;
+ }
+
+ public void AbrirInfo()
+ {
+ ShowDrawer(new InfoDrawer(base.SelectedDocumento, ocultarInfos: true), 0, close: false);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Seguros/ClienteViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Seguros/ClienteViewModel.cs
new file mode 100644
index 0000000..278faa9
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Seguros/ClienteViewModel.cs
@@ -0,0 +1,1343 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+using Agger.Registro;
+using Gestor.Application.Actions;
+using Gestor.Application.Drawers;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.ViewModels.Command;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Security;
+using Gestor.Common.Validation;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+
+namespace Gestor.Application.ViewModels.Seguros;
+
+public class ClienteViewModel : BaseSegurosViewModel
+{
+ private const int NumeroMaximoCadastros = 9;
+
+ private readonly ClienteServico _servico;
+
+ private const string AddCentralSegurado = "ADICIONAR CENTRAL SEGURADO";
+
+ private const string UpdateCentralSegurado = "ALTERAR DADOS/SENHA CENTRAL SEGURADO";
+
+ private bool _visibilityLogAntigo = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 22);
+
+ private ObservableCollection<ClienteTelefone> _telefones = new ObservableCollection<ClienteTelefone>();
+
+ private ObservableCollection<ClienteEmail> _emails = new ObservableCollection<ClienteEmail>();
+
+ private ObservableCollection<ClienteEndereco> _enderecos = new ObservableCollection<ClienteEndereco>();
+
+ private ObservableCollection<MaisContato> _contatos = new ObservableCollection<MaisContato>();
+
+ private ObservableCollection<ClienteVinculo> _vinculos = new ObservableCollection<ClienteVinculo>();
+
+ private Cliente _vinculo;
+
+ private bool _isLoading;
+
+ private bool _clienteExcluido;
+
+ private DateTime? _nascimentoCliente;
+
+ private DateTime? _habilitaCliente;
+
+ private DateTime? _vencimentoHabCliente;
+
+ private DateTime? _expedicaoCliente;
+
+ private Cliente _selectedCliente;
+
+ private string _fieldNascimento = "NASCIMENTO";
+
+ private string _fieldDocumento = "CPF";
+
+ private Visibility _visibilityJuridica = (Visibility)2;
+
+ private Visibility _visibilityFisica = (Visibility)2;
+
+ private bool _enableAddTelephone = true;
+
+ private bool _enableAddAddress = true;
+
+ private bool _enableAddEmail = true;
+
+ private bool _enableAddContact = true;
+
+ private string _profissaoText;
+
+ private string _atividadeText;
+
+ private bool _saving;
+
+ private ObservableCollection<OrigemCliente> _origens;
+
+ private OrigemCliente _selectedOrigem;
+
+ private Cliente ClienteSelecionado { get; set; }
+
+ private bool Invoke { get; }
+
+ public Visibility AddUsuarioCentralSeguradoVisibility { get; set; } = (Visibility)(string.IsNullOrEmpty(Connection.UrlCentralSegurado) ? 2 : 0);
+
+
+ public ICommand CommandAddUsuarioCentralSegurado { get; set; }
+
+ public string LabelAddUsuarioCentralSegurado
+ {
+ get
+ {
+ if (SelectedCliente == null || !SelectedCliente.EstaNaCentralSegurado)
+ {
+ return "ADICIONAR CENTRAL SEGURADO";
+ }
+ return "ALTERAR DADOS/SENHA CENTRAL SEGURADO";
+ }
+ }
+
+ public bool VisibilityLogAntigo
+ {
+ get
+ {
+ return _visibilityLogAntigo;
+ }
+ set
+ {
+ _visibilityLogAntigo = value;
+ OnPropertyChanged("VisibilityLogAntigo");
+ }
+ }
+
+ public ObservableCollection<ClienteTelefone> Telefones
+ {
+ get
+ {
+ return _telefones;
+ }
+ set
+ {
+ _telefones = value;
+ OnPropertyChanged("Telefones");
+ }
+ }
+
+ public ObservableCollection<ClienteEmail> Emails
+ {
+ get
+ {
+ return _emails;
+ }
+ set
+ {
+ _emails = value;
+ OnPropertyChanged("Emails");
+ }
+ }
+
+ public ObservableCollection<ClienteEndereco> Enderecos
+ {
+ get
+ {
+ return _enderecos;
+ }
+ set
+ {
+ _enderecos = value;
+ OnPropertyChanged("Enderecos");
+ }
+ }
+
+ public ObservableCollection<MaisContato> Contatos
+ {
+ get
+ {
+ return _contatos;
+ }
+ set
+ {
+ _contatos = value;
+ OnPropertyChanged("Contatos");
+ }
+ }
+
+ public ObservableCollection<ClienteVinculo> Vinculos
+ {
+ get
+ {
+ return _vinculos;
+ }
+ set
+ {
+ if (value != null && value.Count > 0 && SelectedCliente != null)
+ {
+ foreach (ClienteVinculo item in value)
+ {
+ if (((DomainBase)item.Cliente2).Id == ((DomainBase)SelectedCliente).Id)
+ {
+ item.Parentesco = Funcoes.ParentescoInverso(item.Parentesco);
+ }
+ }
+ }
+ _vinculos = value;
+ OnPropertyChanged("Vinculos");
+ }
+ }
+
+ public Cliente Vinculo
+ {
+ get
+ {
+ return _vinculo;
+ }
+ set
+ {
+ _vinculo = value;
+ OnPropertyChanged("Vinculo");
+ }
+ }
+
+ public bool Salvando { get; set; }
+
+ public bool IsLoading
+ {
+ get
+ {
+ return _isLoading;
+ }
+ set
+ {
+ _isLoading = value;
+ OnPropertyChanged("IsLoading");
+ }
+ }
+
+ public bool ClienteExcluido
+ {
+ get
+ {
+ return _clienteExcluido;
+ }
+ set
+ {
+ _clienteExcluido = value;
+ OnPropertyChanged("ClienteExcluido");
+ }
+ }
+
+ public DateTime? NascimentoCliente
+ {
+ get
+ {
+ return _nascimentoCliente;
+ }
+ set
+ {
+ _nascimentoCliente = value;
+ OnPropertyChanged("NascimentoCliente");
+ }
+ }
+
+ public DateTime? HabilitaCliente
+ {
+ get
+ {
+ return _habilitaCliente;
+ }
+ set
+ {
+ _habilitaCliente = value;
+ OnPropertyChanged("HabilitaCliente");
+ }
+ }
+
+ public DateTime? VencimentoHabCliente
+ {
+ get
+ {
+ return _vencimentoHabCliente;
+ }
+ set
+ {
+ _vencimentoHabCliente = value;
+ OnPropertyChanged("VencimentoHabCliente");
+ }
+ }
+
+ public DateTime? ExpedicaoCliente
+ {
+ get
+ {
+ return _expedicaoCliente;
+ }
+ set
+ {
+ _expedicaoCliente = value;
+ OnPropertyChanged("ExpedicaoCliente");
+ }
+ }
+
+ public Cliente SelectedCliente
+ {
+ get
+ {
+ return _selectedCliente;
+ }
+ set
+ {
+ _selectedCliente = value;
+ WorkOnSelectedCliente(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedCliente");
+ OnPropertyChanged("LabelAddUsuarioCentralSegurado");
+ }
+ }
+
+ private bool IsJuridica { get; set; }
+
+ public string FieldNascimento
+ {
+ get
+ {
+ return _fieldNascimento;
+ }
+ set
+ {
+ _fieldNascimento = value;
+ OnPropertyChanged("FieldNascimento");
+ }
+ }
+
+ public string FieldDocumento
+ {
+ get
+ {
+ return _fieldDocumento;
+ }
+ set
+ {
+ _fieldDocumento = value;
+ OnPropertyChanged("FieldDocumento");
+ }
+ }
+
+ public Visibility VisibilityJuridica
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityJuridica;
+ }
+ 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)
+ _visibilityJuridica = value;
+ OnPropertyChanged("VisibilityJuridica");
+ }
+ }
+
+ public Visibility VisibilityFisica
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityFisica;
+ }
+ 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)
+ _visibilityFisica = value;
+ OnPropertyChanged("VisibilityFisica");
+ }
+ }
+
+ public bool EnableAddTelephone
+ {
+ get
+ {
+ return _enableAddTelephone;
+ }
+ set
+ {
+ _enableAddTelephone = value;
+ OnPropertyChanged("EnableAddTelephone");
+ }
+ }
+
+ public bool EnableAddAddress
+ {
+ get
+ {
+ return _enableAddAddress;
+ }
+ set
+ {
+ _enableAddAddress = value;
+ OnPropertyChanged("EnableAddAddress");
+ }
+ }
+
+ public bool EnableAddEmail
+ {
+ get
+ {
+ return _enableAddEmail;
+ }
+ set
+ {
+ _enableAddEmail = value;
+ OnPropertyChanged("EnableAddEmail");
+ }
+ }
+
+ public bool EnableAddContact
+ {
+ get
+ {
+ return _enableAddContact;
+ }
+ set
+ {
+ _enableAddContact = value;
+ OnPropertyChanged("EnableAddContact");
+ }
+ }
+
+ public string ProfissaoText
+ {
+ get
+ {
+ return _profissaoText;
+ }
+ set
+ {
+ _profissaoText = value;
+ OnPropertyChanged("ProfissaoText");
+ }
+ }
+
+ public string AtividadeText
+ {
+ get
+ {
+ return _atividadeText;
+ }
+ set
+ {
+ _atividadeText = value;
+ OnPropertyChanged("AtividadeText");
+ }
+ }
+
+ public ObservableCollection<OrigemCliente> Origens
+ {
+ get
+ {
+ return _origens;
+ }
+ set
+ {
+ _origens = value;
+ OnPropertyChanged("Origens");
+ if (Origens != null)
+ {
+ SelectedOrigem = Origens.FirstOrDefault();
+ }
+ }
+ }
+
+ public OrigemCliente SelectedOrigem
+ {
+ get
+ {
+ return _selectedOrigem;
+ }
+ set
+ {
+ _selectedOrigem = value;
+ OnPropertyChanged("SelectedOrigem");
+ }
+ }
+
+ public ClienteViewModel(Cliente cliente = null, bool invoke = true)
+ {
+ //IL_0011: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0094: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009b: Unknown result type (might be due to invalid IL or missing references)
+ Invoke = invoke;
+ _servico = new ClienteServico();
+ ClienteSelecionado = cliente ?? MainViewModel.ClienteSelecionado;
+ SelecionaCliente(ClienteSelecionado);
+ CommandAddUsuarioCentralSegurado = new RelayCommand(delegate
+ {
+ AddUsuarioCentralSegurado();
+ });
+ }
+
+ public async void SelecionaCliente(Cliente value)
+ {
+ if (!_saving || !Invoke)
+ {
+ if (value == null)
+ {
+ ClienteSelecionado = new Cliente();
+ value = ClienteSelecionado;
+ }
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)1);
+ await CarregaCliente(value);
+ Loading(isLoading: false);
+ }
+ }
+
+ public async Task CarregaCliente(Cliente value)
+ {
+ if (value == null || ((DomainBase)value).Id == 0L)
+ {
+ SelectedCliente = null;
+ Telefones = null;
+ Enderecos = null;
+ Emails = null;
+ Contatos = null;
+ Vinculos = null;
+ Origens = null;
+ return;
+ }
+ Cliente cliente = value;
+ if (((DomainBase)value).Id != 0L)
+ {
+ cliente = await _servico.BuscarCliente(((DomainBase)value).Id);
+ Cliente val = cliente;
+ val.Telefones = await _servico.BuscarTelefonesAsync(((DomainBase)value).Id);
+ ClienteViewModel clienteViewModel = this;
+ ObservableCollection<ClienteTelefone> telefones = cliente.Telefones;
+ clienteViewModel.EnableAddTelephone = telefones != null && telefones.Count <= 9;
+ val = cliente;
+ val.Emails = await _servico.BuscarEmailsAsync(((DomainBase)value).Id);
+ ClienteViewModel clienteViewModel2 = this;
+ ObservableCollection<ClienteEmail> emails = cliente.Emails;
+ clienteViewModel2.EnableAddEmail = emails != null && emails.Count <= 9;
+ val = cliente;
+ val.Enderecos = await _servico.BuscarEnderecosAsync(((DomainBase)value).Id);
+ ClienteViewModel clienteViewModel3 = this;
+ ObservableCollection<ClienteEndereco> enderecos = cliente.Enderecos;
+ clienteViewModel3.EnableAddAddress = enderecos != null && enderecos.Count <= 9;
+ val = cliente;
+ val.Contatos = await _servico.BuscarContatosAsync(((DomainBase)value).Id);
+ ClienteViewModel clienteViewModel4 = this;
+ ObservableCollection<MaisContato> contatos = cliente.Contatos;
+ clienteViewModel4.EnableAddContact = contatos != null && contatos.Count <= 9;
+ val = cliente;
+ val.Vinculos = await _servico.BuscarVinculosAsync(((DomainBase)value).Id);
+ Origens = await _servico.BuscarOrigens(((DomainBase)value).Id);
+ Telefones = cliente.Telefones;
+ ObservableCollection<ClienteTelefone> telefones2 = Telefones;
+ if (telefones2 != null && telefones2.Count == 0)
+ {
+ IncluirTelefone();
+ }
+ Emails = cliente.Emails;
+ ObservableCollection<ClienteEmail> emails2 = Emails;
+ if (emails2 != null && emails2.Count == 0)
+ {
+ IncluirEmail();
+ }
+ Enderecos = cliente.Enderecos;
+ ObservableCollection<ClienteEndereco> enderecos2 = Enderecos;
+ if (enderecos2 != null && enderecos2.Count == 0)
+ {
+ IncluirEndereco();
+ }
+ Contatos = cliente.Contatos;
+ Vinculos = cliente.Vinculos;
+ }
+ if (!cliente.DocumentoPrincipal.HasValue)
+ {
+ cliente.DocumentoPrincipal = (TipoDocumento)0;
+ }
+ if (cliente.ResponsavelAssinatura == null)
+ {
+ cliente.ResponsavelAssinatura = new ResponsavelAssinatura
+ {
+ IdCliente = ((DomainBase)cliente).Id
+ };
+ }
+ SelectedCliente = cliente;
+ JuridicaouFisica(SelectedCliente.Documento);
+ ((DomainBase)SelectedCliente).Initialize();
+ SelectedCliente.Telefones?.ToList().ForEach(delegate(ClienteTelefone telefone)
+ {
+ ((DomainBase)telefone).Initialize();
+ });
+ SelectedCliente.Enderecos?.ToList().ForEach(delegate(ClienteEndereco endereco)
+ {
+ ((DomainBase)endereco).Initialize();
+ });
+ SelectedCliente.Contatos?.ToList().ForEach(delegate(MaisContato contato)
+ {
+ ((DomainBase)contato).Initialize();
+ });
+ SelectedCliente.Emails?.ToList().ForEach(delegate(ClienteEmail email)
+ {
+ ((DomainBase)email).Initialize();
+ });
+ SelectedCliente.Vinculos?.ToList().ForEach(delegate(ClienteVinculo vinculo)
+ {
+ ((DomainBase)vinculo).Initialize();
+ });
+ Initialized = true;
+ }
+
+ private async void WorkOnSelectedCliente(Cliente value)
+ {
+ if (value != null && ((DomainBase)value).Id != 0L && !IsLoading)
+ {
+ Loading(isLoading: true);
+ Cliente cliente = await _servico.BuscarCliente(((DomainBase)value).Id);
+ if (cliente.ResponsavelAssinatura == null)
+ {
+ cliente.ResponsavelAssinatura = new ResponsavelAssinatura
+ {
+ IdCliente = ((DomainBase)cliente).Id
+ };
+ }
+ Cliente val = cliente;
+ val.Telefones = await _servico.BuscarTelefonesAsync(((DomainBase)value).Id);
+ val = cliente;
+ val.Emails = await _servico.BuscarEmailsAsync(((DomainBase)value).Id);
+ val = cliente;
+ val.Enderecos = await _servico.BuscarEnderecosAsync(((DomainBase)value).Id);
+ val = cliente;
+ val.Contatos = await _servico.BuscarContatosAsync(((DomainBase)value).Id);
+ val = cliente;
+ val.Vinculos = await _servico.BuscarVinculosAsync(((DomainBase)value).Id);
+ Origens = await _servico.BuscarOrigens(((DomainBase)value).Id);
+ cliente.DocumentoPrincipal = cliente.DocumentoPrincipal.GetValueOrDefault();
+ ClienteExcluido = cliente.Excluido;
+ if (SelectedCliente != null)
+ {
+ DomainBase.Copy<Cliente, Cliente>(SelectedCliente, cliente);
+ JuridicaouFisica(SelectedCliente.Documento);
+ ((DomainBase)SelectedCliente).Initialize();
+ ClienteSelecionado = cliente;
+ }
+ NascimentoCliente = ((value != null && value.Nascimento.HasValue) ? value.Nascimento : new DateTime?(Funcoes.GetNetworkTime().Date));
+ HabilitaCliente = ((value != null && value.PrimeiraHabilitacao.HasValue) ? value.PrimeiraHabilitacao : new DateTime?(Funcoes.GetNetworkTime().Date));
+ VencimentoHabCliente = ((value != null && value.VencimentoHabilitacao.HasValue) ? value.VencimentoHabilitacao : new DateTime?(Funcoes.GetNetworkTime().Date));
+ ExpedicaoCliente = ((value != null && value.Expedicao.HasValue) ? value.Expedicao : new DateTime?(Funcoes.GetNetworkTime().Date));
+ Initialized = true;
+ Loading(isLoading: false);
+ }
+ }
+
+ public void JuridicaouFisica(string documento)
+ {
+ if (SelectedCliente != null)
+ {
+ ProfissaoText = "";
+ AtividadeText = "";
+ if (documento == null || ValidationHelper.OnlyNumber(documento).Length > 11)
+ {
+ VisibilityJuridica = (Visibility)0;
+ VisibilityFisica = (Visibility)2;
+ FieldNascimento = "FUNDAÇÃO";
+ FieldDocumento = "CNPJ";
+ SelectedCliente.Profissao = null;
+ IsJuridica = true;
+ }
+ else
+ {
+ VisibilityJuridica = (Visibility)2;
+ VisibilityFisica = (Visibility)0;
+ FieldNascimento = "NASCIMENTO";
+ FieldDocumento = "CPF";
+ SelectedCliente.Atividade = null;
+ IsJuridica = false;
+ }
+ }
+ }
+
+ public void IncluirEmail()
+ {
+ //IL_0031: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0036: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0042: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005b: Expected O, but got Unknown
+ if (SelectedCliente != null)
+ {
+ if (Emails == null)
+ {
+ Emails = new ObservableCollection<ClienteEmail>();
+ }
+ EnableAddEmail = Emails.Count < 9;
+ ClienteEmail item = new ClienteEmail
+ {
+ Cliente = SelectedCliente,
+ Ordem = Emails.Count + 1
+ };
+ Emails.Add(item);
+ OnPropertyChanged("IncluirEmail");
+ }
+ }
+
+ public void IncluirTelefone()
+ {
+ //IL_0031: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0036: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0042: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0067: Expected O, but got Unknown
+ if (SelectedCliente != null)
+ {
+ if (Telefones == null)
+ {
+ Telefones = new ObservableCollection<ClienteTelefone>();
+ }
+ EnableAddTelephone = Telefones.Count < 9;
+ ClienteTelefone item = new ClienteTelefone
+ {
+ Cliente = SelectedCliente,
+ Tipo = (TipoTelefone)1,
+ Ordem = Telefones.Count + 1
+ };
+ Telefones.Add(item);
+ OnPropertyChanged("IncluirTelefone");
+ }
+ }
+
+ public async Task IncluirOrigem(string name)
+ {
+ if (SelectedCliente != null && !string.IsNullOrWhiteSpace(name))
+ {
+ if (Origens == null)
+ {
+ Origens = new ObservableCollection<OrigemCliente>();
+ }
+ if (Origens.Any((OrigemCliente x) => x.Nome?.Trim() == name.Trim()))
+ {
+ await ShowMessage("JÁ EXISTE UMA ORIGEM " + name + ". PROCESSO CANCELADO.");
+ return;
+ }
+ Origens.Insert(0, new OrigemCliente
+ {
+ Cliente = SelectedCliente,
+ Nome = name,
+ TipoOrigem = 1L
+ });
+ OnPropertyChanged("Origens");
+ }
+ }
+
+ public void IncluirEndereco()
+ {
+ //IL_0031: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0036: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0042: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005b: Expected O, but got Unknown
+ if (SelectedCliente != null)
+ {
+ if (Enderecos == null)
+ {
+ Enderecos = new ObservableCollection<ClienteEndereco>();
+ }
+ EnableAddAddress = Enderecos.Count < 9;
+ ClienteEndereco item = new ClienteEndereco
+ {
+ Cliente = SelectedCliente,
+ Ordem = Enderecos.Count + 1
+ };
+ Enderecos.Add(item);
+ OnPropertyChanged("IncluirEndereco");
+ }
+ }
+
+ public void IncluirContato()
+ {
+ //IL_001c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0021: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002e: Expected O, but got Unknown
+ if (SelectedCliente != null)
+ {
+ if (Contatos == null)
+ {
+ Contatos = new ObservableCollection<MaisContato>();
+ }
+ MaisContato item = new MaisContato
+ {
+ Cliente = SelectedCliente
+ };
+ EnableAddContact = Contatos.Count < 9;
+ Contatos.Add(item);
+ OnPropertyChanged("IncluirContato");
+ }
+ }
+
+ public bool IncluirVinculo()
+ {
+ //IL_0050: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0055: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0061: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006e: Expected O, but got Unknown
+ if (Vinculo == null || ((DomainBase)Vinculo).Id == ((DomainBase)SelectedCliente).Id)
+ {
+ return false;
+ }
+ if (Vinculos == null)
+ {
+ Vinculos = new ObservableCollection<ClienteVinculo>();
+ }
+ if (Vinculos.Any((ClienteVinculo x) => ((DomainBase)x.Cliente1).Id == ((DomainBase)Vinculo).Id || ((DomainBase)x.Cliente2).Id == ((DomainBase)Vinculo).Id))
+ {
+ return false;
+ }
+ ClienteVinculo item = new ClienteVinculo
+ {
+ Cliente1 = SelectedCliente,
+ Cliente2 = Vinculo
+ };
+ Vinculos.Add(item);
+ Vinculo = null;
+ OnPropertyChanged("IncluirVinculo");
+ return true;
+ }
+
+ public async void ExcluirTelefone(ClienteTelefone telefone)
+ {
+ if (Telefones.Count < 2)
+ {
+ await ShowMessage("É NECESSÁRIO TER AO MENOS UM CONTATO TELEFÔNICO CADASTRADO.");
+ return;
+ }
+ EnableAddTelephone = Telefones.Count <= 9;
+ Telefones.Remove(telefone);
+ }
+
+ public async void ExcluirEmail(ClienteEmail email)
+ {
+ if (Emails.Count < 2 && Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 29))
+ {
+ await ShowMessage("É NECESSÁRIO TER AO MENOS UM CONTATO DE E-MAIL CADASTRADO.");
+ return;
+ }
+ EnableAddEmail = Emails.Count <= 9;
+ Emails.Remove(email);
+ }
+
+ public async void ExcluirEndereco(ClienteEndereco endereco)
+ {
+ if (Enderecos.Count < 2)
+ {
+ await ShowMessage("É NECESSÁRIO TER AO MENOS UM ENDEREÇO CADASTRADO.");
+ return;
+ }
+ EnableAddAddress = Enderecos.Count <= 9;
+ Enderecos.Remove(endereco);
+ }
+
+ public void ExcluirContato(MaisContato contato)
+ {
+ EnableAddContact = Contatos.Count <= 9;
+ Contatos.Remove(contato);
+ }
+
+ public void ExcluirVinculo(ClienteVinculo vinculo)
+ {
+ Vinculos.Remove(vinculo);
+ }
+
+ public async Task<bool> Validate(ClienteEmail item)
+ {
+ if (ValidationHelper.ValidateMail(((EmailBase)item).Email))
+ {
+ return true;
+ }
+ await ShowMessage("ENDEREÇO DE E-MAIL INVÁLIDO");
+ return false;
+ }
+
+ public void IncluirCliente()
+ {
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0014: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0024: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0030: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0047: Expected O, but got Unknown
+ //IL_004c: Expected O, but got Unknown
+ //IL_0083: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0088: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0094: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b1: Expected O, but got Unknown
+ //IL_00bd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ce: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00df: Expected O, but got Unknown
+ //IL_00eb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00fc: Unknown result type (might be due to invalid IL or missing references)
+ //IL_010d: Expected O, but got Unknown
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ SelectedCliente = new Cliente
+ {
+ IdEmpresa = Recursos.Usuario.IdEmpresa,
+ DocumentoPrincipal = (TipoDocumento)0,
+ ClienteDesde = date,
+ ResponsavelAssinatura = new ResponsavelAssinatura()
+ };
+ NascimentoCliente = date;
+ HabilitaCliente = date;
+ VencimentoHabCliente = date;
+ ExpedicaoCliente = date;
+ Telefones = new ObservableCollection<ClienteTelefone>
+ {
+ new ClienteTelefone
+ {
+ Cliente = SelectedCliente,
+ Tipo = (TipoTelefone)1,
+ Ordem = 1
+ }
+ };
+ Enderecos = new ObservableCollection<ClienteEndereco>
+ {
+ new ClienteEndereco
+ {
+ Cliente = SelectedCliente,
+ Ordem = 1
+ }
+ };
+ Emails = new ObservableCollection<ClienteEmail>
+ {
+ new ClienteEmail
+ {
+ Cliente = SelectedCliente,
+ Ordem = 1
+ }
+ };
+ Contatos = new ObservableCollection<MaisContato>();
+ Vinculos = new ObservableCollection<ClienteVinculo>();
+ Origens = new ObservableCollection<OrigemCliente>();
+ Salvando = true;
+ Alterar(alterar: true);
+ }
+
+ public async void CancelarAlteracao()
+ {
+ Loading(isLoading: true);
+ IsLoading = true;
+ Alterar(alterar: false);
+ await CarregaCliente(ClienteSelecionado);
+ Salvando = false;
+ IsLoading = false;
+ Loading(isLoading: false);
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedCliente == null || ((DomainBase)SelectedCliente).Id == 0L)
+ {
+ return;
+ }
+ if ((await new ApoliceServico().BuscarApolicesAsync(((DomainBase)SelectedCliente).Id, (FiltroStatusDocumento)4)).Count > 0)
+ {
+ await ShowMessage("NÃO É POSSÍVEL EXCLUIR O CLIENTE POIS POSSUI APÓLICES CADASTRADAS.");
+ }
+ else if (await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO"))
+ {
+ Cliente cliente = SelectedCliente;
+ cliente.Excluido = true;
+ if (await _servico.Delete(cliente))
+ {
+ ClienteSelecionado = null;
+ MainViewModel.ClienteSelecionado = null;
+ Gestor.Application.Actions.Actions.LimparCliente?.Invoke();
+ SelectedCliente = new Cliente
+ {
+ IdEmpresa = Recursos.Usuario.IdEmpresa,
+ DocumentoPrincipal = (TipoDocumento)0,
+ ClienteDesde = Funcoes.GetNetworkTime().Date
+ };
+ Telefones = new ObservableCollection<ClienteTelefone>
+ {
+ new ClienteTelefone
+ {
+ Cliente = SelectedCliente,
+ Tipo = (TipoTelefone)1,
+ Ordem = 1
+ }
+ };
+ Enderecos = new ObservableCollection<ClienteEndereco>
+ {
+ new ClienteEndereco
+ {
+ Cliente = SelectedCliente,
+ Ordem = 1
+ }
+ };
+ Emails = new ObservableCollection<ClienteEmail>
+ {
+ new ClienteEmail
+ {
+ Cliente = SelectedCliente,
+ Ordem = 1
+ }
+ };
+ Contatos = new ObservableCollection<MaisContato>();
+ Vinculos = new ObservableCollection<ClienteVinculo>();
+ Origens = new ObservableCollection<OrigemCliente>();
+ string descricao = $"EXCLUIU CLIENTE \"{cliente.Nome}\", ID: {((DomainBase)cliente).Id}";
+ RegistrarAcao(descricao, ((DomainBase)cliente).Id, (TipoTela)1, $"CLIENTE \"{SelectedCliente.Nome}\", ID: {((DomainBase)SelectedCliente).Id}");
+ ToggleSnackBar("CLIENTE EXCLUÍDO COM SUCESSO");
+ }
+ }
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<ClienteTelefone> list = Telefones.Where((ClienteTelefone x) => !string.IsNullOrEmpty(((TelefoneBase)x).Numero)).ToList();
+ List<ClienteEndereco> list2 = Enderecos.Where((ClienteEndereco x) => !string.IsNullOrEmpty(((EnderecoBase)x).Endereco)).ToList();
+ List<MaisContato> list3 = Contatos?.Where((MaisContato x) => !string.IsNullOrEmpty(x.Nome)).ToList();
+ List<ClienteEmail> emails = Emails.Where((ClienteEmail x) => !string.IsNullOrEmpty(((EmailBase)x).Email)).ToList();
+ List<ClienteVinculo> list4 = Vinculos?.Where((ClienteVinculo x) => x.Cliente2 != null && x.Parentesco.HasValue).ToList();
+ if (list4 != null && ClienteSelecionado != null)
+ {
+ foreach (ClienteVinculo item in list4.Where((ClienteVinculo c) => ((DomainBase)c.Cliente2).Id == ((DomainBase)ClienteSelecionado).Id))
+ {
+ item.Parentesco = Funcoes.ParentescoInverso(item.Parentesco);
+ }
+ }
+ SelectedCliente.Telefones = new ObservableCollection<ClienteTelefone>(list);
+ SelectedCliente.Enderecos = new ObservableCollection<ClienteEndereco>(list2);
+ SelectedCliente.Contatos = ((list3 != null) ? new ObservableCollection<MaisContato>(list3) : null);
+ SelectedCliente.Emails = new ObservableCollection<ClienteEmail>(emails);
+ SelectedCliente.Vinculos = ((list4 != null) ? new ObservableCollection<ClienteVinculo>(list4) : null);
+ SelectedCliente.Origens = Origens?.ToList();
+ if (ValidationHelper.OnlyNumber(SelectedCliente.Documento).Length <= 11 && !string.IsNullOrWhiteSpace(ProfissaoText) && SelectedCliente.Profissao == null)
+ {
+ ProfissaoServico profissaoServico = new ProfissaoServico();
+ Cliente selectedCliente = SelectedCliente;
+ ProfissaoServico profissaoServico2 = profissaoServico;
+ Profissao val = new Profissao();
+ val.Nome = ProfissaoText;
+ val.Codigo = "0";
+ Profissao val2 = val;
+ ((DomainBase)val2).Id = await profissaoServico.FindLastId() + 1;
+ selectedCliente.Profissao = await profissaoServico2.Save(val);
+ if (!profissaoServico.Sucesso)
+ {
+ return null;
+ }
+ }
+ if (ValidationHelper.OnlyNumber(SelectedCliente.Documento).Length > 11 && !string.IsNullOrWhiteSpace(AtividadeText) && SelectedCliente.Atividade == null)
+ {
+ AtividadeServico atividadeServico = new AtividadeServico();
+ Cliente selectedCliente = SelectedCliente;
+ AtividadeServico atividadeServico2 = atividadeServico;
+ Atividade val3 = new Atividade();
+ val3.Nome = AtividadeText;
+ val3.Cnac = "0";
+ Atividade val4 = val3;
+ ((DomainBase)val4).Id = await atividadeServico.FindLastId() + 1;
+ selectedCliente.Atividade = await atividadeServico2.Save(val3);
+ if (!atividadeServico.Sucesso)
+ {
+ return null;
+ }
+ }
+ if (IsJuridica)
+ {
+ SelectedCliente.Cei = null;
+ SelectedCliente.Rne = null;
+ SelectedCliente.Caepf = null;
+ }
+ List<KeyValuePair<string, string>> errorMessages = SelectedCliente.Validate();
+ emails.ForEach(delegate(ClienteEmail x)
+ {
+ errorMessages.AddRange(x.Validate());
+ });
+ List<KeyValuePair<string, string>> list5 = errorMessages;
+ list5.AddRange(await Validate());
+ foreach (MaisContato contato in Contatos)
+ {
+ errorMessages.AddRange(contato.Validate());
+ }
+ foreach (ClienteVinculo vinculo in Vinculos)
+ {
+ errorMessages.AddRange(vinculo.Validate());
+ }
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ bool insert = ((DomainBase)SelectedCliente).Id == 0;
+ _saving = true;
+ Cliente clienteSelecionado = ClienteSelecionado;
+ int num2;
+ if (clienteSelecionado == null || ((DomainBase)clienteSelecionado).Id != 0)
+ {
+ Cliente clienteSelecionado2 = ClienteSelecionado;
+ long? num = ((clienteSelecionado2 != null) ? new long?(((DomainBase)clienteSelecionado2).Id) : null);
+ Cliente selectedCliente2 = SelectedCliente;
+ if (num == ((selectedCliente2 != null) ? new long?(((DomainBase)selectedCliente2).Id) : null))
+ {
+ num2 = (Salvando ? 1 : 0);
+ goto IL_0815;
+ }
+ }
+ num2 = 0;
+ goto IL_0815;
+ IL_0815:
+ bool flag = (byte)num2 != 0;
+ if (flag)
+ {
+ flag = await ShowMessage("NÃO FOI POSSIVEL INCLUIR UM NOVO SEGURADO, TENTE NOVAMENTE");
+ }
+ if (flag)
+ {
+ return null;
+ }
+ SelectedCliente = await _servico.Save(SelectedCliente, Salvando);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ if (Invoke)
+ {
+ Gestor.Application.Actions.Actions.SelectCliente?.Invoke(SelectedCliente);
+ }
+ await CarregaCliente(SelectedCliente);
+ string text = (insert ? "INCLUIU" : "ALTEROU");
+ RegistrarAcao(text + " CLIENTE \"" + SelectedCliente.Nome + "\"", ((DomainBase)SelectedCliente).Id, (TipoTela)1, $"CLIENTE \"{SelectedCliente.Nome}\", ID: {((DomainBase)SelectedCliente).Id}");
+ ToggleSnackBar("CLIENTE SALVO COM SUCESSO");
+ if (Invoke)
+ {
+ ConsultaViewModel.DocumentoSelecionado = null;
+ Gestor.Application.Actions.Actions.AtualizaContatos?.Invoke();
+ if (insert)
+ {
+ MainViewModel.ClienteSelecionado = SelectedCliente;
+ if (await ShowMessage("DESEJA INCLUIR UMA APÓLICE AGORA?", "SIM", "NÃO"))
+ {
+ Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)2, "");
+ }
+ }
+ }
+ Salvando = false;
+ Alterar(alterar: false);
+ _saving = false;
+ return null;
+ }
+
+ private async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ bool valida = !string.IsNullOrEmpty(SelectedCliente.Nome);
+ switch (SelectedCliente.DocumentoPrincipal)
+ {
+ case 0L:
+ if (!ValidationHelper.ValidateDocument(SelectedCliente.Documento))
+ {
+ valida = false;
+ }
+ break;
+ case 1L:
+ if (!ValidationHelper.ValidateRne(SelectedCliente.Rne))
+ {
+ valida = false;
+ }
+ break;
+ case 2L:
+ if (!ValidationHelper.ValidateCei(SelectedCliente.Cei))
+ {
+ valida = false;
+ }
+ break;
+ case 3L:
+ if (!ValidationHelper.ValidateCaepf(SelectedCliente.Caepf))
+ {
+ valida = false;
+ }
+ break;
+ }
+ if (ValidationHelper.ValidateDocument(SelectedCliente.Documento) && SelectedCliente.DocumentoPrincipal == (TipoDocumento?)0)
+ {
+ SelectedCliente.Documento = ValidationHelper.FormatDocument(SelectedCliente.Documento);
+ }
+ List<Cliente> list = ((!ValidationHelper.ValidateDocument(SelectedCliente.Documento)) ? new List<Cliente>() : (await new ClienteServico().BuscarCliente(SelectedCliente.Documento, null, (TipoFiltroCliente)2)));
+ List<Cliente> clienteBase = list;
+ if (!IsJuridica)
+ {
+ list = ((!ValidationHelper.ValidateCei(SelectedCliente.Cei)) ? new List<Cliente>() : (await new ClienteServico().BuscarCliente(SelectedCliente.Cei, null, (TipoFiltroCliente)2)));
+ List<Cliente> clienteCei = list;
+ list = ((!ValidationHelper.ValidateRne(SelectedCliente.Rne)) ? new List<Cliente>() : (await new ClienteServico().BuscarCliente(SelectedCliente.Rne, null, (TipoFiltroCliente)2)));
+ List<Cliente> clienteRne = list;
+ list = ((!ValidationHelper.ValidateCaepf(SelectedCliente.Caepf)) ? new List<Cliente>() : (await new ClienteServico().BuscarCliente(SelectedCliente.Caepf, null, (TipoFiltroCliente)2)));
+ List<Cliente> list2 = list;
+ clienteBase.AddRange(clienteCei ?? new List<Cliente>());
+ clienteBase.AddRange(clienteRne ?? new List<Cliente>());
+ clienteBase.AddRange(list2 ?? new List<Cliente>());
+ }
+ string nome = "";
+ string docDuplicado = "";
+ if (clienteBase.Count > 0)
+ {
+ clienteBase.ForEach(delegate(Cliente x)
+ {
+ if (((DomainBase)x).Id != ((DomainBase)SelectedCliente).Id && x.IdEmpresa == SelectedCliente.IdEmpresa)
+ {
+ if (!string.IsNullOrEmpty(SelectedCliente.Documento) && x.Documento == SelectedCliente.Documento)
+ {
+ valida = false;
+ nome = x.Nome;
+ }
+ if (!string.IsNullOrEmpty(SelectedCliente.Cei) && x.Cei == SelectedCliente.Cei)
+ {
+ docDuplicado = " (CEI)";
+ valida = false;
+ nome = x.Nome;
+ }
+ if (!string.IsNullOrEmpty(SelectedCliente.Rne) && x.Rne == SelectedCliente.Rne)
+ {
+ docDuplicado = " (RNE)";
+ valida = false;
+ nome = x.Nome;
+ }
+ if (!string.IsNullOrEmpty(SelectedCliente.Caepf) && x.Caepf == SelectedCliente.Caepf)
+ {
+ docDuplicado = " (CAEPF)";
+ valida = false;
+ nome = x.Nome;
+ }
+ }
+ });
+ }
+ if (!valida && clienteBase.Count((Cliente x) => ((DomainBase)x).Id != ((DomainBase)SelectedCliente).Id) > 0)
+ {
+ if (!(await new VendedorUsuarioServico().FindVinculoByUsuario(((DomainBase)Recursos.Usuario).Id)))
+ {
+ errors.Add(new KeyValuePair<string, string>("Documento", "O DOCUMENTO" + docDuplicado + " JÁ ESTÁ CADASTRADO PARA O CLIENTE " + nome));
+ }
+ else
+ {
+ Cliente? obj = clienteBase.FirstOrDefault();
+ long idCliente = ((obj != null) ? ((DomainBase)obj).Id : 0);
+ string text = string.Join("|", (await new VendedorServico().BuscarVinculosCliente(idCliente)).Select((Vendedor vendedor) => vendedor.Nome));
+ errors.Add(new KeyValuePair<string, string>("Documento", "O DOCUMENTO" + docDuplicado + " JÁ ESTÁ CADASTRADO PARA O CLIENTE " + nome + ".\nEXISTENTE NO VINCULO COM VENDEDORES: " + text + " "));
+ }
+ }
+ if (SelectedCliente.Telefones == null || SelectedCliente.Telefones.Count == 0)
+ {
+ errors.Add(new KeyValuePair<string, string>("Telefones", "NECESSITA-SE AO MENOS UM TELEFONE VÁLIDO."));
+ }
+ if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 29) && (SelectedCliente.Emails == null || SelectedCliente.Emails.Count == 0))
+ {
+ errors.Add(new KeyValuePair<string, string>("Emails|E-MAILS", "NECESSITA-SE AO MENOS UM E-MAIL VÁLIDO."));
+ }
+ if (SelectedCliente.Enderecos == null || SelectedCliente.Enderecos.Count == 0)
+ {
+ errors.Add(new KeyValuePair<string, string>("Enderecos|ENDEREÇOS", "NECESSITA-SE AO MENOS UM ENDEREÇO VÁLIDO."));
+ }
+ return errors;
+ }
+
+ public async Task ExcluirOrigem(OrigemCliente origem)
+ {
+ Origens.Remove(origem);
+ OnPropertyChanged("Origens");
+ }
+
+ public async void AbrirLogAntigo()
+ {
+ Loading(isLoading: true);
+ string text = await _servico.BuscarLogAntigo(((DomainBase)SelectedCliente).Id);
+ Loading(isLoading: false);
+ if (string.IsNullOrEmpty(text))
+ {
+ await ShowMessage("NÃO HÁ LOG PARA ESSE CLIENTE");
+ }
+ else
+ {
+ ShowDrawer(new LogSistemaAntigo(((DomainBase)SelectedCliente).Id, text), 0, close: false);
+ }
+ }
+
+ public async void AddUsuarioCentralSegurado()
+ {
+ if (SelectedCliente == null || SelectedCliente.Emails.Count == 0)
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ string message = "CLIENTE CADASTRADO/ALTERADO COM SUCESSO!";
+ try
+ {
+ string text = ((SelectedCliente.Telefones.Count == 0) ? string.Empty : ("(" + ((TelefoneBase)SelectedCliente.Telefones[0]).Prefixo + ") " + ((TelefoneBase)SelectedCliente.Telefones[0]).Numero));
+ bool flag = SelectedCliente.Enderecos.Count > 0;
+ Token val = new Token();
+ UsuarioCentralSegurado val2 = new UsuarioCentralSegurado
+ {
+ Id = "",
+ Senha = "",
+ Serial = val.Encrypt(Recursos.Empresa.Serial),
+ FornecedorId = ApplicationHelper.IdFornecedor,
+ Nome = val.Encrypt(SelectedCliente.Nome),
+ Documento = val.Encrypt(SelectedCliente.Documento.Clear()),
+ Email = val.Encrypt(((EmailBase)SelectedCliente.Emails[0]).Email),
+ IdEmpresa = SelectedCliente.IdEmpresa,
+ Telefone = val.Encrypt(text),
+ Rua = (flag ? val.Encrypt(((EnderecoBase)SelectedCliente.Enderecos[0]).Endereco) : string.Empty),
+ Numero = (flag ? val.Encrypt(((EnderecoBase)SelectedCliente.Enderecos[0]).Numero) : string.Empty),
+ Bairro = (flag ? val.Encrypt(((EnderecoBase)SelectedCliente.Enderecos[0]).Bairro) : string.Empty),
+ Cidade = (flag ? val.Encrypt(((EnderecoBase)SelectedCliente.Enderecos[0]).Cidade) : string.Empty),
+ Estado = (flag ? val.Encrypt(((EnderecoBase)SelectedCliente.Enderecos[0]).Estado) : string.Empty),
+ Cep = (flag ? val.Encrypt(((EnderecoBase)SelectedCliente.Enderecos[0]).Cep) : string.Empty),
+ Corretora = val.Encrypt(Recursos.Empresa.Nome),
+ UriCorretora = val.Encrypt(Connection.UrlCentralSegurado)
+ };
+ HttpClient client = new HttpClient();
+ try
+ {
+ StringContent val3 = new StringContent(JsonConvert.SerializeObject((object)val2), Encoding.UTF8, "application/json");
+ Uri uri = Address.CentralSegurado.Append("Usuario").Append("AddAggerApp");
+ HttpResponseMessage response = await client.PostAsync(uri, (HttpContent)(object)val3);
+ await _servico.AddCentralSegurado(((DomainBase)SelectedCliente).Id, response.IsSuccessStatusCode);
+ if (!response.IsSuccessStatusCode)
+ {
+ message = "HOUVE(RAM) O(S) SEGUINTE(S) ERROS: " + (await response.Content.ReadAsStringAsync()).Replace(";", ", ").ToUpper();
+ }
+ }
+ finally
+ {
+ ((IDisposable)client)?.Dispose();
+ }
+ }
+ catch
+ {
+ message = "HOUVERAM ERROS AO CADASTRAR/ALTERAR O CLIENTE!";
+ }
+ OnPropertyChanged("LabelAddUsuarioCentralSegurado");
+ Loading(isLoading: false);
+ await ShowMessage(message);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Seguros/ConsultaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Seguros/ConsultaViewModel.cs
new file mode 100644
index 0000000..a41d428
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Seguros/ConsultaViewModel.cs
@@ -0,0 +1,1685 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Forms;
+using System.Windows.Threading;
+using Assinador.Infrastructure.Helpers;
+using ClosedXML.Excel;
+using Gestor.Application.Actions;
+using Gestor.Application.Helpers;
+using Gestor.Application.Model;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Seguros;
+
+public class ConsultaViewModel : BaseSegurosViewModel
+{
+ private readonly ApoliceServico _apoliceServico;
+
+ private readonly ParcelaServico _parcelaServico;
+
+ private readonly ItemServico _itemServico;
+
+ private readonly VendedorServico _vendedorServico;
+
+ public bool UpdatingScroll;
+
+ public static Parcela ParcelaSelecionada;
+
+ public static Item ItemSelecionado;
+
+ private static Documento _documentoSelecionado;
+
+ private bool _apelido;
+
+ private Visibility _semDocumentos = (Visibility)2;
+
+ private Cliente _selectedCliente = new Cliente();
+
+ private bool _carregando;
+
+ private bool _isLoading;
+
+ private Visibility _visibilityParcelasVendedores;
+
+ private ObservableCollection<Documento> _apolices = new ObservableCollection<Documento>();
+
+ private ObservableCollection<Documento> _endossos = new ObservableCollection<Documento>();
+
+ private Documento _selectedEndosso = new Documento();
+
+ private string _parcelasLabel = "PARCELAS";
+
+ private Documento _selectedControle = new Documento();
+
+ private bool _isFatura;
+
+ private bool _isEnabledParcelaItem = true;
+
+ private Item _selectedItem = new Item();
+
+ private ObservableCollection<Item> _itens = new ObservableCollection<Item>();
+
+ private Parcela _selectedParcela = new Parcela();
+
+ private ObservableCollection<Parcela> _parcelas = new ObservableCollection<Parcela>();
+
+ private Visibility _isVisibleRadioEndosso = (Visibility)2;
+
+ private Visibility _isVisibleEndosso = (Visibility)2;
+
+ private Visibility _isVisibleApolice;
+
+ private string _pendenciaApolice = "";
+
+ private Visibility _isVisiblePendenciaApolice = (Visibility)2;
+
+ private decimal _gerada;
+
+ private decimal _recebida;
+
+ private decimal _pendente;
+
+ private bool _isLoadingParcelas = true;
+
+ private bool _isLoadingItens = true;
+
+ private int _filterItens;
+
+ private int _filterDocumento;
+
+ private Visibility _manutencaoItemVisibility;
+
+ private Visibility _recusaVisibility;
+
+ private Visibility _renovarVisibility;
+
+ private Visibility _endossarVisibility;
+
+ private Visibility _trocarClienteVisibility;
+
+ private Visibility _tarefasVisibility;
+
+ private Visibility _comissaoVisibility;
+
+ private Visibility _comissaoValorVisibility;
+
+ private Visibility _mostrarItensVisibility = (Visibility)2;
+
+ private Visibility _mostrarSinistroVisibility;
+
+ private ObservableCollection<ClienteTelefone> _telefones = new ObservableCollection<ClienteTelefone>();
+
+ public static Documento DocumentoSelecionado
+ {
+ get
+ {
+ return _documentoSelecionado;
+ }
+ set
+ {
+ _documentoSelecionado = value;
+ Gestor.Application.Actions.Actions.EnableItens?.Invoke(value != null && ((DomainBase)value).Id > 0);
+ Gestor.Application.Actions.Actions.EnableDocumento?.Invoke(value != null && ((DomainBase)value).Id > 0);
+ }
+ }
+
+ public static Documento DocumentoRenovado { get; set; }
+
+ public bool Apelido
+ {
+ get
+ {
+ return _apelido;
+ }
+ set
+ {
+ _apelido = value;
+ OnPropertyChanged("Apelido");
+ }
+ }
+
+ public bool Pesquisando { get; set; }
+
+ public Visibility SemDocumentos
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _semDocumentos;
+ }
+ 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)
+ _semDocumentos = value;
+ OnPropertyChanged("SemDocumentos");
+ }
+ }
+
+ public Cliente SelectedCliente
+ {
+ get
+ {
+ return _selectedCliente;
+ }
+ set
+ {
+ _selectedCliente = value;
+ OnPropertyChanged("SelectedCliente");
+ }
+ }
+
+ public bool Carregando
+ {
+ get
+ {
+ return _carregando;
+ }
+ set
+ {
+ _carregando = value;
+ SemDocumentos = (Visibility)((value || (Apolices != null && Apolices.Count != 0)) ? 2 : 0);
+ }
+ }
+
+ public bool IsLoading
+ {
+ get
+ {
+ return _isLoading;
+ }
+ set
+ {
+ _isLoading = value;
+ OnPropertyChanged("IsLoading");
+ }
+ }
+
+ public Visibility VisibilityParcelasVendedores
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityParcelasVendedores;
+ }
+ 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)
+ _visibilityParcelasVendedores = value;
+ OnPropertyChanged("VisibilityParcelasVendedores");
+ }
+ }
+
+ public ObservableCollection<Documento> Apolices
+ {
+ get
+ {
+ return _apolices;
+ }
+ set
+ {
+ _apolices = value;
+ OnPropertyChanged("Apolices");
+ }
+ }
+
+ public ObservableCollection<Documento> Endossos
+ {
+ get
+ {
+ return _endossos;
+ }
+ set
+ {
+ _endossos = value;
+ OnPropertyChanged("Endossos");
+ }
+ }
+
+ public Documento SelectedEndosso
+ {
+ get
+ {
+ return _selectedEndosso;
+ }
+ set
+ {
+ _selectedEndosso = value;
+ WorkOnSelectedDocumento(value);
+ OnPropertyChanged("SelectedEndosso");
+ }
+ }
+
+ public string ParcelasLabel
+ {
+ get
+ {
+ return _parcelasLabel;
+ }
+ set
+ {
+ _parcelasLabel = value;
+ OnPropertyChanged("ParcelasLabel");
+ }
+ }
+
+ public Documento SelectedControle
+ {
+ get
+ {
+ return _selectedControle;
+ }
+ set
+ {
+ _selectedControle = value;
+ int enableButtons;
+ if (value != null && ((DomainBase)value).Id > 0)
+ {
+ Usuario usuario = Recursos.Usuario;
+ enableButtons = ((usuario != null && ((DomainBase)usuario).Id > 0) ? 1 : 0);
+ }
+ else
+ {
+ enableButtons = 0;
+ }
+ base.EnableButtons = (byte)enableButtons != 0;
+ bool flag = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 13);
+ base.EnableEndossar = value != null && ((DomainBase)value).Id > 0 && (flag || (!string.IsNullOrWhiteSpace(value.Apolice) && !string.IsNullOrWhiteSpace(value.Proposta) && value.Emissao.HasValue));
+ base.EnableRenovar = value != null && ((DomainBase)value).Id > 0 && value.Vigencia2.HasValue && !string.IsNullOrWhiteSpace(value.Apolice);
+ WorkOnSelectedDocumento(value);
+ RecusaVisibility = (Visibility)((Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 19) && !string.IsNullOrWhiteSpace((value != null) ? value.Apolice : null) && value.Emissao.HasValue) ? 2 : 0);
+ ItensRevelados = false;
+ MostrarItensVisibility = (Visibility)2;
+ MostrarSinistroVisibility = (Visibility)0;
+ OnPropertyChanged("SelectedControle");
+ }
+ }
+
+ public bool IsFatura
+ {
+ get
+ {
+ return _isFatura;
+ }
+ set
+ {
+ //IL_0004: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000a: Invalid comparison between Unknown and I4
+ if (!value)
+ {
+ value = (int)ComissaoValorVisibility == 2;
+ }
+ _isFatura = value;
+ OnPropertyChanged("IsFatura");
+ }
+ }
+
+ public bool Recarregando { get; set; }
+
+ public bool IsEnabledParcelaItem
+ {
+ get
+ {
+ return _isEnabledParcelaItem;
+ }
+ set
+ {
+ _isEnabledParcelaItem = value;
+ OnPropertyChanged("IsEnabledParcelaItem");
+ }
+ }
+
+ public Item SelectedItem
+ {
+ get
+ {
+ return _selectedItem;
+ }
+ set
+ {
+ _selectedItem = value;
+ WorkOnSelectedItem(value);
+ OnPropertyChanged("SelectedItem");
+ }
+ }
+
+ public ObservableCollection<Item> Itens
+ {
+ get
+ {
+ return _itens;
+ }
+ set
+ {
+ _itens = value;
+ OnPropertyChanged("Itens");
+ }
+ }
+
+ public Parcela SelectedParcela
+ {
+ get
+ {
+ return _selectedParcela;
+ }
+ set
+ {
+ _selectedParcela = value;
+ OnPropertyChanged("SelectedParcela");
+ }
+ }
+
+ public ObservableCollection<Parcela> Parcelas
+ {
+ get
+ {
+ return _parcelas;
+ }
+ set
+ {
+ _parcelas = value;
+ OnPropertyChanged("Parcelas");
+ }
+ }
+
+ public Visibility IsVisibleRadioEndosso
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleRadioEndosso;
+ }
+ 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)
+ _isVisibleRadioEndosso = value;
+ OnPropertyChanged("IsVisibleRadioEndosso");
+ }
+ }
+
+ public Visibility IsVisibleEndosso
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleEndosso;
+ }
+ 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)
+ _isVisibleEndosso = value;
+ OnPropertyChanged("IsVisibleEndosso");
+ }
+ }
+
+ public Visibility IsVisibleApolice
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleApolice;
+ }
+ 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)
+ _isVisibleApolice = value;
+ OnPropertyChanged("IsVisibleApolice");
+ }
+ }
+
+ public string PendenciaApolice
+ {
+ get
+ {
+ return _pendenciaApolice;
+ }
+ set
+ {
+ _pendenciaApolice = value;
+ IsVisiblePendenciaApolice = (Visibility)(string.IsNullOrEmpty(_pendenciaApolice) ? 2 : 0);
+ OnPropertyChanged("PendenciaApolice");
+ }
+ }
+
+ public Visibility IsVisiblePendenciaApolice
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisiblePendenciaApolice;
+ }
+ 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)
+ _isVisiblePendenciaApolice = value;
+ OnPropertyChanged("IsVisiblePendenciaApolice");
+ }
+ }
+
+ public decimal Gerada
+ {
+ get
+ {
+ return _gerada;
+ }
+ set
+ {
+ _gerada = value;
+ OnPropertyChanged("Gerada");
+ }
+ }
+
+ public decimal Recebida
+ {
+ get
+ {
+ return _recebida;
+ }
+ set
+ {
+ _recebida = value;
+ OnPropertyChanged("Recebida");
+ }
+ }
+
+ public decimal Pendente
+ {
+ get
+ {
+ return _pendente;
+ }
+ set
+ {
+ _pendente = value;
+ OnPropertyChanged("Pendente");
+ }
+ }
+
+ public bool IsLoadingParcelas
+ {
+ get
+ {
+ return _isLoadingParcelas;
+ }
+ set
+ {
+ _isLoadingParcelas = value;
+ OnPropertyChanged("IsLoadingParcelas");
+ }
+ }
+
+ public bool IsLoadingItens
+ {
+ get
+ {
+ return _isLoadingItens;
+ }
+ set
+ {
+ _isLoadingItens = value;
+ OnPropertyChanged("IsLoadingItens");
+ }
+ }
+
+ public static int FiltrarItens { get; set; }
+
+ public int FilterItens
+ {
+ get
+ {
+ return _filterItens;
+ }
+ set
+ {
+ _filterItens = value;
+ FiltrarItens = value;
+ OnPropertyChanged("FilterItens");
+ }
+ }
+
+ public int FilterDocumento
+ {
+ get
+ {
+ return _filterDocumento;
+ }
+ set
+ {
+ _filterDocumento = value;
+ Gestor.Application.Actions.Actions.UpdateRadioApolice?.Invoke(_filterDocumento);
+ OnPropertyChanged("FilterDocumento");
+ }
+ }
+
+ public Visibility ManutencaoItemVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _manutencaoItemVisibility;
+ }
+ set
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ _manutencaoItemVisibility = (Visibility)(Restricao((TipoRestricao)22) ? 2 : ((int)value));
+ OnPropertyChanged("ManutencaoItemVisibility");
+ }
+ }
+
+ public Visibility RecusaVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _recusaVisibility;
+ }
+ set
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ _recusaVisibility = (Visibility)(Restricao((TipoRestricao)18) ? 2 : ((int)value));
+ OnPropertyChanged("RecusaVisibility");
+ }
+ }
+
+ public Visibility RenovarVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _renovarVisibility;
+ }
+ set
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ _renovarVisibility = (Visibility)(Restricao((TipoRestricao)17) ? 2 : ((int)value));
+ OnPropertyChanged("RenovarVisibility");
+ }
+ }
+
+ public Visibility EndossarVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _endossarVisibility;
+ }
+ set
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ _endossarVisibility = (Visibility)(Restricao((TipoRestricao)33) ? 2 : ((int)value));
+ OnPropertyChanged("EndossarVisibility");
+ }
+ }
+
+ public Visibility TrocarClienteVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _trocarClienteVisibility;
+ }
+ set
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ _trocarClienteVisibility = (Visibility)(Restricao((TipoRestricao)21) ? 2 : ((int)value));
+ OnPropertyChanged("TrocarClienteVisibility");
+ }
+ }
+
+ public Visibility TarefasVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _tarefasVisibility;
+ }
+ set
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ _tarefasVisibility = (Visibility)((!Permissao((TipoTela)38)) ? 2 : ((int)value));
+ OnPropertyChanged("TarefasVisibility");
+ }
+ }
+
+ public Visibility ComissaoVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _comissaoVisibility;
+ }
+ set
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ _comissaoVisibility = (Visibility)(Restricao((TipoRestricao)95) ? 2 : ((int)value));
+ OnPropertyChanged("ComissaoVisibility");
+ }
+ }
+
+ public Visibility ComissaoValorVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _comissaoValorVisibility;
+ }
+ set
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ _comissaoValorVisibility = (Visibility)(Restricao((TipoRestricao)14) ? 2 : ((int)value));
+ OnPropertyChanged("ComissaoValorVisibility");
+ }
+ }
+
+ public Visibility MostrarItensVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _mostrarItensVisibility;
+ }
+ 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)
+ _mostrarItensVisibility = value;
+ OnPropertyChanged("MostrarItensVisibility");
+ }
+ }
+
+ public Visibility MostrarSinistroVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _mostrarSinistroVisibility;
+ }
+ 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)
+ _mostrarSinistroVisibility = value;
+ OnPropertyChanged("MostrarSinistroVisibility");
+ }
+ }
+
+ public bool ItensRevelados { get; set; }
+
+ public ObservableCollection<ClienteTelefone> Telefones
+ {
+ get
+ {
+ return _telefones;
+ }
+ set
+ {
+ _telefones = value;
+ OnPropertyChanged("Telefones");
+ }
+ }
+
+ public ConsultaViewModel()
+ {
+ //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)
+ //IL_0012: Expected O, but got Unknown
+ //IL_0029: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0033: Expected O, but got Unknown
+ //IL_003f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0049: Expected O, but got Unknown
+ //IL_0051: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005b: Expected O, but got Unknown
+ //IL_0067: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0071: Expected O, but got Unknown
+ //IL_007e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0085: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0097: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ac: Unknown result type (might be due to invalid IL or missing references)
+ _apoliceServico = new ApoliceServico();
+ _parcelaServico = new ParcelaServico();
+ _vendedorServico = new VendedorServico();
+ _itemServico = new ItemServico();
+ Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 6);
+ SemDocumentos = (Visibility)0;
+ base.EnableButtons = false;
+ if (MainViewModel.ClienteSelecionado != null && ((DomainBase)MainViewModel.ClienteSelecionado).Id > 0)
+ {
+ SelecionarCliente(MainViewModel.ClienteSelecionado);
+ }
+ }
+
+ public async Task Pesquisar(PesquisaAvancada pesquisa)
+ {
+ MainViewModel.StatusSelecionado = pesquisa.Status;
+ if (pesquisa.IdDocumento == 0L)
+ {
+ await SelecionarCliente(pesquisa.IdCliente, selecionar: true);
+ return;
+ }
+ Pesquisando = true;
+ await SelecionarCliente(pesquisa.IdCliente, selecionar: false);
+ Loading(isLoading: true);
+ Documento documento = await _apoliceServico.BuscarApoliceAsync(pesquisa.IdDocumento);
+ if (documento == null || Apolices.Count == 0 || Apolices == null)
+ {
+ Pesquisando = false;
+ Loading(isLoading: false);
+ return;
+ }
+ Documento val = ((IEnumerable<Documento>)Apolices).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x.Controle).Id == ((DomainBase)documento.Controle).Id));
+ if (val == null && documento.Tipo == 1)
+ {
+ val = documento;
+ val.TemEndosso = true;
+ if (val == null)
+ {
+ Pesquisando = false;
+ Loading(isLoading: false);
+ return;
+ }
+ }
+ SelectedControle = val;
+ IsVisibleApolice = (Visibility)0;
+ VisibilityParcelasVendedores = (Visibility)2;
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ PendenciaApolice = (string.IsNullOrEmpty(val.Apolice) ? $"{(date - val.Vigencia1).TotalDays} DIAS DE PENDÊNCIA" : "");
+ IsVisibleRadioEndosso = (Visibility)((!val.TemEndosso) ? 2 : 0);
+ if (val.TemEndosso)
+ {
+ IsVisibleRadioEndosso = (Visibility)0;
+ Endossos = new ObservableCollection<Documento>(val.Controle.Documentos.Where((Documento x) => x.Tipo == 1 && !x.Excluido));
+ }
+ if (documento.Tipo == 1)
+ {
+ documento = Endossos.First((Documento x) => ((DomainBase)x).Id == ((DomainBase)documento).Id);
+ FilterDocumento = 1;
+ IsVisibleEndosso = (Visibility)0;
+ SelectedEndosso = documento;
+ PendenciaApolice = (string.IsNullOrEmpty(documento.Endosso) ? $"{(date - documento.Vigencia1).TotalDays} DIAS DE PENDÊNCIA" : "");
+ }
+ CarregaDocumentos(documento.Tipo);
+ await SelecionaParcelas(documento);
+ VisibilityParcelasVendedores = (Visibility)0;
+ Pesquisando = false;
+ if (pesquisa.IdItem == 0L)
+ {
+ await SelecionaItens((documento.Tipo == 0) ? 1 : 2, documento, 0L);
+ Loading(isLoading: false);
+ return;
+ }
+ await SelecionaItens((documento.Tipo == 0) ? 1 : 2, documento, pesquisa.IdItem, pesquisaAvancada: true);
+ SelecionaItem(((IEnumerable<Item>)Itens).FirstOrDefault((Func<Item, bool>)((Item x) => ((DomainBase)x).Id == pesquisa.IdItem)));
+ Loading(isLoading: false);
+ if (pesquisa.IdSinistro != 0L)
+ {
+ Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)7, "");
+ }
+ }
+
+ public async void SelecionarCliente(Cliente cliente)
+ {
+ await SelecionaCliente(cliente);
+ ScrollDocumento();
+ }
+
+ public void ScrollDocumento()
+ {
+ if (UpdatingScroll)
+ {
+ return;
+ }
+ UpdatingScroll = true;
+ Task.Run(async delegate
+ {
+ await Task.Delay(300);
+ ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate
+ {
+ Gestor.Application.Actions.Actions.ScrollDocumento?.Invoke();
+ });
+ });
+ }
+
+ public async Task SelecionarCliente(long id, bool selecionar)
+ {
+ await SelecionaCliente(await new ClienteServico().BuscarCliente(id), selecionar);
+ }
+
+ public async Task SelecionaCliente(Cliente value, bool selecionar = true)
+ {
+ Clear();
+ if (value == null || ((DomainBase)value).Id == 0L)
+ {
+ base.IsVisible = (Visibility)2;
+ return;
+ }
+ try
+ {
+ Carregando = true;
+ Loading(isLoading: true);
+ SelectedCliente = value;
+ ApoliceServico apoliceServico = _apoliceServico;
+ long id = ((DomainBase)value).Id;
+ FiltroStatusDocumento statusSelecionado = MainViewModel.StatusSelecionado;
+ List<VendedorUsuario> vendedorVinculado = ((Recursos.Usuario != null) ? (await VerificaVinculoVendedor(Recursos.Usuario)) : new List<VendedorUsuario>());
+ Apolices = await apoliceServico.BuscarApolicesAsync(id, statusSelecionado, vendedorVinculado);
+ ConsultaViewModel consultaViewModel = this;
+ string descricao = "CONSULTOU " + (((int)MainViewModel.StatusSelecionado != 4) ? ("OS " + Functions.GetDescription((Enum)(object)MainViewModel.StatusSelecionado)) : "TODOS OS DOCUMENTOS") + " DO CLIENTE \"" + SelectedCliente.Nome + "\"";
+ long id2 = ((DomainBase)SelectedCliente).Id;
+ TipoTela? tela = (TipoTela)21;
+ Cliente selectedCliente = SelectedCliente;
+ consultaViewModel.RegistrarAcao(descricao, id2, tela, $"ID CLIENTE: {((selectedCliente != null) ? new long?(((DomainBase)selectedCliente).Id) : null)}");
+ if (Apolices != null && Apolices.Count > 0)
+ {
+ if (!selecionar)
+ {
+ Loading(isLoading: false);
+ Carregando = false;
+ return;
+ }
+ if (DocumentoSelecionado != null && DocumentoSelecionado.Tipo != 0)
+ {
+ Controle controle = DocumentoSelecionado.Controle;
+ long? obj;
+ if (controle == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ Cliente cliente = controle.Cliente;
+ obj = ((cliente != null) ? new long?(((DomainBase)cliente).Id) : null);
+ }
+ if (obj == ((DomainBase)value).Id)
+ {
+ Controle controle2 = DocumentoSelecionado.Controle;
+ long? obj2;
+ if (controle2 == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ IList<Documento> documentos = controle2.Documentos;
+ if (documentos == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Documento? obj3 = ((IEnumerable<Documento>)documentos).FirstOrDefault((Func<Documento, bool>)((Documento x) => x.Tipo == 0));
+ obj2 = ((obj3 != null) ? new long?(((DomainBase)obj3).Id) : null);
+ }
+ }
+ long? num = obj2;
+ long documentId = num.GetValueOrDefault();
+ Documento documentoSelecionado = DocumentoSelecionado;
+ long? endossoId = ((documentoSelecionado != null) ? new long?(((DomainBase)documentoSelecionado).Id) : null);
+ if (((documentId > 0) ? ((IEnumerable<Documento>)Apolices).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == documentId)) : null) != null)
+ {
+ await SelecionaDocumento(0, ((IEnumerable<Documento>)Apolices).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == documentId)));
+ FilterDocumento = 1;
+ IsVisibleEndosso = (Visibility)0;
+ SelectedEndosso = ((IEnumerable<Documento>)Endossos).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == endossoId)) ?? Endossos[0];
+ IsLoading = false;
+ await WorkOnSelectedEndosso(SelectedEndosso);
+ CarregaDocumentos(1);
+ }
+ else
+ {
+ await SelecionaDocumento(0, (DocumentoSelecionado != null) ? (((IEnumerable<Documento>)Apolices).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == ((DomainBase)DocumentoSelecionado).Id)) ?? Apolices.FirstOrDefault()) : Apolices.FirstOrDefault());
+ CarregaDocumentos(0);
+ }
+ goto IL_06af;
+ }
+ }
+ await SelecionaDocumento(0, (DocumentoSelecionado != null) ? (((IEnumerable<Documento>)Apolices).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == ((DomainBase)DocumentoSelecionado).Id)) ?? Apolices.FirstOrDefault()) : Apolices.FirstOrDefault());
+ CarregaDocumentos(0);
+ }
+ else
+ {
+ SelectedControle = null;
+ SelectedEndosso = null;
+ SelectedItem = null;
+ SelectedParcela = null;
+ DocumentoSelecionado = null;
+ ItemSelecionado = null;
+ FilterDocumento = 0;
+ IsVisibleRadioEndosso = (Visibility)2;
+ Gestor.Application.Actions.Actions.UpdateDocumento?.Invoke(null);
+ }
+ goto IL_06af;
+ IL_06af:
+ ManutencaoItemVisibility = (Visibility)0;
+ RenovarVisibility = (Visibility)0;
+ TrocarClienteVisibility = (Visibility)0;
+ TarefasVisibility = (Visibility)0;
+ EndossarVisibility = (Visibility)0;
+ ComissaoVisibility = (Visibility)0;
+ Loading(isLoading: false);
+ }
+ catch (Exception e)
+ {
+ Clear();
+ SelectedControle = null;
+ SelectedEndosso = null;
+ SelectedItem = null;
+ SelectedParcela = null;
+ DocumentoSelecionado = null;
+ ItemSelecionado = null;
+ FilterDocumento = 0;
+ IsVisibleRadioEndosso = (Visibility)2;
+ Gestor.Application.Actions.Actions.UpdateDocumento?.Invoke(null);
+ new BaseServico().Registrar(e, (TipoErro)1, 3, new { value, selecionar });
+ }
+ Carregando = false;
+ }
+
+ private void Clear()
+ {
+ Apolices = null;
+ Parcelas = null;
+ Itens = null;
+ }
+
+ private async Task WorkOnSelectedEndosso(Documento value)
+ {
+ if (value == null || ((DomainBase)value).Id == 0L || IsLoading)
+ {
+ return;
+ }
+ DocumentoSelecionado = value;
+ base.IsEnabled = false;
+ IsLoading = true;
+ VisibilityParcelasVendedores = (Visibility)2;
+ PendenciaApolice = (string.IsNullOrEmpty(value.Endosso) ? $"{(Funcoes.GetNetworkTime().Date - value.Vigencia1).TotalDays} DIAS DE PENDÊNCIA" : "");
+ await SelecionaParcelas(value);
+ Item itemSelecionado = ItemSelecionado;
+ long item = ((itemSelecionado != null) ? ((DomainBase)itemSelecionado).Id : 0);
+ await SelecionaItens(FilterItens, null, 0L);
+ if (item > 0 && Itens != null && Itens.Any((Item x) => ((DomainBase)x).Id == item))
+ {
+ ItemSelecionado = Itens.First((Item x) => ((DomainBase)x).Id == item);
+ SelecionaItem(ItemSelecionado);
+ Gestor.Application.Actions.Actions.ScrollToItem?.Invoke();
+ }
+ VisibilityParcelasVendedores = (Visibility)0;
+ ConsultaViewModel consultaViewModel = this;
+ int num;
+ if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 19))
+ {
+ if (!string.IsNullOrWhiteSpace((value != null) ? value.Apolice : null) && value.Emissao.HasValue)
+ {
+ num = 2;
+ goto IL_027b;
+ }
+ }
+ num = 0;
+ goto IL_027b;
+ IL_027b:
+ consultaViewModel.RecusaVisibility = (Visibility)num;
+ base.IsEnabled = true;
+ IsLoading = false;
+ }
+
+ private void WorkOnSelectedDocumento(Documento value)
+ {
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002e: Invalid comparison between Unknown and I4
+ //IL_004f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0055: Invalid comparison between Unknown and I4
+ if (value != null && ((DomainBase)value).Id != 0L && !Recarregando)
+ {
+ DocumentoSelecionado = value;
+ ParcelasLabel = (((int)DocumentoSelecionado.TipoRecebimento.GetValueOrDefault() == 2) ? "FATURAS" : "PARCELAS");
+ IsFatura = (int)DocumentoSelecionado.TipoRecebimento.GetValueOrDefault() == 2;
+ Gestor.Application.Actions.Actions.UpdateDocumento?.Invoke(value);
+ }
+ }
+
+ private async Task WorkOnSelectedControle(Documento value)
+ {
+ if (value == null || ((DomainBase)value).Id == 0L || IsLoading)
+ {
+ return;
+ }
+ DocumentoSelecionado = value;
+ IsEnabledParcelaItem = false;
+ IsLoading = true;
+ VisibilityParcelasVendedores = (Visibility)2;
+ PendenciaApolice = (string.IsNullOrEmpty(value.Apolice) ? $"{(Funcoes.GetNetworkTime().Date - value.Vigencia1).TotalDays} DIAS DE PENDÊNCIA" : "");
+ IsVisibleRadioEndosso = (Visibility)((!value.TemEndosso) ? 2 : 0);
+ await SelecionaParcelas(value);
+ VisibilityParcelasVendedores = (Visibility)0;
+ FilterItens = 0;
+ Item itemSelecionado = ItemSelecionado;
+ long item = ((itemSelecionado != null) ? ((DomainBase)itemSelecionado).Id : 0);
+ await SelecionaItens(FilterItens, value, 0L);
+ if (item > 0 && Itens != null && Itens.Any((Item x) => ((DomainBase)x).Id == item))
+ {
+ ItemSelecionado = Itens.First((Item x) => ((DomainBase)x).Id == item);
+ SelecionaItem(ItemSelecionado);
+ Gestor.Application.Actions.Actions.ScrollToItem?.Invoke();
+ }
+ IsLoading = false;
+ IsEnabledParcelaItem = true;
+ }
+
+ private void CalculaComissao(Documento documento, ObservableCollection<Parcela> parcelas)
+ {
+ decimal num = (documento.AdicionalComiss ? (documento.PremioLiquido + documento.PremioAdicional) : documento.PremioLiquido);
+ decimal num2 = documento.Comissao * 0.01m;
+ Gerada = num * num2;
+ Recebida = (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 32) ? parcelas.Where((Parcela x) => (int)x.SubTipo == 1 || (int)x.SubTipo == 6).Sum((Parcela x) => x.ValorComissao) : parcelas.Where((Parcela x) => (int)x.SubTipo == 1).Sum((Parcela x) => x.ValorComissao));
+ Pendente = Gerada - Recebida;
+ Pendente = ((Pendente < 0.01m) ? 0.00m : Pendente);
+ }
+
+ public async Task SelecionaParcelas(Documento documento = null)
+ {
+ if (documento == null)
+ {
+ documento = SelectedControle;
+ }
+ ObservableCollection<Parcela> observableCollection = await _parcelaServico.BuscarParcelasPorDocumento(documento);
+ Parcelas = (((int)documento.TipoRecebimento.GetValueOrDefault() == 2) ? new ObservableCollection<Parcela>(observableCollection.OrderByDescending((Parcela x) => x.NumeroParcela)) : observableCollection);
+ SelectedParcela = ((Parcelas != null && Parcelas.Count > 0) ? Parcelas[0] : null);
+ CalculaComissao(documento, Parcelas);
+ IsLoadingParcelas = true;
+ }
+
+ public async Task SelecionaItens(int type, Documento documento = null, long iditem = 0L, bool pesquisaAvancada = false)
+ {
+ if (documento == null)
+ {
+ documento = SelectedControle;
+ }
+ if (documento == null)
+ {
+ return;
+ }
+ IsLoadingItens = false;
+ bool flag = !pesquisaAvancada;
+ if (flag)
+ {
+ flag = await VerificaItens(documento);
+ }
+ if (flag)
+ {
+ return;
+ }
+ await CarregaItens(type, documento);
+ int filterItens = FilterItens;
+ if (iditem == 0L && filterItens != 2)
+ {
+ Item val = Itens?.FirstOrDefault((Func<Item, bool>)delegate(Item i)
+ {
+ long id3 = ((DomainBase)i).Id;
+ Item selectedItem5 = SelectedItem;
+ return id3 == ((selectedItem5 != null) ? new long?(((DomainBase)selectedItem5).Id) : null);
+ });
+ if (val != null || filterItens == 0)
+ {
+ SelectedItem = (Item)((val != null) ? ((object)val) : ((object)Itens?.FirstOrDefault()));
+ }
+ else if (val == null && filterItens == 1)
+ {
+ Item selectedItem = SelectedItem;
+ if (selectedItem != null && selectedItem.Substituicao > 0)
+ {
+ val = Itens?.FirstOrDefault((Func<Item, bool>)delegate(Item i)
+ {
+ long id2 = ((DomainBase)i).Id;
+ Item selectedItem4 = SelectedItem;
+ return id2 == ((selectedItem4 != null) ? selectedItem4.Substituicao : null);
+ });
+ }
+ SelectedItem = (Item)((val != null) ? ((object)val) : ((object)Itens?.FirstOrDefault()));
+ }
+ Item selectedItem2 = SelectedItem;
+ if (selectedItem2 != null && selectedItem2.Substituido > 0 && filterItens != 1)
+ {
+ FilterItens = 3;
+ Itens = await _itemServico.BuscarItens(((DomainBase)documento.Controle).Id, (StatusItem)1);
+ val = Itens?.FirstOrDefault((Func<Item, bool>)delegate(Item i)
+ {
+ long id = ((DomainBase)i).Id;
+ Item selectedItem3 = SelectedItem;
+ return id == ((selectedItem3 != null) ? new long?(((DomainBase)selectedItem3).Id) : null);
+ });
+ SelectedItem = (Item)((val != null) ? ((object)val) : ((object)Itens?.FirstOrDefault()));
+ }
+ }
+ IsLoadingItens = true;
+ }
+
+ public async Task<bool> VerificaItens(Documento documento)
+ {
+ if (!ItensRevelados && await _itemServico.ChecarQuantidade(((DomainBase)documento).Id) > 2)
+ {
+ Itens = new ObservableCollection<Item>();
+ Itens.Add(new Item
+ {
+ Id = 0L,
+ Descricao = "Item - Apólice Coletiva"
+ });
+ MostrarItensVisibility = (Visibility)0;
+ MostrarSinistroVisibility = (Visibility)2;
+ return true;
+ }
+ return false;
+ }
+
+ public async Task MostrarItens(int type = 0)
+ {
+ IsLoadingItens = false;
+ MostrarItensVisibility = (Visibility)2;
+ MostrarSinistroVisibility = (Visibility)0;
+ ItensRevelados = true;
+ Documento documento = DocumentoSelecionado;
+ if (type == 1 && DocumentoSelecionado.Tipo == 1)
+ {
+ documento = SelectedControle;
+ }
+ await CarregaItens(type, documento);
+ ObservableCollection<Item> itens = Itens;
+ if (itens != null && itens.Count > 1)
+ {
+ SelectedItem = Itens?.FirstOrDefault();
+ }
+ IsLoadingItens = true;
+ }
+
+ public async Task CarregaItens(int type, Documento documento)
+ {
+ FilterItens = 0;
+ switch (type)
+ {
+ case 0:
+ Itens = await _itemServico.BuscarItens(((DomainBase)documento.Controle).Id, (StatusItem)0);
+ break;
+ case 1:
+ FilterItens = 1;
+ Itens = await _itemServico.BuscarItens(((DomainBase)documento).Id, (StatusItem)2);
+ break;
+ case 2:
+ FilterItens = 2;
+ documento = SelectedEndosso ?? documento;
+ Itens = await _itemServico.BuscarItens(((DomainBase)documento).Id, (StatusItem)2);
+ break;
+ case 3:
+ FilterItens = 3;
+ Itens = await _itemServico.BuscarItens(((DomainBase)documento.Controle).Id, (StatusItem)1);
+ break;
+ }
+ }
+
+ public async Task SelecionaDocumento(int type, Documento documento)
+ {
+ if (Pesquisando)
+ {
+ return;
+ }
+ if (documento == null)
+ {
+ FilterDocumento = 0;
+ IsVisibleRadioEndosso = (Visibility)2;
+ IsVisibleApolice = (Visibility)0;
+ return;
+ }
+ documento.Controle.Cliente.Nome = SelectedCliente.Nome;
+ if (type != 1)
+ {
+ FilterDocumento = 0;
+ IsVisibleRadioEndosso = (Visibility)2;
+ IsVisibleApolice = (Visibility)0;
+ SelectedControle = documento;
+ await WorkOnSelectedControle(documento);
+ if (documento.TemEndosso)
+ {
+ IsVisibleRadioEndosso = (Visibility)0;
+ Endossos = new ObservableCollection<Documento>(documento.Controle.Documentos.Where((Documento x) => x.Tipo == 1 && (((DomainBase)Recursos.Usuario).Id == 0L || !x.Excluido)));
+ }
+ }
+ else
+ {
+ FilterDocumento = 1;
+ IsVisibleEndosso = (Visibility)0;
+ SelectedEndosso = documento;
+ await WorkOnSelectedEndosso(documento);
+ }
+ }
+
+ public void CarregaDocumentos(int type)
+ {
+ IsVisibleApolice = (Visibility)2;
+ IsVisibleEndosso = (Visibility)2;
+ if (type != 1)
+ {
+ IsVisibleApolice = (Visibility)0;
+ }
+ else
+ {
+ IsVisibleEndosso = (Visibility)0;
+ }
+ }
+
+ public void SelecionaItem(Item item)
+ {
+ if (item != null && ((DomainBase)item).Id != 0L)
+ {
+ FilterItens = ((item != null && item.Substituido > 0) ? 3 : 0);
+ SelectedItem = item;
+ }
+ }
+
+ private static void WorkOnSelectedItem(Item value)
+ {
+ if (value != null)
+ {
+ Item itemSelecionado = ItemSelecionado;
+ if (((itemSelecionado != null) ? new long?(((DomainBase)itemSelecionado).Id) : null) == ((DomainBase)value).Id)
+ {
+ return;
+ }
+ }
+ ItemSelecionado = value;
+ Gestor.Application.Actions.Actions.UpdateItem?.Invoke(value);
+ }
+
+ public async Task<Documento> AbrirDetalhes()
+ {
+ Documento documento = SelectedControle;
+ if (FilterDocumento == 1)
+ {
+ documento = SelectedEndosso ?? SelectedControle;
+ }
+ Documento val = documento;
+ val.Pagamentos = await _vendedorServico.BuscaRepasse(((DomainBase)documento).Id);
+ val = documento;
+ val.Parcelas = await _parcelaServico.BuscarParcelasAsync(((DomainBase)documento).Id);
+ return documento;
+ }
+
+ public async Task EditarParcelas()
+ {
+ await ShowEditarParcelasDialog(DocumentoSelecionado);
+ await SelecionaParcelas(DocumentoSelecionado);
+ }
+
+ public async Task RecusarDocumento()
+ {
+ if (DocumentoSelecionado == null)
+ {
+ return;
+ }
+ bool[] array = await Funcoes.VerificarPagamento(((DomainBase)DocumentoSelecionado).Id);
+ if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 23) && array.Any((bool x) => x))
+ {
+ await ShowMessage("NÃO É POSSÍVEL RECUSAR UMA APÓLICE ENQUANTO HOUVER RECEBIMENTO DE COMISSÃO OU PAGAMENTO DE VENDEDORES");
+ return;
+ }
+ bool flag = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 23) && array[1];
+ if (flag)
+ {
+ flag = await ShowMessage("EXISTEM PAGAMENTOS PARA OS VENDEDORES DO CONTRATO, DESEJA CRIAR ESTORNOS PARA ESSES PAGAMENTOS?", "SIM", "NÃO");
+ }
+ bool estorno = flag;
+ Documento documento = await _apoliceServico.BuscarApoliceAsync(((DomainBase)DocumentoSelecionado).Id);
+ IList<Documento> list;
+ if (documento.Controle.Documentos.Count <= 1)
+ {
+ list = documento.Controle.Documentos;
+ }
+ else
+ {
+ IList<Documento> list2 = (from x in documento.Controle.Documentos
+ where !x.Excluido
+ orderby x.Ordem
+ select x).ToList();
+ list = list2;
+ }
+ IList<Documento> list3 = list;
+ if (list3.Count > 1 && ((DomainBase)list3.Last((Documento x) => (int)x.Situacao != 7)).Id != ((DomainBase)DocumentoSelecionado).Id)
+ {
+ await ShowMessage("NÃO É POSSÍVEL RECUSAR UM DOCUMENTO ENQUANTO HOUVER ENDOSSOS EM CIMA DO MESMO.");
+ return;
+ }
+ if ((int)documento.Situacao == 7)
+ {
+ await ShowMessage("NÃO É POSSÍVEL RECUSAR UM DOCUMENTO JÁ RECUSADO.");
+ return;
+ }
+ string text = ((documento.Tipo == 0 && string.IsNullOrEmpty(documento.Apolice)) ? "A PROPOSTA SELECIONADA" : ((documento.Tipo == 0 && !string.IsNullOrEmpty(documento.Apolice)) ? "A APÓLICE SELECIONADA" : "O ENDOSSO SELECIONADO"));
+ if (await ShowMessage("DESEJA REALMENTE RECUSAR " + text + "?", "SIM", "NÃO"))
+ {
+ string text2 = await ShowObservacaoDialog();
+ if (text2 != null)
+ {
+ Loading(isLoading: true);
+ await Funcoes.RecusarApolice(documento, text2, estorno);
+ DocumentoSelecionado = null;
+ await SelecionaCliente(SelectedCliente);
+ Loading(isLoading: false);
+ }
+ }
+ }
+
+ public async Task<Parcela> AbrirDetalhesParcela()
+ {
+ Parcela parcela = SelectedParcela;
+ parcela.Vendedores = new ObservableCollection<VendedorParcela>(await _vendedorServico.BuscaRepasseParcela(((DomainBase)parcela).Id));
+ return parcela;
+ }
+
+ public void ManutecaoItens()
+ {
+ Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)3, "Manutencao");
+ }
+
+ public async Task GerarExcel(int type)
+ {
+ if (SelectedControle == null)
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ bool iniciar = Type.GetTypeFromProgID("Excel.Application") != null;
+ string descricao = "ATIVOS";
+ ObservableCollection<Item> observableCollection;
+ switch (type)
+ {
+ default:
+ observableCollection = await _itemServico.BuscarItems(((DomainBase)SelectedControle.Controle).Id, (StatusItem)0, sinsitroCompleto: true);
+ break;
+ case 1:
+ descricao = "DA APÓLICE";
+ observableCollection = await _itemServico.BuscarItems(((DomainBase)SelectedControle).Id, (StatusItem)2, sinsitroCompleto: true);
+ break;
+ case 2:
+ {
+ Documento val = SelectedEndosso ?? SelectedControle;
+ descricao = ((SelectedEndosso == null) ? "DA APÓLICE" : "DO ENDOSSO");
+ observableCollection = await _itemServico.BuscarItems(((DomainBase)val).Id, (StatusItem)2, sinsitroCompleto: true);
+ break;
+ }
+ case 3:
+ descricao = "INATIVOS";
+ observableCollection = await _itemServico.BuscarItems(((DomainBase)SelectedControle.Controle).Id, (StatusItem)1, sinsitroCompleto: true);
+ break;
+ }
+ if (observableCollection == null || observableCollection.Count == 0)
+ {
+ Loading(isLoading: false);
+ await ShowMessage("NÃO HÁ ITENS PARA EXIBIR A RELAÇÃO");
+ return;
+ }
+ List<RelacaoItens> itensList = new List<RelacaoItens>();
+ observableCollection.ToList().ForEach(delegate(Item x)
+ {
+ string Coberturas = "";
+ if (x.Coberturas.Count() > 0)
+ {
+ x.Coberturas.ToList().ForEach(delegate(Cobertura c)
+ {
+ Coberturas += $"Cobertura: {c.Observacao} | Premio: {c.Premio} | Franquia: {c.Franquia} | LMI: {c.Lmi}\n";
+ });
+ }
+ RelacaoItens obj = new RelacaoItens
+ {
+ Nome = SelectedCliente.Nome,
+ Documento = SelectedCliente.Documento,
+ Apolice = SelectedControle.Apolice,
+ VigenciaInicial = SelectedControle.Vigencia1,
+ VigenciaFinal = SelectedControle.Vigencia2,
+ Ordem = x.Ordem,
+ Sinistrado = (x.Sinistrado ? "SIM" : "NÃO")
+ };
+ ControleSinistro? obj2 = x.Sinistros.FirstOrDefault();
+ obj.DataSinistro = ((obj2 != null) ? obj2.DataSinistro : null);
+ ControleSinistro? obj3 = x.Sinistros.FirstOrDefault();
+ object numSinistro;
+ if (obj3 == null)
+ {
+ numSinistro = null;
+ }
+ else
+ {
+ Sinistro? obj4 = obj3.Sinistros.FirstOrDefault();
+ numSinistro = ((obj4 != null) ? obj4.Numero : null);
+ }
+ obj.NumSinistro = (string)numSinistro;
+ ControleSinistro? obj5 = x.Sinistros.FirstOrDefault();
+ StatusSinistro? statusSinistro;
+ if (obj5 == null)
+ {
+ statusSinistro = null;
+ }
+ else
+ {
+ Sinistro? obj6 = obj5.Sinistros.FirstOrDefault();
+ statusSinistro = ((obj6 != null) ? obj6.StatusSinistro : null);
+ }
+ obj.StatusSinistro = statusSinistro;
+ ControleSinistro? obj7 = x.Sinistros.FirstOrDefault();
+ object itemSinistrado;
+ if (obj7 == null)
+ {
+ itemSinistrado = null;
+ }
+ else
+ {
+ Sinistro? obj8 = obj7.Sinistros.FirstOrDefault();
+ itemSinistrado = ((obj8 != null) ? obj8.ItemSinistrado : null);
+ }
+ obj.ItemSinistrado = (string)itemSinistrado;
+ ControleSinistro? obj9 = x.Sinistros.FirstOrDefault();
+ decimal? valor;
+ if (obj9 == null)
+ {
+ valor = null;
+ }
+ else
+ {
+ Sinistro? obj10 = obj9.Sinistros.FirstOrDefault();
+ valor = ((obj10 != null) ? new decimal?(obj10.Valor) : null);
+ }
+ obj.Valor = valor;
+ ControleSinistro? obj11 = x.Sinistros.FirstOrDefault();
+ DateTime? dataLiq;
+ if (obj11 == null)
+ {
+ dataLiq = null;
+ }
+ else
+ {
+ Sinistro? obj12 = obj11.Sinistros.FirstOrDefault();
+ dataLiq = ((obj12 != null) ? obj12.DataLiquidacao : null);
+ }
+ obj.DataLiq = dataLiq;
+ ControleSinistro? obj13 = x.Sinistros.FirstOrDefault();
+ DateTime? dataRec;
+ if (obj13 == null)
+ {
+ dataRec = null;
+ }
+ else
+ {
+ Sinistro? obj14 = obj13.Sinistros.FirstOrDefault();
+ dataRec = ((obj14 != null) ? obj14.DataReclamacao : null);
+ }
+ obj.DataRec = dataRec;
+ ControleSinistro? obj15 = x.Sinistros.FirstOrDefault();
+ object motivo;
+ if (obj15 == null)
+ {
+ motivo = null;
+ }
+ else
+ {
+ Sinistro? obj16 = obj15.Sinistros.FirstOrDefault();
+ motivo = ((obj16 != null) ? obj16.Motivo : null);
+ }
+ obj.Motivo = (string)motivo;
+ obj.Status = (string.IsNullOrEmpty(x.Status) ? x.StatusInclusao : x.Status);
+ obj.Cobertura = ((Coberturas.Length > 4000) ? Coberturas.Substring(0, 4000) : Coberturas);
+ RelacaoItens relacaoItens = obj;
+ switch (((DomainBase)SelectedControle.Controle.Ramo).Id)
+ {
+ case 1L:
+ case 2L:
+ case 3L:
+ case 18L:
+ relacaoItens.Endereco = ((EnderecoBase)x.Patrimonial).Endereco;
+ relacaoItens.Numero = ((EnderecoBase)x.Patrimonial).Numero;
+ relacaoItens.Bairro = ((EnderecoBase)x.Patrimonial).Bairro;
+ relacaoItens.Cidade = ((EnderecoBase)x.Patrimonial).Cidade;
+ relacaoItens.Estado = ((EnderecoBase)x.Patrimonial).Estado;
+ relacaoItens.Cep = ((EnderecoBase)x.Patrimonial).Cep;
+ relacaoItens.Complemento = ((EnderecoBase)x.Patrimonial).Complemento;
+ relacaoItens.Bens = x.Patrimonial.Bens;
+ relacaoItens.Descricao = x.Descricao;
+ break;
+ case 5L:
+ case 37L:
+ {
+ relacaoItens.Fipe = x.Auto.Fipe;
+ Fabricante fabricante = x.Auto.Fabricante;
+ relacaoItens.Fabricante = ((fabricante != null) ? fabricante.Descricao : null);
+ relacaoItens.Modelo = x.Auto.Modelo;
+ relacaoItens.AnoFab = x.Auto.AnoFabricacao;
+ relacaoItens.AnoMod = x.Auto.AnoModelo;
+ relacaoItens.Chassi = x.Auto.Chassi;
+ relacaoItens.Placa = x.Auto.Placa;
+ relacaoItens.RegiaoCirculacao = x.Auto.RegiaoCirculacao;
+ relacaoItens.Bonus = x.Auto.Bonus;
+ relacaoItens.Descricao = x.Descricao;
+ break;
+ }
+ default:
+ relacaoItens.Descricao = x.Descricao;
+ break;
+ }
+ itensList.Add(relacaoItens);
+ });
+ string text = "";
+ string fileName;
+ if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 41))
+ {
+ FolderBrowserDialog val2 = new FolderBrowserDialog();
+ try
+ {
+ if (1 != (int)((CommonDialog)val2).ShowDialog())
+ {
+ return;
+ }
+ text = val2.SelectedPath + "\\";
+ Directory.CreateDirectory(text);
+ }
+ finally
+ {
+ ((IDisposable)val2)?.Dispose();
+ }
+ fileName = string.Format("{0}ITENS - {1} {2} {3}.xlsx", text, descricao, SelectedControle.Apolice.Replace("/", ""), Guid.NewGuid());
+ }
+ else
+ {
+ text = Path.GetTempPath();
+ fileName = $"{text}{Guid.NewGuid()}.xlsx";
+ }
+ (await Funcoes.GerarXls(new XLWorkbook(), "ITENS - " + SelectedControle.Apolice?.Replace("/", ""), itensList)).SaveAs(fileName);
+ if (!iniciar)
+ {
+ await ShowMessage("ARQUIVO SALVO NO CAMINHO " + fileName);
+ }
+ else
+ {
+ Process.Start(fileName);
+ }
+ RegistrarAcao($"GEROU A RELAÇÃO DOS ITENS DO DOCUMENTO DE ID {((DomainBase)SelectedControle).Id}", ((DomainBase)SelectedControle).Id, (TipoTela)21);
+ Loading(isLoading: false);
+ }
+
+ public async void SalvarOrdem(ObservableCollection<Item> itens)
+ {
+ if (itens == null)
+ {
+ return;
+ }
+ if (itens.Any((Item x) => x.Ordem == 0))
+ {
+ await ShowMessage("O CAMPO ORDEM DEVE SER MAIOR QUE ZERO.");
+ return;
+ }
+ if ((from item in itens
+ group item by item.Ordem).Any((IGrouping<int?, Item> x) => x.Count() > 1))
+ {
+ await ShowMessage("EXISTEM ITENS COM ORDEM REPETIDA. \nDEFINA UMA SEQUÊNCIA DIFERENTE PARA CADA ITEM.");
+ return;
+ }
+ Loading(isLoading: true);
+ foreach (Item iten in itens)
+ {
+ await _itemServico.Save(iten);
+ }
+ await SelecionaItens(FilterItens, null, 0L);
+ Loading(isLoading: false);
+ }
+
+ public async Task<string> CreateLink(Documento documento)
+ {
+ if (documento == null || SelectedCliente == null)
+ {
+ return "";
+ }
+ Telefones = new ObservableCollection<ClienteTelefone>(await new ClienteServico().BuscarTelefonesAsync(((DomainBase)SelectedCliente).Id));
+ object obj2;
+ if (Itens != null)
+ {
+ if (Itens.Count <= 1)
+ {
+ Item? obj = Itens.FirstOrDefault();
+ obj2 = ((obj != null) ? obj.Descricao : null);
+ }
+ else
+ {
+ obj2 = "APÓLICE COLETIVA";
+ }
+ }
+ else
+ {
+ obj2 = "";
+ }
+ string item = (string)obj2;
+ return await CreateLinkAssistencia(documento, item);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Seguros/CriticaApoliceViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Seguros/CriticaApoliceViewModel.cs
new file mode 100644
index 0000000..1bc6e72
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Seguros/CriticaApoliceViewModel.cs
@@ -0,0 +1,1109 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows;
+using Gestor.Application.Helpers;
+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.Seguros;
+
+namespace Gestor.Application.ViewModels.Seguros;
+
+public class CriticaApoliceViewModel : BaseApoliceViewModel
+{
+ private readonly CriticaApoliceServico _criticaServico;
+
+ private readonly ClienteServico _clienteServico;
+
+ private readonly ItemServico _itemServico;
+
+ private List<VendedorUsuario> Vinculos;
+
+ private ObservableCollection<Usuario> _usuarios = new ObservableCollection<Usuario>();
+
+ private ObservableCollection<Seguradora> _seguradorasFiltro = new ObservableCollection<Seguradora>();
+
+ private string _fieldNascimento = "NASCIMENTO";
+
+ private bool _isExpanded = true;
+
+ private DateTime _inicio = Funcoes.GetNetworkTime().Date.AddDays(-7.0);
+
+ private DateTime _fim = Funcoes.GetNetworkTime().Date;
+
+ private Usuario _selectedUsuario;
+
+ private Seguradora _selectedSeguradora;
+
+ private bool _criticado;
+
+ private ObservableCollection<CriticaApolice> _criticas = new ObservableCollection<CriticaApolice>();
+
+ private ObservableCollection<CriticaApolice> _criticaFiltrada = new ObservableCollection<CriticaApolice>();
+
+ private bool _isCriticaSelected;
+
+ private CriticaApolice _selectedCritica;
+
+ private bool _hasChange;
+
+ private bool _isParcela;
+
+ private DateTime? _emissaoCritica;
+
+ private DateTime? _transmissaoCritica;
+
+ private DateTime? _nascimentoCritica;
+
+ private TipoSeguro? _situacao;
+
+ private Cliente _selectedCliente;
+
+ private string _documentoPrincipal;
+
+ private Visibility _visibilityFisica = (Visibility)2;
+
+ private ObservableCollection<ClienteTelefone> _telefones = new ObservableCollection<ClienteTelefone>();
+
+ private ObservableCollection<ClienteEmail> _emails = new ObservableCollection<ClienteEmail>();
+
+ private ObservableCollection<Item> _itens = new ObservableCollection<Item>();
+
+ private bool _enableGrid = true;
+
+ private string _pesquisa = "";
+
+ private ObservableCollection<string> _pesquisaCritica = new ObservableCollection<string>();
+
+ private string _profissaoText;
+
+ private string _atividadeText;
+
+ private Visibility _visibilityJuridica = (Visibility)2;
+
+ private string _fieldDocumento = "CPF";
+
+ private Visibility _valorComissao;
+
+ public ObservableCollection<Usuario> Usuarios
+ {
+ get
+ {
+ return _usuarios;
+ }
+ set
+ {
+ _usuarios = value;
+ SelectedUsuario = SelectedUsuario ?? value.FirstOrDefault();
+ OnPropertyChanged("Usuarios");
+ }
+ }
+
+ public ObservableCollection<Seguradora> SeguradorasFiltro
+ {
+ get
+ {
+ return _seguradorasFiltro;
+ }
+ set
+ {
+ _seguradorasFiltro = value;
+ SelectedSeguradora = SelectedSeguradora ?? value.FirstOrDefault();
+ OnPropertyChanged("SeguradorasFiltro");
+ }
+ }
+
+ public string FieldNascimento
+ {
+ get
+ {
+ return _fieldNascimento;
+ }
+ set
+ {
+ _fieldNascimento = value;
+ OnPropertyChanged("FieldNascimento");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public DateTime Inicio
+ {
+ get
+ {
+ return _inicio;
+ }
+ set
+ {
+ _inicio = value;
+ OnPropertyChanged("Inicio");
+ }
+ }
+
+ public DateTime Fim
+ {
+ get
+ {
+ return _fim;
+ }
+ set
+ {
+ _fim = value;
+ OnPropertyChanged("Fim");
+ }
+ }
+
+ public Usuario SelectedUsuario
+ {
+ get
+ {
+ return _selectedUsuario;
+ }
+ set
+ {
+ _selectedUsuario = value;
+ OnPropertyChanged("SelectedUsuario");
+ }
+ }
+
+ public Seguradora SelectedSeguradora
+ {
+ get
+ {
+ return _selectedSeguradora;
+ }
+ set
+ {
+ _selectedSeguradora = value;
+ OnPropertyChanged("SelectedSeguradora");
+ }
+ }
+
+ public bool Criticado
+ {
+ get
+ {
+ return _criticado;
+ }
+ set
+ {
+ _criticado = value;
+ OnPropertyChanged("Criticado");
+ }
+ }
+
+ public ObservableCollection<CriticaApolice> Criticas
+ {
+ get
+ {
+ return _criticas;
+ }
+ set
+ {
+ _criticas = value;
+ OnPropertyChanged("Criticas");
+ }
+ }
+
+ public ObservableCollection<CriticaApolice> CriticaFiltrada
+ {
+ get
+ {
+ return _criticaFiltrada;
+ }
+ set
+ {
+ _criticaFiltrada = value;
+ OnPropertyChanged("CriticaFiltrada");
+ }
+ }
+
+ public bool IsCriticaSelected
+ {
+ get
+ {
+ return _isCriticaSelected;
+ }
+ set
+ {
+ _isCriticaSelected = value;
+ OnPropertyChanged("IsCriticaSelected");
+ }
+ }
+
+ public CriticaApolice SelectedCritica
+ {
+ get
+ {
+ return _selectedCritica;
+ }
+ set
+ {
+ _selectedCritica = value;
+ IsCriticaSelected = value != null;
+ OnPropertyChanged("SelectedCritica");
+ }
+ }
+
+ public bool HasChange
+ {
+ get
+ {
+ return _hasChange;
+ }
+ set
+ {
+ _hasChange = value;
+ OnPropertyChanged("HasChange");
+ }
+ }
+
+ public bool IsParcela
+ {
+ get
+ {
+ return _isParcela;
+ }
+ set
+ {
+ _isParcela = value;
+ OnPropertyChanged("IsParcela");
+ }
+ }
+
+ public DateTime? EmissaoCritica
+ {
+ get
+ {
+ return _emissaoCritica;
+ }
+ set
+ {
+ _emissaoCritica = value;
+ OnPropertyChanged("EmissaoCritica");
+ }
+ }
+
+ public DateTime? TransmissaoCritica
+ {
+ get
+ {
+ return _transmissaoCritica;
+ }
+ set
+ {
+ _transmissaoCritica = value;
+ OnPropertyChanged("TransmissaoCritica");
+ }
+ }
+
+ public DateTime? NascimentoCritica
+ {
+ get
+ {
+ return _nascimentoCritica;
+ }
+ set
+ {
+ _nascimentoCritica = value;
+ OnPropertyChanged("NascimentoCritica");
+ }
+ }
+
+ public bool BuscaInicial { get; set; } = true;
+
+
+ public bool SeguroCombinado { get; set; }
+
+ public bool IsLoading { get; set; }
+
+ public TipoSeguro? StatusDocumento
+ {
+ get
+ {
+ return _situacao;
+ }
+ set
+ {
+ _situacao = value;
+ OnPropertyChanged("StatusDocumento");
+ }
+ }
+
+ public Cliente SelectedCliente
+ {
+ get
+ {
+ return _selectedCliente;
+ }
+ set
+ {
+ _selectedCliente = value;
+ OnPropertyChanged("SelectedCliente");
+ }
+ }
+
+ public string DocumentoPrincipal
+ {
+ get
+ {
+ return _documentoPrincipal;
+ }
+ set
+ {
+ //IL_005e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0063: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0064: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0066: Invalid comparison between Unknown and I4
+ //IL_0068: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006a: Invalid comparison between Unknown and I4
+ if (value == null || ValidationHelper.OnlyNumber(value).Length > 11)
+ {
+ VisibilityFisica = (Visibility)2;
+ FieldNascimento = "FUNDAÇÃO";
+ }
+ else
+ {
+ VisibilityFisica = (Visibility)0;
+ FieldNascimento = "NASCIMENTO";
+ }
+ _documentoPrincipal = value;
+ if (SelectedCliente != null)
+ {
+ TipoDocumento? documentoPrincipal = SelectedCliente.DocumentoPrincipal;
+ if (!documentoPrincipal.HasValue)
+ {
+ goto IL_006c;
+ }
+ TipoDocumento valueOrDefault = documentoPrincipal.GetValueOrDefault();
+ if ((int)valueOrDefault != 1)
+ {
+ if ((int)valueOrDefault != 2)
+ {
+ goto IL_006c;
+ }
+ SelectedCliente.Cei = value;
+ }
+ else
+ {
+ SelectedCliente.Rne = value;
+ }
+ }
+ goto IL_0094;
+ IL_006c:
+ SelectedCliente.Documento = value;
+ goto IL_0094;
+ IL_0094:
+ OnPropertyChanged("DocumentoPrincipal");
+ }
+ }
+
+ public Visibility VisibilityFisica
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityFisica;
+ }
+ 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)
+ _visibilityFisica = value;
+ OnPropertyChanged("VisibilityFisica");
+ }
+ }
+
+ public ObservableCollection<ClienteTelefone> Telefones
+ {
+ get
+ {
+ return _telefones;
+ }
+ set
+ {
+ _telefones = value;
+ OnPropertyChanged("Telefones");
+ }
+ }
+
+ public ObservableCollection<ClienteEmail> Emails
+ {
+ get
+ {
+ return _emails;
+ }
+ set
+ {
+ _emails = value;
+ OnPropertyChanged("Emails");
+ }
+ }
+
+ public ObservableCollection<Item> Itens
+ {
+ get
+ {
+ return _itens;
+ }
+ set
+ {
+ _itens = value;
+ OnPropertyChanged("Itens");
+ }
+ }
+
+ public int Index { get; set; } = -1;
+
+
+ public bool EnableGrid
+ {
+ get
+ {
+ return _enableGrid;
+ }
+ set
+ {
+ _enableGrid = value;
+ OnPropertyChanged("EnableGrid");
+ }
+ }
+
+ public string Pesquisa
+ {
+ get
+ {
+ return _pesquisa;
+ }
+ set
+ {
+ _pesquisa = value;
+ OnPropertyChanged("Pesquisa");
+ }
+ }
+
+ public ObservableCollection<string> PesquisaCritica
+ {
+ get
+ {
+ return _pesquisaCritica;
+ }
+ set
+ {
+ _pesquisaCritica = value;
+ OnPropertyChanged("PesquisaCritica");
+ }
+ }
+
+ public string ProfissaoText
+ {
+ get
+ {
+ return _profissaoText;
+ }
+ set
+ {
+ _profissaoText = value;
+ OnPropertyChanged("ProfissaoText");
+ }
+ }
+
+ public string AtividadeText
+ {
+ get
+ {
+ return _atividadeText;
+ }
+ set
+ {
+ _atividadeText = value;
+ OnPropertyChanged("AtividadeText");
+ }
+ }
+
+ public Visibility VisibilityJuridica
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityJuridica;
+ }
+ 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)
+ _visibilityJuridica = value;
+ OnPropertyChanged("VisibilityJuridica");
+ }
+ }
+
+ public string FieldDocumento
+ {
+ get
+ {
+ return _fieldDocumento;
+ }
+ set
+ {
+ _fieldDocumento = value;
+ OnPropertyChanged("FieldDocumento");
+ }
+ }
+
+ public Visibility ValorComissao
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _valorComissao;
+ }
+ 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)
+ _valorComissao = value;
+ OnPropertyChanged("ValorComissao");
+ }
+ }
+
+ public CriticaApoliceViewModel()
+ {
+ //IL_007e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ca: Unknown result type (might be due to invalid IL or missing references)
+ base.Invoke = false;
+ _criticaServico = new CriticaApoliceServico();
+ _clienteServico = new ClienteServico();
+ _itemServico = new ItemServico();
+ }
+
+ public async Task InitialLoad()
+ {
+ IsLoading = true;
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)2);
+ await SelecionaUsuario();
+ await CarregarUsuarios(0L);
+ await CarregarSeguradoras();
+ CriticaApoliceViewModel criticaApoliceViewModel = this;
+ Usuario selectedUsuario = SelectedUsuario;
+ await criticaApoliceViewModel.CarregaCritica((selectedUsuario != null) ? ((DomainBase)selectedUsuario).Id : 0, 0L);
+ Loading(isLoading: false);
+ IsLoading = false;
+ }
+
+ public async Task SelecionaUsuario()
+ {
+ IsLoading = true;
+ if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 38 || (int)x.Configuracao == 43) && ((DomainBase)Recursos.Usuario).Id != 0L)
+ {
+ Vinculos = await VerificaVinculoVendedor(Recursos.Usuario);
+ }
+ IsLoading = false;
+ }
+
+ public async Task CarregarUsuarios(long selected = 0L, bool criticado = false)
+ {
+ IsLoading = true;
+ Criticado = criticado;
+ List<Usuario> list = new List<Usuario>();
+ List<VendedorUsuario> vinculos = Vinculos;
+ if (vinculos != null && vinculos.Count > 0)
+ {
+ list.Insert(0, new Usuario
+ {
+ Id = ((DomainBase)Recursos.Usuario).Id,
+ Nome = Recursos.Usuario.Nome
+ });
+ }
+ else
+ {
+ list = await _criticaServico.BuscarUsuarioCritica(Inicio, Fim, Criticado);
+ list.Insert(0, new Usuario
+ {
+ Id = 0L,
+ Nome = "TODOS OS USUÁRIOS"
+ });
+ }
+ Usuarios = new ObservableCollection<Usuario>(list);
+ SelectedUsuario = ((IEnumerable<Usuario>)Usuarios).FirstOrDefault((Func<Usuario, bool>)((Usuario x) => ((DomainBase)x).Id == selected)) ?? Usuarios.FirstOrDefault();
+ IsLoading = false;
+ }
+
+ public async Task CarregarSeguradoras()
+ {
+ IsLoading = true;
+ List<Seguradora> list = (await _criticaServico.BuscarSeguradorasAsync()).OrderBy((Seguradora x) => x.Nome).ToList();
+ list.Insert(0, new Seguradora
+ {
+ Id = 0L,
+ Nome = "TODAS AS SEGURADORAS",
+ Ativo = true
+ });
+ SeguradorasFiltro = new ObservableCollection<Seguradora>(list.Where((Seguradora x) => x.Ativo));
+ SelectedSeguradora = SeguradorasFiltro.FirstOrDefault();
+ IsLoading = false;
+ }
+
+ public async Task CarregaCritica(long usuario, long seguradora, bool criticado = false)
+ {
+ if (!IsLoading || BuscaInicial)
+ {
+ BuscaInicial = false;
+ EnableGrid = false;
+ Loading(isLoading: true);
+ Criticado = criticado;
+ await CarregarUsuarios(usuario, Criticado);
+ Criticas = new ObservableCollection<CriticaApolice>(from x in await _criticaServico.BuscarCritica(usuario, Inicio, Fim, 0L, Criticado, Vinculos)
+ where (usuario == 0L || ((DomainBase)x.UsuarioImportacao).Id == usuario) && (seguradora == 0L || ((DomainBase)x.Documento.Controle.Seguradora).Id == seguradora)
+ orderby x.DataImportacao, x.Documento.Controle.Cliente.Nome descending
+ select x);
+ CriticaFiltrada = Criticas;
+ if (CriticaFiltrada != null && CriticaFiltrada.Count > 0)
+ {
+ await SelecionaCritica(CriticaFiltrada.First());
+ }
+ else
+ {
+ IsCriticaSelected = false;
+ }
+ CriticaApoliceViewModel criticaApoliceViewModel = this;
+ ObservableCollection<CriticaApolice> criticaFiltrada = CriticaFiltrada;
+ criticaApoliceViewModel.IsExpanded = criticaFiltrada != null && criticaFiltrada.Count > 0;
+ Loading(isLoading: false);
+ Usuario val = Usuarios?.FirstOrDefault((Func<Usuario, bool>)((Usuario x) => ((DomainBase)x).Id == usuario));
+ Seguradora val2 = base.Seguradoras?.FirstOrDefault((Func<Seguradora, bool>)((Seguradora x) => ((DomainBase)x).Id == seguradora));
+ RegistrarAcao($"CONSULTOU CRÍTICAS NO PERÍODO ENTRE {Inicio:d} E {Fim:d}", 0L, (TipoTela)20, (PesquisaCritica != null && PesquisaCritica.Count > 0) ? string.Format("USUÁRIO IMPORTAÇÃO: {0} ({1})\nSEGURADORA: {2} ({3})\nCRITICADOS: {4}\nPESQUISA PERSONALIZADA: \"{5}\"", ((val != null) ? val.Nome : null) ?? "TODOS USUÁRIOS", (val != null) ? ((DomainBase)val).Id : 0, ((val2 != null) ? val2.Nome : null) ?? "TODAS AS SEGURADORAS", (val2 != null) ? ((DomainBase)val2).Id : 0, Criticado ? "SIM" : "NÃO", ValidationHelper.Join((IEnumerable<string>)PesquisaCritica, ", ")) : string.Format("USUÁRIO IMPORTAÇÃO: {0} ({1})\nSEGURADORA: {2} ({3})\nCRITICADOS: {4}", ((val != null) ? val.Nome : null) ?? "TODOS USUÁRIOS", (val != null) ? ((DomainBase)val).Id : 0, ((val2 != null) ? val2.Nome : null) ?? "TODAS AS SEGURADORAS", (val2 != null) ? ((DomainBase)val2).Id : 0, Criticado ? "SIM" : "NÃO"));
+ EnableGrid = true;
+ }
+ }
+
+ public async Task SelecionaCritica(CriticaApolice critica)
+ {
+ if (critica != null && !IsLoading)
+ {
+ IsLoading = true;
+ Loading(isLoading: true);
+ critica.Documento = await Servico.BuscarApoliceAsync(((DomainBase)critica.Documento).Id);
+ base.SelectedDocumento = null;
+ base.Repasses = null;
+ base.Parcelas = null;
+ base.Pagamentos = null;
+ base.SelectedParcela = null;
+ base.SelectedPagamento = null;
+ SelectedCritica = critica;
+ await SelecionaDocumento(critica.Documento);
+ EmissaoCritica = ((critica.Documento != null && critica.Documento.Emissao.HasValue) ? critica.Documento.Emissao : new DateTime?(Funcoes.GetNetworkTime().Date));
+ TransmissaoCritica = ((critica.Documento != null && critica.Documento.Remessa.HasValue) ? critica.Documento.Remessa : new DateTime?(Funcoes.GetNetworkTime().Date));
+ StatusDocumento = (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 3) ? new TipoSeguro?(base.SelectedDocumento.Situacao) : null);
+ if (base.SelectedDocumento == null)
+ {
+ IsParcela = true;
+ HasChange = false;
+ Loading(isLoading: false);
+ return;
+ }
+ IsParcela = (int)base.SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1;
+ await SelecionaCliente(base.SelectedDocumento.Controle.Cliente);
+ await SelecionaItens(((DomainBase)base.SelectedDocumento.Controle).Id);
+ HasChange = false;
+ Loading(isLoading: false);
+ IsLoading = false;
+ }
+ }
+
+ public async Task SelecionaItens(long id)
+ {
+ Itens = await _itemServico.BuscarItens(id, (StatusItem)0);
+ }
+
+ public async Task SelecionaCliente(Cliente cliente)
+ {
+ TipoDocumento? documentoPrincipal = cliente.DocumentoPrincipal;
+ if (!documentoPrincipal.HasValue)
+ {
+ goto IL_0040;
+ }
+ TipoDocumento valueOrDefault = documentoPrincipal.GetValueOrDefault();
+ if ((int)valueOrDefault != 1)
+ {
+ if ((int)valueOrDefault != 2)
+ {
+ goto IL_0040;
+ }
+ DocumentoPrincipal = cliente.Cei;
+ }
+ else
+ {
+ DocumentoPrincipal = cliente.Rne;
+ }
+ goto IL_0088;
+ IL_0088:
+ NascimentoCritica = ((cliente != null && cliente.Nascimento.HasValue) ? cliente.Nascimento : new DateTime?(Funcoes.GetNetworkTime().Date));
+ SelectedCliente = cliente;
+ ((DomainBase)SelectedCliente).Initialize();
+ Telefones = await _clienteServico.BuscarTelefonesAsync(((DomainBase)SelectedCliente).Id);
+ if (Telefones.Count == 0)
+ {
+ Telefones.Add(new ClienteTelefone
+ {
+ Cliente = SelectedCliente
+ });
+ }
+ Telefones.ToList().ForEach(delegate(ClienteTelefone x)
+ {
+ ((DomainBase)x).Initialize();
+ });
+ Emails = await _clienteServico.BuscarEmailsAsync(((DomainBase)SelectedCliente).Id);
+ if (Emails.Count == 0)
+ {
+ Emails.Add(new ClienteEmail
+ {
+ Cliente = SelectedCliente
+ });
+ }
+ Emails.ToList().ForEach(delegate(ClienteEmail x)
+ {
+ ((DomainBase)x).Initialize();
+ });
+ return;
+ IL_0040:
+ DocumentoPrincipal = cliente.Documento;
+ cliente.DocumentoPrincipal = (TipoDocumento)0;
+ goto IL_0088;
+ }
+
+ public async Task ConcluirCritica()
+ {
+ DateTime now = Funcoes.GetNetworkTime();
+ SelectedCritica.Critica = true;
+ SelectedCritica.DataCritica = now;
+ SelectedCritica.UsuarioCritica = ((DomainBase)Recursos.Usuario).Id;
+ foreach (CriticaApolice item2 in await _criticaServico.BuscarCritica(((DomainBase)SelectedCritica.Documento).Id))
+ {
+ item2.Critica = true;
+ item2.DataCritica = now;
+ item2.UsuarioCritica = ((DomainBase)Recursos.Usuario).Id;
+ await _criticaServico.Save(item2);
+ }
+ if (SeguroCombinado)
+ {
+ List<CriticaApolice> list = (await _criticaServico.BuscarSeguroCombinado(((DomainBase)SelectedCritica.Documento.Controle.Cliente).Id, SelectedCritica.Documento.Vigencia1)).Where(delegate(CriticaApolice duo)
+ {
+ if (((DomainBase)duo.Documento.Controle.Seguradora).Id == ((DomainBase)SelectedCritica.Documento.Controle.Seguradora).Id && ((DomainBase)duo.Documento.Controle.Cliente).Id == ((DomainBase)SelectedCritica.Documento.Controle.Cliente).Id && duo.Documento.Vigencia1 == SelectedCritica.Documento.Vigencia1)
+ {
+ DateTime? vigencia = duo.Documento.Vigencia2;
+ DateTime? vigencia2 = SelectedCritica.Documento.Vigencia2;
+ if (vigencia.HasValue == vigencia2.HasValue && (!vigencia.HasValue || vigencia.GetValueOrDefault() == vigencia2.GetValueOrDefault()) && ((DomainBase)duo.Documento).Id != ((DomainBase)SelectedCritica.Documento).Id && duo.Documento.Apolice == SelectedCritica.Documento.Apolice && duo.Documento.Proposta == null)
+ {
+ return true;
+ }
+ }
+ return Regex.Replace(duo.Documento.Proposta, "[^.'-,/]", "") == Regex.Replace(SelectedCritica.Documento.Proposta, "[^.'-,/]", "");
+ }).ToList();
+ List<CriticaApolice> list2 = ((list == null || list.Count() <= 0) ? null : (await _criticaServico.BuscarCritica(((DomainBase)list.FirstOrDefault().Documento).Id)));
+ list = list2;
+ if (list != null && list.Any())
+ {
+ foreach (CriticaApolice seguroduo in list)
+ {
+ seguroduo.Critica = true;
+ seguroduo.DataCritica = now;
+ seguroduo.Documento.PremioLiquido = 0.01m;
+ seguroduo.Documento.PremioTotal = 0.01m;
+ seguroduo.Documento.Comissao = 0.01m;
+ seguroduo.UsuarioCritica = ((DomainBase)Recursos.Usuario).Id;
+ await _criticaServico.Save(seguroduo);
+ await Servico.Save(seguroduo.Documento, updateParcelas: false, criarParcelas: false);
+ }
+ }
+ }
+ string text = ((SelectedCritica.Tipo == "0") ? ("A PROPOSTA \"" + CancelDocumento.Proposta + "\"") : ((SelectedCritica.Tipo == "1") ? ("A APÓLICE \"" + CancelDocumento.Apolice + "\"") : ("O ENDOSSO \"" + CancelDocumento.Endosso + "\"")));
+ RegistrarAcao("CONCLUIU A CRÍTICA D" + text, ((DomainBase)SelectedCritica).Id, (TipoTela)20);
+ object obj2;
+ if (Itens != null)
+ {
+ if (Itens.Count <= 1)
+ {
+ Item? obj = Itens.FirstOrDefault();
+ obj2 = ((obj != null) ? obj.Descricao : null);
+ }
+ else
+ {
+ obj2 = "APÓLICE COLETIVA";
+ }
+ }
+ else
+ {
+ obj2 = "";
+ }
+ string item = (string)obj2;
+ try
+ {
+ if (string.IsNullOrEmpty(base.SelectedDocumento.Controle.AssistenciaId))
+ {
+ await CreateLinkAssistencia(base.SelectedDocumento, item, retorno: false);
+ }
+ }
+ catch (Exception)
+ {
+ }
+ base.SelectedDocumento = null;
+ SelectedCliente = null;
+ Telefones = null;
+ Emails = null;
+ Itens = null;
+ await CarregaCritica(((DomainBase)SelectedUsuario).Id, ((DomainBase)SelectedSeguradora).Id, Criticado);
+ }
+
+ public async void ExcluirTelefone(ClienteTelefone telefone)
+ {
+ if (Telefones.Count < 2)
+ {
+ await ShowMessage("É NECESSÁRIO TER AO MENOS UM TELEFONE CADASTRADO.");
+ return;
+ }
+ HasChange = true;
+ bool num = telefone.Ordem != Telefones.Count;
+ int quantidate = Telefones.Count;
+ Telefones.Remove(telefone);
+ if (num && ((IEnumerable<ClienteTelefone>)Telefones).FirstOrDefault((Func<ClienteTelefone, bool>)((ClienteTelefone x) => x.Ordem == quantidate)) != null)
+ {
+ Telefones.First((ClienteTelefone x) => x.Ordem == quantidate).Ordem = telefone.Ordem;
+ Telefones = new ObservableCollection<ClienteTelefone>(Telefones.OrderBy((ClienteTelefone x) => x.Ordem));
+ }
+ }
+
+ public async void ExcluirEmail(ClienteEmail email)
+ {
+ if (Emails.Count < 2)
+ {
+ await ShowMessage("É NECESSÁRIO TER AO MENOS UM CONTATO DE E-MAIL CADASTRADO.");
+ return;
+ }
+ HasChange = true;
+ bool num = email.Ordem != Emails.Count;
+ int quantidate = Emails.Count;
+ Emails.Remove(email);
+ if (num && ((IEnumerable<ClienteEmail>)Emails).FirstOrDefault((Func<ClienteEmail, bool>)((ClienteEmail x) => x.Ordem == quantidate)) != null)
+ {
+ Emails.First((ClienteEmail x) => x.Ordem == quantidate).Ordem = email.Ordem;
+ Emails = new ObservableCollection<ClienteEmail>(Emails.OrderBy((ClienteEmail x) => x.Ordem));
+ }
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> SalvarCliente()
+ {
+ if (!HasChange && !((DomainBase)SelectedCliente).HasChange() && Telefones.All((ClienteTelefone x) => !((DomainBase)x).HasChange()) && Emails.All((ClienteEmail x) => !((DomainBase)x).HasChange()))
+ {
+ return null;
+ }
+ List<ClienteTelefone> list = Telefones.Where((ClienteTelefone x) => !string.IsNullOrEmpty(((TelefoneBase)x).Numero)).ToList();
+ List<ClienteEmail> list2 = Emails.Where((ClienteEmail x) => !string.IsNullOrEmpty(((EmailBase)x).Email)).ToList();
+ SelectedCliente.Telefones = new ObservableCollection<ClienteTelefone>(list);
+ SelectedCliente.Emails = new ObservableCollection<ClienteEmail>(list2);
+ TipoDocumento? documentoPrincipal = SelectedCliente.DocumentoPrincipal;
+ if (!documentoPrincipal.HasValue)
+ {
+ goto IL_0147;
+ }
+ TipoDocumento valueOrDefault = documentoPrincipal.GetValueOrDefault();
+ if ((int)valueOrDefault != 1)
+ {
+ if ((int)valueOrDefault != 2)
+ {
+ goto IL_0147;
+ }
+ SelectedCliente.Cei = DocumentoPrincipal;
+ }
+ else
+ {
+ SelectedCliente.Rne = DocumentoPrincipal;
+ }
+ goto IL_017e;
+ IL_017e:
+ List<KeyValuePair<string, string>> errorMessages = SelectedCliente.Validate();
+ list.ForEach(delegate(ClienteTelefone x)
+ {
+ errorMessages.AddRange(x.Validate());
+ });
+ list2.ForEach(delegate(ClienteEmail x)
+ {
+ errorMessages.AddRange(x.Validate());
+ });
+ List<KeyValuePair<string, string>> list3 = errorMessages;
+ list3.AddRange(await Validate());
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ await _clienteServico.Save(SelectedCliente);
+ return null;
+ IL_0147:
+ SelectedCliente.Documento = DocumentoPrincipal;
+ goto IL_017e;
+ }
+
+ private async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ bool valida = !string.IsNullOrEmpty(SelectedCliente.Nome);
+ switch (SelectedCliente.DocumentoPrincipal)
+ {
+ case 0L:
+ if (!ValidationHelper.ValidateDocument(SelectedCliente.Documento))
+ {
+ valida = false;
+ }
+ break;
+ case 1L:
+ if (!ValidationHelper.ValidateRne(SelectedCliente.Rne))
+ {
+ valida = false;
+ }
+ break;
+ case 2L:
+ if (!ValidationHelper.ValidateCei(SelectedCliente.Cei))
+ {
+ valida = false;
+ }
+ break;
+ }
+ List<Cliente> list = ((!ValidationHelper.ValidateDocument(SelectedCliente.Documento)) ? new List<Cliente>() : (await new ClienteServico().BuscarClientePorDocumento(SelectedCliente.Documento)));
+ List<Cliente> list2 = list;
+ string nome = "";
+ if (list2.Count > 0)
+ {
+ list2.ForEach(delegate(Cliente x)
+ {
+ if (((DomainBase)x).Id != ((DomainBase)SelectedCliente).Id && SelectedCliente.IdEmpresa == x.IdEmpresa && !string.IsNullOrEmpty(SelectedCliente.Documento) && x.Documento == SelectedCliente.Documento)
+ {
+ valida = false;
+ nome = x.Nome;
+ }
+ });
+ }
+ if (!valida)
+ {
+ errors.Add(new KeyValuePair<string, string>("Documento", "O DOCUMENTO JÁ ESTÁ CADASTRADO PARA O CLIENTE " + nome + "."));
+ }
+ if (SelectedCliente.Telefones == null || SelectedCliente.Telefones.Count == 0)
+ {
+ errors.Add(new KeyValuePair<string, string>("Telefones", "NECESSITA-SE AO MENOS UM TELEFONE VÁLIDO."));
+ }
+ if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 29) && (SelectedCliente.Emails == null || SelectedCliente.Emails.Count == 0))
+ {
+ errors.Add(new KeyValuePair<string, string>("Emails", "NECESSITA-SE AO MENOS UM E-MAIL VÁLIDO."));
+ }
+ return errors;
+ }
+
+ public void AlteraDocumentoPrincipal()
+ {
+ //IL_0020: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0025: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0026: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0028: Invalid comparison between Unknown and I4
+ //IL_002a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002c: Invalid comparison between Unknown and I4
+ if (SelectedCliente == null)
+ {
+ return;
+ }
+ TipoDocumento? documentoPrincipal = SelectedCliente.DocumentoPrincipal;
+ if (documentoPrincipal.HasValue)
+ {
+ TipoDocumento valueOrDefault = documentoPrincipal.GetValueOrDefault();
+ if ((int)valueOrDefault == 1)
+ {
+ DocumentoPrincipal = SelectedCliente.Rne;
+ return;
+ }
+ if ((int)valueOrDefault == 2)
+ {
+ DocumentoPrincipal = SelectedCliente.Cei;
+ return;
+ }
+ }
+ DocumentoPrincipal = SelectedCliente.Documento;
+ SelectedCliente.DocumentoPrincipal = (TipoDocumento)0;
+ }
+
+ public void AdcionarFiltro()
+ {
+ if (!string.IsNullOrEmpty(Pesquisa) && !string.IsNullOrWhiteSpace(Pesquisa.Replace("+", "")))
+ {
+ if (PesquisaCritica == null)
+ {
+ PesquisaCritica = new ObservableCollection<string>();
+ }
+ PesquisaCritica.Add(Pesquisa);
+ Pesquisa = string.Empty;
+ Pesquisar();
+ }
+ }
+
+ public async void Pesquisar()
+ {
+ EnableGrid = false;
+ if (PesquisaCritica == null || PesquisaCritica.Count == 0)
+ {
+ CriticaFiltrada = new ObservableCollection<CriticaApolice>(Criticas);
+ }
+ else
+ {
+ CriticaFiltrada = new ObservableCollection<CriticaApolice>(from x in Criticas
+ where PesquisaCritica.All((string s) => (from f in s.Split(new char[1] { '+' }).ToList()
+ where !string.IsNullOrWhiteSpace(f)
+ select f).Any((string f) => ValidationHelper.RemoveDiacritics(x.Documento.Controle.Cliente.Nome).ToUpper().Contains(ValidationHelper.RemoveDiacritics(f)) || (x.Documento.Controle.Cliente.Documento != null && x.Documento.Controle.Cliente.Documento.Contains(f)) || (x.Documento.Controle.Cliente.Cei != null && x.Documento.Controle.Cliente.Cei.Contains(f)) || (x.Documento.Controle.Cliente.Rne != null && x.Documento.Controle.Cliente.Rne.Contains(f)) || (x.UsuarioImportacao != null && x.UsuarioImportacao.Nome.Contains(f)) || (x.DataImportacao.HasValue && x.DataImportacao.ToString().Contains(f)) || (x.Documento.Apolice != null && x.Documento.Apolice.ToUpper().Contains(f.ToUpper())) || (x.Documento.Proposta != null && x.Documento.Proposta.ToUpper().Contains(f.ToUpper()))))
+ orderby x.DataImportacao, x.Documento.Controle.Cliente.Nome descending
+ select x);
+ }
+ await SelecionaCritica(CriticaFiltrada.FirstOrDefault());
+ EnableGrid = true;
+ }
+
+ public void JuridicaouFisica(string documento)
+ {
+ if (SelectedCliente != null)
+ {
+ ProfissaoText = "";
+ AtividadeText = "";
+ if (documento == null || ValidationHelper.OnlyNumber(documento).Length > 11)
+ {
+ VisibilityJuridica = (Visibility)0;
+ VisibilityFisica = (Visibility)2;
+ FieldNascimento = "FUNDAÇÃO";
+ FieldDocumento = "CNPJ";
+ SelectedCliente.Profissao = null;
+ }
+ else
+ {
+ VisibilityJuridica = (Visibility)2;
+ VisibilityFisica = (Visibility)0;
+ FieldNascimento = "NASCIMENTO";
+ FieldDocumento = "CPF";
+ SelectedCliente.Atividade = null;
+ }
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Seguros/PerfilEmpresaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Seguros/PerfilEmpresaViewModel.cs
new file mode 100644
index 0000000..a119dd3
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Seguros/PerfilEmpresaViewModel.cs
@@ -0,0 +1,256 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using System.Windows;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.Helper;
+using Gestor.Model.Resources;
+
+namespace Gestor.Application.ViewModels.Seguros;
+
+public class PerfilEmpresaViewModel : BaseViewModel
+{
+ private readonly PerfilEmpresaServico _servico;
+
+ private readonly Controle _controle;
+
+ private Visibility _ativaCampos = (Visibility)2;
+
+ private string _equipamentoSeguranca = "";
+
+ private string _equipamentoIncendio = "";
+
+ private bool _enableIncluirPerfil;
+
+ private string _dataConstrucao;
+
+ public long CancelPerfil;
+
+ private PerfilEmpresa _selectedPerfilEmpresa = new PerfilEmpresa();
+
+ public Visibility AtivaCampos
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _ativaCampos;
+ }
+ 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)
+ _ativaCampos = value;
+ OnPropertyChanged("AtivaCampos");
+ }
+ }
+
+ public string EquipamentoSeguranca
+ {
+ get
+ {
+ return _equipamentoSeguranca;
+ }
+ set
+ {
+ _equipamentoSeguranca = value;
+ OnPropertyChanged("EquipamentoSeguranca");
+ }
+ }
+
+ public string EquipamentoIncendio
+ {
+ get
+ {
+ return _equipamentoIncendio;
+ }
+ set
+ {
+ _equipamentoIncendio = value;
+ OnPropertyChanged("EquipamentoIncendio");
+ }
+ }
+
+ public bool EnableIncluirPerfil
+ {
+ get
+ {
+ return _enableIncluirPerfil;
+ }
+ set
+ {
+ _enableIncluirPerfil = value;
+ OnPropertyChanged("EnableIncluirPerfil");
+ }
+ }
+
+ public string DataConstrucao
+ {
+ get
+ {
+ return _dataConstrucao;
+ }
+ set
+ {
+ _dataConstrucao = value?.Replace(" ", "");
+ OnPropertyChanged("DataConstrucao");
+ }
+ }
+
+ public PerfilEmpresa SelectedPerfilEmpresa
+ {
+ get
+ {
+ return _selectedPerfilEmpresa;
+ }
+ set
+ {
+ _selectedPerfilEmpresa = value;
+ if (value != null && ((DomainBase)value).Id > 0)
+ {
+ CancelPerfil = ((DomainBase)value).Id;
+ }
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedPerfilEmpresa");
+ }
+ }
+
+ public PerfilEmpresaViewModel(Controle controle)
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0028: Expected O, but got Unknown
+ _servico = new PerfilEmpresaServico();
+ _controle = controle;
+ Seleciona(((DomainBase)controle).Id);
+ }
+
+ private async void Seleciona(long id)
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)32);
+ await SelecionaPerfil(id);
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaPerfil(long id)
+ {
+ Loading(isLoading: true);
+ SelectedPerfilEmpresa = await _servico.BuscarPerfis(id);
+ if (SelectedPerfilEmpresa != null)
+ {
+ EquipamentoSeguranca = BindingEnumHelper.ConcatenarDescricoesEnum<EquipamentoSeguranca>(SelectedPerfilEmpresa.EquipamentoSeguranca);
+ EquipamentoIncendio = BindingEnumHelper.ConcatenarDescricoesEnum<EquipamentoIncendio>(SelectedPerfilEmpresa.EquipamentoIncendio);
+ if (SelectedPerfilEmpresa.AnoConstrucao.HasValue)
+ {
+ DataConstrucao = SelectedPerfilEmpresa.AnoConstrucao.Value.Year.ToString();
+ }
+ }
+ else
+ {
+ EnableIncluirPerfil = true;
+ EquipamentoSeguranca = "";
+ EquipamentoIncendio = "";
+ }
+ Loading(isLoading: false);
+ }
+
+ public void Incluir()
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0011: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0022: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0046: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0052: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0077: Expected O, but got Unknown
+ PerfilEmpresa selectedPerfilEmpresa = new PerfilEmpresa
+ {
+ Controle = _controle,
+ Cliente = _controle.Cliente,
+ ExclusivoDeposito = false,
+ DivisaTerrenoBaldio = false,
+ PatrimonioHistorio = false,
+ PossuiTelhado = false,
+ CaixasEletronicos = false,
+ Isopainel = false,
+ ConstrucaoReforma = false
+ };
+ SelectedPerfilEmpresa = selectedPerfilEmpresa;
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> errorMessages = SelectedPerfilEmpresa.Validate();
+ errorMessages = ValidateCampos(errorMessages);
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ if (DataConstrucao != null && DataConstrucao != "")
+ {
+ SelectedPerfilEmpresa.AnoConstrucao = DateTime.Parse("01/01/" + DataConstrucao);
+ }
+ SelectedPerfilEmpresa = await _servico.Save(SelectedPerfilEmpresa);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ await SelecionaPerfil(((DomainBase)_controle).Id);
+ ToggleSnackBar("PERFIL SALVO COM SUCESSO");
+ Alterar(alterar: false);
+ return null;
+ }
+
+ private List<KeyValuePair<string, string>> ValidateCampos(List<KeyValuePair<string, string>> errorMessages)
+ {
+ if (DataConstrucao == null)
+ {
+ ValidationHelper.AddValue<string, string>(errorMessages, "ANO DA CONSTRUÇÃO", Messages.DataInvalida, true);
+ }
+ if (!int.TryParse(DataConstrucao, out var _))
+ {
+ ValidationHelper.AddValue<string, string>(errorMessages, "ANO DA CONSTRUÇÃO", Messages.DataInvalida, true);
+ }
+ if (DataConstrucao != null && int.TryParse(DataConstrucao, out var _) && (int.Parse(DataConstrucao) <= 1755 || int.Parse(DataConstrucao) >= 9999))
+ {
+ ValidationHelper.AddValue<string, string>(errorMessages, "ANO DA CONSTRUÇÃO", Messages.DataInvalida, true);
+ }
+ return errorMessages;
+ }
+
+ public void CancelarAlteracao()
+ {
+ Loading(isLoading: true);
+ Alterar(alterar: false);
+ Loading(isLoading: false);
+ }
+
+ public async Task Excluir()
+ {
+ if (SelectedPerfilEmpresa != null && ((DomainBase)SelectedPerfilEmpresa).Id != 0L && await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO"))
+ {
+ Loading(isLoading: true);
+ if (!(await _servico.Delete(SelectedPerfilEmpresa)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ await SelecionaPerfil(((DomainBase)_controle).Id);
+ Loading(isLoading: false);
+ EnableIncluirPerfil = true;
+ AtivaCampos = (Visibility)2;
+ DataConstrucao = null;
+ ToggleSnackBar("PERFIL EXCLUÍDO COM SUCESSO");
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Seguros/PerfilViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Seguros/PerfilViewModel.cs
new file mode 100644
index 0000000..2515b35
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Seguros/PerfilViewModel.cs
@@ -0,0 +1,168 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Seguros;
+
+public class PerfilViewModel : BaseViewModel
+{
+ private readonly PerfilServico _servico;
+
+ private readonly Controle _controle;
+
+ public long CancelPerfil;
+
+ private Perfil _selectedPerfil = new Perfil();
+
+ private ObservableCollection<Perfil> _perfis;
+
+ public Perfil SelectedPerfil
+ {
+ get
+ {
+ return _selectedPerfil;
+ }
+ set
+ {
+ _selectedPerfil = value;
+ if (value != null && ((DomainBase)value).Id > 0)
+ {
+ CancelPerfil = ((DomainBase)value).Id;
+ }
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedPerfil");
+ }
+ }
+
+ public ObservableCollection<Perfil> Perfis
+ {
+ get
+ {
+ return _perfis;
+ }
+ set
+ {
+ _perfis = value;
+ OnPropertyChanged("Perfis");
+ }
+ }
+
+ public PerfilViewModel(Controle controle)
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000b: Expected O, but got Unknown
+ _servico = new PerfilServico();
+ _controle = controle;
+ Seleciona(((DomainBase)controle).Id);
+ }
+
+ private async void Seleciona(long id)
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)32);
+ await SelecionaPerfis(id, 0L);
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaPerfis(long id, long perfilId = 0L)
+ {
+ Loading(isLoading: true);
+ Perfis = new ObservableCollection<Perfil>(await _servico.BuscarPerfis(id));
+ SelectedPerfil = (Perfil)((perfilId == 0L) ? ((object)Perfis.FirstOrDefault()) : ((object)Perfis.First((Perfil x) => ((DomainBase)x).Id == perfilId)));
+ Loading(isLoading: false);
+ }
+
+ public void Incluir()
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0011: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0022: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0046: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0052: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005f: Expected O, but got Unknown
+ Perfil selectedPerfil = new Perfil
+ {
+ Controle = _controle,
+ Cliente = _controle.Cliente,
+ UsoProfissional = false,
+ AntiFurto = (Antifurto)0,
+ Isencao = false,
+ SeguroVida = false,
+ EstenderCobertura = false
+ };
+ SelectedPerfil = selectedPerfil;
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedPerfil.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ SelectedPerfil = await _servico.Save(SelectedPerfil);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ await SelecionaPerfis(((DomainBase)_controle).Id, ((DomainBase)SelectedPerfil).Id);
+ ToggleSnackBar("PERFIL SALVO COM SUCESSO");
+ Alterar(alterar: false);
+ return null;
+ }
+
+ public void CancelarAlteracao()
+ {
+ Loading(isLoading: true);
+ if (CancelPerfil > 0)
+ {
+ SelectedPerfil = ((IEnumerable<Perfil>)Perfis).FirstOrDefault((Func<Perfil, bool>)((Perfil x) => ((DomainBase)x).Id == CancelPerfil));
+ }
+ Alterar(alterar: false);
+ Loading(isLoading: false);
+ }
+
+ public async Task Excluir()
+ {
+ if (SelectedPerfil == null || ((DomainBase)SelectedPerfil).Id == 0L || !(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ bool isLast = SelectedPerfil == Perfis.Last();
+ if (!(await _servico.Delete(SelectedPerfil)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ if (isLast)
+ {
+ int num = Perfis.IndexOf(SelectedPerfil);
+ if (num <= 0)
+ {
+ await SelecionaPerfis(((DomainBase)_controle).Id, 0L);
+ }
+ else
+ {
+ await SelecionaPerfis(((DomainBase)_controle).Id, ((DomainBase)Perfis[num - 1]).Id);
+ }
+ }
+ else if (Perfis.Count > 0)
+ {
+ await SelecionaPerfis(((DomainBase)_controle).Id, ((DomainBase)Perfis[Perfis.IndexOf(SelectedPerfil) + 1]).Id);
+ }
+ Loading(isLoading: false);
+ ToggleSnackBar("PERFIL EXCLUÍDO COM SUCESSO");
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Seguros/SinistroViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Seguros/SinistroViewModel.cs
new file mode 100644
index 0000000..d5b0f8f
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Seguros/SinistroViewModel.cs
@@ -0,0 +1,1337 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using Gestor.Application.Drawers;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.Views.Ferramentas;
+using Gestor.Application.Views.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.MalaDireta;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Seguros;
+
+public class SinistroViewModel : BaseSegurosViewModel
+{
+ private readonly SinistroServico _servico;
+
+ private readonly ItemServico _itemServico;
+
+ private readonly Documento _documentoSelecionado;
+
+ private readonly ClienteServico _clienteServico;
+
+ private bool _editarObservacao = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 49);
+
+ private bool _isAnotacoes = true;
+
+ private List<TipoPerda> _tipoPerdaAuto = new List<TipoPerda>
+ {
+ (TipoPerda)1,
+ (TipoPerda)2,
+ (TipoPerda)4,
+ (TipoPerda)3,
+ (TipoPerda)8
+ };
+
+ private List<TipoPerda> _tipoPerdaVida = new List<TipoPerda>
+ {
+ (TipoPerda)5,
+ (TipoPerda)6,
+ (TipoPerda)7,
+ (TipoPerda)8
+ };
+
+ private Credencial _selectedCredencial = new Credencial();
+
+ private List<Credencial> _credenciais = new List<Credencial>();
+
+ private ObservableCollection<Item> _itens = new ObservableCollection<Item>();
+
+ private ObservableCollection<Item> _itensFiltrados = new ObservableCollection<Item>();
+
+ private ObservableCollection<Parceiro> _parceiros = new ObservableCollection<Parceiro>(GerarParceiros());
+
+ private bool _habilitarImprimirHistorico;
+
+ private bool _habilitarEnviarHistorico;
+
+ private Visibility _isVisibleImprimirHistorico;
+
+ private Visibility _isVisibleIncluir;
+
+ private Visibility _isVisibleTerceiro = (Visibility)2;
+
+ private Visibility _visibilityAuto = (Visibility)2;
+
+ private Visibility _visibilityVida = (Visibility)2;
+
+ private Visibility _liquidacaoVisibility;
+
+ private bool _isReadOnlyItem = true;
+
+ private bool _tipoSinistroEnabled;
+
+ private Item _selectedItem = new Item();
+
+ private bool _mostrarLista;
+
+ private bool _isExpandedItem = true;
+
+ private bool _isExpandedSinistro = true;
+
+ private List<ControleSinistro> _controles = new List<ControleSinistro>();
+
+ private ObservableCollection<ControleSinistro> _controlesFiltrados = new ObservableCollection<ControleSinistro>();
+
+ private ControleSinistro _selectedControle = new ControleSinistro();
+
+ private Sinistro _selectedSinistro;
+
+ private string _codigoSinistro;
+
+ private string _anotacoes;
+
+ private string _anotacoesInternas;
+
+ private string _telefonesMecanica;
+
+ private string _telefonesFunileiro;
+
+ public int FiltroItens { get; set; }
+
+ public Item ItemSelecionado { get; set; }
+
+ public bool EditarObservacao
+ {
+ get
+ {
+ return _editarObservacao;
+ }
+ set
+ {
+ _editarObservacao = value;
+ OnPropertyChanged("EditarObservacao");
+ }
+ }
+
+ public bool IsAnotacoes
+ {
+ get
+ {
+ return _isAnotacoes;
+ }
+ set
+ {
+ _isAnotacoes = value;
+ OnPropertyChanged("IsAnotacoes");
+ }
+ }
+
+ private bool Carregando { get; set; }
+
+ public List<TipoPerda> TipoPerdaAuto
+ {
+ get
+ {
+ return _tipoPerdaAuto;
+ }
+ set
+ {
+ _tipoPerdaAuto = value;
+ OnPropertyChanged("TipoPerdaAuto");
+ }
+ }
+
+ public List<TipoPerda> TipoPerdaVida
+ {
+ get
+ {
+ return _tipoPerdaVida;
+ }
+ set
+ {
+ _tipoPerdaVida = value;
+ OnPropertyChanged("TipoPerdaVida");
+ }
+ }
+
+ public Credencial SelectedCredencial
+ {
+ get
+ {
+ return _selectedCredencial;
+ }
+ set
+ {
+ _selectedCredencial = value;
+ OnPropertyChanged("SelectedCredencial");
+ }
+ }
+
+ public List<Credencial> Credenciais
+ {
+ get
+ {
+ return _credenciais;
+ }
+ set
+ {
+ _credenciais = value;
+ OnPropertyChanged("Credenciais");
+ }
+ }
+
+ public ObservableCollection<Item> Itens
+ {
+ get
+ {
+ return _itens;
+ }
+ set
+ {
+ _itens = value;
+ OnPropertyChanged("Itens");
+ }
+ }
+
+ public ObservableCollection<Item> ItensFiltrados
+ {
+ get
+ {
+ return _itensFiltrados;
+ }
+ set
+ {
+ _itensFiltrados = value;
+ IsExpandedItem = value != null && value.Count > 0;
+ OnPropertyChanged("ItensFiltrados");
+ }
+ }
+
+ public ObservableCollection<Parceiro> Parceiros
+ {
+ get
+ {
+ return _parceiros;
+ }
+ set
+ {
+ _parceiros = value;
+ OnPropertyChanged("Parceiros");
+ }
+ }
+
+ public bool HabilitarImprimirHistorico
+ {
+ get
+ {
+ return _habilitarImprimirHistorico;
+ }
+ set
+ {
+ _habilitarImprimirHistorico = value;
+ OnPropertyChanged("HabilitarImprimirHistorico");
+ }
+ }
+
+ public bool HabilitarEnviarHistorico
+ {
+ get
+ {
+ return _habilitarEnviarHistorico;
+ }
+ set
+ {
+ _habilitarEnviarHistorico = value;
+ OnPropertyChanged("HabilitarEnviarHistorico");
+ }
+ }
+
+ public Visibility IsVisibleImprimirHistorico
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleImprimirHistorico;
+ }
+ 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)
+ _isVisibleImprimirHistorico = value;
+ OnPropertyChanged("IsVisibleImprimirHistorico");
+ }
+ }
+
+ public Visibility IsVisibleIncluir
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleIncluir;
+ }
+ 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)
+ _isVisibleIncluir = value;
+ OnPropertyChanged("IsVisibleIncluir");
+ }
+ }
+
+ public Visibility IsVisibleTerceiro
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleTerceiro;
+ }
+ 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)
+ _isVisibleTerceiro = value;
+ OnPropertyChanged("IsVisibleTerceiro");
+ }
+ }
+
+ public Visibility VisibilityAuto
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityAuto;
+ }
+ 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)
+ _visibilityAuto = value;
+ OnPropertyChanged("VisibilityAuto");
+ }
+ }
+
+ public Visibility VisibilityVida
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityVida;
+ }
+ 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)
+ _visibilityVida = value;
+ OnPropertyChanged("VisibilityVida");
+ }
+ }
+
+ public Visibility LiquidacaoVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _liquidacaoVisibility;
+ }
+ 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)
+ _liquidacaoVisibility = value;
+ OnPropertyChanged("LiquidacaoVisibility");
+ }
+ }
+
+ public bool IsReadOnlyItem
+ {
+ get
+ {
+ return _isReadOnlyItem;
+ }
+ set
+ {
+ _isReadOnlyItem = value;
+ OnPropertyChanged("IsReadOnlyItem");
+ }
+ }
+
+ public bool TipoSinistroEnabled
+ {
+ get
+ {
+ return _tipoSinistroEnabled;
+ }
+ set
+ {
+ _tipoSinistroEnabled = value;
+ OnPropertyChanged("TipoSinistroEnabled");
+ }
+ }
+
+ public Item SelectedItem
+ {
+ get
+ {
+ return _selectedItem;
+ }
+ set
+ {
+ _selectedItem = value;
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedItem");
+ }
+ }
+
+ public bool MostrarLista
+ {
+ get
+ {
+ return _mostrarLista;
+ }
+ set
+ {
+ _mostrarLista = value;
+ OnPropertyChanged("MostrarLista");
+ }
+ }
+
+ public bool IsExpandedItem
+ {
+ get
+ {
+ return _isExpandedItem;
+ }
+ set
+ {
+ _isExpandedItem = value;
+ OnPropertyChanged("IsExpandedItem");
+ }
+ }
+
+ public bool IsExpandedSinistro
+ {
+ get
+ {
+ return _isExpandedSinistro;
+ }
+ set
+ {
+ _isExpandedSinistro = value;
+ OnPropertyChanged("IsExpandedSinistro");
+ }
+ }
+
+ public List<ControleSinistro> Controles
+ {
+ get
+ {
+ return _controles;
+ }
+ set
+ {
+ _controles = value;
+ base.EnableIncluir = value == null || value.Count == 0;
+ OnPropertyChanged("Controles");
+ }
+ }
+
+ public ObservableCollection<ControleSinistro> ControlesFiltrados
+ {
+ get
+ {
+ return _controlesFiltrados;
+ }
+ set
+ {
+ _controlesFiltrados = value;
+ IsExpandedSinistro = value != null && value.Count > 0;
+ OnPropertyChanged("ControlesFiltrados");
+ }
+ }
+
+ public ControleSinistro SelectedControle
+ {
+ get
+ {
+ return _selectedControle;
+ }
+ set
+ {
+ _selectedControle = value;
+ if (value != null)
+ {
+ base.EnableButtons = ((DomainBase)value).Id > 0;
+ base.EnableIncluir = ((DomainBase)value).Id > 0;
+ IsVisibleTerceiro = (Visibility)((value.Sinistros == null || (value.Sinistros != null && value.Sinistros.Count < 2)) ? 2 : 0);
+ IsVisibleIncluir = (Visibility)((value.Sinistros != null && value.Sinistros.Any()) ? 2 : 0);
+ int mostrarLista;
+ if (!MostrarLista)
+ {
+ List<ControleSinistro> controles = Controles;
+ mostrarLista = ((controles != null && controles.Count > 1) ? 1 : 0);
+ }
+ else
+ {
+ mostrarLista = 1;
+ }
+ MostrarLista = (byte)mostrarLista != 0;
+ }
+ OnPropertyChanged("SelectedControle");
+ }
+ }
+
+ public Sinistro SelectedSinistro
+ {
+ get
+ {
+ return _selectedSinistro;
+ }
+ set
+ {
+ //IL_0186: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0093: Invalid comparison between Unknown and I4
+ _selectedSinistro = value;
+ Anotacoes = string.Empty;
+ AnotacoesInternas = string.Empty;
+ HabilitarImprimirHistorico = value != null;
+ HabilitarEnviarHistorico = value != null;
+ CodigoSinistro = ((SelectedSinistro == null || ((DomainBase)SelectedSinistro).Id == 0L) ? "" : $"CÓDIGO SINISTRO {((DomainBase)SelectedSinistro).Id}");
+ if (value != null && ((DomainBase)value).Id != 0L && (LastAccessId != ((DomainBase)value).Id || (int)LastAccessTela != 7))
+ {
+ RegistrarAcao($"ACESSOU SINISTRO DE ID \"{((DomainBase)value).Id}\"", ((DomainBase)value).Id, (TipoTela)7, $"ID ITEM: {((DomainBase)value.ControleSinistro.Item).Id}\nID DOCUMENTO: {((DomainBase)value.ControleSinistro.Item.Documento).Id}\nRAMO: {value.ControleSinistro.Item.Documento.Controle.Ramo.Nome}\nCLIENTE: {value.ControleSinistro.Item.Documento.Controle.Cliente.Nome}\nID CLIENTE: {((DomainBase)value.ControleSinistro.Item.Documento.Controle.Cliente).Id}\nDESCRIÇÃO: \"{value.Descricao}\"");
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)7;
+ }
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedSinistro");
+ }
+ }
+
+ public string CodigoSinistro
+ {
+ get
+ {
+ return _codigoSinistro;
+ }
+ set
+ {
+ _codigoSinistro = value;
+ OnPropertyChanged("CodigoSinistro");
+ }
+ }
+
+ public new string Anotacoes
+ {
+ get
+ {
+ return _anotacoes;
+ }
+ set
+ {
+ _anotacoes = value;
+ OnPropertyChanged("Anotacoes");
+ }
+ }
+
+ public string AnotacoesInternas
+ {
+ get
+ {
+ return _anotacoesInternas;
+ }
+ set
+ {
+ _anotacoesInternas = value;
+ OnPropertyChanged("AnotacoesInternas");
+ }
+ }
+
+ public string TelefonesMecanica
+ {
+ get
+ {
+ return _telefonesMecanica;
+ }
+ set
+ {
+ _telefonesMecanica = value;
+ OnPropertyChanged("TelefonesMecanica");
+ }
+ }
+
+ public string TelefonesFunileiro
+ {
+ get
+ {
+ return _telefonesFunileiro;
+ }
+ set
+ {
+ _telefonesFunileiro = value;
+ OnPropertyChanged("TelefonesFunileiro");
+ }
+ }
+
+ public SinistroViewModel(Item item, bool attached)
+ {
+ //IL_008c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0096: Expected O, but got Unknown
+ //IL_00c9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ee: Expected O, but got Unknown
+ //IL_0113: Unknown result type (might be due to invalid IL or missing references)
+ //IL_011d: Expected O, but got Unknown
+ _servico = new SinistroServico();
+ _itemServico = new ItemServico();
+ _clienteServico = new ClienteServico();
+ _documentoSelecionado = (attached ? ConsultaViewModel.DocumentoSelecionado : item.Documento);
+ FiltroItens = ConsultaViewModel.FiltrarItens;
+ ItemSelecionado = ConsultaViewModel.ItemSelecionado;
+ if (!attached)
+ {
+ FiltroItens = 4;
+ ItemSelecionado = item;
+ }
+ if (((item != null) ? item.Documento : null) != null)
+ {
+ Documento documentoSelecionado = ConsultaViewModel.DocumentoSelecionado;
+ if (((documentoSelecionado != null) ? documentoSelecionado.VendedorPrincipal : null) != null)
+ {
+ item.Documento.VendedorPrincipal = ConsultaViewModel.DocumentoSelecionado.VendedorPrincipal;
+ }
+ }
+ Seleciona(item);
+ }
+
+ public async void SelecionaItem(Item item)
+ {
+ if (Carregando)
+ {
+ return;
+ }
+ SelectedItem = item;
+ if (SelectedItem == null || Carregando)
+ {
+ return;
+ }
+ if (((DomainBase)item).Id != ((DomainBase)SelectedItem).Id)
+ {
+ SelectedItem = ((IEnumerable<Item>)ItensFiltrados).FirstOrDefault((Func<Item, bool>)((Item x) => ((DomainBase)x).Id == ((DomainBase)item).Id));
+ }
+ await SelecionaControles(item);
+ }
+
+ public void SelecionaControle(ControleSinistro controle)
+ {
+ if (Carregando)
+ {
+ return;
+ }
+ SelectedControle = controle;
+ ControleSinistro selectedControle = SelectedControle;
+ ControleSinistro selectedControle2 = SelectedControle;
+ selectedControle.Sinistros = ((selectedControle2 == null) ? null : selectedControle2.Sinistros?.OrderBy((Sinistro x) => ((DomainBase)x).Id).ToList());
+ if (Carregando)
+ {
+ return;
+ }
+ if (((DomainBase)controle).Id != ((DomainBase)SelectedControle).Id)
+ {
+ SelectedControle = controle;
+ }
+ ControleSinistro selectedControle3 = SelectedControle;
+ if (((selectedControle3 != null) ? selectedControle3.Sinistros : null) != null)
+ {
+ TipoSinistroEnabled = !SelectedControle.Sinistros.Any((Sinistro x) => x.TipoSinistro == (TipoSinistro?)0) || SelectedControle.Sinistros.Count <= 1;
+ }
+ }
+
+ public void CarregarParceiros()
+ {
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001b: Expected O, but got Unknown
+ List<Parceiro> list = new List<Parceiro>
+ {
+ new Parceiro
+ {
+ Nome = "NENHUM"
+ }
+ };
+ list.AddRange(Recursos.Parceiros.OrderBy((Parceiro x) => x.Nome));
+ Parceiros = new ObservableCollection<Parceiro>(list);
+ }
+
+ private static List<Parceiro> GerarParceiros()
+ {
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001b: Expected O, but got Unknown
+ List<Parceiro> list = new List<Parceiro>();
+ list.Add(new Parceiro
+ {
+ Nome = "NENHUM"
+ });
+ list.AddRange(Recursos.Parceiros.OrderBy((Parceiro x) => x.Nome));
+ return list;
+ }
+
+ public async Task IncluirSinistro()
+ {
+ if (SelectedItem == null)
+ {
+ await ShowMessage("NECESSÁRIO INCLUIR O ITEM ANTES DE INCLUIR UM SINISTRO.");
+ return;
+ }
+ DateTime now = Funcoes.GetNetworkTime();
+ ControleSinistro controle = new ControleSinistro
+ {
+ DataSinistro = now,
+ Item = SelectedItem
+ };
+ Cobertura val = ((IEnumerable<Cobertura>)(await _itemServico.BuscarCoberturasPorItemAsync(((DomainBase)SelectedItem).Id))).FirstOrDefault((Func<Cobertura, bool>)((Cobertura x) => x.CoberturaPadrao != null && ((DomainBase)x.CoberturaPadrao).Id == 1));
+ Sinistro val2 = new Sinistro
+ {
+ ControleSinistro = controle,
+ TipoSinistro = (TipoSinistro)0,
+ Ativo = true,
+ DataReclamacao = now,
+ StatusSinistro = (StatusSinistro)1,
+ ItemSinistrado = SelectedItem.Descricao,
+ ValorFranquia = ((val != null) ? val.Franquia : 0m)
+ };
+ long id = ((DomainBase)_documentoSelecionado.Controle.Ramo).Id;
+ long num = id - 5;
+ if ((ulong)num <= 5uL)
+ {
+ switch (num)
+ {
+ case 0L:
+ goto IL_0215;
+ case 1L:
+ case 2L:
+ case 4L:
+ case 5L:
+ goto IL_022e;
+ case 3L:
+ goto IL_0239;
+ }
+ }
+ if (id == 37)
+ {
+ goto IL_0215;
+ }
+ if (id == 53)
+ {
+ goto IL_022e;
+ }
+ goto IL_0239;
+ IL_0215:
+ val2.SinistroAuto = new SinistroAuto
+ {
+ Culpado = false
+ };
+ goto IL_0239;
+ IL_0239:
+ IsReadOnlyItem = true;
+ SelectedControle = controle;
+ SelectedSinistro = val2;
+ Alterar(alterar: true);
+ return;
+ IL_022e:
+ val2.SinistroVida = new SinistroVida();
+ goto IL_0239;
+ }
+
+ public async void IncluirEnvolvido()
+ {
+ Sinistro sinistro = new Sinistro
+ {
+ ControleSinistro = SelectedControle,
+ TipoSinistro = (TipoSinistro)1,
+ Ativo = true,
+ StatusSinistro = (StatusSinistro)1
+ };
+ long id = ((DomainBase)_documentoSelecionado.Controle.Ramo).Id;
+ long num = id - 5;
+ if ((ulong)num <= 5uL)
+ {
+ switch (num)
+ {
+ case 0L:
+ goto IL_0098;
+ case 1L:
+ case 2L:
+ case 4L:
+ case 5L:
+ goto IL_00aa;
+ case 3L:
+ goto IL_011e;
+ }
+ }
+ if (id == 37)
+ {
+ goto IL_0098;
+ }
+ if (id == 53)
+ {
+ goto IL_00aa;
+ }
+ goto IL_011e;
+ IL_00aa:
+ sinistro.SinistroVida = new SinistroVida();
+ goto IL_011e;
+ IL_011e:
+ if (await ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO"))
+ {
+ sinistro.ItemSinistrado = SelectedItem.Descricao;
+ sinistro.Descricao = SelectedSinistro.Descricao;
+ sinistro.DataReclamacao = SelectedSinistro.DataReclamacao;
+ if (sinistro.SinistroAuto != null)
+ {
+ if (SelectedSinistro.SinistroAuto == null)
+ {
+ SelectedSinistro.SinistroAuto = new SinistroAuto();
+ }
+ sinistro.SinistroAuto.Endereco = SelectedSinistro.SinistroAuto.Endereco;
+ }
+ }
+ else
+ {
+ sinistro.DataReclamacao = Funcoes.GetNetworkTime();
+ }
+ IsReadOnlyItem = false;
+ SelectedSinistro = sinistro;
+ Alterar(alterar: true);
+ return;
+ IL_0098:
+ sinistro.SinistroAuto = new SinistroAuto();
+ goto IL_011e;
+ }
+
+ internal void ImprimirHistorico()
+ {
+ Vendedor vendedorPrincipal = _documentoSelecionado.VendedorPrincipal;
+ string value = GerarHtmlSinistro((vendedorPrincipal != null) ? vendedorPrincipal.Nome : null);
+ string tempPath = Path.GetTempPath();
+ string text = $"{tempPath}{(object)(TipoTela)7}_{Funcoes.GetNetworkTime():ddMMyyyyhhmmss}.html";
+ StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8);
+ streamWriter.Write(value);
+ streamWriter.Close();
+ Process.Start(text);
+ }
+
+ public string GerarHtmlSinistro(string vendedorPrincipal = "")
+ {
+ string text = "<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=yes'><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> HISTÓRICO DO SINISTRO </title></head><body ><div class='-2'>";
+ string text2 = "";
+ foreach (Sinistro item in SelectedControle.Sinistros.OrderBy((Sinistro x) => x.TipoSinistro))
+ {
+ text += "<h2 style='text-align: center'>";
+ text2 = (string.IsNullOrEmpty(text2) ? "CLIENTE" : ("TERCEIRO Nº " + item.Numero));
+ text = text + text2 + "</h2>";
+ text += "<div class='table-responsive'><table class='table table-bordered' style='width:100%'>";
+ int num = 0;
+ if (text2 == "CLIENTE")
+ {
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>CLIENTE: </b>" + item.ControleSinistro.Item.Documento.Controle.Cliente.Nome + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>DOCUMENTO DO SEGURADO: </b>" + item.ControleSinistro.Item.Documento.Controle.Cliente.Documento + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>APÓLICE: </b>" + item.ControleSinistro.Item.Documento.Apolice + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>VIGÊNCIA INICIAL: </b>" + item.ControleSinistro.Item.Documento.Vigencia1.ToShortDateString() + "</td></tr>";
+ num = 0;
+ string text3 = ((!(item.ControleSinistro.Item.Documento.Vigencia2.GetValueOrDefault().ToString(new CultureInfo("pt-BR")) != "01/01/0001 00:00:00")) ? "NÃO POSSUI" : item.ControleSinistro.Item.Documento.Vigencia2?.ToShortDateString());
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>VIGÊNCIA FINAL: </b>" + text3 + "</td></tr>";
+ num = 1;
+ vendedorPrincipal = ((item.ControleSinistro.Item.Documento.VendedorPrincipal == null) ? vendedorPrincipal : item.ControleSinistro.Item.Documento.VendedorPrincipal.Nome);
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>VENDEDOR PRINCIPAL: </b>" + vendedorPrincipal + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>SEGURADORA: </b>" + item.ControleSinistro.Item.Documento.Controle.Seguradora.Nome + "</td></tr>";
+ }
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>NÚMERO SINISTRO: </b>" + item.Numero + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>DATA DO SINISTRO: </b>" + item.ControleSinistro.DataSinistro?.ToShortDateString() + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>HORA DO SINISTRO: </b>" + item.ControleSinistro.HoraSinistro?.ToShortTimeString() + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>DATA/HORA ABERTURA: </b>" + item.DataReclamacao.ToString() + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>DATA LIQUIDAÇÃO: </b>" + item.DataLiquidacao.ToString() + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>DESCRIÇÃO DO BEM SINISTRADO: </b>" + item.ItemSinistrado + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>VALOR ORÇADO: </b>" + item.ValorOrcado.ToString("C", new CultureInfo("pt-BR", useUserOverride: false)) + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>VALOR LIBERADO: </b>" + item.ValorLiberado.ToString("C", new CultureInfo("pt-BR", useUserOverride: false)) + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>VALOR PAGO: </b>" + item.ValorPago.ToString("C", new CultureInfo("pt-BR", useUserOverride: false)) + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>VALOR FRANQUIA: </b>" + item.ValorFranquia.ToString("C", new CultureInfo("pt-BR", useUserOverride: false)) + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>SITUAÇÃO: </b>" + ValidationHelper.GetDescription((Enum)(object)item.StatusSinistro) + "</td></tr>";
+ text += "</table></div>";
+ string text4;
+ object obj;
+ if (item.SinistroAuto != null)
+ {
+ text += "<div class='table-responsive'><table class='table table-bordered' style='width:100%'>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>NÚMERO B.O.: </b>" + item.SinistroAuto.NumeroBo + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>TIPO PERDA: </b>" + ValidationHelper.GetDescription((Enum)(object)item.SinistroAuto.TipoPerda) + "</td></tr>";
+ num = 0;
+ text4 = text;
+ if ("<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>CONSIDERA-SE CULPADO? </b>" + item.SinistroAuto.Culpado != null)
+ {
+ SinistroAuto sinistroAuto = item.SinistroAuto;
+ if (sinistroAuto == null || sinistroAuto.Culpado != false)
+ {
+ obj = "SIM</td></tr>";
+ goto IL_08f0;
+ }
+ }
+ obj = "NÃO";
+ goto IL_08f0;
+ }
+ goto IL_14d5;
+ IL_14d5:
+ if (item.SinistroVida != null)
+ {
+ text += "<div class='table-responsive'><table class='table table-bordered' style='width:100%'>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>TIPO PERDA: </b>" + ValidationHelper.GetDescription((Enum)(object)item.SinistroVida.TipoPerda) + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>AUXÍLIO FUNERAL: </b>" + ((item.SinistroVida.AuxFuneral.HasValue && item.SinistroVida.AuxFuneral.Value) ? "SIM" : "NÃO") + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>ESTADO CIVIL: </b>" + ValidationHelper.GetDescription((Enum)(object)item.SinistroVida.EstadoCivil) + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>CERTIDÃO DE ÓBITO: </b>" + item.SinistroVida.CertObito + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>BENEFICIÁRIO: </b>" + item.SinistroVida.Beneficiario + "</td></tr>";
+ text += "</table></div>";
+ }
+ if (!string.IsNullOrWhiteSpace(item.Descricao))
+ {
+ text += "<hr/>";
+ text += "<h4>DESCRIÇÃO</h4>";
+ text += "<br>";
+ text = text + "<div>" + item.Descricao + "</div>";
+ }
+ if (!string.IsNullOrWhiteSpace(item.Observacao))
+ {
+ text += "<hr/>";
+ text += "<h4>HISTÓRICO</h4>";
+ text += "<br>";
+ text = text + "<div>" + item.Observacao.Replace("<BODY>", "").Replace("</BODY>", "") + "</div>";
+ }
+ continue;
+ IL_08f0:
+ text = text4 + (string?)obj;
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>ÚLTIMO DOC. ENVIADO: </b>" + $"{item.SinistroAuto.UltimoDocEnviado:dd/MM/yyyy}" + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>ENDEREÇO: </b>" + item.SinistroAuto.Endereco + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>ENVOLVIDO/PROPRIETÁRIO: </b>" + item.SinistroAuto.Envolvido + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>MOTORISTA: </b>" + item.SinistroAuto.Motorista + "</td></tr>";
+ num = 1;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>TELEFONE: </b>(" + item.SinistroAuto.Ddd + ") " + item.SinistroAuto.Telefone + "</td></tr>";
+ num = 0;
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>E-MAIL: </b>" + item.SinistroAuto.Email + "</td></tr>";
+ text += "</table></div>";
+ text += "<div class='table-responsive'><table class='table table-bordered' style='width:100%'>";
+ num = 1;
+ string text5 = ((item.SinistroAuto.ParceiroMecanica != null) ? item.SinistroAuto.ParceiroMecanica.Nome : "");
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>PARCEIRO MECÂNICA: </b>" + text5 + "</td></tr>";
+ num = 0;
+ string text6 = ((item.SinistroAuto.ParceiroMecanica == null || (string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Ddd1) && string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Telefone1))) ? "" : ("(" + item.SinistroAuto.ParceiroMecanica.Ddd1 + ") " + item.SinistroAuto.ParceiroMecanica.Telefone1));
+ string text7 = ((item.SinistroAuto.ParceiroMecanica == null || (string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Ddd2) && string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Telefone2))) ? "" : (" / (" + item.SinistroAuto.ParceiroMecanica.Ddd2 + ") " + item.SinistroAuto.ParceiroMecanica.Telefone2));
+ string text8 = ((item.SinistroAuto.ParceiroMecanica == null || (string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Ddd3) && string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Telefone3))) ? "" : (" / (" + item.SinistroAuto.ParceiroMecanica.Ddd3 + ") " + item.SinistroAuto.ParceiroMecanica.Telefone3));
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>CONTATOS: </b>" + text6 + text7 + text8 + "</td></tr>";
+ num = 1;
+ string text9 = ((item.SinistroAuto.ParceiroMecanica == null) ? "" : item.SinistroAuto.ParceiroMecanica.Email);
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>EMAIL: </b>" + text9 + "</td></tr>";
+ num = 0;
+ string text10 = ((item.SinistroAuto.ParceiroMecanica == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Endereco)) ? "" : (item.SinistroAuto.ParceiroMecanica.Endereco ?? ""));
+ string text11 = ((item.SinistroAuto.ParceiroMecanica == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Numero)) ? "" : (", " + item.SinistroAuto.ParceiroMecanica.Numero));
+ string text12 = ((item.SinistroAuto.ParceiroMecanica == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Complemento)) ? "" : (", " + item.SinistroAuto.ParceiroMecanica.Complemento));
+ string text13 = ((item.SinistroAuto.ParceiroMecanica == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Bairro)) ? "" : (", " + item.SinistroAuto.ParceiroMecanica.Bairro));
+ string text14 = ((item.SinistroAuto.ParceiroMecanica == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Cidade)) ? "" : (" - " + item.SinistroAuto.ParceiroMecanica.Cidade));
+ string text15 = ((item.SinistroAuto.ParceiroMecanica == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Uf)) ? "" : (" - " + item.SinistroAuto.ParceiroMecanica.Uf));
+ string text16 = ((item.SinistroAuto.ParceiroMecanica == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroMecanica.Cep)) ? "" : (" - " + item.SinistroAuto.ParceiroMecanica.Cep));
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>ENDEREÇO: </b>" + text10 + text11 + text12 + text13 + text14 + text15 + text16 + "</td></tr>";
+ text += "</table></div>";
+ text += "<div class='table-responsive'><table class='table table-bordered' style='width:100%'>";
+ num = 1;
+ text5 = ((item.SinistroAuto.ParceiroFunilaria != null) ? item.SinistroAuto.ParceiroFunilaria.Nome : "");
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>PARCEIRO FUNILARIA: </b>" + text5 + "</td></tr>";
+ num = 0;
+ text6 = ((item.SinistroAuto.ParceiroFunilaria == null || (string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Ddd1) && string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Telefone1))) ? "" : ("(" + item.SinistroAuto.ParceiroFunilaria.Ddd1 + ") " + item.SinistroAuto.ParceiroFunilaria.Telefone1));
+ text7 = ((item.SinistroAuto.ParceiroFunilaria == null || (string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Ddd2) && string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Telefone2))) ? "" : (" / (" + item.SinistroAuto.ParceiroFunilaria.Ddd2 + ") " + item.SinistroAuto.ParceiroFunilaria.Telefone2));
+ text8 = ((item.SinistroAuto.ParceiroFunilaria == null || (string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Ddd3) && string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Telefone3))) ? "" : (" / (" + item.SinistroAuto.ParceiroFunilaria.Ddd3 + ") " + item.SinistroAuto.ParceiroFunilaria.Telefone3));
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>CONTATOS: </b>" + text6 + text7 + text8 + "</td></tr>";
+ num = 1;
+ text9 = ((item.SinistroAuto.ParceiroFunilaria == null) ? "" : item.SinistroAuto.ParceiroFunilaria.Email);
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>EMAIL: </b>" + text9 + "</td></tr>";
+ num = 0;
+ text10 = ((item.SinistroAuto.ParceiroFunilaria == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Endereco)) ? "" : (item.SinistroAuto.ParceiroFunilaria.Endereco ?? ""));
+ text11 = ((item.SinistroAuto.ParceiroFunilaria == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Numero)) ? "" : (", " + item.SinistroAuto.ParceiroFunilaria.Numero));
+ text12 = ((item.SinistroAuto.ParceiroFunilaria == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Complemento)) ? "" : (", " + item.SinistroAuto.ParceiroFunilaria.Complemento));
+ text13 = ((item.SinistroAuto.ParceiroFunilaria == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Bairro)) ? "" : (", " + item.SinistroAuto.ParceiroFunilaria.Bairro));
+ text14 = ((item.SinistroAuto.ParceiroFunilaria == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Cidade)) ? "" : (" - " + item.SinistroAuto.ParceiroFunilaria.Cidade));
+ text15 = ((item.SinistroAuto.ParceiroFunilaria == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Uf)) ? "" : (" - " + item.SinistroAuto.ParceiroFunilaria.Uf));
+ text16 = ((item.SinistroAuto.ParceiroFunilaria == null || string.IsNullOrEmpty(item.SinistroAuto.ParceiroFunilaria.Cep)) ? "" : (" - " + item.SinistroAuto.ParceiroFunilaria.Cep));
+ text = text + "<tr><td bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'><b>ENDEREÇO: </b>" + text10 + text11 + text12 + text13 + text14 + text15 + text16 + "</td></tr>";
+ text += "</table></div>";
+ goto IL_14d5;
+ }
+ return text + "</div></body></html>";
+ }
+
+ public async void CancelarAlteracao()
+ {
+ Loading(isLoading: true);
+ ControleSinistro selectedControle = SelectedControle;
+ long controle = ((selectedControle != null) ? ((DomainBase)selectedControle).Id : 0);
+ Sinistro selectedSinistro = SelectedSinistro;
+ long sinistro = ((selectedSinistro != null) ? ((DomainBase)selectedSinistro).Id : 0);
+ await CarregarControles(SelectedItem);
+ Anotacoes = string.Empty;
+ AnotacoesInternas = string.Empty;
+ SelectedControle = ((IEnumerable<ControleSinistro>)ControlesFiltrados).FirstOrDefault((Func<ControleSinistro, bool>)((ControleSinistro x) => ((DomainBase)x).Id == controle)) ?? ControlesFiltrados.FirstOrDefault();
+ SinistroViewModel sinistroViewModel = this;
+ object obj;
+ if (SelectedControle == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ ControleSinistro selectedControle2 = SelectedControle;
+ obj = ((selectedControle2 == null) ? null : selectedControle2.Sinistros?.FirstOrDefault((Func<Sinistro, bool>)((Sinistro x) => ((DomainBase)x).Id == sinistro)));
+ if (obj == null)
+ {
+ ControleSinistro selectedControle3 = SelectedControle;
+ obj = ((selectedControle3 == null) ? null : selectedControle3.Sinistros?.FirstOrDefault());
+ }
+ }
+ sinistroViewModel.SelectedSinistro = (Sinistro)obj;
+ Alterar(alterar: false);
+ SinistroViewModel sinistroViewModel2 = this;
+ Sinistro selectedSinistro2 = SelectedSinistro;
+ sinistroViewModel2.VerificarEnables((selectedSinistro2 != null) ? new long?(((DomainBase)selectedSinistro2).Id) : null);
+ Loading(isLoading: false);
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedSinistro == null || ((DomainBase)SelectedSinistro).Id == 0L || !(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ RegistrarAcao($"EXCLUIU SINISTRO DE ID \"{((DomainBase)SelectedSinistro).Id}\"", ((DomainBase)SelectedSinistro).Id, (TipoTela)7, $"ID ITEM: {((DomainBase)SelectedSinistro.ControleSinistro.Item).Id}\nID DOCUMENTO: {((DomainBase)SelectedSinistro.ControleSinistro.Item.Documento).Id}\nRAMO: {SelectedSinistro.ControleSinistro.Item.Documento.Controle.Ramo.Nome}\nCLIENTE: {SelectedSinistro.ControleSinistro.Item.Documento.Controle.Cliente.Nome}\nID CLIENTE: {((DomainBase)SelectedSinistro.ControleSinistro.Item.Documento.Controle.Cliente).Id}\nDESCRIÇÃO: {((DomainBase)SelectedSinistro).Id}");
+ if (SelectedControle.Sinistros.Count == 1)
+ {
+ List<ControleSinistro> controles = Controles;
+ controles.Remove(SelectedControle);
+ if (!(await _servico.DeleteControle(SelectedControle, controles == null || controles.Count == 0)))
+ {
+ return;
+ }
+ int num = ControlesFiltrados.IndexOf(SelectedControle);
+ Controles.Remove(SelectedControle);
+ ControlesFiltrados.Remove(SelectedControle);
+ ControlesFiltrados = new ObservableCollection<ControleSinistro>(ControlesFiltrados);
+ if (ControlesFiltrados.Count > 0)
+ {
+ SelectedControle = ((num < ControlesFiltrados.Count) ? ControlesFiltrados.ElementAt(((num == 0) ? 1 : num) - 1) : ControlesFiltrados.Last());
+ }
+ else
+ {
+ SelectedControle = new ControleSinistro();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ SinistroViewModel sinistroViewModel = this;
+ ControleSinistro selectedControle = SelectedControle;
+ sinistroViewModel.SelectedSinistro = ((selectedControle == null) ? null : selectedControle.Sinistros?.FirstOrDefault());
+ }
+ else
+ {
+ if (!(await _servico.Delete(SelectedSinistro)))
+ {
+ return;
+ }
+ int num2 = SelectedControle.Sinistros.IndexOf(SelectedSinistro);
+ SelectedControle.Sinistros.Remove(SelectedSinistro);
+ long id = ((DomainBase)SelectedControle).Id;
+ SelectedControle = null;
+ SelectedControle = ControlesFiltrados.First((ControleSinistro x) => ((DomainBase)x).Id == id);
+ SelectedSinistro = ((num2 < SelectedControle.Sinistros.Count) ? SelectedControle.Sinistros.ElementAt(num2) : SelectedControle.Sinistros.Last());
+ }
+ if (Controles == null || Controles.Count == 0)
+ {
+ ItemServico itemServico = new ItemServico();
+ Item val = await itemServico.BuscarItemPorIdAsync(((DomainBase)SelectedItem).Id);
+ val.Sinistrado = false;
+ await itemServico.Save(val);
+ }
+ if (ItensFiltrados.Count > 0 && ItensFiltrados != null)
+ {
+ Item obj = ItensFiltrados.First((Item x) => ((DomainBase)x).Id == ((DomainBase)SelectedItem).Id);
+ ControleSinistro selectedControle2 = SelectedControle;
+ obj.Sinistrado = selectedControle2 != null && selectedControle2.Sinistros?.Count > 0;
+ }
+ ItensFiltrados = new ObservableCollection<Item>(ItensFiltrados);
+ Loading(isLoading: false);
+ ToggleSnackBar("SINISTRO EXCLUÍDO COM SUCESSO");
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedSinistro.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ Sinistro sinistro = SelectedSinistro;
+ if (sinistro.SinistroAuto != null)
+ {
+ Parceiro parceiroFunilaria = sinistro.SinistroAuto.ParceiroFunilaria;
+ if (parceiroFunilaria != null && ((DomainBase)parceiroFunilaria).Id == 0)
+ {
+ sinistro.SinistroAuto.ParceiroFunilaria = null;
+ }
+ Parceiro parceiroMecanica = sinistro.SinistroAuto.ParceiroMecanica;
+ if (parceiroMecanica != null && ((DomainBase)parceiroMecanica).Id == 0)
+ {
+ sinistro.SinistroAuto.ParceiroMecanica = null;
+ }
+ }
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ if (!string.IsNullOrWhiteSpace(Anotacoes) && !Anotacoes.IsEmpty())
+ {
+ sinistro.Observacao = $"<p>{Recursos.Usuario.Nome}, ID: {((DomainBase)Recursos.Usuario).Id}, {networkTime:g}<br>{Anotacoes}<p/><br><br>{sinistro.Observacao}";
+ }
+ if (!string.IsNullOrWhiteSpace(AnotacoesInternas) && !AnotacoesInternas.IsEmpty())
+ {
+ sinistro.ObservacaoInterna = $"<p>{Recursos.Usuario.Nome}, ID: {((DomainBase)Recursos.Usuario).Id}, {networkTime:g}<br>{AnotacoesInternas}<p/><br><br>{sinistro.ObservacaoInterna}";
+ }
+ if (((DomainBase)sinistro).Id == 0L)
+ {
+ sinistro.DataCriacao = DateTime.Now;
+ sinistro.IdUsuarioCriacao = ((DomainBase)Recursos.Usuario).Id;
+ }
+ else
+ {
+ sinistro.DataAlteracao = DateTime.Now;
+ sinistro.IdUsuarioAlteracao = ((DomainBase)Recursos.Usuario).Id;
+ }
+ string acao = ((((DomainBase)sinistro).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ sinistro = await _servico.Save(sinistro, ((DomainBase)_documentoSelecionado.Controle.Ramo).Id);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ await CarregarControles(sinistro.ControleSinistro.Item);
+ SelectedControle = ControlesFiltrados.First((ControleSinistro x) => ((DomainBase)x).Id == ((DomainBase)sinistro.ControleSinistro).Id);
+ SelectedSinistro = SelectedControle.Sinistros.First((Sinistro x) => ((DomainBase)x).Id == ((DomainBase)sinistro).Id);
+ Recursos.Parceiros = Parceiros.ToList();
+ Alterar(alterar: false);
+ ToggleSnackBar("SINISTRO SALVO COM SUCESSO");
+ RegistrarAcao($"{acao} SINISTRO DE ID \"{((DomainBase)sinistro).Id}\"", ((DomainBase)sinistro).Id, (TipoTela)7, $"ID ITEM: {((DomainBase)sinistro.ControleSinistro.Item).Id}\nID DOCUMENTO: {((DomainBase)sinistro.ControleSinistro.Item.Documento).Id}\nRAMO: {sinistro.ControleSinistro.Item.Documento.Controle.Ramo.Nome}\nCLIENTE: {sinistro.ControleSinistro.Item.Documento.Controle.Cliente.Nome}\nID CLIENTE: {((DomainBase)sinistro.ControleSinistro.Item.Documento.Controle.Cliente).Id}\nDESCRIÇÃO: \"{sinistro.Descricao}\"");
+ return null;
+ }
+
+ public async void Seleciona(Item item)
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)7);
+ SelectedItem = ItemSelecionado;
+ VisibilityAuto = (Visibility)((((DomainBase)_documentoSelecionado.Controle.Ramo).Id != 5) ? 2 : 0);
+ VisibilityVida = (Visibility)((((DomainBase)_documentoSelecionado.Controle.Ramo).Id != 6) ? 2 : 0);
+ if (item == null)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ await SelecionaControles(item);
+ Loading(isLoading: false);
+ }
+
+ public async Task SelecionaItens(int type, Item item = null)
+ {
+ Loading(isLoading: true);
+ Carregando = true;
+ switch (type)
+ {
+ default:
+ Itens = await _itemServico.BuscarItens(((DomainBase)_documentoSelecionado.Controle).Id, (StatusItem)0);
+ break;
+ case 1:
+ case 2:
+ Itens = await _itemServico.BuscarItens(((DomainBase)_documentoSelecionado).Id, (StatusItem)2);
+ break;
+ case 3:
+ Itens = await _itemServico.BuscarItens(((DomainBase)_documentoSelecionado.Controle).Id, (StatusItem)1);
+ break;
+ case 4:
+ Itens = await _itemServico.BuscarItens(((DomainBase)_documentoSelecionado.Controle).Id, (StatusItem)3);
+ break;
+ }
+ ItensFiltrados = Itens;
+ if (item != null && ((DomainBase)item).Id > 0)
+ {
+ SelectedItem = ((ItensFiltrados != null && ItensFiltrados.Count > 0) ? ((IEnumerable<Item>)ItensFiltrados).FirstOrDefault((Func<Item, bool>)((Item x) => ((DomainBase)x).Id == ((DomainBase)item).Id)) : null);
+ }
+ SinistroViewModel sinistroViewModel = this;
+ int mostrarLista;
+ if (!MostrarLista)
+ {
+ ObservableCollection<Item> itens = Itens;
+ mostrarLista = ((itens != null && itens.Count > 1) ? 1 : 0);
+ }
+ else
+ {
+ mostrarLista = 1;
+ }
+ sinistroViewModel.MostrarLista = (byte)mostrarLista != 0;
+ Carregando = false;
+ Loading(isLoading: false);
+ }
+
+ public async Task SelecionaControles(Item item)
+ {
+ Loading(isLoading: true);
+ await CarregarControles(item);
+ if (ControlesFiltrados.Count > 0)
+ {
+ SelectedControle = ControlesFiltrados.FirstOrDefault();
+ }
+ else
+ {
+ SelectedControle = new ControleSinistro();
+ Alterar(alterar: false);
+ }
+ SinistroViewModel sinistroViewModel = this;
+ ControleSinistro selectedControle = SelectedControle;
+ sinistroViewModel.SelectedSinistro = ((selectedControle == null) ? null : selectedControle.Sinistros?.FirstOrDefault());
+ Loading(isLoading: false);
+ }
+
+ private async Task CarregarControles(Item item)
+ {
+ Controles = (await _servico.BuscarControles(((DomainBase)item).Id)).OrderByDescending((ControleSinistro x) => x.DataSinistro).ToList();
+ ControlesFiltrados = new ObservableCollection<ControleSinistro>(Controles);
+ }
+
+ internal async Task<List<ControleSinistro>> SinistroFiltrar(string value)
+ {
+ return await Task.Run(() => FiltrarSinistro(value));
+ }
+
+ public List<ControleSinistro> FiltrarSinistro(string filter)
+ {
+ ControlesFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<ControleSinistro>(Controles) : new ObservableCollection<ControleSinistro>(from x in Controles
+ where ValidationHelper.RemoveDiacritics(x.DataSinistro.ToString().Trim()).Contains(filter) || (x.Sinistros != null && x.Sinistros.Count > 0 && ValidationHelper.RemoveDiacritics(x.Sinistros[0].Numero.Trim()).Contains(filter))
+ orderby x.DataSinistro
+ select x));
+ SelectedControle = ((ControlesFiltrados.Count > 0) ? ControlesFiltrados.First() : null);
+ return ControlesFiltrados.ToList();
+ }
+
+ internal async Task<List<Item>> ItemFiltrar(string value)
+ {
+ return await Task.Run(() => FiltrarItem(value));
+ }
+
+ public List<Item> FiltrarItem(string filter)
+ {
+ ItensFiltrados = (string.IsNullOrWhiteSpace(filter) ? Itens : new ObservableCollection<Item>(from x in Itens
+ where ValidationHelper.RemoveDiacritics(x.Descricao.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ordem
+ select x));
+ return ItensFiltrados.ToList();
+ }
+
+ public async Task<Cliente> BuscarClienteSinistro()
+ {
+ return await _itemServico.BuscarCliente(((DomainBase)SelectedItem).Id);
+ }
+
+ public async void EnviarLogEmail()
+ {
+ List<Credencial> list = Credenciais;
+ if (list == null)
+ {
+ list = await new BaseServico().BuscarCredenciais();
+ }
+ Credenciais = list;
+ SelectedCredencial = ((IEnumerable<Credencial>)Credenciais).FirstOrDefault((Func<Credencial, bool>)((Credencial x) => x.IdUsuario == ((DomainBase)Recursos.Usuario).Id)) ?? Credenciais.FirstOrDefault();
+ ObservableCollection<ClienteEmail> mails = await _clienteServico.BuscarEmailsAsync(((DomainBase)SelectedSinistro.ControleSinistro.Item.Documento.Controle.Cliente).Id);
+ if (mails.Count == 0)
+ {
+ await ShowMessage("O CLIENTE NÃO POSSUI NENHUM E-MAIL CADASTRADO");
+ return;
+ }
+ Documento val = await new ApoliceServico().BuscarApoliceAsync(((DomainBase)_documentoSelecionado).Id);
+ SinistroViewModel sinistroViewModel = this;
+ Vendedor vendedorPrincipal = val.VendedorPrincipal;
+ string text = sinistroViewModel.GerarHtmlSinistro((vendedorPrincipal != null) ? vendedorPrincipal.Nome : null);
+ string input = new Regex("<title>.*<\\/title>").Replace(text, " ").Trim();
+ input = new Regex("(<[^>]*>)|(p\\s?{[^}]*})|(\\r)|(\\n)").Replace(input, " ").Trim();
+ input = input.Replace("@page{ size: A4;} body; -webkit-print-color-adjust: exact; }", " ");
+ input.Replace("NEW P { MARGIN-BOTTOM: 0; MARGIN-TOP: 0; }", " ");
+ MalaDireta val2 = new MalaDireta
+ {
+ Cliente = val.Controle.Cliente,
+ ArquivoDigital = null,
+ Sinistro = SelectedSinistro,
+ Item = SelectedItem,
+ Apolice = val,
+ Tela = (TipoTela)7
+ };
+ ClienteEmail? obj = mails.FirstOrDefault();
+ val2.Email = ((obj != null) ? ((EmailBase)obj).Email : null);
+ ClienteEmail? obj2 = mails.FirstOrDefault();
+ val2.Ordem = ((obj2 != null) ? obj2.Ordem : null).GetValueOrDefault();
+ MalaDireta item = val2;
+ if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL"))
+ {
+ Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL");
+ }
+ ((Window)new HosterWindow((ContentControl)(object)new MalaDiretaView(new List<MalaDireta> { item }, "HISTÓRICO DO SINISTRO DO ITEM " + SelectedItem.Descricao, text), "ENVIO DE E-MAIL", 1200.0, 600.0, canMaximize: true)).ShowDialog();
+ }
+
+ public void AbrirInfo()
+ {
+ ShowDrawer(new InfoDrawer(_documentoSelecionado), 0, close: false);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Seguros/TrocarClienteViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Seguros/TrocarClienteViewModel.cs
new file mode 100644
index 0000000..2384db1
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Seguros/TrocarClienteViewModel.cs
@@ -0,0 +1,75 @@
+using System.Threading.Tasks;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Seguros;
+
+public class TrocarClienteViewModel : BaseSegurosViewModel
+{
+ private readonly ApoliceServico _apoliceServico;
+
+ private readonly ClienteServico _clienteServico;
+
+ private Documento _selectedDocumento;
+
+ private Cliente _selectedCliente;
+
+ public Documento SelectedDocumento
+ {
+ get
+ {
+ return _selectedDocumento;
+ }
+ set
+ {
+ OnPropertyChanged("SelectedDocumento");
+ _selectedDocumento = value;
+ }
+ }
+
+ public Cliente SelectedCliente
+ {
+ get
+ {
+ return _selectedCliente;
+ }
+ set
+ {
+ OnPropertyChanged("SelectedCliente");
+ _selectedCliente = value;
+ }
+ }
+
+ public TrocarClienteViewModel()
+ {
+ _apoliceServico = new ApoliceServico();
+ _clienteServico = new ClienteServico();
+ }
+
+ public async Task<bool> Salvar()
+ {
+ if (SelectedCliente == null)
+ {
+ return false;
+ }
+ if (((DomainBase)SelectedCliente).Id == ((DomainBase)SelectedDocumento.Controle.Cliente).Id)
+ {
+ return false;
+ }
+ Cliente clienteantigo = await _clienteServico.BuscarCliente(((DomainBase)SelectedDocumento.Controle.Cliente).Id);
+ Documento documento = SelectedDocumento;
+ _apoliceServico.Sucesso = true;
+ await _apoliceServico.Save(documento.Controle, SelectedCliente);
+ if (!_apoliceServico.Sucesso)
+ {
+ return false;
+ }
+ RegistrarAcao($"TROCOU O CLIENTE DO DOCUMENTO DE ID {((DomainBase)SelectedDocumento).Id}", ((DomainBase)SelectedDocumento).Id, (TipoTela)41, $"CLIENTE ANTIGO: {clienteantigo.Nome}\nNOVO CLIENTE: {SelectedCliente.Nome} ({((DomainBase)SelectedCliente).Id})");
+ SelectedCliente = documento.Controle.Cliente;
+ SelectedDocumento = documento;
+ return true;
+ }
+}