summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels/MainViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels/MainViewModel.cs')
-rw-r--r--Decompiler/Gestor.Application.ViewModels/MainViewModel.cs1061
1 files changed, 1061 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels/MainViewModel.cs b/Decompiler/Gestor.Application.ViewModels/MainViewModel.cs
new file mode 100644
index 0000000..f9a9093
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels/MainViewModel.cs
@@ -0,0 +1,1061 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Threading;
+using Gestor.Application.Actions;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.ViewModels.Seguros;
+using Gestor.Application.Views.Financeiro;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Card;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.License;
+
+namespace Gestor.Application.ViewModels;
+
+public class MainViewModel : BaseSegurosViewModel
+{
+ public FinanceiroView FinanceiroView;
+
+ public ConsultaViewModel ConsultaViewModel;
+
+ public ClienteViewModel ClienteViewModel;
+
+ private readonly ClienteServico _servico;
+
+ public DashboardViewModel DashboardViewModel;
+
+ private List<Payment> _boletos;
+
+ private BitmapImage _qrCode;
+
+ private string _code;
+
+ private Geometry _maximizeRestore = Geometry.Parse((string)Application.Current.Resources[(object)"Restore"]);
+
+ private object _content;
+
+ private double _headMaxWidth;
+
+ private string _head;
+
+ private string _tela;
+
+ private TipoTela? _telaAberta;
+
+ private string _versao;
+
+ private long _selectedRamo = 5L;
+
+ public bool PesquisaAvançada;
+
+ private Cliente _selectedCliente;
+
+ private bool _isEnableDocumento;
+
+ private bool _isEnableItens;
+
+ private TipoDocumento _tipoDocumento;
+
+ private string _documentoPrincipal = "";
+
+ private ObservableCollection<AjudaTela> _ajuda = new ObservableCollection<AjudaTela>();
+
+ private bool _matrizFilial = LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 2 && x.Status == 1);
+
+ private readonly bool _temEpic = LicenseHelper.Produtos.Any((Licenca produto) => (int)produto.Produto == 83 && produto.Status == 1);
+
+ private bool _carregandoAjuda;
+
+ private string _empresa = "";
+
+ private ObservableCollection<Contato> _contatos = new ObservableCollection<Contato>();
+
+ private int _liquido;
+
+ private int _mediaComissao;
+
+ private int _resultado;
+
+ private Visibility _visibleChaveInstalacao = (Visibility)2;
+
+ private Visibility _visibleSeguros = (Visibility)2;
+
+ private Visibility _visibleBi = (Visibility)2;
+
+ private FiltroStatusDocumento _selectedStatus;
+
+ private TipoFiltroCliente _selectedFiltroCliente = (TipoFiltroCliente)1;
+
+ private bool _buscaNome = true;
+
+ private bool _enableSeguros;
+
+ private bool _enableBuscar;
+
+ private Visibility _visibilityVoltar = (Visibility)2;
+
+ private int _notasBadge;
+
+ private int _tarefasBadge;
+
+ private int _badges;
+
+ private int _ultimoUpdate;
+
+ private Visibility _mensagemTarefasVisibility = (Visibility)2;
+
+ private string _mensagemTarefas = "";
+
+ private string _pesquisa = "";
+
+ private int _medalhaCor;
+
+ private Visibility _medalhaVisibility = (Visibility)2;
+
+ private string _placeHolderAutoComplete = "PESQUISAR CLIENTE POR NOME OU NOME SOCIAL";
+
+ public static string ViewAberta { get; set; }
+
+ public static Cliente ClienteSelecionado { get; set; }
+
+ public static FiltroStatusDocumento StatusSelecionado { get; set; }
+
+ public List<Payment> Boletos
+ {
+ get
+ {
+ return _boletos;
+ }
+ set
+ {
+ _boletos = value;
+ OnPropertyChanged("Boletos");
+ }
+ }
+
+ public BitmapImage QrCode
+ {
+ get
+ {
+ return _qrCode;
+ }
+ set
+ {
+ _qrCode = value;
+ OnPropertyChanged("QrCode");
+ }
+ }
+
+ public string Code
+ {
+ get
+ {
+ return _code;
+ }
+ set
+ {
+ _code = value;
+ OnPropertyChanged("Code");
+ }
+ }
+
+ public Geometry MaximizeRestore
+ {
+ get
+ {
+ return _maximizeRestore;
+ }
+ set
+ {
+ _maximizeRestore = value;
+ OnPropertyChanged("MaximizeRestore");
+ }
+ }
+
+ public object Content
+ {
+ get
+ {
+ return _content;
+ }
+ set
+ {
+ _content = value;
+ OnPropertyChanged("Content");
+ }
+ }
+
+ public double HeadMaxWidth
+ {
+ get
+ {
+ return _headMaxWidth;
+ }
+ set
+ {
+ _headMaxWidth = value;
+ OnPropertyChanged("HeadMaxWidth");
+ }
+ }
+
+ public string Head
+ {
+ get
+ {
+ return _head;
+ }
+ set
+ {
+ _head = value;
+ OnPropertyChanged("Head");
+ }
+ }
+
+ public string Tela
+ {
+ get
+ {
+ return _tela;
+ }
+ set
+ {
+ _tela = value;
+ OnPropertyChanged("Tela");
+ }
+ }
+
+ public TipoTela? TelaAberta
+ {
+ get
+ {
+ return _telaAberta;
+ }
+ set
+ {
+ _telaAberta = value;
+ OnPropertyChanged("TelaAberta");
+ }
+ }
+
+ public string Versao
+ {
+ get
+ {
+ return _versao;
+ }
+ set
+ {
+ _versao = value;
+ OnPropertyChanged("Versao");
+ }
+ }
+
+ public long SelectedRamo
+ {
+ get
+ {
+ return _selectedRamo;
+ }
+ set
+ {
+ _selectedRamo = value;
+ OnPropertyChanged("SelectedRamo");
+ }
+ }
+
+ public bool Invoke { get; set; } = true;
+
+
+ public Cliente SelectedCliente
+ {
+ get
+ {
+ return _selectedCliente;
+ }
+ set
+ {
+ if (Invoke)
+ {
+ if (value != null)
+ {
+ long id = ((DomainBase)value).Id;
+ Cliente selectedCliente = SelectedCliente;
+ if (id == ((selectedCliente != null) ? new long?(((DomainBase)selectedCliente).Id) : null))
+ {
+ goto IL_004a;
+ }
+ }
+ ClienteSelecionado = value;
+ }
+ goto IL_004a;
+ IL_004a:
+ _selectedCliente = value;
+ OnPropertyChanged("SelectedCliente");
+ }
+ }
+
+ public bool Isdropped { get; set; }
+
+ public bool IsPopulating { get; set; }
+
+ public List<Cliente> ClientesFiltrados { get; set; }
+
+ public bool IsEnableDocumento
+ {
+ get
+ {
+ return _isEnableDocumento;
+ }
+ set
+ {
+ _isEnableDocumento = value;
+ OnPropertyChanged("IsEnableDocumento");
+ }
+ }
+
+ public bool IsEnableItens
+ {
+ get
+ {
+ return _isEnableItens;
+ }
+ set
+ {
+ _isEnableItens = value;
+ OnPropertyChanged("IsEnableItens");
+ }
+ }
+
+ public TipoDocumento TipoDocumento
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _tipoDocumento;
+ }
+ 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)
+ _tipoDocumento = value;
+ OnPropertyChanged("TipoDocumento");
+ }
+ }
+
+ public string DocumentoPrincipal
+ {
+ get
+ {
+ return _documentoPrincipal;
+ }
+ set
+ {
+ _documentoPrincipal = value;
+ OnPropertyChanged("DocumentoPrincipal");
+ }
+ }
+
+ public ObservableCollection<AjudaTela> Ajuda
+ {
+ get
+ {
+ return _ajuda;
+ }
+ set
+ {
+ _ajuda = value;
+ OnPropertyChanged("Ajuda");
+ }
+ }
+
+ public bool MatrizFilial
+ {
+ get
+ {
+ return _matrizFilial;
+ }
+ set
+ {
+ _matrizFilial = value;
+ OnPropertyChanged("MatrizFilial");
+ }
+ }
+
+ public Visibility TemEpic
+ {
+ get
+ {
+ if (_temEpic)
+ {
+ return (Visibility)0;
+ }
+ return (Visibility)2;
+ }
+ }
+
+ public bool CarregandoAjuda
+ {
+ get
+ {
+ return _carregandoAjuda;
+ }
+ set
+ {
+ _carregandoAjuda = value;
+ OnPropertyChanged("CarregandoAjuda");
+ }
+ }
+
+ public string Empresa
+ {
+ get
+ {
+ return _empresa;
+ }
+ set
+ {
+ _empresa = value;
+ OnPropertyChanged("Empresa");
+ }
+ }
+
+ public ObservableCollection<Contato> Contatos
+ {
+ get
+ {
+ return _contatos;
+ }
+ set
+ {
+ _contatos = value;
+ OnPropertyChanged("Contatos");
+ }
+ }
+
+ public List<VendedorUsuario> VendedorUsuario { get; set; }
+
+ public Visibility VisibleChaveInstalacao
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibleChaveInstalacao;
+ }
+ 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)
+ _visibleChaveInstalacao = value;
+ OnPropertyChanged("VisibleChaveInstalacao");
+ }
+ }
+
+ public Visibility VisibleSeguros
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibleSeguros;
+ }
+ 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)
+ _visibleSeguros = value;
+ OnPropertyChanged("VisibleSeguros");
+ }
+ }
+
+ public Visibility VisibleBi
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibleBi;
+ }
+ 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)
+ _visibleBi = value;
+ OnPropertyChanged("VisibleBi");
+ }
+ }
+
+ public FiltroStatusDocumento SelectedStatus
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _selectedStatus;
+ }
+ 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)
+ _selectedStatus = value;
+ WorkOnSelectedStatus(value);
+ OnPropertyChanged("SelectedStatus");
+ }
+ }
+
+ public TipoFiltroCliente SelectedFiltroCliente
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _selectedFiltroCliente;
+ }
+ 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_000a: Invalid comparison between Unknown and I4
+ //IL_0013: Unknown result type (might be due to invalid IL or missing references)
+ _selectedFiltroCliente = value;
+ BuscaNome = (int)value == 1;
+ PlaceHolderAutoComplete = (((int)_selectedFiltroCliente == 0) ? "PESQUISAR CLIENTE POR NOME OU SOBRENOME" : "PESQUISAR CLIENTE POR NOME OU DOCUMENTO");
+ OnPropertyChanged("SelectedFiltroCliente");
+ }
+ }
+
+ public bool BuscaNome
+ {
+ get
+ {
+ return _buscaNome;
+ }
+ set
+ {
+ _buscaNome = value;
+ OnPropertyChanged("BuscaNome");
+ }
+ }
+
+ public bool EnableSeguros
+ {
+ get
+ {
+ return _enableSeguros;
+ }
+ set
+ {
+ _enableSeguros = value;
+ OnPropertyChanged("EnableSeguros");
+ }
+ }
+
+ public bool EnableBuscar
+ {
+ get
+ {
+ return _enableBuscar;
+ }
+ set
+ {
+ _enableBuscar = value;
+ OnPropertyChanged("EnableBuscar");
+ }
+ }
+
+ public Visibility VisibilityVoltar
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityVoltar;
+ }
+ 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)
+ _visibilityVoltar = value;
+ OnPropertyChanged("VisibilityVoltar");
+ }
+ }
+
+ public int NotasBadge
+ {
+ get
+ {
+ return _notasBadge;
+ }
+ set
+ {
+ _notasBadge = value;
+ Badges = value + TarefasBadge;
+ OnPropertyChanged("NotasBadge");
+ }
+ }
+
+ public int TarefasBadge
+ {
+ get
+ {
+ return _tarefasBadge;
+ }
+ set
+ {
+ _tarefasBadge = value;
+ Badges = value + NotasBadge;
+ OnPropertyChanged("TarefasBadge");
+ }
+ }
+
+ public int Badges
+ {
+ get
+ {
+ return _badges;
+ }
+ set
+ {
+ _badges = value;
+ OnPropertyChanged("Badges");
+ }
+ }
+
+ public Visibility MensagemTarefasVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _mensagemTarefasVisibility;
+ }
+ 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)
+ _mensagemTarefasVisibility = value;
+ OnPropertyChanged("MensagemTarefasVisibility");
+ }
+ }
+
+ public string MensagemTarefas
+ {
+ get
+ {
+ return _mensagemTarefas;
+ }
+ set
+ {
+ _mensagemTarefas = value;
+ OnPropertyChanged("MensagemTarefas");
+ }
+ }
+
+ public string Pesquisa
+ {
+ get
+ {
+ return _pesquisa;
+ }
+ set
+ {
+ _pesquisa = value;
+ OnPropertyChanged("Pesquisa");
+ }
+ }
+
+ public int MedalhaCor
+ {
+ get
+ {
+ return _medalhaCor;
+ }
+ set
+ {
+ _medalhaCor = value;
+ OnPropertyChanged("MedalhaCor");
+ }
+ }
+
+ public Visibility MedalhaVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _medalhaVisibility;
+ }
+ 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)
+ _medalhaVisibility = value;
+ OnPropertyChanged("MedalhaVisibility");
+ }
+ }
+
+ public string PlaceHolderAutoComplete
+ {
+ get
+ {
+ return _placeHolderAutoComplete;
+ }
+ set
+ {
+ _placeHolderAutoComplete = value;
+ OnPropertyChanged("PlaceHolderAutoComplete");
+ }
+ }
+
+ public List<Cliente> ClientesEncontrados { get; set; }
+
+ public MainViewModel()
+ {
+ //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_00cd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d4: 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_0106: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0225: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0254: Unknown result type (might be due to invalid IL or missing references)
+ Gestor.Application.Actions.Actions.AtualizaBadges = AtualizarBadges;
+ Gestor.Application.Actions.Actions.LimparCliente = LimparCliente;
+ _servico = new ClienteServico();
+ Gestor.Application.Actions.Actions.UpdateDocumento = (Action<Documento>)Delegate.Combine(Gestor.Application.Actions.Actions.UpdateDocumento, new Action<Documento>(UpdateRamoIcon));
+ Gestor.Application.Actions.Actions.SelectCliente = (Action<Cliente>)Delegate.Combine(Gestor.Application.Actions.Actions.SelectCliente, new Action<Cliente>(SelectCliente));
+ Gestor.Application.Actions.Actions.AtualizaContatos = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.AtualizaContatos, new Action(AtualizarContatos));
+ Gestor.Application.Actions.Actions.EnableItens = (Action<bool>)Delegate.Combine(Gestor.Application.Actions.Actions.EnableItens, new Action<bool>(EnableItens));
+ Gestor.Application.Actions.Actions.EnableDocumento = (Action<bool>)Delegate.Combine(Gestor.Application.Actions.Actions.EnableDocumento, new Action<bool>(EnableDocumento));
+ Versao = Recursos.Empresa.Nome + " | " + LoginViewModel.VersaoAtual;
+ Usuario usuario = Recursos.Usuario;
+ SelectedFiltroCliente = ((usuario != null) ? usuario.FiltroInicial : null).GetValueOrDefault();
+ new DispatcherTimer(TimeSpan.FromHours(1.0), (DispatcherPriority)4, (EventHandler)delegate
+ {
+ AtualizarBadges();
+ }, ((DispatcherObject)Application.Current).Dispatcher).Start();
+ }
+
+ private void SelectCliente(Cliente cliente)
+ {
+ SelectedCliente = cliente;
+ if (Pesquisa != ((cliente == null) ? null : cliente.NomeSocial?.Trim()))
+ {
+ Pesquisa = ((cliente == null) ? null : cliente.NomeSocial?.Trim());
+ }
+ }
+
+ private void EnableItens(bool enabled)
+ {
+ IsEnableItens = enabled;
+ }
+
+ private void EnableDocumento(bool enabled)
+ {
+ IsEnableDocumento = enabled;
+ }
+
+ public async Task SelecionarCliente(Cliente value)
+ {
+ IsEnableDocumento = false;
+ IsEnableItens = false;
+ LimparDocumentos();
+ if (value != null)
+ {
+ if (Invoke)
+ {
+ ClienteSelecionado = value;
+ }
+ await WorkOnSelectedCliente(value);
+ IsEnableDocumento = true;
+ }
+ }
+
+ private async Task WorkOnSelectedCliente(Cliente value)
+ {
+ base.IsEnabled = false;
+ List<Contato> contatos = new List<Contato>();
+ ObservableCollection<ClienteTelefone> telefones = await _servico.BuscarTelefonesAsync(((DomainBase)value).Id);
+ ObservableCollection<ClienteEmail> observableCollection = await _servico.BuscarEmailsAsync(((DomainBase)value).Id);
+ if (telefones != null)
+ {
+ contatos.AddRange(((IEnumerable<ClienteTelefone>)telefones).Select((Func<ClienteTelefone, Contato>)((ClienteTelefone x) => new Contato
+ {
+ Tipo = (TipoContato)0,
+ TipoTelefone = ((TelefoneBase)x).Tipo.GetValueOrDefault((TipoTelefone)1),
+ Numero = ((TelefoneBase)x).Prefixo + " " + ((TelefoneBase)x).Numero
+ })).Take(2).ToList());
+ }
+ if (observableCollection != null)
+ {
+ contatos.AddRange(((IEnumerable<ClienteEmail>)observableCollection).Select((Func<ClienteEmail, Contato>)((ClienteEmail x) => new Contato
+ {
+ Tipo = (TipoContato)1,
+ TipoTelefone = null,
+ Numero = ((EmailBase)x).Email
+ })).Take(1).ToList());
+ }
+ Contatos = new ObservableCollection<Contato>(contatos);
+ TipoDocumento = value.DocumentoPrincipal.GetValueOrDefault();
+ MainViewModel mainViewModel = this;
+ Empresa? obj = ((IEnumerable<Empresa>)Recursos.Empresas).FirstOrDefault((Func<Empresa, bool>)((Empresa x) => ((DomainBase)x).Id == value.IdEmpresa));
+ mainViewModel.Empresa = ((obj != null) ? obj.Nome : null) ?? Recursos.Empresa.Nome;
+ TipoDocumento tipoDocumento = TipoDocumento;
+ switch ((int)tipoDocumento)
+ {
+ case 0:
+ DocumentoPrincipal = value.Documento ?? "";
+ break;
+ case 1:
+ DocumentoPrincipal = value.Rne ?? "";
+ break;
+ case 2:
+ DocumentoPrincipal = value.Cei ?? "";
+ break;
+ case 3:
+ DocumentoPrincipal = value.Caepf ?? "";
+ break;
+ }
+ if (ClienteSelecionado != null)
+ {
+ ClienteSelecionado.Telefones = telefones;
+ ClienteSelecionado.Emails = observableCollection;
+ }
+ string viewAberta = ViewAberta;
+ if (!(viewAberta == "ConsultaOriginalView"))
+ {
+ if (viewAberta == "ClienteView")
+ {
+ ClienteViewModel?.SelecionaCliente(SelectedCliente);
+ MainViewModel mainViewModel2 = this;
+ string descricao = "ACESSOU CLIENTE \"" + SelectedCliente.Nome + "\"";
+ long id = ((DomainBase)SelectedCliente).Id;
+ TipoTela? tela = (TipoTela)1;
+ Cliente selectedCliente = SelectedCliente;
+ mainViewModel2.RegistrarAcao(descricao, id, tela, $"ID CLIENTE: {((selectedCliente != null) ? new long?(((DomainBase)selectedCliente).Id) : null)}");
+ }
+ }
+ else if (ConsultaViewModel != null)
+ {
+ await (ConsultaViewModel?.SelecionaCliente(value));
+ AtualizarMedalha(ConsultaViewModel.Apolices.ToList());
+ }
+ base.IsEnabled = true;
+ MainViewModel mainViewModel3 = this;
+ Cliente selectedCliente2 = SelectedCliente;
+ mainViewModel3.Pesquisa = ((selectedCliente2 != null) ? selectedCliente2.NomeSocial : null);
+ }
+
+ private async void AtualizarMedalha(List<Documento> apolices)
+ {
+ Qualificacao val = await _servico.BuscarQualificacaoAsync();
+ if (((DomainBase)val).Id == 0L)
+ {
+ val = new Qualificacao
+ {
+ Liquido1 = 0m,
+ Liquido2 = 1000m,
+ Liquido3 = 5000m,
+ Comissao1 = 10m,
+ Comissao2 = 15m,
+ Comissao3 = 20m,
+ Resultado1 = 100m,
+ Resultado2 = 200m,
+ Resultado3 = 300m,
+ Id = 1L
+ };
+ }
+ _liquido = 0;
+ _mediaComissao = 0;
+ _resultado = 0;
+ decimal num = apolices.Sum((Documento p) => p.PremioLiquido);
+ if (num >= val.Liquido3)
+ {
+ _liquido = 3;
+ }
+ else if (num >= val.Liquido2)
+ {
+ _liquido = 2;
+ }
+ else if (num >= val.Liquido1)
+ {
+ _liquido = 1;
+ }
+ decimal num2 = (apolices.Any((Documento c) => c.Comissao > 0m) ? decimal.Round(apolices.Sum((Documento c) => c.Comissao) / (decimal)apolices.Count((Documento c) => c.Comissao > 0m), 2) : 0m);
+ if (num2 >= val.Comissao3)
+ {
+ _mediaComissao = 3;
+ }
+ else if (num2 >= val.Comissao2)
+ {
+ _mediaComissao = 2;
+ }
+ else if (num2 >= val.Comissao1)
+ {
+ _mediaComissao = 1;
+ }
+ decimal num3 = apolices.Sum((Documento p) => (p.PremioLiquido + (p.AdicionalComiss ? p.PremioAdicional : 0m)) * p.Comissao * 0.01m);
+ if (num3 >= val.Resultado3)
+ {
+ _resultado = 3;
+ }
+ else if (num3 >= val.Resultado2)
+ {
+ _resultado = 2;
+ }
+ else if (num3 >= val.Resultado1)
+ {
+ _resultado = 1;
+ }
+ MedalhaCor = (int)Math.Round(((float)_liquido + (float)_mediaComissao + (float)_resultado) / 3f);
+ MedalhaVisibility = (Visibility)0;
+ }
+
+ public async void Medalha()
+ {
+ await ShowMedalha(_liquido, _mediaComissao, _resultado, MedalhaCor);
+ }
+
+ private async void AtualizarContatos()
+ {
+ List<Contato> contatos = new List<Contato>();
+ if (SelectedCliente == null)
+ {
+ return;
+ }
+ ObservableCollection<ClienteTelefone> telefones = await _servico.BuscarTelefonesAsync(((DomainBase)SelectedCliente).Id);
+ ObservableCollection<ClienteEmail> observableCollection = await _servico.BuscarEmailsAsync(((DomainBase)SelectedCliente).Id);
+ if (telefones != null)
+ {
+ contatos.AddRange(((IEnumerable<ClienteTelefone>)telefones).Select((Func<ClienteTelefone, Contato>)((ClienteTelefone x) => new Contato
+ {
+ Tipo = (TipoContato)0,
+ TipoTelefone = ((TelefoneBase)x).Tipo.GetValueOrDefault((TipoTelefone)1),
+ Numero = ((TelefoneBase)x).Prefixo + " " + ((TelefoneBase)x).Numero
+ })).Take(2).ToList());
+ }
+ if (observableCollection != null)
+ {
+ contatos.AddRange(((IEnumerable<ClienteEmail>)observableCollection).Select((Func<ClienteEmail, Contato>)((ClienteEmail x) => new Contato
+ {
+ Tipo = (TipoContato)1,
+ TipoTelefone = null,
+ Numero = ((EmailBase)x).Email
+ })).Take(1).ToList());
+ }
+ Contatos = new ObservableCollection<Contato>(contatos);
+ }
+
+ private void WorkOnSelectedStatus(FiltroStatusDocumento value)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ StatusSelecionado = value;
+ if (SelectedCliente == null || !Invoke)
+ {
+ return;
+ }
+ string viewAberta = ViewAberta;
+ if (!(viewAberta == "ConsultaOriginalView"))
+ {
+ if (viewAberta == "ClienteView")
+ {
+ ClienteViewModel?.SelecionaCliente(SelectedCliente);
+ }
+ }
+ else
+ {
+ ConsultaViewModel?.SelecionarCliente(SelectedCliente);
+ }
+ }
+
+ private void UpdateRamoIcon(Documento documento)
+ {
+ if (documento != null && ((DomainBase)documento).Id != 0L)
+ {
+ SelectedRamo = ((DomainBase)documento.Controle.Ramo).Id;
+ }
+ }
+
+ private async void AtualizarBadges()
+ {
+ try
+ {
+ int[] array = await new TarefaServico().AtualizarNotasTarefas();
+ NotasBadge = array[0];
+ TarefasBadge = array[1];
+ if (array[1] > _ultimoUpdate)
+ {
+ MensagemTarefas = string.Format("{0} NOVA{1} TAREFA{2}", array[1], (array[1] > 1) ? "S" : "", (array[1] > 1) ? "S" : "");
+ MensagemTarefasVisibility = (Visibility)0;
+ }
+ _ultimoUpdate = array[1];
+ }
+ catch
+ {
+ }
+ }
+
+ public async void LimparDocumentos()
+ {
+ Contatos = null;
+ DocumentoPrincipal = "";
+ string viewAberta = ViewAberta;
+ if (!(viewAberta == "ConsultaOriginalView"))
+ {
+ if (viewAberta == "ClienteView")
+ {
+ ClienteViewModel?.SelecionaCliente(null);
+ }
+ }
+ else if (ConsultaViewModel != null)
+ {
+ await (ConsultaViewModel?.SelecionaCliente(null));
+ }
+ }
+
+ private void LimparCliente()
+ {
+ SelectedCliente = null;
+ Contatos = null;
+ DocumentoPrincipal = "";
+ Pesquisa = "";
+ }
+
+ public async Task CarregarAjuda()
+ {
+ if (TelaAberta.HasValue && !Ajuda.Any((AjudaTela x) => (TipoTela?)x.Tela == TelaAberta))
+ {
+ CarregandoAjuda = true;
+ Ajuda = new ObservableCollection<AjudaTela>(await Connection.Get<List<AjudaTela>>($"Help/{(int)TelaAberta.Value}"));
+ CarregandoAjuda = false;
+ }
+ }
+
+ public List<Cliente> FiltrarClientes(string value)
+ {
+ return FilterCliente(ClientesEncontrados, value);
+ }
+
+ public async void VerificarLogo()
+ {
+ if (string.IsNullOrEmpty(Recursos.Empresa.LogoId) && Recursos.Empresa.Logo != null)
+ {
+ Logo val = new Logo
+ {
+ CustomId = ApplicationHelper.NumeroSerial,
+ Data = Recursos.Empresa.Logo
+ };
+ Empresa empresa = Recursos.Empresa;
+ empresa.LogoId = await Funcoes.Criarlogo(val);
+ new EmpresaServico().AtualizarLogoId(((DomainBase)Recursos.Empresa).Id, Recursos.Empresa.LogoId);
+ }
+ }
+}