summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Generic
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
commit225aa1499e37faf9d38257caabbadc68d78b427e (patch)
tree102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.ViewModels.Generic
parent1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff)
downloadgestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz
gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Generic')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/BaseApoliceViewModel.cs4483
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/BaseDialogViewModel.cs5
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/BaseFinanceiroViewModel.cs371
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/BaseSegurosViewModel.cs656
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/BaseTarefaViewModel.cs105
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs2102
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogAdvertisingViewModel.cs225
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogAnexarViewModel.cs35
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogCopiaViewModel.cs162
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogCopiarPermissaoViewModel.cs320
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogEditarParcelasViewModel.cs245
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogEnviarEmailsViewModel.cs273
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogExportarPermissaoViewModel.cs109
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogGraficoViewModel.cs38
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogMedalhaViewModel.cs72
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogPesquisaAvancadaViewModel.cs503
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogProspeccaoViewModel.cs315
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogTarefaViewModel.cs300
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogTrilhaViewModel.cs95
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogViewModel.cs78
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/DialogVinculoViewModel.cs177
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/ErrorDialogViewModel.cs38
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/ExtratoComissaoViewModel.cs137
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/ItemViewModel.cs682
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/ProtocoloViewModel.cs28
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/ReordenarItensViewModel.cs63
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Generic/SelecionarItensViewModel.cs82
27 files changed, 11699 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/BaseApoliceViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/BaseApoliceViewModel.cs
new file mode 100644
index 0000000..038aec6
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/BaseApoliceViewModel.cs
@@ -0,0 +1,4483 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+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.Generic;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Application.ViewModels.Seguros;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.Helper;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class BaseApoliceViewModel : BaseSegurosViewModel
+{
+ internal ApoliceServico Servico;
+
+ internal PerfilServico PerfilServico;
+
+ internal RamoServico RamoServico;
+
+ internal SeguradoraServico SeguradoraServico;
+
+ internal VendedorServico VendedorServico;
+
+ internal ParcelaServico ParcelaServico;
+
+ internal ProdutoServico ProdutoServico;
+
+ internal EstipulanteServico EstipulanteServico;
+
+ internal TarefaServico TarefaServico;
+
+ private bool _invoke = true;
+
+ public bool UpdatePremio;
+
+ private bool _enableControle = true;
+
+ private bool _apelido;
+
+ private bool _controleAdm;
+
+ private Documento _selectedDocumento;
+
+ private Visibility _visibilityExcluirParcela = (Visibility)2;
+
+ private Visibility _visibilityReplicarFatura = (Visibility)2;
+
+ private Visibility _visibilityAlterarVencimento;
+
+ private string _importado = "CLIQUE PARA VER INFORMAÇÕES SOBRE A INCLUSÃO";
+
+ private string _codigoDocumento;
+
+ private DateTime? _emissaoDocumento;
+
+ private DateTime? _transmissaoDocumento;
+
+ private bool _editandoParcela;
+
+ private bool _botoesParcelaEnabled = true;
+
+ private List<Vendedor> _vendedores;
+
+ private List<Vendedor> _todosVendedores;
+
+ private ObservableCollection<VendedorParcela> _pagamentos;
+
+ private ObservableCollection<TipoSeguro> _situacao = new ObservableCollection<TipoSeguro>(new List<TipoSeguro>
+ {
+ (TipoSeguro)1,
+ (TipoSeguro)2,
+ (TipoSeguro)5
+ });
+
+ private ObservableCollection<TipoEndosso> _tipoEndosso = new ObservableCollection<TipoEndosso>(new List<TipoEndosso>
+ {
+ (TipoEndosso)0,
+ (TipoEndosso)1,
+ (TipoEndosso)2,
+ (TipoEndosso)4,
+ (TipoEndosso)3
+ });
+
+ private Parcela _selectedParcela;
+
+ private bool _coCorretagem;
+
+ private Visibility _baixarParcelaVisibility = (Visibility)2;
+
+ private ObservableCollection<Parcela> _parcelas;
+
+ private decimal _gerada;
+
+ private decimal _comissOriginal;
+
+ private Visibility _comissOriginalVisibility = (Visibility)2;
+
+ private decimal _recebida;
+
+ private decimal _pendente;
+
+ private decimal _repasse;
+
+ private Visibility _recusaVisibility;
+
+ private string _excluirParcelaLabel = "EXCLUIR BAIXA";
+
+ private bool _isEnableSituacao;
+
+ private List<Produto> _produtos = Recursos.Produtos;
+
+ private List<Status> _status = Recursos.Status;
+
+ private List<Ramo> _ramos;
+
+ private List<Seguradora> _seguradorasAnteriores;
+
+ private List<Seguradora> _seguradoras;
+
+ private Visibility _isRenovacaoVisibility = (Visibility)2;
+
+ private bool _isEndosso;
+
+ private bool _enableAlterarSituacao;
+
+ private string _assinada = "PROPOSTA ASSINADA";
+
+ private string _conferida = "APÓLICE CONFERIDA";
+
+ private string _transmissao = "TRANSMISSÃO DE PROPOSTA";
+
+ private string _emissao = "EMISSÃO DA APÓLICE";
+
+ private List<TipoVendedor> _tiposVendedor = Recursos.TipoVendedor?.Where((TipoVendedor x) => !x.Ativo.HasValue || x.Ativo.Value).ToList();
+
+ private List<Estipulante> _estipulantes;
+
+ public Documento CancelDocumento;
+
+ private List<VendedorParcela> _repasses;
+
+ private List<Repasse> _repassesVendedores;
+
+ private List<Repasse> _repassesVendedor;
+
+ private VendedorParcela _selectedPagamento;
+
+ private bool _baixarParcelas;
+
+ private bool _isFatura;
+
+ private bool _ultimaFatura;
+
+ private bool _allowEditVendedor = true;
+
+ private bool _alteracaoEnabled = true;
+
+ private bool _allowEditEmissao = true;
+
+ private bool _allowEditApolice = true;
+
+ private bool _allowVigenciaFinal = true;
+
+ private bool _novaApolice;
+
+ private bool _renovar;
+
+ public decimal Tolerancia;
+
+ private bool _enableRepasse;
+
+ private bool _bloquearObservacao = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 39);
+
+ private string _editarParcelasLabel = "EDITAR PARCELAS";
+
+ private string _anotacoes;
+
+ private int _quantidadeFaturas;
+
+ private double _tamanhoGrid;
+
+ private bool _inclusao;
+
+ private bool _criandoParcelaEspecial;
+
+ private bool _visibilityLogAntigo = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 22);
+
+ internal Documento DocumentoSelecionado { get; set; }
+
+ internal long ParcelaSelecionada { get; set; }
+
+ public bool Invoke
+ {
+ get
+ {
+ return _invoke;
+ }
+ set
+ {
+ _invoke = value;
+ OnPropertyChanged("Invoke");
+ }
+ }
+
+ public bool EnableControle
+ {
+ get
+ {
+ return _enableControle;
+ }
+ set
+ {
+ _enableControle = value;
+ OnPropertyChanged("EnableControle");
+ }
+ }
+
+ public AcessoApolice Acesso { get; set; }
+
+ public bool Apelido
+ {
+ get
+ {
+ return _apelido;
+ }
+ set
+ {
+ _apelido = value;
+ OnPropertyChanged("Apelido");
+ }
+ }
+
+ public bool ControleAdm
+ {
+ get
+ {
+ return _controleAdm;
+ }
+ set
+ {
+ _controleAdm = value;
+ OnPropertyChanged("ControleAdm");
+ }
+ }
+
+ public Documento SelectedDocumento
+ {
+ get
+ {
+ return _selectedDocumento;
+ }
+ set
+ {
+ if (value != null && ((DomainBase)value).Id == 0L)
+ {
+ VisibilityLogAntigo = false;
+ }
+ _selectedDocumento = value;
+ Anotacoes = string.Empty;
+ base.EnableButtons = value != null && ((DomainBase)value).Id > 0;
+ base.EnableIncluir = value == null || ((DomainBase)value).Id > 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);
+ if (value == null || ((DomainBase)value).Id == 0L)
+ {
+ ZeraComissao();
+ }
+ CodigoDocumento = ((SelectedDocumento == null || ((DomainBase)SelectedDocumento).Id == 0L) ? "" : $"{((DomainBase)SelectedDocumento).Id}");
+ if (value != null && value.Status == null && Status.First().Nome == "SEM STATUS")
+ {
+ value.Status = Status.First();
+ }
+ EmissaoDocumento = ((value != null && value.Emissao.HasValue) ? value.Emissao : new DateTime?(Funcoes.GetNetworkTime().Date));
+ TransmissaoDocumento = ((value != null && value.Remessa.HasValue) ? value.Remessa : new DateTime?(Funcoes.GetNetworkTime().Date));
+ RecusaVisibility = (Visibility)((Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 19) && !string.IsNullOrWhiteSpace((value != null) ? value.Apolice : null) && value.Emissao.HasValue) ? 2 : 0);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedDocumento");
+ }
+ }
+
+ public Visibility VisibilityExcluirParcela
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityExcluirParcela;
+ }
+ 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)
+ _visibilityExcluirParcela = value;
+ OnPropertyChanged("VisibilityExcluirParcela");
+ }
+ }
+
+ public Visibility VisibilityReplicarFatura
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityReplicarFatura;
+ }
+ 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)
+ _visibilityReplicarFatura = value;
+ OnPropertyChanged("VisibilityReplicarFatura");
+ }
+ }
+
+ public Visibility VisibilityAlterarVencimento
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityAlterarVencimento;
+ }
+ 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)
+ _visibilityAlterarVencimento = value;
+ OnPropertyChanged("VisibilityAlterarVencimento");
+ }
+ }
+
+ public string Importado
+ {
+ get
+ {
+ return _importado;
+ }
+ set
+ {
+ _importado = value;
+ OnPropertyChanged("Importado");
+ }
+ }
+
+ public string CodigoDocumento
+ {
+ get
+ {
+ return _codigoDocumento;
+ }
+ set
+ {
+ _codigoDocumento = value;
+ OnPropertyChanged("CodigoDocumento");
+ }
+ }
+
+ public DateTime? EmissaoDocumento
+ {
+ get
+ {
+ return _emissaoDocumento;
+ }
+ set
+ {
+ _emissaoDocumento = value;
+ OnPropertyChanged("EmissaoDocumento");
+ }
+ }
+
+ public DateTime? TransmissaoDocumento
+ {
+ get
+ {
+ return _transmissaoDocumento;
+ }
+ set
+ {
+ _transmissaoDocumento = value;
+ OnPropertyChanged("TransmissaoDocumento");
+ }
+ }
+
+ public bool EditandoParcela
+ {
+ get
+ {
+ return _editandoParcela;
+ }
+ set
+ {
+ _editandoParcela = value;
+ OnPropertyChanged("EditandoParcela");
+ }
+ }
+
+ public bool BotoesParcelaEnabled
+ {
+ get
+ {
+ return _botoesParcelaEnabled;
+ }
+ set
+ {
+ _botoesParcelaEnabled = value;
+ OnPropertyChanged("BotoesParcelaEnabled");
+ }
+ }
+
+ public List<Vendedor> Vendedores
+ {
+ get
+ {
+ return _vendedores;
+ }
+ set
+ {
+ _vendedores = value;
+ OnPropertyChanged("Vendedores");
+ }
+ }
+
+ public List<Vendedor> TodosVendedores
+ {
+ get
+ {
+ return _todosVendedores;
+ }
+ set
+ {
+ _todosVendedores = value;
+ OnPropertyChanged("TodosVendedores");
+ }
+ }
+
+ public ObservableCollection<VendedorParcela> Pagamentos
+ {
+ get
+ {
+ return _pagamentos;
+ }
+ set
+ {
+ _pagamentos = value;
+ OnPropertyChanged("Pagamentos");
+ }
+ }
+
+ public ObservableCollection<TipoSeguro> Situacao
+ {
+ get
+ {
+ return _situacao;
+ }
+ set
+ {
+ _situacao = value;
+ OnPropertyChanged("Situacao");
+ }
+ }
+
+ public ObservableCollection<TipoEndosso> TipoEndossoList
+ {
+ get
+ {
+ return _tipoEndosso;
+ }
+ set
+ {
+ _tipoEndosso = value;
+ OnPropertyChanged("TipoEndossoList");
+ }
+ }
+
+ public Parcela SelectedParcela
+ {
+ get
+ {
+ return _selectedParcela;
+ }
+ set
+ {
+ _selectedParcela = value;
+ WorkOnSelectedParcela(value);
+ OnPropertyChanged("SelectedParcela");
+ }
+ }
+
+ public bool CoCorretagem
+ {
+ get
+ {
+ return _coCorretagem;
+ }
+ set
+ {
+ if (SelectedPagamento != null)
+ {
+ SelectedPagamento.CoCorretagem = value;
+ }
+ _coCorretagem = value;
+ OnPropertyChanged("CoCorretagem");
+ }
+ }
+
+ public Visibility BaixarParcelaVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _baixarParcelaVisibility;
+ }
+ set
+ {
+ //IL_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000d: Unknown result type (might be due to invalid IL or missing references)
+ if (!Restricao((TipoRestricao)15))
+ {
+ _baixarParcelaVisibility = value;
+ OnPropertyChanged("BaixarParcelaVisibility");
+ }
+ }
+ }
+
+ public ObservableCollection<Parcela> Parcelas
+ {
+ get
+ {
+ return _parcelas;
+ }
+ set
+ {
+ _parcelas = value;
+ if (value != null && value.Count == 0)
+ {
+ VisibilityExcluirParcela = (Visibility)2;
+ VisibilityReplicarFatura = (Visibility)2;
+ BaixarParcelaVisibility = (Visibility)2;
+ VisibilityAlterarVencimento = (Visibility)2;
+ }
+ OnPropertyChanged("Parcelas");
+ }
+ }
+
+ public decimal Gerada
+ {
+ get
+ {
+ return _gerada;
+ }
+ set
+ {
+ _gerada = value;
+ OnPropertyChanged("Gerada");
+ }
+ }
+
+ public decimal ComissOriginal
+ {
+ get
+ {
+ return _comissOriginal;
+ }
+ set
+ {
+ ComissOriginalVisibility = (Visibility)((!VerificaCoCorretagem()) ? 2 : 0);
+ _comissOriginal = value;
+ OnPropertyChanged("ComissOriginal");
+ }
+ }
+
+ public Visibility ComissOriginalVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _comissOriginalVisibility;
+ }
+ 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)
+ _comissOriginalVisibility = value;
+ OnPropertyChanged("ComissOriginalVisibility");
+ }
+ }
+
+ public decimal Recebida
+ {
+ get
+ {
+ return _recebida;
+ }
+ set
+ {
+ _recebida = value;
+ OnPropertyChanged("Recebida");
+ }
+ }
+
+ public decimal Pendente
+ {
+ get
+ {
+ return _pendente;
+ }
+ set
+ {
+ _pendente = value;
+ OnPropertyChanged("Pendente");
+ }
+ }
+
+ public decimal Repasse
+ {
+ get
+ {
+ return _repasse;
+ }
+ set
+ {
+ _repasse = value;
+ OnPropertyChanged("Repasse");
+ }
+ }
+
+ 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 bool Loaded { get; set; }
+
+ public string ExcluirParcelaLabel
+ {
+ get
+ {
+ return _excluirParcelaLabel;
+ }
+ set
+ {
+ _excluirParcelaLabel = value;
+ OnPropertyChanged("ExcluirParcelaLabel");
+ }
+ }
+
+ public bool IsEnableSituacao
+ {
+ get
+ {
+ return _isEnableSituacao;
+ }
+ set
+ {
+ _isEnableSituacao = value;
+ OnPropertyChanged("IsEnableSituacao");
+ }
+ }
+
+ public List<Produto> Produtos
+ {
+ get
+ {
+ return _produtos;
+ }
+ set
+ {
+ _produtos = value;
+ OnPropertyChanged("Produtos");
+ }
+ }
+
+ public List<Status> Status
+ {
+ get
+ {
+ return _status;
+ }
+ set
+ {
+ //IL_0029: 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_0039: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0041: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004d: Expected O, but got Unknown
+ if (value.All((Status x) => x.Nome != "SEM STATUS"))
+ {
+ value.Insert(0, new Status
+ {
+ Nome = "SEM STATUS",
+ Id = 0L,
+ Ativo = true
+ });
+ }
+ _status = value;
+ OnPropertyChanged("Status");
+ }
+ }
+
+ public List<Ramo> Ramos
+ {
+ get
+ {
+ return _ramos;
+ }
+ set
+ {
+ _ramos = value;
+ OnPropertyChanged("Ramos");
+ }
+ }
+
+ public List<Seguradora> SeguradorasAnteriores
+ {
+ get
+ {
+ return _seguradorasAnteriores;
+ }
+ set
+ {
+ _seguradorasAnteriores = value;
+ OnPropertyChanged("SeguradorasAnteriores");
+ }
+ }
+
+ public List<Seguradora> Seguradoras
+ {
+ get
+ {
+ return _seguradoras;
+ }
+ set
+ {
+ _seguradoras = value;
+ OnPropertyChanged("Seguradoras");
+ }
+ }
+
+ public Visibility IsRenovacaoVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isRenovacaoVisibility;
+ }
+ 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)
+ _isRenovacaoVisibility = value;
+ OnPropertyChanged("IsRenovacaoVisibility");
+ }
+ }
+
+ public bool IsEndosso
+ {
+ get
+ {
+ return _isEndosso;
+ }
+ set
+ {
+ _isEndosso = value;
+ WorkOnSelectedTipo(value);
+ OnPropertyChanged("IsEndosso");
+ }
+ }
+
+ public bool EnableAlterarSituacao
+ {
+ get
+ {
+ return _enableAlterarSituacao;
+ }
+ set
+ {
+ _enableAlterarSituacao = value;
+ OnPropertyChanged("EnableAlterarSituacao");
+ }
+ }
+
+ public string Assinada
+ {
+ get
+ {
+ return _assinada;
+ }
+ set
+ {
+ _assinada = value;
+ OnPropertyChanged("Assinada");
+ }
+ }
+
+ public string Conferida
+ {
+ get
+ {
+ return _conferida;
+ }
+ set
+ {
+ _conferida = value;
+ OnPropertyChanged("Conferida");
+ }
+ }
+
+ public string Transmissao
+ {
+ get
+ {
+ return _transmissao;
+ }
+ set
+ {
+ _transmissao = value;
+ OnPropertyChanged("Transmissao");
+ }
+ }
+
+ public string Emissao
+ {
+ get
+ {
+ return _emissao;
+ }
+ set
+ {
+ _emissao = value;
+ OnPropertyChanged("Emissao");
+ }
+ }
+
+ public List<TipoVendedor> TiposVendedor
+ {
+ get
+ {
+ return _tiposVendedor;
+ }
+ set
+ {
+ _tiposVendedor = value;
+ OnPropertyChanged("TiposVendedor");
+ }
+ }
+
+ public List<Estipulante> Estipulantes
+ {
+ get
+ {
+ return _estipulantes;
+ }
+ set
+ {
+ _estipulantes = value;
+ OnPropertyChanged("Estipulantes");
+ }
+ }
+
+ public List<VendedorParcela> Repasses
+ {
+ get
+ {
+ return _repasses;
+ }
+ set
+ {
+ _repasses = value;
+ OnPropertyChanged("Repasses");
+ }
+ }
+
+ public List<Repasse> RepassesVendedores
+ {
+ get
+ {
+ return _repassesVendedores;
+ }
+ set
+ {
+ _repassesVendedores = value;
+ OnPropertyChanged("RepassesVendedores");
+ }
+ }
+
+ public List<Repasse> RepassesVendedor
+ {
+ get
+ {
+ return _repassesVendedor;
+ }
+ set
+ {
+ _repassesVendedor = value;
+ EnableRepasse = value != null && value.Count > 0;
+ OnPropertyChanged("RepassesVendedor");
+ }
+ }
+
+ public VendedorParcela SelectedPagamento
+ {
+ get
+ {
+ return _selectedPagamento;
+ }
+ set
+ {
+ _selectedPagamento = value;
+ OnPropertyChanged("SelectedPagamento");
+ }
+ }
+
+ public bool BaixarParcelas
+ {
+ get
+ {
+ return _baixarParcelas;
+ }
+ set
+ {
+ _baixarParcelas = value;
+ OnPropertyChanged("BaixarParcelas");
+ }
+ }
+
+ public bool IsFatura
+ {
+ get
+ {
+ return _isFatura;
+ }
+ set
+ {
+ _isFatura = value;
+ OnPropertyChanged("IsFatura");
+ }
+ }
+
+ public bool UltimaFatura
+ {
+ get
+ {
+ return _ultimaFatura;
+ }
+ set
+ {
+ _ultimaFatura = value;
+ OnPropertyChanged("UltimaFatura");
+ }
+ }
+
+ public bool AllowEditVendedor
+ {
+ get
+ {
+ return _allowEditVendedor;
+ }
+ set
+ {
+ _allowEditVendedor = _incluirPermissEnabled && value;
+ OnPropertyChanged("AllowEditVendedor");
+ }
+ }
+
+ public bool AlteracaoEnabled
+ {
+ get
+ {
+ return _alteracaoEnabled;
+ }
+ set
+ {
+ _alteracaoEnabled = value;
+ OnPropertyChanged("AlteracaoEnabled");
+ }
+ }
+
+ public bool AllowEditEmissao
+ {
+ get
+ {
+ return _allowEditEmissao;
+ }
+ set
+ {
+ _allowEditEmissao = value;
+ OnPropertyChanged("AllowEditEmissao");
+ }
+ }
+
+ public bool AllowEditApolice
+ {
+ get
+ {
+ return _allowEditApolice;
+ }
+ set
+ {
+ _allowEditApolice = value;
+ AllowVigenciaFinal = value || IsFatura;
+ OnPropertyChanged("AllowEditApolice");
+ }
+ }
+
+ public bool AllowVigenciaFinal
+ {
+ get
+ {
+ return _allowVigenciaFinal;
+ }
+ set
+ {
+ _allowVigenciaFinal = value;
+ OnPropertyChanged("AllowVigenciaFinal");
+ }
+ }
+
+ private Documento DocumentoRenovado { get; set; }
+
+ public bool NovaApolice
+ {
+ get
+ {
+ return _novaApolice;
+ }
+ set
+ {
+ _novaApolice = value;
+ OnPropertyChanged("NovaApolice");
+ }
+ }
+
+ public bool Renovar
+ {
+ get
+ {
+ return _renovar;
+ }
+ set
+ {
+ _renovar = value;
+ OnPropertyChanged("Renovar");
+ }
+ }
+
+ public bool EnableRepasse
+ {
+ get
+ {
+ return _enableRepasse;
+ }
+ set
+ {
+ _enableRepasse = value;
+ OnPropertyChanged("EnableRepasse");
+ }
+ }
+
+ public bool BloquearObservacao
+ {
+ get
+ {
+ return _bloquearObservacao;
+ }
+ set
+ {
+ _bloquearObservacao = value;
+ OnPropertyChanged("BloquearObservacao");
+ }
+ }
+
+ public string EditarParcelasLabel
+ {
+ get
+ {
+ return _editarParcelasLabel;
+ }
+ set
+ {
+ _editarParcelasLabel = value;
+ OnPropertyChanged("EditarParcelasLabel");
+ }
+ }
+
+ public new string Anotacoes
+ {
+ get
+ {
+ return _anotacoes;
+ }
+ set
+ {
+ _anotacoes = value;
+ OnPropertyChanged("Anotacoes");
+ }
+ }
+
+ public int QuantidadeFaturas
+ {
+ get
+ {
+ return _quantidadeFaturas;
+ }
+ set
+ {
+ if (value < 0)
+ {
+ value = 0;
+ }
+ if (value > 12)
+ {
+ value = 12;
+ }
+ _quantidadeFaturas = value;
+ OnPropertyChanged("QuantidadeFaturas");
+ }
+ }
+
+ public double TamanhoGrid
+ {
+ get
+ {
+ return _tamanhoGrid;
+ }
+ set
+ {
+ _tamanhoGrid = value;
+ OnPropertyChanged("TamanhoGrid");
+ }
+ }
+
+ public bool Inclusao
+ {
+ get
+ {
+ return _inclusao;
+ }
+ set
+ {
+ _inclusao = value;
+ OnPropertyChanged("Inclusao");
+ }
+ }
+
+ public bool CriandoParcelaEspecial
+ {
+ get
+ {
+ return _criandoParcelaEspecial;
+ }
+ set
+ {
+ _criandoParcelaEspecial = value;
+ }
+ }
+
+ public Imposto Imposto { get; set; }
+
+ public bool VisibilityLogAntigo
+ {
+ get
+ {
+ return _visibilityLogAntigo;
+ }
+ set
+ {
+ _visibilityLogAntigo = value;
+ OnPropertyChanged("VisibilityLogAntigo");
+ }
+ }
+
+ public BaseApoliceViewModel()
+ {
+ //IL_0010: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: 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_008f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b7: Unknown result type (might be due to invalid IL or missing references)
+ Servico = new ApoliceServico();
+ VendedorServico = new VendedorServico();
+ ParcelaServico = new ParcelaServico();
+ RamoServico = new RamoServico();
+ SeguradoraServico = new SeguradoraServico();
+ ProdutoServico = new ProdutoServico();
+ EstipulanteServico = new EstipulanteServico();
+ TarefaServico = new TarefaServico();
+ PerfilServico = new PerfilServico();
+ Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 6);
+ ControleAdm = Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 33) || Recursos.Usuario.Administrador;
+ }
+
+ public async Task Importacao()
+ {
+ List<CriticaApolice> importados = await new CriticaApoliceServico().BuscarImportacao(((DomainBase)SelectedDocumento).Id);
+ List<RegistroLog> list = (await new LogServico().FindByEntityId((TipoTela)2, ((DomainBase)SelectedDocumento).Id)).ToList();
+ RegistroLog val = ((list.Count > 0) ? list.Last() : null);
+ switch (importados.Count)
+ {
+ case 0:
+ {
+ BaseApoliceViewModel baseApoliceViewModel = this;
+ string importado;
+ if (SelectedDocumento.DataCriacao.HasValue)
+ {
+ Usuario usuarioCriacao = SelectedDocumento.UsuarioCriacao;
+ importado = $"CADASTRO MANUAL: {((usuarioCriacao != null) ? usuarioCriacao.Nome : null)} - {SelectedDocumento.DataCriacao:dd/MM/yyyy 'ÀS' HH:mm:ss}";
+ }
+ else
+ {
+ importado = $"CADASTRO MANUAL: {((val != null) ? val.Usuario.Nome : null)} - {((val != null) ? new DateTime?(val.DataHora) : null):dd/MM/yyyy 'ÀS' HH:mm:ss}";
+ }
+ baseApoliceViewModel.Importado = importado;
+ break;
+ }
+ case 1:
+ if (string.IsNullOrWhiteSpace(importados[0].Tipo) || importados[0].Tipo == "0")
+ {
+ Importado = ((!importados[0].Aggilizador.HasValue || !importados[0].Aggilizador.Value) ? $"IMPORTAÇÃO DA PROPOSTA: {importados[0].UsuarioImportacao.Nome} - {importados[0].DataImportacao:dd/MM/yyyy 'ÀS' HH:mm:ss}" : $"IMPORTAÇÃO DA PROPOSTA VIA AGGILIZADOR: {importados[0].UsuarioImportacao.Nome} - {importados[0].DataImportacao:dd/MM/yyyy 'ÀS' HH:mm:ss}");
+ }
+ if (importados[0].Tipo == "1")
+ {
+ if (!SelectedDocumento.DataCriacao.HasValue)
+ {
+ Importado = $"CADASTRO MANUAL DA PROPOSTA: {((val != null) ? val.Usuario.Nome : null)} - {((val != null) ? new DateTime?(val.DataHora) : null):dd/MM/yyyy 'ÀS' HH:mm:ss}\n";
+ }
+ else if (importados[0].DataImportacao.HasValue && DateTime.Compare(SelectedDocumento.DataCriacao.Value, importados[0].DataImportacao.Value) < 0)
+ {
+ Importado = $"CADASTRO MANUAL DA PROPOSTA: {SelectedDocumento.UsuarioCriacao} - {SelectedDocumento.DataCriacao:dd/MM/yyyy 'ÀS' HH:mm:ss}\n";
+ }
+ if (SelectedDocumento.DataCriacao <= importados[0].DataImportacao)
+ {
+ Importado = ((!importados[0].Aggilizador.HasValue || !importados[0].Aggilizador.Value) ? $"IMPORTAÇÃO DA APÓLICE: {importados[0].UsuarioImportacao.Nome} - {importados[0].DataImportacao:dd/MM/yyyy 'ÀS' HH:mm:ss}" : $"IMPORTAÇÃO DA APÓLICE VIA AGGILIZADOR: {importados[0].UsuarioImportacao.Nome} - {importados[0].DataImportacao:dd/MM/yyyy 'ÀS' HH:mm:ss}");
+ }
+ }
+ if (importados[0].Tipo == "2")
+ {
+ if (!SelectedDocumento.DataCriacao.HasValue)
+ {
+ Importado = $"CADASTRO MANUAL DA PROPOSTA: {((val != null) ? val.Usuario.Nome : null)} - {((val != null) ? new DateTime?(val.DataHora) : null):dd/MM/yyyy 'ÀS' HH:mm:ss}\n";
+ }
+ else if (importados[0].DataImportacao.HasValue && DateTime.Compare(SelectedDocumento.DataCriacao.Value, importados[0].DataImportacao.Value) < 0)
+ {
+ Importado = $"CADASTRO MANUAL DA PROPOSTA: {SelectedDocumento.UsuarioCriacao} - {SelectedDocumento.DataCriacao:dd/MM/yyyy 'ÀS' HH:mm:ss}\n";
+ }
+ if (SelectedDocumento.DataCriacao <= importados[0].DataImportacao)
+ {
+ Importado = ((!importados[0].Aggilizador.HasValue || !importados[0].Aggilizador.Value) ? $"IMPORTAÇÃO DO ENDOSSO: {importados[0].UsuarioImportacao.Nome} - {importados[0].DataImportacao:dd/MM/yyyy 'ÀS' HH:mm:ss}" : $"IMPORTAÇÃO DO ENDOSSO VIA AGGILIZADOR: {importados[0].UsuarioImportacao.Nome} - {importados[0].DataImportacao:dd/MM/yyyy 'ÀS' HH:mm:ss}");
+ }
+ }
+ break;
+ case 2:
+ case 3:
+ {
+ CriticaApolice val2 = importados.Find((CriticaApolice x) => string.IsNullOrWhiteSpace(x.Tipo) || x.Tipo == "0");
+ CriticaApolice val3 = importados.Find((CriticaApolice x) => x.Tipo == "1");
+ Importado = ((!val2.Aggilizador.HasValue || !val2.Aggilizador.Value) ? $"IMPORTAÇÃO DA PROPOSTA: {val2.UsuarioImportacao.Nome} - {val2.DataImportacao:dd/MM/yyyy 'ÀS' HH:mm:ss}\n" : $"IMPORTAÇÃO DA PROPOSTA VIA AGGILIZADOR: {val2.UsuarioImportacao.Nome} - {val2.DataImportacao:dd/MM/yyyy 'ÀS' HH:mm:ss}\n");
+ if (val3 != null)
+ {
+ Importado += ((!val3.Aggilizador.HasValue || !val3.Aggilizador.Value) ? $"IMPORTAÇÃO DA APÓLICE: {val3.UsuarioImportacao.Nome} - {val3.DataImportacao:dd/MM/yyyy 'ÀS' HH:mm:ss}" : $"IMPORTAÇÃO DA APÓLICE VIA AGGILIZADOR: {val3.UsuarioImportacao.Nome} - {val3.DataImportacao:dd/MM/yyyy 'ÀS' HH:mm:ss}");
+ }
+ break;
+ }
+ }
+ }
+
+ private void WorkOnSelectedParcela(Parcela value)
+ {
+ //IL_003a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0040: Invalid comparison between Unknown and I4
+ //IL_00a0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a6: Invalid comparison between Unknown and I4
+ //IL_00b9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00bf: Invalid comparison between Unknown and I4
+ //IL_01fe: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0204: Invalid comparison between Unknown and I4
+ if (value == null || ((DomainBase)value).Id == 0L || SelectedDocumento == null)
+ {
+ return;
+ }
+ bool flag = Repasses.Any((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id && x.DataPagamento.HasValue);
+ if ((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2)
+ {
+ AllowEditEmissao = (Repasses?.Where((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id && x.Repasse != null && (int)x.Repasse.Base.GetValueOrDefault() == 4).All((VendedorParcela x) => !x.DataPagamento.HasValue)).Value;
+ }
+ if ((int)value.SubTipo == 1 && (int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1)
+ {
+ BaixarParcelaVisibility = (Visibility)((!Parcelas.Any((Parcela x) => !x.DataRecebimento.HasValue && (int)x.SubTipo == 1)) ? 2 : 0);
+ Parcela val = ((IEnumerable<Parcela>)Parcelas.OrderBy((Parcela x) => x.NumeroParcela)).LastOrDefault((Func<Parcela, bool>)((Parcela x) => x.DataRecebimento.HasValue && (int)x.SubTipo == 1 && (x.ValorComissao != 0m || x.ValorRealizado != 0m)));
+ VisibilityExcluirParcela = (Visibility)(flag ? 2 : (((!value.DataRecebimento.HasValue || val != null) && !(((val != null) ? new int?(val.NumeroParcela) : null) <= value.NumeroParcela)) ? 2 : 0));
+ ExcluirParcelaLabel = "EXCLUIR BAIXA";
+ }
+ else
+ {
+ BaixarParcelaVisibility = (Visibility)(value.DataRecebimento.HasValue ? 2 : 0);
+ VisibilityExcluirParcela = (Visibility)(flag ? 2 : 0);
+ ExcluirParcelaLabel = (value.DataRecebimento.HasValue ? "EXCLUIR BAIXA" : (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1) ? "EXCLUIR PARCELA" : "EXCLUIR FATURA"));
+ }
+ VisibilityReplicarFatura = (Visibility)((!IsFatura) ? 2 : 0);
+ }
+
+ private void ZeraComissao()
+ {
+ Gerada = 0m;
+ Recebida = 0m;
+ Pendente = 0m;
+ Repasse = 0m;
+ ComissOriginal = 0m;
+ }
+
+ public async void Seleciona(Documento documento)
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)2);
+ await PermissaoTela((TipoTela)5);
+ if (documento == null || documento != SelectedDocumento)
+ {
+ await SelecionaDocumento(documento);
+ }
+ Gestor.Application.Actions.Actions.Redimencionar?.Invoke(Invoke);
+ Loading(isLoading: false);
+ }
+
+ public async Task BuscarVendedores(bool verificarRamo = true)
+ {
+ if (RepassesVendedores == null)
+ {
+ RepassesVendedores = await VendedorServico.BuscaRepasses();
+ TodosVendedores = (from x in RepassesVendedores
+ group x by ((DomainBase)x.Vendedor).Id into x
+ select x.First().Vendedor into x
+ orderby x.Nome
+ select x).ToList();
+ }
+ Documento selectedDocumento = SelectedDocumento;
+ List<Vendedor> list = ((selectedDocumento != null) ? selectedDocumento.Vendedores : null);
+ if (list == null)
+ {
+ Documento selectedDocumento2 = SelectedDocumento;
+ List<Vendedor> list2 = ((selectedDocumento2 == null || ((DomainBase)selectedDocumento2).Id <= 0) ? new List<Vendedor>() : (await ParcelaServico.BuscarVendedores(((DomainBase)SelectedDocumento).Id)));
+ list = list2;
+ }
+ List<Vendedor> vendedores = list;
+ Vendedores = TodosVendedores.Where((Vendedor x) => (x.IdEmpresa == Recursos.Usuario.IdEmpresa || vendedores.Select((Vendedor y) => ((DomainBase)y).Id).Contains(((DomainBase)x).Id)) && x.Ativo && !x.Corretora).ToList();
+ List<VendedorUsuario> list3 = await VerificaVinculoVendedor(Recursos.Usuario);
+ if (list3.Count > 0)
+ {
+ list3.ForEach(delegate(VendedorUsuario x)
+ {
+ vendedores.Add(x.Vendedor);
+ });
+ Vendedores = vendedores;
+ }
+ if (!verificarRamo)
+ {
+ return;
+ }
+ Documento selectedDocumento3 = SelectedDocumento;
+ object obj;
+ if (selectedDocumento3 == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ Controle controle = selectedDocumento3.Controle;
+ obj = ((controle != null) ? controle.Ramo : null);
+ }
+ if (obj == null)
+ {
+ return;
+ }
+ for (int num = Vendedores.Count - 1; num >= 0; num--)
+ {
+ List<Repasse> repasses = GetRepasses(Vendedores[num]);
+ if (!repasses.Any((Repasse x) => x.Ramo == null) && repasses.All((Repasse x) => ((DomainBase)x.Ramo).Id != ((DomainBase)SelectedDocumento.Controle.Ramo).Id))
+ {
+ Vendedores.Remove(Vendedores[num]);
+ }
+ }
+ }
+
+ public async Task LimparRepasses()
+ {
+ if (Pagamentos == null)
+ {
+ return;
+ }
+ ObservableCollection<VendedorParcela> pagamentos = Pagamentos;
+ if ((pagamentos == null || pagamentos.Count != 0) && Repasses != null)
+ {
+ List<VendedorParcela> repasses = Repasses;
+ if ((repasses == null || repasses.Count != 0) && ((DomainBase)SelectedDocumento).Id == 0L && base.EnableFields && AllowEditApolice && AlteracaoEnabled)
+ {
+ await ShowMessage("REPASSES ADICIONADOS NÃO PERTENCEM AO RAMO SELECIONADO E SERÃO EXCLUÍDOS.");
+ Pagamentos.Clear();
+ Repasses.Clear();
+ }
+ }
+ }
+
+ public async Task SelecionaDocumento(Documento documento)
+ {
+ Loading(isLoading: true);
+ base.IsEnabled = false;
+ await BuscarVendedores(verificarRamo: false);
+ Estipulantes = (from x in await new BaseServico().BuscarEstipulantes()
+ where (documento != null) ? (x.IdEmpresa == documento.Controle.IdEmpresa && x.Ativo) : (x.IdEmpresa == Recursos.Usuario.IdEmpresa)
+ orderby x.Nome
+ select x).ToList();
+ SelectedDocumento = null;
+ PreLoad();
+ if (documento == null)
+ {
+ base.EnableFields = false;
+ Loading(isLoading: false);
+ return;
+ }
+ await WorkOnSelectedDocumento(documento);
+ if (Invoke)
+ {
+ long id = ((DomainBase)SelectedDocumento).Id;
+ Documento documentoSelecionado = ConsultaViewModel.DocumentoSelecionado;
+ if (id != ((documentoSelecionado != null) ? new long?(((DomainBase)documentoSelecionado).Id) : null))
+ {
+ ConsultaViewModel.DocumentoSelecionado = SelectedDocumento;
+ }
+ }
+ if ((int)Acesso == 1 && ParcelaSelecionada != 0L)
+ {
+ await SelecionaParcela(((IEnumerable<Parcela>)Parcelas).FirstOrDefault((Func<Parcela, bool>)((Parcela x) => ((DomainBase)x).Id == ParcelaSelecionada)));
+ }
+ if (Invoke)
+ {
+ Loaded = true;
+ }
+ base.IsEnabled = true;
+ Loading(isLoading: false);
+ }
+
+ private void PreLoad()
+ {
+ Ramos = Recursos.Ramos;
+ Seguradoras = Recursos.Seguradoras;
+ Produtos = Recursos.Produtos;
+ Status = Recursos.Status;
+ SeguradorasAnteriores = Recursos.Seguradoras;
+ TipoEndossoList = new ObservableCollection<TipoEndosso>(new List<TipoEndosso>
+ {
+ (TipoEndosso)0,
+ (TipoEndosso)1,
+ (TipoEndosso)2,
+ (TipoEndosso)4,
+ (TipoEndosso)3
+ });
+ }
+
+ private async Task WorkOnSelectedDocumento(Documento value)
+ {
+ base.IsEnabledEdit = value == null || ((DomainBase)value).Id == 0;
+ base.IsEnabledEditEndosso = value == null || ((DomainBase)value).Id == 0;
+ if (value != null && ((DomainBase)value).Id != 0L)
+ {
+ if (Situacao.All((TipoSeguro x) => x != value.Situacao))
+ {
+ List<TipoSeguro> list = new List<TipoSeguro>
+ {
+ (TipoSeguro)1,
+ (TipoSeguro)2,
+ (TipoSeguro)5,
+ value.Situacao
+ };
+ Situacao = new ObservableCollection<TipoSeguro>(list);
+ }
+ else
+ {
+ IsEnableSituacao = true;
+ }
+ Controle controle = value.Controle;
+ List<Seguradora> seguradoras = ((((controle != null) ? controle.Seguradora : null) != null) ? Recursos.Seguradoras.Where((Seguradora x) => x.Ativo || ((DomainBase)x).Id == ((DomainBase)value.Controle.Seguradora).Id).ToList() : Recursos.Seguradoras.Where((Seguradora x) => x.Ativo).ToList());
+ Seguradoras = seguradoras;
+ SeguradorasAnteriores = Recursos.Seguradoras;
+ SelectedDocumento = await Servico.BuscarApoliceAsync(((DomainBase)value).Id);
+ if (!SelectedDocumento.NegocioCorretora.HasValue)
+ {
+ SelectedDocumento.NegocioCorretora = (NegocioCorretora)(((int)SelectedDocumento.Situacao == 2 && SelectedDocumento.Negocio.HasValue && (int)SelectedDocumento.Negocio.GetValueOrDefault() == 1) ? 1 : 0);
+ OnPropertyChanged("SelectedDocumento");
+ }
+ BaseApoliceViewModel baseApoliceViewModel = this;
+ Controle controle2 = SelectedDocumento.Controle;
+ decimal? obj;
+ if (controle2 == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ Seguradora seguradora = controle2.Seguradora;
+ obj = ((seguradora != null) ? seguradora.Tolerancia : null);
+ }
+ decimal? num = obj;
+ baseApoliceViewModel.Tolerancia = num.GetValueOrDefault(2m);
+ List<Produto> produtos = Recursos.Produtos.Where((Produto x) => x.Ativo || (SelectedDocumento.Controle.Produto != null && ((DomainBase)x).Id == ((DomainBase)SelectedDocumento.Controle.Produto).Id)).ToList();
+ Produtos = produtos;
+ if (Invoke)
+ {
+ ConsultaViewModel.DocumentoSelecionado = SelectedDocumento;
+ }
+ Documento documento = (Documento)((DomainBase)SelectedDocumento).Clone();
+ await CarregarParcelas(documento);
+ await CarregaRepasse(((DomainBase)documento).Id);
+ ((DomainBase)SelectedDocumento).Initialize();
+ Initialized = true;
+ if (Parcelas.Count == 0)
+ {
+ AllowEditVendedor = false;
+ }
+ AllowEditApolice = Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).All((Parcela x) => !x.DataRecebimento.HasValue) && Repasses.Where((VendedorParcela x) => (int)x.Parcela.SubTipo == 1).All((VendedorParcela x) => !x.DataPagamento.HasValue);
+ AllowEditEmissao = (int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2 || Repasses.Where((VendedorParcela x) => x.Repasse != null && (int)x.Repasse.Base.GetValueOrDefault() == 4).All((VendedorParcela x) => !x.DataPagamento.HasValue);
+ CalculaComissao(SelectedDocumento, Parcelas);
+ IsEndosso = SelectedDocumento.Tipo != 0;
+ EnableAlterarSituacao = !SelectedDocumento.TipoEndosso.HasValue || ((int)SelectedDocumento.TipoEndosso.GetValueOrDefault() != 2 && (int)SelectedDocumento.TipoEndosso.GetValueOrDefault() != 3);
+ EditarParcelasLabel = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? "EDITAR FATURAS" : "EDITAR PARCELAS");
+ base.AllowEditParcela = true;
+ CancelDocumento = (Documento)((DomainBase)SelectedDocumento).Clone();
+ }
+ }
+
+ public bool VerificaCoCorretagem()
+ {
+ return Repasses?.Any((VendedorParcela x) => x.CoCorretagem) ?? false;
+ }
+
+ public async Task CarregarParcelas(Documento documento)
+ {
+ if (documento != null)
+ {
+ ObservableCollection<Parcela> observableCollection = await ParcelaServico.BuscarParcelasPorDocumento(documento);
+ Parcelas = (IsFatura ? new ObservableCollection<Parcela>(observableCollection.OrderByDescending((Parcela x) => x.NumeroParcela)) : observableCollection);
+ if (Invoke)
+ {
+ Gestor.Application.Actions.Actions.RecarregarParcelas?.Invoke(SelectedDocumento);
+ }
+ }
+ }
+
+ 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);
+ Repasse = Repasses.Where((VendedorParcela x) => x.DataPrePagamento.HasValue && !x.CoCorretagem).Sum((VendedorParcela x) => x.ValorRepasse.GetValueOrDefault());
+ if (Pendente < Tolerancia)
+ {
+ Pendente = 0m;
+ }
+ if (VerificaCoCorretagem())
+ {
+ Documento selectedDocumento = SelectedDocumento;
+ ComissOriginal = ((selectedDocumento != null) ? selectedDocumento.ComissaoTotal : null).GetValueOrDefault();
+ }
+ }
+
+ public void ToggleSeguradoraAnterior(TipoSeguro situacao)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Invalid comparison between Unknown and I4
+ if ((int)situacao != 2)
+ {
+ IsRenovacaoVisibility = (Visibility)2;
+ }
+ else
+ {
+ IsRenovacaoVisibility = (Visibility)0;
+ }
+ }
+
+ private void WorkOnSelectedTipo(bool value)
+ {
+ Assinada = (value ? "PROPOSTA DE ENDOSSO ASSINADA" : "PROPOSTA ASSINADA");
+ Conferida = (value ? "ENDOSSO CONFERIDO" : "APÓLICE CONFERIDA");
+ Transmissao = (value ? "TRANSMISSÃO DA PROPOSTA DE ENDOSSO" : "TRANSMISSÃO DA PROPOSTA");
+ Emissao = (value ? "EMISSÃO DO ENDOSSO" : "EMISSÃO DA APÓLICE");
+ }
+
+ public async Task<bool> SelecionarParcelaBaixa()
+ {
+ if (SelectedParcela == null || SelectedDocumento == null)
+ {
+ return false;
+ }
+ if ((int)SelectedParcela.SubTipo != 1 && !SelectedParcela.DataRecebimento.HasValue)
+ {
+ SelectedParcela.ValorLiquidoFatura = SelectedDocumento.PremioLiquido / ((SelectedDocumento.NumeroParcelas > 0m) ? SelectedDocumento.NumeroParcelas : 1m);
+ SelectedParcela.Baixando = true;
+ return true;
+ }
+ if (IsFatura && !SelectedParcela.DataRecebimento.HasValue)
+ {
+ SelectedParcela.Baixando = true;
+ return true;
+ }
+ if (Parcelas == null || !Parcelas.Any())
+ {
+ return false;
+ }
+ Parcela parcela = ((IEnumerable<Parcela>)Parcelas.OrderBy((Parcela x) => x.NumeroParcela)).FirstOrDefault((Func<Parcela, bool>)((Parcela x) => !x.DataRecebimento.HasValue && (int)x.SubTipo == 1));
+ if (parcela != null && !IsFatura && SelectedDocumento.NumeroParcelas > 0m)
+ {
+ parcela.ValorLiquidoFatura = (SelectedDocumento.AdicionalComiss ? ((SelectedDocumento.PremioLiquido + SelectedDocumento.PremioAdicional) / SelectedDocumento.NumeroParcelas) : (SelectedDocumento.PremioLiquido / SelectedDocumento.NumeroParcelas));
+ }
+ SelectedParcela = parcela ?? SelectedParcela;
+ if (parcela == null)
+ {
+ await ShowMessage("NÃO HÁ MAIS NENHUMA PARCELA A SER BAIXADA");
+ }
+ if (parcela != null)
+ {
+ SelectedParcela.Baixando = true;
+ }
+ return parcela != null;
+ }
+
+ public async Task SelecionaParcela(Parcela parcela)
+ {
+ SelectedParcela = parcela;
+ if (parcela == null || ((DomainBase)parcela).Id == 0L || SelectedDocumento == null)
+ {
+ return;
+ }
+ if (Repasses == null)
+ {
+ await CarregaRepasse(((DomainBase)SelectedDocumento).Id);
+ }
+ List<VendedorParcela> source = Repasses.Where((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)parcela).Id).ToList();
+ if (IsFatura || (int)parcela.SubTipo != 1)
+ {
+ AllowEditVendedor = !parcela.DataRecebimento.HasValue && source.All((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)parcela).Id && !x.DataPagamento.HasValue);
+ }
+ if (!IsFatura && (int)parcela.SubTipo == 1)
+ {
+ AllowEditVendedor = parcela.NumeroParcela == 1 && !parcela.DataRecebimento.HasValue && source.All((VendedorParcela x) => (int)x.Parcela.SubTipo == 1 && !x.DataPagamento.HasValue);
+ }
+ Pagamentos = new ObservableCollection<VendedorParcela>(source.OrderBy((VendedorParcela x) => ((DomainBase)x.TipoVendedor).Id));
+ }
+
+ public async Task CarregaRepasse(long id)
+ {
+ Repasses = await VendedorServico.BuscaRepasse(id);
+ await SelecionaParcela(SelectedParcela ?? Parcelas.FirstOrDefault());
+ }
+
+ public async void CancelPagamento()
+ {
+ BaixarParcelas = false;
+ SelectedParcela.Baixando = false;
+ ObservableCollection<Parcela> observableCollection = await ParcelaServico.BuscarParcelasAsync(((DomainBase)SelectedDocumento).Id);
+ Parcelas = (IsFatura ? new ObservableCollection<Parcela>(observableCollection.OrderByDescending((Parcela x) => x.NumeroParcela)) : observableCollection);
+ await CarregaRepasse(((DomainBase)SelectedDocumento).Id);
+ await SelecionaParcela(Parcelas.FirstOrDefault());
+ }
+
+ public void IncluirParcelaEspecial()
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0013: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0029: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0035: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0048: 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_005c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0067: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0077: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008c: Expected O, but got Unknown
+ SelectedParcela = new Parcela
+ {
+ IdEmpresa = SelectedDocumento.Controle.IdEmpresa,
+ Documento = SelectedDocumento,
+ Vencimento = Funcoes.GetNetworkTime().Date,
+ Comissao = 100m,
+ SubTipo = (SubTipo)3,
+ NumeroParcela = 999,
+ DataCriacao = Funcoes.GetNetworkTime(),
+ UsuarioCriacao = ((DomainBase)Recursos.Usuario).Id
+ };
+ Parcela parcelaAtual = Parcelas?.FirstOrDefault((Func<Parcela, bool>)((Parcela x) => (int)x.SubTipo == 1));
+ if (parcelaAtual == null)
+ {
+ Repasses = new List<VendedorParcela>();
+ return;
+ }
+ List<VendedorParcela> list = Repasses.Where((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)parcelaAtual).Id).ToList();
+ list.ForEach(delegate(VendedorParcela x)
+ {
+ ((DomainBase)x).Id = 0L;
+ x.Parcela = SelectedParcela;
+ x.DataPrePagamento = null;
+ x.DataPagamento = null;
+ x.ValorRepasse = default(decimal);
+ x.DataPagamento = null;
+ });
+ Repasses = list;
+ RecalculaRepasse();
+ }
+
+ public void IncluirFatura()
+ {
+ //IL_011e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0123: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0139: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0145: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0159: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0160: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0167: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_017a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_018f: Expected O, but got Unknown
+ Parcela? obj = ((IEnumerable<Parcela>)Parcelas.OrderBy((Parcela x) => x.NumeroParcela)).LastOrDefault((Func<Parcela, bool>)((Parcela x) => (int)x.SubTipo == 1));
+ int numeroParcela = ((obj != null) ? obj.NumeroParcela : 0) + 1;
+ decimal comissao = ((obj != null) ? obj.Comissao : 0m);
+ Parcela selectedParcela = SelectedParcela;
+ long num2;
+ if (selectedParcela == null)
+ {
+ ObservableCollection<Parcela> parcelas = Parcelas;
+ long? obj2;
+ if (parcelas == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Parcela? obj3 = ((IEnumerable<Parcela>)parcelas.OrderBy((Parcela x) => x.NumeroParcela)).LastOrDefault((Func<Parcela, bool>)((Parcela x) => (int)x.SubTipo == 1));
+ obj2 = ((obj3 != null) ? new long?(((DomainBase)obj3).Id) : null);
+ }
+ long? num = obj2;
+ num2 = num.GetValueOrDefault();
+ }
+ else
+ {
+ num2 = ((DomainBase)selectedParcela).Id;
+ }
+ long parcelaAtual = num2;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ SelectedParcela = new Parcela
+ {
+ IdEmpresa = SelectedDocumento.Controle.IdEmpresa,
+ Documento = SelectedDocumento,
+ Vencimento = Funcoes.GetNetworkTime().Date,
+ Comissao = comissao,
+ SubTipo = (SubTipo)1,
+ NumeroParcela = numeroParcela,
+ DataCriacao = networkTime,
+ UsuarioCriacao = ((DomainBase)Recursos.Usuario).Id
+ };
+ if (parcelaAtual != 0L)
+ {
+ List<VendedorParcela> list = Repasses.Where((VendedorParcela x) => ((DomainBase)x.Parcela).Id == parcelaAtual).ToList();
+ list.ForEach(delegate(VendedorParcela x)
+ {
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005c: 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)
+ ((DomainBase)x).Id = 0L;
+ x.Parcela = SelectedParcela;
+ x.DataPrePagamento = null;
+ x.DataPagamento = null;
+ x.PorcentagemRepasse = ((x.Repasse == null) ? 0m : ((SelectedDocumento.NegocioCorretora == (NegocioCorretora?)0) ? x.Repasse.ValorNovo : x.Repasse.ValorRenovacao));
+ });
+ Repasses = list;
+ RecalculaRepasse();
+ }
+ }
+
+ public async Task ReplicarFatura()
+ {
+ if (Parcelas != null)
+ {
+ Parcela val = ((IEnumerable<Parcela>)Parcelas.OrderBy((Parcela x) => x.NumeroParcela)).LastOrDefault((Func<Parcela, bool>)((Parcela x) => (int)x.SubTipo == 1));
+ if (val != null && val.NumeroParcela == 999)
+ {
+ await ShowMessage("PARCELA ESPECIAL NÃO PODE SER REPLICADA.");
+ return;
+ }
+ int numeroParcela = ((val != null) ? val.NumeroParcela : 0) + 1;
+ Parcela selectedParcela = SelectedParcela;
+ decimal comissao = ((selectedParcela != null) ? selectedParcela.Comissao : 0m);
+ Parcela parcelaAtual = Parcelas.First((Parcela x) => (int)x.SubTipo == 1);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Parcela obj = parcelaAtual;
+ DateTime value = ((obj != null) ? obj.VigenciaFinal : null) ?? networkTime.Date;
+ Parcela obj2 = parcelaAtual;
+ DateTime value2 = ((obj2 == null) ? null : obj2.Emissao?.AddMonths(1)) ?? networkTime.Date;
+ Parcela obj3 = parcelaAtual;
+ DateTime vencimento = ((obj3 != null) ? obj3.Vencimento.AddMonths(1) : networkTime.Date);
+ DateTime value3 = value.AddMonths(1);
+ Parcela obj4 = parcelaAtual;
+ decimal valor = ((obj4 != null) ? obj4.Valor : 0m);
+ Parcela obj5 = parcelaAtual;
+ decimal valorLiquidoFatura = ((obj5 != null) ? obj5.ValorLiquidoFatura : 0m);
+ List<VendedorParcela> list = Funcoes.DistinctBy(Repasses.Where((VendedorParcela x) => parcelaAtual != null && ((DomainBase)x.Parcela).Id == ((DomainBase)parcelaAtual).Id), (VendedorParcela x) => new
+ {
+ Id = ((DomainBase)x.Parcela).Id,
+ vendedor = ((DomainBase)x.Vendedor).Id,
+ tipovendedor = ((DomainBase)x.TipoVendedor).Id
+ }).ToList();
+ SelectedParcela = new Parcela
+ {
+ IdEmpresa = SelectedDocumento.Controle.IdEmpresa,
+ Documento = SelectedDocumento,
+ Vencimento = vencimento,
+ Comissao = comissao,
+ SubTipo = (SubTipo)1,
+ NumeroParcela = numeroParcela,
+ VigenciaIncial = value,
+ VigenciaFinal = value3,
+ Valor = valor,
+ Emissao = value2,
+ DataCriacao = networkTime,
+ ValorLiquidoFatura = valorLiquidoFatura
+ };
+ list.ForEach(delegate(VendedorParcela x)
+ {
+ //IL_004f: 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_0057: Unknown result type (might be due to invalid IL or missing references)
+ ((DomainBase)x).Id = 0L;
+ x.Parcela = SelectedParcela;
+ x.DataPrePagamento = null;
+ x.DataPagamento = null;
+ x.PorcentagemRepasse = ((x.Repasse == null) ? 0m : ((SelectedDocumento.NegocioCorretora == (NegocioCorretora?)0) ? x.Repasse.ValorNovo : x.Repasse.ValorRenovacao));
+ });
+ Repasses = list;
+ }
+ RecalculaRepasse();
+ }
+
+ public void IncluirVendedor()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Expected O, but got Unknown
+ SelectedPagamento = new VendedorParcela
+ {
+ Documento = SelectedDocumento
+ };
+ }
+
+ public void SelecionarVendedor()
+ {
+ SelectedPagamento = Pagamentos?.FirstOrDefault();
+ }
+
+ public void SelecionaPrimeiraParcela()
+ {
+ SelectedParcela = SelectedParcela ?? Parcelas.FirstOrDefault();
+ }
+
+ public async Task<bool> IncluirApolice(bool renovar = false)
+ {
+ if (renovar && (string.IsNullOrWhiteSpace(SelectedDocumento.Apolice) || !SelectedDocumento.Emissao.HasValue))
+ {
+ await ShowMessage("PROPOSTA NÃO PODE SER RENOVADA. NECESSÁRIO PREENCHER O NÚMERO DA APÓLICE E DATA DE EMISSÃO ANTES DE PROSSEGUIR.");
+ return false;
+ }
+ List<Seguradora> seguradoras = (from x in Recursos.Seguradoras
+ where x.Ativo
+ orderby x.Nome
+ select x).ToList();
+ Seguradoras = seguradoras;
+ SeguradorasAnteriores = Recursos.Seguradoras;
+ List<Ramo> ramos = (from x in Recursos.Ramos
+ where x.Ativo
+ orderby x.Nome
+ select x).ToList();
+ Ramos = ramos;
+ List<Produto> produtos = Recursos.Produtos.Where((Produto x) => x.Ativo).ToList();
+ Produtos = produtos;
+ List<Status> status = Recursos.Status.Where((Status x) => x.Ativo).ToList();
+ Status = status;
+ DateTime today = Funcoes.GetNetworkTime().Date;
+ Documento documento;
+ if (renovar)
+ {
+ SelectedDocumento = await Servico.BuscarApoliceAsync(((DomainBase)SelectedDocumento).Id);
+ DocumentoRenovado = SelectedDocumento;
+ if (Seguradoras.All((Seguradora x) => ((DomainBase)x).Id != ((DomainBase)SelectedDocumento.Controle.Seguradora).Id))
+ {
+ Seguradoras.Add(SelectedDocumento.Controle.Seguradora);
+ }
+ if (SelectedDocumento.Controle.Produto != null && Produtos.All((Produto x) => ((DomainBase)x).Id != ((DomainBase)SelectedDocumento.Controle.Produto).Id))
+ {
+ Seguradoras.Add(SelectedDocumento.Controle.Seguradora);
+ }
+ if (SelectedDocumento.Controle.Ramo != null && Ramos.All((Ramo x) => ((DomainBase)x).Id != ((DomainBase)SelectedDocumento.Controle.Ramo).Id))
+ {
+ Seguradoras.Add(SelectedDocumento.Controle.Seguradora);
+ }
+ Vendedores = (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 20) ? TodosVendedores.Where((Vendedor x) => x.IdEmpresa == SelectedDocumento.Controle.IdEmpresa && x.Ativo && !x.Corretora).ToList() : new List<Vendedor>());
+ Estipulantes = Recursos.Estipulantes.Where((Estipulante x) => x.IdEmpresa == SelectedDocumento.Controle.IdEmpresa && x.Ativo).ToList();
+ documento = new Documento
+ {
+ Controle = new Controle
+ {
+ Cliente = MainViewModel.ClienteSelecionado,
+ IdEmpresa = SelectedDocumento.Controle.IdEmpresa,
+ Ramo = SelectedDocumento.Controle.Ramo,
+ Seguradora = SelectedDocumento.Controle.Seguradora,
+ SeguradoraAnterior = SelectedDocumento.Controle.Seguradora
+ },
+ Ordem = 0,
+ Tipo = 0,
+ NegocioCorretora = (NegocioCorretora)1,
+ Situacao = (TipoSeguro)2,
+ Negocio = (Negocio)1,
+ TipoRecebimento = (TipoRecebimento)1,
+ Vigencia1 = SelectedDocumento.Vigencia2.GetValueOrDefault(today),
+ Vigencia2 = (SelectedDocumento.Vigencia2?.AddYears(1) ?? today.AddYears(1)),
+ ApoliceConferida = false,
+ PropostaAssinada = false,
+ AdicionalComiss = false,
+ Excluido = false,
+ ApoliceAnterior = SelectedDocumento.Apolice,
+ FormaPagamento = null
+ };
+ EmissaoDocumento = today;
+ TransmissaoDocumento = today;
+ if (await ShowMessage("DESEJA MANTER OS VENDEDORES DA APÓLICE ANTERIOR?", "SIM", "NÃO"))
+ {
+ Pagamentos?.ToList().ForEach(delegate(VendedorParcela x)
+ {
+ x.Documento = null;
+ x.ValorRepasse = default(decimal);
+ x.ValorTotal = null;
+ x.DataPagamento = null;
+ x.DataPagamento = null;
+ });
+ }
+ else
+ {
+ Pagamentos = new ObservableCollection<VendedorParcela> { PropriaCorretora() };
+ Repasses = null;
+ }
+ Pagamentos = ((Pagamentos != null) ? new ObservableCollection<VendedorParcela>(Pagamentos) : new ObservableCollection<VendedorParcela>());
+ }
+ else
+ {
+ Inclusao = true;
+ Vendedores = (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 20) ? TodosVendedores.Where((Vendedor x) => x.IdEmpresa == MainViewModel.ClienteSelecionado.IdEmpresa && x.Ativo && !x.Corretora).ToList() : new List<Vendedor>());
+ Estipulantes = Recursos.Estipulantes.Where((Estipulante x) => x.IdEmpresa == MainViewModel.ClienteSelecionado.IdEmpresa && x.Ativo).ToList();
+ documento = new Documento
+ {
+ Controle = new Controle
+ {
+ Cliente = MainViewModel.ClienteSelecionado,
+ IdEmpresa = MainViewModel.ClienteSelecionado.IdEmpresa
+ },
+ Ordem = 0,
+ Tipo = 0,
+ NegocioCorretora = (NegocioCorretora)0,
+ Situacao = (TipoSeguro)1,
+ TipoRecebimento = (TipoRecebimento)1,
+ Vigencia1 = today,
+ Vigencia2 = today.AddYears(1),
+ ApoliceConferida = false,
+ PropostaAssinada = false,
+ AdicionalComiss = false,
+ Excluido = false,
+ FormaPagamento = null
+ };
+ Pagamentos = null;
+ Repasses = null;
+ }
+ IsFatura = false;
+ SelectedParcela = null;
+ SelectedDocumento = null;
+ SelectedPagamento = null;
+ Parcelas = null;
+ SelectedDocumento = documento;
+ IsEndosso = false;
+ NovaApolice = true;
+ Renovar = renovar;
+ EnableAlterarSituacao = true;
+ AllowEditVendedor = !renovar;
+ AllowEditApolice = true;
+ base.IsEnabledEdit = true;
+ base.IsEnabledEditEndosso = true;
+ base.AllowEditParcela = false;
+ base.EnableFields = true;
+ base.EnableIncluir = false;
+ Gestor.Application.Actions.Actions.EnableMainMenu?.Invoke(obj: false);
+ return true;
+ }
+
+ public async Task<bool> VerificarVigencia(Documento documento)
+ {
+ if (!documento.Vigencia2.HasValue)
+ {
+ return true;
+ }
+ TimeSpan timeSpan = DateTime.Parse(documento.Vigencia2.ToString()) - documento.Vigencia1;
+ string text = ((timeSpan.Days > 366) ? "VIGÊNCIA FINAL MAIOR QUE 365 DIAS.\nDESEJA CONTINUAR?" : ((timeSpan.Days < 365) ? "VIGÊNCIA FINAL MENOR QUE 365 DIAS.\nDESEJA CONTINUAR?" : ""));
+ if (text == "")
+ {
+ return true;
+ }
+ return await ShowMessage(text, "SIM", "NÃO");
+ }
+
+ private void ZerarValores()
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0014: Invalid comparison between Unknown and I4
+ if ((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2)
+ {
+ SelectedDocumento.PremioLiquido = 0m;
+ SelectedDocumento.PremioAdicional = 0m;
+ SelectedDocumento.PremioAdicional = 0m;
+ SelectedDocumento.Iof = 0m;
+ SelectedDocumento.Diferenca = 0m;
+ SelectedDocumento.NumeroParcelas = 0m;
+ }
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar(bool critica = false)
+ {
+ if ((int)SelectedDocumento.Situacao == 2)
+ {
+ SelectedDocumento.Negocio = (Negocio)((SelectedDocumento.NegocioCorretora != (NegocioCorretora?)0) ? 1 : 2);
+ }
+ Status status = SelectedDocumento.Status;
+ if (status != null && ((DomainBase)status).Id == 0)
+ {
+ SelectedDocumento.Status = null;
+ }
+ ZerarValores();
+ List<KeyValuePair<string, string>> errors = SelectedDocumento.Validate(IsEndosso, Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 11));
+ if (SelectedDocumento.Comissao > 100m)
+ {
+ SelectedDocumento.Comissao = 100m;
+ }
+ bool insert = ((DomainBase)SelectedDocumento).Id == 0;
+ VendedorParcela selectedPagamento = SelectedPagamento;
+ if (((selectedPagamento != null) ? selectedPagamento.Vendedor : null) != null && SelectedDocumento.Vendedores == null)
+ {
+ SelectedDocumento.Vendedores = new List<Vendedor> { TodosVendedores.First((Vendedor x) => x.Corretora && x.IdEmpresa == SelectedDocumento.Controle.IdEmpresa) };
+ }
+ if (insert)
+ {
+ VendedorParcela selectedPagamento2 = SelectedPagamento;
+ if (((selectedPagamento2 != null) ? selectedPagamento2.Vendedor : null) != null && SelectedDocumento.Vendedores != null)
+ {
+ List<KeyValuePair<string, string>> list = errors;
+ list.AddRange((await AdicionarVendedor()) ?? new List<KeyValuePair<string, string>>());
+ }
+ }
+ if (errors.Count > 0)
+ {
+ return errors;
+ }
+ bool flag = SelectedDocumento.Tipo == 0;
+ if (flag)
+ {
+ flag = !(await VerificarVigencia(SelectedDocumento));
+ }
+ if (flag)
+ {
+ if (critica)
+ {
+ errors.Add(new KeyValuePair<string, string>("Vigencia2", "VIGENCIANAOACEITA"));
+ }
+ return errors;
+ }
+ if ((int)SelectedDocumento.TipoEndosso.GetValueOrDefault() != 3 && (int)SelectedDocumento.Situacao == 3 && ((DomainBase)SelectedDocumento).Id == 0L)
+ {
+ await ShowMessage("EM DOCUMENTOS CANCELADOS SÓ É POSSIVEL INCLUIR ENDOSSO DE REABILITAÇÃO.");
+ Alterar(alterar: true);
+ return null;
+ }
+ if (SelectedDocumento.TipoEndosso.HasValue && (int)SelectedDocumento.TipoEndosso.GetValueOrDefault() == 3)
+ {
+ SelectedDocumento.Situacao = (TipoSeguro)4;
+ }
+ Documento documento = SelectedDocumento;
+ Alterar(alterar: false);
+ if (!documento.FormaPagamento.HasValue)
+ {
+ documento.FormaPagamento = (FormaPagamento)(Recursos.Configuracoes.Any((ConfiguracaoSistema y) => (int)y.Configuracao == 21) ? 4 : 0);
+ }
+ Acesso = (AcessoApolice)0;
+ bool updateValores = ((DomainBase)documento).Id > 0 && AllowEditApolice && (CancelDocumento.PremioLiquido != documento.PremioLiquido || CancelDocumento.AdicionalComiss != documento.AdicionalComiss || (documento.AdicionalComiss && CancelDocumento.PremioAdicional != documento.PremioAdicional) || CancelDocumento.Comissao != documento.Comissao || CancelDocumento.NegocioCorretora != documento.NegocioCorretora || CancelDocumento.Diferenca != documento.Diferenca || CancelDocumento.Iof != documento.Iof || UpdatePremio);
+ bool criarNovasParelas = (int)documento.TipoRecebimento.GetValueOrDefault() != 2 && (((DomainBase)documento).Id == 0L || CancelDocumento.NumeroParcelas != documento.NumeroParcelas || documento.NumeroParcelas != (decimal)Parcelas.Count((Parcela x) => (int)x.SubTipo == 1));
+ bool renovacao = (int)documento.NegocioCorretora.GetValueOrDefault() == 1;
+ if (criarNovasParelas && (int)documento.TipoRecebimento.GetValueOrDefault() == 1)
+ {
+ CriarParcelas(insert);
+ Parcelas.ToList().ForEach(delegate(Parcela x)
+ {
+ x.Documento = documento;
+ errors.AddRange(x.Validate(Recursos.Configuracoes.Any((ConfiguracaoSistema y) => (int)y.Configuracao == 9), Recursos.Configuracoes.Any((ConfiguracaoSistema y) => (int)y.Configuracao == 11), EditandoParcela, Recursos.Configuracoes.Any((ConfiguracaoSistema r) => (int)r.Configuracao == 16)));
+ });
+ if (errors.Count > 0)
+ {
+ Alterar(alterar: true);
+ return errors.Distinct().ToList();
+ }
+ }
+ if (Parcelas == null || Parcelas.Count == 0)
+ {
+ Pagamentos = new ObservableCollection<VendedorParcela>();
+ }
+ if (updateValores && !criarNovasParelas)
+ {
+ AtualizaValores(renovacao);
+ }
+ if ((int)SelectedDocumento.Situacao == 5 && SelectedDocumento.Controle.Documentos != null && SelectedDocumento.Controle.Documentos.Count > 0)
+ {
+ foreach (Documento item in SelectedDocumento.Controle.Documentos.Where((Documento x) => x.Tipo != 0 && !x.Excluido))
+ {
+ if ((int)item.Situacao != 3)
+ {
+ item.SituacaoAnterior = item.Situacao;
+ item.Situacao = (TipoSeguro)5;
+ await Servico.Save(item, updateParcelas: false, criarParcelas: false);
+ }
+ }
+ }
+ if (((DomainBase)SelectedDocumento).Id != 0L && SelectedDocumento.Tipo == 0 && SelectedDocumento.Controle.Documentos != null && SelectedDocumento.Controle.Documentos.Count > 0 && SelectedDocumento.Controle.Documentos.Where((Documento x) => x.Tipo != 0 && !x.Excluido).Any((Documento x) => x.Apolice != SelectedDocumento.Apolice || x.Proposta != SelectedDocumento.Proposta))
+ {
+ foreach (Documento item2 in SelectedDocumento.Controle.Documentos.Where((Documento x) => x.Tipo != 0 && !x.Excluido))
+ {
+ item2.Apolice = SelectedDocumento.Apolice;
+ item2.Proposta = SelectedDocumento.Proposta;
+ await Servico.Save(item2, updateParcelas: false, criarParcelas: false);
+ ToggleSnackBar("NUMERO DA PROPOSTA/APOLICE ATUALIZADOS NO ENDOSSO");
+ }
+ }
+ if (Renovar)
+ {
+ if (!CancelDocumento.NegocioCorretora.HasValue)
+ {
+ CancelDocumento.NegocioCorretora = (NegocioCorretora)((CancelDocumento.Negocio.HasValue && (int)CancelDocumento.Negocio.GetValueOrDefault() == 1) ? 1 : 0);
+ }
+ CancelDocumento.Situacao = (TipoSeguro)5;
+ IEnumerable<Documento> enumerable = CancelDocumento.Controle.Documentos.Where((Documento d) => d.Tipo == 1 && ((int)d.Situacao == 1 || (int)d.Situacao == 2 || (int)d.Situacao == 4));
+ foreach (Documento item3 in enumerable)
+ {
+ item3.Situacao = (TipoSeguro)5;
+ await Servico.Save(item3, updateParcelas: false, criarParcelas: false);
+ }
+ Servico.Sucesso = true;
+ await Servico.Save(CancelDocumento, updateParcelas: false, criarParcelas: false);
+ if (!Servico.Sucesso)
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL ALTERAR O STATUS DO DOCUMENTO RENOVADO, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.");
+ }
+ string text = (string.IsNullOrEmpty(CancelDocumento.Apolice) ? ("A PROPOSTA \"" + CancelDocumento.Proposta + "\"") : ("A APÓLICE \"" + CancelDocumento.Apolice + "\""));
+ RegistrarAcao("RENOVOU " + text, ((DomainBase)CancelDocumento).Id, (TipoTela)2, GerarObs(CancelDocumento));
+ }
+ if (documento.TipoEndosso.HasValue && (int)documento.TipoEndosso.GetValueOrDefault() == 4 && SelectedDocumento.Vigencia2.HasValue && !(await Servico.Prorrogar(((DomainBase)SelectedDocumento.Controle).Id, SelectedDocumento.Vigencia2.Value)))
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL ALTERAR A VIGÊNCIA FINAL DA APÓLICE, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.");
+ }
+ if (documento.TipoEndosso.HasValue && (int)documento.TipoEndosso.GetValueOrDefault() == 3 && !(await Servico.Reabilitar(((DomainBase)SelectedDocumento.Controle).Id)))
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL ALTERAR O STATUS DA APÓLICE, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.");
+ }
+ if (documento.TipoEndosso.HasValue && (int)documento.TipoEndosso.GetValueOrDefault() == 2)
+ {
+ Documento apolice = ((IEnumerable<Documento>)CancelDocumento.Controle.Documentos).FirstOrDefault((Func<Documento, bool>)((Documento x) => x.Tipo == 0));
+ apolice.Situacao = (TipoSeguro)3;
+ IEnumerable<Documento> enumerable2 = CancelDocumento.Controle.Documentos.Where((Documento x) => x.Tipo == 1);
+ foreach (Documento item4 in enumerable2)
+ {
+ item4.Situacao = (TipoSeguro)3;
+ await Servico.Save(item4, updateParcelas: false, criarParcelas: false);
+ }
+ if (!apolice.NegocioCorretora.HasValue)
+ {
+ apolice.NegocioCorretora = (NegocioCorretora)((apolice.Negocio.HasValue && (int)apolice.Negocio.GetValueOrDefault() == 1) ? 1 : 0);
+ }
+ documento.Situacao = (TipoSeguro)3;
+ Servico.Sucesso = true;
+ await Servico.Save(apolice, updateParcelas: false, criarParcelas: false);
+ if (!Servico.Sucesso)
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL ALTERAR O STATUS DO DOCUMENTO CANCELADO, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.");
+ }
+ flag = insert;
+ if (flag)
+ {
+ flag = await ShowMessage("DESEJA BAIXAR AS PARCELAS PENDENTES ABAIXO DESSE DOCUMENTO?", "SIM", "NÃO");
+ }
+ if (flag)
+ {
+ bool baixarParcelas = true;
+ foreach (Documento documento2 in apolice.Controle.Documentos)
+ {
+ baixarParcelas = await Servico.BaixarParcelasCancelamento(documento2, estorno: false) && baixarParcelas;
+ }
+ if (!baixarParcelas)
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL AS PARCELAS DO DOCUMENTO CANCELADO, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.");
+ }
+ }
+ string text2 = "A APÓLICE \"" + apolice.Apolice + "\"";
+ RegistrarAcao("CANCELOU " + text2, ((DomainBase)apolice).Id, (TipoTela)2, GerarObs(apolice));
+ }
+ if (Parcelas != null)
+ {
+ documento.Parcelas = new ObservableCollection<Parcela>(Parcelas.Where((Parcela x) => (int)x.SubTipo == 1));
+ }
+ if (!string.IsNullOrWhiteSpace(Anotacoes))
+ {
+ documento.Observacao = $"{Recursos.Usuario.Nome}, ID: {((DomainBase)Recursos.Usuario).Id}, {Funcoes.GetNetworkTime():g}{Environment.NewLine}{Anotacoes}{Environment.NewLine}{Environment.NewLine}{documento.Observacao}";
+ }
+ Documento documentoSelecionado = DocumentoSelecionado;
+ int num;
+ if (documentoSelecionado == null)
+ {
+ num = 0;
+ }
+ else
+ {
+ _ = documentoSelecionado.Situacao;
+ num = 1;
+ }
+ if (num != 0 && (int)DocumentoSelecionado.Situacao == 7 && DocumentoSelecionado.Situacao != documento.Situacao)
+ {
+ ObservableCollection<Parcela> parcelas = documento.Parcelas;
+ if (parcelas != null && parcelas.Where((Parcela x) => x.DataRecebimento.HasValue).Count() >= 1)
+ {
+ await ShowMessage("O DOCUMENTO TEM PARCELAS BAIXADAS DEVIDO A RECUSA. CASO NECESSÁRIO, REALIZE A EXCLUSÃO DAS BAIXAS MANUALMENTE.");
+ Alterar(alterar: true);
+ return null;
+ }
+ }
+ Servico.Sucesso = true;
+ if (((DomainBase)documento).Id == 0L)
+ {
+ documento.DataCriacao = Funcoes.GetNetworkTime();
+ documento.UsuarioCriacao = Recursos.Usuario;
+ }
+ documento.SituacaoAnterior = documento.Situacao;
+ Documento documentoSalvo = await Servico.Save(documento, updateValores, criarNovasParelas);
+ List<VendedorParcela> list2 = Pagamentos?.Where((VendedorParcela p) => (int)documentoSalvo.TipoRecebimento.GetValueOrDefault() == 1 && p.Repasse != null && ((int)p.Repasse.Base.GetValueOrDefault() == 1 || (int)p.Repasse.Base.GetValueOrDefault() == 4 || (int)p.Repasse.Base.GetValueOrDefault() == 5) && !p.DataPagamento.HasValue).ToList();
+ if (list2 != null && list2.Count > 0)
+ {
+ List<VendedorParcela> atualizarPagamentos = new List<VendedorParcela>();
+ list2?.ForEach(delegate(VendedorParcela p)
+ {
+ //IL_001a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0020: 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_003c: Expected I4, but got Unknown
+ BaseRepasse? @base = p.Repasse.Base;
+ if (@base.HasValue)
+ {
+ BaseRepasse valueOrDefault = @base.GetValueOrDefault();
+ switch (valueOrDefault - 1)
+ {
+ case 0:
+ if (!(p.DataPrePagamento == documentoSalvo.Vigencia1))
+ {
+ p.DataPrePagamento = documentoSalvo.Vigencia1;
+ atualizarPagamentos.Add(p);
+ }
+ break;
+ case 3:
+ if (!(p.DataPrePagamento == documentoSalvo.Emissao))
+ {
+ p.DataPrePagamento = documentoSalvo.Emissao;
+ atualizarPagamentos.Add(p);
+ }
+ break;
+ case 4:
+ if (!(p.DataPrePagamento == documentoSalvo.Remessa))
+ {
+ p.DataPrePagamento = documentoSalvo.Remessa;
+ atualizarPagamentos.Add(p);
+ }
+ break;
+ case 1:
+ case 2:
+ break;
+ }
+ }
+ });
+ if (atualizarPagamentos.Count > 0)
+ {
+ await new ParcelaServico().SaveRange(atualizarPagamentos.ToList());
+ }
+ }
+ if (!Servico.Sucesso)
+ {
+ Alterar(alterar: true);
+ return null;
+ }
+ Documento documentoSelecionado2 = DocumentoSelecionado;
+ int num2;
+ if (documentoSelecionado2 == null)
+ {
+ num2 = 0;
+ }
+ else
+ {
+ _ = documentoSelecionado2.Situacao;
+ num2 = 1;
+ }
+ if (num2 != 0 && (int)DocumentoSelecionado.Situacao == 7 && documento.Situacao != DocumentoSelecionado.Situacao)
+ {
+ Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, "");
+ }
+ SelectedDocumento = await Servico.BuscarApoliceAsync(((DomainBase)documentoSalvo).Id);
+ ((DomainBase)SelectedDocumento).Initialize();
+ await CarregarParcelas(SelectedDocumento);
+ await CarregaRepasse(((DomainBase)SelectedDocumento).Id);
+ SelectedParcela = Parcelas.FirstOrDefault();
+ Documento selectedDocumento = SelectedDocumento;
+ VendedorParcela? obj = ((IEnumerable<VendedorParcela>)Repasses).FirstOrDefault((Func<VendedorParcela, bool>)((VendedorParcela x) => ((DomainBase)x.TipoVendedor).Id == 1));
+ selectedDocumento.VendedorPrincipal = ((obj != null) ? obj.Vendedor : null);
+ bool renovar = Renovar;
+ ConsultaViewModel.DocumentoRenovado = (renovar ? DocumentoRenovado : ConsultaViewModel.DocumentoSelecionado);
+ NovaApolice = false;
+ Renovar = false;
+ if (insert)
+ {
+ AllowEditApolice = true;
+ base.IsEnabledEdit = true;
+ base.IsEnabledEditEndosso = true;
+ if (Invoke)
+ {
+ ConsultaViewModel.DocumentoSelecionado = SelectedDocumento;
+ }
+ if (Invoke)
+ {
+ Gestor.Application.Actions.Actions.RecarregarDocumentos?.Invoke(SelectedDocumento);
+ }
+ if (Invoke)
+ {
+ Gestor.Application.Actions.Actions.UpdateDocumento?.Invoke(SelectedDocumento);
+ }
+ }
+ else if (Invoke)
+ {
+ long id = ((DomainBase)SelectedDocumento).Id;
+ Documento documentoSelecionado3 = ConsultaViewModel.DocumentoSelecionado;
+ if (id != ((documentoSelecionado3 != null) ? new long?(((DomainBase)documentoSelecionado3).Id) : null))
+ {
+ ConsultaViewModel.DocumentoSelecionado = SelectedDocumento;
+ }
+ }
+ if (Parcelas.Count == 0)
+ {
+ AllowEditVendedor = false;
+ }
+ base.AllowEditParcela = true;
+ ToggleSnackBar("DOCUMENTO SALVO COM SUCESSO");
+ Gestor.Application.Actions.Actions.EnableMainMenu?.Invoke(obj: true);
+ Gestor.Application.Actions.Actions.EnableMenu?.Invoke(obj: true);
+ if (renovar && await ShowMessage("DESEJA MANTER OS DADOS DO PERFIL DA APÓLICE ANTERIOR?", "SIM", "NÃO"))
+ {
+ List<Perfil> source = await PerfilServico.BuscarPerfis(((DomainBase)CancelDocumento.Controle).Id);
+ try
+ {
+ foreach (Perfil item5 in source.ToList())
+ {
+ Perfil perfil = new Perfil
+ {
+ Id = 0L,
+ AntiFurto = item5.AntiFurto,
+ CepCirculacao = ValidationHelper.FormataCep(item5.CepCirculacao),
+ CepPernoite = ValidationHelper.FormataCep(item5.CepPernoite),
+ Cliente = item5.Cliente,
+ Controle = new Controle
+ {
+ AssistenciaId = item5.Controle.AssistenciaId,
+ Cliente = item5.Controle.Cliente,
+ Documentos = item5.Controle.Documentos,
+ Id = ((DomainBase)SelectedDocumento.Controle).Id,
+ IdEmpresa = item5.Controle.IdEmpresa,
+ Item = item5.Controle.Item,
+ Produto = item5.Controle.Produto,
+ Ramo = item5.Controle.Ramo,
+ Seguradora = item5.Controle.Seguradora,
+ SeguradoraAnterior = item5.Controle.SeguradoraAnterior
+ },
+ Cpf = item5.Cpf,
+ DistanciaResidenciaTrabalho = item5.DistanciaResidenciaTrabalho,
+ EstadoCivil = item5.EstadoCivil,
+ EstenderCobertura = item5.EstenderCobertura,
+ GaragemEstudo = item5.GaragemEstudo,
+ GaragemResidencia = item5.GaragemResidencia,
+ GaragemTrabalho = item5.GaragemTrabalho,
+ Habilitacao = item5.Habilitacao,
+ Isencao = item5.Isencao,
+ KmMensal = item5.KmMensal,
+ Nascimento = item5.Nascimento,
+ Nome = item5.Nome,
+ Ocupacao = item5.Ocupacao,
+ Relacao = item5.Relacao,
+ SeguroVida = item5.SeguroVida,
+ Sexo = item5.Sexo,
+ TempoHabilitacao = item5.TempoHabilitacao,
+ TipoResidencia = item5.TipoResidencia,
+ UsoDependentes = item5.UsoDependentes,
+ UsoProfissional = item5.UsoProfissional,
+ VeiculoResidencia = item5.VeiculoResidencia
+ };
+ await PerfilServico.Save(perfil);
+ }
+ }
+ catch (Exception ex)
+ {
+ _ = ex;
+ await ShowMessage("NÃO FOI POSSÍVEL MANTER OS DADOS DO PERFIL DA APÓLICE ANTERIOR, POR FAVOR VERIFIQUE APÓS O PROCEDIMENTO SER CONCLUÍDO.");
+ }
+ }
+ CancelDocumento = (Documento)((DomainBase)SelectedDocumento).Clone();
+ EditarParcelasLabel = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? "EDITAR FATURAS" : "EDITAR PARCELAS");
+ base.EnableFields = false;
+ CalculaComissao(SelectedDocumento, Parcelas);
+ string text3 = (insert ? "INCLUIU" : "ALTEROU");
+ string text4 = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("A PROPOSTA \"" + SelectedDocumento.Proposta + "\"") : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("A APÓLICE \"" + SelectedDocumento.Apolice + "\"") : (string.IsNullOrEmpty(SelectedDocumento.Endosso) ? ("A PROPOSTA DE ENDOSSO \"" + SelectedDocumento.PropostaEndosso + "\"") : ("O ENDOSSO \"" + SelectedDocumento.Endosso + "\""))));
+ RegistrarAcao(text3 + " " + text4, ((DomainBase)SelectedDocumento).Id, (TipoTela)2, GerarObs(SelectedDocumento));
+ if ((renovar || (IsEndosso && (int)SelectedDocumento.TipoEndosso.GetValueOrDefault() != 2)) && insert)
+ {
+ Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)3, renovar ? "Renovação" : "Endosso");
+ return null;
+ }
+ if ((int)SelectedDocumento.TipoEndosso.GetValueOrDefault() == 2)
+ {
+ return null;
+ }
+ flag = !Invoke || !insert;
+ if (!flag)
+ {
+ flag = !(await ShowMessage("DESEJA INCLUIR O ITEM AGORA?", "SIM", "NÃO"));
+ }
+ if (flag)
+ {
+ return null;
+ }
+ Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)3, "");
+ return null;
+ }
+
+ private void AtualizaValores(bool renovacao)
+ {
+ Repasses.ForEach(delegate(VendedorParcela x)
+ {
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001d: Invalid comparison between Unknown and I4
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002e: Invalid comparison between Unknown and I4
+ //IL_0094: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009a: Invalid comparison between Unknown and I4
+ if (x.Repasse != null && (int)x.Repasse.Tipo.GetValueOrDefault() != 1)
+ {
+ Parcela parcela = x.Parcela;
+ if ((int)parcela.SubTipo == 1)
+ {
+ parcela.Documento = SelectedDocumento;
+ decimal value = Funcoes.CalculaRepasse(x.Repasse, parcela);
+ decimal value2 = (renovacao ? x.Repasse.ValorRenovacao : x.Repasse.ValorNovo);
+ if (x.CoCorretagem)
+ {
+ value2 = x.Repasse.ValorNovo;
+ }
+ if ((int)x.Repasse.Forma.GetValueOrDefault() == 3)
+ {
+ value /= SelectedDocumento.NumeroParcelas;
+ }
+ if (x.CoCorretagem)
+ {
+ decimal comissao = SelectedDocumento.Comissao;
+ Documento selectedDocumento = SelectedDocumento;
+ decimal valueOrDefault = ((selectedDocumento != null) ? selectedDocumento.ComissaoTotal : null).GetValueOrDefault();
+ value = SelectedDocumento.PremioLiquido * ((valueOrDefault - comissao) / 100m);
+ }
+ x.PorcentagemRepasse = value2;
+ x.ValorRepasse = value;
+ x.ValorTotal = value;
+ }
+ }
+ });
+ decimal valor = ((Parcelas.Count((Parcela x) => (int)x.SubTipo == 1) > 0) ? (SelectedDocumento.PremioTotal / (decimal)Parcelas.Count((Parcela x) => (int)x.SubTipo == 1)) : 0m);
+ Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).ToList().ForEach(delegate(Parcela x)
+ {
+ x.Valor = valor;
+ x.Comissao = SelectedDocumento.Comissao;
+ x.Vendedores = new ObservableCollection<VendedorParcela>(Repasses.Where((VendedorParcela r) => ((DomainBase)r.Parcela).Id == ((DomainBase)x).Id));
+ });
+ }
+
+ private void CriarParcelas(bool insert)
+ {
+ if (Repasses == null)
+ {
+ Repasses = new List<VendedorParcela>();
+ }
+ var list = (from x in Repasses
+ where insert || (int)x.Parcela.SubTipo == 1
+ group x by new { x.Repasse, x.TipoVendedor }).Distinct().ToList();
+ List<VendedorParcela> vendedorParcelas = new List<VendedorParcela>();
+ list.ForEach(x =>
+ {
+ //IL_003e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0044: Invalid comparison between Unknown and I4
+ if (x.Key.Repasse != null)
+ {
+ VendedorParcela val = CalculaRepasse(x.Key.Repasse, x.Key.TipoVendedor);
+ if ((int)val.Repasse.Forma.GetValueOrDefault() == 3)
+ {
+ val.ValorRepasse /= (decimal?)((SelectedDocumento.NumeroParcelas > 0m) ? SelectedDocumento.NumeroParcelas : 1m);
+ }
+ vendedorParcelas.Add(val);
+ }
+ });
+ if (vendedorParcelas.All((VendedorParcela x) => ((DomainBase)x.TipoVendedor).Id != 1))
+ {
+ vendedorParcelas.Add(PropriaCorretora());
+ }
+ Parcelas = new ObservableCollection<Parcela>(CriarParcelas(vendedorParcelas));
+ }
+
+ private List<Parcela> CriarParcelas(List<VendedorParcela> vendedores)
+ {
+ //IL_0068: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0083: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0091: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00bf: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0102: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0110: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0114: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0119: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0135: Unknown result type (might be due to invalid IL or missing references)
+ //IL_013b: Invalid comparison between Unknown and I4
+ //IL_0181: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0191: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01a3: Expected O, but got Unknown
+ //IL_014b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0151: Invalid comparison between Unknown and I4
+ //IL_0161: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0167: Invalid comparison between Unknown and I4
+ List<Parcela> list = new List<Parcela>();
+ if (SelectedDocumento.NumeroParcelas == 0m)
+ {
+ return list;
+ }
+ decimal valor = SelectedDocumento.PremioTotal / SelectedDocumento.NumeroParcelas;
+ if (!SelectedDocumento.FormaPagamento.HasValue)
+ {
+ SelectedDocumento.FormaPagamento = (FormaPagamento)0;
+ }
+ for (int i = 1; (decimal)i <= SelectedDocumento.NumeroParcelas; i++)
+ {
+ Parcela item = new Parcela
+ {
+ IdEmpresa = SelectedDocumento.Controle.IdEmpresa,
+ NumeroParcela = i,
+ Valor = valor,
+ Comissao = SelectedDocumento.Comissao,
+ Vencimento = SelectedDocumento.Vigencia1.AddMonths(i - 1),
+ SubTipo = (SubTipo)1,
+ Vendedores = new ObservableCollection<VendedorParcela>((i == 1) ? vendedores : vendedores.Where(delegate(VendedorParcela x)
+ {
+ //IL_0014: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001a: Invalid comparison between Unknown and I4
+ Repasse repasse = x.Repasse;
+ return repasse != null && (int)repasse.Forma.GetValueOrDefault() == 3;
+ }).ToList()),
+ TipoPagamento = (TipoPagamento)((SelectedDocumento.FormaPagamento == (FormaPagamento?)0) ? 7 : (((int)SelectedDocumento.FormaPagamento.GetValueOrDefault() == 1) ? 3 : (((int)SelectedDocumento.FormaPagamento.GetValueOrDefault() == 2) ? 15 : (((int)SelectedDocumento.FormaPagamento.GetValueOrDefault() == 3 && i == 1) ? 15 : 7)))),
+ DataCriacao = Funcoes.GetNetworkTime(),
+ UsuarioCriacao = ((DomainBase)Recursos.Usuario).Id
+ };
+ list.Add(item);
+ }
+ return list;
+ }
+
+ private List<VendedorParcela> CriarRepasses(VendedorParcela repasse)
+ {
+ //IL_0050: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0056: Invalid comparison between Unknown and I4
+ if (Parcelas == null || Parcelas.Count == 0 || SelectedDocumento == null)
+ {
+ return null;
+ }
+ List<VendedorParcela> repasses = new List<VendedorParcela>();
+ repasse.ValorRepasse = (((int)repasse.Repasse.Forma.GetValueOrDefault() != 3) ? repasse.ValorRepasse : (repasse.ValorRepasse / (decimal?)SelectedDocumento.NumeroParcelas));
+ Parcelas.ToList().ForEach(delegate(Parcela x)
+ {
+ //IL_0013: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0019: Invalid comparison between Unknown and I4
+ //IL_0030: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0036: Expected O, but got Unknown
+ //IL_0049: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004f: Invalid comparison between Unknown and I4
+ if ((int)repasse.Repasse.Forma.GetValueOrDefault() == 3 || x.NumeroParcela <= 1)
+ {
+ VendedorParcela val = (VendedorParcela)((DomainBase)repasse).Clone();
+ if ((int)repasse.Repasse.Forma.GetValueOrDefault() == 3)
+ {
+ val.DataPrePagamento = x.Vencimento;
+ }
+ val.Parcela = x;
+ repasses.Add(val);
+ }
+ });
+ return repasses;
+ }
+
+ private VendedorParcela PropriaCorretora()
+ {
+ //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_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0020: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0048: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008c: Expected O, but got Unknown
+ return new VendedorParcela
+ {
+ Repasse = null,
+ ValorRepasse = default(decimal),
+ Documento = SelectedDocumento,
+ Vendedor = ((IEnumerable<Vendedor>)Recursos.Vendedores).FirstOrDefault((Func<Vendedor, bool>)delegate(Vendedor x)
+ {
+ long idEmpresa = x.IdEmpresa;
+ Documento selectedDocumento = SelectedDocumento;
+ long? obj;
+ if (selectedDocumento == null)
+ {
+ obj = null;
+ }
+ else
+ {
+ Controle controle = selectedDocumento.Controle;
+ obj = ((controle != null) ? new long?(controle.IdEmpresa) : null);
+ }
+ return idEmpresa == (obj ?? ((DomainBase)Recursos.Empresa).Id) && x.Corretora;
+ }),
+ PorcentagemRepasse = default(decimal),
+ TipoVendedor = Recursos.TipoVendedor.First((TipoVendedor x) => ((DomainBase)x).Id == 1)
+ };
+ }
+
+ public VendedorParcela CalculaRepasse(Repasse repasse, TipoVendedor tipoVendedor)
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0014: Invalid comparison between Unknown and I4
+ //IL_0066: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0072: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0096: Unknown result type (might be due to invalid IL or missing references)
+ //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_002c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0047: Expected O, but got Unknown
+ //IL_00b2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00cf: Invalid comparison between Unknown and I4
+ //IL_00d7: Expected O, but got Unknown
+ bool flag = (int)SelectedDocumento.NegocioCorretora.GetValueOrDefault() == 1;
+ if (SelectedParcela == null)
+ {
+ SelectedParcela = new Parcela
+ {
+ SubTipo = (SubTipo)1,
+ IdEmpresa = SelectedDocumento.Controle.IdEmpresa
+ };
+ }
+ SelectedParcela.Documento = SelectedDocumento;
+ decimal value = Funcoes.CalculaRepasse(repasse, SelectedParcela);
+ return new VendedorParcela
+ {
+ Repasse = repasse,
+ ValorRepasse = value,
+ ValorTotal = value,
+ Vendedor = repasse.Vendedor,
+ PorcentagemRepasse = (flag ? repasse.ValorRenovacao : repasse.ValorNovo),
+ TipoVendedor = tipoVendedor,
+ CoCorretagem = (repasse != null && (int)repasse.Tipo.GetValueOrDefault() == 3)
+ };
+ }
+
+ public List<Repasse> GetRepasses(Vendedor vendedor)
+ {
+ if (CoCorretagem)
+ {
+ return RepassesVendedores.Where((Repasse x) => ((DomainBase)x.Vendedor).Id == ((DomainBase)vendedor).Id)?.Where((Repasse x) => (int)x.Tipo.GetValueOrDefault() == 3)?.OrderBy((Repasse x) => x.ValorNovo).ToList();
+ }
+ if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 20))
+ {
+ return (from x in RepassesVendedores.Where((Repasse x) => ((DomainBase)x.Vendedor).Id == ((DomainBase)vendedor).Id)?.Where((Repasse x) => (int)x.Tipo.GetValueOrDefault() != 3)
+ orderby x.ValorNovo
+ select x).ToList();
+ }
+ if (RepassesVendedores.Any((Repasse x) => ((DomainBase)x.Vendedor).Id == ((DomainBase)vendedor).Id && x.Ramo != null && ((DomainBase)x.Ramo).Id == ((DomainBase)SelectedDocumento.Controle.Ramo).Id))
+ {
+ return (from x in RepassesVendedores
+ where ((DomainBase)x.Vendedor).Id == ((DomainBase)vendedor).Id && x.Ramo != null && ((DomainBase)x.Ramo).Id == ((DomainBase)SelectedDocumento.Controle.Ramo).Id
+ orderby x.ValorNovo
+ select x).ToList();
+ }
+ return (from x in RepassesVendedores
+ where ((DomainBase)x.Vendedor).Id == ((DomainBase)vendedor).Id && x.Ramo == null
+ orderby x.ValorNovo
+ select x).ToList();
+ }
+
+ public void FiltrarRepasse(Vendedor vendedor)
+ {
+ //IL_0009: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0013: Expected O, but got Unknown
+ if (SelectedPagamento == null)
+ {
+ SelectedPagamento = new VendedorParcela();
+ }
+ SelectedPagamento.Vendedor = vendedor;
+ RepassesVendedor = GetRepasses(vendedor);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> AdicionarVendedor()
+ {
+ if (SelectedPagamento == null)
+ {
+ return null;
+ }
+ if (SelectedPagamento.Repasse == null)
+ {
+ return new List<KeyValuePair<string, string>>
+ {
+ new KeyValuePair<string, string>("ValorRepasse|VALOR DO REPASSE", "OBRIGATÓRIO")
+ };
+ }
+ if (SelectedDocumento.Comissao == 0m)
+ {
+ return new List<KeyValuePair<string, string>>
+ {
+ new KeyValuePair<string, string>("Comissao|PORCENTAGEM DE COMISSÃO", "OBRIGATÓRIO")
+ };
+ }
+ Loading(isLoading: true);
+ SelectedPagamento.Parcela = SelectedParcela ?? Parcelas?.OrderBy((Parcela x) => x.NumeroParcela).FirstOrDefault();
+ List<VinculoRepasse> vinculo = SelectedPagamento.Repasse.Vinculo?.Where((VinculoRepasse x) => ((DomainBase)x.TipoVendedor).Id == ((DomainBase)SelectedPagamento.TipoVendedor).Id).ToList();
+ List<VendedorParcela> pagamentos = new List<VendedorParcela> { SelectedPagamento };
+ bool renovacao = (SelectedDocumento.NegocioCorretora.HasValue ? ((int)SelectedDocumento.NegocioCorretora.GetValueOrDefault() == 1) : ((int)SelectedDocumento.Situacao == 2 && SelectedDocumento.Negocio.HasValue && (int)SelectedDocumento.Negocio.GetValueOrDefault() == 1));
+ if (vinculo != null && vinculo.Count > 0 && await ShowMessage("DESEJA ADICIONAR OS REPASSES VINCULADOS?", "SIM", "NÃO"))
+ {
+ foreach (VinculoRepasse item2 in vinculo)
+ {
+ decimal value = Funcoes.CalculaRepasse(item2.RepasseVinculo, SelectedPagamento.Parcela, SelectedPagamento.Parcela == null || (int)SelectedPagamento.Parcela.SubTipo == 1);
+ VendedorParcela val = new VendedorParcela
+ {
+ TipoVendedor = item2.TipoVendedorVinculo,
+ Vendedor = item2.RepasseVinculo.Vendedor,
+ Repasse = item2.RepasseVinculo,
+ Documento = SelectedPagamento.Documento,
+ Parcela = SelectedPagamento.Parcela,
+ PorcentagemRepasse = (renovacao ? item2.RepasseVinculo.ValorRenovacao : item2.RepasseVinculo.ValorNovo),
+ ValorRepasse = value,
+ ValorTotal = value
+ };
+ Repasse repasseVinculo = item2.RepasseVinculo;
+ val.CoCorretagem = repasseVinculo != null && (int)repasseVinculo.Tipo.GetValueOrDefault() == 3;
+ VendedorParcela item = val;
+ pagamentos.Add(item);
+ }
+ }
+ List<KeyValuePair<string, string>> errors;
+ foreach (VendedorParcela p in pagamentos)
+ {
+ VendedorParcela pagamento = p;
+ if (((pagamento != null) ? pagamento.Documento : null) == null && ((DomainBase)pagamento.Parcela.Documento).Id == ((DomainBase)SelectedDocumento).Id)
+ {
+ pagamento.Documento = SelectedDocumento;
+ }
+ errors = pagamento.Validate();
+ errors.AddRange(Validate(pagamento));
+ if (errors.Count > 0)
+ {
+ if (SelectedPagamento == null)
+ {
+ SelectedPagamento = pagamento;
+ }
+ Loading(isLoading: false);
+ return errors;
+ }
+ if (pagamento.Repasse != null)
+ {
+ switch (pagamento.Repasse.Base)
+ {
+ case 2L:
+ pagamento.DataPrePagamento = ((pagamento.Parcela.Vencimento == DateTime.MinValue) ? SelectedDocumento.Vigencia1 : pagamento.Parcela.Vencimento);
+ break;
+ case 0L:
+ pagamento.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? SelectedParcela.VigenciaIncial : new DateTime?(SelectedDocumento.Vigencia1));
+ break;
+ case 1L:
+ pagamento.DataPrePagamento = SelectedDocumento.DataCriacao;
+ break;
+ case 3L:
+ pagamento.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? SelectedParcela.Emissao : SelectedDocumento.Emissao);
+ break;
+ case 4L:
+ pagamento.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? SelectedParcela.Emissao : SelectedDocumento.Remessa);
+ break;
+ }
+ }
+ if (Pagamentos == null)
+ {
+ Pagamentos = new ObservableCollection<VendedorParcela>();
+ }
+ if (((DomainBase)SelectedDocumento).Id == 0L)
+ {
+ Repasses.Add(pagamento);
+ Pagamentos.Add(pagamento);
+ SelectedPagamento = new VendedorParcela();
+ continue;
+ }
+ if ((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() != 2 && SelectedDocumento.NumeroParcelas != (decimal)Parcelas.Count((Parcela x) => (int)x.SubTipo == 1))
+ {
+ CriarParcelas(insert: true);
+ Parcelas.ToList().ForEach(delegate(Parcela x)
+ {
+ x.Documento = SelectedDocumento;
+ errors.AddRange(x.Validate(Recursos.Configuracoes.Any((ConfiguracaoSistema y) => (int)y.Configuracao == 9), Recursos.Configuracoes.Any((ConfiguracaoSistema y) => (int)y.Configuracao == 11), EditandoParcela, Recursos.Configuracoes.Any((ConfiguracaoSistema r) => (int)r.Configuracao == 16)));
+ });
+ if (errors.Count > 0)
+ {
+ Loading(isLoading: false);
+ return errors.Distinct().ToList();
+ }
+ ParcelaServico.Sucesso = true;
+ await ParcelaServico.SaveRange(Parcelas.ToList());
+ if (!ParcelaServico.Sucesso)
+ {
+ Repasses = await VendedorServico.BuscaRepasse(((DomainBase)SelectedDocumento).Id);
+ await SelecionaParcela(SelectedParcela ?? Parcelas.FirstOrDefault());
+ SelectedPagamento = null;
+ Loading(isLoading: false);
+ return null;
+ }
+ await CarregarParcelas(SelectedDocumento);
+ SelectedPagamento.Parcela = Parcelas.First();
+ SelectedParcela = Parcelas.First();
+ }
+ VendedorParcela corretora = ((IEnumerable<VendedorParcela>)Repasses).FirstOrDefault((Func<VendedorParcela, bool>)((VendedorParcela x) => (int)x.Parcela.SubTipo == 1 && ((DomainBase)x.TipoVendedor).Id == 1 && x.Vendedor.Corretora));
+ bool excluirCorretora = !pagamento.CoCorretagem && ((DomainBase)pagamento.TipoVendedor).Id == 1 && corretora != null;
+ if (pagamento.CoCorretagem)
+ {
+ await AjusteComissãoCoCorretagem();
+ decimal premioLiquido = SelectedDocumento.PremioLiquido;
+ decimal? num = (SelectedDocumento.ComissaoTotal - (decimal?)SelectedDocumento.Comissao) / (decimal?)100;
+ decimal? num2 = (decimal?)premioLiquido * num;
+ pagamento.PorcentagemRepasse = p.Repasse.ValorNovo;
+ pagamento.ValorRepasse = num2;
+ pagamento.ValorTotal = num2;
+ p.ValorRepasse = num2;
+ p.ValorTotal = num2;
+ }
+ List<VendedorParcela> repasses = CriarRepasses(pagamento);
+ repasses = await Servico.IncluirVendedores(repasses);
+ if (!Servico.Sucesso)
+ {
+ Repasses = await VendedorServico.BuscaRepasse(((DomainBase)SelectedDocumento).Id);
+ await SelecionaParcela(SelectedParcela ?? Parcelas.FirstOrDefault());
+ SelectedPagamento = null;
+ Loading(isLoading: false);
+ return null;
+ }
+ string tipodoc = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("NA PROPOSTA \"" + SelectedDocumento.Proposta + "\"") : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("NA APÓLICE \"" + SelectedDocumento.Apolice + "\"") : (string.IsNullOrEmpty(SelectedDocumento.Endosso) ? ("NA PROPOSTA DE ENDOSSO \"" + SelectedDocumento.PropostaEndosso + "\"") : ("NO ENDOSSO \"" + SelectedDocumento.Endosso + "\""))));
+ repasses?.ForEach(delegate(VendedorParcela x)
+ {
+ string descricao = "VENDEDOR " + x.Vendedor.Nome + " ADICIONADO, " + tipodoc;
+ RegistrarAcao(descricao, ((DomainBase)x).Id, (TipoTela)37, $"{GerarObs(SelectedDocumento)}{Environment.NewLine}VENDEDOR: {x.Vendedor.Nome}{Environment.NewLine}COMISSÃO TOTAL: {x.ValorTotal:C2}");
+ });
+ Repasses.AddRange(repasses);
+ if (excluirCorretora)
+ {
+ await ExcluirVendedor(corretora, incluirCorretora: false);
+ Documento selectedDocumento = SelectedDocumento;
+ VendedorParcela? obj = ((IEnumerable<VendedorParcela>)Repasses).FirstOrDefault((Func<VendedorParcela, bool>)((VendedorParcela x) => ((DomainBase)x.TipoVendedor).Id == 1));
+ selectedDocumento.VendedorPrincipal = ((obj != null) ? obj.Vendedor : null);
+ }
+ ToggleSnackBar("VENDEDOR ADICIONADO COM SUCESSO");
+ Repasses = await VendedorServico.BuscaRepasse(((DomainBase)SelectedDocumento).Id);
+ await SelecionaParcela(SelectedParcela ?? Parcelas.FirstOrDefault());
+ SelectedPagamento = null;
+ }
+ CalculaComissao(SelectedDocumento, Parcelas);
+ Loading(isLoading: false);
+ return null;
+ }
+
+ public List<KeyValuePair<string, string>> Validate(VendedorParcela pagamento)
+ {
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (pagamento == null || SelectedDocumento == null)
+ {
+ list.Add(new KeyValuePair<string, string>("pagamento|PAGAMENTO", "ERRO AO INSERIR VENDEDOR."));
+ return list;
+ }
+ if (pagamento.TipoVendedor == null || pagamento.Vendedor == null)
+ {
+ return list;
+ }
+ if (Repasses == null)
+ {
+ Repasses = new List<VendedorParcela>();
+ }
+ if (Repasses.Count > 0)
+ {
+ if (Repasses.All((VendedorParcela x) => x.Parcela == null))
+ {
+ if (((DomainBase)SelectedDocumento).Id > 0)
+ {
+ ObservableCollection<Parcela> parcelas = Parcelas;
+ if (parcelas != null && parcelas.Count > 0)
+ {
+ goto IL_00da;
+ }
+ }
+ if (SelectedDocumento.Tipo == 1)
+ {
+ goto IL_00da;
+ }
+ }
+ decimal value = Repasses.Where(delegate(VendedorParcela x)
+ {
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Invalid comparison between Unknown and I4
+ //IL_0047: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004d: Invalid comparison between Unknown and I4
+ if ((int)x.Parcela.SubTipo == 1)
+ {
+ decimal? porcentagemRepasse = x.PorcentagemRepasse;
+ decimal num = 100;
+ if (!((porcentagemRepasse.GetValueOrDefault() == num) & porcentagemRepasse.HasValue))
+ {
+ return (int)pagamento.Repasse.Forma.GetValueOrDefault() == 1;
+ }
+ return false;
+ }
+ return false;
+ }).Sum((VendedorParcela x) => x.ValorRepasse.GetValueOrDefault()) + pagamento.ValorRepasse.GetValueOrDefault();
+ decimal value2 = (SelectedDocumento.AdicionalComiss ? (SelectedDocumento.PremioLiquido + SelectedDocumento.PremioAdicional) : SelectedDocumento.PremioLiquido) * SelectedDocumento.Comissao * 0.01m;
+ if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 15) && Math.Abs(value) > Math.Abs(value2) + Tolerancia)
+ {
+ list.Add(new KeyValuePair<string, string>("ValorRepasse|VALOR DO REPASSE", "O TOTAL DE COMISSÃO PAGA NÃO PODE SER SUPERIOR A COMISSÃO PREVISTA PARA RECEBIMENTO."));
+ }
+ if (Repasses.Where((VendedorParcela vendedorParcela) => vendedorParcela.Repasse != null && (int)vendedorParcela.Repasse.Tipo.GetValueOrDefault() != 3).Any((VendedorParcela x) => ((DomainBase)x.TipoVendedor).Id == ((DomainBase)pagamento.TipoVendedor).Id && !x.Vendedor.Corretora && (int)x.Parcela.SubTipo == 1))
+ {
+ list.Add(new KeyValuePair<string, string>("TipoVendedor|TIPO VENDEDOR", "JÁ EXISTE UM VENDEDOR DO TIPO " + pagamento.TipoVendedor.Descricao + " ADICIONADO AO DOCUMENTO."));
+ }
+ if (Repasses.Any((VendedorParcela x) => ((DomainBase)x.Vendedor).Id == ((DomainBase)pagamento.Vendedor).Id && (int)x.Parcela.SubTipo == 1))
+ {
+ list.Add(new KeyValuePair<string, string>("Nome|VENDEDOR", "VENDEDOR " + pagamento.Vendedor.Nome + " JÁ ADICIONADO AO DOCUMENTO."));
+ }
+ }
+ long id = ((DomainBase)pagamento.Vendedor).Id;
+ Repasse repasse = pagamento.Repasse;
+ if (id != ((repasse != null) ? new long?(((DomainBase)repasse.Vendedor).Id) : null))
+ {
+ list.Add(new KeyValuePair<string, string>("ValorRepasse|VALOR DO REPASSE", "PERCENTUAL DE REPASSE DEVE SER SELECIONADO"));
+ }
+ return list;
+ IL_00da:
+ list.Add(new KeyValuePair<string, string>("|PARCELA", "PARCELA DEVE SER SELECIONADA PARA A INCLUSÃO DO VENDEDOR."));
+ return list;
+ }
+
+ public List<KeyValuePair<string, string>> ValidateEspecial(VendedorParcela pagamento)
+ {
+ //IL_0231: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0237: Invalid comparison between Unknown and I4
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (SelectedParcela == null)
+ {
+ list.Add(new KeyValuePair<string, string>("SelectedParcela|PARCELA", "PARCELA DEVE SER SELECIONADA PARA A INCLUSÃO DO VENDEDOR."));
+ return list;
+ }
+ if (Repasses == null)
+ {
+ Repasses = new List<VendedorParcela>();
+ }
+ decimal? num = Repasses.Where((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)pagamento.Parcela).Id).Sum((VendedorParcela x) => x.ValorRepasse) + pagamento.ValorRepasse;
+ decimal valor = SelectedParcela.Valor;
+ decimal value = (SelectedParcela.DataRecebimento.HasValue ? SelectedParcela.ValorComDesconto : (valor * SelectedParcela.Comissao * 0.01m));
+ if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 15) && num.HasValue && Math.Abs(num.Value) > Math.Abs(value) + Tolerancia)
+ {
+ list.Add(new KeyValuePair<string, string>("SelectedParcela|VALOR DO REPASSE", "O TOTAL DE COMISSÃO PAGA NÃO PODE SER SUPERIOR A COMISSÃO PREVISTA PARA RECEBIMENTO."));
+ }
+ if (pagamento.Parcela == null)
+ {
+ if (Repasses.Any((VendedorParcela x) => ((DomainBase)x.TipoVendedor).Id == ((DomainBase)pagamento.TipoVendedor).Id && !x.Vendedor.Corretora))
+ {
+ list.Add(new KeyValuePair<string, string>("TipoVendedor|TIPO VENDEDOR", "JÁ EXISTE UM VENDEDOR DO TIPO " + pagamento.TipoVendedor.Descricao + " ADICIONADO AO DOCUMENTO."));
+ }
+ if (Repasses.Any((VendedorParcela x) => ((DomainBase)x.Vendedor).Id == ((DomainBase)pagamento.Vendedor).Id))
+ {
+ list.Add(new KeyValuePair<string, string>("Nome|VENDEDOR", "VENDEDOR " + pagamento.Vendedor.Nome + " JÁ ADICIONADO AO DOCUMENTO"));
+ }
+ return list;
+ }
+ if ((int)pagamento.Parcela.SubTipo == 1)
+ {
+ if (Repasses.Any(delegate(VendedorParcela x)
+ {
+ long id = ((DomainBase)x.TipoVendedor).Id;
+ TipoVendedor tipoVendedor = pagamento.TipoVendedor;
+ return id == ((tipoVendedor != null) ? new long?(((DomainBase)tipoVendedor).Id) : null) && !x.Vendedor.Corretora && ((DomainBase)x.Parcela).Id == ((DomainBase)pagamento.Parcela).Id;
+ }))
+ {
+ list.Add(new KeyValuePair<string, string>("TipoVendedor|TIPO VENDEDOR", "JÁ EXISTE UM VENDEDOR DO TIPO " + pagamento.TipoVendedor.Descricao + " ADICIONADO AO DOCUMENTO."));
+ }
+ if (Repasses.Any((VendedorParcela x) => ((DomainBase)x.Vendedor).Id == ((DomainBase)pagamento.Vendedor).Id && ((DomainBase)x.Parcela).Id == ((DomainBase)pagamento.Parcela).Id))
+ {
+ list.Add(new KeyValuePair<string, string>("Nome|VENDEDOR", "VENDEDOR " + pagamento.Vendedor.Nome + " JÁ ADICIONADO AO DOCUMENTO"));
+ }
+ return list;
+ }
+ if (Repasses.Any((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)pagamento.Parcela).Id && ((DomainBase)x.TipoVendedor).Id == ((DomainBase)pagamento.TipoVendedor).Id && !x.Vendedor.Corretora))
+ {
+ list.Add(new KeyValuePair<string, string>("TipoVendedor|TIPO VENDEDOR", "JÁ EXISTE UM VENDEDOR DO TIPO " + pagamento.TipoVendedor.Descricao + " ADICIONADO A PARCELA."));
+ }
+ if (Repasses.Any((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)pagamento.Parcela).Id && ((DomainBase)x.Vendedor).Id == ((DomainBase)pagamento.Vendedor).Id))
+ {
+ list.Add(new KeyValuePair<string, string>("Nome|VENDEDOR", "VENDEDOR " + pagamento.Vendedor.Nome + " JÁ ADICIONADO A PARCELA"));
+ }
+ return list;
+ }
+
+ public List<KeyValuePair<string, string>> HabilitarVendedor(int editarParcelaTipo = 0)
+ {
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (editarParcelaTipo == 4)
+ {
+ if (SelectedParcela != null)
+ {
+ Parcela selectedParcela = SelectedParcela;
+ list.AddRange((selectedParcela != null) ? selectedParcela.Validate(Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 9), Recursos.Configuracoes.Any((ConfiguracaoSistema y) => (int)y.Configuracao == 11), EditandoParcela, Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 16)) : null);
+ }
+ }
+ else
+ {
+ list.AddRange(SelectedDocumento.Validate(IsEndosso, Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 11)));
+ }
+ return list;
+ }
+
+ public async Task ExcluirVendedor(VendedorParcela pagamento, bool incluirCorretora = true)
+ {
+ if (IsEndosso && ((DomainBase)SelectedDocumento).Id == 0L)
+ {
+ RemoverVendedor(((DomainBase)pagamento.Vendedor).Id);
+ ToggleSnackBar("VENDEDOR EXCLUÍDO COM SUCESSO");
+ return;
+ }
+ if (!AllowEditApolice && !IsFatura && (int)SelectedParcela.SubTipo == 1)
+ {
+ await ShowMessage("O VENDEDOR " + pagamento.Vendedor.Nome.ToUpper() + " NÃO PODE SER EXCLUÍDO." + Environment.NewLine + "JÁ EXISTEM RECEBIMENTOS OU PAGAMENTOS DE COMISSÃO PARA ESSE DOCUMENTO.");
+ return;
+ }
+ if (((DomainBase)SelectedDocumento).Id > 0 && (IsFatura || (int)SelectedParcela.SubTipo != 1) && ((((DomainBase)SelectedParcela).Id > 0 && SelectedParcela.DataRecebimento.HasValue) || Repasses.Any((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id && x.DataPagamento.HasValue)))
+ {
+ await ShowMessage("O VENDEDOR " + pagamento.Vendedor.Nome.ToUpper() + " NÃO PODE SER EXCLUÍDO." + Environment.NewLine + "JÁ EXISTEM RECEBIMENTOS OU PAGAMENTOS DE COMISSÃO PARA ESSA FATURA.");
+ return;
+ }
+ if (((DomainBase)SelectedDocumento).Id == 0L)
+ {
+ RemoverVendedor(((DomainBase)pagamento.Vendedor).Id);
+ ToggleSnackBar("VENDEDOR EXCLUÍDO COM SUCESSO");
+ return;
+ }
+ List<VendedorParcela> source = (((int)SelectedParcela.SubTipo == 1 && !IsFatura) ? Repasses.Where((VendedorParcela x) => ((DomainBase)x.Vendedor).Id == ((DomainBase)pagamento.Vendedor).Id && x.Parcela.NumeroParcela != 999).ToList() : Repasses.Where((VendedorParcela x) => ((DomainBase)x.Vendedor).Id == ((DomainBase)pagamento.Vendedor).Id && ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id).ToList());
+ List<VendedorParcela> vendedores = source.Distinct().ToList();
+ if (!(await Servico.ExcluirPagamento(vendedores)))
+ {
+ await SelecionaParcela(SelectedParcela ?? Parcelas.FirstOrDefault());
+ return;
+ }
+ if (((DomainBase)SelectedParcela).Id > 0)
+ {
+ string tipodoc = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("NA PROPOSTA \"" + SelectedDocumento.Proposta + "\"") : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("NA APÓLICE \"" + SelectedDocumento.Apolice + "\"") : (string.IsNullOrEmpty(SelectedDocumento.Endosso) ? ("NA PROPOSTA DE ENDOSSO \"" + SelectedDocumento.PropostaEndosso + "\"") : ("NO ENDOSSO \"" + SelectedDocumento.Endosso + "\""))));
+ vendedores.ForEach(delegate(VendedorParcela x)
+ {
+ string descricao = "VENDEDOR " + x.Vendedor.Nome + " EXCLUÍDO, " + tipodoc;
+ RegistrarAcao(descricao, ((DomainBase)x).Id, (TipoTela)37, $"{GerarObs(SelectedDocumento)}{Environment.NewLine}VENDEDOR: {x.Vendedor.Nome}{Environment.NewLine}COMISSÃO TOTAL: {x.ValorTotal:C2}");
+ });
+ }
+ RemoverVendedor(((DomainBase)pagamento.Vendedor).Id);
+ bool flag = ((IsFatura || (int)SelectedParcela.SubTipo != 1) ? Repasses.Any((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id && ((DomainBase)x.TipoVendedor).Id == 1) : Repasses.Any((VendedorParcela x) => (int)x.Parcela.SubTipo == 1 && ((DomainBase)x.TipoVendedor).Id == 1 && !x.CoCorretagem));
+ if (((DomainBase)pagamento.TipoVendedor).Id == 1 && incluirCorretora && !flag)
+ {
+ VendedorParcela val = await IncluirPropriaCorretora();
+ if (val != null)
+ {
+ Repasses.Add(val);
+ Documento selectedDocumento = SelectedDocumento;
+ VendedorParcela? obj = ((IEnumerable<VendedorParcela>)Repasses).FirstOrDefault((Func<VendedorParcela, bool>)((VendedorParcela x) => ((DomainBase)x.TipoVendedor).Id == 1));
+ selectedDocumento.VendedorPrincipal = ((obj != null) ? obj.Vendedor : null);
+ }
+ }
+ if (Repasses != null)
+ {
+ Pagamentos = new ObservableCollection<VendedorParcela>(Repasses.Where((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id).ToList());
+ }
+ ToggleSnackBar("VENDEDOR EXCLUÍDO COM SUCESSO");
+ CalculaComissao(SelectedDocumento, Parcelas);
+ }
+
+ private void RemoverVendedor(long id)
+ {
+ //IL_0027: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002d: Invalid comparison between Unknown and I4
+ //IL_0095: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009b: Invalid comparison between Unknown and I4
+ ((((DomainBase)SelectedDocumento).Id == 0L || ((int)SelectedParcela.SubTipo == 1 && !IsFatura)) ? Repasses.Where((VendedorParcela x) => ((DomainBase)x.Vendedor).Id == id).ToList() : Repasses.Where((VendedorParcela x) => ((DomainBase)x.Vendedor).Id == id && ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id).ToList()).ForEach(delegate(VendedorParcela x)
+ {
+ Repasses.Remove(x);
+ });
+ ((((DomainBase)SelectedDocumento).Id == 0L || ((int)SelectedParcela.SubTipo == 1 && !IsFatura)) ? Pagamentos.Where((VendedorParcela x) => ((DomainBase)x.Vendedor).Id == id).ToList() : Pagamentos.Where(delegate(VendedorParcela x)
+ {
+ if (((DomainBase)x.Vendedor).Id == id)
+ {
+ Parcela parcela = x.Parcela;
+ return ((parcela != null) ? ((DomainBase)parcela).Id : 0) == ((DomainBase)SelectedParcela).Id;
+ }
+ return false;
+ }).ToList()).ForEach(delegate(VendedorParcela x)
+ {
+ Pagamentos.Remove(x);
+ });
+ }
+
+ private async Task<VendedorParcela> IncluirPropriaCorretora()
+ {
+ if (Parcelas.Count == 0)
+ {
+ return null;
+ }
+ VendedorParcela val = PropriaCorretora();
+ Parcela val3 = (val.Parcela = (Parcela)(((int)SelectedParcela.SubTipo == 1 && !IsFatura) ? ((object)((IEnumerable<Parcela>)Parcelas).FirstOrDefault((Func<Parcela, bool>)((Parcela x) => x.NumeroParcela == 1))) : ((object)SelectedParcela)));
+ val.Documento = SelectedDocumento;
+ if (val3 != null && ((DomainBase)val3).Id == 0L)
+ {
+ return val;
+ }
+ return await Servico.IncluirVendedor(val);
+ }
+
+ public async Task CancelarAlteracao()
+ {
+ Acesso = (AcessoApolice)0;
+ if (CancelDocumento != null && ((DomainBase)CancelDocumento).Id != 0L)
+ {
+ await SelecionaDocumento(CancelDocumento);
+ }
+ else
+ {
+ SelectedDocumento = null;
+ }
+ Anotacoes = string.Empty;
+ base.EnableFields = false;
+ Gestor.Application.Actions.Actions.EnableMainMenu?.Invoke(obj: true);
+ Gestor.Application.Actions.Actions.EnableMenu?.Invoke(obj: true);
+ Gestor.Application.Actions.Actions.EnablePesquisarClientes?.Invoke(obj: true);
+ }
+
+ public async Task AlterarVencimento()
+ {
+ if (SelectedParcela == null)
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ bool flag = (int)SelectedParcela.SubTipo == 1 && !IsFatura && (decimal)SelectedParcela.NumeroParcela < SelectedDocumento.NumeroParcelas;
+ if (flag)
+ {
+ flag = await ShowMessage("DESEJA ALTERAR O VENCIMENTO PARA AS PRÓXIMAS PARCELAS?", "SIM", "NÃO");
+ }
+ bool alterarDemais = flag;
+ if ((int)SelectedParcela.SubTipo == 1 && !IsFatura)
+ {
+ DateTime vencimento = SelectedParcela.Vencimento;
+ decimal valor = SelectedDocumento.PremioTotal - Parcelas.Where((Parcela x) => (int)x.SubTipo == 1 && ((DomainBase)x).Id != ((DomainBase)SelectedParcela).Id).Sum((Parcela x) => x.Valor);
+ decimal num = SelectedDocumento.PremioTotal - Parcelas.Where((Parcela x) => (int)x.SubTipo == 1 && ((DomainBase)x).Id < ((DomainBase)SelectedParcela).Id).Sum((Parcela x) => x.Valor);
+ num -= SelectedParcela.Valor;
+ decimal num2 = SelectedDocumento.NumeroParcelas - (decimal)SelectedParcela.NumeroParcela;
+ if (num2 == 0m)
+ {
+ num2 = 1m;
+ }
+ decimal valorDemais = ((num2 > 0m) ? (num / num2) : 0m);
+ if (valorDemais == 0m)
+ {
+ SelectedParcela.Valor = valor;
+ }
+ List<Parcela> parcelas = new List<Parcela> { SelectedParcela };
+ decimal num3 = Math.Abs(valorDemais);
+ decimal? tolerancia = SelectedDocumento.Controle.Seguradora.Tolerancia;
+ if (((num3 > tolerancia.GetValueOrDefault()) & tolerancia.HasValue) && !Parcelas.Any((Parcela x) => (int)x.SubTipo == 1 && x.NumeroParcela > SelectedParcela.NumeroParcela))
+ {
+ SelectedParcela.Valor = valor;
+ }
+ Parcelas.Where((Parcela x) => (int)x.SubTipo == 1 && x.NumeroParcela != SelectedParcela.NumeroParcela).ToList().ForEach(delegate(Parcela x)
+ {
+ if (x.NumeroParcela > SelectedParcela.NumeroParcela)
+ {
+ if (alterarDemais)
+ {
+ vencimento = vencimento.AddMonths(1);
+ if (SelectedDocumento.Vigencia2.HasValue)
+ {
+ DateTime value = vencimento;
+ DateTime? vigencia = SelectedDocumento.Vigencia2;
+ if (!(value < vigencia) && !Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 11))
+ {
+ goto IL_00d0;
+ }
+ }
+ x.Vencimento = vencimento;
+ }
+ goto IL_00d0;
+ }
+ goto IL_012b;
+ IL_012b:
+ parcelas.Add(x);
+ return;
+ IL_00d0:
+ x.Valor = ((valorDemais > 0m) ? valorDemais : x.Valor);
+ x.Comissao = ((x.Comissao == 0m) ? SelectedDocumento.Comissao : x.Comissao);
+ goto IL_012b;
+ });
+ Repasses?.ForEach(delegate(VendedorParcela x)
+ {
+ //IL_00c8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ce: Invalid comparison between Unknown and I4
+ if (!x.CoCorretagem && x.Repasse != null && x.Parcela != null && (((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id || alterarDemais) && !x.DataPagamento.HasValue)
+ {
+ Parcela val = ((IEnumerable<Parcela>)parcelas).FirstOrDefault((Func<Parcela, bool>)((Parcela y) => ((DomainBase)y).Id == ((DomainBase)x.Parcela).Id));
+ x.Parcela = ((val != null) ? val : x.Parcela);
+ if ((int)x.Repasse.Base.GetValueOrDefault() == 3 && val != null)
+ {
+ x.DataPrePagamento = ((x.Parcela.Vencimento == DateTime.MinValue) ? SelectedDocumento.Vigencia1 : x.Parcela.Vencimento);
+ }
+ }
+ });
+ foreach (Parcela x2 in parcelas)
+ {
+ if (x2.NumeroParcela >= SelectedParcela.NumeroParcela)
+ {
+ x2.Documento = SelectedDocumento;
+ if (((DomainBase)x2).Id != ((DomainBase)SelectedParcela).Id)
+ {
+ x2.Valor = valorDemais;
+ }
+ }
+ List<VendedorParcela> auxRepasse = Repasses?.Where((VendedorParcela y) => ((DomainBase)y.Parcela).Id == ((DomainBase)x2).Id).ToList();
+ ObservableCollection<Parcela> source = await ParcelaServico.BuscarParcelasAsync(((DomainBase)SelectedDocumento).Id);
+ if (auxRepasse == null && auxRepasse.Count <= 0)
+ {
+ await ParcelaServico.Save(x2, source.ToList());
+ }
+ else
+ {
+ await ParcelaServico.Save(x2, source.ToList(), auxRepasse);
+ }
+ string text = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("PROPOSTA " + SelectedDocumento.Proposta) : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("APÓLICE " + SelectedDocumento.Apolice) : (string.IsNullOrEmpty(SelectedDocumento.Endosso) ? ("PROPOSTA DE ENDOSSO " + SelectedDocumento.PropostaEndosso) : ("ENDOSSO " + SelectedDocumento.Endosso))));
+ string descricao = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1) ? $"PARCELA {x2.NumeroParcela} ALTERADA, {text}" : ("FATURA " + x2.Fatura + " ALTERADA, " + text));
+ RegistrarAcao(descricao, ((DomainBase)x2).Id, (TipoTela)5, GerarObs(SelectedDocumento));
+ if (!ParcelaServico.Sucesso && x2.NumeroParcela >= SelectedParcela.NumeroParcela)
+ {
+ await CarregarParcelas(SelectedDocumento);
+ Loading(isLoading: false);
+ return;
+ }
+ }
+ }
+ else
+ {
+ SelectedParcela.Documento = SelectedDocumento;
+ Repasses?.ForEach(delegate(VendedorParcela x)
+ {
+ //IL_0057: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005d: Invalid comparison between Unknown and I4
+ //IL_008f: 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_0095: 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_00b1: Expected I4, but got Unknown
+ //IL_0107: Unknown result type (might be due to invalid IL or missing references)
+ //IL_010d: Invalid comparison between Unknown and I4
+ //IL_0163: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0169: Invalid comparison between Unknown and I4
+ //IL_01a3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01a9: Invalid comparison between Unknown and I4
+ if (!x.CoCorretagem && x.Repasse != null && x.Parcela != null && ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id && !x.DataPagamento.HasValue)
+ {
+ if ((int)x.Repasse.Forma.GetValueOrDefault() == 1)
+ {
+ x.DataPrePagamento = SelectedParcela.DataRecebimento;
+ }
+ BaseRepasse? @base = x.Repasse.Base;
+ if (@base.HasValue)
+ {
+ BaseRepasse valueOrDefault = @base.GetValueOrDefault();
+ switch (valueOrDefault - 1)
+ {
+ case 2:
+ x.DataPrePagamento = ((x.Parcela.Vencimento == DateTime.MinValue) ? SelectedDocumento.Vigencia1 : x.Parcela.Vencimento);
+ break;
+ case 0:
+ x.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? SelectedParcela.VigenciaIncial : new DateTime?(SelectedDocumento.Vigencia1));
+ break;
+ case 1:
+ x.DataPrePagamento = x.Parcela.DataCriacao;
+ break;
+ case 3:
+ x.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? x.Parcela.Emissao : SelectedDocumento.Emissao);
+ break;
+ case 4:
+ x.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? x.Parcela.Emissao : SelectedDocumento.Remessa);
+ break;
+ }
+ }
+ }
+ });
+ ObservableCollection<Parcela> source2 = await ParcelaServico.BuscarParcelasAsync(((DomainBase)SelectedDocumento).Id);
+ SelectedParcela = await ParcelaServico.Save(SelectedParcela, source2.ToList(), Repasses?.Where((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id).ToList());
+ if (!ParcelaServico.Sucesso)
+ {
+ await CarregarParcelas(SelectedDocumento);
+ Loading(isLoading: false);
+ return;
+ }
+ }
+ ToggleSnackBar("PARCELAS ALTERADAS COM SUCESSO");
+ await CarregarParcelas(SelectedDocumento);
+ Loading(isLoading: false);
+ }
+
+ public async Task AdicionarParcelaEspecial()
+ {
+ if (SelectedParcela == null || CriandoParcelaEspecial)
+ {
+ return;
+ }
+ CriandoParcelaEspecial = true;
+ if (SelectedPagamento == null || SelectedPagamento.Vendedor.Corretora)
+ {
+ SelectedPagamento = PropriaCorretora();
+ }
+ else
+ {
+ List<KeyValuePair<string, string>> list = await AdicionarVendedorParcelaEspecial();
+ if (list.Count > 0)
+ {
+ _criandoParcelaEspecial = false;
+ await ShowMessage(list, " PROCESSO INTERROMPIDO, PARCELA/FATURA SEM VENDENDEDOR", "OK");
+ return;
+ }
+ }
+ SelectedParcela.Documento = SelectedDocumento;
+ DateTime vencimento = SelectedParcela.Vencimento;
+ DateTime? recebimento = SelectedParcela.DataRecebimento;
+ DateTime? credito = SelectedParcela.DataCredito;
+ DateTime? controle = SelectedParcela.DataControle;
+ int numeroParcela = SelectedParcela.NumeroParcela;
+ DateTime? vigencia1 = SelectedParcela.VigenciaIncial;
+ DateTime? vigencia2 = SelectedParcela.VigenciaFinal;
+ DateTime? emissao = SelectedParcela.Emissao;
+ long result;
+ long fatura = (long.TryParse(string.IsNullOrWhiteSpace(ValidationHelper.OnlyNumber(SelectedParcela.Fatura)) ? "1" : ValidationHelper.OnlyNumber(SelectedParcela.Fatura), out result) ? result : 1);
+ if (QuantidadeFaturas == 0 || !IsFatura)
+ {
+ QuantidadeFaturas = 1;
+ }
+ if (QuantidadeFaturas > 12)
+ {
+ CriandoParcelaEspecial = false;
+ await ShowMessage("NÃO É POSSIVEL REPLICAR MAIS QUE 12 VEZES A MESMA FATURA. PROCESSO CANCELADO");
+ return;
+ }
+ for (int i = 0; i < QuantidadeFaturas; i++)
+ {
+ SelectedParcela.Vencimento = vencimento.AddMonths(i);
+ SelectedParcela.VigenciaIncial = vigencia1?.AddMonths(i);
+ SelectedParcela.VigenciaFinal = vigencia2?.AddMonths(i);
+ SelectedParcela.Emissao = emissao?.AddMonths(i);
+ SelectedParcela.DataRecebimento = recebimento?.AddMonths(i);
+ SelectedParcela.DataCredito = credito?.AddMonths(i);
+ SelectedParcela.DataControle = controle?.AddMonths(i);
+ SelectedParcela.NumeroParcela = numeroParcela + i;
+ if (i > 0)
+ {
+ fatura++;
+ SelectedParcela.Fatura = $"{fatura}";
+ SelectedParcela.DataQuitacao = null;
+ }
+ Repasses?.ForEach(delegate(VendedorParcela x)
+ {
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001d: Invalid comparison between Unknown and I4
+ //IL_0056: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005c: 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_0078: Expected I4, but got Unknown
+ //IL_00c3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c9: Invalid comparison between Unknown and I4
+ //IL_010f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0115: Invalid comparison between Unknown and I4
+ //IL_0144: Unknown result type (might be due to invalid IL or missing references)
+ //IL_014a: Invalid comparison between Unknown and I4
+ if (x.Repasse != null)
+ {
+ if ((int)x.Repasse.Forma.GetValueOrDefault() == 1)
+ {
+ x.DataPrePagamento = SelectedParcela.DataRecebimento;
+ }
+ x.Parcela = SelectedParcela;
+ BaseRepasse? @base = x.Repasse.Base;
+ if (@base.HasValue)
+ {
+ BaseRepasse valueOrDefault = @base.GetValueOrDefault();
+ switch (valueOrDefault - 1)
+ {
+ case 2:
+ x.DataPrePagamento = ((x.Parcela.Vencimento == DateTime.MinValue) ? SelectedDocumento.Vigencia1 : x.Parcela.Vencimento);
+ break;
+ case 0:
+ x.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? x.Parcela.VigenciaIncial : new DateTime?(SelectedDocumento.Vigencia1));
+ break;
+ case 1:
+ x.DataPrePagamento = x.Parcela.DataCriacao;
+ break;
+ case 3:
+ x.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? x.Parcela.Emissao : SelectedDocumento.Emissao);
+ break;
+ case 4:
+ x.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? x.Parcela.Emissao : SelectedDocumento.Remessa);
+ break;
+ }
+ }
+ }
+ });
+ if (Repasses == null)
+ {
+ Repasses = new List<VendedorParcela> { PropriaCorretora() };
+ }
+ if (Repasses.All((VendedorParcela x) => ((DomainBase)x.TipoVendedor).Id != 1))
+ {
+ Repasses.Add(PropriaCorretora());
+ }
+ Parcela selectedParcela = await ParcelaServico.Save(SelectedParcela, Parcelas.ToList(), Repasses);
+ if (i == QuantidadeFaturas - 1)
+ {
+ SelectedParcela = selectedParcela;
+ }
+ }
+ QuantidadeFaturas = 0;
+ string text = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("NA PROPOSTA \"" + SelectedDocumento.Proposta + "\"") : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("NA APÓLICE \"" + SelectedDocumento.Apolice + "\"") : (string.IsNullOrEmpty(SelectedDocumento.Endosso) ? ("NA PROPOSTA DE ENDOSSO \"" + SelectedDocumento.PropostaEndosso + "\"") : ("NO ENDOSSO \"" + SelectedDocumento.Endosso + "\""))));
+ string descricao = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1) ? ("PARCELA ESPECIAL ADICIONADA, " + text) : ("FATURA " + SelectedParcela.Fatura + " ADICIONADA, " + text));
+ RegistrarAcao(descricao, ((DomainBase)SelectedParcela).Id, (TipoTela)5, GerarObs(SelectedDocumento));
+ if (ParcelaServico.Sucesso)
+ {
+ ToggleSnackBar(((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1) ? "PARCELA ESPECIAL ADICIONADA COM SUCESSO" : "FATURA ADICIONADA COM SUCESSO");
+ }
+ await CarregarParcelas(SelectedDocumento);
+ await CarregaRepasse(((DomainBase)SelectedDocumento).Id);
+ await SelecionaParcela(SelectedParcela ?? Parcelas.FirstOrDefault());
+ CalculaComissao(SelectedDocumento, Parcelas);
+ BaixarParcelas = false;
+ CriandoParcelaEspecial = false;
+ }
+
+ public void EditarParcelaEspecial()
+ {
+ AllowEditVendedor = true;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> AdicionarVendedorParcelaEspecial()
+ {
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (SelectedPagamento == null)
+ {
+ list.Add(new KeyValuePair<string, string>("SelectedPagamento|PAGAMENTO", "ERRO AO INCLUIR VENDEDOR."));
+ return list;
+ }
+ if (SelectedPagamento.Repasse == null)
+ {
+ list.Add(new KeyValuePair<string, string>("Repasse|REPASSE", "ERRO AO INCLUIR VENDEDOR."));
+ return list;
+ }
+ SelectedPagamento.Parcela = SelectedParcela;
+ if ((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2 && (int)SelectedPagamento.Repasse.Forma.GetValueOrDefault() == 3)
+ {
+ ShowMessage("NÃO É POSSÍVEL ADICIONAR UM VENDEDOR COM A FORMA DE PAGAMENTO À PRAZO EM DOCUMENTOS DO TIPO FATURA");
+ return null;
+ }
+ Repasse repasse = SelectedPagamento.Repasse;
+ List<VinculoRepasse> vinculo = ((repasse == null) ? null : repasse.Vinculo?.Where((VinculoRepasse x) => ((DomainBase)x.TipoVendedor).Id == ((DomainBase)SelectedPagamento.TipoVendedor).Id).ToList());
+ List<VendedorParcela> pagamentos = new List<VendedorParcela> { SelectedPagamento };
+ bool renovacao = (SelectedDocumento.NegocioCorretora.HasValue ? ((int)SelectedDocumento.NegocioCorretora.GetValueOrDefault() == 1) : ((int)SelectedDocumento.Situacao == 2 && SelectedDocumento.Negocio.HasValue && (int)SelectedDocumento.Negocio.GetValueOrDefault() == 1));
+ bool flag = vinculo != null && vinculo.Count > 0;
+ if (flag)
+ {
+ flag = await ShowMessage("DESEJA ADICIONAR OS REPASSES VINCULADOS?", "SIM", "NÃO");
+ }
+ if (flag)
+ {
+ foreach (VinculoRepasse item2 in vinculo)
+ {
+ decimal value = Funcoes.CalculaRepasse(item2.RepasseVinculo, SelectedPagamento.Parcela, SelectedPagamento.Parcela == null || (int)SelectedPagamento.Parcela.SubTipo == 1);
+ VendedorParcela item = new VendedorParcela
+ {
+ TipoVendedor = item2.TipoVendedorVinculo,
+ Vendedor = item2.RepasseVinculo.Vendedor,
+ Repasse = item2.RepasseVinculo,
+ Documento = SelectedPagamento.Documento,
+ Parcela = SelectedPagamento.Parcela,
+ PorcentagemRepasse = (renovacao ? item2.RepasseVinculo.ValorRenovacao : item2.RepasseVinculo.ValorNovo),
+ ValorRepasse = value,
+ ValorTotal = value
+ };
+ pagamentos.Add(item);
+ }
+ }
+ foreach (VendedorParcela item3 in pagamentos)
+ {
+ VendedorParcela val = item3;
+ list = val.Validate();
+ list.AddRange(ValidateEspecial(val));
+ if (list.Count > 0)
+ {
+ if (SelectedPagamento == null)
+ {
+ SelectedPagamento = val;
+ }
+ return list;
+ }
+ if (val.Repasse != null)
+ {
+ switch (val.Repasse.Base)
+ {
+ case 2L:
+ val.DataPrePagamento = ((val.Parcela.Vencimento == DateTime.MinValue) ? SelectedDocumento.Vigencia1 : val.Parcela.Vencimento);
+ break;
+ case 0L:
+ val.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? val.Parcela.VigenciaIncial : new DateTime?(SelectedDocumento.Vigencia1));
+ break;
+ case 1L:
+ val.DataPrePagamento = val.Parcela.DataCriacao;
+ break;
+ case 3L:
+ val.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? val.Parcela.Emissao : SelectedDocumento.Emissao);
+ break;
+ case 4L:
+ val.DataPrePagamento = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? val.Parcela.Emissao : SelectedDocumento.Remessa);
+ break;
+ }
+ }
+ if (Pagamentos == null)
+ {
+ Pagamentos = new ObservableCollection<VendedorParcela>();
+ }
+ VendedorParcela corretora = ((IEnumerable<VendedorParcela>)Repasses).FirstOrDefault((Func<VendedorParcela, bool>)((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id && ((DomainBase)x.TipoVendedor).Id == 1 && x.Vendedor.Corretora));
+ bool excluirCorretora = ((DomainBase)val.TipoVendedor).Id == 1 && corretora != null;
+ if (((DomainBase)SelectedParcela).Id == 0L)
+ {
+ Repasses.Add(val);
+ Pagamentos.Add(val);
+ SelectedPagamento = null;
+ if ((IsFatura || (int)SelectedParcela.SubTipo != 1) && excluirCorretora)
+ {
+ await ExcluirVendedor(corretora, incluirCorretora: false);
+ }
+ continue;
+ }
+ if ((int)val.Repasse.Forma.GetValueOrDefault() == 1)
+ {
+ val.DataPrePagamento = SelectedParcela.DataRecebimento;
+ }
+ List<VendedorParcela> repasses = new List<VendedorParcela> { val };
+ repasses = await Servico.IncluirVendedores(repasses);
+ string tipodoc = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("NA PROPOSTA \"" + SelectedDocumento.Proposta + "\"") : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("NA APÓLICE \"" + SelectedDocumento.Apolice + "\"") : (string.IsNullOrEmpty(SelectedDocumento.Endosso) ? ("NA PROPOSTA DE ENDOSSO \"" + SelectedDocumento.PropostaEndosso + "\"") : ("NO ENDOSSO \"" + SelectedDocumento.Endosso + "\""))));
+ repasses?.ForEach(delegate(VendedorParcela x)
+ {
+ string descricao = "VENDEDOR " + x.Vendedor.Nome + " ADICIONADO A PARCELA ESPECIAL, " + tipodoc;
+ RegistrarAcao(descricao, ((DomainBase)x).Id, (TipoTela)37, $"{GerarObs(SelectedDocumento)}{Environment.NewLine}VENDEDOR: {x.Vendedor.Nome}{Environment.NewLine}COMISSÃO TOTAL: {x.ValorTotal:C2}");
+ });
+ Repasses.AddRange(repasses);
+ if (excluirCorretora)
+ {
+ await ExcluirVendedor(corretora, incluirCorretora: false);
+ }
+ Repasses = await VendedorServico.BuscaRepasse(((DomainBase)SelectedDocumento).Id);
+ await SelecionaParcela(SelectedParcela ?? Parcelas.FirstOrDefault());
+ SelectedPagamento = null;
+ }
+ ToggleSnackBar("VENDEDOR ADICIONADO COM SUCESSO");
+ return null;
+ }
+
+ internal async Task BaixarComissao()
+ {
+ if (SelectedParcela == null)
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ int num;
+ if (IsFatura)
+ {
+ Parcela? obj = ((IEnumerable<Parcela>)Parcelas.OrderBy((Parcela x) => x.NumeroParcela)).LastOrDefault((Func<Parcela, bool>)((Parcela x) => (int)x.SubTipo == 1));
+ num = ((((obj != null) ? new long?(((DomainBase)obj).Id) : null) == ((DomainBase)SelectedParcela).Id) ? 1 : 0);
+ }
+ else
+ {
+ num = 0;
+ }
+ bool ultimafatura = (byte)num != 0;
+ SelectedParcela.Documento = SelectedDocumento;
+ Parcela selectedParcela = SelectedParcela;
+ List<Parcela> parcelas = Parcelas.ToList();
+ List<VendedorParcela> repasses = Repasses;
+ Documento selectedDocumento = SelectedDocumento;
+ decimal? obj2;
+ if (selectedDocumento == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Controle controle = selectedDocumento.Controle;
+ if (controle == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Seguradora seguradora = controle.Seguradora;
+ obj2 = ((seguradora != null) ? seguradora.Tolerancia : null);
+ }
+ }
+ SelectedParcela = await Funcoes.BaixarComissao(selectedParcela, parcelas, repasses, obj2 ?? Tolerancia);
+ Documento selectedDocumento2 = SelectedDocumento;
+ string text;
+ if (selectedDocumento2 == null || selectedDocumento2.Tipo != 0 || !string.IsNullOrEmpty(SelectedDocumento.Apolice))
+ {
+ Documento selectedDocumento3 = SelectedDocumento;
+ if (selectedDocumento3 == null || selectedDocumento3.Tipo != 0 || string.IsNullOrEmpty(SelectedDocumento.Apolice))
+ {
+ Documento selectedDocumento4 = SelectedDocumento;
+ if (!string.IsNullOrEmpty((selectedDocumento4 != null) ? selectedDocumento4.Endosso : null))
+ {
+ text = "ENDOSSO " + SelectedDocumento.Endosso;
+ }
+ else
+ {
+ Documento selectedDocumento5 = SelectedDocumento;
+ text = "PROPOSTA DE ENDOSSO " + ((selectedDocumento5 != null) ? selectedDocumento5.PropostaEndosso : null);
+ }
+ }
+ else
+ {
+ text = "APÓLICE " + SelectedDocumento.Apolice;
+ }
+ }
+ else
+ {
+ text = "PROPOSTA " + SelectedDocumento.Proposta;
+ }
+ string text2 = text;
+ Documento selectedDocumento6 = SelectedDocumento;
+ string descricao = ((selectedDocumento6 != null && (int)selectedDocumento6.TipoRecebimento.GetValueOrDefault() == 1) ? $"PARCELA {SelectedParcela.NumeroParcela} BAIXADA, {text2}" : ("FATURA " + SelectedParcela.Fatura + " BAIXADA, " + text2));
+ RegistrarAcao(descricao, ((DomainBase)SelectedParcela).Id, (TipoTela)5, GerarObs(SelectedDocumento));
+ if (SelectedDocumento != null)
+ {
+ await CarregarParcelas(SelectedDocumento);
+ await CarregaRepasse(((DomainBase)SelectedDocumento).Id);
+ CalculaComissao(SelectedDocumento, Parcelas);
+ }
+ await SelecionaParcela(SelectedParcela ?? Parcelas.FirstOrDefault());
+ BaixarParcelas = false;
+ AllowEditApolice = Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).All((Parcela x) => !x.DataRecebimento.HasValue) && Repasses.Where((VendedorParcela x) => (int)x.Parcela.SubTipo == 1).All((VendedorParcela x) => !x.DataPagamento.HasValue);
+ Loading(isLoading: false);
+ bool flag = ultimafatura;
+ if (flag)
+ {
+ flag = await ShowMessage("DESEJA INCLUIR A PRÓXIMA FATURA?", "SIM", "NÃO");
+ }
+ if (flag)
+ {
+ UltimaFatura = true;
+ }
+ ToggleSnackBar("PARCELA BAIXADA COM SUCESSO");
+ }
+
+ internal async Task ExcluirBaixa()
+ {
+ if (SelectedParcela != null && await ShowMessage("DESEJA REALMENTE EXCLUIR A BAIXA DA PARCELA SELECIONADA?" + Environment.NewLine + "ESSE PROCEDIMENTO É IRREVERSÍVEL.", "SIM", "NÃO"))
+ {
+ Loading(isLoading: true);
+ SelectedParcela.Documento = SelectedDocumento;
+ SelectedParcela = await Funcoes.ExcluirBaixa(SelectedParcela, Repasses, Parcelas.ToList());
+ string text = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("PROPOSTA " + SelectedDocumento.Proposta) : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("APÓLICE " + SelectedDocumento.Apolice) : (string.IsNullOrEmpty(SelectedDocumento.Endosso) ? ("PROPOSTA DE ENDOSSO " + SelectedDocumento.PropostaEndosso) : ("ENDOSSO " + SelectedDocumento.Endosso))));
+ string descricao = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1) ? $"BAIXA DA PARCELA {SelectedParcela.NumeroParcela} EXCLUÍDA, {text}" : ("BAIXA DA FATURA " + SelectedParcela.Fatura + " EXCLUÍDA, " + text));
+ RegistrarAcao(descricao, ((DomainBase)SelectedParcela).Id, (TipoTela)5, GerarObs(SelectedDocumento));
+ await CarregarParcelas(SelectedDocumento);
+ await CarregaRepasse(((DomainBase)SelectedDocumento).Id);
+ CalculaComissao(SelectedDocumento, Parcelas);
+ await SelecionaParcela(SelectedParcela ?? Parcelas.FirstOrDefault());
+ BaixarParcelas = false;
+ AllowEditApolice = Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).All((Parcela x) => !x.DataRecebimento.HasValue) && Repasses.Where((VendedorParcela x) => (int)x.Parcela.SubTipo == 1).All((VendedorParcela x) => !x.DataPagamento.HasValue);
+ Loading(isLoading: false);
+ ToggleSnackBar("BAIXA EXCLUÍDA COM SUCESSO");
+ }
+ }
+
+ public async Task ExcluirParcela()
+ {
+ if (SelectedParcela == null || ((int)SelectedParcela.SubTipo == 1 && (int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1))
+ {
+ return;
+ }
+ if ((int)SelectedParcela.SubTipo == 1)
+ {
+ Parcela val = Parcelas.OrderBy((Parcela x) => x.NumeroParcela).Last((Parcela x) => (int)x.SubTipo == 1);
+ if (((DomainBase)SelectedParcela).Id != ((DomainBase)val).Id)
+ {
+ await ShowMessage("A FATURA NÃO PODE SER EXCLUÍDA POIS HÁ FATURAS CADASTRADAS ACIMA DA SELECIONADA.");
+ return;
+ }
+ }
+ if (await ShowMessage("DESEJA REALMENTE EXCLUIR A PARCELA SELECIONADA?" + Environment.NewLine + "ESSE PROCEDIMENTO É IRREVERSÍVEL.", "SIM", "NÃO"))
+ {
+ Loading(isLoading: true);
+ if (await ParcelaServico.Delete(SelectedParcela, Parcelas.ToList()))
+ {
+ ToggleSnackBar(((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1) ? "PARCELA EXCLUÍDA COM SUCESSO" : "FATURA EXCLUÍDA COM SUCESSO");
+ string text = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("PROPOSTA " + SelectedDocumento.Proposta) : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("APÓLICE " + SelectedDocumento.Apolice) : (string.IsNullOrEmpty(SelectedDocumento.Endosso) ? ("PROPOSTA DE ENDOSSO " + SelectedDocumento.PropostaEndosso) : ("ENDOSSO " + SelectedDocumento.Endosso))));
+ string descricao = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1) ? $"PARCELA {SelectedParcela.NumeroParcela} EXCLUÍDA, {text}" : ("FATURA " + SelectedParcela.Fatura + " EXCLUÍDA, " + text));
+ RegistrarAcao(descricao, ((DomainBase)SelectedParcela).Id, (TipoTela)5, GerarObs(SelectedDocumento));
+ }
+ await CarregarParcelas(SelectedDocumento);
+ await CarregaRepasse(((DomainBase)SelectedDocumento).Id);
+ await SelecionaParcela(Parcelas.FirstOrDefault());
+ BaixarParcelas = false;
+ if (Parcelas == null || Parcelas.Count == 0)
+ {
+ VisibilityExcluirParcela = (Visibility)2;
+ VisibilityReplicarFatura = (Visibility)2;
+ BaixarParcelaVisibility = (Visibility)2;
+ }
+ Loading(isLoading: false);
+ AllowEditVendedor = Parcelas.Any();
+ }
+ }
+
+ public async Task ExcluirApolice()
+ {
+ if (SelectedDocumento == null)
+ {
+ return;
+ }
+ if (!AllowEditApolice || Parcelas.Any((Parcela x) => x.DataRecebimento.HasValue) || Repasses.Any((VendedorParcela x) => x.DataPagamento.HasValue))
+ {
+ await ShowMessage("DOCUMENTO NÃO PODE SER EXCLUÍDO POIS POSSUI BAIXAS DE COMISSÃO OU PAGAMENTO DE VENDEDORES.");
+ return;
+ }
+ if (SelectedDocumento.Tipo > 0 && SelectedDocumento.Sinistro)
+ {
+ await ShowMessage("DOCUMENTO NÃO PODE SER EXCLUÍDO POIS POSSUI SINISTROS PARA UM OU MAIS DE SEUS ITENS.");
+ return;
+ }
+ Documento documentoSelecionado = SelectedDocumento;
+ string documento = ((documentoSelecionado.Tipo == 0 && string.IsNullOrEmpty(documentoSelecionado.Apolice)) ? "A PROPOSTA SELECIONADA" : ((documentoSelecionado.Tipo == 0 && !string.IsNullOrEmpty(documentoSelecionado.Apolice)) ? "A APÓLICE SELECIONADA" : "O ENDOSSO SELECIONADO"));
+ int ordem = SelectedDocumento.Ordem;
+ Documento? obj = ((IEnumerable<Documento>)SelectedDocumento.Controle.Documentos.OrderByDescending((Documento x) => x.Ordem)).FirstOrDefault((Func<Documento, bool>)((Documento x) => (!x.Excluido && (int)x.Situacao != 7) || ((DomainBase)x).Id == ((DomainBase)SelectedDocumento).Id));
+ if (ordem != ((obj != null) ? obj.Ordem : SelectedDocumento.Ordem))
+ {
+ await ShowMessage(documento + " NÃO PODE SER EXCLUÍDO(A) POIS POSSUEM DOCUMENTOS ATIVOS ACIMA.");
+ }
+ else
+ {
+ if (!(await ShowMessage("DESEJA REALMENTE EXCLUIR " + documento + "?" + Environment.NewLine + "ESSE PROCEDIMENTO É IRREVERSÍVEL.", "SIM", "NÃO")))
+ {
+ return;
+ }
+ bool flag = documentoSelecionado.TipoEndosso.HasValue;
+ if (flag)
+ {
+ flag = await ShowMessage("DESEJA DESFAZER AS ALTERAÇOES NOS ITENS VINCULADOS A ESSE ENDOSSO ?", "SIM", "NÃO");
+ }
+ if (flag)
+ {
+ Documento? obj2 = ((IEnumerable<Documento>)SelectedDocumento.Controle.Documentos.OrderByDescending((Documento x) => x.Ordem)).FirstOrDefault((Func<Documento, bool>)((Documento x) => !x.Excluido && (int)x.Situacao != 7 && x.Ordem > SelectedDocumento.Ordem));
+ if (((obj2 != null) ? new int?(obj2.Ordem) : null) > SelectedDocumento.Ordem)
+ {
+ await ShowMessage("NÃO É POSSIVEL DESFAZER AS ALTERAÇÕES, POIS " + documento + " POSSUE ENDOSSOS ATIVOS ACIMA.");
+ return;
+ }
+ await DesfazerAlteracoes();
+ }
+ string descricao = ((documentoSelecionado.Tipo == 0 && string.IsNullOrEmpty(documentoSelecionado.Apolice)) ? ("EXCLUIU PROPOSTA " + documentoSelecionado.Proposta) : ((documentoSelecionado.Tipo == 0 && !string.IsNullOrEmpty(documentoSelecionado.Apolice)) ? ("EXCLUIU APÓLICE " + documentoSelecionado.Apolice) : (string.IsNullOrEmpty(documentoSelecionado.Endosso) ? ("EXCLUIU PROPOSTA DE ENDOSSO " + documentoSelecionado.PropostaEndosso) : ("EXCLUIU ENDOSSO " + documentoSelecionado.Endosso))));
+ RegistrarAcao(descricao, ((DomainBase)SelectedDocumento).Id, (TipoTela)2, GerarObs(documentoSelecionado));
+ Loading(isLoading: true);
+ string label = ((documentoSelecionado.Tipo == 0 && string.IsNullOrEmpty(documentoSelecionado.Apolice)) ? "PROPOSTA EXCLUÍDA" : ((documentoSelecionado.Tipo == 0 && !string.IsNullOrEmpty(documentoSelecionado.Apolice)) ? "APÓLICE EXCLUÍDA" : "ENDOSSO EXCLUÍDO"));
+ documentoSelecionado.Excluido = true;
+ Servico.Sucesso = true;
+ await Servico.ExcluirCritica(((DomainBase)documentoSelecionado).Id);
+ if (!Servico.Sucesso)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ TarefaServico tarefaServico = TarefaServico;
+ tarefaServico.Sucesso = await TarefaServico.ExcluirTarefasDocumento(((DomainBase)documentoSelecionado).Id);
+ if (!TarefaServico.Sucesso)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ Servico.Sucesso = true;
+ if (documentoSelecionado.TipoEndosso.HasValue && (int)documentoSelecionado.TipoEndosso.GetValueOrDefault() == 2)
+ {
+ Documento apolice = ((IEnumerable<Documento>)CancelDocumento.Controle.Documentos).FirstOrDefault((Func<Documento, bool>)((Documento x) => x.Tipo == 0 && !x.Excluido));
+ List<Documento> endossos = CancelDocumento.Controle.Documentos.Where((Documento x) => x.Tipo == 1 && !x.Excluido).ToList();
+ if (apolice != null)
+ {
+ apolice.Situacao = (TipoSeguro)((apolice.SituacaoAnterior.HasValue && (int)apolice.SituacaoAnterior.GetValueOrDefault() != 3) ? ((int)apolice.SituacaoAnterior.Value) : (((int)apolice.NegocioCorretora.GetValueOrDefault() != 1) ? 1 : 2));
+ await Servico.Save(apolice, updateParcelas: false, criarParcelas: false);
+ foreach (Documento item in endossos)
+ {
+ item.Situacao = apolice.Situacao;
+ await Servico.Save(item, updateParcelas: false, criarParcelas: false);
+ }
+ }
+ }
+ await Servico.Excluir(documentoSelecionado);
+ if (!Servico.Sucesso)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ if (documentoSelecionado.Tipo > 0)
+ {
+ await Funcoes.OrganizarDocumentos(((DomainBase)documentoSelecionado.Controle).Id);
+ await Funcoes.InativarItens(((DomainBase)documentoSelecionado).Id, ((DomainBase)documentoSelecionado.Controle.Ramo).Id);
+ }
+ if (Invoke)
+ {
+ ConsultaViewModel.DocumentoSelecionado = null;
+ Gestor.Application.Actions.Actions.RecarregarDocumentos?.Invoke(null);
+ }
+ Loading(isLoading: false);
+ ToggleSnackBar(label + " COM SUCESSO");
+ if (Invoke)
+ {
+ Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, "");
+ }
+ }
+ }
+
+ private async Task DesfazerAlteracoes()
+ {
+ ObservableCollection<Item> itensApoMae = await new ItemServico().BuscarItems(((DomainBase)((IEnumerable<Documento>)SelectedDocumento.Controle.Documentos).FirstOrDefault((Func<Documento, bool>)((Documento x) => !x.Excluido && (int)x.Situacao != 7 && x.Ordem == 0))).Id, (StatusItem)2);
+ ObservableCollection<Item> itensDocumento = await new ItemServico().BuscarItems(((DomainBase)SelectedDocumento).Id, (StatusItem)2);
+ List<Item> list = itensApoMae.Where((Item x) => x.IdDocumentoCancelado == ((DomainBase)SelectedDocumento).Id).ToList();
+ list.AddRange(itensApoMae.Where(delegate(Item x)
+ {
+ if (x.Substituido.HasValue)
+ {
+ long? substituido = x.Substituido;
+ Item? obj = ((IEnumerable<Item>)itensDocumento).FirstOrDefault((Func<Item, bool>)((Item d) => ((DomainBase)d).Id == x.Substituido));
+ return substituido == ((obj != null) ? new long?(((DomainBase)obj).Id) : null);
+ }
+ return false;
+ })?.ToList());
+ if (list.Count == 0)
+ {
+ list = itensApoMae.Where((Item x) => x.Status != null && !ValidationHelper.IsNullOrEmpty(x.Status) && x.Status.Contains("ORDEM") && x.Status.Replace("ORDEM", "-").Split(new char[1] { '-' })[1].Trim().Equals($"{SelectedDocumento.Ordem}")).ToList();
+ }
+ foreach (Item item in list)
+ {
+ await new ItemServico().Reativar(item, "");
+ }
+ }
+
+ public string GerarObs(Documento doc)
+ {
+ if (doc.Tipo != 0)
+ {
+ return $"CLIENTE: {doc.Controle.Cliente.Nome}{Environment.NewLine}CÓDIGO: {((DomainBase)doc).Id}{Environment.NewLine}PROPOSTA: {doc.Proposta}{Environment.NewLine}APÓLICE: {doc.Apolice}{Environment.NewLine}PROPOSTA DE ENDOSSO: {doc.PropostaEndosso}{Environment.NewLine}ENDOSSO: {doc.Endosso}";
+ }
+ return $"CLIENTE: {doc.Controle.Cliente.Nome}{Environment.NewLine}CÓDIGO: {((DomainBase)doc).Id}{Environment.NewLine}PROPOSTA: {doc.Proposta}{Environment.NewLine}APÓLICE: {doc.Apolice}";
+ }
+
+ public async Task RecusarApolice()
+ {
+ if (SelectedDocumento == null)
+ {
+ return;
+ }
+ bool[] array = await Funcoes.VerificarPagamento(((DomainBase)SelectedDocumento).Id);
+ if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 23) && array.Any((bool x) => x))
+ {
+ await ShowMessage("NÃO É POSSÍVEL RECURSAR UM APÓLICE ENQUANTO HOUVER RECEBIMENTO DE COMISSÃO OU PAGAMENTO DE VENDEDORES PARA A APÓLICE");
+ 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 val = await Servico.BuscarApoliceAsync(((DomainBase)DocumentoSelecionado).Id);
+ IList<Documento> list;
+ if (val.Controle.Documentos.Count <= 1)
+ {
+ list = val.Controle.Documentos;
+ }
+ else
+ {
+ IList<Documento> list2 = (from x in val.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)val.Situacao == 7)
+ {
+ await ShowMessage("NÃO É POSSÍVEL RECUSAR UM DOCUMENTO JÁ RECUSADO.");
+ return;
+ }
+ string text = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? "A PROPOSTA SELECIONADA" : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? "A APÓLICE SELECIONADA" : "O ENDOSSO SELECIONADO"));
+ if (await ShowMessage("DESEJA REALMENTE RECUSAR " + text + "? " + Environment.NewLine + "ESSE PROCEDIMENTO É IRREVERSÍVEL.", "SIM", "NÃO"))
+ {
+ string motivo = await ShowObservacaoDialog();
+ if (motivo != null)
+ {
+ Loading(isLoading: true);
+ await Funcoes.RecusarApolice(SelectedDocumento, motivo, estorno);
+ string text2 = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("A PROPOSTA \"" + SelectedDocumento.Proposta + "\"") : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("A APÓLICE \"" + SelectedDocumento.Apolice + "\"") : (string.IsNullOrEmpty(SelectedDocumento.Endosso) ? ("A PROPOSTA DE ENDOSSO \"" + SelectedDocumento.PropostaEndosso + "\"") : ("O ENDOSSO \"" + SelectedDocumento.Endosso + "\""))));
+ RegistrarAcao("RECUSOU " + text2, ((DomainBase)SelectedDocumento).Id, (TipoTela)2, GerarObs(SelectedDocumento) + Environment.NewLine + "MOTIVO: " + motivo);
+ Loading(isLoading: false);
+ }
+ }
+ }
+
+ public async Task<bool> IncluirEndosso()
+ {
+ if (!Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 13) && string.IsNullOrWhiteSpace(SelectedDocumento.Apolice))
+ {
+ await ShowMessage("PROPOSTA NÃO PODE SER ENDOSSADA. NECESSÁRIO PREENCHER O NÚMERO DA APÓLICE E DATA DE EMISSÃO ANTES DE PROSSEGUIR.");
+ return false;
+ }
+ ObservableCollection<TipoEndosso> tipoEndossoList = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? new ObservableCollection<TipoEndosso>(new List<TipoEndosso>
+ {
+ (TipoEndosso)2,
+ (TipoEndosso)1,
+ (TipoEndosso)4
+ }) : new ObservableCollection<TipoEndosso>(new List<TipoEndosso>
+ {
+ (TipoEndosso)0,
+ (TipoEndosso)1,
+ (TipoEndosso)2,
+ (TipoEndosso)4
+ }));
+ if ((int)SelectedDocumento.Situacao == 3)
+ {
+ tipoEndossoList = new ObservableCollection<TipoEndosso>(new List<TipoEndosso> { (TipoEndosso)3 });
+ }
+ TipoEndossoList = tipoEndossoList;
+ Documento val = new Documento
+ {
+ Controle = SelectedDocumento.Controle,
+ Tipo = 1,
+ Ordem = SelectedDocumento.Controle.Documentos.Where((Documento x) => !x.Excluido).Max((Documento x) => x.Ordem) + 1,
+ NegocioCorretora = (NegocioCorretora)(((int?)SelectedDocumento.NegocioCorretora) ?? (((int)SelectedDocumento.Situacao == 2 && SelectedDocumento.Negocio.HasValue && (int)SelectedDocumento.Negocio.GetValueOrDefault() == 1) ? 1 : 0)),
+ Situacao = SelectedDocumento.Situacao,
+ Negocio = SelectedDocumento.Negocio,
+ TipoRecebimento = SelectedDocumento.TipoRecebimento,
+ Vigencia1 = Funcoes.GetNetworkTime().Date,
+ Vigencia2 = SelectedDocumento.Vigencia2,
+ ApoliceConferida = false,
+ PropostaAssinada = false,
+ AdicionalComiss = false,
+ Excluido = false,
+ Apolice = SelectedDocumento.Apolice,
+ Proposta = SelectedDocumento.Proposta,
+ TipoEndosso = (TipoEndosso)(((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 2) ? 2 : 0),
+ Comissao = SelectedDocumento.Comissao,
+ Estipulante1 = SelectedDocumento.Estipulante1,
+ Estipulante2 = SelectedDocumento.Estipulante2,
+ Estipulante3 = SelectedDocumento.Estipulante3,
+ Estipulante4 = SelectedDocumento.Estipulante4,
+ Estipulante5 = SelectedDocumento.Estipulante5
+ };
+ SelectedParcela = null;
+ SelectedDocumento = null;
+ SelectedPagamento = null;
+ if ((int)val.TipoRecebimento.GetValueOrDefault() == 1)
+ {
+ List<VendedorParcela> list = (from x in Repasses.Where((VendedorParcela x) => (int)x.Parcela.SubTipo == 1).ToList()
+ group x by ((DomainBase)x.Vendedor).Id).Select((Func<IGrouping<long, VendedorParcela>, VendedorParcela>)((IGrouping<long, VendedorParcela> x) => new VendedorParcela
+ {
+ Repasse = x.First().Repasse,
+ Parcela = SelectedParcela,
+ Documento = SelectedDocumento,
+ ValorRepasse = default(decimal),
+ Vendedor = x.First().Vendedor,
+ PorcentagemRepasse = x.First().PorcentagemRepasse,
+ TipoVendedor = x.First().TipoVendedor
+ })).ToList();
+ Pagamentos = new ObservableCollection<VendedorParcela>(list);
+ Repasses = list;
+ }
+ else
+ {
+ Pagamentos = null;
+ Repasses = null;
+ }
+ Parcelas = null;
+ SelectedDocumento = val;
+ NovaApolice = true;
+ AllowEditVendedor = false;
+ AllowEditApolice = true;
+ IsEndosso = true;
+ base.IsEnabledEditEndosso = true;
+ base.EnableFields = true;
+ base.EnableIncluir = false;
+ AllowEditEmissao = true;
+ Gestor.Application.Actions.Actions.EnableMainMenu?.Invoke(obj: false);
+ return true;
+ }
+
+ public async void RecalculaRepasses()
+ {
+ if (Repasses == null)
+ {
+ return;
+ }
+ bool renovacao = (SelectedDocumento.NegocioCorretora.HasValue ? ((int)SelectedDocumento.NegocioCorretora.GetValueOrDefault() == 1) : ((int)SelectedDocumento.Situacao == 2 && SelectedDocumento.Negocio.HasValue && (int)SelectedDocumento.Negocio.GetValueOrDefault() == 1));
+ Repasses?.Where((VendedorParcela x) => NovaApolice || (int)x.Parcela.SubTipo == 1).ToList().ForEach(delegate(VendedorParcela x)
+ {
+ //IL_00a6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ac: Invalid comparison between Unknown and I4
+ //IL_0068: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006e: Invalid comparison between Unknown and I4
+ if (x.Parcela == null || x.Repasse == null || x.DataPagamento.HasValue)
+ {
+ return;
+ }
+ Parcela parcela = x.Parcela;
+ parcela.Documento = SelectedDocumento;
+ decimal value = Funcoes.CalculaRepasse(x.Repasse, parcela);
+ decimal value2;
+ if (renovacao)
+ {
+ Repasse repasse = x.Repasse;
+ if (repasse == null || (int)repasse.Tipo.GetValueOrDefault() != 3)
+ {
+ value2 = x.Repasse.ValorRenovacao;
+ goto IL_008d;
+ }
+ }
+ value2 = x.Repasse.ValorNovo;
+ goto IL_008d;
+ IL_008d:
+ x.PorcentagemRepasse = value2;
+ decimal? valorRepasse = (((int)x.Repasse.Forma.GetValueOrDefault() != 3) ? new decimal?(value) : (x.ValorTotal / (decimal?)SelectedDocumento.NumeroParcelas));
+ if (x.CoCorretagem)
+ {
+ decimal premioLiquido = SelectedDocumento.PremioLiquido;
+ decimal? num = (SelectedDocumento.ComissaoTotal - (decimal?)SelectedDocumento.Comissao) / (decimal?)100;
+ valorRepasse = (decimal?)premioLiquido * num;
+ }
+ x.ValorRepasse = valorRepasse;
+ x.ValorTotal = value;
+ });
+ if (NovaApolice)
+ {
+ Pagamentos = new ObservableCollection<VendedorParcela>(Repasses.OrderBy((VendedorParcela x) => ((DomainBase)x.TipoVendedor).Id));
+ }
+ else
+ {
+ await SelecionaParcela(SelectedParcela ?? Parcelas.FirstOrDefault());
+ CalculaComissao(SelectedDocumento, Parcelas);
+ }
+ }
+
+ public void RecalculaRepasse()
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001c: Invalid comparison between Unknown and I4
+ if ((!IsFatura && BaixarParcelas && (int)SelectedParcela.SubTipo == 1) || Repasses == null || Repasses.Count == 0)
+ {
+ return;
+ }
+ if (((DomainBase)SelectedParcela).Id == 0L)
+ {
+ Repasses.ForEach(delegate(VendedorParcela x)
+ {
+ //IL_0026: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002c: Invalid comparison between Unknown and I4
+ //IL_010d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0113: Invalid comparison between Unknown and I4
+ if (x.DataPagamento.HasValue)
+ {
+ return;
+ }
+ Repasse repasse3 = x.Repasse;
+ if (repasse3 != null && (int)repasse3.Tipo.GetValueOrDefault() == 3)
+ {
+ return;
+ }
+ Parcela val = x.Parcela ?? SelectedParcela;
+ val.Documento = SelectedDocumento;
+ if (x.Repasse != null)
+ {
+ x.Repasse.ValorNovo = x.PorcentagemRepasse ?? x.Repasse.ValorNovo;
+ x.Repasse.ValorRenovacao = x.PorcentagemRepasse ?? x.Repasse.ValorRenovacao;
+ }
+ decimal value2 = Funcoes.CalculaRepasse(x.Repasse, val);
+ decimal? valorRepasse2;
+ if (SelectedDocumento.NumeroParcelas > 0m && !SelectedParcela.NumeroParcela.Equals(999))
+ {
+ Repasse repasse4 = x.Repasse;
+ if (repasse4 != null && (int)repasse4.Forma.GetValueOrDefault() == 3)
+ {
+ valorRepasse2 = x.ValorTotal / (decimal?)SelectedDocumento.NumeroParcelas;
+ goto IL_015c;
+ }
+ }
+ valorRepasse2 = value2;
+ goto IL_015c;
+ IL_015c:
+ x.ValorRepasse = valorRepasse2;
+ x.ValorTotal = value2;
+ });
+ Pagamentos = new ObservableCollection<VendedorParcela>(Repasses);
+ return;
+ }
+ Repasses?.Where((VendedorParcela x) => ((DomainBase)SelectedParcela).Id > 0 && ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id).ToList().ForEach(delegate(VendedorParcela x)
+ {
+ //IL_0026: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002c: Invalid comparison between Unknown and I4
+ //IL_0167: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016d: Invalid comparison between Unknown and I4
+ //IL_0175: Unknown result type (might be due to invalid IL or missing references)
+ //IL_017b: Invalid comparison between Unknown and I4
+ //IL_0103: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0109: Invalid comparison between Unknown and I4
+ if (x.DataPagamento.HasValue)
+ {
+ return;
+ }
+ Repasse repasse = x.Repasse;
+ if (repasse != null && (int)repasse.Tipo.GetValueOrDefault() == 3)
+ {
+ return;
+ }
+ Parcela selectedParcela = SelectedParcela;
+ selectedParcela.Documento = SelectedDocumento;
+ if (x.Repasse != null)
+ {
+ x.Repasse.ValorNovo = x.PorcentagemRepasse ?? x.Repasse.ValorNovo;
+ x.Repasse.ValorRenovacao = x.PorcentagemRepasse ?? x.Repasse.ValorRenovacao;
+ }
+ decimal value = Funcoes.CalculaRepasse(x.Repasse, selectedParcela);
+ decimal? valorRepasse;
+ if (SelectedDocumento.NumeroParcelas > 0m && !SelectedParcela.NumeroParcela.Equals(999))
+ {
+ Repasse repasse2 = x.Repasse;
+ if (repasse2 != null && (int)repasse2.Forma.GetValueOrDefault() == 3)
+ {
+ valorRepasse = x.ValorTotal / (decimal?)SelectedDocumento.NumeroParcelas;
+ goto IL_0152;
+ }
+ }
+ valorRepasse = value;
+ goto IL_0152;
+ IL_0152:
+ x.ValorRepasse = valorRepasse;
+ x.ValorTotal = (((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1 && (int)SelectedParcela.SubTipo == 1) ? new decimal?(value) : x.ValorTotal);
+ });
+ Pagamentos = new ObservableCollection<VendedorParcela>(Repasses?.Where((VendedorParcela x) => ((DomainBase)SelectedParcela).Id > 0 && ((DomainBase)x.Parcela).Id == ((DomainBase)SelectedParcela).Id).ToList());
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> SalvarParcelas(int tipo)
+ {
+ if (SelectedParcela.Documento == null)
+ {
+ SelectedParcela.Documento = SelectedDocumento;
+ }
+ SelectedParcela.Documento.Parcelas = Parcelas;
+ if ((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1 && (int)SelectedParcela.SubTipo == 1 && SelectedParcela.Comissao == 0m)
+ {
+ SelectedParcela.Comissao = SelectedDocumento.Comissao;
+ }
+ List<KeyValuePair<string, string>> errors = SelectedParcela.Validate(Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 9), Recursos.Configuracoes.Any((ConfiguracaoSistema y) => (int)y.Configuracao == 11), EditandoParcela, Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 16));
+ errors.AddRange(ValidaParcelaEspecial(tipo));
+ decimal num = ((SelectedParcela.ValorExtrato == 0m) ? SelectedParcela.ValorLiquidoFatura : SelectedParcela.ValorExtrato);
+ int num2 = ((num > 0m) ? num.CompareTo(SelectedParcela.ValorComissao) : SelectedParcela.ValorComissao.CompareTo(num));
+ bool flag = errors.Count == 1 && 2 == (int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() && num2 < 0;
+ if (flag)
+ {
+ flag = await ShowMessage("VALOR RECEBIMENTO MAIOR QUE VALOR PARCELA, CONTINUAR?", "SIM", "NÃO");
+ }
+ if (flag)
+ {
+ errors.Clear();
+ }
+ if (errors.Count > 0)
+ {
+ return errors;
+ }
+ SelectedParcela.Baixando = false;
+ if (!Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 5) && (SelectedParcela.Iss > 0m || SelectedParcela.Irr > 0m || SelectedParcela.Outros > 0m || SelectedParcela.Desconto > 0m))
+ {
+ SelectedParcela.Iss = 0m;
+ SelectedParcela.Irr = 0m;
+ SelectedParcela.Outros = 0m;
+ SelectedParcela.Desconto = 0m;
+ SelectedParcela.ValorComDesconto = SelectedParcela.ValorComissao;
+ }
+ switch (tipo)
+ {
+ case 1:
+ await AlterarVencimento();
+ break;
+ case 2:
+ await BaixarComissao();
+ break;
+ case 3:
+ case 4:
+ await AdicionarParcelaEspecial();
+ break;
+ }
+ return null;
+ }
+
+ private List<KeyValuePair<string, string>> ValidaParcelaEspecial(int tipo)
+ {
+ //IL_0010: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0016: Invalid comparison between Unknown and I4
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (tipo == 4 && (int)SelectedParcela.SubTipo == 1)
+ {
+ list.Add(new KeyValuePair<string, string>("SubTipo|TIPO", "A PARCELA ESPECIAL NÃO PODE SER DO TIPO PARCELA NORMAL"));
+ }
+ return list;
+ }
+
+ public Documento AbrirDetalhes()
+ {
+ Documento selectedDocumento = SelectedDocumento;
+ selectedDocumento.Parcelas = Parcelas;
+ selectedDocumento.Pagamentos = Repasses;
+ return selectedDocumento;
+ }
+
+ public bool CompararValores()
+ {
+ if (((DomainBase)SelectedDocumento).Id != 0L && !((DomainBase)SelectedDocumento).HasChange("PremioLiquido") && !((DomainBase)SelectedDocumento).HasChange("PremioAdicional") && !((DomainBase)SelectedDocumento).HasChange("Comissao") && !((DomainBase)SelectedDocumento).HasChange("Iof"))
+ {
+ return ((DomainBase)SelectedDocumento).HasChange("AdicionalComiss");
+ }
+ return true;
+ }
+
+ public Parcela AbrirDetalhesParcela()
+ {
+ Parcela selectedParcela = SelectedParcela;
+ selectedParcela.Vendedores = Pagamentos;
+ return selectedParcela;
+ }
+
+ public void ManutecaoItens()
+ {
+ if (Invoke)
+ {
+ Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)3, "Manutencao");
+ }
+ }
+
+ public async Task<bool> PagamentoVendedor(Parcela parcela)
+ {
+ return await ParcelaServico.TemPagamento(((DomainBase)parcela).Id);
+ }
+
+ public async Task ExcluirPagamento(VendedorParcela pagamento)
+ {
+ Loading(isLoading: true);
+ if (await Funcoes.ExcluirPagamento(pagamento))
+ {
+ ToggleSnackBar("PAGAMENTO EXCLUÍDO COM SUCESSO");
+ string text = ((SelectedDocumento.Tipo == 0 && string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("NA PROPOSTA \"" + SelectedDocumento.Proposta + "\"") : ((SelectedDocumento.Tipo == 0 && !string.IsNullOrEmpty(SelectedDocumento.Apolice)) ? ("NA APÓLICE \"" + SelectedDocumento.Apolice + "\"") : (string.IsNullOrEmpty(SelectedDocumento.Endosso) ? ("NA PROPOSTA DE ENDOSSO \"" + SelectedDocumento.PropostaEndosso + "\"") : ("NO ENDOSSO \"" + SelectedDocumento.Endosso + "\""))));
+ string descricao = "PAGAMENTO DO VENDEDOR " + pagamento.Vendedor.Nome + " EXCLUÍDO, " + text;
+ RegistrarAcao(descricao, ((DomainBase)pagamento).Id, (TipoTela)37, $"{GerarObs(SelectedDocumento)}{Environment.NewLine}VENDEDOR: {pagamento.Vendedor.Nome}{Environment.NewLine}COMISSÃO TOTAL: {pagamento.ValorTotal:C2}");
+ }
+ await CarregarParcelas(SelectedDocumento);
+ await CarregaRepasse(((DomainBase)SelectedDocumento).Id);
+ await SelecionaParcela(Parcelas.FirstOrDefault());
+ AllowEditApolice = Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).All((Parcela x) => !x.DataRecebimento.HasValue) && Repasses.Where((VendedorParcela x) => (int)x.Parcela.SubTipo == 1).All((VendedorParcela x) => !x.DataPagamento.HasValue);
+ BaixarParcelas = false;
+ Loading(isLoading: false);
+ }
+
+ public async Task CarregarImposto()
+ {
+ List<Imposto> source = await new ImpostoServico().Buscar(true);
+ object obj = ((IEnumerable<Imposto>)source).FirstOrDefault((Func<Imposto, bool>)((Imposto x) => x.Seguradora != null && ((DomainBase)x.Seguradora).Id == ((DomainBase)SelectedDocumento.Controle.Seguradora).Id && x.Ramo != null && ((DomainBase)x.Ramo).Id == ((DomainBase)SelectedDocumento.Controle.Ramo).Id)) ?? ((IEnumerable<Imposto>)source).FirstOrDefault((Func<Imposto, bool>)((Imposto x) => x.Seguradora != null && ((DomainBase)x.Seguradora).Id == ((DomainBase)SelectedDocumento.Controle.Seguradora).Id && x.Ramo == null));
+ if (obj == null)
+ {
+ obj = ((IEnumerable<Imposto>)source).FirstOrDefault((Func<Imposto, bool>)((Imposto x) => x.Seguradora == null && x.Ramo != null && ((DomainBase)x.Ramo).Id == ((DomainBase)SelectedDocumento.Controle.Ramo).Id));
+ }
+ if (obj == null)
+ {
+ obj = ((IEnumerable<Imposto>)source).FirstOrDefault((Func<Imposto, bool>)((Imposto x) => x.Seguradora == null && x.Ramo == null));
+ }
+ Imposto val = (Imposto)obj;
+ Imposto = (Imposto)(((object)val) ?? ((object)new Imposto()));
+ }
+
+ public async Task EditarParcelas()
+ {
+ if (DocumentoSelecionado == null)
+ {
+ DocumentoSelecionado = SelectedDocumento;
+ }
+ await ShowEditarParcelasDialog(DocumentoSelecionado);
+ await CarregarParcelas(DocumentoSelecionado);
+ }
+
+ public async void AbrirLogAntigo()
+ {
+ Loading(isLoading: true);
+ string text = await Servico.BuscarLogAntigo(((DomainBase)SelectedDocumento).Id);
+ Loading(isLoading: false);
+ if (string.IsNullOrEmpty(text))
+ {
+ await ShowMessage("NÃO HÁ LOG PARA ESSE DOCUMENTO");
+ }
+ else
+ {
+ ShowDrawer(new LogSistemaAntigo(((DomainBase)SelectedDocumento).Id, text), 0, close: false);
+ }
+ }
+
+ public async void AbrirLogAntigoParcela()
+ {
+ Loading(isLoading: true);
+ string log = "";
+ foreach (Parcela item in await ParcelaServico.BuscarParcelas(((DomainBase)SelectedDocumento).Id))
+ {
+ string text = log;
+ log = text + await ParcelaServico.BuscarLogAntigo(((DomainBase)item).Id);
+ }
+ Loading(isLoading: false);
+ if (string.IsNullOrEmpty(log))
+ {
+ await ShowMessage("NÃO HÁ LOG PARA PARCELAS");
+ }
+ else
+ {
+ ShowDrawer(new LogSistemaAntigo(((DomainBase)SelectedDocumento).Id, log), 0, close: false);
+ }
+ }
+
+ public async Task AjusteComissãoCoCorretagem(bool removido = false)
+ {
+ try
+ {
+ if (removido)
+ {
+ Documento selectedDocumento = SelectedDocumento;
+ Documento selectedDocumento2 = SelectedDocumento;
+ selectedDocumento.Comissao = ((selectedDocumento2 != null) ? selectedDocumento2.ComissaoTotal : null).GetValueOrDefault();
+ SelectedDocumento = await Servico.Save(SelectedDocumento, updateParcelas: false, criarParcelas: false);
+ AjustaParcelasCoCorretagem();
+ CalculaComissao(SelectedDocumento, Parcelas);
+ }
+ else
+ {
+ VendedorParcela selectedPagamento = SelectedPagamento;
+ decimal num = ((selectedPagamento != null) ? selectedPagamento.Repasse.ValorNovo : 0m);
+ decimal comissao = SelectedDocumento.Comissao;
+ SelectedDocumento.ComissaoTotal = comissao;
+ SelectedDocumento.Comissao = Math.Round(comissao - comissao * (num * 0.01m), 2);
+ SelectedDocumento = await Servico.Save(SelectedDocumento, updateParcelas: false, criarParcelas: false);
+ AjustaParcelasCoCorretagem();
+ CalculaComissao(SelectedDocumento, Parcelas);
+ }
+ }
+ catch
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL ALTERAR A COMISSÃO DA CO-CORRETAGEM");
+ }
+ }
+
+ public async void AjustaParcelasCoCorretagem()
+ {
+ try
+ {
+ ObservableCollection<Parcela> parcelas = Parcelas;
+ foreach (Parcela item in parcelas)
+ {
+ if (item.NumeroParcela == 999)
+ {
+ return;
+ }
+ item.Comissao = SelectedDocumento.Comissao;
+ }
+ Parcelas = new ObservableCollection<Parcela>(await ParcelaServico.SaveRange(parcelas.ToList()));
+ await CarregarParcelas(SelectedDocumento);
+ }
+ catch
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL SALVAR AS PARCELAS");
+ }
+ }
+
+ public List<Vendedor> VendedorCoCorretagem(bool coCorretagem = false)
+ {
+ if (coCorretagem)
+ {
+ return Vendedores = Vendedores.Where((Vendedor vendedor) => RepassesVendedores?.FindAll((Repasse repasse) => ((DomainBase)repasse.Vendedor).Id == ((DomainBase)vendedor).Id).Any((Repasse x) => (int)x.Tipo.GetValueOrDefault() == 3) ?? false).ToList();
+ }
+ return Vendedores = (from vendedor in Recursos.Vendedores
+ where vendedor.Ativo && !vendedor.Corretora && vendedor.IdEmpresa == Recursos.Usuario.IdEmpresa
+ select vendedor into v
+ orderby v.Nome
+ select v).ToList();
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/BaseDialogViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/BaseDialogViewModel.cs
new file mode 100644
index 0000000..77c4577
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/BaseDialogViewModel.cs
@@ -0,0 +1,5 @@
+namespace Gestor.Application.ViewModels.Generic;
+
+public class BaseDialogViewModel : BaseViewModel
+{
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/BaseFinanceiroViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/BaseFinanceiroViewModel.cs
new file mode 100644
index 0000000..abe8a24
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/BaseFinanceiroViewModel.cs
@@ -0,0 +1,371 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+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 System.Windows.Forms;
+using Gestor.Application.Componentes;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Financeiro;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Financeiro;
+using MaterialDesignThemes.Wpf;
+using OfxSharpLib;
+using Xceed.Wpf.AvalonDock.Controls;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public abstract class BaseFinanceiroViewModel : BaseViewModel
+{
+ public AutoCompleteFilterPredicate<object> BancosContasItemFilter => (string searchText, object obj) => ((BancosContas)obj).Descricao.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> FornecedorItemFilter => (string searchText, object obj) => (((Fornecedor)obj).Nome != null && ((Fornecedor)obj).Nome.ToUpper().Contains(searchText.ToUpper())) || (((Fornecedor)obj).Documento != null && ((Fornecedor)obj).Documento.ToString().Contains(searchText.ToUpper())) || (((Fornecedor)obj).Telefone1 != null && ((Fornecedor)obj).Telefone1.ToString().Contains(searchText.ToUpper())) || (((Fornecedor)obj).Telefone2 != null && ((Fornecedor)obj).Telefone2.ToString().Contains(searchText.ToUpper())) || (((Fornecedor)obj).Email != null && ((Fornecedor)obj).Email.ToString().Contains(searchText.ToUpper()));
+
+ public AutoCompleteFilterPredicate<object> LancamentoItemFilter => delegate(string searchText, object obj)
+ {
+ //IL_0001: 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_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0056: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0099: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00dc: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ae: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0113: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0156: Unknown result type (might be due to invalid IL or missing references)
+ //IL_012c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_019e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01e3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01b7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01fc: Unknown result type (might be due to invalid IL or missing references)
+ if ((((Lancamento)obj).Historico == null || !((Lancamento)obj).Historico.ToUpper().Contains(searchText.ToUpper())) && !((Lancamento)obj).Vencimento.ToString().ToUpper().Contains(searchText.ToUpper()) && (!((Lancamento)obj).Baixa.HasValue || !((Lancamento)obj).Baixa.ToString().ToUpper().Contains(searchText.ToUpper())) && (!((Lancamento)obj).Pagamento.HasValue || !((Lancamento)obj).Pagamento.ToString().ToUpper().Contains(searchText.ToUpper())) && (((Lancamento)obj).Conta == null || !((Lancamento)obj).Conta.Descricao.ToString().ToUpper().Contains(searchText.ToUpper())))
+ {
+ ControleFinanceiro controle = ((Lancamento)obj).Controle;
+ if (((controle != null) ? controle.Historico : null) == null || !((Lancamento)obj).Controle.Historico.ToString().ToUpper().Contains(searchText.ToUpper()))
+ {
+ ControleFinanceiro controle2 = ((Lancamento)obj).Controle;
+ if (((controle2 != null) ? controle2.Plano : null) == null || !((Lancamento)obj).Controle.Plano.Descricao.ToString().ToUpper().Contains(searchText.ToUpper()))
+ {
+ ControleFinanceiro controle3 = ((Lancamento)obj).Controle;
+ if (((controle3 != null) ? controle3.Centro : null) == null || !((Lancamento)obj).Controle.Centro.Descricao.ToString().ToUpper().Contains(searchText.ToUpper()))
+ {
+ ControleFinanceiro controle4 = ((Lancamento)obj).Controle;
+ if (((controle4 != null) ? controle4.Fornecedor : null) != null)
+ {
+ return ((Lancamento)obj).Controle.Fornecedor.Nome.ToString().ToUpper().Contains(searchText.ToUpper());
+ }
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ };
+
+ public AutoCompleteFilterPredicate<object> PlanoItemFilter => (string searchText, object obj) => ((Plano)obj).Descricao.ToUpper().Contains(searchText.ToUpper()) || ((Plano)obj).Descricao.ToString().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> PlanosItemFilter => (string searchText, object obj) => ((Planos)obj).Descricao.ToUpper().Contains(searchText.ToUpper()) || ((Planos)obj).Descricao.ToString().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> BancoItemFilter => (string searchText, object obj) => ((Banco)obj).Nome.ToUpper().Contains(searchText.ToUpper());
+
+ internal async Task<List<BancosContas>> BuscarBancosContas(string value)
+ {
+ return await Task.Run(() => new BaseServico().BuscarBancosContas(value));
+ }
+
+ internal async Task<List<Fornecedor>> BuscarFornecedor(string value)
+ {
+ return await Task.Run(() => new BaseServico().BuscarFornecedor(value));
+ }
+
+ internal async Task<List<Fornecedor>> BuscarFornecedorAtivo(string value)
+ {
+ return await Task.Run(() => new BaseServico().BuscarFornecedor(value, ativo: true));
+ }
+
+ internal async Task<Transferencia> ShowTransferencia(Transferencia transferencia)
+ {
+ DialogHost val = Extentions.FindVisualChildren<DialogHost>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).FirstOrDefault();
+ DialogTransferencia dialogControl = new DialogTransferencia(transferencia);
+ return await ExecuteRunExtendedDialogTransferencia((UserControl)(object)dialogControl, (val != null) ? val.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Transferencia> ExecuteRunExtendedDialogTransferencia(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Transferencia)obj;
+ }
+
+ internal async Task<Lancamento> ShowVinculo(FinanceiroViewModel viewModel)
+ {
+ DialogHost val = Extentions.FindVisualChildren<DialogHost>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).FirstOrDefault();
+ VincularLancamentoDialog dialogControl = new VincularLancamentoDialog(viewModel);
+ return await ExecuteRunExtendedDialogVinculo((UserControl)(object)dialogControl, (val != null) ? val.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Lancamento> ExecuteRunExtendedDialogVinculo(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Lancamento)obj;
+ }
+
+ internal async Task<BancosContas> ShowContas(List<BancosContas> contas)
+ {
+ DialogHost val = Extentions.FindVisualChildren<DialogHost>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).FirstOrDefault();
+ ContasDialog dialogControl = new ContasDialog(contas);
+ return await ExecuteRunExtendedDialogContas((UserControl)(object)dialogControl, (val != null) ? val.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<BancosContas> ExecuteRunExtendedDialogContas(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (BancosContas)obj;
+ }
+
+ public Encoding GetEncoding(string filename)
+ {
+ byte[] array = new byte[4];
+ using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read))
+ {
+ fileStream.Read(array, 0, 4);
+ }
+ if (array[0] == 43 && array[1] == 47 && array[2] == 118)
+ {
+ return Encoding.UTF7;
+ }
+ if (array[0] == 239 && array[1] == 187 && array[2] == 191)
+ {
+ return Encoding.UTF8;
+ }
+ if (array[0] == byte.MaxValue && array[1] == 254 && array[2] == 0 && array[3] == 0)
+ {
+ return Encoding.UTF32;
+ }
+ if (array[0] == byte.MaxValue && array[1] == 254)
+ {
+ return Encoding.Unicode;
+ }
+ if (array[0] == 254 && array[1] == byte.MaxValue)
+ {
+ return Encoding.BigEndianUnicode;
+ }
+ if (array[0] == 0 && array[1] == 0 && array[2] == 254 && array[3] == byte.MaxValue)
+ {
+ return new UTF32Encoding(bigEndian: true, byteOrderMark: true);
+ }
+ return Encoding.ASCII;
+ }
+
+ public async Task<List<OfxDocument>> ImportarOfx()
+ {
+ List<OfxDocument> ofxDocuments = new List<OfxDocument>();
+ bool error = false;
+ List<string> files = new List<string>();
+ OpenFileDialog val = new OpenFileDialog();
+ try
+ {
+ val.Multiselect = true;
+ ((FileDialog)val).Filter = "Arquivos OFX|*.ofx";
+ ((FileDialog)val).InitialDirectory = Environment.SpecialFolder.Desktop.ToString();
+ if (1 != (int)((CommonDialog)val).ShowDialog())
+ {
+ return null;
+ }
+ files.AddRange(((FileDialog)val).FileNames);
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ await Task.Run(delegate
+ {
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0018: Expected O, but got Unknown
+ OfxDocumentParser parser = new OfxDocumentParser();
+ files.ForEach(delegate(string x)
+ {
+ try
+ {
+ string text = DateTime.Now.Date.ToString("yyyyMMddHHmmss");
+ string text2 = DetectEncodingAndRead(x).Replace("<DTASOF>00000000", "<DTASOF>" + text).Replace("<DTSERVER>00000000000000", "<DTSERVER>" + text).Replace(",", ".")
+ .Replace("<REFNUM> </REFNUM>", "<REFNUM>.</REFNUM>");
+ if (text2.Contains("<FID>336</FID>") && !text2.Contains("<LEDGERBAL>"))
+ {
+ text2 = text2.Replace("UTF - 8", "USASCII").Replace("</BANKTRANLIST>", "</BANKTRANLIST>\r\n<LEDGERBAL>\r\n<BALAMT>0\r\n<DTASOF>00000000\r\n</LEDGERBAL>").Replace("<DTASOF>00000000", "<DTASOF>" + text)
+ .Replace(": ", ":")
+ .Replace(" ", "")
+ .Replace("<REFNUM/>", "<REFNUM>0");
+ }
+ if (text2.Contains("<FID>0403</FID>") && !text2.Contains("CHARSET:1252") && text2.Contains("ENCODING:UTF-8"))
+ {
+ text2 = text2.Replace("UTF-8", "USASCII\nCHARSET:1252").Replace("<DTASOF>00000000", "<DTASOF>" + text).Replace("[0:GMT]", "")
+ .Replace(": ", ":")
+ .Replace(" ", "");
+ }
+ if (text2.Contains("<FID>260"))
+ {
+ text2 = text2.Replace("UTF-8", "USASCII").Replace("CHARSET:NONE", "CHARSET:1252");
+ }
+ if (text2.Contains("<MEMO></MEMO>"))
+ {
+ text2 = text2.Replace("<MEMO></MEMO>", "<MEMO>SEM INFORMAÇÃO</MEMO>");
+ }
+ if (Regex.IsMatch(text2, "<NAME>\\s*</NAME>"))
+ {
+ text2 = text2.Replace("<NAME>\n</NAME>", "<NAME>SEM NOME</NAME>").Replace("<NAME></NAME>", "<NAME>SEM NOME</NAME>");
+ }
+ OfxDocument item = parser.Import(text2);
+ ofxDocuments.Add(item);
+ }
+ catch (Exception)
+ {
+ error = true;
+ }
+ });
+ });
+ if (error)
+ {
+ await ShowMessage("HOUVE PROBLEMAS AO IMPORTAR O OFX, BAIXE-O NOVAMENTE COM UM PERÍODO MENOR.");
+ }
+ return ofxDocuments;
+ }
+
+ private string DetectEncodingAndRead(string arquivo)
+ {
+ return File.ReadAllText(arquivo, DetectTextFileEncoding(arquivo));
+ }
+
+ public static Encoding DetectTextFileEncoding(string filePath)
+ {
+ byte[] array;
+ using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
+ {
+ int num = (int)Math.Min(fileStream.Length, 4096L);
+ array = new byte[num];
+ fileStream.Read(array, 0, num);
+ }
+ if (array.Length >= 2)
+ {
+ if (array.Length >= 3 && array[0] == 239 && array[1] == 187 && array[2] == 191)
+ {
+ return Encoding.UTF8;
+ }
+ if (array[0] == byte.MaxValue && array[1] == 254)
+ {
+ return Encoding.Unicode;
+ }
+ if (array[0] == 254 && array[1] == byte.MaxValue)
+ {
+ return Encoding.BigEndianUnicode;
+ }
+ if (array.Length >= 4 && array[0] == byte.MaxValue && array[1] == 254 && array[2] == 0 && array[3] == 0)
+ {
+ return Encoding.UTF32;
+ }
+ if (array.Length >= 4 && array[0] == 0 && array[1] == 0 && array[2] == 254 && array[3] == byte.MaxValue)
+ {
+ return new UTF32Encoding(bigEndian: true, byteOrderMark: true);
+ }
+ }
+ bool flag = true;
+ int num2 = 0;
+ int num3 = 0;
+ for (int i = 0; i < array.Length; i++)
+ {
+ if (array[i] <= 127)
+ {
+ num3++;
+ continue;
+ }
+ if (array[i] >= 194 && array[i] <= 223 && i + 1 < array.Length && array[i + 1] >= 128 && array[i + 1] <= 191)
+ {
+ num2++;
+ i++;
+ continue;
+ }
+ if (array[i] >= 224 && array[i] <= 239 && i + 2 < array.Length && array[i + 1] >= 128 && array[i + 1] <= 191 && array[i + 2] >= 128 && array[i + 2] <= 191)
+ {
+ num2++;
+ i += 2;
+ continue;
+ }
+ if (array[i] >= 240 && array[i] <= 244 && i + 3 < array.Length && array[i + 1] >= 128 && array[i + 1] <= 191 && array[i + 2] >= 128 && array[i + 2] <= 191 && array[i + 3] >= 128 && array[i + 3] <= 191)
+ {
+ num2++;
+ i += 3;
+ continue;
+ }
+ flag = false;
+ break;
+ }
+ int num4 = 0;
+ for (int j = 0; j < array.Length - 1; j += 2)
+ {
+ if (array[j] == 0 || array[j + 1] == 0)
+ {
+ num4++;
+ }
+ }
+ if (flag && num2 > 0)
+ {
+ return Encoding.UTF8;
+ }
+ if ((double)num3 > (double)array.Length * 0.95)
+ {
+ return Encoding.ASCII;
+ }
+ if ((double)num4 > (double)array.Length * 0.4)
+ {
+ int num5 = 0;
+ int num6 = 0;
+ for (int k = 0; k < array.Length - 1; k += 2)
+ {
+ if (array[k] == 0 && array[k + 1] != 0)
+ {
+ num6++;
+ }
+ if (array[k] != 0 && array[k + 1] == 0)
+ {
+ num5++;
+ }
+ }
+ if (num5 > num6)
+ {
+ return Encoding.Unicode;
+ }
+ return Encoding.BigEndianUnicode;
+ }
+ return Encoding.GetEncoding(1252);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/BaseSegurosViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/BaseSegurosViewModel.cs
new file mode 100644
index 0000000..b481bbb
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/BaseSegurosViewModel.cs
@@ -0,0 +1,656 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using Agger.Registro;
+using Gestor.Application.Componentes;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Application.ViewModels.Seguros.Itens;
+using Gestor.Application.Views.Seguros.Itens;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Card;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.MalaDireta;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.Helper;
+using MaterialDesignThemes.Wpf;
+using Xceed.Wpf.AvalonDock.Controls;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class BaseSegurosViewModel : BaseViewModel
+{
+ private string _anotacoes;
+
+ private bool _enableEndossar;
+
+ private bool _enableRenovar;
+
+ public AutoCompleteFilterPredicate<object> ClienteItemFilter => (string searchText, object obj) => CultureInfo.InvariantCulture.CompareInfo.IndexOf(((Cliente)obj).Nome.ToUpper(), searchText.Trim(), CompareOptions.IgnoreNonSpace) > -1 || (((Cliente)obj).Documento != null && ((Cliente)obj).Documento.Contains(searchText.Trim())) || (((Cliente)obj).Rne != null && ((Cliente)obj).Rne.Contains(searchText.Trim())) || (((Cliente)obj).Cei != null && ((Cliente)obj).Cei.Contains(searchText.Trim())) || (((Cliente)obj).NomeSocialRg != null && ((Cliente)obj).NomeSocialRg.ToUpper().Contains(searchText.Trim().ToUpper())) || (((Cliente)obj).Telefones != null && ((Cliente)obj).Telefones.Count > 0 && ((Cliente)obj).Telefones.Any((ClienteTelefone x) => ((TelefoneBase)x).Numero.Contains(searchText.Trim())));
+
+ public string Anotacoes
+ {
+ get
+ {
+ return _anotacoes;
+ }
+ set
+ {
+ _anotacoes = value;
+ OnPropertyChanged("Anotacoes");
+ }
+ }
+
+ public AutoCompleteFilterPredicate<object> AgendaItemFilter => (string searchText, object obj) => ((Agenda)obj).Nome.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> VendedorItemFilter => (string searchText, object obj) => ((Vendedor)obj).Nome.ToUpper().Contains(searchText.ToUpper()) || (((Vendedor)obj).Documento != null && ((Vendedor)obj).Documento.ToUpper().Contains(searchText.ToUpper()));
+
+ public AutoCompleteFilterPredicate<object> ProfissaoItemFilter => (string searchText, object obj) => ((Profissao)obj).Nome.ToUpper().Contains(searchText.ToUpper()) || ((Profissao)obj).Codigo.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> EstipulanteItemFilter => (string searchText, object obj) => ((Estipulante)obj).Nome.ToUpper().Contains(searchText.ToUpper()) || ((Estipulante)obj).Documento.ToString().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> ProdutoItemFilter => (string searchText, object obj) => ((Produto)obj).Nome.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> TipoTarefaItemFilter => (string searchText, object obj) => ((TipoDeTarefa)obj).Nome.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> StatusProspeccaoItemFilter => (string searchText, object obj) => ((StatusDeProspeccao)obj).Nome.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> NotaFiscalItemFilter => (string searchText, object obj) => ((NotaFiscal)obj).Seguradora.Nome.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> StatusItemFilter => (string searchText, object obj) => ((Status)obj).Nome.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> ReciboItemFilter => (string searchText, object obj) => ((Recibo)obj).Pagante.ToUpper().Contains(searchText.ToUpper()) || ((Recibo)obj).Recebedor.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> EtiquetaItemFilter => (string searchText, object obj) => ((Documento)obj).Controle.Cliente.Nome.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> EmpresaItemFilter => (string searchText, object obj) => ((Empresa)obj).Nome.ToUpper().Contains(searchText.ToUpper()) || ((Empresa)obj).Documento.ToString().Contains(searchText.ToUpper()) || ((Empresa)obj).Serial.ToString().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> SocioItemFilter => (string searchText, object obj) => ((Socio)obj).Nome.ToUpper().Contains(searchText.ToUpper()) || ((Socio)obj).Email.ToString().Contains(searchText.ToUpper()) || ((Socio)obj).Telefone.ToString().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> UsuarioItemFilter => (string searchText, object obj) => ((Usuario)obj).Nome.ToUpper().Contains(searchText.ToUpper()) || ((Usuario)obj).Documento.ToString().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> NomeItemFilter => (string searchText, object obj) => ((Credencial)obj).Descricao.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> BancoItemFilter => (string searchText, object obj) => ((Banco)obj).Nome.ToUpper().Contains(searchText.ToUpper()) || ((Banco)obj).Codigo.ToString().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> AtividadeItemFilter => (string searchText, object obj) => ((Atividade)obj).Nome.ToUpper().Contains(searchText.ToUpper()) || ((Atividade)obj).Cnac.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> FabricanteItemFilter => (string searchText, object obj) => ((Fabricante)obj).Descricao.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> SeguradoraItemFilter => (string searchText, object obj) => ((Seguradora)obj).Nome.ToUpper().Contains(searchText.ToUpper()) || (((Seguradora)obj).Documento != null && ((Seguradora)obj).Documento.ToUpper().Contains(searchText.ToUpper())) || (((Seguradora)obj).Susep != null && ((Seguradora)obj).Susep.ToUpper().Contains(searchText.ToUpper()));
+
+ public AutoCompleteFilterPredicate<object> ConfigItemFilter => (string searchText, object obj) => ((ConfigExtratoImport)obj).Descricao.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> ParceiroItemFilter => (string searchText, object obj) => ((Parceiro)obj).Nome.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> TipoVendedorItemFilter => (string searchText, object obj) => ((TipoVendedor)obj).Descricao.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> RamoItemFilter => (string searchText, object obj) => ((Ramo)obj).Nome.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> ItemFilter => (string searchText, object obj) => ((Item)obj).Descricao.ToUpper().Contains(searchText.ToUpper());
+
+ public AutoCompleteFilterPredicate<object> SinitroItemFilter => (string searchText, object obj) => ((ControleSinistro)obj).DataSinistro.ToString().Contains(searchText) || (((ControleSinistro)obj).Sinistros != null && ((ControleSinistro)obj).Sinistros.Count > 0 && ((ControleSinistro)obj).Sinistros[0].Numero.ToUpper().Contains(searchText.ToUpper()));
+
+ public AutoCompleteFilterPredicate<object> CoberturaPadraoItemFilter => (string searchText, object obj) => ((CoberturaPadrao)obj).Descricao.ToUpper().Contains(searchText.ToUpper());
+
+ public bool EnableEndossar
+ {
+ get
+ {
+ return _enableEndossar;
+ }
+ set
+ {
+ _enableEndossar = value;
+ OnPropertyChanged("EnableEndossar");
+ }
+ }
+
+ public bool EnableRenovar
+ {
+ get
+ {
+ return _enableRenovar;
+ }
+ set
+ {
+ _enableRenovar = value;
+ OnPropertyChanged("EnableRenovar");
+ }
+ }
+
+ public List<Cliente> FilterCliente(List<Cliente> clientes, string searchText)
+ {
+ return clientes.Where((Cliente x) => x.Nome.ToUpper().Contains(searchText.ToUpper()) || (x.Documento != null && x.Documento.Contains(searchText)) || (x.Rne != null && x.Rne.Contains(searchText)) || (x.Cei != null && x.Cei.Contains(searchText))).ToList();
+ }
+
+ internal async Task<List<Cliente>> BuscarClienteEmpresa(string value)
+ {
+ return await Task.Run(() => new BaseServico().BuscarClienteEmpresa(value));
+ }
+
+ internal async Task<List<Cliente>> BuscarCliente(string value, List<long> vinculos = null, TipoFiltroCliente tipoFiltroCliente = 2)
+ {
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ return await new ClienteServico().BuscarCliente(value, vinculos, tipoFiltroCliente);
+ }
+
+ internal async Task<List<Cliente>> BuscarClienteVinculo(string value, long id)
+ {
+ return await Task.Run(() => new ClienteServico().BuscarClienteVinculo(value, id));
+ }
+
+ internal async Task<List<Profissao>> BuscarProfissao(string value)
+ {
+ return await Task.Run(() => new BaseServico().BuscarProfissao(value));
+ }
+
+ internal async Task<List<Atividade>> BuscarAtividade(string value)
+ {
+ return await Task.Run(() => new BaseServico().BuscarAtividade(value));
+ }
+
+ internal async Task<List<Fabricante>> BuscaFabricante(string value)
+ {
+ return await Task.Run(() => new BaseServico().BuscarFabricante(value));
+ }
+
+ internal async Task<List<Usuario>> BuscarUsuario(string value)
+ {
+ return await Task.Run(() => new BaseServico().BuscarUsuario(value));
+ }
+
+ internal async Task ShowDetalheExtrato(List<DetalheExtrato> detalhes)
+ {
+ DialogHost host = GetHost();
+ if (host == null || !host.IsOpen)
+ {
+ DialogDetalheExtrato dialogControl = new DialogDetalheExtrato(detalhes);
+ await ExecuteRunExtendedDialogDetalheExtrato((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+ }
+
+ public async Task ExecuteRunExtendedDialogDetalheExtrato(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ }
+
+ internal async Task<Fipe> ShowBuscaModeloDialog(string modelo, string ano)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ BuscarModeloView dialogControl = new BuscarModeloView(new BuscarModeloViewModel(modelo, ano));
+ return await ExecuteRunExtendedDialogBuscaModelo((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task ShowEditarParcelasDialog(Documento documento)
+ {
+ DialogHost host = GetHost();
+ if (host == null || !host.IsOpen)
+ {
+ DialogEditarParcelas dialogControl = new DialogEditarParcelas(documento);
+ await ExecuteRunExtendedDialogEditarParcelas((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+ }
+
+ public async Task ExecuteRunExtendedDialogEditarParcelas(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ }
+
+ internal async Task<string> ShowObservacaoDialog()
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogObservacao dialogControl = new DialogObservacao();
+ return await ExecuteRunExtendedDialogObservacao((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<string> ExecuteRunExtendedDialogObservacao(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (string)obj;
+ }
+
+ public async Task<Fipe> ExecuteRunExtendedDialogBuscaModelo(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Fipe)obj;
+ }
+
+ internal async Task<VinculoRepasse> ShowVinculoDialog(VinculoRepasse vinculo, List<Repasse> repasses, Repasse repasse)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogVinculo dialogControl = new DialogVinculo(vinculo, repasses, repasse);
+ return await ExecuteRunExtendedDialogVinculo((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<VinculoRepasse> ExecuteRunExtendedDialogVinculo(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (VinculoRepasse)obj;
+ }
+
+ internal async Task<Tarefa> ShowTarefaDialog(Tarefa tarefa, bool nota = false, bool agendamento = false)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ List<TelefoneBase> telefones = new List<TelefoneBase>();
+ if (tarefa != null && tarefa.IdCliente > 0)
+ {
+ telefones = (await new ClienteServico().BuscarTelefonesAsync(tarefa.IdCliente)).Where((ClienteTelefone x) => ValidationHelper.ValidacaoTelefone(((TelefoneBase)x).Numero)).Select((Func<ClienteTelefone, TelefoneBase>)((ClienteTelefone x) => new TelefoneBase
+ {
+ Tipo = ((TelefoneBase)x).Tipo,
+ Id = ((DomainBase)x).Id,
+ Numero = ((TelefoneBase)x).Numero,
+ Prefixo = ((TelefoneBase)x).Prefixo
+ })).ToList();
+ }
+ DialogTarefa dialogControl = new DialogTarefa(tarefa, telefones, nota, agendamento);
+ return await ExecuteRunExtendedDialogTarefa((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task<ObservableCollection<Item>> ShowSelecionarItensDialog(long id)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogSelecionarItens dialogControl = new DialogSelecionarItens(id);
+ return await ExecuteRunExtendedDialogSelecionarItens((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task<ObservableCollection<Item>> ShowReordenarItensDialog(List<long> ids)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogReordenarItens dialogControl = new DialogReordenarItens(ids);
+ return await ExecuteRunExtendedDialogReordenarItens((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task<List<Documento>> ShowProtocoloDialog(List<Documento> itens)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogProtocolo dialogControl = new DialogProtocolo(itens);
+ return await ExecuteRunExtendedDialogProtocolo((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<List<Documento>> ExecuteRunExtendedDialogProtocolo(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj == null || obj is bool)
+ {
+ return null;
+ }
+ return ((ObservableCollection<Documento>)obj).ToList();
+ }
+
+ public async Task<ObservableCollection<Item>> ExecuteRunExtendedDialogReordenarItens(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj == null || obj is bool)
+ {
+ return null;
+ }
+ return (ObservableCollection<Item>)obj;
+ }
+
+ public async Task<ObservableCollection<Item>> ExecuteRunExtendedDialogSelecionarItens(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (ObservableCollection<Item>)obj;
+ }
+
+ internal async Task<Tuple<List<PermissaoUsuario>, Usuario, List<RestricaoUsuario>, List<PermissaoArquivoDigital>, List<RestricaoUsuarioCamposRelatorios>>> ShowCopiarPermissaoDialog()
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogCopiarPermissao dialogControl = new DialogCopiarPermissao(new DialogCopiarPermissaoViewModel());
+ return await ExecuteRunExtendedDialogCopiarPermiss((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task<List<Usuario>> ShowExportarPermissaoDialog(long idUsuario)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogExportarPermissao dialogControl = new DialogExportarPermissao(new DialogExportarPermissaoViewModel(idUsuario));
+ return await ExecuteRunExtendedDialogExportarPermiss((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task ShowLogAcessoDialog(TipoTela tela, Usuario usuario)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ DialogHost host = GetHost();
+ if (host == null || !host.IsOpen)
+ {
+ DialogLogAcesso dialogControl = new DialogLogAcesso(tela, usuario);
+ await ExecuteRunExtendedDialogEnviarEmails((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+ }
+
+ public async Task ExecuteRunExtendedDialogLogAcesso(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ }
+
+ internal async Task ShowEnviarEmailsDialog(List<MalaDireta> lista, bool assinatura, bool original, List<ArquivoDigital> arquivosAnexados, string assunto, string corpo, Credencial credencial, FiltroArquivoDigital filtro, bool salvarAd, bool confirmarLeitura)
+ {
+ DialogHost host = GetHost();
+ if (host == null || !host.IsOpen)
+ {
+ DialogEnviarEmails dialogControl = new DialogEnviarEmails(new DialogEnviarEmailsViewModel(lista, assinatura, original, arquivosAnexados, assunto, corpo, credencial, filtro, salvarAd, confirmarLeitura));
+ await ExecuteRunExtendedDialogEnviarEmails((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+ }
+
+ internal async Task<PesquisaAvancada> ShowPesquisaAvancadaDialog()
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogPesquisaAvancadaViewModel dialogPesquisaAvancadaViewModel = new DialogPesquisaAvancadaViewModel();
+ DialogPesquisaAvancada dialogPesquisaAvancada = new DialogPesquisaAvancada(dialogPesquisaAvancadaViewModel);
+ ((FrameworkElement)dialogPesquisaAvancada).DataContext = dialogPesquisaAvancadaViewModel;
+ DialogPesquisaAvancada dialogControl = dialogPesquisaAvancada;
+ return await ExecuteRunExtendedDialogPesquisaAvancada((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Tarefa> ExecuteRunExtendedDialogTarefa(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Tarefa)obj;
+ }
+
+ public async Task<Tuple<List<PermissaoUsuario>, Usuario, List<RestricaoUsuario>, List<PermissaoArquivoDigital>, List<RestricaoUsuarioCamposRelatorios>>> ExecuteRunExtendedDialogCopiarPermiss(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Tuple<List<PermissaoUsuario>, Usuario, List<RestricaoUsuario>, List<PermissaoArquivoDigital>, List<RestricaoUsuarioCamposRelatorios>>)obj;
+ }
+
+ public async Task<List<Usuario>> ExecuteRunExtendedDialogExportarPermiss(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (List<Usuario>)obj;
+ }
+
+ public async Task ExecuteRunExtendedDialogEnviarEmails(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ }
+
+ public async Task<PesquisaAvancada> ExecuteRunExtendedDialogPesquisaAvancada(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (PesquisaAvancada)obj;
+ }
+
+ public async Task<Documento> CarregaApolice(long id)
+ {
+ return await new ApoliceServico().BuscarApoliceAsync(id);
+ }
+
+ public async Task<Cliente> CarregaCliente(long id)
+ {
+ return await new ClienteServico().BuscarClienteAsync(id);
+ }
+
+ public async Task<Sinistro> CarregaSinistroApolice(long id)
+ {
+ return await new SinistroServico().BuscarSinistro(id);
+ }
+
+ public async Task<Documento> CarregaApoliceParcela(long id)
+ {
+ return await new ParcelaServico().BuscarApolice(id);
+ }
+
+ public async Task<Parcela> CarregaParcela(long id)
+ {
+ return await new ParcelaServico().BuscarParcela(id);
+ }
+
+ public async Task<Prospeccao> CarregarProspeccao(long id)
+ {
+ return await new ProspeccaoServico().BuscarProspeccao(id);
+ }
+
+ public async Task<List<Item>> CarregarItem(long id, StatusItem status = 2)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ return (await new ItemServico().BuscarItens(id, status)).ToList();
+ }
+
+ public async Task<string> CreateLinkAssistencia(Documento documento, string item, bool retorno = true)
+ {
+ if (documento == null)
+ {
+ return "";
+ }
+ return $"{Address.Assistance}{((DomainBase)documento).Id.GeraAssistencia()}";
+ }
+
+ public async Task<string> CreateCardLogo(Empresa empresa, string id = null)
+ {
+ if (empresa == null)
+ {
+ return "";
+ }
+ Logo logo = new Logo
+ {
+ CustomId = ApplicationHelper.NumeroSerial,
+ Data = empresa.Logo,
+ Corretora = ((!string.IsNullOrEmpty(empresa.NomeSocial)) ? empresa.NomeSocial : empresa.Nome),
+ Whatsapp = empresa.Whatsapp,
+ WhatsappSinistro = empresa.WhatsappSinistro
+ };
+ string text = ((!string.IsNullOrWhiteSpace(id)) ? (await logo.Atualizarlogo(id)) : (await logo.Criarlogo()));
+ id = text;
+ return id;
+ }
+
+ public async Task<string> CreateSeguradora(Seguradora seguradora, string id = null)
+ {
+ if (seguradora == null)
+ {
+ return "";
+ }
+ int index = 1;
+ AssistenciaCia assistencia = new AssistenciaCia
+ {
+ Seguradora = seguradora.Nome,
+ IdSeguradora = ((DomainBase)seguradora).Id,
+ LinkAppAndroid = seguradora.LinkAppAndroid,
+ LinkAppIos = seguradora.LinkAppIos,
+ CustomId = ApplicationHelper.NumeroSerial
+ };
+ seguradora.Contatos.OrderBy((SeguradoraContato x) => ((object)((TelefoneBase)x).Tipo.GetValueOrDefault((TipoTelefone)7)).GetType()).ToList().ForEach(delegate(SeguradoraContato x)
+ {
+ //IL_0121: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0208: Unknown result type (might be due to invalid IL or missing references)
+ //IL_02ef: 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_0160: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0167: Invalid comparison between Unknown and I4
+ //IL_014e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0155: Invalid comparison between Unknown and I4
+ //IL_0247: Unknown result type (might be due to invalid IL or missing references)
+ //IL_024e: Invalid comparison between Unknown and I4
+ //IL_0235: Unknown result type (might be due to invalid IL or missing references)
+ //IL_023c: Invalid comparison between Unknown and I4
+ //IL_032e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0335: Invalid comparison between Unknown and I4
+ //IL_031c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0323: Invalid comparison between Unknown and I4
+ //IL_0079: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0080: Invalid comparison between Unknown and I4
+ //IL_0067: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006e: Invalid comparison between Unknown and I4
+ //IL_0172: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0178: Invalid comparison between Unknown and I4
+ //IL_0259: Unknown result type (might be due to invalid IL or missing references)
+ //IL_025f: Invalid comparison between Unknown and I4
+ //IL_0340: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0346: Invalid comparison between Unknown and I4
+ //IL_008b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0091: Invalid comparison between Unknown and I4
+ switch (index)
+ {
+ default:
+ assistencia.Assistencia1Tipo = ((!((TelefoneBase)x).Tipo.HasValue) ? 10 : ((int)((TelefoneBase)x).Tipo.Value));
+ assistencia.Assistencia1 = ((((TelefoneBase)x).Tipo.HasValue && (int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 10) ? ("0800-" + ((TelefoneBase)x).Numero) : (((int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 11) ? ("0300-" + ((TelefoneBase)x).Numero) : (((int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 7 && string.IsNullOrEmpty(((TelefoneBase)x).Prefixo)) ? ((TelefoneBase)x).Numero : ("(" + ((TelefoneBase)x).Prefixo + ") " + ((TelefoneBase)x).Numero))));
+ assistencia.Assistencia1Obs = x.NomeContato;
+ break;
+ case 2:
+ assistencia.Assistencia2Tipo = ((!((TelefoneBase)x).Tipo.HasValue) ? 10 : ((int)((TelefoneBase)x).Tipo.Value));
+ assistencia.Assistencia2 = ((((TelefoneBase)x).Tipo.HasValue && (int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 10) ? ("0800-" + ((TelefoneBase)x).Numero) : (((int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 11) ? ("0300-" + ((TelefoneBase)x).Numero) : (((int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 7 && string.IsNullOrEmpty(((TelefoneBase)x).Prefixo)) ? ((TelefoneBase)x).Numero : ("(" + ((TelefoneBase)x).Prefixo + ") " + ((TelefoneBase)x).Numero))));
+ assistencia.Assistencia2Obs = x.NomeContato;
+ break;
+ case 3:
+ assistencia.Assistencia3Tipo = ((!((TelefoneBase)x).Tipo.HasValue) ? 10 : ((int)((TelefoneBase)x).Tipo.Value));
+ assistencia.Assistencia3 = ((((TelefoneBase)x).Tipo.HasValue && (int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 10) ? ("0800-" + ((TelefoneBase)x).Numero) : (((int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 11) ? ("0300-" + ((TelefoneBase)x).Numero) : (((int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 7 && string.IsNullOrEmpty(((TelefoneBase)x).Prefixo)) ? ((TelefoneBase)x).Numero : ("(" + ((TelefoneBase)x).Prefixo + ") " + ((TelefoneBase)x).Numero))));
+ assistencia.Assistencia3Obs = x.NomeContato;
+ break;
+ case 4:
+ assistencia.Assistencia4Tipo = ((!((TelefoneBase)x).Tipo.HasValue) ? 10 : ((int)((TelefoneBase)x).Tipo.Value));
+ assistencia.Assistencia4 = ((((TelefoneBase)x).Tipo.HasValue && (int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 10) ? ("0800-" + ((TelefoneBase)x).Numero) : (((int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 11) ? ("0300-" + ((TelefoneBase)x).Numero) : (((int)((TelefoneBase)x).Tipo.GetValueOrDefault() == 7 && string.IsNullOrEmpty(((TelefoneBase)x).Prefixo)) ? ((TelefoneBase)x).Numero : ("(" + ((TelefoneBase)x).Prefixo + ") " + ((TelefoneBase)x).Numero))));
+ assistencia.Assistencia4Obs = x.NomeContato;
+ break;
+ }
+ index++;
+ });
+ string text = ((!string.IsNullOrWhiteSpace(id)) ? (await assistencia.AtualizarSeguradora(id)) : (await assistencia.CriarSeguradora()));
+ id = text;
+ return id;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/BaseTarefaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/BaseTarefaViewModel.cs
new file mode 100644
index 0000000..8f2eb16
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/BaseTarefaViewModel.cs
@@ -0,0 +1,105 @@
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public abstract class BaseTarefaViewModel : BaseSegurosViewModel
+{
+ private ObservableCollection<ResponsavelTarefa> _responsaveis = new ObservableCollection<ResponsavelTarefa>();
+
+ private bool _hasResponsaveis;
+
+ public TarefaServico Servico { get; set; }
+
+ public abstract Tarefa SelectedTarefa { get; set; }
+
+ public abstract bool EnableAlterarTarefa { get; set; }
+
+ public ObservableCollection<ResponsavelTarefa> Responsaveis
+ {
+ get
+ {
+ return _responsaveis;
+ }
+ set
+ {
+ _responsaveis = value;
+ HasResponsaveis = value != null && value.Count > 0;
+ OnPropertyChanged("Responsaveis");
+ }
+ }
+
+ public bool HasResponsaveis
+ {
+ get
+ {
+ return _hasResponsaveis;
+ }
+ set
+ {
+ _hasResponsaveis = value;
+ OnPropertyChanged("HasResponsaveis");
+ }
+ }
+
+ public async Task<bool> ValidaPermissaoParaEditarTarefa()
+ {
+ bool flag = false;
+ bool flag3;
+ if (SelectedTarefa == null)
+ {
+ BaseTarefaViewModel baseTarefaViewModel = this;
+ BaseTarefaViewModel baseTarefaViewModel2 = this;
+ flag3 = (EnableAlterarTarefa = flag);
+ bool enableAlterar = (baseTarefaViewModel2.EnableExcluir = flag3);
+ baseTarefaViewModel.EnableAlterar = enableAlterar;
+ return flag;
+ }
+ PermissaoUsuario val = await BuscaPermisaoUsuario();
+ flag = Recursos.Usuario.Administrador || (val == null && !SelectedTarefa.Restrito.GetValueOrDefault()) || ((val == null || val.Alterar) && (!SelectedTarefa.Restrito.GetValueOrDefault() || ((DomainBase)SelectedTarefa.UsuarioCadastro).Id == ((DomainBase)Recursos.Usuario).Id || (SelectedTarefa.Responsaveis?.Any((ResponsavelTarefa x) => ((DomainBase)x.Usuario).Id == ((DomainBase)Recursos.Usuario).Id) ?? false) || ((DomainBase)SelectedTarefa.Usuario).Id == ((DomainBase)Recursos.Usuario).Id));
+ BaseTarefaViewModel baseTarefaViewModel3 = this;
+ BaseTarefaViewModel baseTarefaViewModel4 = this;
+ bool flag6 = (EnableAlterarTarefa = flag);
+ flag3 = (baseTarefaViewModel4.EnableExcluir = flag6);
+ return baseTarefaViewModel3.EnableAlterar = flag3;
+ }
+
+ internal async Task<PermissaoUsuario> BuscaPermisaoUsuario()
+ {
+ return await new PermissaoUsuarioServico().VerificarPermissao(Recursos.Usuario, (TipoTela)38);
+ }
+
+ public async Task<bool> ValidaPermissaoParaExcluirTarefa(Tarefa tarefa = null)
+ {
+ if (tarefa != null)
+ {
+ SelectedTarefa = tarefa;
+ }
+ PermissaoUsuario val = await BuscaPermisaoUsuario();
+ return Recursos.Usuario.Administrador || (val == null && !SelectedTarefa.Restrito.GetValueOrDefault()) || ((val == null || val.Excluir) && (!SelectedTarefa.Restrito.GetValueOrDefault() || ((DomainBase)SelectedTarefa.UsuarioCadastro).Id == ((DomainBase)Recursos.Usuario).Id || (SelectedTarefa.Responsaveis?.Any((ResponsavelTarefa x) => ((DomainBase)x.Usuario).Id == ((DomainBase)Recursos.Usuario).Id) ?? false) || ((DomainBase)SelectedTarefa.Usuario).Id == ((DomainBase)Recursos.Usuario).Id));
+ }
+
+ public void ListaUsuariosResponsaveis()
+ {
+ //IL_0035: 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_004b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0061: Expected O, but got Unknown
+ Tarefa selectedTarefa = SelectedTarefa;
+ if (((selectedTarefa != null) ? selectedTarefa.Usuario : null) != null && !Responsaveis.Any((ResponsavelTarefa r) => ((DomainBase)r.Usuario).Id == ((DomainBase)SelectedTarefa.Usuario).Id))
+ {
+ Responsaveis.Insert(0, new ResponsavelTarefa
+ {
+ IdTarefa = ((DomainBase)SelectedTarefa).Id,
+ Usuario = SelectedTarefa.Usuario
+ });
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs
new file mode 100644
index 0000000..d48c992
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/BaseViewModel.cs
@@ -0,0 +1,2102 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+using System.Windows.Threading;
+using Agger.Registro;
+using Gestor.Application.Actions;
+using Gestor.Application.Componentes;
+using Gestor.Application.Drawers;
+using Gestor.Application.Helpers;
+using Gestor.Application.Model;
+using Gestor.Application.Properties;
+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.Common.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Aggilizador;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.MalaDireta;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.License;
+using MaterialDesignThemes.Wpf;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Xceed.Wpf.AvalonDock.Controls;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public abstract class BaseViewModel : INotifyPropertyChanged
+{
+ public ArquivoDigitalServico ArquivoDigitalServico;
+
+ public PermissaoArquivoDigitalServico ServicoPermissArquivoDigital;
+
+ public PermissaoUsuarioServico ServicoPermissUsuario;
+
+ public RestricaoUsuarioServico ServicoRestriUsuario;
+
+ public VendedorUsuarioServico ServicoVendedorUsuario;
+
+ public bool _incluirPermissEnabled;
+
+ public bool _alterarPermissEnabled;
+
+ public bool _excluirPermissEnabled;
+
+ public long LastAccessId;
+
+ public TipoTela LastAccessTela;
+
+ private bool _enableButtons = true;
+
+ private bool _enableIncluir = true;
+
+ private bool _isVisibleEmpresa;
+
+ private bool _enableAlterar;
+
+ private bool _enableExcluir;
+
+ private long? _lastId;
+
+ private bool _incluirParcelaEnabled;
+
+ private bool _alterarParcelaEnabled;
+
+ private bool _excluirParcelaEnabled;
+
+ private bool _permissaoWhatsapp;
+
+ public bool Initialized;
+
+ private bool _enableFields;
+
+ private bool _allowEditParcela;
+
+ private bool _isEnableEdit;
+
+ private bool _isEnabledEditEndosso;
+
+ private bool _enableMenu;
+
+ private bool _enableMainMenu;
+
+ private bool _isEnabled;
+
+ private Visibility _isVisible;
+
+ private object _popupContent;
+
+ public bool EnableButtons
+ {
+ get
+ {
+ return _enableButtons;
+ }
+ set
+ {
+ _enableButtons = value;
+ OnPropertyChanged("EnableButtons");
+ }
+ }
+
+ public bool EnableIncluir
+ {
+ get
+ {
+ return _enableIncluir;
+ }
+ set
+ {
+ _enableIncluir = _incluirPermissEnabled && value;
+ OnPropertyChanged("EnableIncluir");
+ }
+ }
+
+ public bool IsVisibleEmpresa
+ {
+ get
+ {
+ return _isVisibleEmpresa;
+ }
+ set
+ {
+ _isVisibleEmpresa = value;
+ OnPropertyChanged("IsVisibleEmpresa");
+ }
+ }
+
+ public bool EnableAlterar
+ {
+ get
+ {
+ return _enableAlterar;
+ }
+ set
+ {
+ _enableAlterar = _alterarPermissEnabled && value;
+ OnPropertyChanged("EnableAlterar");
+ }
+ }
+
+ public bool EnableExcluir
+ {
+ get
+ {
+ return _enableExcluir;
+ }
+ set
+ {
+ _enableExcluir = _excluirPermissEnabled && value;
+ OnPropertyChanged("EnableExcluir");
+ }
+ }
+
+ public bool IncluirParcelaEnabled
+ {
+ get
+ {
+ return _incluirParcelaEnabled;
+ }
+ set
+ {
+ _incluirParcelaEnabled = value;
+ OnPropertyChanged("IncluirParcelaEnabled");
+ }
+ }
+
+ public bool AlterarParcelaEnabled
+ {
+ get
+ {
+ return _alterarParcelaEnabled;
+ }
+ set
+ {
+ _alterarParcelaEnabled = value;
+ OnPropertyChanged("AlterarParcelaEnabled");
+ }
+ }
+
+ public bool ExcluirParcelaEnabled
+ {
+ get
+ {
+ return _excluirParcelaEnabled;
+ }
+ set
+ {
+ _excluirParcelaEnabled = value;
+ OnPropertyChanged("ExcluirParcelaEnabled");
+ }
+ }
+
+ public bool PermissaoWhatsapp
+ {
+ get
+ {
+ return _permissaoWhatsapp;
+ }
+ set
+ {
+ _permissaoWhatsapp = value;
+ OnPropertyChanged("PermissaoWhatsapp");
+ }
+ }
+
+ public bool EnableFields
+ {
+ get
+ {
+ return _enableFields;
+ }
+ set
+ {
+ _enableFields = value;
+ OnPropertyChanged("EnableFields");
+ }
+ }
+
+ public bool AllowEditParcela
+ {
+ get
+ {
+ return _allowEditParcela;
+ }
+ set
+ {
+ _allowEditParcela = value;
+ OnPropertyChanged("AllowEditParcela");
+ }
+ }
+
+ public bool IsEnabledEdit
+ {
+ get
+ {
+ return _isEnableEdit;
+ }
+ set
+ {
+ _isEnableEdit = value;
+ OnPropertyChanged("IsEnabledEdit");
+ }
+ }
+
+ public bool IsEnabledEditEndosso
+ {
+ get
+ {
+ return _isEnabledEditEndosso;
+ }
+ set
+ {
+ _isEnabledEditEndosso = value;
+ OnPropertyChanged("IsEnabledEditEndosso");
+ }
+ }
+
+ public bool EnableMenu
+ {
+ get
+ {
+ return _enableMenu;
+ }
+ set
+ {
+ _enableMenu = value;
+ OnPropertyChanged("EnableMenu");
+ }
+ }
+
+ public bool EnableMainMenu
+ {
+ get
+ {
+ return _enableMainMenu;
+ }
+ set
+ {
+ _enableMainMenu = value;
+ OnPropertyChanged("EnableMainMenu");
+ }
+ }
+
+ public bool IsEnabled
+ {
+ get
+ {
+ return _isEnabled;
+ }
+ set
+ {
+ _isEnabled = value;
+ OnPropertyChanged("IsEnabled");
+ }
+ }
+
+ public Visibility IsVisible
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisible;
+ }
+ 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)
+ _isVisible = value;
+ OnPropertyChanged("IsVisible");
+ }
+ }
+
+ public string ErroCamposInvalidos { get; }
+
+ public object PopupContent
+ {
+ get
+ {
+ return _popupContent;
+ }
+ set
+ {
+ _popupContent = value;
+ OnPropertyChanged("PopupContent");
+ }
+ }
+
+ public AutoCompleteFilterPredicate<object> CoberturaItemFilter => (string searchText, object obj) => ((CoberturaPadrao)obj).Descricao.ToUpper().Contains(searchText.ToUpper());
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected BaseViewModel()
+ {
+ //IL_00b3: Unknown result type (might be due to invalid IL or missing references)
+ int isVisibleEmpresa;
+ if (LicenseHelper.Produtos != null && LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 2 && x.Status == 1))
+ {
+ Empresa empresa = Recursos.Empresa;
+ isVisibleEmpresa = ((empresa != null && ((DomainBase)empresa).Id == 1) ? 1 : 0);
+ }
+ else
+ {
+ isVisibleEmpresa = 0;
+ }
+ _isVisibleEmpresa = (byte)isVisibleEmpresa != 0;
+ _enableAlterar = true;
+ _enableExcluir = true;
+ _permissaoWhatsapp = true;
+ _allowEditParcela = true;
+ _isEnableEdit = true;
+ _isEnabledEditEndosso = true;
+ Usuario usuario = Recursos.Usuario;
+ _enableMenu = usuario != null && ((DomainBase)usuario).Id > 0;
+ _enableMainMenu = true;
+ _isEnabled = true;
+ _isVisible = (Visibility)2;
+ ErroCamposInvalidos = "HÁ CAMPOS DESTACADOS QUE DEVEM SER PREENCHIDOS CORRETAMENTE." + Environment.NewLine + "REALIZE A CORREÇÃO E TENTE NOVAMENTE.";
+ base._002Ector();
+ ArquivoDigitalServico = new ArquivoDigitalServico();
+ Gestor.Application.Actions.Actions.EnableMainMenu = (Action<bool>)Delegate.Combine(Gestor.Application.Actions.Actions.EnableMainMenu, new Action<bool>(HabilitarMenu));
+ Gestor.Application.Actions.Actions.EnableMenu = (Action<bool>)Delegate.Combine(Gestor.Application.Actions.Actions.EnableMenu, new Action<bool>(HabilitarMenuSecundario));
+ ServicoPermissArquivoDigital = new PermissaoArquivoDigitalServico();
+ ServicoPermissUsuario = new PermissaoUsuarioServico();
+ ServicoRestriUsuario = new RestricaoUsuarioServico();
+ ServicoVendedorUsuario = new VendedorUsuarioServico();
+ }
+
+ public void VerificarEnables(long? id)
+ {
+ _lastId = id;
+ EnableIncluir = !id.HasValue || id.Value >= 0;
+ EnableAlterar = id.HasValue && id.Value > 0;
+ EnableExcluir = id.HasValue && id.Value > 0;
+ EnableButtons = id.HasValue && id.Value > 0;
+ }
+
+ public async Task<bool> PermissaoConsultar(TipoTela tela)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ return true;
+ }
+ PermissaoUsuario obj = await ServicoPermissUsuario.VerificarPermissao(Recursos.Usuario, tela);
+ return obj == null || obj.Consultar;
+ }
+
+ public async Task PermissaoTela(TipoTela tela)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ EnableIncluir = false;
+ EnableAlterar = false;
+ EnableExcluir = false;
+ if (((DomainBase)Recursos.Usuario).Id != 0L)
+ {
+ PermissaoUsuario val = await ServicoPermissUsuario.VerificarPermissao(Recursos.Usuario, tela);
+ if ((int)tela == 5)
+ {
+ IncluirParcelaEnabled = val == null || val.Incluir;
+ AlterarParcelaEnabled = val == null || val.Alterar;
+ ExcluirParcelaEnabled = val == null || val.Excluir;
+ }
+ else if ((int)tela == 24 || (int)tela == 26 || (int)tela == 29 || (int)tela == 28 || (int)tela == 27)
+ {
+ _incluirPermissEnabled = true;
+ _alterarPermissEnabled = true;
+ _excluirPermissEnabled = true;
+ }
+ else
+ {
+ _incluirPermissEnabled = val == null || val.Incluir;
+ _alterarPermissEnabled = val == null || val.Alterar;
+ _excluirPermissEnabled = val == null || val.Excluir;
+ }
+ }
+ }
+
+ public async Task PermissaoArquivoDigital(TipoArquivoDigital tela)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ EnableIncluir = false;
+ EnableExcluir = false;
+ if (((DomainBase)Recursos.Usuario).Id != 0L)
+ {
+ PermissaoArquivoDigital val = await ServicoPermissArquivoDigital.VerificarPermissao(Recursos.Usuario, tela);
+ _incluirPermissEnabled = val == null || val.Incluir;
+ _excluirPermissEnabled = val == null || val.Excluir;
+ }
+ }
+
+ public async Task VerificarVersao()
+ {
+ bool flag;
+ try
+ {
+ string text = await Connection.Get<string>($"Update/Stable?versao={ApplicationHelper.Versao}");
+ flag = text != null && bool.Parse(text);
+ }
+ catch (Exception e)
+ {
+ new BaseServico().Registrar(e, (TipoErro)287, 3, ApplicationHelper.Versao.ToString(), abrirTela: false);
+ flag = false;
+ }
+ if (!flag)
+ {
+ ApplicationHelper.ChecagemVersao = Funcoes.GetNetworkTime();
+ return;
+ }
+ await ShowMessage("HÁ UMA ATUALIZAÇÃO OBRIGATÓRIA A SER FEITA. O PROCESSO SERÁ CANCELADO PARA A ATUALIZAÇÃO");
+ Application.Current.Shutdown();
+ }
+
+ public async void Alterar(bool alterar)
+ {
+ Gestor.Application.Actions.Actions.EnablePesquisarClientes?.Invoke(!alterar);
+ Gestor.Application.Actions.Actions.EnableMenu?.Invoke(!alterar);
+ Gestor.Application.Actions.Actions.EnableMainMenu?.Invoke(!alterar);
+ EnableFields = alterar;
+ EnableMenu = !alterar;
+ if (!alterar)
+ {
+ VerificarEnables(_lastId);
+ }
+ else
+ {
+ EnableIncluir = false;
+ EnableAlterar = false;
+ EnableExcluir = false;
+ EnableButtons = false;
+ }
+ AllowEditParcela = !alterar;
+ IsEnabledEdit = !alterar;
+ IsEnabledEditEndosso = !alterar;
+ if ((Funcoes.GetNetworkTime() - ApplicationHelper.ChecagemVersao).TotalMinutes > 10.0)
+ {
+ await VerificarVersao();
+ }
+ }
+
+ private void HabilitarMenu(bool enable)
+ {
+ EnableMainMenu = enable;
+ }
+
+ private void HabilitarMenuSecundario(bool enable)
+ {
+ EnableMenu = enable;
+ }
+
+ public void OnPropertyChanged([CallerMemberName] string name = "")
+ {
+ this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
+ }
+
+ public void Loading(bool isLoading)
+ {
+ Grid progressRing = App.ProgressRing;
+ if (progressRing == null)
+ {
+ return;
+ }
+ Dispatcher dispatcher = ((DispatcherObject)progressRing).Dispatcher;
+ if (dispatcher != null)
+ {
+ dispatcher.BeginInvoke((DispatcherPriority)4, (Delegate)(Action)delegate
+ {
+ LoadingThread(isLoading);
+ });
+ }
+ }
+
+ public void LoadingThread(bool isLoading)
+ {
+ IsVisible = (Visibility)(isLoading ? 2 : 0);
+ ((UIElement)App.ProgressRing).Visibility = (Visibility)((!isLoading) ? 2 : 0);
+ IsEnabled = !isLoading;
+ }
+
+ public async Task<EnderecoBase> BuscaCep(string cep)
+ {
+ return await new CepService().SearchDirect(cep);
+ }
+
+ internal void ShowDrawer(object content, int position, bool close = true)
+ {
+ Window? obj = ((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive));
+ DrawerHost val = Extentions.FindVisualChildren<DrawerHost>((DependencyObject)(object)obj).FirstOrDefault();
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)obj).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ if (val == null)
+ {
+ return;
+ }
+ switch (position)
+ {
+ case 1:
+ val.TopDrawerContent = content;
+ val.IsTopDrawerOpen = true;
+ val.TopDrawerCloseOnClickAway = close;
+ return;
+ case 2:
+ val.LeftDrawerContent = content;
+ val.IsLeftDrawerOpen = true;
+ val.LeftDrawerCloseOnClickAway = close;
+ return;
+ case 3:
+ val.BottomDrawerContent = content;
+ val.IsBottomDrawerOpen = true;
+ val.BottomDrawerCloseOnClickAway = close;
+ return;
+ }
+ if (val.IsRightDrawerOpen && (val.RightDrawerContent == null || val.RightDrawerContent.GetType() != content.GetType()))
+ {
+ val.LeftDrawerContent = content;
+ val.IsLeftDrawerOpen = true;
+ val.LeftDrawerCloseOnClickAway = close;
+ }
+ else
+ {
+ val.IsRightDrawerOpen = true;
+ val.RightDrawerContent = content;
+ val.RightDrawerCloseOnClickAway = close;
+ }
+ }
+
+ internal void CloseDrawer()
+ {
+ Window? obj = ((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive));
+ DrawerHost val = Extentions.FindVisualChildren<DrawerHost>((DependencyObject)(object)obj).FirstOrDefault();
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)obj).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)0;
+ });
+ if (val != null)
+ {
+ val.IsBottomDrawerOpen = false;
+ val.IsTopDrawerOpen = false;
+ if (val.IsLeftDrawerOpen)
+ {
+ val.IsLeftDrawerOpen = false;
+ }
+ else
+ {
+ val.IsRightDrawerOpen = false;
+ }
+ }
+ }
+
+ internal DialogHost GetHost()
+ {
+ DialogHost val = Extentions.FindVisualChildren<DialogHost>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).FirstOrDefault();
+ if (val == null)
+ {
+ foreach (Window item in ((IEnumerable)Application.Current.Windows).OfType<Window>())
+ {
+ val = Extentions.FindVisualChildren<DialogHost>((DependencyObject)(object)item).FirstOrDefault();
+ if (val != null && !val.IsOpen)
+ {
+ break;
+ }
+ }
+ }
+ if (val == null || !val.IsOpen)
+ {
+ return val;
+ }
+ return null;
+ }
+
+ internal async Task<bool> ShowMessage(string message, string accept = "OK", string cancel = "", bool root = false)
+ {
+ DialogHost val = null;
+ if (!root)
+ {
+ val = GetHost();
+ if (val == null)
+ {
+ return false;
+ }
+ }
+ DefaultDialog defaultDialog = new DefaultDialog();
+ ((FrameworkElement)defaultDialog).DataContext = new DialogViewModel
+ {
+ AcceptContent = accept,
+ CancelContent = cancel,
+ Message = message
+ };
+ DefaultDialog dialogControl = defaultDialog;
+ return await ExecuteRunExtendedDialog((UserControl)(object)dialogControl, (val != null) ? val.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task<ConfiguracaoImpressao> ShowDialogPrint(Relatorio relatorio, Type tipo)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogPrint dialogControl = new DialogPrint(relatorio, tipo);
+ return await ExecuteRunExtendedDialogPrint((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<ConfiguracaoImpressao> ExecuteRunExtendedDialogPrint(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ return (ConfiguracaoImpressao)(await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler)));
+ }
+
+ internal async Task<List<ArquivoDigital>> ShowDialogAnexar(List<ArquivoDigital> arquivos, bool root = false)
+ {
+ DialogHost val = null;
+ if (!root)
+ {
+ val = GetHost();
+ if (val != null && val.IsOpen)
+ {
+ return arquivos;
+ }
+ }
+ DialogAnexar dialogControl = new DialogAnexar(arquivos);
+ return await ExecuteRunExtendedDialogAnexar((UserControl)(object)dialogControl, (val != null) ? val.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<List<ArquivoDigital>> ExecuteRunExtendedDialogAnexar(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ return (List<ArquivoDigital>)(await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandlerArquivo)));
+ }
+
+ internal async Task ShowDialogAdvertising(bool root = false)
+ {
+ _ = 1;
+ try
+ {
+ DialogHost host = null;
+ if (!root)
+ {
+ host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return;
+ }
+ }
+ DialogAdvertising dialogAdvertising = await CreateDialogAdvertising();
+ if (dialogAdvertising != null)
+ {
+ await ExecuteRunExtendedDialogAdvertising((UserControl)(object)dialogAdvertising, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+ }
+ catch
+ {
+ }
+ }
+
+ private async Task<DialogAdvertising> CreateDialogAdvertising()
+ {
+ JObject val = await LoadJsonAdvertising(Address.SurveyJson);
+ if (val == null)
+ {
+ return await LoadDialogAdertisingPromo();
+ }
+ JToken obj = val["Inicio"];
+ DateTime? dateTime = ((obj != null) ? new DateTime?(Extensions.Value<DateTime>((IEnumerable<JToken>)obj)) : null);
+ JToken obj2 = val["Fim"];
+ DateTime? dateTime2 = ((obj2 != null) ? new DateTime?(Extensions.Value<DateTime>((IEnumerable<JToken>)obj2)) : null);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Gestor.Application.Model.Configuracoes configuracoes = LoadConfiguracoes();
+ JToken obj3 = val["UrlPost"];
+ string text = ((obj3 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj3) : null);
+ if (ValidationHelper.IsNullOrEmpty(text))
+ {
+ JToken obj4 = val["UrlFixa"];
+ text = ((obj4 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj4) : null) ?? string.Empty;
+ }
+ if (configuracoes.LinkPromo == text || configuracoes.NaoverPromo)
+ {
+ return null;
+ }
+ return (!(dateTime2 >= networkTime) || !(dateTime <= networkTime)) ? (await LoadDialogAdertisingPromo()) : new DialogAdvertising(val, isPromo: false);
+ }
+
+ private Gestor.Application.Model.Configuracoes LoadConfiguracoes()
+ {
+ CriarConfiguracaoPadrao("config.json");
+ return JsonConvert.DeserializeObject<Gestor.Application.Model.Configuracoes>(File.ReadAllText("config.json"));
+ }
+
+ private async Task<DialogAdvertising> LoadDialogAdertisingPromo()
+ {
+ Gestor.Application.Model.Configuracoes config = LoadConfiguracoes();
+ JObject val = await LoadJsonAdvertising(Address.JsonPromo());
+ if (val == null)
+ {
+ return null;
+ }
+ JToken obj = val["Imagem"];
+ string text = ((obj != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj) : null) ?? string.Empty;
+ if (config.LinkPromo == text || config.NaoverPromo)
+ {
+ return null;
+ }
+ return new DialogAdvertising(val);
+ }
+
+ private async Task<JObject> LoadJsonAdvertising(Uri location)
+ {
+ HttpClient client = new HttpClient();
+ try
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ client.Timeout = TimeSpan.FromSeconds(20.0);
+ HttpResponseMessage val = await client.GetAsync(location);
+ return (!val.IsSuccessStatusCode) ? null : JObject.Parse(await val.Content.ReadAsStringAsync());
+ }
+ finally
+ {
+ ((IDisposable)client)?.Dispose();
+ }
+ }
+
+ private void CriarConfiguracaoPadrao(string configFile)
+ {
+ if (!File.Exists(configFile))
+ {
+ Gestor.Application.Model.Configuracoes configuracoes = new Gestor.Application.Model.Configuracoes
+ {
+ LinkPromo = "",
+ NaoverPromo = false
+ };
+ File.WriteAllText(configFile, JsonConvert.SerializeObject((object)configuracoes, (Formatting)1));
+ }
+ }
+
+ public async Task ExecuteRunExtendedDialogAdvertising(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandlerArquivo));
+ }
+
+ internal async Task<bool> ShowMessage(List<KeyValuePair<string, string>> pairs, string message, string accept, string cancel = "")
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return false;
+ }
+ ErrorDialog errorDialog = new ErrorDialog();
+ ((FrameworkElement)errorDialog).DataContext = new ErrorDialogViewModel
+ {
+ Erros = pairs.Select((KeyValuePair<string, string> pair) => new KeyValuePair<string, string>(pair.Key.Contains("|") ? pair.Key.Substring(pair.Key.IndexOf("|", StringComparison.Ordinal) + 1) : pair.Key, pair.Value)).ToList(),
+ AcceptContent = accept,
+ CancelContent = cancel,
+ Message = message
+ };
+ ErrorDialog dialogControl = errorDialog;
+ return await ExecuteRunExtendedDialog((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task ShowMedalha(int liquido, int comissao, int resultado, int media)
+ {
+ DialogHost host = GetHost();
+ if (host == null || !host.IsOpen)
+ {
+ DialogMedalha dialogControl = new DialogMedalha(liquido, comissao, resultado, media);
+ await ExecuteRunExtendedDialog((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+ }
+
+ internal async Task<bool?> ShowSenha(string mensagem)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return false;
+ }
+ DialogSenhaAdm dialogControl = new DialogSenhaAdm(mensagem);
+ return await ExecuteRunExtendedDialogSenha((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ internal async Task<Instalacao> ShowInstalacoes(List<Instalacao> instalacoes)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogInstalacoes dialogControl = new DialogInstalacoes(instalacoes);
+ return await ExecuteRunExtendedDialogInstalacoes((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Instalacao> ExecuteRunExtendedDialogInstalacoes(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ object obj2 = obj;
+ if (obj2 == null || (obj2 is bool && !(bool)obj2))
+ {
+ return null;
+ }
+ return (Instalacao)obj;
+ }
+
+ internal async Task<Prospeccao> ShowProspeccaoDialog(Prospeccao prospecao)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ ProspeccaoDialog dialogControl = new ProspeccaoDialog(prospecao);
+ return await ExecuteRunExtendedDialogProspeccao((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Prospeccao> ExecuteRunExtendedDialogProspeccao(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Prospeccao)obj;
+ }
+
+ public async Task<bool> ExecuteRunExtendedDialog(UserControl dialogControl, string hostName)
+ {
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ DialogHost.CloseDialogCommand.Execute((object)null, (IInputElement)null);
+ return obj != null && (bool)obj;
+ }
+
+ public async Task<bool?> ExecuteRunExtendedDialogSenha(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ return (bool?)(await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler)));
+ }
+
+ public void ExtendedOpenedEventHandler(object sender, DialogOpenedEventArgs eventargs)
+ {
+ IsEnabled = false;
+ }
+
+ public void ExtendedClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
+ {
+ IsEnabled = true;
+ Window? obj = ((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive));
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)obj).ToList().ForEach(delegate(WebEditor x)
+ {
+ if (!x.IsReadOnly)
+ {
+ ((UIElement)x).Visibility = (Visibility)0;
+ }
+ });
+ Extentions.FindVisualChildren<DrawerHost>((DependencyObject)(object)obj).Any((DrawerHost x) => x.IsLeftDrawerOpen || x.IsBottomDrawerOpen || x.IsRightDrawerOpen || x.IsTopDrawerOpen);
+ }
+
+ public void ExtendedClosingEventHandlerArquivo(object sender, DialogClosingEventArgs eventArgs)
+ {
+ IsEnabled = true;
+ Extentions.FindVisualChildren<DrawerHost>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).Any((DrawerHost x) => x.IsLeftDrawerOpen || x.IsBottomDrawerOpen || x.IsRightDrawerOpen || x.IsTopDrawerOpen);
+ }
+
+ public void ToggleSnackBar(string message, bool active = true)
+ {
+ Snackbar val = Extentions.FindVisualChildren<Snackbar>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).FirstOrDefault();
+ if (val != null)
+ {
+ ((ContentControl)val.Message).Content = message;
+ val.IsActive = active;
+ if (active)
+ {
+ Task.Factory.StartNew(CloseSlackBar);
+ }
+ }
+ }
+
+ private void CloseSlackBar()
+ {
+ Thread.Sleep(5000);
+ Dispatcher dispatcher = ((DispatcherObject)App.ProgressRing).Dispatcher;
+ if (dispatcher != null)
+ {
+ dispatcher.BeginInvoke((DispatcherPriority)4, (Delegate)(Action)delegate
+ {
+ ToggleSnackBar("", active: false);
+ });
+ }
+ }
+
+ public async Task<List<string>> ValidateAttachment(List<ArquivoDigital> attachments, List<string> files)
+ {
+ string message = ("Os Arquivos Abaixo não podem ser anexados pois não possuem Formatos válidos, são maiores que o permitido ou já foram anexados!" + Environment.NewLine + Environment.NewLine).ToUpper();
+ List<string> result = new List<string>();
+ bool error = false;
+ foreach (string x in files)
+ {
+ try
+ {
+ if (attachments?.Exists(delegate(ArquivoDigital a)
+ {
+ string text2 = ValidationHelper.RemoveDiacritics(a.Descricao.ToUpper());
+ string? fileNameWithoutExtension = Path.GetFileNameWithoutExtension(x);
+ return text2 == ((fileNameWithoutExtension != null) ? ValidationHelper.RemoveDiacritics(fileNameWithoutExtension.ToUpper()) : null);
+ }) ?? false)
+ {
+ message += Path.GetFileName(x);
+ error = true;
+ continue;
+ }
+ FileInfo fileInfo = new FileInfo(x);
+ if (fileInfo.Length > 1024 && fileInfo.Length / 1024 > ((Recursos.Empresa.MaxFileSize > 0) ? Recursos.Empresa.MaxFileSize : 14336))
+ {
+ message += Path.GetFileName(x);
+ error = true;
+ continue;
+ }
+ string text = Path.GetExtension(x)?.ToLower();
+ if (text != null)
+ {
+ int length = text.Length;
+ if (length != 4)
+ {
+ if (length == 5)
+ {
+ switch (text[2])
+ {
+ case 'o':
+ break;
+ case 'l':
+ goto IL_0341;
+ case 'p':
+ goto IL_0351;
+ case 's':
+ goto IL_0361;
+ default:
+ goto IL_036f;
+ }
+ if (text == ".docx")
+ {
+ goto IL_038d;
+ }
+ }
+ }
+ else
+ {
+ switch (text[1])
+ {
+ case 't':
+ break;
+ case 'd':
+ goto IL_0243;
+ case 'x':
+ goto IL_0259;
+ case 'j':
+ goto IL_026f;
+ case 'p':
+ goto IL_0285;
+ case 'b':
+ goto IL_02ac;
+ case 'z':
+ goto IL_02c2;
+ case 'r':
+ goto IL_02d8;
+ case 'm':
+ goto IL_02ee;
+ case 'e':
+ goto IL_0301;
+ case 'a':
+ goto IL_0311;
+ case 'o':
+ goto IL_0321;
+ default:
+ goto IL_036f;
+ }
+ if (text == ".txt")
+ {
+ goto IL_038d;
+ }
+ }
+ }
+ goto IL_036f;
+ IL_0285:
+ if (!(text == ".png") && !(text == ".pdf"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_026f:
+ if (!(text == ".jpg"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0311:
+ if (!(text == ".amr"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_02d8:
+ if (!(text == ".rar"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0321:
+ if (!(text == ".ogg"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0301:
+ if (!(text == ".eml"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_02ac:
+ if (!(text == ".bmp"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0243:
+ if (!(text == ".doc"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_02ee:
+ if (!(text == ".msg"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0361:
+ if (!(text == ".json"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_038d:
+ result.Add(x);
+ goto end_IL_0080;
+ IL_0341:
+ if (!(text == ".xlsx"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_036f:
+ message += Path.GetFileName(x);
+ goto end_IL_0080;
+ IL_0351:
+ if (!(text == ".jpeg"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_0259:
+ if (!(text == ".xls"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ IL_02c2:
+ if (!(text == ".zip"))
+ {
+ goto IL_036f;
+ }
+ goto IL_038d;
+ end_IL_0080:;
+ }
+ catch (Exception)
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL CARREGAR O ARQUIVO " + x + "." + Environment.NewLine + "O ARQUIVO ESTÁ INACESSÍVEL OU SENDO UTILIZADO POR OUTRO PROCESSO.");
+ }
+ }
+ if (error)
+ {
+ await ShowMessage((message + Environment.NewLine + Environment.NewLine + "Favor Corrija antes de tentar novamente.").ToUpper());
+ }
+ return result;
+ }
+
+ public async Task<List<ArquivoDigital>> AddAttachments(List<ArquivoDigital> attachments, List<ArquivoDigital> attacheds)
+ {
+ List<string> list = new List<string>();
+ OpenFileDialog val = new OpenFileDialog();
+ try
+ {
+ val.Multiselect = true;
+ ((FileDialog)val).Filter = "Todos os Arquivos|*.pdf;*.jpg;*.jpeg;*.png;*.bmp;*.doc;*.docx;*.xls;*.xlsx;*.json;*.rar;*.zip;*.msg;*.eml;*.txt|Arquivos PDF|*.pdf|Imagens|*.jpg;*.jpeg;*.png;*.bmp|Documentos|*.doc;*.docx;*.msg|Planilhas|*.xls;*.xlsx|Arquivos do Aggilizador|*.json|Arquivos de Áudio|*.amr;*.ogg";
+ ((FileDialog)val).InitialDirectory = Environment.SpecialFolder.Desktop.ToString();
+ if (1 != (int)((CommonDialog)val).ShowDialog())
+ {
+ return null;
+ }
+ list.AddRange(((FileDialog)val).FileNames);
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ list = await ValidateAttachment(attacheds, await ValidateAttachment(attachments, list));
+ attachments = new List<ArquivoDigital>();
+ foreach (string item2 in list)
+ {
+ try
+ {
+ string extension = Path.GetExtension(item2);
+ using MemoryStream memoryStream = new MemoryStream(File.ReadAllBytes(item2));
+ byte[] array = new byte[memoryStream.Length];
+ memoryStream.Position = 0L;
+ memoryStream.Read(array, 0, array.Length);
+ ArquivoDigital item = new ArquivoDigital
+ {
+ Arquivo = array,
+ Descricao = Path.GetFileNameWithoutExtension(item2),
+ Extensao = extension
+ };
+ attachments.Add(item);
+ }
+ catch (Exception)
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL CARREGAR O ARQUIVO " + item2 + "." + Environment.NewLine + "O ARQUIVO ESTÁ INACESSÍVEL OU SENDO UTILIZADO POR OUTRO PROCESSO.");
+ }
+ }
+ return (attachments.Count == 0) ? null : attachments;
+ }
+
+ public async void Download(IndiceArquivoDigital indice, bool open = true)
+ {
+ if (((DomainBase)indice).Id == 0L)
+ {
+ return;
+ }
+ ArquivoDigital arquivo = null;
+ if (indice.Assinado)
+ {
+ ArquivoDigital val = await ArquivoDigitalServico.BuscarPorId(((DomainBase)indice).Id);
+ if (((val != null) ? val.Arquivo : null) != null)
+ {
+ if (!val.Extensao.Contains("."))
+ {
+ val.Extensao = "." + val.Extensao;
+ }
+ arquivo = val;
+ }
+ }
+ if (arquivo == null)
+ {
+ arquivo = await ArquivoDigitalServico.BuscarPorId(indice.IdArquivoDigital, indice.Bd);
+ }
+ ArquivoDigital obj = arquivo;
+ if (((obj != null) ? obj.Arquivo : null) == null || arquivo.Extensao == null)
+ {
+ string text = "DOCUMENTO NÃO POSSUI PDF";
+ if (indice.DataCriacao?.Year <= DateTime.Now.Year - 5)
+ {
+ text += " OU POR SER UM ARQUIVO ANTIGO, TENTE NOVAMENTE EM ALGUNS MINUTOS";
+ }
+ await ShowMessage(text + ".");
+ return;
+ }
+ if (open)
+ {
+ if (Abrir(indice, arquivo))
+ {
+ return;
+ }
+ await ShowMessage("NÃO FOI POSSÍVEL ABRIR O ARQUIVO. ESCOLHA UM LOCAL PARA SALVAR O ARQUIVO.");
+ }
+ SaveFileDialog sfd = new SaveFileDialog();
+ try
+ {
+ ((FileDialog)sfd).Filter = "All Files|*.*";
+ ((FileDialog)sfd).FileName = indice.Descricao;
+ if (1 != (int)((CommonDialog)sfd).ShowDialog())
+ {
+ return;
+ }
+ if (File.Exists(((FileDialog)sfd).FileName + ValidationHelper.GetDefaultExtension(arquivo.Extensao)))
+ {
+ await ShowMessage("JÁ EXISTE UM ARQUIVO COM O NOME DE " + arquivo.Descricao + ValidationHelper.GetDefaultExtension(arquivo.Extensao) + " NA PASTA SELECIONADA. " + Environment.NewLine + "TENTE NOVAMENTE EM OUTRA PASTA.");
+ return;
+ }
+ using BinaryWriter binaryWriter = new BinaryWriter(File.Open(((FileDialog)sfd).FileName + ValidationHelper.GetDefaultExtension(arquivo.Extensao), FileMode.Create));
+ binaryWriter.Write(arquivo.Arquivo);
+ }
+ finally
+ {
+ ((IDisposable)sfd)?.Dispose();
+ }
+ }
+
+ public async Task<string> Salvar(IndiceArquivoDigital indice)
+ {
+ if (((DomainBase)indice).Id == 0L)
+ {
+ return null;
+ }
+ ArquivoDigital val = await ArquivoDigitalServico.BuscarPorId(indice.IdArquivoDigital, indice.Bd);
+ if (((val != null) ? val.Arquivo : null) == null || val.Extensao == null)
+ {
+ return null;
+ }
+ string tempPath = Path.GetTempPath();
+ string text = $"{tempPath}{val.AzureGuid ?? Guid.NewGuid()}{ValidationHelper.GetDefaultExtension(val.Extensao)}";
+ using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(text, FileMode.Create)))
+ {
+ binaryWriter.Write(val.Arquivo);
+ }
+ return text;
+ }
+
+ public bool Abrir(IndiceArquivoDigital indice, ArquivoDigital arquivo)
+ {
+ string tempPath = Path.GetTempPath();
+ string text = $"{tempPath}{arquivo.AzureGuid ?? Guid.NewGuid()}{ValidationHelper.GetDefaultExtension(arquivo.Extensao)}";
+ try
+ {
+ using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(text, FileMode.Create)))
+ {
+ binaryWriter.Write(arquivo.Arquivo);
+ }
+ Process.Start(text);
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public async Task<bool> DownloadAll(List<IndiceArquivoDigital> indices, long id)
+ {
+ FolderBrowserDialog val = new FolderBrowserDialog();
+ string selectedPath;
+ try
+ {
+ if (1 != (int)((CommonDialog)val).ShowDialog())
+ {
+ return false;
+ }
+ selectedPath = $"{val.SelectedPath}\\{id}";
+ Directory.CreateDirectory(selectedPath);
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ int count = 1;
+ foreach (IndiceArquivoDigital indice in indices)
+ {
+ ArquivoDigital arquivo = null;
+ if (indice.Assinado)
+ {
+ ArquivoDigital val2 = await ArquivoDigitalServico.BuscarPorId(((DomainBase)indice).Id);
+ if (((val2 != null) ? val2.Arquivo : null) != null)
+ {
+ arquivo = val2;
+ }
+ }
+ if (arquivo == null)
+ {
+ arquivo = await ArquivoDigitalServico.BuscarPorId(indice.IdArquivoDigital, indice.Bd);
+ }
+ ArquivoDigital obj = arquivo;
+ if (((obj != null) ? obj.Arquivo : null) == null || arquivo.Extensao == null)
+ {
+ return false;
+ }
+ if (File.Exists(ValidationHelper.NormalizePath(selectedPath + "\\" + indice.Descricao + ValidationHelper.GetDefaultExtension(arquivo.Extensao))))
+ {
+ indice.Descricao = $"{indice.Descricao}_{count}";
+ count++;
+ }
+ using BinaryWriter binaryWriter = new BinaryWriter(File.Open(ValidationHelper.NormalizePath(selectedPath + "\\" + indice.Descricao + ValidationHelper.GetDefaultExtension(arquivo.Extensao)), FileMode.Create));
+ binaryWriter.Write(arquivo.Arquivo);
+ }
+ Process.Start(selectedPath);
+ return true;
+ }
+
+ public async Task DownloadAll(List<long> ids, TipoArquivoVinculo type)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (ids == null || ids.Count == 0)
+ {
+ return;
+ }
+ string selectedPath = $"{Path.GetTempPath()}{Guid.NewGuid()}";
+ BaseServico baseServico = new BaseServico();
+ ArquivoDigitalServico attachment = new ArquivoDigitalServico();
+ List<ArquivoVinculo> arquivos = await baseServico.ArquivoVinculo(ids, type);
+ int count = 1;
+ if (!Directory.Exists(selectedPath))
+ {
+ Directory.CreateDirectory(selectedPath);
+ }
+ foreach (ArquivoVinculo item in await attachment.BaixarArquivosPendentes(arquivos))
+ {
+ if (((item != null) ? item.Arquivo : null) != null)
+ {
+ string text = Guid.NewGuid().ToString();
+ if (File.Exists(selectedPath + "\\" + text + ".pdf"))
+ {
+ text = $"{text}_{count}";
+ count++;
+ }
+ using BinaryWriter binaryWriter = new BinaryWriter(File.Open(selectedPath + "\\" + text + ".pdf", FileMode.Create));
+ binaryWriter.Write(item.Arquivo);
+ }
+ }
+ Process.Start(selectedPath);
+ }
+
+ internal async Task<List<Banco>> BuscarBanco(string value)
+ {
+ return await Task.Run(() => new BaseServico().BuscarBanco(value));
+ }
+
+ public bool Restricao(TipoRestricao tipoRestricao)
+ {
+ //IL_0019: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ return false;
+ }
+ RestricaoUsuario val = ServicoRestriUsuario.BuscarRestricao(Recursos.Usuario, tipoRestricao);
+ if (val != null)
+ {
+ return val.Restricao;
+ }
+ return false;
+ }
+
+ public bool Permissao(TipoTela tipoTela)
+ {
+ //IL_0019: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ return false;
+ }
+ PermissaoUsuario val = ServicoPermissUsuario.BuscarPermissao(Recursos.Usuario, tipoTela);
+ if (val != null)
+ {
+ return val.Consultar;
+ }
+ return true;
+ }
+
+ public async Task<List<VendedorUsuario>> VerificaVinculoVendedor(Usuario usuario)
+ {
+ if (usuario == null || ((DomainBase)usuario).Id == 0L)
+ {
+ return new List<VendedorUsuario>();
+ }
+ return await ServicoVendedorUsuario.FindByVinculo(usuario);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> SalvarProspeccao(Prospeccao prospecao)
+ {
+ List<KeyValuePair<string, string>> list = prospecao.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ List<ArquivoDigital> anexos = prospecao.Anexos;
+ if (((DomainBase)prospecao.Tarefa).Id == 0L)
+ {
+ prospecao.Tarefa.Cliente = prospecao.Nome;
+ prospecao.Tarefa.Titulo = "PROSPECÇÃO " + prospecao.VigenciaFinal?.ToString("d");
+ prospecao.Tarefa.Referencia = prospecao.Item;
+ prospecao.Tarefa.Descricao = $"{Recursos.Usuario.Nome} {Funcoes.GetNetworkTime():g} {Environment.NewLine}{prospecao.Observacao}";
+ }
+ Prospeccao prosccaoSalva = await new ProspeccaoServico().Salvar(prospecao);
+ if (anexos != null && anexos.Count > 0)
+ {
+ await SalvarAttachments(anexos, (TipoArquivoDigital)11, ((DomainBase)prosccaoSalva).Id);
+ }
+ if (prosccaoSalva.Tarefa != null && prospecao.AbrirTarefa && prosccaoSalva != null && ((DomainBase)prosccaoSalva).Id > 0)
+ {
+ Tarefa tarefa = prosccaoSalva.Tarefa;
+ ShowDrawer(new TarefaDrawer(tarefa), 0, close: false);
+ }
+ return null;
+ }
+
+ public async Task<bool> VerificarRestricao(TipoRestricao tipoRestricao, bool root = false, bool showmessage = true)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ return true;
+ }
+ RestricaoUsuario val = ServicoRestriUsuario.BuscarRestricao(Recursos.Usuario, tipoRestricao);
+ if (val == null || !val.Restricao)
+ {
+ return true;
+ }
+ if (showmessage)
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR ESSA TELA. CONTATE O ADMINISTRADOR DO SISTEMA.", "OK", "", root);
+ }
+ return false;
+ }
+
+ public async Task<bool> VerificarPermissao(TipoTela tela, bool root = false)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (await PermissaoConsultar(tela))
+ {
+ return true;
+ }
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR ESSA TELA. CONTATE O ADIMINSTRADOR DO SISTEMA.", "OK", "", root);
+ return false;
+ }
+
+ public async Task<bool> VerificarContrato(Produto produto, bool message = true, bool root = false)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if ((int)produto == 79)
+ {
+ if (LicenseHelper.Produtos.Exists((Licenca x) => (int)x.Produto == 91 && x.AcessoLiberado))
+ {
+ return true;
+ }
+ if (LicenseHelper.Produtos.Exists((Licenca x) => (int)x.Produto == 81 && x.AcessoLiberado))
+ {
+ return true;
+ }
+ if (LicenseHelper.Produtos.Exists((Licenca x) => (int)x.Produto == 77 && x.AcessoLiberado))
+ {
+ return true;
+ }
+ }
+ if (LicenseHelper.Produtos != null && LicenseHelper.Produtos.Exists((Licenca x) => x.Produto == produto && x.AcessoLiberado))
+ {
+ return true;
+ }
+ if (message)
+ {
+ Licenca val = LicenseHelper.Produtos?.FirstOrDefault((Func<Licenca, bool>)((Licenca x) => x.Produto == produto));
+ await ShowMessage((val == null) ? ("VOCÊ NÃO POSSUI O MÓDULO " + EnumHelper.GetDescription<Produto>(produto) + " CONTRATADO") : ("ACESSO AO MÓDULO " + EnumHelper.GetDescription<Produto>(produto) + " INTERROMPIDO"), "OK", "", root);
+ }
+ return false;
+ }
+
+ internal async Task<List<NotaFiscal>> ShowExtratoComissaoDialog(List<Seguradora> seguradoras)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogExtratoComissao dialogControl = new DialogExtratoComissao(seguradoras);
+ return await ExecuteRunExtendedDialogExtratoComissao((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<List<NotaFiscal>> ExecuteRunExtendedDialogExtratoComissao(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (List<NotaFiscal>)obj;
+ }
+
+ internal async Task<Cliente> ShowCopiarCliente()
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogCopiarCliente dialogControl = new DialogCopiarCliente();
+ return await ExecuteRunExtendedDialogCopiarCliente((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Cliente> ExecuteRunExtendedDialogCopiarCliente(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Cliente)obj;
+ }
+
+ internal async Task<Copia> ShowCopiaDialog(Copia copia)
+ {
+ DialogHost host = GetHost();
+ if (host != null && host.IsOpen)
+ {
+ return null;
+ }
+ DialogCopia dialogControl = new DialogCopia(copia);
+ return await ExecuteRunExtendedDialogCopia((UserControl)(object)dialogControl, (host != null) ? host.Identifier.ToString() : "RootDialog");
+ }
+
+ public async Task<Copia> ExecuteRunExtendedDialogCopia(UserControl dialogControl, string hostName)
+ {
+ Extentions.FindVisualChildren<WebEditor>((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x)
+ {
+ ((UIElement)x).Visibility = (Visibility)2;
+ });
+ object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(ExtendedOpenedEventHandler), new DialogClosingEventHandler(ExtendedClosingEventHandler));
+ if (obj is bool)
+ {
+ return null;
+ }
+ return (Copia)obj;
+ }
+
+ public async void AbrirLog(TipoTela tipoTela, long id)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ ShowDrawer(new LogDrawer(tipoTela, id), 0, close: false);
+ return;
+ }
+ RestricaoUsuario val = ServicoRestriUsuario.BuscarRestricao(Recursos.Usuario, (TipoRestricao)109);
+ if (val == null || !val.Restricao)
+ {
+ ShowDrawer(new LogDrawer(tipoTela, id), 0, close: false);
+ }
+ else
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR OS LOGS");
+ }
+ }
+
+ public async void AbrirLogParcela(List<long> parcelas, long documento, int numparcela = 0)
+ {
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ ShowDrawer(new LogDrawer((TipoTela)5, documento, parcelas, numparcela), 0, close: false);
+ return;
+ }
+ RestricaoUsuario val = ServicoRestriUsuario.BuscarRestricao(Recursos.Usuario, (TipoRestricao)109);
+ if (val == null || !val.Restricao)
+ {
+ ShowDrawer(new LogDrawer((TipoTela)5, documento, parcelas, numparcela), 0, close: false);
+ }
+ else
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR OS LOGS");
+ }
+ }
+
+ public async void AbrirLogEmail(TipoTela tela, long id)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ ShowDrawer(new LogEmailDrawer(tela, id), 0, close: false);
+ return;
+ }
+ RestricaoUsuario val = ServicoRestriUsuario.BuscarRestricao(Recursos.Usuario, (TipoRestricao)109);
+ if (val == null || !val.Restricao)
+ {
+ ShowDrawer(new LogEmailDrawer(tela, id), 0, close: false);
+ }
+ else
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR OS LOGS");
+ }
+ }
+
+ public async Task ImprimirFornecedor(List<Fornecedor> fornecedores)
+ {
+ new ParcelaServico();
+ string text = "<html><head><title>RELATÓRIO DE FORNECEDORES</title></head><body style='font-size: 12px; font-family: Arial, Helvetica, sans-serif; margin-left: 50px; margin-right: 50px; line-height: 30px;' onload='self.print();'>";
+ text += "<div align='center' style='font-size: 20px;'><strong>RELATÓRIO DE FORNECEDORES</strong></div> <br>";
+ text += "<div class='table-responsive'>";
+ text += "<table align='center' class='table table-bordered' border='1px' style='border-collapse:collapse;' style='width:100%;' style='margin:auto;'>";
+ int num = 1;
+ text += "<tr bgcolor=LightBlue>";
+ text += "<td><strong>NOME</strong></td>";
+ text += "<td><strong>CPF/CNPJ</strong></td>";
+ text += "<td><strong>ENDEREÇO</strong></td>";
+ text += "<td><strong>E-MAIL</strong></td>";
+ text += "<td><strong>TIPO PESSOA</strong></td>";
+ text += "</tr>";
+ foreach (Fornecedor fornecedore in fornecedores)
+ {
+ text = text + "<tr> <td style='padding:10px' bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + fornecedore.Nome + "</td>";
+ text = text + "<td style='padding:10px' bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + fornecedore.Documento + "</td>";
+ text = text + "<td style='padding:10px' bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + ((EnderecoBase)fornecedore).Endereco + "</td>";
+ text = text + "<td style='padding:10px' bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + fornecedore.Email + "</td>";
+ string text2 = ((fornecedore.Documento == null) ? "" : ((ValidationHelper.OnlyNumber(fornecedore.Documento).Length > 11) ? "JURÍDICA" : "FÍSICA"));
+ text = text + "<td style='padding:10px' bgcolor='" + ((num % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + text2 + "</td></tr>";
+ num = ((num != 1) ? (num + 1) : 0);
+ }
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ string nome = Recursos.Usuario.Nome;
+ text += "</table></div>";
+ text += $"Emitido pelo usuário: {nome}, data e hora: {networkTime}.";
+ text += "</body>";
+ string tempPath = Path.GetTempPath();
+ string text3 = $"{tempPath}FORNECEDORES_{networkTime:ddMMyyyyhhmmss}.html";
+ StreamWriter streamWriter = new StreamWriter(text3, append: true, Encoding.UTF8);
+ streamWriter.Write(text);
+ streamWriter.Close();
+ Process.Start(text3);
+ }
+
+ public async Task EmitirCheckList(List<Documento> documentos)
+ {
+ ParcelaServico parcelaServico = new ParcelaServico();
+ string html5 = "<html><head><title>CHECK LIST DE PROTOCOLOS</title></head><body style='font-size: 12px; font-family: Arial, Helvetica, sans-serif; margin-left: 50px; margin-right: 50px; line-height: 30px;' onload='self.print();'>";
+ html5 += "<div align='center' style='font-size: 20px;'><strong>CHECK LIST DE PROTOCOLOS</strong></div> <br>";
+ html5 += "<div class='table-responsive'>";
+ html5 += "<table align='center' class='table table-bordered' border='1px' style='border-collapse:collapse;' style='width:100%;' style='margin:auto;'>";
+ int color = 1;
+ html5 += "<tr bgcolor=LightBlue>";
+ html5 += "<td><strong>CLIENTE</strong></td>";
+ html5 += "<td><strong>APÓLICE</strong></td>";
+ html5 += "<td><strong>1ª PARCELA</strong></td>";
+ html5 += "<td><strong>2ª PARCELA</strong></td>";
+ html5 += "<td><strong>RECEBIDA POR</strong></td>";
+ html5 += "<td><strong>VENDEDOR</strong></td>";
+ html5 += "</tr>";
+ documentos = documentos.OrderBy((Documento x) => x.Controle.Cliente.Nome).ToList();
+ foreach (Documento doc in documentos)
+ {
+ Documento val = doc;
+ val.Parcelas = await parcelaServico.BuscarParcelasAsync(((DomainBase)doc).Id);
+ html5 = html5 + "<tr> <td style='padding:10px' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + doc.Controle.Cliente.Nome + "</td>";
+ html5 = html5 + "<td style='padding:10px' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + doc.Apolice + "</td>";
+ string text = ((doc.Parcelas != null && doc.Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).ToList().Count > 0) ? doc.Parcelas.Where((Parcela x) => x.NumeroParcela == 1).First().Vencimento.Date.ToString("dd/MM/yyyy") : "");
+ html5 = html5 + "<td style='padding:10px' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + text + "</td>";
+ text = ((doc.Parcelas != null && doc.Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).ToList().Count > 1) ? doc.Parcelas.Where((Parcela x) => x.NumeroParcela == 2).First().Vencimento.Date.ToString("dd/MM/yyyy") : "");
+ html5 = html5 + "<td style='padding:10px' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'>" + text + "</td>";
+ html5 = html5 + "<td style='padding:10px' bgcolor='" + ((color % 2 == 0) ? "WhiteSmoke" : "White") + "'>____________/____/___</td>";
+ string[] obj = new string[6]
+ {
+ html5,
+ "<td style='padding:10px' bgcolor='",
+ (color % 2 == 0) ? "WhiteSmoke" : "White",
+ "'>",
+ null,
+ null
+ };
+ Vendedor vendedorPrincipal = doc.VendedorPrincipal;
+ obj[4] = ((vendedorPrincipal != null) ? vendedorPrincipal.Nome : null);
+ obj[5] = "</td></tr>";
+ html5 = string.Concat(obj);
+ color = ((color != 1) ? (color + 1) : 0);
+ }
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ string nome = Recursos.Usuario.Nome;
+ html5 += "</table></div>";
+ html5 = html5 + "<div align='center'><strong>TOTAL DE PROTOCOLOS: " + documentos.Count + "</strong></div>";
+ html5 += $"Emitido pelo usuário: {nome}, data e hora: {networkTime}.";
+ html5 += "</body>";
+ string tempPath = Path.GetTempPath();
+ string text2 = $"{tempPath}{(object)(TipoExtrato)0}CheckList_{networkTime:ddMMyyyyhhmmss}.html";
+ StreamWriter streamWriter = new StreamWriter(text2, append: true, Encoding.UTF8);
+ streamWriter.Write(html5);
+ streamWriter.Close();
+ Process.Start(text2);
+ }
+
+ public async Task EmitirProtocolos(List<Tuple<long, string>> lista, bool doisPorPagina, List<Documento> protocolo)
+ {
+ int multiploDois = 0;
+ DateTime now = Funcoes.GetNetworkTime();
+ int i = 0;
+ StringBuilder pageBuilder = new StringBuilder();
+ StringBuilder protocoloContent = new StringBuilder();
+ foreach (Tuple<long, string> listum in lista)
+ {
+ i++;
+ ApoliceServico apoliceServico = new ApoliceServico();
+ ItemServico itemServico = new ItemServico();
+ ClienteServico cliServico = new ClienteServico();
+ ParcelaServico parcelaServico = new ParcelaServico();
+ Documento apolice = await apoliceServico.BuscarApoliceAsync(listum.Item1);
+ apolice.Controle.Cliente.Telefones = cliServico.BuscarTelefones(((DomainBase)apolice.Controle.Cliente).Id);
+ Cliente cliente = apolice.Controle.Cliente;
+ cliente.Emails = await cliServico.BuscarEmailsAsync(((DomainBase)apolice.Controle.Cliente).Id);
+ cliente = apolice.Controle.Cliente;
+ cliente.Enderecos = await cliServico.BuscarEnderecosAsync(((DomainBase)apolice.Controle.Cliente).Id);
+ if (apolice.VendedorPrincipal == null)
+ {
+ Documento val = apolice;
+ val.VendedorPrincipal = await apoliceServico.BuscarVendedorPrincipal(((DomainBase)apolice.Controle).Id);
+ }
+ ObservableCollection<Item> itens = await itemServico.BuscarItems(((DomainBase)apolice).Id, (StatusItem)2);
+ if (itens == null || itens.Count == 0)
+ {
+ itens = await itemServico.BuscarItens(((DomainBase)apolice.Controle).Id, (StatusItem)3);
+ }
+ ObservableCollection<Parcela> observableCollection = await parcelaServico.BuscarParcelasAsync(((DomainBase)apolice).Id);
+ apolice.ProtocoloEmail = protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloEmail;
+ apolice.ProtocoloTelefone = protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloTelefone;
+ apolice.ProtocoloParcela = protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloParcela;
+ apolice.ProtocoloEndereco = protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloEndereco;
+ apolice.ProtocoloVendedor = protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloVendedor;
+ ObservableCollection<ClienteTelefone> telefones = apolice.Controle.Cliente.Telefones;
+ string text = "Telefone: <b>" + ((apolice.ProtocoloTelefone && telefones != null && telefones.Where((ClienteTelefone t) => !string.IsNullOrEmpty(((TelefoneBase)t).Numero)).Any()) ? string.Join(" | ", (from t in telefones
+ where !string.IsNullOrEmpty(((TelefoneBase)t).Numero)
+ select ((TelefoneBase)t).Prefixo + " " + ((TelefoneBase)t).Numero).ToList()) : null) + "</b>";
+ ClienteEndereco val2 = apolice.Controle.Cliente.Enderecos?.FirstOrDefault();
+ string newValue = (protocolo.Find((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id).ProtocoloEndereco ? ((string.IsNullOrWhiteSpace(((EnderecoBase)val2).Endereco) ? "" : ((EnderecoBase)val2).Endereco) + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Numero) ? "" : ((EnderecoBase)val2).Numero) + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Complemento) ? "" : (" - " + ((EnderecoBase)val2).Complemento)) + " - " + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Bairro) ? "" : ((EnderecoBase)val2).Bairro) + " - " + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Cidade) ? "" : ((EnderecoBase)val2).Cidade) + " - " + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Estado) ? "" : ((EnderecoBase)val2).Estado) + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)val2).Cep) ? "" : ((EnderecoBase)val2).Cep)) : null);
+ ObservableCollection<ClienteEmail> emails = apolice.Controle.Cliente.Emails;
+ bool flag = apolice.ProtocoloEmail && emails != null && emails.Count > 0 && !string.IsNullOrEmpty(((EmailBase)emails.First()).Email);
+ string newValue2 = " Email: <b>" + (flag ? ((EmailBase)emails.First()).Email : null) + "</b>";
+ string newValue3 = ((telefones == null && val2 == null && emails == null) ? "style='display:none;'" : "");
+ string newValue4 = (string.IsNullOrWhiteSpace(apolice.Endosso) ? ", " : (" e<br>endosso de n° <b>" + apolice.Endosso + "</b>, "));
+ string newValue5 = "iniciado em <b>" + (string.IsNullOrWhiteSpace(apolice.Vigencia1.ToShortDateString()) ? "" : apolice.Vigencia1.ToShortDateString()) + "</b> até <b>" + (string.IsNullOrWhiteSpace(apolice.Vigencia2?.ToShortDateString()) ? "" : apolice.Vigencia2?.ToShortDateString()) + "</b>";
+ string newValue6 = ((itens != null && itens.Count > 0) ? ("<b>" + (string.IsNullOrWhiteSpace(itens[0].Descricao) ? "" : itens[0].Descricao) + "</b>") : "");
+ string text2 = "";
+ Documento? obj = ((IEnumerable<Documento>)protocolo).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == ((DomainBase)apolice).Id));
+ string text3 = ((obj != null) ? obj.ObsProtocolo : null);
+ string newValue7 = (string.IsNullOrEmpty(text3) ? "" : ("OBSERVAÇÃO: " + text3));
+ if (apolice.ProtocoloParcela && observableCollection != null && observableCollection.Count > 0)
+ {
+ text2 = ((observableCollection.Count != 1) ? (string.Format("{0} parcelas: vencimento 1ª parcela: <strong>{1}</strong>, ", observableCollection.Count, string.IsNullOrWhiteSpace(observableCollection[0].Vencimento.ToShortDateString()) ? "" : observableCollection[0].Vencimento.ToShortDateString()) + "vencimento 2ª parcela: <strong>" + (string.IsNullOrWhiteSpace(observableCollection[1].Vencimento.ToShortDateString()) ? "" : observableCollection[1].Vencimento.ToShortDateString()) + "</strong>, demais parcelas, vide apólice.") : (text2 + "1 parcela: vencimento <strong>" + (string.IsNullOrWhiteSpace(observableCollection[0].Vencimento.ToShortDateString()) ? "" : observableCollection[0].Vencimento.ToShortDateString()) + "</strong> "));
+ }
+ string text4 = (apolice.ProtocoloVendedor ? apolice.Pasta : null);
+ object obj2;
+ if (!apolice.ProtocoloVendedor)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Vendedor vendedorPrincipal = apolice.VendedorPrincipal;
+ obj2 = ((vendedorPrincipal != null) ? vendedorPrincipal.Nome : null);
+ }
+ string text5 = (string)obj2;
+ string newValue8 = ((text4 != null || text5 != null) ? "" : "style = 'display:none;'");
+ protocoloContent.Append(Resources.ProtocoloTemplate.Replace("{Tamanho}", doisPorPagina ? "12.2cm" : "24.4cm").Replace("{Observacao}", newValue7).Replace("{Nome}", apolice.Controle.Cliente.Nome)
+ .Replace("{Email}", newValue2)
+ .Replace("{DisplayTelefones}", newValue3)
+ .Replace("{Telefones}", (telefones != null) ? text : "")
+ .Replace("{Endereço}", newValue)
+ .Replace("{Ramo}", apolice.Controle.Ramo.Nome)
+ .Replace("{Apolice}", apolice.Apolice)
+ .Replace("{Endosso}", newValue4)
+ .Replace("{Seguradora}", apolice.Controle.Seguradora.Nome)
+ .Replace("{Vigencias}", newValue5)
+ .Replace("{Item}", newValue6)
+ .Replace("{Parcelas}", text2)
+ .Replace("{Pasta}", text4)
+ .Replace("{Vendedor}", text5)
+ .Replace("{DisplayVendedor}", newValue8)
+ .Replace("{NomeCorretora}", Recursos.Empresa.Nome)
+ .Replace("{Usuario}", Recursos.Usuario.Nome)
+ .Replace("{Emissao}", $"{now}"));
+ multiploDois++;
+ if (!doisPorPagina || i == 2)
+ {
+ protocoloContent.Append("<div style='page-break-after: always'></div>");
+ i = 0;
+ }
+ }
+ pageBuilder.Append(Resources.ProtocoloPageTemplate.Replace("{Protocolos}", protocoloContent.ToString()));
+ string tempPath = Path.GetTempPath();
+ string text6 = $"{tempPath}{(object)(TipoExtrato)0}_{now:ddMMyyyyhhmmss}.html";
+ StreamWriter streamWriter = new StreamWriter(text6, append: true, Encoding.UTF8);
+ streamWriter.Write((object?)pageBuilder);
+ streamWriter.Close();
+ Process.Start(text6);
+ RegistrarAcao(string.Format("EMITIU PROTOCOLO DE {0} DOCUMENTO{1}", lista.Count, (lista.Count == 1) ? "" : "S"), 0L, (TipoTela)59, "IDS DOS DOCUMENTOS E SUAS RESPECTIVAS OBSERVAÇÕES:\n" + string.Join("\n", lista.Select((Tuple<long, string> x) => x.Item1 + ": \"" + x.Item2 + "\"")));
+ }
+
+ public async Task<string> VerificarAcesso(long id)
+ {
+ string erro = null;
+ Usuario val = await new UsuarioServico().BuscarUsuarioPorId(id);
+ if (val == null)
+ {
+ return "DADOS DE ACESSO INVÁLIDOS";
+ }
+ List<string> list = new List<string>();
+ List<string> list2 = new List<string> { "SEGUNDAS-FEIRAS", "TERÇAS-FEIRAS", "QUARTAS-FEIRAS", "QUINTAS-FEIRAS", "SEXTAS-FEIRAS", "SÁBADOS", "DOMINGOS" };
+ if (val.Segunda == false)
+ {
+ list.Add("SEGUNDAS-FEIRAS");
+ list2.Remove("SEGUNDAS-FEIRAS");
+ }
+ if (val.Terca == false)
+ {
+ list.Add("TERÇAS-FEIRAS");
+ list2.Remove("TERÇAS-FEIRAS");
+ }
+ if (val.Quarta == false)
+ {
+ list.Add("QUARTAS-FEIRAS");
+ list2.Remove("QUARTAS-FEIRAS");
+ }
+ if (val.Quinta == false)
+ {
+ list.Add("QUINTAS-FEIRAS");
+ list2.Remove("QUINTAS-FEIRAS");
+ }
+ if (val.Sexta == false)
+ {
+ list.Add("SEXTAS-FEIRAS");
+ list2.Remove("SEXTAS-FEIRAS");
+ }
+ if (val.Sabado == false)
+ {
+ list.Add("SÁBADOS");
+ list2.Remove("SÁBADOS");
+ }
+ if (val.Domingo == false)
+ {
+ list.Add("DOMINGOS");
+ list2.Remove("DOMINGOS");
+ }
+ string text;
+ if (list.Count == 7)
+ {
+ text = "RESTRITO TODOS OS DIAS";
+ }
+ else if (list.Count <= 3)
+ {
+ text = "RESTRITO ";
+ for (int i = 0; i < list.Count; i++)
+ {
+ text = ((i >= list.Count - 2) ? ((i != list.Count - 2) ? (text + list[i]) : (text + list[i] + " E ")) : (text + list[i] + ", "));
+ }
+ }
+ else
+ {
+ text = "APENAS PERMITIDO ";
+ for (int j = 0; j < list2.Count; j++)
+ {
+ text = ((j >= list2.Count - 2) ? ((j != list2.Count - 2) ? (text + list2[j]) : (text + list2[j] + " E ")) : (text + list2[j] + ", "));
+ }
+ }
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ switch (networkTime.DayOfWeek)
+ {
+ case DayOfWeek.Monday:
+ if (val.Segunda == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Tuesday:
+ if (val.Terca == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Wednesday:
+ if (val.Quarta == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Thursday:
+ if (val.Quinta == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Friday:
+ if (val.Sexta == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Saturday:
+ if (val.Sabado == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ case DayOfWeek.Sunday:
+ if (val.Domingo == false)
+ {
+ return "ACESSO " + text + ". CONTATE O ADMINISTRADOR DO SISTEMA";
+ }
+ break;
+ }
+ if (val.InicioAcesso.HasValue && val.FimAcesso.HasValue && (networkTime.TimeOfDay <= val.InicioAcesso.Value.TimeOfDay || networkTime.TimeOfDay >= val.FimAcesso.Value.TimeOfDay))
+ {
+ erro = "USUÁRIO COM PERMISSÃO DE ACESSO ENTRE " + val.InicioAcesso.Value.ToShortTimeString() + " E " + val.FimAcesso.Value.ToShortTimeString();
+ }
+ return erro;
+ }
+
+ public void RegistrarAcao(string descricao, long entidadeId, TipoTela? tela = null, object obs = null)
+ {
+ //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_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0013: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001b: Expected O, but got Unknown
+ RegistroAcao log = new RegistroAcao
+ {
+ Descricao = descricao,
+ EntidadeId = entidadeId,
+ Tela = tela
+ };
+ new ApoliceServico().SalvarAcao(log, obs);
+ }
+
+ public void RegistrarAcao(string descricao, Relatorio? relatorio, object obs = null)
+ {
+ //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_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0014: Expected O, but got Unknown
+ RegistroAcao log = new RegistroAcao
+ {
+ Relatorio = relatorio,
+ Descricao = descricao
+ };
+ new ApoliceServico().SalvarAcao(log, obs);
+ }
+
+ public async Task<bool> SalvarAttachments(List<ArquivoDigital> arquivos, TipoArquivoDigital tipoAd, long id)
+ {
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ if (arquivos == null || arquivos.Count == 0)
+ {
+ return false;
+ }
+ arquivos.ForEach(delegate(ArquivoDigital x)
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0008: Invalid comparison between Unknown and I4
+ //IL_001b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0021: Invalid comparison between Unknown and I4
+ //IL_0034: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003a: Invalid comparison between Unknown and I4
+ //IL_004d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0053: Invalid comparison between Unknown and I4
+ //IL_0066: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006c: Invalid comparison between Unknown and I4
+ //IL_007f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0085: Invalid comparison between Unknown and I4
+ //IL_0098: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009f: Invalid comparison between Unknown and I4
+ //IL_00b2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b8: Invalid comparison between Unknown and I4
+ //IL_00cb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d1: Invalid comparison between Unknown and I4
+ //IL_00e4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00eb: Invalid comparison between Unknown and I4
+ //IL_00fe: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0105: Invalid comparison between Unknown and I4
+ //IL_0118: Unknown result type (might be due to invalid IL or missing references)
+ //IL_011f: Invalid comparison between Unknown and I4
+ //IL_0132: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0139: Invalid comparison between Unknown and I4
+ //IL_014c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0153: Invalid comparison between Unknown and I4
+ //IL_0166: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016d: Invalid comparison between Unknown and I4
+ //IL_0180: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0187: Invalid comparison between Unknown and I4
+ x.IdCliente = (((int)tipoAd == 1) ? id : 0);
+ x.IdDocumento = (((int)tipoAd == 2) ? id : 0);
+ x.IdParcela = (((int)tipoAd == 3) ? id : 0);
+ x.IdItem = (((int)tipoAd == 4) ? id : 0);
+ x.IdSinistro = (((int)tipoAd == 5) ? id : 0);
+ x.IdVendedor = (((int)tipoAd == 6) ? id : 0);
+ x.IdUsuario = (((int)tipoAd == 12) ? id : 0);
+ x.IdSeguradora = (((int)tipoAd == 8) ? id : 0);
+ x.IdExtrato = (((int)tipoAd == 7) ? id : 0);
+ x.IdLancamento = (((int)tipoAd == 9) ? id : 0);
+ x.IdFornecedor = (((int)tipoAd == 10) ? id : 0);
+ x.IdProspeccao = (((int)tipoAd == 11) ? id : 0);
+ x.IdSocio = (((int)tipoAd == 14) ? id : 0);
+ x.IdTarefa = (((int)tipoAd == 15) ? id : 0);
+ x.IdNotaFiscal = (((int)tipoAd == 16) ? id : 0);
+ x.IdEstipulante = (((int)tipoAd == 17) ? id : 0);
+ x.IdEmpresa = Recursos.Usuario.IdEmpresa;
+ });
+ TipoArquivoDigital val = tipoAd;
+ switch (val - 1)
+ {
+ default:
+ await ArquivoDigitalServico.Insert(arquivos);
+ if (!ArquivoDigitalServico.Sucesso)
+ {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public double GetWindowHeight()
+ {
+ return ((FrameworkElement)((IEnumerable)Application.Current.Windows).OfType<Window>().SingleOrDefault((Func<Window, bool>)((Window x) => x.IsActive))).ActualHeight;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogAdvertisingViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogAdvertisingViewModel.cs
new file mode 100644
index 0000000..eeacfe2
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogAdvertisingViewModel.cs
@@ -0,0 +1,225 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Windows;
+using Gestor.Application.Helpers;
+using Gestor.Application.Model;
+using Gestor.Common.Validation;
+using Gestor.Model.Domain.Generic;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogAdvertisingViewModel : BaseViewModel
+{
+ private readonly bool _isPromo;
+
+ private string _urlPesquisa;
+
+ private Visibility _visualizarNaoExibirNovamente = (Visibility)1;
+
+ private string _titulo = "";
+
+ private string _imagem = "";
+
+ public string Url = "";
+
+ private bool _naoQuero;
+
+ public Visibility VisualizarNaoExibirNovamente
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visualizarNaoExibirNovamente;
+ }
+ 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)
+ _visualizarNaoExibirNovamente = value;
+ OnPropertyChanged("VisualizarNaoExibirNovamente");
+ }
+ }
+
+ public string Titulo
+ {
+ get
+ {
+ return _titulo;
+ }
+ set
+ {
+ _titulo = value;
+ OnPropertyChanged("Titulo");
+ }
+ }
+
+ public string Imagem
+ {
+ get
+ {
+ return _imagem;
+ }
+ set
+ {
+ _imagem = value;
+ OnPropertyChanged("Imagem");
+ }
+ }
+
+ public bool NaoVer
+ {
+ get
+ {
+ return _naoQuero;
+ }
+ set
+ {
+ _naoQuero = value;
+ OnPropertyChanged("NaoVer");
+ }
+ }
+
+ public DialogAdvertisingViewModel(JObject jsonAd, bool isPromo)
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ bool flag = false;
+ _isPromo = isPromo;
+ if (!_isPromo)
+ {
+ CarregaPesquisa(jsonAd);
+ }
+ else
+ {
+ CarregaImagem(jsonAd);
+ JToken obj = jsonAd["NaoExibirNovamente"];
+ flag = obj == null || Extensions.Value<bool>((IEnumerable<JToken>)obj);
+ }
+ VisualizarNaoExibirNovamente = (Visibility)(!flag);
+ }
+
+ private void CarregaImagem(JObject json)
+ {
+ if (json != null)
+ {
+ JToken obj = json["Titulo"];
+ Titulo = ((obj != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj) : null);
+ JToken obj2 = json["Url"];
+ Url = ((obj2 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj2) : null);
+ JToken obj3 = json["Imagem"];
+ Imagem = ((obj3 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj3) : null);
+ }
+ }
+
+ public void SalvaEditarArquivoConfig(bool visto = false)
+ {
+ if (!File.Exists("config.json"))
+ {
+ CriarConfiguracaoPadrao("config.json");
+ }
+ Gestor.Application.Model.Configuracoes configuracoes = JsonConvert.DeserializeObject<Gestor.Application.Model.Configuracoes>(File.ReadAllText("config.json"));
+ configuracoes.LinkPromo = (_isPromo ? Imagem : _urlPesquisa);
+ configuracoes.NaoverPromo = NaoVer;
+ File.WriteAllText("config.json", JsonConvert.SerializeObject((object)configuracoes, (Formatting)1));
+ }
+
+ public void CriarConfiguracaoPadrao(string configFile)
+ {
+ Gestor.Application.Model.Configuracoes configuracoes = new Gestor.Application.Model.Configuracoes
+ {
+ LinkPromo = "",
+ NaoverPromo = NaoVer
+ };
+ File.WriteAllText(configFile, JsonConvert.SerializeObject((object)configuracoes, (Formatting)1));
+ }
+
+ private void CarregaPesquisa(JObject json)
+ {
+ if (json != null)
+ {
+ JToken obj = json["Titulo"];
+ Titulo = ((obj != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj) : null);
+ JToken obj2 = json["Imagem"];
+ Imagem = ((obj2 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj2) : null);
+ JToken obj3 = json["UrlPost"];
+ _urlPesquisa = ((obj3 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj3) : null);
+ if (!ValidationHelper.IsNotNullOrEmpty(_urlPesquisa))
+ {
+ JToken obj4 = json["UrlFixa"];
+ _urlPesquisa = ((obj4 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj4) : null);
+ Url = _urlPesquisa;
+ }
+ }
+ }
+
+ public void EnviarPesquisa()
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Expected O, but got Unknown
+ try
+ {
+ HttpClient val = new HttpClient();
+ try
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ val.Timeout = TimeSpan.FromSeconds(15.0);
+ ((HttpHeaders)val.DefaultRequestHeaders).TryAddWithoutValidation("company-key", "$2b$10$arV/viDP6N.5KX9sRt/.MOo8Gv5FFvHIx0P6HZyuky51P3ItWBV0u");
+ var content = new
+ {
+ customers = new[]
+ {
+ new
+ {
+ nome = Recursos.Usuario.Nome,
+ email = (ValidationHelper.IsNullOrEmpty(Recursos.Usuario.Email) ? $"{((DomainBase)Recursos.Usuario).Id}-{ApplicationHelper.IdFornecedor}@sememail.com" : Recursos.Usuario.Email),
+ corretora = Recursos.Empresa.NomeSocial,
+ produto = "Gestor",
+ idfornecedor = ApplicationHelper.IdFornecedor
+ }
+ }
+ };
+ HttpResponseMessage result = val.PostAsync(_urlPesquisa, (HttpContent)(object)content.ToHttpContent()).Result;
+ if (!result.IsSuccessStatusCode)
+ {
+ return;
+ }
+ JToken obj = JObject.Parse(result.Content.ReadAsStringAsync().Result)["customers"];
+ object obj2;
+ if (obj == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ JToken obj3 = obj[(object)0];
+ if (obj3 == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ JToken obj4 = obj3[(object)"shortUrl"];
+ obj2 = ((obj4 != null) ? Extensions.Value<string>((IEnumerable<JToken>)obj4) : null);
+ }
+ }
+ string text = (string)obj2;
+ if (!ValidationHelper.IsNullOrEmpty(text))
+ {
+ Url = text;
+ }
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogAnexarViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogAnexarViewModel.cs
new file mode 100644
index 0000000..2c372da
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogAnexarViewModel.cs
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Gestor.Model.Domain.Common;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogAnexarViewModel : BaseViewModel
+{
+ private ObservableCollection<ArquivoDigital> _arquivos = new ObservableCollection<ArquivoDigital>();
+
+ public ObservableCollection<ArquivoDigital> Arquivos
+ {
+ get
+ {
+ return _arquivos;
+ }
+ set
+ {
+ _arquivos = value;
+ OnPropertyChanged("Arquivos");
+ }
+ }
+
+ public DialogAnexarViewModel(List<ArquivoDigital> arquivos)
+ {
+ Arquivos = new ObservableCollection<ArquivoDigital>(arquivos);
+ }
+
+ public void Remover(ArquivoDigital removido)
+ {
+ IEnumerable<ArquivoDigital> collection = Arquivos.Where((ArquivoDigital x) => x.Descricao == removido.Descricao && x.Arquivo.Length == removido.Arquivo.Length);
+ Arquivos = new ObservableCollection<ArquivoDigital>(collection);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogCopiaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogCopiaViewModel.cs
new file mode 100644
index 0000000..87c487a
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogCopiaViewModel.cs
@@ -0,0 +1,162 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Gestor.Model.Domain.MalaDireta;
+using Gestor.Model.Helper;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogCopiaViewModel : BaseViewModel
+{
+ private List<string> _tipoCopia = new List<string> { "CÓPIA COMUM", "CÓPIA OCULTA" };
+
+ private string _tipo;
+
+ private string _copiarPara;
+
+ private Copia _copia;
+
+ private string _erro;
+
+ private ObservableCollection<string> _copiasComuns;
+
+ private ObservableCollection<string> _copiasOcultas;
+
+ public List<string> TipoCopia
+ {
+ get
+ {
+ return _tipoCopia;
+ }
+ set
+ {
+ _tipoCopia = value;
+ OnPropertyChanged("TipoCopia");
+ }
+ }
+
+ public string Tipo
+ {
+ get
+ {
+ return _tipo;
+ }
+ set
+ {
+ _tipo = value;
+ OnPropertyChanged("Tipo");
+ }
+ }
+
+ public string CopiarPara
+ {
+ get
+ {
+ return _copiarPara;
+ }
+ set
+ {
+ _copiarPara = value;
+ OnPropertyChanged("CopiarPara");
+ }
+ }
+
+ public Copia Copia
+ {
+ get
+ {
+ return _copia;
+ }
+ set
+ {
+ _copia = value;
+ OnPropertyChanged("Copia");
+ }
+ }
+
+ public string Erro
+ {
+ get
+ {
+ return _erro;
+ }
+ set
+ {
+ _erro = value;
+ OnPropertyChanged("Erro");
+ }
+ }
+
+ public ObservableCollection<string> CopiasComuns
+ {
+ get
+ {
+ return _copiasComuns;
+ }
+ set
+ {
+ _copiasComuns = value;
+ OnPropertyChanged("CopiasComuns");
+ }
+ }
+
+ public ObservableCollection<string> CopiasOcultas
+ {
+ get
+ {
+ return _copiasOcultas;
+ }
+ set
+ {
+ _copiasOcultas = value;
+ OnPropertyChanged("CopiasOcultas");
+ }
+ }
+
+ public DialogCopiaViewModel(Copia copia)
+ {
+ //IL_003e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0043: 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)
+ Tipo = TipoCopia.First();
+ Copia = (Copia)(((object)copia) ?? ((object)new Copia
+ {
+ CopiaOculta = new List<string>(),
+ CopiaComum = new List<string>()
+ }));
+ CopiasComuns = new ObservableCollection<string>(Copia.CopiaComum);
+ CopiasOcultas = new ObservableCollection<string>(Copia.CopiaOculta);
+ }
+
+ public void AdicionarCopia()
+ {
+ if (!ValidationHelper.ValidacaoEmail(CopiarPara))
+ {
+ Erro = "E-MAIL INVÁLIDO";
+ return;
+ }
+ if (Copia.CopiaOculta.Contains(CopiarPara))
+ {
+ Erro = "E-MAIL JÁ ADICIONADO";
+ return;
+ }
+ Copia.CopiaOculta.Add(CopiarPara);
+ CopiasOcultas = new ObservableCollection<string>(Copia.CopiaOculta);
+ CopiarPara = string.Empty;
+ Erro = "E-MAIL ADICIONADO COM SUCESSO";
+ }
+
+ public void ExcluirCopia(string tipo, string copia)
+ {
+ if (!(tipo == "CÓPIA OCULTA"))
+ {
+ Copia.CopiaComum.Remove(copia);
+ }
+ else
+ {
+ Copia.CopiaOculta.Remove(copia);
+ }
+ CopiasComuns = new ObservableCollection<string>(Copia.CopiaComum);
+ CopiasOcultas = new ObservableCollection<string>(Copia.CopiaOculta);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogCopiarPermissaoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogCopiarPermissaoViewModel.cs
new file mode 100644
index 0000000..465409a
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogCopiarPermissaoViewModel.cs
@@ -0,0 +1,320 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Relatorios.ApolicePendente;
+using Gestor.Model.Domain.Relatorios.Auditoria;
+using Gestor.Model.Domain.Relatorios.Classificacao;
+using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos;
+using Gestor.Model.Domain.Relatorios.Comissao;
+using Gestor.Model.Domain.Relatorios.ExtratoBaixado;
+using Gestor.Model.Domain.Relatorios.FaturaPendente;
+using Gestor.Model.Domain.Relatorios.Fechamento;
+using Gestor.Model.Domain.Relatorios.Licenciamento;
+using Gestor.Model.Domain.Relatorios.LogsEnvio;
+using Gestor.Model.Domain.Relatorios.MetaSeguradora;
+using Gestor.Model.Domain.Relatorios.MetaVendedor;
+using Gestor.Model.Domain.Relatorios.NotaFiscal;
+using Gestor.Model.Domain.Relatorios.Pendente;
+using Gestor.Model.Domain.Relatorios.Placa;
+using Gestor.Model.Domain.Relatorios.PrevisaoPagamentoComissao;
+using Gestor.Model.Domain.Relatorios.Producao;
+using Gestor.Model.Domain.Relatorios.Renovacao;
+using Gestor.Model.Domain.Relatorios.Sinistro;
+using Gestor.Model.Domain.Relatorios.Tarefa;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogCopiarPermissaoViewModel : BaseSegurosViewModel
+{
+ private Usuario _selectedUsuario;
+
+ private Tuple<List<PermissaoUsuario>, Usuario, List<RestricaoUsuario>, List<PermissaoArquivoDigital>, List<RestricaoUsuarioCamposRelatorios>> _usuarioParameter;
+
+ public Usuario SelectedUsuario
+ {
+ get
+ {
+ return _selectedUsuario;
+ }
+ set
+ {
+ _selectedUsuario = value;
+ WorkOnSelectedUsuario(value);
+ OnPropertyChanged("SelectedUsuario");
+ }
+ }
+
+ public Tuple<List<PermissaoUsuario>, Usuario, List<RestricaoUsuario>, List<PermissaoArquivoDigital>, List<RestricaoUsuarioCamposRelatorios>> UsuarioParameter
+ {
+ get
+ {
+ return _usuarioParameter;
+ }
+ set
+ {
+ _usuarioParameter = value;
+ OnPropertyChanged("UsuarioParameter");
+ }
+ }
+
+ public DialogCopiarPermissaoViewModel()
+ {
+ UsuarioParameter = new Tuple<List<PermissaoUsuario>, Usuario, List<RestricaoUsuario>, List<PermissaoArquivoDigital>, List<RestricaoUsuarioCamposRelatorios>>(null, null, null, null, null);
+ }
+
+ private async void WorkOnSelectedUsuario(Usuario value)
+ {
+ if (value != null && ((DomainBase)value).Id != 0L)
+ {
+ UsuarioParameter = new Tuple<List<PermissaoUsuario>, Usuario, List<RestricaoUsuario>, List<PermissaoArquivoDigital>, List<RestricaoUsuarioCamposRelatorios>>(await GetPermissoes(value), value, await GetRestricoes(value), await GetPermissoesArquivoDigital(value), await GetRestricoesCamposRelatorios(value));
+ }
+ }
+
+ private async Task<List<PermissaoArquivoDigital>> GetPermissoesArquivoDigital(Usuario usuario)
+ {
+ List<PermissaoArquivoDigital> list = new List<PermissaoArquivoDigital>();
+ List<string> telas = (from TipoArquivoDigital v in Enum.GetValues(typeof(TipoArquivoDigital))
+ select ((object)(TipoArquivoDigital)(ref v)).ToString() into x
+ orderby x
+ select x).ToList();
+ List<PermissaoArquivoDigital> permissoes = await ServicoPermissArquivoDigital.PermissArquivoDigital(usuario);
+ telas.ForEach(delegate(string x)
+ {
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001c: 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)
+ //IL_00cf: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e9: 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_00fa: Expected O, but got Unknown
+ TipoArquivoDigital tela = (TipoArquivoDigital)Enum.Parse(typeof(TipoArquivoDigital), x);
+ long id = 0L;
+ bool consultar = true;
+ bool incluir = true;
+ bool excluir = true;
+ if (permissoes.Count > 0 && permissoes.Any((PermissaoArquivoDigital y) => y.Tela == tela))
+ {
+ id = ((DomainBase)permissoes.First((PermissaoArquivoDigital y) => y.Tela == tela)).Id;
+ consultar = permissoes.First((PermissaoArquivoDigital y) => y.Tela == tela).Consultar;
+ incluir = permissoes.First((PermissaoArquivoDigital y) => y.Tela == tela).Incluir;
+ excluir = permissoes.First((PermissaoArquivoDigital y) => y.Tela == tela).Excluir;
+ }
+ PermissaoArquivoDigital item = new PermissaoArquivoDigital
+ {
+ Id = id,
+ Tela = tela,
+ Consultar = consultar,
+ Incluir = incluir,
+ Excluir = excluir
+ };
+ list.Add(item);
+ });
+ return list;
+ }
+
+ private async Task<List<PermissaoUsuario>> GetPermissoes(Usuario usuario)
+ {
+ List<PermissaoUsuario> list = new List<PermissaoUsuario>();
+ List<string> telas = (from TipoTela v in Enum.GetValues(typeof(TipoTela))
+ select ((object)(TipoTela)(ref v)).ToString() into x
+ orderby x
+ select x).ToList();
+ List<PermissaoUsuario> permissoes = await ServicoPermissUsuario.PermissUsuario(usuario);
+ telas.ForEach(delegate(string x)
+ {
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001c: 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_003f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0129: Unknown result type (might be due to invalid IL or missing references)
+ //IL_012e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0135: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0137: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0141: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0148: Unknown result type (might be due to invalid IL or missing references)
+ //IL_014f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0157: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0161: Expected O, but got Unknown
+ TipoTela tela = (TipoTela)Enum.Parse(typeof(TipoTela), x);
+ if (string.Equals(ValidationHelper.GetCategory((Enum)(object)tela), "seguros", StringComparison.CurrentCultureIgnoreCase) || string.Equals(ValidationHelper.GetCategory((Enum)(object)tela), "ferramentas", StringComparison.CurrentCultureIgnoreCase))
+ {
+ long id = 0L;
+ bool consultar = true;
+ bool incluir = true;
+ bool alterar = true;
+ bool excluir = true;
+ if (permissoes.Count > 0 && permissoes.Any((PermissaoUsuario y) => y.Tela == tela))
+ {
+ id = ((DomainBase)permissoes.First((PermissaoUsuario y) => y.Tela == tela)).Id;
+ consultar = permissoes.First((PermissaoUsuario y) => y.Tela == tela).Consultar;
+ incluir = permissoes.First((PermissaoUsuario y) => y.Tela == tela).Incluir;
+ alterar = permissoes.First((PermissaoUsuario y) => y.Tela == tela).Alterar;
+ excluir = permissoes.First((PermissaoUsuario y) => y.Tela == tela).Excluir;
+ }
+ PermissaoUsuario item = new PermissaoUsuario
+ {
+ Id = id,
+ Tela = tela,
+ Consultar = consultar,
+ Incluir = incluir,
+ Alterar = alterar,
+ Excluir = excluir
+ };
+ list.Add(item);
+ }
+ });
+ return list;
+ }
+
+ private async Task<List<RestricaoUsuario>> GetRestricoes(Usuario usuario)
+ {
+ List<RestricaoUsuario> list = new List<RestricaoUsuario>();
+ List<string> tipos = (from TipoRestricao v in Enum.GetValues(typeof(TipoRestricao))
+ select ((object)(TipoRestricao)(ref v)).ToString() into x
+ orderby x
+ select x).ToList();
+ List<RestricaoUsuario> restricoesUsuario = await ServicoRestriUsuario.BuscarRestricoes(((DomainBase)usuario).Id);
+ tipos.ForEach(delegate(string x)
+ {
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0087: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0093: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0095: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a7: Expected O, but got Unknown
+ TipoRestricao tipo = (TipoRestricao)Enum.Parse(typeof(TipoRestricao), x);
+ long id = 0L;
+ bool restricao = false;
+ if (restricoesUsuario.Count > 0 && restricoesUsuario.Any((RestricaoUsuario y) => y.Tipo == tipo))
+ {
+ id = ((DomainBase)restricoesUsuario.First((RestricaoUsuario y) => y.Tipo == tipo)).Id;
+ restricao = restricoesUsuario.First((RestricaoUsuario y) => y.Tipo == tipo).Restricao;
+ }
+ RestricaoUsuario item = new RestricaoUsuario
+ {
+ Id = id,
+ Tipo = tipo,
+ Restricao = restricao
+ };
+ list.Add(item);
+ });
+ return list;
+ }
+
+ private async Task<List<RestricaoUsuarioCamposRelatorios>> GetRestricoesCamposRelatorios(Usuario usuario)
+ {
+ List<RestricaoUsuarioCamposRelatorios> list = new List<RestricaoUsuarioCamposRelatorios>();
+ List<ParametrosRelatorio> parametros = new List<ParametrosRelatorio>();
+ foreach (Relatorio item2 in Enum.GetValues(typeof(Relatorio)).Cast<Relatorio>())
+ {
+ switch ((int)item2)
+ {
+ case 0:
+ case 1:
+ parametros.AddRange(Funcoes.ColunasRelatorio<ClientesAtivosInativos>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 2:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Producao>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 3:
+ parametros.AddRange(Funcoes.ColunasRelatorio<ApolicePendente>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 18:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Tarefa>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 4:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Renovacao>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 5:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Comissao>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 6:
+ case 16:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Pendente>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 9:
+ case 10:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Sinistro>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 23:
+ parametros.AddRange(Funcoes.ColunasRelatorio<LogsEnvio>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 8:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Auditoria>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 13:
+ parametros.AddRange(Funcoes.ColunasRelatorio<ExtratoBaixadoRelatorio>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 12:
+ parametros.AddRange(Funcoes.ColunasRelatorio<FaturaPendente>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 14:
+ parametros.AddRange(Funcoes.ColunasRelatorio<MetaSeguradoraRelatorio>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 15:
+ parametros.AddRange(Funcoes.ColunasRelatorio<MetaVendedorRelatorio>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 11:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Fechamento>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 17:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Licenciamento>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 27:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Placas>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 7:
+ parametros.AddRange(Funcoes.ColunasRelatorio<DadosRelatorio>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 19:
+ parametros.AddRange(Funcoes.ColunasRelatorio<NotaFiscalRelatorio>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 20:
+ parametros.AddRange(Funcoes.ColunasRelatorio<PrevisaoPagamento>(item2, new List<ParametrosRelatorio>()));
+ break;
+ case 29:
+ parametros.AddRange(Funcoes.ColunasRelatorio<Classificacao>(item2, new List<ParametrosRelatorio>()));
+ break;
+ }
+ }
+ List<RestricaoUsuarioCamposRelatorios> restricoesUsuario = await ServicoRestriUsuario.BuscarRestricoesCamposRelatorios(((DomainBase)usuario).Id);
+ parametros.ForEach(delegate(ParametrosRelatorio x)
+ {
+ //IL_0073: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0078: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0090: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a9: Expected O, but got Unknown
+ long id = 0L;
+ bool restricao = false;
+ if (restricoesUsuario.Count > 0 && restricoesUsuario.Any((RestricaoUsuarioCamposRelatorios y) => y.Campo == x.Header && y.Relatorio == x.Relatorio))
+ {
+ id = ((DomainBase)restricoesUsuario.First((RestricaoUsuarioCamposRelatorios y) => y.Campo == x.Header && y.Relatorio == x.Relatorio)).Id;
+ restricao = restricoesUsuario.First((RestricaoUsuarioCamposRelatorios y) => y.Campo == x.Header && y.Relatorio == x.Relatorio).Restricao;
+ }
+ RestricaoUsuarioCamposRelatorios item = new RestricaoUsuarioCamposRelatorios
+ {
+ Id = id,
+ Campo = x.Header,
+ Relatorio = x.Relatorio,
+ Restricao = restricao
+ };
+ list.Add(item);
+ });
+ return list;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogEditarParcelasViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogEditarParcelasViewModel.cs
new file mode 100644
index 0000000..46f1411
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogEditarParcelasViewModel.cs
@@ -0,0 +1,245 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Actions;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.Resources;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogEditarParcelasViewModel : BaseViewModel
+{
+ private List<Parcela> _parcelasOriginais;
+
+ internal ParcelaServico ParcelaServico;
+
+ private ObservableCollection<Parcela> _parcelas;
+
+ private bool _isFatura;
+
+ private string _status;
+
+ private Parcela _selectedParcela;
+
+ private Documento _selectedDocumento;
+
+ public ObservableCollection<Parcela> Parcelas
+ {
+ get
+ {
+ return _parcelas;
+ }
+ set
+ {
+ _parcelas = value;
+ OnPropertyChanged("Parcelas");
+ }
+ }
+
+ public bool IsFatura
+ {
+ get
+ {
+ return _isFatura;
+ }
+ set
+ {
+ _isFatura = value;
+ OnPropertyChanged("IsFatura");
+ }
+ }
+
+ public string Status
+ {
+ get
+ {
+ return _status;
+ }
+ set
+ {
+ _status = value;
+ OnPropertyChanged("Status");
+ }
+ }
+
+ public Parcela SelectedParcela
+ {
+ get
+ {
+ return _selectedParcela;
+ }
+ set
+ {
+ _selectedParcela = value;
+ OnPropertyChanged("SelectedParcela");
+ }
+ }
+
+ public Documento SelectedDocumento
+ {
+ get
+ {
+ return _selectedDocumento;
+ }
+ set
+ {
+ _selectedDocumento = value;
+ OnPropertyChanged("SelectedDocumento");
+ }
+ }
+
+ public DialogEditarParcelasViewModel(Documento documento)
+ {
+ //IL_002f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0035: Invalid comparison between Unknown and I4
+ SelectedDocumento = documento;
+ ParcelaServico = new ParcelaServico();
+ Carregar(((DomainBase)documento).Id);
+ IsFatura = (int)documento.TipoRecebimento.GetValueOrDefault((TipoRecebimento)1) == 2;
+ }
+
+ public async void Carregar(long id)
+ {
+ await CarregarParcelas(id);
+ }
+
+ public async Task CarregarParcelas(long id)
+ {
+ ObservableCollection<Parcela> observableCollection = await new ParcelaServico().BuscarParcelasAsync(id);
+ _parcelasOriginais = new List<Parcela>();
+ foreach (Parcela item in observableCollection)
+ {
+ _parcelasOriginais.Add((Parcela)((DomainBase)item).Clone());
+ }
+ Parcelas = (IsFatura ? new ObservableCollection<Parcela>(observableCollection.OrderBy((Parcela x) => x.NumeroParcela)) : observableCollection);
+ }
+
+ public async Task<bool> SalvarParcelas()
+ {
+ foreach (Parcela p in Parcelas)
+ {
+ Parcela val = _parcelasOriginais.First((Parcela x) => ((DomainBase)x).Id == ((DomainBase)p).Id);
+ if (!(p.Vencimento != val.Vencimento) && !(p.Valor != val.Valor))
+ {
+ continue;
+ }
+ val.Vencimento = p.Vencimento;
+ val.Valor = p.Valor;
+ List<KeyValuePair<string, string>> list = SelectedParcela.Validate(Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 9), Recursos.Configuracoes.Any((ConfiguracaoSistema y) => (int)y.Configuracao == 11), true, Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 16));
+ if (list.Count > 0)
+ {
+ string text = string.Join(", ", list.Select(delegate(KeyValuePair<string, string> x)
+ {
+ string[] array = x.Key.Split(new char[1] { '|' });
+ return ((array.Length > 1) ? array[1] : x.Key) + ": " + x.Value + Environment.NewLine;
+ }));
+ Status = "NÃO FOI POSSÍVEL SALVAR DEVIDO AOS ERROS ABAIXO:" + Environment.NewLine + text;
+ return false;
+ }
+ await new ParcelaServico().Save(val, _parcelasOriginais);
+ }
+ RegistrarAcao($"EDITOU VENCIMENTO E/OU VALORES DAS PARCELAS/FATURAS DO DOCUMENTO DE ID {((DomainBase)Parcelas[0].Documento).Id}", ((DomainBase)Parcelas[0].Documento).Id, (TipoTela)5);
+ return true;
+ }
+
+ public void AlterandoValor()
+ {
+ //IL_0042: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0048: Invalid comparison between Unknown and I4
+ //IL_0050: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0056: Invalid comparison between Unknown and I4
+ if (SelectedParcela.Documento == null)
+ {
+ SelectedParcela.Documento = SelectedDocumento;
+ }
+ SelectedParcela.Documento.Parcelas = Parcelas;
+ if ((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1 && (int)SelectedParcela.SubTipo == 1 && SelectedParcela.Comissao == 0m)
+ {
+ SelectedParcela.Comissao = SelectedDocumento.Comissao;
+ }
+ SelectedParcela.Baixando = false;
+ AlterarValor();
+ }
+
+ public void AlterandoVencimento(Parcela parcela)
+ {
+ if (Recursos.Configuracoes.All((ConfiguracaoSistema y) => (int)y.Configuracao != 11) && parcela.Documento.Vigencia2.HasValue)
+ {
+ DateTime vencimento = parcela.Vencimento;
+ DateTime? vigencia = parcela.Documento.Vigencia2;
+ if (vigencia.HasValue && vencimento > vigencia.GetValueOrDefault() && ((DomainBase)parcela.Documento.Controle.Ramo).Id != 23)
+ {
+ Gestor.Application.Actions.Actions.AcionarSnackbar?.Invoke("DATA INVÁLIDA. " + Messages.VencimentoMaior);
+ parcela.Vencimento = _parcelasOriginais.First((Parcela x) => ((DomainBase)x).Id == ((DomainBase)parcela).Id).Vencimento;
+ }
+ }
+ if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 9) && ((parcela.Documento.Vigencia1 > DateTime.MinValue && parcela.NumeroParcela == 1 && parcela.Vencimento < parcela.Documento.Vigencia1.AddDays(-30.0)) || (parcela.NumeroParcela != 1 && parcela.Vencimento < parcela.Documento.Vigencia1)))
+ {
+ Gestor.Application.Actions.Actions.AcionarSnackbar?.Invoke("DATA INVÁLIDA. " + Messages.VencimentoMenor);
+ parcela.Vencimento = _parcelasOriginais.First((Parcela x) => ((DomainBase)x).Id == ((DomainBase)parcela).Id).Vencimento;
+ }
+ Parcelas = new ObservableCollection<Parcela>(Parcelas.OrderBy((Parcela x) => x.NumeroParcela));
+ }
+
+ public void AlterarValor()
+ {
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0015: Invalid comparison between Unknown and I4
+ if (SelectedParcela == null)
+ {
+ return;
+ }
+ if ((int)SelectedParcela.SubTipo == 1 && !IsFatura)
+ {
+ decimal valor = SelectedDocumento.PremioTotal - Parcelas.Where((Parcela x) => (int)x.SubTipo == 1 && ((DomainBase)x).Id != ((DomainBase)SelectedParcela).Id).Sum((Parcela x) => x.Valor);
+ decimal num = SelectedDocumento.PremioTotal - Parcelas.Where((Parcela x) => (int)x.SubTipo == 1 && ((DomainBase)x).Id < ((DomainBase)SelectedParcela).Id).Sum((Parcela x) => x.Valor);
+ num -= SelectedParcela.Valor;
+ decimal num2 = SelectedDocumento.NumeroParcelas - (decimal)SelectedParcela.NumeroParcela;
+ if (num2 == 0m)
+ {
+ num2 = 1m;
+ }
+ decimal valorDemais = ((num2 > 0m) ? (num / num2) : 0m);
+ if (valorDemais == 0m)
+ {
+ SelectedParcela.Valor = valor;
+ }
+ List<Parcela> parcelas = new List<Parcela> { SelectedParcela };
+ decimal num3 = Math.Abs(valorDemais);
+ decimal? tolerancia = SelectedDocumento.Controle.Seguradora.Tolerancia;
+ if (((num3 > tolerancia.GetValueOrDefault()) & tolerancia.HasValue) && !Parcelas.Any((Parcela x) => (int)x.SubTipo == 1 && x.NumeroParcela > SelectedParcela.NumeroParcela))
+ {
+ SelectedParcela.Valor = valor;
+ }
+ Parcelas.Where((Parcela x) => (int)x.SubTipo == 1 && x.NumeroParcela != SelectedParcela.NumeroParcela).ToList().ForEach(delegate(Parcela x)
+ {
+ if (x.NumeroParcela > SelectedParcela.NumeroParcela)
+ {
+ x.Valor = ((valorDemais > 0m) ? valorDemais : x.Valor);
+ x.Comissao = ((x.Comissao == 0m) ? SelectedDocumento.Comissao : x.Comissao);
+ }
+ parcelas.Add(x);
+ });
+ foreach (Parcela item in parcelas.Where((Parcela x) => x.NumeroParcela >= SelectedParcela.NumeroParcela))
+ {
+ item.Documento = SelectedDocumento;
+ if (((DomainBase)item).Id != ((DomainBase)SelectedParcela).Id)
+ {
+ item.Valor = valorDemais;
+ }
+ }
+ Parcelas = new ObservableCollection<Parcela>(parcelas.OrderBy((Parcela x) => x.NumeroParcela));
+ }
+ else
+ {
+ SelectedParcela.Documento = SelectedDocumento;
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogEnviarEmailsViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogEnviarEmailsViewModel.cs
new file mode 100644
index 0000000..1a21d9a
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogEnviarEmailsViewModel.cs
@@ -0,0 +1,273 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.MalaDireta;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogEnviarEmailsViewModel : BaseSegurosViewModel
+{
+ private ObservableCollection<MalaDireta> _listaTela = new ObservableCollection<MalaDireta>();
+
+ private string _infoEnvio = "CLIQUE EM ENVIAR PARA INCIAR O ENVIO";
+
+ private bool _assinatura { get; set; }
+
+ private bool _original { get; set; }
+
+ private List<ArquivoDigital> _arquivosAnexados { get; set; }
+
+ private string _assunto { get; set; }
+
+ private string _corpo { get; set; }
+
+ private Credencial _credencial { get; set; }
+
+ private FiltroArquivoDigital _filtro { get; set; }
+
+ private bool _salvarAd { get; set; }
+
+ private bool _confirmarLeitura { get; set; }
+
+ public List<MalaDireta> Lista { get; set; }
+
+ public ObservableCollection<MalaDireta> ListaTela
+ {
+ get
+ {
+ return _listaTela;
+ }
+ set
+ {
+ _listaTela = value;
+ OnPropertyChanged("ListaTela");
+ }
+ }
+
+ public string InfoEnvio
+ {
+ get
+ {
+ return _infoEnvio;
+ }
+ set
+ {
+ _infoEnvio = value;
+ OnPropertyChanged("InfoEnvio");
+ }
+ }
+
+ public DialogEnviarEmailsViewModel(List<MalaDireta> lista, bool assinatura, bool original, List<ArquivoDigital> arquivosAnexados, string assunto, string corpo, Credencial credencial, FiltroArquivoDigital filtro, bool salvarAd, bool confirmarLeitura)
+ {
+ lista.ForEach(delegate(MalaDireta x)
+ {
+ x.InfoEnvio = null;
+ });
+ Lista = lista;
+ PrepararLista();
+ _assinatura = assinatura;
+ _original = original;
+ _arquivosAnexados = arquivosAnexados;
+ _assunto = assunto;
+ _corpo = corpo;
+ _credencial = credencial;
+ _filtro = filtro;
+ _salvarAd = salvarAd;
+ _confirmarLeitura = confirmarLeitura;
+ }
+
+ private void PrepararLista()
+ {
+ List<MalaDireta> listaTela = new List<MalaDireta>();
+ Lista.ForEach(delegate(MalaDireta x)
+ {
+ listaTela.Add(x);
+ if (x.Copia != null)
+ {
+ listaTela.AddRange(((IEnumerable<string>)x.Copia.CopiaOculta).Select((Func<string, MalaDireta>)((string c) => new MalaDireta
+ {
+ Cliente = x.Cliente,
+ Email = c,
+ Enviado = x.Enviado,
+ InfoEnvio = x.InfoEnvio
+ })).ToList());
+ }
+ });
+ ListaTela = new ObservableCollection<MalaDireta>(listaTela);
+ }
+
+ public void Enviar()
+ {
+ Enviar(_assinatura, _original, _arquivosAnexados, _assunto, _corpo, _credencial, _filtro, _salvarAd, _confirmarLeitura);
+ }
+
+ private async void Enviar(bool assinatura, bool original, List<ArquivoDigital> arquivosAnexados, string assunto, string corpo, Credencial credencial, FiltroArquivoDigital filtro, bool salvarAd, bool confirmarLeitura)
+ {
+ Loading(isLoading: true);
+ InfoEnvio = "ENVIANDO, AGUARDE ATÉ O PROCESSO TERMINAR.";
+ await EnviarEmails(assinatura, original, arquivosAnexados, assunto, corpo, credencial, filtro, salvarAd, confirmarLeitura);
+ InfoEnvio = "TENTATIVA DE ENVIO CONCLUÍDA, CONFIRA O STATUS ABAIXO.";
+ Loading(isLoading: false);
+ }
+
+ private async Task EnviarEmails(bool assinatura, bool original, List<ArquivoDigital> arquivosAnexados, string assunto, string corpo, Credencial credencial, FiltroArquivoDigital filtro, bool salvarAd, bool confirmarLeitura)
+ {
+ List<string> list = new List<string>();
+ VariaveisMalaDireta[] array = (VariaveisMalaDireta[])Enum.GetValues(typeof(VariaveisMalaDireta));
+ foreach (VariaveisMalaDireta val in array)
+ {
+ list.Add(ValidationHelper.GetEntity((Enum)(object)val));
+ }
+ bool temVariaveis = list.Any(assunto.Contains) || list.Any(corpo.Contains) || Lista.Any((MalaDireta x) => x.ArquivoDigital != null && x.ArquivoDigital.Count > 0);
+ MailHelper mail = new MailHelper();
+ bool parar = false;
+ if (salvarAd)
+ {
+ ArquivoDigitalServico arquivoServico = new ArquivoDigitalServico();
+ foreach (MalaDireta x2 in Lista)
+ {
+ arquivosAnexados.ForEach(delegate(ArquivoDigital a)
+ {
+ //IL_0007: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000d: Invalid comparison between Unknown and I4
+ //IL_002f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0035: Invalid comparison between Unknown and I4
+ //IL_0057: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005d: Invalid comparison between Unknown and I4
+ //IL_007f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0085: Invalid comparison between Unknown and I4
+ //IL_00a7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ae: Invalid comparison between Unknown and I4
+ //IL_00d0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d6: Invalid comparison between Unknown and I4
+ a.IdCliente = (((int)x2.Tela == 1) ? ((DomainBase)x2.Cliente).Id : 0);
+ a.IdDocumento = (((int)x2.Tela == 2) ? ((DomainBase)x2.Apolice).Id : 0);
+ a.IdItem = (((int)x2.Tela == 3) ? ((DomainBase)x2.Item).Id : 0);
+ a.IdParcela = (((int)x2.Tela == 5) ? ((DomainBase)x2.Parcela).Id : 0);
+ a.IdProspeccao = (((int)x2.Tela == 33) ? ((DomainBase)x2.Prospeccao).Id : 0);
+ a.IdSinistro = (((int)x2.Tela == 7) ? ((DomainBase)x2.Sinistro).Id : 0);
+ a.IdEmpresa = Recursos.Usuario.IdEmpresa;
+ });
+ List<IndiceArquivoDigital> ids = await arquivoServico.Insert(arquivosAnexados.ToList());
+ if (arquivosAnexados.Any((ArquivoDigital arquivo) => arquivo.Arquivo == null))
+ {
+ arquivosAnexados = await arquivoServico.Buscar(ids);
+ }
+ }
+ }
+ if (!string.IsNullOrWhiteSpace(credencial.Cabecalho))
+ {
+ corpo = credencial.Cabecalho + corpo;
+ }
+ if (!string.IsNullOrWhiteSpace(credencial.Assinatura))
+ {
+ corpo = corpo + "<br /><br />" + credencial.Assinatura;
+ }
+ if (!temVariaveis)
+ {
+ while (!parar)
+ {
+ List<MalaDireta> list2 = Lista.Where((MalaDireta x) => !x.Enviado.HasValue).Take(200).ToList();
+ List<string> cco = list2.Select((MalaDireta x) => x.Email).ToList();
+ list2.ForEach(delegate(MalaDireta x)
+ {
+ if (x.Copia != null)
+ {
+ cco.AddRange(x.Copia.CopiaComum);
+ cco.AddRange(x.Copia.CopiaOculta);
+ }
+ });
+ cco = cco.Distinct().ToList();
+ Destinatario destinatario = new Destinatario
+ {
+ Assunto = assunto,
+ Corpo = corpo,
+ Email = credencial.Email,
+ Nome = credencial.Descricao,
+ Encaminhar = new List<string>(),
+ EncaminharOculto = cco,
+ Anexos = arquivosAnexados.ToList()
+ };
+ LogEnvio result = await mail.SendAsync(credencial, destinatario, filtro, Lista.ToList(), (TipoTela)0, confirmarLeitura);
+ List<MalaDireta> list3 = Lista.ToList();
+ list3.ForEach(delegate(MalaDireta x)
+ {
+ x.Enviado = result.Enviado;
+ x.InfoEnvio = (result.Enviado ? "ENVIADO COM SUCESSO" : ("NÃO ENVIADO, ENTRE EM CONTATO COM SEU PROVEDOR/SERVIÇO DE E-MAIL E INFORME OS DADOS ABAIXO: \r\n" + result.Erro));
+ });
+ Lista = list3;
+ parar = Lista.All((MalaDireta x) => x.Enviado.HasValue);
+ }
+ }
+ else
+ {
+ for (int i = 0; i < Lista.Count; i++)
+ {
+ MalaDireta envio = Lista[i];
+ List<ArquivoDigital> list5;
+ if (envio.ArquivoDigital != null)
+ {
+ List<ArquivoDigital> list4 = ((!(!assinatura || original)) ? (await ArquivoDigitalServico.Buscar(envio.ArquivoDigital.Where((IndiceArquivoDigital x) => string.IsNullOrWhiteSpace(x.UrlAssinatura)).ToList())) : (await ArquivoDigitalServico.Buscar(envio.ArquivoDigital.ToList())));
+ list5 = list4;
+ }
+ else
+ {
+ list5 = new List<ArquivoDigital>();
+ }
+ List<ArquivoDigital> arquivos = list5;
+ if (arquivosAnexados != null && arquivosAnexados.Count > 0)
+ {
+ arquivos.AddRange(arquivosAnexados);
+ }
+ if (((envio != null) ? envio.ArquivoDigital : null) == null)
+ {
+ int num;
+ if (envio == null)
+ {
+ num = 0;
+ }
+ else
+ {
+ Documento apolice = envio.Apolice;
+ num = ((((apolice != null) ? new long?(((DomainBase)apolice).Id) : null) > 0) ? 1 : 0);
+ }
+ if (num != 0)
+ {
+ MalaDireta val2 = envio;
+ val2.ArquivoDigital = await ArquivoDigitalServico.BuscarPorTipo((TipoArquivoDigital)2, ((DomainBase)envio.Apolice).Id);
+ }
+ }
+ Destinatario val3 = new Destinatario
+ {
+ Assunto = Funcoes.SubstituirVariaveis(assunto, envio),
+ Corpo = Funcoes.SubstituirVariaveis(corpo, envio),
+ Email = envio.Email
+ };
+ Copia copia = envio.Copia;
+ val3.Encaminhar = ((copia != null) ? copia.CopiaComum : null);
+ Copia copia2 = envio.Copia;
+ val3.EncaminharOculto = ((copia2 != null) ? copia2.CopiaOculta : null);
+ val3.Nome = envio.Cliente.Nome;
+ val3.Anexos = arquivos;
+ Destinatario destinatario2 = val3;
+ List<MalaDireta> maladireta = new List<MalaDireta> { envio };
+ LogEnvio val4 = await mail.SendAsync(credencial, destinatario2, filtro, maladireta, (TipoTela)0, confirmarLeitura);
+ envio.Enviado = val4.Enviado;
+ envio.InfoEnvio = (val4.Enviado ? "ENVIADO COM SUCESSO" : ("NÃO ENVIADO, ENTRE EM CONTATO COM SEU PROVEDOR/SERVIÇO DE E-MAIL E INFORME OS DADOS ABAIXO: \r\n" + val4.Erro));
+ envio.ArquivoDigital = null;
+ Lista = Lista;
+ }
+ }
+ PrepararLista();
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogExportarPermissaoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogExportarPermissaoViewModel.cs
new file mode 100644
index 0000000..d2da048
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogExportarPermissaoViewModel.cs
@@ -0,0 +1,109 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogExportarPermissaoViewModel : BaseSegurosViewModel
+{
+ private bool _enableGrid = true;
+
+ private List<Usuario> _usuarios;
+
+ private ObservableCollection<Usuario> _usuariosFiltrados = new ObservableCollection<Usuario>();
+
+ public bool EnableGrid
+ {
+ get
+ {
+ return _enableGrid;
+ }
+ set
+ {
+ _enableGrid = value;
+ OnPropertyChanged("EnableGrid");
+ }
+ }
+
+ public List<Usuario> Usuarios
+ {
+ get
+ {
+ return _usuarios;
+ }
+ set
+ {
+ _usuarios = value;
+ OnPropertyChanged("Usuarios");
+ }
+ }
+
+ public ObservableCollection<Usuario> UsuariosFiltrados
+ {
+ get
+ {
+ return _usuariosFiltrados;
+ }
+ set
+ {
+ _usuariosFiltrados = value;
+ OnPropertyChanged("UsuariosFiltrados");
+ }
+ }
+
+ public DialogExportarPermissaoViewModel(long idUsuario)
+ {
+ Seleciona(idUsuario);
+ }
+
+ private async void Seleciona(long idUsuario)
+ {
+ Loading(isLoading: true);
+ await SelecionaUsuarios(idUsuario);
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaUsuarios(long idUsuario)
+ {
+ EnableGrid = false;
+ Loading(isLoading: true);
+ Usuarios = (from x in await new BaseServico().BuscarUsuariosAsync()
+ where !x.Excluido && ((DomainBase)x).Id != idUsuario
+ orderby x.Nome
+ select x).ToList();
+ UsuariosFiltrados = new ObservableCollection<Usuario>(Usuarios);
+ Loading(isLoading: false);
+ EnableGrid = true;
+ }
+
+ internal async Task<List<Usuario>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarUsuario(value));
+ }
+
+ public List<Usuario> FiltrarUsuario(string filter)
+ {
+ UsuariosFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Usuario>(Usuarios) : new ObservableCollection<Usuario>(from x in Usuarios
+ where ValidationHelper.RemoveDiacritics(x.Nome.ToUpper().Trim()).Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby !x.Excluido descending, x.Nome
+ select x));
+ return UsuariosFiltrados.ToList();
+ }
+
+ public void Selecionar()
+ {
+ if (UsuariosFiltrados != null && UsuariosFiltrados.Count != 0)
+ {
+ UsuariosFiltrados.ToList().ForEach(delegate(Usuario x)
+ {
+ x.Selecionado = !x.Selecionado;
+ });
+ UsuariosFiltrados = new ObservableCollection<Usuario>(UsuariosFiltrados);
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogGraficoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogGraficoViewModel.cs
new file mode 100644
index 0000000..93aedeb
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogGraficoViewModel.cs
@@ -0,0 +1,38 @@
+using System;
+using System.ComponentModel;
+using Gestor.Application.Helpers;
+using Gestor.Application.Model;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogGraficoViewModel : INotifyPropertyChanged
+{
+ private SinteticoSource _source;
+
+ public SinteticoSource Source
+ {
+ get
+ {
+ return _source;
+ }
+ set
+ {
+ this.MutateVerbose(ref _source, value, RaisePropertyChanged(), "Source");
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public DialogGraficoViewModel(SinteticoSource series)
+ {
+ Source = series;
+ }
+
+ private Action<PropertyChangedEventArgs> RaisePropertyChanged()
+ {
+ return delegate(PropertyChangedEventArgs args)
+ {
+ this.PropertyChanged?.Invoke(this, args);
+ };
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogMedalhaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogMedalhaViewModel.cs
new file mode 100644
index 0000000..7fe1669
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogMedalhaViewModel.cs
@@ -0,0 +1,72 @@
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogMedalhaViewModel : BaseSegurosViewModel
+{
+ private int _liquido;
+
+ private int _comissao;
+
+ private int _resultado;
+
+ private int _media;
+
+ public int Liquido
+ {
+ get
+ {
+ return _liquido;
+ }
+ set
+ {
+ _liquido = value;
+ OnPropertyChanged("Liquido");
+ }
+ }
+
+ public int Comissao
+ {
+ get
+ {
+ return _comissao;
+ }
+ set
+ {
+ _comissao = value;
+ OnPropertyChanged("Comissao");
+ }
+ }
+
+ public int Resultado
+ {
+ get
+ {
+ return _resultado;
+ }
+ set
+ {
+ _resultado = value;
+ OnPropertyChanged("Resultado");
+ }
+ }
+
+ public int Media
+ {
+ get
+ {
+ return _media;
+ }
+ set
+ {
+ _media = value;
+ OnPropertyChanged("Media");
+ }
+ }
+
+ public DialogMedalhaViewModel(int liquido, int comissao, int resultado, int media)
+ {
+ Liquido = liquido;
+ Comissao = comissao;
+ Resultado = resultado;
+ Media = media;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogPesquisaAvancadaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogPesquisaAvancadaViewModel.cs
new file mode 100644
index 0000000..b4985fd
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogPesquisaAvancadaViewModel.cs
@@ -0,0 +1,503 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogPesquisaAvancadaViewModel : BaseSegurosViewModel
+{
+ private ObservableCollection<PesquisaAvancada> _pesquisas = new ObservableCollection<PesquisaAvancada>();
+
+ private PesquisaAvancada _resultado = new PesquisaAvancada();
+
+ private string _pesquisa;
+
+ private FiltroStatusDocumento _status;
+
+ private TipoTela _tela;
+
+ private TipoFiltroBusca _tipoFiltro;
+
+ private bool _habilitarFiltroBuscar;
+
+ private FiltroStatusDocumento _oldStatus;
+
+ private bool _enableStatus = true;
+
+ public bool TipoBusca;
+
+ public ObservableCollection<PesquisaAvancada> Pesquisas
+ {
+ get
+ {
+ return _pesquisas;
+ }
+ set
+ {
+ _pesquisas = value;
+ OnPropertyChanged("Pesquisas");
+ }
+ }
+
+ public PesquisaAvancada Resultado
+ {
+ get
+ {
+ return _resultado;
+ }
+ set
+ {
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ if (value != null)
+ {
+ value.Status = Status;
+ }
+ _resultado = value;
+ OnPropertyChanged("Resultado");
+ }
+ }
+
+ public string Pesquisa
+ {
+ get
+ {
+ return _pesquisa;
+ }
+ set
+ {
+ _pesquisa = value;
+ OnPropertyChanged("Pesquisa");
+ }
+ }
+
+ public FiltroStatusDocumento Status
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _status;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0008: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0009: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001d: Unknown result type (might be due to invalid IL or missing references)
+ _status = value;
+ _oldStatus = value;
+ if (Resultado != null)
+ {
+ Resultado.Status = Status;
+ }
+ OnPropertyChanged("Status");
+ }
+ }
+
+ public TipoTela Tela
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _tela;
+ }
+ 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)
+ _tela = value;
+ OnPropertyChanged("Tela");
+ }
+ }
+
+ public TipoFiltroBusca TipoFiltro
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _tipoFiltro;
+ }
+ 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)
+ _tipoFiltro = value;
+ OnPropertyChanged("TipoFiltro");
+ }
+ }
+
+ public bool HabilitarFiltroBuscar
+ {
+ get
+ {
+ return _habilitarFiltroBuscar;
+ }
+ set
+ {
+ _habilitarFiltroBuscar = value;
+ OnPropertyChanged("HabilitarFiltroBuscar");
+ }
+ }
+
+ private TipoPesquisa _tipo { get; set; } = (TipoPesquisa)14;
+
+
+ public TipoPesquisa Tipo
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _tipo;
+ }
+ set
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Invalid comparison between Unknown and I4
+ //IL_001a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0029: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0004: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Invalid comparison between Unknown and I4
+ //IL_0056: 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_000b: Invalid comparison between Unknown and I4
+ //IL_000d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0010: Invalid comparison between Unknown and I4
+ //IL_0031: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0037: Invalid comparison between Unknown and I4
+ //IL_004b: 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_0040: Invalid comparison between Unknown and I4
+ if ((int)value == 1 || (int)value == 2 || (int)value == 17 || (int)value == 9)
+ {
+ EnableStatus = false;
+ FiltroStatusDocumento oldStatus = _oldStatus;
+ Status = (FiltroStatusDocumento)4;
+ _oldStatus = oldStatus;
+ }
+ else if ((int)_tipo == 1 || (int)_tipo == 2)
+ {
+ EnableStatus = true;
+ Status = _oldStatus;
+ }
+ _tipo = value;
+ GetTipoTela();
+ HabilitarBusca();
+ OnPropertyChanged("Tipo");
+ }
+ }
+
+ public bool EnableStatus
+ {
+ get
+ {
+ return _enableStatus;
+ }
+ set
+ {
+ _enableStatus = value;
+ OnPropertyChanged("EnableStatus");
+ }
+ }
+
+ public string Informacao => "O LIMITE DA PESQUISA É EM MIL ITENS,\r\nPARA OBTER UMA EXATIDÃO NA PESQUISA É NECESSÁRIO ESPECIFICAR O ITEM PROCURADO.";
+
+ public void GetTipoTela()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0007: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0055: Expected I4, but got Unknown
+ TipoPesquisa tipo = Tipo;
+ switch ((int)tipo)
+ {
+ case 1:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 15:
+ case 16:
+ case 17:
+ Tela = (TipoTela)21;
+ break;
+ case 0:
+ case 14:
+ Tela = (TipoTela)3;
+ break;
+ case 2:
+ case 9:
+ Tela = (TipoTela)7;
+ break;
+ }
+ }
+
+ public void HabilitarBusca()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0007: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0049: Expected I4, but got Unknown
+ TipoPesquisa tipo = Tipo;
+ switch ((int)tipo)
+ {
+ case 0:
+ case 4:
+ case 6:
+ case 8:
+ case 10:
+ case 13:
+ case 14:
+ HabilitarFiltroBuscar = true;
+ break;
+ case 1:
+ case 2:
+ TipoFiltro = (TipoFiltroBusca)1;
+ HabilitarFiltroBuscar = false;
+ break;
+ default:
+ TipoFiltro = (TipoFiltroBusca)0;
+ HabilitarFiltroBuscar = false;
+ break;
+ }
+ }
+
+ public void GetTipoPesquisa()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0007: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Invalid comparison between Unknown and I4
+ TipoFiltroBusca tipoFiltro = _tipoFiltro;
+ if ((int)tipoFiltro != 0)
+ {
+ if ((int)tipoFiltro == 1)
+ {
+ TipoBusca = true;
+ }
+ }
+ else
+ {
+ TipoBusca = false;
+ }
+ }
+
+ public async Task Pesquisar()
+ {
+ List<VendedorUsuario> list = ((Recursos.Usuario != null) ? (await VerificaVinculoVendedor(Recursos.Usuario)) : new List<VendedorUsuario>());
+ List<VendedorUsuario> vendedorVinculado = list;
+ GetTipoPesquisa();
+ TipoPesquisa tipo = Tipo;
+ switch ((int)tipo)
+ {
+ case 5:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(await new PatrimonialServico().BuscarImobiliaria(Pesquisa, Status, vendedorVinculado));
+ break;
+ case 7:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(await new PatrimonialServico().BuscarLocatario(Pesquisa, Status, vendedorVinculado));
+ break;
+ case 10:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>((await new ApoliceServico().BuscarApolice(Pesquisa, Status, vendedorVinculado, "Proposta", TipoBusca)).Select(delegate(Documento x)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Expected O, but got Unknown
+ PesquisaAvancada val7 = new PesquisaAvancada();
+ val7.IdCliente = ((DomainBase)x.Controle.Cliente).Id;
+ val7.IdDocumento = ((DomainBase)x).Id;
+ val7.Nome = x.Controle.Cliente.Nome;
+ val7.Pesquisa = "NÚMERO DA PROPOSTA: " + x.Proposta + " - NÚMERO DA APÓLICE: " + x.Apolice + " - NÚMERO DO ENDOSSO: " + x.Endosso;
+ return val7;
+ }).ToList());
+ break;
+ case 11:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(((IEnumerable<Documento>)(await new ApoliceServico().BuscarApolice(Pesquisa, Status, vendedorVinculado, "NumeroEndosso", TipoBusca))).Select((Func<Documento, PesquisaAvancada>)((Documento x) => new PesquisaAvancada
+ {
+ IdCliente = ((DomainBase)x.Controle.Cliente).Id,
+ IdDocumento = ((DomainBase)x).Id,
+ Nome = x.Controle.Cliente.Nome,
+ Pesquisa = "NÚMERO DA APÓLICE: " + x.Apolice + " - NÚMERO DO ENDOSSO: " + x.Endosso
+ })).ToList());
+ break;
+ case 15:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>((await new ApoliceServico().BuscarApolice(Pesquisa, Status, vendedorVinculado, "PedidoEndosso", TipoBusca)).Select(delegate(Documento x)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Expected O, but got Unknown
+ PesquisaAvancada val6 = new PesquisaAvancada();
+ val6.IdCliente = ((DomainBase)x.Controle.Cliente).Id;
+ val6.IdDocumento = ((DomainBase)x).Id;
+ val6.Nome = x.Controle.Cliente.Nome;
+ val6.Pesquisa = "PROPOSTA ENDOSSO: " + x.PropostaEndosso + " - NÚMERO DA APÓLICE: " + x.Apolice + " - NÚMERO DO ENDOSSO: " + x.Endosso;
+ return val6;
+ }).ToList());
+ break;
+ case 8:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>((await new ApoliceServico().BuscarApolice(Pesquisa, Status, vendedorVinculado, "", TipoBusca)).Select(delegate(Documento x)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Expected O, but got Unknown
+ PesquisaAvancada val5 = new PesquisaAvancada();
+ val5.IdCliente = ((DomainBase)x.Controle.Cliente).Id;
+ val5.IdDocumento = ((DomainBase)x).Id;
+ val5.Nome = x.Controle.Cliente.Nome;
+ val5.Pesquisa = ((!x.Vigencia2.HasValue) ? $"NÚMERO DA APÓLICE: {x.Apolice} - VIGÊNCIA INICIAL: {x.Vigencia1:d} - NÚMERO DO ENDOSSO: {x.Endosso}" : $"NÚMERO DA APÓLICE: {x.Apolice} - VIGÊNCIA INICIAL: {x.Vigencia1:d} - VIGÊNCIA FINAL: {x.Vigencia2.Value:d} - NÚMERO DO ENDOSSO: {x.Endosso}");
+ return val5;
+ }).ToList());
+ break;
+ case 1:
+ {
+ if (long.TryParse(Pesquisa, out var _))
+ {
+ Documento val3 = await new ApoliceServico().BuscarCodDocumento(long.Parse(Pesquisa), vendedorVinculado);
+ DialogPesquisaAvancadaViewModel dialogPesquisaAvancadaViewModel2 = this;
+ ObservableCollection<PesquisaAvancada> pesquisas;
+ if (val3 != null && !val3.Excluido)
+ {
+ ObservableCollection<PesquisaAvancada> observableCollection = new ObservableCollection<PesquisaAvancada>();
+ ObservableCollection<PesquisaAvancada> observableCollection3 = observableCollection;
+ PesquisaAvancada val2 = new PesquisaAvancada();
+ val2.Nome = val3.Controle.Cliente.Nome;
+ val2.IdDocumento = ((DomainBase)val3).Id;
+ val2.Pesquisa = "CÓDIGO DO COCUMENTO: " + ((DomainBase)val3).Id + " - NÚMERO DA PROPOSTA: " + val3.Proposta + " - NÚMERO DA APÓLICE: " + val3.Apolice + " - NÚMERO DO ENDOSSO: " + val3.Endosso;
+ val2.IdCliente = ((DomainBase)val3.Controle.Cliente).Id;
+ observableCollection3.Add(val2);
+ pesquisas = observableCollection;
+ }
+ else
+ {
+ pesquisas = new ObservableCollection<PesquisaAvancada>();
+ }
+ dialogPesquisaAvancadaViewModel2.Pesquisas = pesquisas;
+ }
+ break;
+ }
+ case 0:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(await new AutoServico().BuscarChassi(Pesquisa, Status, vendedorVinculado, TipoBusca));
+ break;
+ case 14:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(await new AutoServico().BuscarPlaca(Pesquisa, Status, vendedorVinculado, TipoBusca));
+ break;
+ case 6:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(await new AutoServico().BuscarItem(Pesquisa, Status, vendedorVinculado, TipoBusca));
+ break;
+ case 16:
+ {
+ ClienteServico clienteServico = new ClienteServico();
+ string telefone = (Pesquisa = ValidationHelper.FormatarTelefone(Pesquisa));
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(((IEnumerable<ClienteTelefone>)(await clienteServico.BuscarTelefonesClientes(telefone))).Select((Func<ClienteTelefone, PesquisaAvancada>)((ClienteTelefone x) => new PesquisaAvancada
+ {
+ Nome = x.Cliente.Nome,
+ Pesquisa = "TELEFONE: " + ((TelefoneBase)x).Prefixo + "-" + ((TelefoneBase)x).Numero,
+ IdCliente = ((DomainBase)x.Cliente).Id
+ })).ToList());
+ break;
+ }
+ case 3:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(((IEnumerable<ClienteEmail>)(await new EmailServico().BuscarEmail(Pesquisa))).Select((Func<ClienteEmail, PesquisaAvancada>)((ClienteEmail x) => new PesquisaAvancada
+ {
+ Nome = x.Cliente.Nome,
+ Pesquisa = "E-MAIL: " + ((EmailBase)x).Email,
+ IdCliente = ((DomainBase)x.Cliente).Id
+ })).ToList());
+ break;
+ case 2:
+ {
+ SinistroServico sinistroServico = new SinistroServico();
+ if (int.TryParse(Pesquisa, out var _))
+ {
+ Sinistro val = await sinistroServico.BuscarSinistro(long.Parse(Pesquisa));
+ if (val == null)
+ {
+ Pesquisas = new ObservableCollection<PesquisaAvancada>();
+ break;
+ }
+ DialogPesquisaAvancadaViewModel dialogPesquisaAvancadaViewModel = this;
+ ObservableCollection<PesquisaAvancada> observableCollection = new ObservableCollection<PesquisaAvancada>();
+ ObservableCollection<PesquisaAvancada> observableCollection2 = observableCollection;
+ PesquisaAvancada val2 = new PesquisaAvancada();
+ val2.IdCliente = ((DomainBase)val.ControleSinistro.Item.Documento.Controle.Cliente).Id;
+ val2.IdDocumento = ((DomainBase)val.ControleSinistro.Item.Documento).Id;
+ val2.IdItem = ((DomainBase)val.ControleSinistro.Item).Id;
+ val2.IdSinistro = ((DomainBase)val).Id;
+ val2.Nome = val.ControleSinistro.Item.Documento.NomeProponente;
+ val2.Pesquisa = "CÓDIGO DO SINISTRO: " + ((DomainBase)val.ControleSinistro).Id + " - NÚMERO DA APÓLICE: " + val.ControleSinistro.Item.Documento.Apolice + " - ITEM " + val.ItemSinistrado;
+ observableCollection2.Add(val2);
+ dialogPesquisaAvancadaViewModel.Pesquisas = observableCollection;
+ }
+ break;
+ }
+ case 9:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>((await new SinistroServico().BuscarSinistros(Pesquisa)).Select(delegate(Sinistro x)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Expected O, but got Unknown
+ PesquisaAvancada val4 = new PesquisaAvancada();
+ val4.Nome = x.ControleSinistro.Item.Documento.Controle.Cliente.Nome;
+ val4.Pesquisa = "NÚMERO DO SINISTRO: " + x.Numero + " - NÚMERO DA APÓLICE: " + x.ControleSinistro.Item.Documento.Apolice + " - ITEM: " + x.ItemSinistrado;
+ val4.IdCliente = ((DomainBase)x.ControleSinistro.Item.Documento.Controle.Cliente).Id;
+ val4.IdDocumento = ((DomainBase)x.ControleSinistro.Item.Documento).Id;
+ val4.IdItem = ((DomainBase)x.ControleSinistro.Item).Id;
+ val4.IdSinistro = ((DomainBase)x).Id;
+ return val4;
+ }).ToList());
+ break;
+ case 4:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(((IEnumerable<Documento>)(await new ApoliceServico().BuscarApolice(Pesquisa, Status, vendedorVinculado, "Estipulante", TipoBusca))).Select((Func<Documento, PesquisaAvancada>)((Documento x) => new PesquisaAvancada
+ {
+ IdCliente = ((DomainBase)x.Controle.Cliente).Id,
+ IdDocumento = ((DomainBase)x).Id,
+ Nome = x.Controle.Cliente.Nome,
+ Pesquisa = " NÚMERO DA APÓLICE: " + x.Apolice
+ })).ToList());
+ break;
+ case 12:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(((IEnumerable<Cliente>)(await new ClienteServico().BuscarObsCliente(Pesquisa))).Select((Func<Cliente, PesquisaAvancada>)((Cliente x) => new PesquisaAvancada
+ {
+ Nome = x.Nome,
+ Pesquisa = "OBSERVAÇÃO: " + x.Observacao,
+ IdCliente = ((DomainBase)x).Id
+ })).ToList());
+ break;
+ case 18:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(await new ItemServico().BuscaItensPorObs(Pesquisa, Status, vendedorVinculado, TipoBusca));
+ break;
+ case 13:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(((IEnumerable<Cliente>)(await new ClienteServico().BuscarPastaCliente(Pesquisa, TipoBusca))).Select((Func<Cliente, PesquisaAvancada>)((Cliente x) => new PesquisaAvancada
+ {
+ Nome = x.Nome,
+ Pesquisa = "PASTA: " + x.Pasta,
+ IdCliente = ((DomainBase)x).Id
+ })).ToList());
+ break;
+ case 17:
+ Pesquisas = new ObservableCollection<PesquisaAvancada>(((IEnumerable<Documento>)(await new ParcelaServico().BuscarFatura(Pesquisa))).Select((Func<Documento, PesquisaAvancada>)((Documento x) => new PesquisaAvancada
+ {
+ IdDocumento = ((DomainBase)x).Id,
+ Nome = x.Controle.Cliente.Nome,
+ Pesquisa = "CÓDIGO DA FATURA: " + x.Endosso,
+ IdCliente = ((DomainBase)x.Controle.Cliente).Id
+ })).ToList());
+ break;
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogProspeccaoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogProspeccaoViewModel.cs
new file mode 100644
index 0000000..a86bb11
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogProspeccaoViewModel.cs
@@ -0,0 +1,315 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogProspeccaoViewModel : BaseSegurosViewModel
+{
+ private readonly ClienteServico _servico;
+
+ private Prospeccao _selectedProspeccao;
+
+ private bool _isVisibleAnexos;
+
+ private ObservableCollection<ArquivoDigital> _arquivosAnexados = new ObservableCollection<ArquivoDigital>();
+
+ private ArquivoDigital _selectedAnexado = new ArquivoDigital();
+
+ private ObservableCollection<IndiceArquivoDigital> _arquivos = new ObservableCollection<IndiceArquivoDigital>();
+
+ private Visibility _visibilityStatusPersonalizado;
+
+ private ObservableCollection<Usuario> _usuarios;
+
+ private ObservableCollection<Vendedor> _vendedores;
+
+ private DateTime _dataAgendamento;
+
+ private DateTime _horaAgendamento;
+
+ private List<Produto> _produtos = Recursos.Produtos;
+
+ private ObservableCollection<StatusDeProspeccao> _statusProspeccao;
+
+ private List<Ramo> _ramos = Recursos.Ramos;
+
+ public Prospeccao SelectedProspeccao
+ {
+ get
+ {
+ return _selectedProspeccao;
+ }
+ set
+ {
+ _selectedProspeccao = value;
+ OnPropertyChanged("SelectedProspeccao");
+ }
+ }
+
+ public bool IsVisibleAnexos
+ {
+ get
+ {
+ return _isVisibleAnexos;
+ }
+ set
+ {
+ _isVisibleAnexos = value;
+ OnPropertyChanged("IsVisibleAnexos");
+ }
+ }
+
+ public ObservableCollection<ArquivoDigital> ArquivosAnexados
+ {
+ get
+ {
+ return _arquivosAnexados;
+ }
+ set
+ {
+ _arquivosAnexados = value;
+ OnPropertyChanged("ArquivosAnexados");
+ IsVisibleAnexos = value != null && value.Count > 0;
+ SelectedProspeccao.Anexos = value?.ToList();
+ }
+ }
+
+ public ArquivoDigital SelectedAnexado
+ {
+ get
+ {
+ return _selectedAnexado;
+ }
+ set
+ {
+ _selectedAnexado = value;
+ OnPropertyChanged("SelectedAnexado");
+ }
+ }
+
+ public ObservableCollection<IndiceArquivoDigital> Arquivos
+ {
+ get
+ {
+ return _arquivos;
+ }
+ set
+ {
+ _arquivos = value;
+ OnPropertyChanged("Arquivos");
+ }
+ }
+
+ public Visibility VisibilityStatusPersonalizado
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityStatusPersonalizado;
+ }
+ 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)
+ _visibilityStatusPersonalizado = value;
+ OnPropertyChanged("VisibilityStatusPersonalizado");
+ }
+ }
+
+ public ObservableCollection<Usuario> Usuarios
+ {
+ get
+ {
+ return _usuarios;
+ }
+ set
+ {
+ _usuarios = value;
+ OnPropertyChanged("Usuarios");
+ }
+ }
+
+ public ObservableCollection<Vendedor> Vendedores
+ {
+ get
+ {
+ return _vendedores;
+ }
+ set
+ {
+ _vendedores = value;
+ OnPropertyChanged("Vendedores");
+ }
+ }
+
+ public DateTime DataAgendamento
+ {
+ get
+ {
+ return _dataAgendamento;
+ }
+ set
+ {
+ _dataAgendamento = value;
+ if (SelectedProspeccao.Tarefa != null)
+ {
+ SelectedProspeccao.Tarefa.Agendamento = DateTime.Parse($"{value:d} {SelectedProspeccao.Tarefa.Agendamento:T}");
+ }
+ OnPropertyChanged("DataAgendamento");
+ }
+ }
+
+ public DateTime HoraAgendamento
+ {
+ get
+ {
+ return _horaAgendamento;
+ }
+ set
+ {
+ _horaAgendamento = value;
+ if (SelectedProspeccao.Tarefa != null)
+ {
+ SelectedProspeccao.Tarefa.Agendamento = DateTime.Parse($"{SelectedProspeccao.Tarefa.Agendamento:d} {value:T}");
+ }
+ OnPropertyChanged("HoraAgendamento");
+ }
+ }
+
+ public List<Produto> Produtos
+ {
+ get
+ {
+ return _produtos;
+ }
+ set
+ {
+ _produtos = value;
+ OnPropertyChanged("Produtos");
+ }
+ }
+
+ public ObservableCollection<StatusDeProspeccao> StatusProspeccao
+ {
+ get
+ {
+ return _statusProspeccao;
+ }
+ set
+ {
+ _statusProspeccao = value;
+ OnPropertyChanged("StatusProspeccao");
+ }
+ }
+
+ public List<Ramo> Ramos
+ {
+ get
+ {
+ return _ramos;
+ }
+ set
+ {
+ _ramos = value;
+ OnPropertyChanged("Ramos");
+ }
+ }
+
+ public DialogProspeccaoViewModel(Prospeccao prospeccao)
+ {
+ //IL_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0016: Expected O, but got Unknown
+ //IL_01bc: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01c1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01cc: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01d3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01df: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01ea: Unknown result type (might be due to invalid IL or missing references)
+ //IL_020e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_021f: Expected O, but got Unknown
+ _servico = new ClienteServico();
+ Usuarios = new ObservableCollection<Usuario>((from x in Recursos.Usuarios
+ where (Recursos.Usuario.IdEmpresa == 1 || x.IdEmpresa == Recursos.Usuario.IdEmpresa) && !x.Excluido
+ orderby x.Nome
+ select x).ToList());
+ Vendedores = new ObservableCollection<Vendedor>((from x in Recursos.Vendedores
+ where (Recursos.Usuario.IdEmpresa == 1 || x.IdEmpresa == Recursos.Usuario.IdEmpresa) && x.Ativo
+ orderby x.Nome
+ select x).ToList());
+ StatusProspeccao = new ObservableCollection<StatusDeProspeccao>((from x in Recursos.StatusProspeccao
+ where x.Ativo
+ orderby x.Nome
+ select x).ToList());
+ if (StatusProspeccao == null || StatusProspeccao.Count == 0)
+ {
+ VisibilityStatusPersonalizado = (Visibility)2;
+ }
+ if (prospeccao.Vendedor == null)
+ {
+ prospeccao.Vendedor = Vendedores.First((Vendedor x) => x.Corretora);
+ }
+ if (prospeccao.Tarefa == null)
+ {
+ prospeccao.Tarefa = new Tarefa
+ {
+ Titulo = "PROSPECÇÃO",
+ Entidade = (TipoTarefa)5,
+ IdEntidade = ((DomainBase)prospeccao).Id,
+ Usuario = Recursos.Usuario,
+ Agendamento = (prospeccao.VigenciaFinal ?? Funcoes.GetNetworkTime()),
+ Cliente = prospeccao.Nome
+ };
+ }
+ SelectedProspeccao = prospeccao;
+ Tarefa tarefa = prospeccao.Tarefa;
+ DataAgendamento = ((tarefa != null) ? new DateTime?(tarefa.Agendamento) : null).Value;
+ Tarefa tarefa2 = prospeccao.Tarefa;
+ HoraAgendamento = ((tarefa2 != null) ? new DateTime?(tarefa2.Agendamento) : null).Value;
+ }
+
+ public async Task<Cliente> BuscarInfoCliente(Cliente cliente)
+ {
+ cliente = await _servico.BuscarCliente(((DomainBase)cliente).Id);
+ Cliente val = cliente;
+ val.Telefones = await _servico.BuscarTelefonesAsync(((DomainBase)cliente).Id);
+ val = cliente;
+ val.Emails = await _servico.BuscarEmailsAsync(((DomainBase)cliente).Id);
+ return cliente;
+ }
+
+ public async void Anexar()
+ {
+ List<ArquivoDigital> attacheds = ((IEnumerable<IndiceArquivoDigital>)Arquivos).Select((Func<IndiceArquivoDigital, ArquivoDigital>)((IndiceArquivoDigital x) => new ArquivoDigital
+ {
+ Descricao = x.Descricao,
+ Extensao = x.Extensao
+ })).ToList();
+ List<ArquivoDigital> list = await AddAttachments(ArquivosAnexados.ToList(), attacheds);
+ if (list != null)
+ {
+ list.AddRange(ArquivosAnexados);
+ ArquivosAnexados = new ObservableCollection<ArquivoDigital>(list);
+ }
+ }
+
+ public void Delete(ArquivoDigital arquivo)
+ {
+ if (SelectedAnexado != null)
+ {
+ ArquivoDigital item = ArquivosAnexados.First((ArquivoDigital x) => x.Descricao == arquivo.Descricao);
+ ArquivosAnexados.Remove(item);
+ ArquivosAnexados = new ObservableCollection<ArquivoDigital>(ArquivosAnexados);
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogTarefaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogTarefaViewModel.cs
new file mode 100644
index 0000000..6e53508
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogTarefaViewModel.cs
@@ -0,0 +1,300 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Windows;
+using CsQuery.ExtensionMethods.Internal;
+using Gestor.Application.Helpers;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogTarefaViewModel : BaseSegurosViewModel
+{
+ private bool _showPublica;
+
+ private bool _nota;
+
+ private Visibility _cabecalho;
+
+ private Visibility _agendamento;
+
+ private Visibility _status;
+
+ private List<TelefoneBase> _telefones;
+
+ private ObservableCollection<Usuario> _usuarios;
+
+ private Tarefa _tarefa;
+
+ private DateTime _dataAgendamento = Funcoes.GetNetworkTime();
+
+ private DateTime _horaAgendamento = Funcoes.GetNetworkTime();
+
+ private ObservableCollection<Usuario> _responsaveis = new ObservableCollection<Usuario>();
+
+ private Usuario _selectedUsuario;
+
+ private bool _isAnotacoes = true;
+
+ public bool ShowPublica
+ {
+ get
+ {
+ return _showPublica;
+ }
+ set
+ {
+ _showPublica = value;
+ OnPropertyChanged("ShowPublica");
+ }
+ }
+
+ public bool Nota
+ {
+ get
+ {
+ return _nota;
+ }
+ set
+ {
+ _nota = value;
+ if (value)
+ {
+ Cabecalho = (Visibility)2;
+ Status = (Visibility)2;
+ }
+ }
+ }
+
+ public Visibility Cabecalho
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _cabecalho;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ _cabecalho = value;
+ this.MutateVerbose(ref _cabecalho, value, OnRaisePropertyChanged(), "Cabecalho");
+ }
+ }
+
+ public Visibility Agendamento
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _agendamento;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ _agendamento = value;
+ this.MutateVerbose(ref _agendamento, value, OnRaisePropertyChanged(), "Agendamento");
+ }
+ }
+
+ public Visibility Status
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _status;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ _status = value;
+ this.MutateVerbose(ref _status, value, OnRaisePropertyChanged(), "Status");
+ }
+ }
+
+ public List<TelefoneBase> Telefones
+ {
+ get
+ {
+ return _telefones;
+ }
+ set
+ {
+ _telefones = value;
+ this.MutateVerbose(ref _telefones, value, OnRaisePropertyChanged(), "Telefones");
+ }
+ }
+
+ public ObservableCollection<Usuario> Usuarios
+ {
+ get
+ {
+ return _usuarios;
+ }
+ set
+ {
+ _usuarios = value;
+ this.MutateVerbose(ref _usuarios, value, OnRaisePropertyChanged(), "Usuarios");
+ }
+ }
+
+ public Tarefa Tarefa
+ {
+ get
+ {
+ return _tarefa;
+ }
+ set
+ {
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ DataAgendamento = ((value != null) ? value.Agendamento : networkTime);
+ HoraAgendamento = ((value != null) ? value.Agendamento : networkTime);
+ this.MutateVerbose(ref _tarefa, value, OnRaisePropertyChanged(), "Tarefa");
+ }
+ }
+
+ public DateTime DataAgendamento
+ {
+ get
+ {
+ return _dataAgendamento;
+ }
+ set
+ {
+ _dataAgendamento = value;
+ if (Tarefa != null)
+ {
+ Tarefa.Agendamento = DateTime.Parse($"{value:d} {Tarefa.Agendamento:T}");
+ }
+ this.MutateVerbose(ref _dataAgendamento, value, OnRaisePropertyChanged(), "DataAgendamento");
+ }
+ }
+
+ public DateTime HoraAgendamento
+ {
+ get
+ {
+ return _horaAgendamento;
+ }
+ set
+ {
+ _horaAgendamento = value;
+ if (Tarefa != null)
+ {
+ Tarefa.Agendamento = DateTime.Parse($"{Tarefa.Agendamento:d} {value:T}");
+ }
+ this.MutateVerbose(ref _horaAgendamento, value, OnRaisePropertyChanged(), "HoraAgendamento");
+ }
+ }
+
+ public ObservableCollection<Usuario> Responsaveis
+ {
+ get
+ {
+ return _responsaveis;
+ }
+ set
+ {
+ _responsaveis = value;
+ OnPropertyChanged("Responsaveis");
+ }
+ }
+
+ public Usuario SelectedUsuario
+ {
+ get
+ {
+ return _selectedUsuario;
+ }
+ set
+ {
+ _selectedUsuario = value;
+ OnPropertyChanged("SelectedUsuario");
+ }
+ }
+
+ public bool IsAnotacoes
+ {
+ get
+ {
+ return _isAnotacoes;
+ }
+ set
+ {
+ _isAnotacoes = value;
+ OnPropertyChanged("IsAnotacoes");
+ }
+ }
+
+ public event PropertyChangedEventHandler RaisePropertyChanged;
+
+ public DialogTarefaViewModel(Tarefa tarefa, List<TelefoneBase> telefones, bool nota = false, bool agendamento = false)
+ {
+ //IL_00ac: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b2: Invalid comparison between Unknown and I4
+ ShowPublica = nota && tarefa.HabilitarPublica;
+ Telefones = telefones;
+ Usuarios = new ObservableCollection<Usuario>((from x in Recursos.Usuarios
+ where (Recursos.Usuario.IdEmpresa == 1 || x.IdEmpresa == Recursos.Usuario.IdEmpresa) && !x.Excluido
+ orderby x.Nome
+ select x).ToList());
+ Nota = nota;
+ if ((int)tarefa.Entidade == 1)
+ {
+ tarefa.Anotacoes = tarefa.Descricao;
+ tarefa.Descricao = string.Empty;
+ }
+ if (agendamento)
+ {
+ Agendamento = (Visibility)2;
+ }
+ if (tarefa.UsuariosVinculados != null)
+ {
+ ExtensionMethods.AddRange<Usuario>((ICollection<Usuario>)Responsaveis, (IEnumerable<Usuario>)tarefa.UsuariosVinculados);
+ }
+ Responsaveis.ToList().ForEach(delegate(Usuario x)
+ {
+ Usuarios.Remove(((IEnumerable<Usuario>)Usuarios).FirstOrDefault((Func<Usuario, bool>)((Usuario u) => ((DomainBase)u).Id == ((DomainBase)x).Id)));
+ });
+ Tarefa = tarefa;
+ }
+
+ private Action<PropertyChangedEventArgs> OnRaisePropertyChanged()
+ {
+ return delegate(PropertyChangedEventArgs args)
+ {
+ this.RaisePropertyChanged?.Invoke(this, args);
+ };
+ }
+
+ public void AdcionarResponsavel()
+ {
+ if (SelectedUsuario != null && !Responsaveis.Any((Usuario x) => x == SelectedUsuario))
+ {
+ Responsaveis.Add(SelectedUsuario);
+ Tarefa.UsuariosVinculados = Responsaveis.ToList();
+ Usuarios.Remove(SelectedUsuario);
+ SelectedUsuario = null;
+ }
+ }
+
+ public void RemoverResponsavel(Usuario selectedUsuario)
+ {
+ if (selectedUsuario != null)
+ {
+ Responsaveis.Remove(selectedUsuario);
+ Tarefa.UsuariosVinculados = Responsaveis.ToList();
+ Usuarios.Add(selectedUsuario);
+ selectedUsuario = null;
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogTrilhaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogTrilhaViewModel.cs
new file mode 100644
index 0000000..9ebc626
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogTrilhaViewModel.cs
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using Gestor.Application.Helpers;
+using Gestor.Model.Domain.Ferramentas;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogTrilhaViewModel : INotifyPropertyChanged
+{
+ private Trilha _trilha;
+
+ private ObservableCollection<Fase> _fases;
+
+ private Fase _selectedFase;
+
+ public Trilha Trilha
+ {
+ get
+ {
+ return _trilha;
+ }
+ set
+ {
+ this.MutateVerbose(ref _trilha, value, RaisePropertyChanged(), "Trilha");
+ }
+ }
+
+ public ObservableCollection<Fase> Fases
+ {
+ get
+ {
+ return _fases;
+ }
+ set
+ {
+ this.MutateVerbose(ref _fases, value, RaisePropertyChanged(), "Fases");
+ }
+ }
+
+ public Fase SelectedFase
+ {
+ get
+ {
+ return _selectedFase;
+ }
+ set
+ {
+ this.MutateVerbose(ref _selectedFase, value, RaisePropertyChanged(), "SelectedFase");
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private Action<PropertyChangedEventArgs> RaisePropertyChanged()
+ {
+ return delegate(PropertyChangedEventArgs args)
+ {
+ this.PropertyChanged?.Invoke(this, args);
+ };
+ }
+
+ public void AdicionarFase()
+ {
+ //IL_0019: 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_0029: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0039: Expected O, but got Unknown
+ if (Fases == null)
+ {
+ Fases = new ObservableCollection<Fase>();
+ }
+ Fases.Add(new Fase
+ {
+ Titulo = "TÍTULO",
+ Descricao = "DESCRIÇÃO"
+ });
+ Fases = new ObservableCollection<Fase>(Fases);
+ Trilha.Fases = Fases.ToList();
+ }
+
+ public void ExcluirFase(Fase fase)
+ {
+ Fases.RemoveAt(Fases.IndexOf(fase));
+ Fases = new ObservableCollection<Fase>(Fases);
+ Trilha.Fases = Fases.ToList();
+ }
+
+ public void UpdateFase(int index)
+ {
+ Fases[index] = SelectedFase;
+ Trilha.Fases = Fases.ToList();
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogViewModel.cs
new file mode 100644
index 0000000..c9b9595
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogViewModel.cs
@@ -0,0 +1,78 @@
+using System;
+using System.ComponentModel;
+using System.Windows;
+using Gestor.Application.Helpers;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogViewModel : INotifyPropertyChanged
+{
+ private string _message;
+
+ private string _acceptContent;
+
+ private string _cancelContent;
+
+ private Visibility _cancelVisibility;
+
+ public string Message
+ {
+ get
+ {
+ return _message;
+ }
+ set
+ {
+ this.MutateVerbose(ref _message, value, RaisePropertyChanged(), "Message");
+ }
+ }
+
+ public string AcceptContent
+ {
+ get
+ {
+ return _acceptContent;
+ }
+ set
+ {
+ this.MutateVerbose(ref _acceptContent, value, RaisePropertyChanged(), "AcceptContent");
+ }
+ }
+
+ public string CancelContent
+ {
+ get
+ {
+ return _cancelContent;
+ }
+ set
+ {
+ CancelVisibility = (Visibility)(string.IsNullOrEmpty(value) ? 2 : 0);
+ this.MutateVerbose(ref _cancelContent, value, RaisePropertyChanged(), "CancelContent");
+ }
+ }
+
+ public Visibility CancelVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _cancelVisibility;
+ }
+ set
+ {
+ //IL_0007: Unknown result type (might be due to invalid IL or missing references)
+ this.MutateVerbose(ref _cancelVisibility, value, RaisePropertyChanged(), "CancelVisibility");
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private Action<PropertyChangedEventArgs> RaisePropertyChanged()
+ {
+ return delegate(PropertyChangedEventArgs args)
+ {
+ this.PropertyChanged?.Invoke(this, args);
+ };
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/DialogVinculoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/DialogVinculoViewModel.cs
new file mode 100644
index 0000000..e39aaf7
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/DialogVinculoViewModel.cs
@@ -0,0 +1,177 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Gestor.Application.Helpers;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class DialogVinculoViewModel : BaseViewModel
+{
+ private Repasse _repasse;
+
+ private List<TipoVendedor> _tiposVendedor = Recursos.TipoVendedor?.Where((TipoVendedor x) => !x.Ativo.HasValue || x.Ativo.Value).ToList();
+
+ private ObservableCollection<Vendedor> _vendedoresAtivos = new ObservableCollection<Vendedor>();
+
+ private Vendedor _selectedVendedor = new Vendedor();
+
+ private ObservableCollection<Repasse> _repassesVinculo = new ObservableCollection<Repasse>();
+
+ private Repasse _selectedRepasse = new Repasse();
+
+ private TipoVendedor _selectedTipo = new TipoVendedor();
+
+ private TipoVendedor _selectedTipoVinculo = new TipoVendedor();
+
+ public Repasse Repasse
+ {
+ get
+ {
+ return _repasse;
+ }
+ set
+ {
+ _repasse = value;
+ OnPropertyChanged("Repasse");
+ }
+ }
+
+ public VinculoRepasse Vinculo { get; set; }
+
+ public List<Vendedor> Vendedores { get; set; }
+
+ public List<Repasse> Repasses { get; set; }
+
+ public List<TipoVendedor> TiposVendedor
+ {
+ get
+ {
+ return _tiposVendedor;
+ }
+ set
+ {
+ _tiposVendedor = value;
+ OnPropertyChanged("TiposVendedor");
+ }
+ }
+
+ public ObservableCollection<Vendedor> VendedoresAtivos
+ {
+ get
+ {
+ return _vendedoresAtivos;
+ }
+ set
+ {
+ _vendedoresAtivos = value;
+ OnPropertyChanged("VendedoresAtivos");
+ }
+ }
+
+ public Vendedor SelectedVendedor
+ {
+ get
+ {
+ return _selectedVendedor;
+ }
+ set
+ {
+ _selectedVendedor = value;
+ RepassesVinculo = ((value == null) ? null : new ObservableCollection<Repasse>(Repasses.Where((Repasse x) => ((DomainBase)x.Vendedor).Id == ((DomainBase)value).Id)));
+ OnPropertyChanged("SelectedVendedor");
+ }
+ }
+
+ public ObservableCollection<Repasse> RepassesVinculo
+ {
+ get
+ {
+ return _repassesVinculo;
+ }
+ set
+ {
+ _repassesVinculo = value;
+ OnPropertyChanged("RepassesVinculo");
+ }
+ }
+
+ public Repasse SelectedRepasse
+ {
+ get
+ {
+ return _selectedRepasse;
+ }
+ set
+ {
+ _selectedRepasse = value;
+ Vinculo.RepasseVinculo = value;
+ OnPropertyChanged("SelectedRepasse");
+ }
+ }
+
+ public TipoVendedor SelectedTipo
+ {
+ get
+ {
+ return _selectedTipo;
+ }
+ set
+ {
+ _selectedTipo = value;
+ Vinculo.TipoVendedor = value;
+ OnPropertyChanged("SelectedTipo");
+ }
+ }
+
+ public TipoVendedor SelectedTipoVinculo
+ {
+ get
+ {
+ return _selectedTipoVinculo;
+ }
+ set
+ {
+ _selectedTipoVinculo = value;
+ Vinculo.TipoVendedorVinculo = value;
+ OnPropertyChanged("SelectedTipoVinculo");
+ }
+ }
+
+ public DialogVinculoViewModel(VinculoRepasse vinculo, List<Repasse> repasses, Repasse repasse)
+ {
+ //IL_0047: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0051: Expected O, but got Unknown
+ //IL_005d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0067: Expected O, but got Unknown
+ //IL_0068: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0072: Expected O, but got Unknown
+ //IL_0073: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007d: Expected O, but got Unknown
+ //IL_00ac: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b1: 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_00d8: Expected O, but got Unknown
+ DialogVinculoViewModel dialogVinculoViewModel = this;
+ Repasse = repasse;
+ Repasses = repasses;
+ Vinculo = new VinculoRepasse
+ {
+ IdRepasse = vinculo.IdRepasse,
+ Id = ((DomainBase)vinculo).Id
+ };
+ Vendedores = (from x in Repasses
+ group x by ((DomainBase)x.Vendedor).Id into x
+ select x.First().Vendedor into x
+ orderby x.Nome
+ select x).ToList();
+ long idvendedor = ((DomainBase)Repasses.First((Repasse x) => ((DomainBase)x).Id == dialogVinculoViewModel.Vinculo.IdRepasse).Vendedor).Id;
+ VendedoresAtivos = new ObservableCollection<Vendedor>(Vendedores.Where((Vendedor x) => x.IdEmpresa == Recursos.Usuario.IdEmpresa && x.Ativo && !x.Corretora && ((DomainBase)x).Id != idvendedor));
+ SelectedVendedor = ((vinculo.RepasseVinculo != null) ? ((IEnumerable<Vendedor>)VendedoresAtivos).FirstOrDefault((Func<Vendedor, bool>)((Vendedor x) => ((DomainBase)x).Id == ((DomainBase)vinculo.RepasseVinculo.Vendedor).Id)) : null);
+ SelectedRepasse = ((vinculo.RepasseVinculo != null) ? ((IEnumerable<Repasse>)RepassesVinculo).FirstOrDefault((Func<Repasse, bool>)((Repasse x) => ((DomainBase)x).Id == ((DomainBase)vinculo.RepasseVinculo).Id)) : null);
+ SelectedTipo = ((vinculo.TipoVendedor != null) ? ((IEnumerable<TipoVendedor>)TiposVendedor).FirstOrDefault((Func<TipoVendedor, bool>)((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)vinculo.TipoVendedor).Id)) : null);
+ SelectedTipoVinculo = ((vinculo.TipoVendedorVinculo != null) ? ((IEnumerable<TipoVendedor>)TiposVendedor).FirstOrDefault((Func<TipoVendedor, bool>)((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)vinculo.TipoVendedorVinculo).Id)) : null);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/ErrorDialogViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/ErrorDialogViewModel.cs
new file mode 100644
index 0000000..66e554c
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/ErrorDialogViewModel.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using Gestor.Application.Helpers;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class ErrorDialogViewModel : DialogViewModel, INotifyPropertyChanged
+{
+ private List<KeyValuePair<string, string>> _erros;
+
+ public List<KeyValuePair<string, string>> Erros
+ {
+ get
+ {
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ foreach (KeyValuePair<string, string> erro in _erros)
+ {
+ list.Add(new KeyValuePair<string, string>(erro.Key.ToUpper(), erro.Value.ToUpper()));
+ }
+ return list;
+ }
+ set
+ {
+ this.MutateVerbose(ref _erros, value, RaisePropertyChanged(), "Erros");
+ }
+ }
+
+ public new event PropertyChangedEventHandler PropertyChanged;
+
+ private Action<PropertyChangedEventArgs> RaisePropertyChanged()
+ {
+ return delegate(PropertyChangedEventArgs args)
+ {
+ this.PropertyChanged?.Invoke(this, args);
+ };
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/ExtratoComissaoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/ExtratoComissaoViewModel.cs
new file mode 100644
index 0000000..de7163c
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/ExtratoComissaoViewModel.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class ExtratoComissaoViewModel : BaseViewModel
+{
+ private ServicoExtrato _servico;
+
+ private bool _apelido;
+
+ private List<Seguradora> _seguradoras;
+
+ private DateTime _inicio = new DateTime(Funcoes.GetNetworkTime().Date.Year, Funcoes.GetNetworkTime().Date.Month, 1);
+
+ private DateTime _fim = Funcoes.GetNetworkTime().Date;
+
+ private ObservableCollection<Extrato> _extratos;
+
+ public bool Apelido
+ {
+ get
+ {
+ return _apelido;
+ }
+ set
+ {
+ _apelido = value;
+ OnPropertyChanged("Apelido");
+ }
+ }
+
+ public List<Seguradora> Seguradoras
+ {
+ get
+ {
+ return _seguradoras;
+ }
+ set
+ {
+ _seguradoras = value;
+ OnPropertyChanged("Seguradoras");
+ }
+ }
+
+ public DateTime Inicio
+ {
+ get
+ {
+ return _inicio;
+ }
+ set
+ {
+ _inicio = value;
+ OnPropertyChanged("Inicio");
+ }
+ }
+
+ public DateTime Fim
+ {
+ get
+ {
+ return _fim;
+ }
+ set
+ {
+ _fim = value;
+ OnPropertyChanged("Fim");
+ }
+ }
+
+ public ObservableCollection<Extrato> Extratos
+ {
+ get
+ {
+ return _extratos;
+ }
+ set
+ {
+ _extratos = value;
+ OnPropertyChanged("Extratos");
+ }
+ }
+
+ public ExtratoComissaoViewModel(List<Seguradora> seguradoras)
+ {
+ _servico = new ServicoExtrato();
+ Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 6);
+ Seguradoras = seguradoras;
+ }
+
+ public async Task CarregarExtratos(Seguradora seguradora, DateTime inicio, DateTime fim)
+ {
+ Extratos = new ObservableCollection<Extrato>(await _servico.BuscarExtrato(((DomainBase)seguradora).Id, 0L, (StatusExtrato)4, inicio, fim));
+ }
+
+ internal void SelecionarTudo()
+ {
+ if (Extratos != null)
+ {
+ Extratos.ToList().ForEach(delegate(Extrato x)
+ {
+ x.Selecionado = !x.Selecionado;
+ });
+ Extratos = new ObservableCollection<Extrato>(Extratos);
+ }
+ }
+
+ internal List<NotaFiscal> Selecionar()
+ {
+ if (Extratos == null)
+ {
+ return null;
+ }
+ return Extratos.Where((Extrato x) => x.Selecionado).Select((Func<Extrato, NotaFiscal>)((Extrato x) => new NotaFiscal
+ {
+ IdExtrato = ((DomainBase)x).Id,
+ Seguradora = x.Seguradora,
+ Data = x.Data,
+ Iss = x.Iss.GetValueOrDefault(),
+ Ir = x.Ir.GetValueOrDefault(),
+ ValorBruto = x.Bruto.GetValueOrDefault(),
+ ValorLiquido = x.Liquido.GetValueOrDefault(),
+ Extrato = x.Numero
+ })).ToList();
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/ItemViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/ItemViewModel.cs
new file mode 100644
index 0000000..22dba97
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/ItemViewModel.cs
@@ -0,0 +1,682 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Data;
+using System.Globalization;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+using CsQuery.ExtensionMethods.Internal;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Microsoft.Office.Interop.Excel;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class ItemViewModel : BaseSegurosViewModel
+{
+ private bool _alterandoFiltros;
+
+ public CoberturaViewModel CoberturaViewModel;
+
+ public ItemServico _itemServico;
+
+ private Visibility _alteracaoTitularesVisibility = (Visibility)2;
+
+ private bool _enableAlterarExcluirTitulares;
+
+ private List<TitularesVida> _excluirTlitulares = new List<TitularesVida>();
+
+ private TitularesVida _titularAlteracao = new TitularesVida();
+
+ private bool _codigo;
+
+ private bool _inicio;
+
+ private bool _fim;
+
+ private bool _fatura;
+
+ private bool _nome;
+
+ private bool _observacao;
+
+ private bool _nascimento;
+
+ private bool _cpf;
+
+ private bool _matricula;
+
+ private bool _premio;
+
+ private bool _capital;
+
+ private bool _tipo;
+
+ private ObservableCollection<TitularesVida> _titulares = new ObservableCollection<TitularesVida>();
+
+ private bool? _allSelected = false;
+
+ private bool _allSelectedChanging;
+
+ private List<TitularesVida> _oldTitulares = new List<TitularesVida>();
+
+ public Item ItemSubstituido { get; set; }
+
+ public bool Mantido { get; set; }
+
+ public Visibility AlteracaoTitularesVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _alteracaoTitularesVisibility;
+ }
+ 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)
+ _alteracaoTitularesVisibility = value;
+ OnPropertyChanged("AlteracaoTitularesVisibility");
+ }
+ }
+
+ public bool EnableAlterarExcluirTitulares
+ {
+ get
+ {
+ return _enableAlterarExcluirTitulares;
+ }
+ set
+ {
+ _enableAlterarExcluirTitulares = value;
+ OnPropertyChanged("EnableAlterarExcluirTitulares");
+ }
+ }
+
+ public List<TitularesVida> ExcluirTitulares
+ {
+ get
+ {
+ return _excluirTlitulares;
+ }
+ set
+ {
+ _excluirTlitulares = value;
+ OnPropertyChanged("ExcluirTitulares");
+ }
+ }
+
+ public TitularesVida TitularAlteracao
+ {
+ get
+ {
+ return _titularAlteracao;
+ }
+ set
+ {
+ _titularAlteracao = value;
+ OnPropertyChanged("TitularAlteracao");
+ }
+ }
+
+ public bool Codigo
+ {
+ get
+ {
+ return _codigo;
+ }
+ set
+ {
+ _codigo = value;
+ OnPropertyChanged("Codigo");
+ }
+ }
+
+ public bool Inicio
+ {
+ get
+ {
+ return _inicio;
+ }
+ set
+ {
+ _inicio = value;
+ OnPropertyChanged("Inicio");
+ }
+ }
+
+ public bool Fim
+ {
+ get
+ {
+ return _fim;
+ }
+ set
+ {
+ _fim = value;
+ OnPropertyChanged("Fim");
+ }
+ }
+
+ public bool Fatura
+ {
+ get
+ {
+ return _fatura;
+ }
+ set
+ {
+ _fatura = value;
+ OnPropertyChanged("Fatura");
+ }
+ }
+
+ public bool Nome
+ {
+ get
+ {
+ return _nome;
+ }
+ set
+ {
+ _nome = value;
+ OnPropertyChanged("Nome");
+ }
+ }
+
+ public bool Observacao
+ {
+ get
+ {
+ return _observacao;
+ }
+ set
+ {
+ _observacao = value;
+ OnPropertyChanged("Observacao");
+ }
+ }
+
+ public bool Nascimento
+ {
+ get
+ {
+ return _nascimento;
+ }
+ set
+ {
+ _nascimento = value;
+ OnPropertyChanged("Nascimento");
+ }
+ }
+
+ public bool Cpf
+ {
+ get
+ {
+ return _cpf;
+ }
+ set
+ {
+ _cpf = value;
+ OnPropertyChanged("Cpf");
+ }
+ }
+
+ public bool Matricula
+ {
+ get
+ {
+ return _matricula;
+ }
+ set
+ {
+ _matricula = value;
+ OnPropertyChanged("Matricula");
+ }
+ }
+
+ public bool Premio
+ {
+ get
+ {
+ return _premio;
+ }
+ set
+ {
+ _premio = value;
+ OnPropertyChanged("Premio");
+ }
+ }
+
+ public bool Capital
+ {
+ get
+ {
+ return _capital;
+ }
+ set
+ {
+ _capital = value;
+ OnPropertyChanged("Capital");
+ }
+ }
+
+ public bool Tipo
+ {
+ get
+ {
+ return _tipo;
+ }
+ set
+ {
+ _tipo = value;
+ OnPropertyChanged("Tipo");
+ }
+ }
+
+ public ObservableCollection<TitularesVida> Titulares
+ {
+ get
+ {
+ return _titulares;
+ }
+ set
+ {
+ _titulares = value;
+ foreach (TitularesVida titulare in Titulares)
+ {
+ titulare.PropertyChanged += TitularesOnPropertyChanged;
+ }
+ OnPropertyChanged("Titulares");
+ }
+ }
+
+ public bool? AllSelected
+ {
+ get
+ {
+ return _allSelected;
+ }
+ set
+ {
+ if (value != _allSelected)
+ {
+ EnableAlterarExcluirTitulares = value != false;
+ if (value == false)
+ {
+ AlteracaoTitularesVisibility = (Visibility)2;
+ }
+ _allSelected = value;
+ AllSelectedChanged();
+ Titulares = new ObservableCollection<TitularesVida>(Titulares);
+ OnPropertyChanged("AllSelected");
+ }
+ }
+ }
+
+ public List<TitularesVida> OldTitulares
+ {
+ get
+ {
+ return _oldTitulares;
+ }
+ set
+ {
+ _oldTitulares = value;
+ OnPropertyChanged("OldTitulares");
+ }
+ }
+
+ public AutoCompleteFilterPredicate<object> DependenteItemFilter => (string searchText, object obj) => ((TitularesVida)obj).Nome.ToUpper().Contains(searchText.ToUpper()) && (int)((TitularesVida)obj).Tipo.GetValueOrDefault() != 2;
+
+ public ItemViewModel()
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0013: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001d: Expected O, but got Unknown
+ CoberturaViewModel = new CoberturaViewModel();
+ _itemServico = new ItemServico();
+ }
+
+ public async Task<int> QuantidadeDeItens(long id)
+ {
+ return await new ItemServico().BuscarProximoItem(id);
+ }
+
+ private void AllSelectedChanged()
+ {
+ if (_allSelectedChanging)
+ {
+ return;
+ }
+ try
+ {
+ _alterandoFiltros = true;
+ _allSelectedChanging = true;
+ if (!AllSelected.HasValue)
+ {
+ return;
+ }
+ foreach (TitularesVida titulare in Titulares)
+ {
+ titulare.Selecionado = AllSelected.Value;
+ }
+ _alterandoFiltros = false;
+ }
+ finally
+ {
+ _allSelectedChanging = false;
+ }
+ }
+
+ private void TitularesOnPropertyChanged(object sender, PropertyChangedEventArgs args)
+ {
+ if (!_alterandoFiltros)
+ {
+ RecheckAllSelected();
+ }
+ }
+
+ public void RecheckAllSelected()
+ {
+ if (_allSelectedChanging)
+ {
+ return;
+ }
+ try
+ {
+ _allSelectedChanging = true;
+ if (Titulares.All((TitularesVida e) => e.Selecionado))
+ {
+ AllSelected = true;
+ }
+ else if (Titulares.All((TitularesVida e) => !e.Selecionado))
+ {
+ AllSelected = false;
+ }
+ else
+ {
+ AllSelected = null;
+ }
+ }
+ finally
+ {
+ _allSelectedChanging = false;
+ }
+ }
+
+ public async Task ImportarTitulares()
+ {
+ OpenFileDialog val = new OpenFileDialog();
+ string path;
+ try
+ {
+ ((FileDialog)val).Filter = "Excel|*.xls;*.xlsx";
+ ((FileDialog)val).InitialDirectory = Environment.SpecialFolder.Desktop.ToString();
+ if (1 != (int)((CommonDialog)val).ShowDialog())
+ {
+ return;
+ }
+ path = ((FileDialog)val).FileName;
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ Loading(isLoading: true);
+ try
+ {
+ List<TitularesVida> list = await Task.Run(delegate
+ {
+ Microsoft.Office.Interop.Excel.Application application = (Microsoft.Office.Interop.Excel.Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
+ Workbook workbook = application.Workbooks.Open(path, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
+ List<string> list2 = new List<string>
+ {
+ "codigo", "inicio", "fim", "fatura", "nome", "nascimento", "cpf", "matricula", "premio", "capital",
+ "tipo", "observacao", "titulardependente"
+ };
+ List<DataTable> list3 = new List<DataTable>();
+ foreach (object worksheet in workbook.Worksheets)
+ {
+ DataTable dataTable = new DataTable();
+ Microsoft.Office.Interop.Excel.Range usedRange = ((Worksheet)worksheet).UsedRange;
+ object[,] array = (dynamic)usedRange.Value2;
+ int num = 0;
+ if (array != null)
+ {
+ for (int i = 0; i <= usedRange.Columns.Count - 1; i++)
+ {
+ if (array[1, i + 1] == null || !list2.Contains(Funcoes.RemoverAcentos(array[1, i + 1].ToString().ToLower().Trim())))
+ {
+ num--;
+ }
+ else
+ {
+ DataColumn column = new DataColumn
+ {
+ DataType = Type.GetType("System.String"),
+ ColumnName = Funcoes.RemoverAcentos(array[1, i + 1].ToString().ToLower().Trim())
+ };
+ dataTable.Columns.Add(column);
+ for (int j = 0; j <= usedRange.Rows.Count - 2; j++)
+ {
+ object obj2 = array[j + 2, i + 1];
+ array[1, i + 1].ToString().ToLower();
+ string value;
+ if (Funcoes.RemoverAcentos(array[1, i + 1].ToString().Trim().ToLower()) == "inicio" || Funcoes.RemoverAcentos(array[1, i + 1].ToString().Trim().ToLower()) == "fim" || Funcoes.RemoverAcentos(array[1, i + 1].ToString().Trim().ToLower()) == "nascimento")
+ {
+ DateTime result;
+ if (obj2 is double d)
+ {
+ result = DateTime.FromOADate(d);
+ value = result.ToShortDateString();
+ }
+ else if (DateTime.TryParse((string)obj2, out result))
+ {
+ result = DateTime.Parse((string)obj2);
+ value = result.ToShortDateString();
+ }
+ else
+ {
+ value = "";
+ }
+ }
+ else
+ {
+ value = ((obj2 is string text) ? Funcoes.RemoverAcentos(text).ToUpper().Trim() : ((obj2 is double num2) ? num2.ToString(CultureInfo.InvariantCulture) : ((!(obj2 is bool)) ? "" : (((bool)obj2) ? "1" : "0"))));
+ }
+ if (i + num == 0)
+ {
+ dataTable.Rows.Add(dataTable.NewRow());
+ dataTable.Rows[j][i + num] = value;
+ }
+ else
+ {
+ dataTable.Rows[j][i + num] = value;
+ }
+ }
+ }
+ }
+ list3.Add(dataTable);
+ }
+ }
+ application.Quit();
+ List<TitularesVida> list4 = new List<TitularesVida>();
+ foreach (DataTable dt in list3)
+ {
+ list4.AddRange(((IEnumerable<DataRow>)(from x in dt.AsEnumerable()
+ where x.Field<object>("nome") != null && !string.IsNullOrEmpty(x.Field<object>("nome").ToString())
+ select x).ToList()).Select((Func<DataRow, TitularesVida>)((DataRow x) => new TitularesVida
+ {
+ Codigo = ((!dt.Columns.Contains("codigo") || string.IsNullOrWhiteSpace(x.Field<object>("codigo").ToString())) ? null : x.Field<object>("codigo").ToString().ToUpper()),
+ Inicio = ((!dt.Columns.Contains("inicio") || string.IsNullOrWhiteSpace(x.Field<object>("inicio").ToString())) ? null : new DateTime?(DateTime.Parse(x.Field<object>("inicio").ToString()))),
+ Fim = ((!dt.Columns.Contains("fim") | string.IsNullOrWhiteSpace(x.Field<object>("fim").ToString())) ? null : new DateTime?(DateTime.Parse(x.Field<object>("fim").ToString()))),
+ Fatura = ((!dt.Columns.Contains("fatura") || string.IsNullOrWhiteSpace(x.Field<object>("fatura").ToString())) ? null : x.Field<object>("fatura").ToString().ToUpper()),
+ Nome = ((!dt.Columns.Contains("nome") || string.IsNullOrWhiteSpace(x.Field<object>("nome").ToString())) ? null : x.Field<object>("nome").ToString().ToUpper()),
+ Observacao = ((!dt.Columns.Contains("observacao") || string.IsNullOrWhiteSpace(x.Field<object>("observacao").ToString())) ? null : x.Field<object>("observacao").ToString().ToUpper()),
+ Nascimento = ((!dt.Columns.Contains("nascimento") || string.IsNullOrWhiteSpace(x.Field<object>("nascimento").ToString())) ? null : new DateTime?(DateTime.Parse(x.Field<object>("nascimento").ToString()))),
+ Cpf = ((!dt.Columns.Contains("cpf") || string.IsNullOrWhiteSpace(x.Field<object>("cpf").ToString())) ? null : x.Field<object>("cpf").ToString()),
+ Matricula = ((!dt.Columns.Contains("matricula") || string.IsNullOrWhiteSpace(x.Field<object>("matricula").ToString())) ? null : x.Field<object>("matricula").ToString().ToUpper()),
+ Premio = ((!dt.Columns.Contains("premio") || string.IsNullOrWhiteSpace(x.Field<object>("premio").ToString())) ? null : new decimal?(decimal.Parse(x.Field<object>("premio").ToString(), NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, CultureInfo.InvariantCulture))),
+ Capital = ((!dt.Columns.Contains("capital") || string.IsNullOrWhiteSpace(x.Field<object>("capital").ToString())) ? null : new decimal?(decimal.Parse(x.Field<object>("capital").ToString(), NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, CultureInfo.InvariantCulture))),
+ Tipo = ((!dt.Columns.Contains("tipo") || string.IsNullOrWhiteSpace(x.Field<object>("tipo").ToString())) ? null : ((x.Field<object>("tipo").ToString() == "SOCIO") ? new TipoTitular?((TipoTitular)0) : ((x.Field<object>("tipo").ToString() == "FUNCIONARIO") ? new TipoTitular?((TipoTitular)1) : null)))
+ })).ToList());
+ }
+ return list4;
+ });
+ Loading(isLoading: false);
+ if (list.Count == 0)
+ {
+ await ShowMessage("NENHUMA COLUNA FOI ENCONTRADA");
+ }
+ else
+ {
+ ExtensionMethods.AddRange<TitularesVida>((ICollection<TitularesVida>)Titulares, (IEnumerable<TitularesVida>)list);
+ }
+ }
+ catch
+ {
+ Loading(isLoading: false);
+ await ShowMessage("FALHA AO IMPORTAR O EXCEL, VERIFIQUE SE O ARQUIVO POSSUI ALGUM ERRO.");
+ }
+ }
+
+ public void AlterarTitular()
+ {
+ //IL_0001: 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_001b: Expected O, but got Unknown
+ if ((int)AlteracaoTitularesVisibility == 0)
+ {
+ AlteracaoTitularesVisibility = (Visibility)2;
+ return;
+ }
+ TitularAlteracao = new TitularesVida();
+ Codigo = false;
+ Inicio = false;
+ Fim = false;
+ Fatura = false;
+ Nome = false;
+ Nascimento = false;
+ Cpf = false;
+ Matricula = false;
+ Premio = false;
+ Capital = false;
+ Tipo = false;
+ AlteracaoTitularesVisibility = (Visibility)0;
+ }
+
+ public void AplicarTitular()
+ {
+ foreach (TitularesVida item in Titulares.Where((TitularesVida x) => x.Selecionado).ToList())
+ {
+ if (Codigo)
+ {
+ item.Codigo = TitularAlteracao.Codigo;
+ }
+ if (Inicio)
+ {
+ item.Inicio = TitularAlteracao.Inicio;
+ }
+ if (Fim)
+ {
+ item.Fim = TitularAlteracao.Fim;
+ }
+ if (Fatura)
+ {
+ item.Fatura = TitularAlteracao.Fatura;
+ }
+ if (Nome)
+ {
+ item.Nome = TitularAlteracao.Nome;
+ }
+ if (Observacao)
+ {
+ item.Observacao = TitularAlteracao.Observacao;
+ }
+ if (Nascimento)
+ {
+ item.Nascimento = TitularAlteracao.Nascimento;
+ }
+ if (Cpf)
+ {
+ item.Cpf = TitularAlteracao.Cpf;
+ }
+ if (Matricula)
+ {
+ item.Matricula = TitularAlteracao.Matricula;
+ }
+ if (Premio)
+ {
+ item.Premio = TitularAlteracao.Premio;
+ }
+ if (Capital)
+ {
+ item.Capital = TitularAlteracao.Capital;
+ }
+ if (Tipo)
+ {
+ item.Tipo = TitularAlteracao.Tipo;
+ }
+ }
+ Titulares = new ObservableCollection<TitularesVida>(Titulares);
+ AlteracaoTitularesVisibility = (Visibility)2;
+ }
+
+ internal async Task<List<TitularesVida>> BuscarTitulares(string value)
+ {
+ return await Task.Run(() => Titulares.Where((TitularesVida x) => (int)x.Tipo.GetValueOrDefault() != 2 && x.Nome != null && ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(value.ToUpper())).ToList());
+ }
+
+ public async Task CarregarTitulares(long id)
+ {
+ Titulares = new ObservableCollection<TitularesVida>(await _itemServico.BuscaTitularesVida(id));
+ OldTitulares = ((IEnumerable<TitularesVida>)Titulares.ToList()).Select((Func<TitularesVida, TitularesVida>)((TitularesVida x) => new TitularesVida
+ {
+ Id = ((DomainBase)x).Id,
+ IdItem = x.IdItem,
+ Codigo = x.Codigo,
+ Inicio = x.Inicio,
+ Fim = x.Fim,
+ Fatura = x.Fatura,
+ Nome = x.Nome,
+ Observacao = x.Observacao,
+ Nascimento = x.Nascimento,
+ Cpf = x.Cpf,
+ Matricula = x.Matricula,
+ Premio = x.Premio,
+ Capital = x.Capital,
+ Tipo = x.Tipo,
+ Dependente = x.Dependente
+ })).ToList();
+ }
+
+ public void IncluirTitular()
+ {
+ //IL_0007: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0011: Expected O, but got Unknown
+ Titulares.Insert(0, new TitularesVida());
+ Titulares = new ObservableCollection<TitularesVida>(Titulares);
+ }
+
+ public void ExcluirTitular()
+ {
+ List<TitularesVida> list = Titulares.Where((TitularesVida x) => x.Selecionado).ToList();
+ ExcluirTitulares.AddRange(list.Where((TitularesVida x) => ((DomainBase)x).Id > 0));
+ foreach (TitularesVida item in list)
+ {
+ Titulares.Remove(item);
+ }
+ AllSelected = false;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/ProtocoloViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/ProtocoloViewModel.cs
new file mode 100644
index 0000000..dbb3048
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/ProtocoloViewModel.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class ProtocoloViewModel : BaseSegurosViewModel
+{
+ private ObservableCollection<Documento> _itens = new ObservableCollection<Documento>();
+
+ public ObservableCollection<Documento> Itens
+ {
+ get
+ {
+ return _itens;
+ }
+ set
+ {
+ _itens = value;
+ OnPropertyChanged("Itens");
+ }
+ }
+
+ public ProtocoloViewModel(List<Documento> itens)
+ {
+ Itens = new ObservableCollection<Documento>(itens);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/ReordenarItensViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/ReordenarItensViewModel.cs
new file mode 100644
index 0000000..27ca9c2
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/ReordenarItensViewModel.cs
@@ -0,0 +1,63 @@
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class ReordenarItensViewModel : BaseSegurosViewModel
+{
+ private readonly ItemServico _itemServico;
+
+ private bool _carregando;
+
+ private ObservableCollection<Item> _itens = new ObservableCollection<Item>();
+
+ public bool Carregando
+ {
+ get
+ {
+ return _carregando;
+ }
+ set
+ {
+ _carregando = value;
+ OnPropertyChanged("Carregando");
+ }
+ }
+
+ public ObservableCollection<Item> Itens
+ {
+ get
+ {
+ return _itens;
+ }
+ set
+ {
+ _itens = value;
+ OnPropertyChanged("Itens");
+ }
+ }
+
+ public ReordenarItensViewModel(List<long> ids)
+ {
+ _itemServico = new ItemServico();
+ CarregarItens(ids);
+ }
+
+ private async void CarregarItens(List<long> ids)
+ {
+ Carregando = true;
+ Itens = await _itemServico.BuscarItens(ids);
+ Carregando = false;
+ }
+
+ public void ReordenarAutomaticamente()
+ {
+ foreach (Item iten in Itens)
+ {
+ iten.Ordem = Itens.IndexOf(iten) + 1;
+ }
+ Itens = new ObservableCollection<Item>(Itens);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/SelecionarItensViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/SelecionarItensViewModel.cs
new file mode 100644
index 0000000..6e0bd14
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Generic/SelecionarItensViewModel.cs
@@ -0,0 +1,82 @@
+using System.Collections.ObjectModel;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Generic;
+
+public class SelecionarItensViewModel : BaseSegurosViewModel
+{
+ private ItemServico _itemServico;
+
+ private ObservableCollection<Item> _itens = new ObservableCollection<Item>();
+
+ private bool? _allSelected;
+
+ private bool _allSelectedChanging;
+
+ public ObservableCollection<Item> Itens
+ {
+ get
+ {
+ return _itens;
+ }
+ set
+ {
+ _itens = value;
+ OnPropertyChanged("Itens");
+ }
+ }
+
+ public bool? AllSelected
+ {
+ get
+ {
+ return _allSelected;
+ }
+ set
+ {
+ if (value != _allSelected)
+ {
+ _allSelected = value;
+ AllSelectedChanged();
+ OnPropertyChanged("AllSelected");
+ }
+ }
+ }
+
+ public SelecionarItensViewModel(long id)
+ {
+ _itemServico = new ItemServico();
+ CarregarItens(id);
+ }
+
+ private async void CarregarItens(long id)
+ {
+ Itens = await _itemServico.BuscarItens(id, (StatusItem)0);
+ }
+
+ private void AllSelectedChanged()
+ {
+ if (_allSelectedChanging)
+ {
+ return;
+ }
+ try
+ {
+ _allSelectedChanging = true;
+ if (!AllSelected.HasValue)
+ {
+ return;
+ }
+ foreach (Item iten in Itens)
+ {
+ iten.Selecionado = AllSelected.Value;
+ }
+ }
+ finally
+ {
+ _allSelectedChanging = false;
+ }
+ }
+}