summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Ferramentas
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Ferramentas')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/CadastroEmailViewModel.cs285
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/CadastroParceiroViewModel.cs273
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/ComboModelo.cs37
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/ComboVariavel.cs47
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/DownloadViewModel.cs482
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/EmpresaViewModel.cs444
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/EstipulanteViewModel.cs316
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/EtiquetaViewModel.cs792
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/IncluirRamoViewModel.cs103
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/IncluirSeguradoraViewModel.cs103
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/MalaDiretaViewModel.cs660
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/ManutencaoPagamentosViewModel.cs756
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/NotaFiscalViewModel.cs348
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/ProdutoViewModel.cs245
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/ProtocoloDocumentosViewModel.cs278
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/ProtocoloEtiqueta.cs11
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/QualificacaoViewModel.cs122
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/RamoViewModel.cs284
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/ReciboViewModel.cs537
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/SeguradoraViewModel.cs535
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/SocioViewModel.cs301
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/StatusProspeccaoViewModel.cs263
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/StatusViewModel.cs295
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/TipoTarefaViewModel.cs263
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/TipoVendedorViewModel.cs294
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/UsuarioViewModel.cs684
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Ferramentas/VendedorViewModel.cs698
27 files changed, 9456 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/CadastroEmailViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/CadastroEmailViewModel.cs
new file mode 100644
index 0000000..6aefb0b
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/CadastroEmailViewModel.cs
@@ -0,0 +1,285 @@
+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.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class CadastroEmailViewModel : BaseSegurosViewModel
+{
+ private readonly EmailServico _servico;
+
+ public Credencial CancelCredencial;
+
+ private Credencial _selectedCredencial;
+
+ private ObservableCollection<Credencial> _credenciaisFiltrados = new ObservableCollection<Credencial>();
+
+ private bool _isExpanded;
+
+ public Credencial SelectedCredencial
+ {
+ get
+ {
+ return _selectedCredencial;
+ }
+ set
+ {
+ _selectedCredencial = value;
+ WorkOnSelectedCredencial(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedCredencial");
+ }
+ }
+
+ public ObservableCollection<Credencial> CredenciaisFiltrados
+ {
+ get
+ {
+ return _credenciaisFiltrados;
+ }
+ set
+ {
+ _credenciaisFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("CredenciaisFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public List<Credencial> Credenciais { get; set; }
+
+ public CadastroEmailViewModel()
+ {
+ _servico = new EmailServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ public void Incluir()
+ {
+ //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_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002b: Expected O, but got Unknown
+ SelectedCredencial = new Credencial
+ {
+ IdEmpresa = Recursos.Usuario.IdEmpresa,
+ IdUsuario = ((DomainBase)Recursos.Usuario).Id
+ };
+ Alterar(alterar: true);
+ }
+
+ public async Task CancelarAlteracao()
+ {
+ await CarregarCredenciais();
+ if (CredenciaisFiltrados.Any())
+ {
+ Credencial cancelCredencial = CancelCredencial;
+ long id = ((cancelCredencial != null) ? ((DomainBase)cancelCredencial).Id : 0);
+ SelectedCredencial = ((IEnumerable<Credencial>)CredenciaisFiltrados).FirstOrDefault((Func<Credencial, bool>)((Credencial x) => ((DomainBase)x).Id == id));
+ }
+ else
+ {
+ SelectedCredencial = new Credencial();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Alterar(alterar: false);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedCredencial.Validate();
+ list.AddRange(Validate());
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ SelectedCredencial.Assinatura = SelectedCredencial.Assinatura.GetBody();
+ SelectedCredencial.Cabecalho = SelectedCredencial.Cabecalho.GetBody();
+ if (SelectedCredencial.Senha == null)
+ {
+ SelectedCredencial.Senha = "";
+ }
+ string acao = ((((DomainBase)SelectedCredencial).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Credencial value = await _servico.Save(SelectedCredencial);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " E-MAIL \"" + value.Email + "\"", ((DomainBase)value).Id, (TipoTela)17, $"E-MAIL: {value.Email}\nID: {((DomainBase)value).Id}");
+ await CarregarCredenciais();
+ SelectedCredencial = ((IEnumerable<Credencial>)CredenciaisFiltrados).FirstOrDefault((Func<Credencial, bool>)((Credencial x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ Alterar(alterar: false);
+ ToggleSnackBar("E-MAIL SALVO COM SUCESSO");
+ return null;
+ }
+
+ public async Task Excluir()
+ {
+ if (SelectedCredencial == null || ((DomainBase)SelectedCredencial).Id == 0L || !(await ShowMessage("DESEJA REALMENTE EXCLUIR O E-MAIL " + SelectedCredencial.Email + " PERMANENTEMENTE?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ if (!(await _servico.Delete(SelectedCredencial)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ RegistrarAcao("EXCLUIU E-MAIL \"" + SelectedCredencial.Email + "\"", ((DomainBase)SelectedCredencial).Id, (TipoTela)17, $"E-MAIL: {SelectedCredencial.Email}\nID: {((DomainBase)SelectedCredencial).Id}");
+ await CarregarCredenciais();
+ if (CredenciaisFiltrados.Any())
+ {
+ SelectedCredencial = CredenciaisFiltrados.FirstOrDefault();
+ }
+ else
+ {
+ SelectedCredencial = new Credencial();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Loading(isLoading: false);
+ ToggleSnackBar("E-MAIL EXCLUÍDO COM SUCESSO");
+ }
+
+ public List<KeyValuePair<string, string>> Validate()
+ {
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (Credenciais.Any((Credencial x) => ((DomainBase)x).Id != ((DomainBase)SelectedCredencial).Id && x.Descricao == SelectedCredencial.Descricao))
+ {
+ list.Add(new KeyValuePair<string, string>("Descricao", "UM E-MAIL COM A MESMA DESCRIÇÃO/NOME JÁ EXISTE."));
+ }
+ return list;
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)17);
+ Loading(isLoading: false);
+ }
+
+ public async Task SelecionaCredenciais()
+ {
+ Loading(isLoading: true);
+ await CarregarCredenciais();
+ SelectedCredencial = CredenciaisFiltrados.FirstOrDefault();
+ Loading(isLoading: false);
+ }
+
+ private async Task CarregarCredenciais()
+ {
+ List<Credencial> list = await new BaseServico().BuscarCredenciais();
+ foreach (Credencial item in list)
+ {
+ if (item.Email.Contains("@gmail.com"))
+ {
+ item.Tipo = (TipoEmail)1;
+ }
+ item.Senha = EncryptionHelper.Decrypt(item.Senha);
+ }
+ Credenciais = list.OrderBy((Credencial x) => x.Descricao).ToList();
+ CredenciaisFiltrados = new ObservableCollection<Credencial>(Credenciais);
+ }
+
+ private void WorkOnSelectedCredencial(Credencial value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0071: Invalid comparison between Unknown and I4
+ //IL_00d7: Unknown result type (might be due to invalid IL or missing references)
+ CancelCredencial = (Credencial)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelCredencial) : ((object)(Credencial)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 17))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU E-MAIL \"" + value.Email + "\"", ((DomainBase)value).Id, (TipoTela)17, $"ID E-MAIL: {((DomainBase)value).Id}");
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)17;
+ Credencial selectedCredencial = SelectedCredencial;
+ if (((selectedCredencial != null) ? new long?(((DomainBase)selectedCredencial).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedCredencial = ((IEnumerable<Credencial>)CredenciaisFiltrados).FirstOrDefault((Func<Credencial, bool>)((Credencial x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+
+ internal async Task<List<Credencial>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarCredenciais(value));
+ }
+
+ public List<Credencial> FiltrarCredenciais(string filter)
+ {
+ CredenciaisFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Credencial>(Credenciais) : new ObservableCollection<Credencial>(Credenciais.Where((Credencial x) => ValidationHelper.RemoveDiacritics(x.Descricao.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)))));
+ SelectedCredencial = CredenciaisFiltrados.FirstOrDefault();
+ return CredenciaisFiltrados.ToList();
+ }
+
+ public void SelecionaCredencial(Credencial credencial)
+ {
+ SelectedCredencial = CredenciaisFiltrados.First((Credencial x) => ((DomainBase)x).Id == ((DomainBase)credencial).Id);
+ }
+
+ public async Task<bool> EnviarTesteEmail()
+ {
+ if (SelectedCredencial == null)
+ {
+ await ShowMessage("NECESSÁRIO CRIAR UM E-MAIL DE ENVIO PARA PROSSEGUIR.");
+ return false;
+ }
+ TipoEmail tipo = SelectedCredencial.Tipo;
+ if ((int)tipo != 0)
+ {
+ if (tipo - 1 <= 1 && string.IsNullOrWhiteSpace(SelectedCredencial.Email))
+ {
+ await ShowMessage("NECESSÁRIO PREENCHER O E-MAIL PARA ENVIAR UM E-MAIL DE TESTE");
+ return false;
+ }
+ }
+ else if (string.IsNullOrWhiteSpace(SelectedCredencial.Email) || !SelectedCredencial.Porta.HasValue || string.IsNullOrWhiteSpace(SelectedCredencial.Dominio))
+ {
+ await ShowMessage("NECESSÁRIO PREENCHER O E-MAIL, PORTA E DOMÍNIO PARA ENVIAR UM E-MAIL DE TESTE");
+ return false;
+ }
+ LogEnvio val = await new MailHelper().SendAsync(destinatario: new Destinatario
+ {
+ Assunto = "TESTE ENVIO E-MAIL",
+ Corpo = "TESTE DE ENVIO DE E-MAIL",
+ Email = SelectedCredencial.Email,
+ Nome = SelectedCredencial.Descricao
+ }, credencial: SelectedCredencial, filtro: null, maladireta: null, tela: (TipoTela)0);
+ if (!val.Enviado)
+ {
+ await ShowMessage(val.Erro);
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/CadastroParceiroViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/CadastroParceiroViewModel.cs
new file mode 100644
index 0000000..b0abb9b
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/CadastroParceiroViewModel.cs
@@ -0,0 +1,273 @@
+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.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class CadastroParceiroViewModel : BaseSegurosViewModel
+{
+ private readonly ParceiroServico _servico;
+
+ private Parceiro _selectedParceiro;
+
+ private ObservableCollection<Parceiro> _parceirosFiltrados = new ObservableCollection<Parceiro>();
+
+ private bool _isExpanded;
+
+ public Parceiro CancelParceiro;
+
+ private Item _selectedItem = new Item();
+
+ public List<Parceiro> Parceiros { get; set; }
+
+ public Parceiro SelectedParceiro
+ {
+ get
+ {
+ return _selectedParceiro;
+ }
+ set
+ {
+ _selectedParceiro = value;
+ WorkOnSelectedParceiro(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedParceiro");
+ }
+ }
+
+ public ObservableCollection<Parceiro> ParceirosFiltrados
+ {
+ get
+ {
+ return _parceirosFiltrados;
+ }
+ set
+ {
+ _parceirosFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("ParceirosFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public Item SelectedItem
+ {
+ get
+ {
+ return _selectedItem;
+ }
+ set
+ {
+ _selectedItem = value;
+ OnPropertyChanged("SelectedItem");
+ }
+ }
+
+ public CadastroParceiroViewModel(Parceiro parceiro)
+ {
+ //IL_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0016: Expected O, but got Unknown
+ _servico = new ParceiroServico();
+ base.EnableMenu = true;
+ Seleciona(parceiro);
+ }
+
+ private async void Seleciona(Parceiro parceiro)
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)22);
+ await SelecionaParceiro(parceiro);
+ Loading(isLoading: false);
+ }
+
+ public async void SelecionarParceiro(Parceiro parceiro)
+ {
+ if (parceiro == null)
+ {
+ SelectedParceiro = null;
+ return;
+ }
+ Parceiro val = await _servico.BuscarParceiro(((DomainBase)parceiro).Id);
+ DomainBase.Copy<Parceiro, Parceiro>(ParceirosFiltrados.First((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)parceiro).Id), val);
+ SelectedParceiro = ParceirosFiltrados.First((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)parceiro).Id);
+ }
+
+ private async Task SelecionaParceiro(Parceiro parceiro = null)
+ {
+ Loading(isLoading: true);
+ Parceiros = (await new BaseServico().BuscarParceirosAsync()).OrderBy((Parceiro x) => x.Nome).ToList();
+ ParceirosFiltrados = new ObservableCollection<Parceiro>(Parceiros);
+ SelecionarParceiro(parceiro ?? ParceirosFiltrados.FirstOrDefault());
+ Loading(isLoading: false);
+ }
+
+ private async void WorkOnSelectedParceiro(Parceiro value, bool registrar = true)
+ {
+ CancelParceiro = (Parceiro)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelParceiro) : ((object)(Parceiro)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 22))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU PARCEIRO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)22, "DOCUMENTO: " + value.Cgccpf + "\nTELEFONE 1: (" + value.Ddd1 + ") " + value.Telefone1 + "\nTELEFONE 2: (" + value.Ddd2 + ") " + value.Telefone2 + "\nTELEFONE 3: (" + value.Ddd3 + ") " + value.Telefone3 + "\nE-MAIL: " + value.Email + "\n\nENDEREÇO: " + value.Endereco + ", " + value.Numero + ", " + (string.IsNullOrWhiteSpace(value.Complemento) ? "-" : (value.Complemento ?? "")) + ", " + value.Bairro + ", " + value.Cidade + "/" + value.Uf + " - " + value.Cep);
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)22;
+ Parceiro selectedParceiro = SelectedParceiro;
+ if (((selectedParceiro != null) ? new long?(((DomainBase)selectedParceiro).Id) : null) != ((DomainBase)value).Id)
+ {
+ Parceiro val = await _servico.BuscarParceiro(((DomainBase)value).Id);
+ DomainBase.Copy<Parceiro, Parceiro>(SelectedParceiro, val);
+ Parceiro selectedParceiro2 = SelectedParceiro;
+ if (selectedParceiro2 != null)
+ {
+ ((DomainBase)selectedParceiro2).Initialize();
+ }
+ Initialized = true;
+ }
+ }
+
+ internal async Task<List<Parceiro>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarParceiro(value));
+ }
+
+ public List<Parceiro> FiltrarParceiro(string filter)
+ {
+ ParceirosFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Parceiro>(Parceiros) : new ObservableCollection<Parceiro>(Parceiros.Where((Parceiro x) => ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)))));
+ return ParceirosFiltrados.ToList();
+ }
+
+ public void Incluir()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000b: Expected O, but got Unknown
+ SelectedParceiro = new Parceiro();
+ Alterar(alterar: true);
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelParceiro != null && Parceiros.Any((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)CancelParceiro).Id))
+ {
+ DomainBase.Copy<Parceiro, Parceiro>(Parceiros.First((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)CancelParceiro).Id), CancelParceiro);
+ if (ParceirosFiltrados.Count > 0 && ParceirosFiltrados.Any((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)CancelParceiro).Id))
+ {
+ DomainBase.Copy<Parceiro, Parceiro>(ParceirosFiltrados.First((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)CancelParceiro).Id), CancelParceiro);
+ }
+ else
+ {
+ ParceirosFiltrados.Add(CancelParceiro);
+ }
+ ParceirosFiltrados = new ObservableCollection<Parceiro>(ParceirosFiltrados);
+ SelecionarParceiro(ParceirosFiltrados.First((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)CancelParceiro).Id));
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedParceiro.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ string acao = ((((DomainBase)SelectedParceiro).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Parceiro value = await _servico.Save(SelectedParceiro);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " PARCEIRO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)22, "DOCUMENTO: " + value.Cgccpf + "\nTELEFONE 1: (" + value.Ddd1 + ") " + value.Telefone1 + "\nTELEFONE 2: (" + value.Ddd2 + ") " + value.Telefone2 + "\nTELEFONE 3: (" + value.Ddd3 + ") " + value.Telefone3 + "\nE-MAIL: " + value.Email + "\n\nENDEREÇO: " + value.Endereco + ", " + value.Numero + ", " + (string.IsNullOrWhiteSpace(value.Complemento) ? "-" : (value.Complemento ?? "")) + ", " + value.Bairro + ", " + value.Cidade + "/" + value.Uf + " - " + value.Cep);
+ if (Parceiros.Any((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Parceiro, Parceiro>(Parceiros.First((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ Parceiros.Add(value);
+ }
+ if (ParceirosFiltrados.Any((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Parceiro, Parceiro>(ParceirosFiltrados.First((Parceiro x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ ParceirosFiltrados.Add(value);
+ }
+ ParceirosFiltrados = new ObservableCollection<Parceiro>(ParceirosFiltrados);
+ Recursos.Parceiros = Parceiros;
+ WorkOnSelectedParceiro(value, registrar: false);
+ Alterar(alterar: false);
+ ToggleSnackBar("PARCEIRO SALVO COM SUCESSO");
+ return null;
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedParceiro == null || ((DomainBase)SelectedParceiro).Id == 0L)
+ {
+ return;
+ }
+ if (await new BaseServico().ParceiroUtilizado(((DomainBase)SelectedParceiro).Id))
+ {
+ await ShowMessage("PARCEIRO NÃO PODE SER EXCLUÍDO POIS ESTÁ SENDO UTILIZADO.");
+ }
+ else
+ {
+ if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ if (!(await _servico.Delete(SelectedParceiro)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ RegistrarAcao("EXCLUIU O PARCEIRO \"" + SelectedParceiro.Nome + "\"", ((DomainBase)SelectedParceiro).Id, (TipoTela)22, "DOCUMENTO: " + SelectedParceiro.Cgccpf + "\nTELEFONE 1: (" + SelectedParceiro.Ddd1 + ") " + SelectedParceiro.Telefone1 + "\nTELEFONE 2: (" + SelectedParceiro.Ddd2 + ") " + SelectedParceiro.Telefone2 + "\nTELEFONE 3: (" + SelectedParceiro.Ddd3 + ") " + SelectedParceiro.Telefone3 + "\nE-MAIL: " + SelectedParceiro.Email + "\n\nENDEREÇO: " + SelectedParceiro.Endereco + ", " + SelectedParceiro.Numero + ", " + (string.IsNullOrWhiteSpace(SelectedParceiro.Complemento) ? "-" : (SelectedParceiro.Complemento ?? "")) + ", " + SelectedParceiro.Bairro + ", " + SelectedParceiro.Cidade + "/" + SelectedParceiro.Uf + " - " + SelectedParceiro.Cep);
+ int num = ParceirosFiltrados.IndexOf(SelectedParceiro);
+ Parceiros.Remove(SelectedParceiro);
+ ParceirosFiltrados.Remove(SelectedParceiro);
+ ParceirosFiltrados = new ObservableCollection<Parceiro>(ParceirosFiltrados);
+ if (ParceirosFiltrados.Count > 0)
+ {
+ SelecionarParceiro((num < ParceirosFiltrados.Count) ? ParceirosFiltrados.ElementAt(num) : ParceirosFiltrados.Last());
+ }
+ else
+ {
+ Incluir();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Loading(isLoading: false);
+ ToggleSnackBar("PARCEIRO EXCLUÍDO COM SUCESSO");
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/ComboModelo.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ComboModelo.cs
new file mode 100644
index 0000000..1d78404
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ComboModelo.cs
@@ -0,0 +1,37 @@
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Domain.MalaDireta;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class ComboModelo : BaseViewModel
+{
+ private ModeloMalaDireta _modeloMalaDireta = new ModeloMalaDireta();
+
+ private bool _indisponivel;
+
+ public ModeloMalaDireta ModeloMalaDireta
+ {
+ get
+ {
+ return _modeloMalaDireta;
+ }
+ set
+ {
+ _modeloMalaDireta = value;
+ OnPropertyChanged("ModeloMalaDireta");
+ }
+ }
+
+ public bool Indisponivel
+ {
+ get
+ {
+ return _indisponivel;
+ }
+ set
+ {
+ _indisponivel = value;
+ OnPropertyChanged("Indisponivel");
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/ComboVariavel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ComboVariavel.cs
new file mode 100644
index 0000000..f1df618
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ComboVariavel.cs
@@ -0,0 +1,47 @@
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Domain.MalaDireta;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class ComboVariavel : BaseViewModel
+{
+ private VariaveisMalaDireta _variaveisMalaDireta;
+
+ private bool _indisponivel;
+
+ public VariaveisMalaDireta VariaveisMalaDireta
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _variaveisMalaDireta;
+ }
+ 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)
+ _variaveisMalaDireta = value;
+ OnPropertyChanged("VariaveisMalaDireta");
+ }
+ }
+
+ public bool Indisponivel
+ {
+ get
+ {
+ return _indisponivel;
+ }
+ set
+ {
+ _indisponivel = value;
+ OnPropertyChanged("Indisponivel");
+ }
+ }
+
+ public ComboVariavel(VariaveisMalaDireta variaveisMalaDireta, bool indisponivel)
+ {
+ //IL_0007: Unknown result type (might be due to invalid IL or missing references)
+ VariaveisMalaDireta = variaveisMalaDireta;
+ Indisponivel = indisponivel;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/DownloadViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/DownloadViewModel.cs
new file mode 100644
index 0000000..1246bfe
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/DownloadViewModel.cs
@@ -0,0 +1,482 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using System.Net;
+using System.Runtime.InteropServices;
+using System.Text.RegularExpressions;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using Gestor.Application.Helpers;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.Views.Ferramentas;
+using Gestor.Common.Validation;
+using Gestor.Model.API;
+using Gestor.Model.Domain.Generic;
+using IWshRuntimeLibrary;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class DownloadViewModel : BaseSegurosViewModel
+{
+ private const string _path = "c:\\AggerSeguros\\";
+
+ private string _head;
+
+ private string _total;
+
+ private string _progresso;
+
+ private decimal _porcentagem;
+
+ private bool _processando = true;
+
+ private Geometry _maximizeRestore = Geometry.Parse((string)Application.Current.Resources[(object)"Maximize"]);
+
+ private Parameters Parameters { get; set; }
+
+ private string CurrentVersion { get; set; }
+
+ public string Head
+ {
+ get
+ {
+ return _head;
+ }
+ set
+ {
+ _head = value;
+ OnPropertyChanged("Head");
+ }
+ }
+
+ public string Total
+ {
+ get
+ {
+ return _total;
+ }
+ set
+ {
+ _total = value;
+ OnPropertyChanged("Total");
+ }
+ }
+
+ public string Progresso
+ {
+ get
+ {
+ return _progresso;
+ }
+ set
+ {
+ _progresso = value;
+ OnPropertyChanged("Progresso");
+ }
+ }
+
+ public decimal Porcentagem
+ {
+ get
+ {
+ return _porcentagem;
+ }
+ set
+ {
+ _porcentagem = value;
+ Progresso = $"{value}% de {Total} MB";
+ OnPropertyChanged("Porcentagem");
+ }
+ }
+
+ public bool Processando
+ {
+ get
+ {
+ return _processando;
+ }
+ set
+ {
+ _processando = value;
+ OnPropertyChanged("Processando");
+ }
+ }
+
+ public Geometry MaximizeRestore
+ {
+ get
+ {
+ return _maximizeRestore;
+ }
+ set
+ {
+ _maximizeRestore = value;
+ OnPropertyChanged("MaximizeRestore");
+ }
+ }
+
+ public DownloadViewModel(Parameters parameters)
+ {
+ Parameters = parameters;
+ base.IsEnabled = false;
+ Head = "ATUALIZAÇÃO " + Parameters.Directory.ToUpper();
+ }
+
+ public async Task Atualizar()
+ {
+ string rota = (Parameters.Beta ? "Beta" : "Released");
+ switch (Parameters.Type)
+ {
+ default:
+ {
+ CurrentVersion = await GetCurrentVersion(Parameters.Directory);
+ Version val2 = await Connection.Get<Version>($"Update/{rota}/{Parameters.Type}");
+ if (VerificarVersao(val2))
+ {
+ Open();
+ }
+ else
+ {
+ await Atualizar(val2);
+ }
+ break;
+ }
+ case 88:
+ if (!File.Exists("c:\\AggerSeguros\\Aggilizador.Application.exe"))
+ {
+ Parameters.Arguments = "";
+ await AtualizarAggilizador();
+ }
+ else
+ {
+ Parameters.Application = "Aggilizador.Application.exe";
+ Open();
+ }
+ break;
+ case 7:
+ try
+ {
+ Version val = await Connection.Get<Version>($"Update/{rota}/{Parameters.Type}");
+ FileVersionInfo fileVersionInfo = (File.Exists("c:\\AggerSeguros\\Agger.Gestor.exe") ? FileVersionInfo.GetVersionInfo("c:\\AggerSeguros\\Agger.Gestor.exe") : null);
+ if (fileVersionInfo == null || !Version.TryParse(fileVersionInfo.FileVersion, out Version result) || !(result >= Version.Parse(val.VersaoAplicacao)))
+ {
+ await AtualizarGestor(val, criarAtalho: true);
+ }
+ else
+ {
+ Funcoes.Destroy<DownloadWindow>();
+ }
+ break;
+ }
+ catch (Exception)
+ {
+ Funcoes.Destroy<DownloadWindow>();
+ break;
+ }
+ case 99:
+ await Atualizar(await Connection.Get<Version>($"Update/Released/{Parameters.Type}"));
+ break;
+ }
+ }
+
+ public void Open()
+ {
+ if (!Parameters.Run)
+ {
+ Funcoes.Destroy<DownloadWindow>();
+ return;
+ }
+ string fileName = Path.Combine((Parameters.Type == 99 || Parameters.Type == 88) ? "c:\\AggerSeguros\\" : ("c:\\AggerSeguros\\" + CurrentVersion), Parameters.Application);
+ try
+ {
+ Process.Start(fileName, Parameters.Arguments);
+ }
+ catch
+ {
+ }
+ Funcoes.Destroy<DownloadWindow>();
+ }
+
+ private bool CheckFreeSpace()
+ {
+ DriveInfo driveInfo = new DriveInfo("C");
+ if (driveInfo.IsReady)
+ {
+ return driveInfo.AvailableFreeSpace > 314572800;
+ }
+ return false;
+ }
+
+ public async Task Atualizar(Version version)
+ {
+ if (!CheckFreeSpace())
+ {
+ Erro.RegistrarErro(new LogError
+ {
+ IdFornecedor = ApplicationHelper.IdFornecedor,
+ Fornecedor = Recursos.Empresa.Nome,
+ UsuarioLogado = Recursos.Usuario.Nome,
+ IdUsuarioLogado = ((DomainBase)Recursos.Usuario).Id,
+ Versao = ApplicationHelper.Versao.ToString(),
+ Data = Funcoes.GetNetworkTime(),
+ IdErro = 1001,
+ Erro = ValidationHelper.GetDescription((Enum)(object)(TipoErro)1001) + " - " + version.Name,
+ HResult = 0,
+ HelpLink = "",
+ Message = "",
+ Source = "",
+ StackTrace = "",
+ Maquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName
+ });
+ return;
+ }
+ string text = "c:\\AggerSeguros\\" + version.Name;
+ if (Directory.Exists(text))
+ {
+ Directory.Delete(text, recursive: true);
+ }
+ while (Directory.Exists(text))
+ {
+ Thread.Sleep(500);
+ }
+ Directory.CreateDirectory(text);
+ using WebClient webClient = new WebClient();
+ webClient.DownloadFileCompleted += DownloadFileComplete;
+ webClient.DownloadProgressChanged += DownloadProgressCallback;
+ CurrentVersion = version.Name;
+ string address = ((Parameters.Type == 99) ? (version.Uri + "/" + version.Name + ".exe") : (version.Uri + "/" + version.Name + ".zip"));
+ string fileName = ((Parameters.Type == 99) ? (text + ".exe") : (text + "//" + version.Name + ".zip"));
+ Stream stream = webClient.OpenRead(address);
+ Total = Math.Round((float)long.Parse(webClient.ResponseHeaders["Content-Length"]) / 1024f / 1024f, 2).ToString(CultureInfo.InvariantCulture);
+ stream?.Dispose();
+ await webClient.DownloadFileTaskAsync(address, fileName);
+ webClient.Dispose();
+ }
+
+ public async Task AtualizarGestor(Version version, bool criarAtalho = false)
+ {
+ string text = "c:\\AggerSeguros\\";
+ using (WebClient webClient = new WebClient())
+ {
+ webClient.DownloadFileCompleted += DownloadFileCompleteGestor;
+ webClient.DownloadProgressChanged += DownloadProgressCallback;
+ CurrentVersion = version.Name;
+ string address = version.Uri + "/" + version.Name + ".zip";
+ string fileName = text + version.Name + ".zip";
+ Stream stream = webClient.OpenRead(address);
+ Total = Math.Round((float)long.Parse(webClient.ResponseHeaders["Content-Length"]) / 1024f / 1024f, 2).ToString(CultureInfo.InvariantCulture);
+ stream?.Dispose();
+ await webClient.DownloadFileTaskAsync(address, fileName);
+ webClient.Dispose();
+ }
+ if (criarAtalho)
+ {
+ CriarAtalho();
+ }
+ }
+
+ private void CriarAtalho()
+ {
+ WshShell wshShell = (WshShell)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")));
+ string text = "c:\\AggerSeguros\\";
+ string text2 = "Agger.Gestor.exe";
+ string description = "Agger Gestor";
+ try
+ {
+ if (wshShell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Agger Gestor.lnk") is IWshShortcut wshShortcut)
+ {
+ wshShortcut.TargetPath = text + text2;
+ wshShortcut.WindowStyle = 1;
+ wshShortcut.Description = description;
+ wshShortcut.WorkingDirectory = text;
+ wshShortcut.IconLocation = text + text2 + ",0";
+ wshShortcut.Save();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ try
+ {
+ if (wshShell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Programs) + "\\Agger Gestor.lnk") is IWshShortcut wshShortcut2)
+ {
+ wshShortcut2.TargetPath = text + text2;
+ wshShortcut2.WindowStyle = 1;
+ wshShortcut2.Description = description;
+ wshShortcut2.WorkingDirectory = text;
+ wshShortcut2.IconLocation = text + text2 + ",0";
+ wshShortcut2.Save();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ try
+ {
+ if (wshShell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Agger Gestor.lnk") is IWshShortcut wshShortcut3)
+ {
+ wshShortcut3.TargetPath = text + text2;
+ wshShortcut3.WindowStyle = 1;
+ wshShortcut3.Description = description;
+ wshShortcut3.WorkingDirectory = text;
+ wshShortcut3.IconLocation = text + text2 + ",0";
+ wshShortcut3.Save();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ try
+ {
+ if (wshShell.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Agger Gestor.lnk") is IWshShortcut wshShortcut4)
+ {
+ wshShortcut4.TargetPath = text + text2;
+ wshShortcut4.WindowStyle = 1;
+ wshShortcut4.Description = description;
+ wshShortcut4.WorkingDirectory = text;
+ wshShortcut4.IconLocation = text + text2 + ",0";
+ wshShortcut4.Save();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ public async Task AtualizarAggilizador()
+ {
+ if (!CheckFreeSpace())
+ {
+ Erro.RegistrarErro(new LogError
+ {
+ IdFornecedor = ApplicationHelper.IdFornecedor,
+ Fornecedor = Recursos.Empresa.Nome,
+ UsuarioLogado = Recursos.Usuario.Nome,
+ IdUsuarioLogado = ((DomainBase)Recursos.Usuario).Id,
+ Versao = ApplicationHelper.Versao.ToString(),
+ Data = Funcoes.GetNetworkTime(),
+ IdErro = 1001,
+ Erro = ValidationHelper.GetDescription((Enum)(object)(TipoErro)1001) + " - AGGILIZADOR",
+ HResult = 0,
+ HelpLink = "",
+ Message = "",
+ Source = "",
+ StackTrace = "",
+ Maquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName
+ });
+ }
+ else
+ {
+ using WebClient webClient = new WebClient();
+ webClient.DownloadFileCompleted += DownloadFileComplete;
+ webClient.DownloadProgressChanged += DownloadProgressCallback;
+ string address = "https://update.aggilizador.com.br/stable/Instalador.exe";
+ string fileName = "c:\\AggerSeguros\\" + Parameters.Application;
+ Stream stream = webClient.OpenRead(address);
+ Total = Math.Round((float)long.Parse(webClient.ResponseHeaders["Content-Length"]) / 1024f / 1024f, 2).ToString(CultureInfo.InvariantCulture);
+ stream?.Dispose();
+ await webClient.DownloadFileTaskAsync(address, fileName);
+ webClient.Dispose();
+ }
+ }
+
+ private bool VerificarVersao(Version versao)
+ {
+ bool flag = File.Exists("c:\\AggerSeguros\\\\" + CurrentVersion + "\\" + Parameters.Application);
+ return versao.Name == CurrentVersion && flag;
+ }
+
+ private async Task<string> GetCurrentVersion(string name)
+ {
+ return await Task.Run(delegate
+ {
+ string[] directories = Directory.GetDirectories("c:\\AggerSeguros\\");
+ List<long> list = new List<long>();
+ string[] array = directories;
+ foreach (string text in array)
+ {
+ if (text.IndexOf(name, StringComparison.Ordinal) > -1)
+ {
+ Match match = new Regex("(^[A-Za-z]+)(.)([A-Za-z]+)(\\d+)", RegexOptions.IgnoreCase).Match(text.Replace("c:\\AggerSeguros\\", ""));
+ if (match.Success)
+ {
+ long item = long.Parse(match.Groups[4].Value);
+ list.Add(item);
+ }
+ }
+ }
+ list.Reverse();
+ return (list.Count != 0) ? $"{name}{list.First()}" : "";
+ });
+ }
+
+ private void DownloadFileComplete(object sender, AsyncCompletedEventArgs e)
+ {
+ Processando = true;
+ Porcentagem = 0m;
+ Extract();
+ Open();
+ }
+
+ private void DownloadFileCompleteGestor(object sender, AsyncCompletedEventArgs e)
+ {
+ Processando = true;
+ Porcentagem = 0m;
+ ExtractGestor();
+ Funcoes.Destroy<DownloadWindow>();
+ }
+
+ public void Extract()
+ {
+ if (Parameters.Type != 99 && Parameters.Type != 88)
+ {
+ string text = "c:\\AggerSeguros\\" + CurrentVersion;
+ string text2 = text + "\\" + CurrentVersion + ".zip";
+ _ = text + "\\" + Parameters.Application;
+ ZipFile.ExtractToDirectory(text2, text);
+ File.Delete(text2);
+ }
+ }
+
+ public void ExtractGestor()
+ {
+ string text = "c:\\AggerSeguros\\" + CurrentVersion + ".zip";
+ ZipArchive zipArchive = ZipFile.OpenRead(text);
+ try
+ {
+ foreach (ZipArchiveEntry entry in zipArchive.Entries)
+ {
+ string fullPath = Path.GetFullPath(Path.Combine("c:\\AggerSeguros\\", entry.FullName));
+ fullPath.StartsWith("c:\\AggerSeguros\\", StringComparison.OrdinalIgnoreCase);
+ if (entry.Name == "")
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
+ }
+ else
+ {
+ entry.ExtractToFile(fullPath, overwrite: true);
+ }
+ }
+ zipArchive.Dispose();
+ File.Delete(text);
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ private void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e)
+ {
+ Processando = false;
+ Porcentagem = e.ProgressPercentage;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/EmpresaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/EmpresaViewModel.cs
new file mode 100644
index 0000000..578dbd9
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/EmpresaViewModel.cs
@@ -0,0 +1,444 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Forms;
+using System.Windows.Input;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Command;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class EmpresaViewModel : BaseSegurosViewModel
+{
+ private readonly EmpresaServico _servico;
+
+ public Empresa CancelEmpresa;
+
+ private Empresa _selectedEmpresa = new Empresa();
+
+ private string _logoLabel = "ANEXAR LOGOTIPO";
+
+ private bool _passWordReadOnly;
+
+ private bool _enableConsultaEspaco = true;
+
+ private double _espaco;
+
+ private string _senha;
+
+ private string _confirmaSenha;
+
+ private ObservableCollection<Empresa> _empresasFiltradas = new ObservableCollection<Empresa>();
+
+ private bool _isExpanded;
+
+ public ICommand ConsultarEspacoCommand { get; set; }
+
+ public List<Empresa> Empresas { get; set; }
+
+ public Empresa SelectedEmpresa
+ {
+ get
+ {
+ return _selectedEmpresa;
+ }
+ set
+ {
+ _selectedEmpresa = value;
+ object senha;
+ if (value == null)
+ {
+ senha = null;
+ }
+ else
+ {
+ string senhaAdmin = value.SenhaAdmin;
+ senha = ((senhaAdmin != null) ? EncryptionHelper.Decrypt(senhaAdmin) : null);
+ }
+ Senha = (string)senha;
+ ConfirmaSenha = string.Empty;
+ WorkOnSelectedEmpresa(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedEmpresa");
+ }
+ }
+
+ public string LogoLabel
+ {
+ get
+ {
+ return _logoLabel;
+ }
+ set
+ {
+ _logoLabel = value;
+ OnPropertyChanged("LogoLabel");
+ }
+ }
+
+ public bool PassWordReadOnly
+ {
+ get
+ {
+ return _passWordReadOnly;
+ }
+ set
+ {
+ _passWordReadOnly = value && (Recursos.Usuario.Administrador || ((DomainBase)Recursos.Usuario).Id == 0);
+ OnPropertyChanged("PassWordReadOnly");
+ }
+ }
+
+ public bool EnableConsultaEspaco
+ {
+ get
+ {
+ return _enableConsultaEspaco;
+ }
+ set
+ {
+ _enableConsultaEspaco = value;
+ OnPropertyChanged("EnableConsultaEspaco");
+ }
+ }
+
+ public double Espaco
+ {
+ get
+ {
+ return _espaco;
+ }
+ set
+ {
+ _espaco = value;
+ OnPropertyChanged("Espaco");
+ }
+ }
+
+ public string Senha
+ {
+ get
+ {
+ return _senha;
+ }
+ set
+ {
+ _senha = value;
+ OnPropertyChanged("Senha");
+ }
+ }
+
+ public string ConfirmaSenha
+ {
+ get
+ {
+ return _confirmaSenha;
+ }
+ set
+ {
+ _confirmaSenha = value;
+ OnPropertyChanged("ConfirmaSenha");
+ }
+ }
+
+ public ObservableCollection<Empresa> EmpresasFiltradas
+ {
+ get
+ {
+ return _empresasFiltradas;
+ }
+ set
+ {
+ _empresasFiltradas = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("EmpresasFiltradas");
+ }
+ }
+
+ private Visibility _visualizacaoMatriz { get; set; } = (Visibility)2;
+
+
+ public Visibility VisualizacaoMatriz
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visualizacaoMatriz;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ _visualizacaoMatriz = value;
+ OnPropertyChanged("VisualizacaoMatriz");
+ }
+ }
+
+ private Visibility _confirmacaoSenha { get; set; } = (Visibility)2;
+
+
+ public Visibility ConfirmacaoSenha
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _confirmacaoSenha;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ _confirmacaoSenha = value;
+ OnPropertyChanged("ConfirmacaoSenha");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public EmpresaViewModel()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000b: Expected O, but got Unknown
+ //IL_002a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0031: Unknown result type (might be due to invalid IL or missing references)
+ ConsultarEspacoCommand = new RelayCommand(async delegate
+ {
+ await ConsultaEspacoUsadoClienteInGb();
+ });
+ _servico = new EmpresaServico();
+ base.EnableMenu = true;
+ PassWordReadOnly = Recursos.Usuario.Administrador && base.EnableFields;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)18);
+ await SelecionaEmpresas();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaEmpresas()
+ {
+ Loading(isLoading: true);
+ Empresas = (from x in await new BaseServico().BuscarEmpresasAsync()
+ where Recursos.Usuario.IdEmpresa == 1 || ((DomainBase)x).Id == Recursos.Usuario.IdEmpresa
+ orderby x.Nome
+ select x).ToList();
+ EmpresasFiltradas = new ObservableCollection<Empresa>(Empresas);
+ if (EmpresasFiltradas.Count > 0)
+ {
+ SelecionaEmpresa(EmpresasFiltradas.First());
+ }
+ else
+ {
+ SelectedEmpresa = new Empresa();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Loading(isLoading: false);
+ }
+
+ public void Incluir()
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Expected O, but got Unknown
+ Empresa selectedEmpresa = new Empresa();
+ SelectedEmpresa = selectedEmpresa;
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedEmpresa.Validate();
+ if ((int)VisualizacaoMatriz != 2 && ConfirmaSenha != Senha)
+ {
+ list.Add(new KeyValuePair<string, string>("SenhaAdmin|SENHA ADM", "A SENHA E A CONFIRMAÇÃO DA SENHA DEVEM SER IGUAIS."));
+ }
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ if (((DomainBase)SelectedEmpresa).Id == 1)
+ {
+ SelectedEmpresa.SenhaAdmin = EncryptionHelper.Encrypt(Senha);
+ }
+ string acao = ((((DomainBase)SelectedEmpresa).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Empresa value = await _servico.Save(SelectedEmpresa);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " EMPRESA \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)18, $"EMPRESA \"{value.Nome}\", ID: {((DomainBase)value).Id}");
+ if (Empresas.Any((Empresa x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Empresa, Empresa>(Empresas.First((Empresa x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ Empresas.Add(value);
+ }
+ if (EmpresasFiltradas.Any((Empresa x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Empresa, Empresa>(EmpresasFiltradas.First((Empresa x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ EmpresasFiltradas.Add(value);
+ }
+ EmpresasFiltradas = new ObservableCollection<Empresa>(EmpresasFiltradas);
+ Recursos.Empresas = Empresas;
+ WorkOnSelectedEmpresa(value, registrar: false);
+ Alterar(alterar: false);
+ ToggleSnackBar("EMPRESA SALVA COM SUCESSO");
+ return null;
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelEmpresa != null && Empresas.Any((Empresa x) => ((DomainBase)x).Id == ((DomainBase)CancelEmpresa).Id))
+ {
+ DomainBase.Copy<Empresa, Empresa>(Empresas.First((Empresa x) => ((DomainBase)x).Id == ((DomainBase)CancelEmpresa).Id), CancelEmpresa);
+ if (EmpresasFiltradas.Count > 0 && EmpresasFiltradas.Any((Empresa x) => ((DomainBase)x).Id == ((DomainBase)CancelEmpresa).Id))
+ {
+ DomainBase.Copy<Empresa, Empresa>(EmpresasFiltradas.First((Empresa x) => ((DomainBase)x).Id == ((DomainBase)CancelEmpresa).Id), CancelEmpresa);
+ }
+ else
+ {
+ EmpresasFiltradas.Add(CancelEmpresa);
+ }
+ EmpresasFiltradas = new ObservableCollection<Empresa>(EmpresasFiltradas);
+ SelectedEmpresa = EmpresasFiltradas.First((Empresa x) => ((DomainBase)x).Id == ((DomainBase)CancelEmpresa).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ private void WorkOnSelectedEmpresa(Empresa value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Invalid comparison between Unknown and I4
+ //IL_00d6: Unknown result type (might be due to invalid IL or missing references)
+ CancelEmpresa = (Empresa)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelEmpresa) : ((object)(Empresa)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 18))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU EMPRESA \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)18, $"ID EMPRESA: {((DomainBase)value).Id}");
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)18;
+ Empresa selectedEmpresa = SelectedEmpresa;
+ if (((selectedEmpresa != null) ? new long?(((DomainBase)selectedEmpresa).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedEmpresa = ((IEnumerable<Empresa>)EmpresasFiltradas).FirstOrDefault((Func<Empresa, bool>)((Empresa x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ Empresa selectedEmpresa2 = SelectedEmpresa;
+ LogoLabel = ((((selectedEmpresa2 != null) ? selectedEmpresa2.Logo : null) == null) ? "ANEXAR LOGOTIPO" : "ALTERAR LOGOTIPO");
+ VisualizacaoMatriz = (Visibility)((((DomainBase)SelectedEmpresa).Id != 1) ? 2 : 0);
+ }
+
+ internal async Task<List<Empresa>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarEmpresa(value));
+ }
+
+ public List<Empresa> FiltrarEmpresa(string filter)
+ {
+ EmpresasFiltradas = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Empresa>(Empresas) : new ObservableCollection<Empresa>(from x in Empresas
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Nome
+ select x));
+ return EmpresasFiltradas.ToList();
+ }
+
+ public async void SelecionaEmpresa(Empresa empresa)
+ {
+ Empresa val = await _servico.BuscarEmpresaPorId(((DomainBase)empresa).Id);
+ DomainBase.Copy<Empresa, Empresa>(EmpresasFiltradas.First((Empresa x) => ((DomainBase)x).Id == ((DomainBase)empresa).Id), val);
+ SelectedEmpresa = EmpresasFiltradas.First((Empresa x) => ((DomainBase)x).Id == ((DomainBase)empresa).Id);
+ }
+
+ public async Task AnexarLogo()
+ {
+ string text = "";
+ OpenFileDialog val = new OpenFileDialog();
+ try
+ {
+ val.Multiselect = false;
+ ((FileDialog)val).Filter = "Imagens|*.jpg;*.jpeg;*.png;";
+ ((FileDialog)val).InitialDirectory = Environment.SpecialFolder.Desktop.ToString();
+ if (1 != (int)((CommonDialog)val).ShowDialog())
+ {
+ return;
+ }
+ text = ((FileDialog)val).FileName;
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
+ }
+ try
+ {
+ using MemoryStream memoryStream = new MemoryStream(File.ReadAllBytes(text));
+ byte[] array = new byte[memoryStream.Length];
+ memoryStream.Position = 0L;
+ memoryStream.Read(array, 0, array.Length);
+ SelectedEmpresa.Logo = array;
+ }
+ catch (Exception)
+ {
+ await ShowMessage("NÃO FOI POSSÍVEL CARREGAR O ARQUIVO " + text + "." + Environment.NewLine + "O ARQUIVO ESTÁ INACESSÍVEL OU SENDO UTILIZADO POR OUTRO PROCESSO.");
+ }
+ }
+
+ public async Task ConsultaEspacoUsadoClienteInGb()
+ {
+ EnableConsultaEspaco = false;
+ Loading(isLoading: true);
+ double espacoBanco = await _servico.ConsultaEspacoBancoInGb();
+ double espacoStorageInGB = 0.0;
+ if (Connection.ConnectionAddress.UsaAzureStorage)
+ {
+ double num = await Connection.EspacoUsadoAzureInBytes();
+ if (num > 0.0)
+ {
+ espacoStorageInGB = num / 1024.0 / 1024.0 / 1024.0;
+ }
+ }
+ Espaco = espacoBanco + espacoStorageInGB;
+ if (Espaco == 0.0)
+ {
+ EnableConsultaEspaco = true;
+ }
+ Loading(isLoading: false);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/EstipulanteViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/EstipulanteViewModel.cs
new file mode 100644
index 0000000..2848ad4
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/EstipulanteViewModel.cs
@@ -0,0 +1,316 @@
+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.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class EstipulanteViewModel : BaseSegurosViewModel
+{
+ private readonly EstipulanteServico _servico;
+
+ public Estipulante CancelEstipulante;
+
+ private Estipulante _selectedEstipulante = new Estipulante();
+
+ private ObservableCollection<Estipulante> _estipulantesFiltrados = new ObservableCollection<Estipulante>();
+
+ private bool _isExpanded;
+
+ public List<Estipulante> Estipulantes { get; set; }
+
+ public Estipulante SelectedEstipulante
+ {
+ get
+ {
+ return _selectedEstipulante;
+ }
+ set
+ {
+ _selectedEstipulante = value;
+ WorkOnSelectedEstipulante(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedEstipulante");
+ if (value != null)
+ {
+ ((DomainBase)SelectedEstipulante).Initialize();
+ }
+ }
+ }
+
+ public ObservableCollection<Estipulante> EstipulantesFiltrados
+ {
+ get
+ {
+ return _estipulantesFiltrados;
+ }
+ set
+ {
+ _estipulantesFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("EstipulantesFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public EstipulanteViewModel()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000b: Expected O, but got Unknown
+ _servico = new EstipulanteServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)9);
+ await SelecionaEstipulantes();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaEstipulantes()
+ {
+ Loading(isLoading: true);
+ List<Estipulante> list = await new BaseServico().BuscarEstipulantesAsync();
+ Estipulantes = (from x in list
+ where Recursos.Usuario.IdEmpresa == 1 || Recursos.Usuario.IdEmpresa == x.IdEmpresa
+ orderby x.Ativo descending, x.Nome
+ select x).ToList();
+ EstipulantesFiltrados = new ObservableCollection<Estipulante>(Estipulantes);
+ if (EstipulantesFiltrados.Count > 0)
+ {
+ SelecionaEstipulante(EstipulantesFiltrados.First());
+ }
+ else
+ {
+ SelectedEstipulante = new Estipulante();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Recursos.Estipulantes = list;
+ Loading(isLoading: false);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ bool valida = !string.IsNullOrEmpty(SelectedEstipulante.Nome);
+ List<Estipulante> list = ((!ValidationHelper.ValidateDocument(SelectedEstipulante.Documento)) ? new List<Estipulante>() : (await new BaseServico().BuscarEstipulante(SelectedEstipulante.Documento)));
+ List<Estipulante> list2 = list;
+ string nome = "";
+ if (list2.Count > 0)
+ {
+ list2.ForEach(delegate(Estipulante x)
+ {
+ if (((DomainBase)x).Id != ((DomainBase)SelectedEstipulante).Id && !string.IsNullOrEmpty(SelectedEstipulante.Documento) && x.Documento == SelectedEstipulante.Documento)
+ {
+ valida = false;
+ nome = x.Nome;
+ }
+ });
+ }
+ if (!valida)
+ {
+ errors.Add(new KeyValuePair<string, string>("Documento", "O DOCUMENTO ESTÁ CADASTRADO PARA O ESTIPULANTE " + nome + "."));
+ }
+ return errors;
+ }
+
+ public void Incluir()
+ {
+ //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_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0022: Expected O, but got Unknown
+ SelectedEstipulante = new Estipulante
+ {
+ IdEmpresa = Recursos.Usuario.IdEmpresa,
+ Ativo = true
+ };
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> errorMessages = SelectedEstipulante.Validate();
+ List<KeyValuePair<string, string>> list = errorMessages;
+ list.AddRange(await Validate());
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ string acao = ((((DomainBase)SelectedEstipulante).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Estipulante value = await _servico.Save(SelectedEstipulante);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " ESTIPULANTE \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)9, $"ESTIPULANTE \"{value.Nome}\", ID: {((DomainBase)value).Id}");
+ if (Estipulantes.Any((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Estipulante, Estipulante>(Estipulantes.First((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ Estipulantes.Add(value);
+ }
+ if (EstipulantesFiltrados.Any((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Estipulante, Estipulante>(EstipulantesFiltrados.First((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ EstipulantesFiltrados.Add(value);
+ }
+ EstipulantesFiltrados = new ObservableCollection<Estipulante>(EstipulantesFiltrados);
+ Recursos.Estipulantes = Estipulantes;
+ WorkOnSelectedEstipulante(value, registrar: false);
+ Alterar(alterar: false);
+ ((DomainBase)SelectedEstipulante).Initialize();
+ ToggleSnackBar("ESTIPULANTE SALVO COM SUCESSO");
+ return null;
+ }
+
+ private void WorkOnSelectedEstipulante(Estipulante value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Invalid comparison between Unknown and I4
+ //IL_00d6: Unknown result type (might be due to invalid IL or missing references)
+ CancelEstipulante = (Estipulante)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelEstipulante) : ((object)(Estipulante)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 9))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU ESTIPULANTE \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)9, $"ID ESTIPULANTE: {((DomainBase)value).Id}");
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)9;
+ Estipulante selectedEstipulante = SelectedEstipulante;
+ if (((selectedEstipulante != null) ? new long?(((DomainBase)selectedEstipulante).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedEstipulante = ((IEnumerable<Estipulante>)EstipulantesFiltrados).FirstOrDefault((Func<Estipulante, bool>)((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelEstipulante != null && Estipulantes.Any((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)CancelEstipulante).Id))
+ {
+ DomainBase.Copy<Estipulante, Estipulante>(Estipulantes.First((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)CancelEstipulante).Id), CancelEstipulante);
+ if (EstipulantesFiltrados.Count > 0 && EstipulantesFiltrados.Any((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)CancelEstipulante).Id))
+ {
+ DomainBase.Copy<Estipulante, Estipulante>(EstipulantesFiltrados.First((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)CancelEstipulante).Id), CancelEstipulante);
+ }
+ else
+ {
+ EstipulantesFiltrados.Add(CancelEstipulante);
+ }
+ EstipulantesFiltrados = new ObservableCollection<Estipulante>(EstipulantesFiltrados);
+ SelectedEstipulante = EstipulantesFiltrados.First((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)CancelEstipulante).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedEstipulante == null || ((DomainBase)SelectedEstipulante).Id == 0L)
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ List<Documento> list = await new BaseServico().BuscarDocumentosPorEstipulante(((DomainBase)SelectedEstipulante).Id);
+ Loading(isLoading: false);
+ if (list.Count > 0)
+ {
+ string text = "ESTIPULANTE NÃO PODE SER EXCLUÍDO POIS ESTÁ VINCULADO AOS SEGUINTES DOCUMENTOS:";
+ foreach (Documento item in list)
+ {
+ text = ((!string.IsNullOrWhiteSpace(item.Apolice)) ? (text + $"{Environment.NewLine}DOCUMENTO {list.IndexOf(item) + 1} (NÚMERO DA PROPOSTA: {item.Proposta}, NÚMERO DA APÓLICE: {item.Apolice})") : (text + $"{Environment.NewLine}DOCUMENTO {list.IndexOf(item) + 1} (NÚMERO DA PROPOSTA: {item.Proposta})"));
+ }
+ await ShowMessage(text);
+ }
+ else
+ {
+ if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ if (!(await _servico.Delete(SelectedEstipulante)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ RegistrarAcao("EXCLUIU ESTIPULANTE \"" + SelectedEstipulante.Nome + "\"", ((DomainBase)SelectedEstipulante).Id, (TipoTela)9, $"ESTIPULANTE \"{SelectedEstipulante.Nome}\", ID: {((DomainBase)SelectedEstipulante).Id}");
+ int num = EstipulantesFiltrados.IndexOf(SelectedEstipulante);
+ Estipulantes.Remove(SelectedEstipulante);
+ EstipulantesFiltrados.Remove(SelectedEstipulante);
+ EstipulantesFiltrados = new ObservableCollection<Estipulante>(EstipulantesFiltrados);
+ if (EstipulantesFiltrados.Count > 0)
+ {
+ SelectedEstipulante = ((num < EstipulantesFiltrados.Count) ? EstipulantesFiltrados.ElementAt(num) : EstipulantesFiltrados.Last());
+ }
+ else
+ {
+ SelectedEstipulante = new Estipulante();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Recursos.Estipulantes = await new BaseServico().BuscarEstipulantesAsync();
+ Loading(isLoading: false);
+ ToggleSnackBar("ESTIPULANTE EXCLUÍDO COM SUCESSO");
+ }
+ }
+
+ internal async Task<List<Estipulante>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarEstipulante(value));
+ }
+
+ public List<Estipulante> FiltrarEstipulante(string filter)
+ {
+ EstipulantesFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Estipulante>(Estipulantes) : new ObservableCollection<Estipulante>(from x in Estipulantes
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ativo descending, x.Nome
+ select x));
+ SelectedEstipulante = EstipulantesFiltrados.FirstOrDefault();
+ return EstipulantesFiltrados.ToList();
+ }
+
+ public async void SelecionaEstipulante(Estipulante estipulante)
+ {
+ Estipulante val = await _servico.BuscarEstipulantePorId(((DomainBase)estipulante).Id);
+ DomainBase.Copy<Estipulante, Estipulante>(EstipulantesFiltrados.First((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)estipulante).Id), val);
+ SelectedEstipulante = EstipulantesFiltrados.First((Estipulante x) => ((DomainBase)x).Id == ((DomainBase)estipulante).Id);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/EtiquetaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/EtiquetaViewModel.cs
new file mode 100644
index 0000000..a541f8f
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/EtiquetaViewModel.cs
@@ -0,0 +1,792 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class EtiquetaViewModel : BaseSegurosViewModel
+{
+ private bool _allSelectedChanging;
+
+ private List<string> _tiposEtiqueta = new List<string> { "CLIENTE", "APÓLICE" };
+
+ private string _tipoEtiqueta = "CLIENTE";
+
+ private bool? _allSelected;
+
+ private ObservableCollection<Documento> _apolicesFiltrados = new ObservableCollection<Documento>();
+
+ private bool _duasColunas = true;
+
+ private bool _tresColunas;
+
+ private bool _umaPagina;
+
+ private bool _mostrarNascimento;
+
+ private int _pular;
+
+ private object _visibilityColunas;
+
+ private bool _mostrarApolice = true;
+
+ private bool _mostrarVendedor = true;
+
+ private bool _mostrarItem = true;
+
+ public List<string> TiposEtiqueta
+ {
+ get
+ {
+ return _tiposEtiqueta;
+ }
+ set
+ {
+ _tiposEtiqueta = value;
+ OnPropertyChanged("TiposEtiqueta");
+ }
+ }
+
+ public string TipoEtiqueta
+ {
+ get
+ {
+ return _tipoEtiqueta;
+ }
+ set
+ {
+ _tipoEtiqueta = value;
+ OnPropertyChanged("TipoEtiqueta");
+ OnPropertyChanged("ExibirControlesEtiquetaApolice");
+ OnPropertyChanged("ExibirControlesEtiquetaCliente");
+ }
+ }
+
+ public Visibility ExibirControlesEtiquetaApolice
+ {
+ get
+ {
+ if (TipoEtiqueta == "APÓLICE")
+ {
+ return (Visibility)0;
+ }
+ return (Visibility)2;
+ }
+ }
+
+ public Visibility ExibirControlesEtiquetaCliente
+ {
+ get
+ {
+ if (TipoEtiqueta == "CLIENTE")
+ {
+ return (Visibility)0;
+ }
+ return (Visibility)2;
+ }
+ }
+
+ public bool? AllSelected
+ {
+ get
+ {
+ return _allSelected;
+ }
+ set
+ {
+ if (value != _allSelected)
+ {
+ _allSelected = value;
+ AllSelectedChanged();
+ Apolices = new List<Documento>(Apolices);
+ OnPropertyChanged("AllSelected");
+ }
+ }
+ }
+
+ public List<Documento> Apolices { get; set; }
+
+ public ObservableCollection<Documento> ApolicesFiltrados
+ {
+ get
+ {
+ return _apolicesFiltrados;
+ }
+ set
+ {
+ _apolicesFiltrados = value;
+ foreach (Documento apolicesFiltrado in ApolicesFiltrados)
+ {
+ apolicesFiltrado.PropertyChanged += EntryOnPropertyChanged;
+ }
+ OnPropertyChanged("ApolicesFiltrados");
+ }
+ }
+
+ public bool DuasColunas
+ {
+ get
+ {
+ return _duasColunas;
+ }
+ set
+ {
+ _duasColunas = value;
+ OnPropertyChanged("DuasColunas");
+ }
+ }
+
+ public bool TresColunas
+ {
+ get
+ {
+ return _tresColunas;
+ }
+ set
+ {
+ _tresColunas = value;
+ OnPropertyChanged("TresColunas");
+ }
+ }
+
+ public bool UmaPagina
+ {
+ get
+ {
+ return _umaPagina;
+ }
+ set
+ {
+ _umaPagina = value;
+ VisibilityColunas = (object)(Visibility)(value ? 2 : 0);
+ OnPropertyChanged("UmaPagina");
+ }
+ }
+
+ public bool MostrarNascimento
+ {
+ get
+ {
+ return _mostrarNascimento;
+ }
+ set
+ {
+ _mostrarNascimento = value;
+ OnPropertyChanged("MostrarNascimento");
+ }
+ }
+
+ public int Pular
+ {
+ get
+ {
+ return _pular;
+ }
+ set
+ {
+ _pular = value;
+ OnPropertyChanged("Pular");
+ }
+ }
+
+ public object VisibilityColunas
+ {
+ get
+ {
+ return _visibilityColunas;
+ }
+ set
+ {
+ _visibilityColunas = value;
+ OnPropertyChanged("VisibilityColunas");
+ }
+ }
+
+ public bool MostrarApolice
+ {
+ get
+ {
+ return _mostrarApolice;
+ }
+ set
+ {
+ _mostrarApolice = value;
+ OnPropertyChanged("MostrarApolice");
+ }
+ }
+
+ public bool MostrarVendedor
+ {
+ get
+ {
+ return _mostrarVendedor;
+ }
+ set
+ {
+ _mostrarVendedor = value;
+ OnPropertyChanged("MostrarVendedor");
+ }
+ }
+
+ public bool MostrarItem
+ {
+ get
+ {
+ return _mostrarItem;
+ }
+ set
+ {
+ _mostrarItem = value;
+ OnPropertyChanged("MostrarItem");
+ }
+ }
+
+ private void EntryOnPropertyChanged(object sender, PropertyChangedEventArgs args)
+ {
+ if (args.PropertyName == "Selecionado")
+ {
+ RecheckAllSelected();
+ }
+ }
+
+ private void RecheckAllSelected()
+ {
+ if (_allSelectedChanging)
+ {
+ return;
+ }
+ try
+ {
+ _allSelectedChanging = true;
+ if (Apolices.All((Documento e) => e.Selecionado))
+ {
+ AllSelected = true;
+ }
+ else if (Apolices.All((Documento e) => !e.Selecionado))
+ {
+ AllSelected = false;
+ }
+ else
+ {
+ AllSelected = null;
+ }
+ }
+ finally
+ {
+ _allSelectedChanging = false;
+ }
+ }
+
+ private void AllSelectedChanged()
+ {
+ if (_allSelectedChanging)
+ {
+ return;
+ }
+ try
+ {
+ _allSelectedChanging = true;
+ if (!AllSelected.HasValue)
+ {
+ return;
+ }
+ foreach (Documento apolice in Apolices)
+ {
+ apolice.Selecionado = AllSelected.Value;
+ }
+ }
+ finally
+ {
+ _allSelectedChanging = false;
+ }
+ }
+
+ public async Task CarregarDados(List<Documento> list, bool apenasCliente)
+ {
+ List<Cliente> source = ((IEnumerable<Documento>)list.ToList()).Select((Func<Documento, Cliente>)((Documento x) => new Cliente
+ {
+ Id = ((DomainBase)x.Controle.Cliente).Id
+ })).ToList();
+ ClienteServico clienteServico = new ClienteServico();
+ ItemServico itemServico = new ItemServico();
+ List<ClienteEndereco> enderecos = await clienteServico.BuscarEnderecosPorCliente(source.Where((Cliente x) => ((DomainBase)x).Id > 0).ToList());
+ ObservableCollection<Item> observableCollection = ((!apenasCliente) ? (await itemServico.BuscarItens(list.ToList())) : null);
+ ObservableCollection<Item> source2 = observableCollection;
+ foreach (Documento x2 in list)
+ {
+ if (enderecos.Where((ClienteEndereco y) => ((DomainBase)y.Cliente).Id == ((DomainBase)x2.Controle.Cliente).Id).Count() == 0)
+ {
+ continue;
+ }
+ if (((DomainBase)x2.Controle.Cliente).Id > 0)
+ {
+ x2.Controle.Cliente.Enderecos = new ObservableCollection<ClienteEndereco>(from y in enderecos.Where((ClienteEndereco y) => ((DomainBase)y.Cliente).Id == ((DomainBase)x2.Controle.Cliente).Id).ToList()
+ orderby y.Ordem
+ select y);
+ }
+ if (!apenasCliente)
+ {
+ x2.ItensAtivo = source2.Where((Item y) => ((DomainBase)y.Documento).Id == ((DomainBase)x2).Id).ToList();
+ }
+ }
+ TipoEtiqueta = (apenasCliente ? "CLIENTE" : "APÓLICE");
+ Apolices = (from x in list.Where(delegate(Documento x)
+ {
+ Cliente cliente = x.Controle.Cliente;
+ if (((cliente != null) ? cliente.Enderecos : null) != null)
+ {
+ Cliente cliente2 = x.Controle.Cliente;
+ if (cliente2 == null)
+ {
+ return false;
+ }
+ return cliente2.Enderecos.Count() > 0;
+ }
+ return false;
+ })
+ orderby x.Controle.Cliente.Nome
+ select x).ToList();
+ ApolicesFiltrados = new ObservableCollection<Documento>(Apolices);
+ AllSelected = true;
+ RecheckAllSelected();
+ }
+
+ public void EmitirEtiquetas()
+ {
+ string text = "";
+ List<Documento> list = Apolices.Where((Documento x) => x.Selecionado).ToList();
+ string tipoEtiqueta = TipoEtiqueta;
+ if (!(tipoEtiqueta == "CLIENTE"))
+ {
+ if (tipoEtiqueta == "APÓLICE")
+ {
+ if (UmaPagina)
+ {
+ text = "<html><head><style type='text/css'>@page{size: landscape}</style><title>ETIQUETAS</title></head><body>";
+ for (int i = 0; i < list.Count; i++)
+ {
+ text += "<div style='clear: both; page-break-after:always; margin-top:";
+ text += ((i == 0) ? "25%'>" : "30%'>");
+ text += "<div align='center'>";
+ text += "<table style='text-align: center;'>";
+ text += "<tr style='height: 2.5cm;'>";
+ text = text + "<td style='width: " + 10.7.ToString(CultureInfo.InvariantCulture) + "cm;'><font size='1px' face='Arial'>";
+ Documento val = list[i];
+ string[] obj = new string[7]
+ {
+ text,
+ val.Controle.Cliente.Nome.Trim(),
+ " <br>",
+ null,
+ null,
+ null,
+ null
+ };
+ object obj2;
+ if (!MostrarItem)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ if (val.ItensAtivo.Count <= 1)
+ {
+ Item? obj3 = val.ItensAtivo.FirstOrDefault();
+ obj2 = ((obj3 != null) ? obj3.Descricao.ToUpper() : null) + "<br>";
+ }
+ else
+ {
+ obj2 = "APÓLICE COLETIVA <br>";
+ }
+ if (obj2 == null)
+ {
+ obj2 = "";
+ }
+ }
+ obj[3] = (string)obj2;
+ obj[4] = (MostrarApolice ? (((val.Apolice == "PROSPECÇÃO") ? $"{val.Vigencia2:d} - APÓLICE: {val.Apolice} <br>" : ($"{val.Vigencia1:d} - {val.Vigencia2:d} - APÓLICE: {val.Apolice}" + (string.IsNullOrEmpty(val.Endosso) ? "<br>" : (" /" + val.Endosso + " <br>")))) ?? "") : null);
+ obj[5] = ((val.Apolice == "PROSPECÇÃO") ? "" : (val.Controle.Seguradora.Nome + " - " + val.Controle.Ramo.Nome + " <br>"));
+ obj[6] = (MostrarVendedor ? (((val.VendedorPrincipal == null) ? "" : ("VENDEDOR: " + val.VendedorPrincipal.Nome)) ?? "") : null);
+ text = string.Concat(obj);
+ text += "</font></td>";
+ text += "</tr>";
+ text += "</table>";
+ text += "</div>";
+ text += "</div>";
+ }
+ }
+ else
+ {
+ int num = 0;
+ int num2 = 0;
+ double num3 = 0.0;
+ if (DuasColunas)
+ {
+ num = 10;
+ num2 = 2;
+ num3 = 10.52;
+ }
+ else if (TresColunas)
+ {
+ num = 10;
+ num2 = 3;
+ num3 = 6.87;
+ }
+ Pular %= num * num2;
+ int pular = Pular;
+ text = "<html><head><style type='text/css'>@page{size: Letter; margin: 0cm}</style><title>ETIQUETAS</title></head><body><div align='center'>";
+ int num4 = 0;
+ while (num4 < list.Count)
+ {
+ text += "<div style='clear: both; page-break-after:always;'>";
+ text = text + "<table><tr style='height: " + ((num4 == 0) ? "0.55" : "0.8") + "cm;'></tr>";
+ for (int j = 0; j < num * num2; j += num2)
+ {
+ text += "<tr style='height: 2.6cm;'>";
+ for (int k = 0; k < num2; k++)
+ {
+ text = text + "<td style='width: " + num3.ToString(CultureInfo.InvariantCulture) + "cm; padding: 10px;'><font size='1px' face='Arial'>";
+ if (j + k >= Pular)
+ {
+ if (num4 < list.Count)
+ {
+ Documento val2 = list[num4];
+ string[] obj4 = new string[7]
+ {
+ text,
+ val2.Controle.Cliente.Nome.Trim(),
+ " <br>",
+ null,
+ null,
+ null,
+ null
+ };
+ object obj5;
+ if (!MostrarItem)
+ {
+ obj5 = null;
+ }
+ else
+ {
+ if (val2.ItensAtivo.Count <= 1)
+ {
+ Item? obj6 = val2.ItensAtivo.FirstOrDefault();
+ obj5 = ((obj6 != null) ? obj6.Descricao.ToUpper() : null) + "<br>";
+ }
+ else
+ {
+ obj5 = "APÓLICE COLETIVA <br>";
+ }
+ if (obj5 == null)
+ {
+ obj5 = "";
+ }
+ }
+ obj4[3] = (string)obj5;
+ obj4[4] = ((!MostrarApolice) ? null : (((val2.Apolice == "PROSPECÇÃO") ? $"{val2.Vigencia2:d} - APÓLICE: {val2.Apolice} <br>" : ($"{val2.Vigencia1:d} - {val2.Vigencia2:d} - APÓLICE: {val2.Apolice}" + (string.IsNullOrEmpty(val2.Endosso) ? "<br>" : (" /" + val2.Endosso + " <br>")))) ?? ""));
+ obj4[5] = ((val2.Apolice == "PROSPECÇÃO") ? "" : (val2.Controle.Seguradora.Nome + " - " + val2.Controle.Ramo.Nome + " <br>"));
+ obj4[6] = ((!MostrarVendedor) ? null : (((val2.VendedorPrincipal == null) ? "" : ("VENDEDOR: " + val2.VendedorPrincipal.Nome)) ?? ""));
+ text = string.Concat(obj4);
+ num4++;
+ }
+ Pular = 0;
+ }
+ text += "</font></td>";
+ }
+ }
+ text += "</table>";
+ text += "</div>";
+ }
+ Pular = (pular + list.Count) % (num * num2);
+ }
+ RegistrarAcao(string.Format("EMITIU ETIQUETA DE {0} DOCUMENTO{1}", list.Count, (list.Count == 1) ? "" : "S"), 0L, (TipoTela)59, "IDS DOS DOCUMENTOS:\n" + string.Join(", ", list.Select((Documento x) => ((DomainBase)x).Id)));
+ }
+ }
+ else
+ {
+ list = Apolices.Where((Documento x) => x.Selecionado && x.Controle.Cliente.Enderecos != null).ToList();
+ if (UmaPagina)
+ {
+ text = "<html><head><style type='text/css'>@page{size: landscape}</style><title>ETIQUETAS</title></head><body>";
+ for (int l = 0; l < list.Count; l++)
+ {
+ text += "<div style='clear: both; page-break-after:always; margin-top:";
+ text += ((l == 0) ? "25%'>" : "30%'>");
+ text += "<div align='center'>";
+ text += "<table style='text-align: center;'>";
+ text += "<tr style='height: 2.48cm;'>";
+ text = text + "<td style='width: " + 10.7.ToString(CultureInfo.InvariantCulture) + "cm;'><font size='3px' face='Arial'>";
+ Documento val3 = list[l];
+ if (MostrarNascimento)
+ {
+ val3.Controle.Cliente.Nascimento = new ClienteServico().BuscarNascimento(((DomainBase)val3.Controle.Cliente).Id);
+ }
+ string[] obj7 = new string[9]
+ {
+ text,
+ val3.Controle.Cliente.Nome.Trim(),
+ " ",
+ (!val3.Controle.Cliente.Nascimento.HasValue || !MostrarNascimento) ? "" : val3.Controle.Cliente.Nascimento?.ToString("dd/MM"),
+ " <br>",
+ null,
+ null,
+ null,
+ null
+ };
+ object obj16;
+ if (((DomainBase)val3.Controle.Cliente).Id != 0L)
+ {
+ string[] array = new string[10];
+ ClienteEndereco? obj8 = val3.Controle.Cliente.Enderecos.OrderBy((ClienteEndereco x) => x.Ordem).FirstOrDefault();
+ array[0] = ((obj8 == null) ? null : ((EnderecoBase)obj8).Endereco?.Trim());
+ array[1] = ", ";
+ ClienteEndereco? obj9 = val3.Controle.Cliente.Enderecos.FirstOrDefault();
+ array[2] = ((obj9 == null) ? null : ((EnderecoBase)obj9).Numero?.Trim());
+ ClienteEndereco? obj10 = val3.Controle.Cliente.Enderecos.FirstOrDefault();
+ object obj11;
+ if (string.IsNullOrWhiteSpace((obj10 != null) ? ((EnderecoBase)obj10).Complemento : null))
+ {
+ obj11 = "";
+ }
+ else
+ {
+ ClienteEndereco? obj12 = val3.Controle.Cliente.Enderecos.FirstOrDefault();
+ obj11 = "<br>" + ((obj12 == null) ? null : ((EnderecoBase)obj12).Complemento?.Trim());
+ }
+ array[3] = (string)obj11;
+ array[4] = "<br>";
+ ClienteEndereco? obj13 = val3.Controle.Cliente.Enderecos.FirstOrDefault();
+ array[5] = ((obj13 == null) ? null : ((EnderecoBase)obj13).Bairro?.Trim());
+ array[6] = " - ";
+ ClienteEndereco? obj14 = val3.Controle.Cliente.Enderecos.FirstOrDefault();
+ array[7] = ((obj14 == null) ? null : ((EnderecoBase)obj14).Cidade?.Trim());
+ array[8] = "/";
+ ClienteEndereco? obj15 = val3.Controle.Cliente.Enderecos.FirstOrDefault();
+ array[9] = ((obj15 == null) ? null : ((EnderecoBase)obj15).Estado?.Trim());
+ obj16 = string.Concat(array);
+ }
+ else
+ {
+ obj16 = "";
+ }
+ obj7[5] = (string)obj16;
+ obj7[6] = " <br>";
+ object obj18;
+ if (((DomainBase)val3.Controle.Cliente).Id != 0L)
+ {
+ ClienteEndereco? obj17 = val3.Controle.Cliente.Enderecos.OrderBy((ClienteEndereco x) => x.Ordem).FirstOrDefault();
+ obj18 = ((obj17 != null) ? ((EnderecoBase)obj17).Cep.Trim() : null) ?? "";
+ }
+ else
+ {
+ obj18 = "";
+ }
+ obj7[7] = (string)obj18;
+ obj7[8] = " <br>";
+ text = string.Concat(obj7);
+ text += "</font></td>";
+ text += "</tr>";
+ text += "</table>";
+ text += "</div>";
+ text += "</div>";
+ }
+ }
+ else
+ {
+ int num5 = 0;
+ int num6 = 0;
+ double num7 = 0.0;
+ if (DuasColunas)
+ {
+ num5 = 10;
+ num6 = 2;
+ num7 = 10.52;
+ }
+ else if (TresColunas)
+ {
+ num5 = 10;
+ num6 = 3;
+ num7 = 6.82;
+ }
+ Pular %= num5 * num6;
+ int pular2 = Pular;
+ text = "<html><head><style type='text/css'>@page{size: Letter; margin: 0cm}</style><title>ETIQUETAS</title></head><body><div align='center'>";
+ int num8 = 0;
+ while (num8 < list.Count)
+ {
+ text += "<div style='clear: both; page-break-after:always;'>";
+ bool flag = num8 == 0 || num8 == num5 * num6;
+ text = text + "<table><tr style='height: " + (flag ? "0.55" : "0.85") + "cm;'></tr>";
+ for (int m = 0; m < num5 * num6; m += num6)
+ {
+ text += "<tr style='height: 2.60cm;'>";
+ if (DuasColunas)
+ {
+ text += "<td style='width: 0.4cm;'>";
+ }
+ else if (TresColunas)
+ {
+ text += "<td style='width: 0.05cm;'>";
+ }
+ text += "</td>";
+ for (int n = 0; n < num6; n++)
+ {
+ text = text + "<td style='width: " + num7.ToString(CultureInfo.InvariantCulture) + "cm;'><font size='1px' face='Arial'>";
+ if (m + n >= Pular)
+ {
+ if (num8 < list.Count)
+ {
+ Documento val4 = list[num8];
+ if (MostrarNascimento)
+ {
+ val4.Controle.Cliente.Nascimento = new ClienteServico().BuscarNascimento(((DomainBase)val4.Controle.Cliente).Id);
+ }
+ if (val4.Controle.Cliente.Enderecos.Count() > 0)
+ {
+ string[] obj19 = new string[8]
+ {
+ text,
+ val4.Controle.Cliente.Nome.Trim(),
+ " ",
+ (!val4.Controle.Cliente.Nascimento.HasValue || !MostrarNascimento) ? "" : val4.Controle.Cliente.Nascimento?.ToString("dd/MM"),
+ " <br>",
+ null,
+ null,
+ null
+ };
+ object obj32;
+ if (((DomainBase)val4.Controle.Cliente).Id != 0L)
+ {
+ string[] array2 = new string[10];
+ ClienteEndereco? obj20 = val4.Controle.Cliente.Enderecos.FirstOrDefault();
+ array2[0] = ((obj20 == null) ? null : ((EnderecoBase)obj20).Endereco?.Trim());
+ array2[1] = ", ";
+ ClienteEndereco? obj21 = val4.Controle.Cliente.Enderecos.FirstOrDefault();
+ array2[2] = ((obj21 == null) ? null : ((EnderecoBase)obj21).Numero?.Trim());
+ ClienteEndereco? obj22 = val4.Controle.Cliente.Enderecos.FirstOrDefault();
+ object obj23;
+ if (string.IsNullOrWhiteSpace((obj22 != null) ? ((EnderecoBase)obj22).Complemento : null))
+ {
+ obj23 = "";
+ }
+ else
+ {
+ ClienteEndereco? obj24 = val4.Controle.Cliente.Enderecos.FirstOrDefault();
+ obj23 = "<br>" + ((obj24 != null) ? ((EnderecoBase)obj24).Complemento.Trim() : null);
+ }
+ array2[3] = (string)obj23;
+ array2[4] = "<br>";
+ ClienteEndereco? obj25 = val4.Controle.Cliente.Enderecos.FirstOrDefault();
+ array2[5] = ((obj25 == null) ? null : ((EnderecoBase)obj25).Bairro?.Trim());
+ array2[6] = " - ";
+ ClienteEndereco? obj26 = val4.Controle.Cliente.Enderecos.FirstOrDefault();
+ object obj27;
+ if (string.IsNullOrEmpty((obj26 != null) ? ((EnderecoBase)obj26).Cidade : null))
+ {
+ obj27 = "";
+ }
+ else
+ {
+ ClienteEndereco? obj28 = val4.Controle.Cliente.Enderecos.FirstOrDefault();
+ obj27 = ((obj28 != null) ? ((EnderecoBase)obj28).Cidade.Trim() : null);
+ }
+ array2[7] = (string)obj27;
+ array2[8] = "/";
+ ClienteEndereco? obj29 = val4.Controle.Cliente.Enderecos.FirstOrDefault();
+ object obj30;
+ if (string.IsNullOrEmpty((obj29 != null) ? ((EnderecoBase)obj29).Estado : null))
+ {
+ obj30 = "";
+ }
+ else
+ {
+ ClienteEndereco? obj31 = val4.Controle.Cliente.Enderecos.FirstOrDefault();
+ obj30 = ((obj31 != null) ? ((EnderecoBase)obj31).Estado.Trim() : null);
+ }
+ array2[9] = (string)obj30;
+ obj32 = string.Concat(array2);
+ }
+ else
+ {
+ obj32 = "";
+ }
+ obj19[5] = (string)obj32;
+ obj19[6] = " <br>";
+ object obj34;
+ if (((DomainBase)val4.Controle.Cliente).Id != 0L)
+ {
+ ClienteEndereco? obj33 = val4.Controle.Cliente.Enderecos.FirstOrDefault();
+ obj34 = ((obj33 != null) ? ((EnderecoBase)obj33).Cep.Trim() : null) ?? "";
+ }
+ else
+ {
+ obj34 = "";
+ }
+ obj19[7] = (string)obj34;
+ text = string.Concat(obj19);
+ }
+ num8++;
+ }
+ Pular = 0;
+ }
+ text += "</font></td>";
+ if (n < num6 - 1)
+ {
+ if (DuasColunas)
+ {
+ text += "<td style='width: 0.5cm;'>";
+ }
+ else if (TresColunas)
+ {
+ text += "<td style='width: 0.3cm;'>";
+ }
+ }
+ text += "</td>";
+ }
+ }
+ text += "</table>";
+ text += "</div>";
+ }
+ Pular = (pular2 + list.Count) % (num5 * num6);
+ }
+ RegistrarAcao(string.Format("EMITIU ETIQUETA DE {0} CLIENTE{1}", list.Count, (list.Count == 1) ? "" : "S"), 0L, (TipoTela)59, "IDS E NOMES DOS CLIENTES:\n" + string.Join("\n", list.Select((Documento x) => ((DomainBase)x.Controle.Cliente).Id + ": \"" + x.Controle.Cliente.Nome + "\"")));
+ }
+ text += "</body></html>";
+ string tempPath = Path.GetTempPath();
+ string text2 = $"{tempPath}{(object)(TipoExtrato)0}_{Funcoes.GetNetworkTime():ddMMyyyyhhmmss}.html";
+ StreamWriter streamWriter = new StreamWriter(text2, append: true, Encoding.UTF8);
+ streamWriter.Write(text);
+ streamWriter.Close();
+ Process.Start(text2);
+ }
+
+ internal async Task<List<Documento>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarApolice(value));
+ }
+
+ public List<Documento> FiltrarApolice(string filter)
+ {
+ ApolicesFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Documento>(Apolices) : new ObservableCollection<Documento>(from x in Apolices
+ where ValidationHelper.RemoveDiacritics(x.Controle.Cliente.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Controle.Cliente.Nome descending, ((DomainBase)x).Id
+ select x));
+ return ApolicesFiltrados.ToList();
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/IncluirRamoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/IncluirRamoViewModel.cs
new file mode 100644
index 0000000..f9bc22b
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/IncluirRamoViewModel.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Gestor.Application.Helpers;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class IncluirRamoViewModel : BaseSegurosViewModel
+{
+ private Ramo _selectedRamo;
+
+ private Ramo _adicionarRamo;
+
+ private List<Ramo> _ramosAdicionadas;
+
+ private ObservableCollection<Ramo> _ramos;
+
+ private string _filtro;
+
+ public Ramo SelectedRamo
+ {
+ get
+ {
+ return _selectedRamo;
+ }
+ set
+ {
+ _selectedRamo = value;
+ OnPropertyChanged("SelectedRamo");
+ }
+ }
+
+ public Ramo AdicionarRamo
+ {
+ get
+ {
+ return _adicionarRamo;
+ }
+ set
+ {
+ _adicionarRamo = value;
+ OnPropertyChanged("AdicionarRamo");
+ }
+ }
+
+ public List<Ramo> RamosAdicionadas
+ {
+ get
+ {
+ return _ramosAdicionadas;
+ }
+ set
+ {
+ _ramosAdicionadas = value;
+ OnPropertyChanged("RamosAdicionadas");
+ }
+ }
+
+ public ObservableCollection<Ramo> Ramos
+ {
+ get
+ {
+ return _ramos;
+ }
+ set
+ {
+ _ramos = value;
+ OnPropertyChanged("Ramos");
+ }
+ }
+
+ public string Filtro
+ {
+ get
+ {
+ return _filtro;
+ }
+ set
+ {
+ _filtro = value;
+ OnPropertyChanged("Filtro");
+ }
+ }
+
+ public IncluirRamoViewModel(List<Ramo> ramos)
+ {
+ RamosAdicionadas = ramos;
+ }
+
+ public async void Pesquisar()
+ {
+ if (string.IsNullOrWhiteSpace(Filtro) || Filtro.Length < 3)
+ {
+ return;
+ }
+ string text = Uri.EscapeDataString(Filtro);
+ Ramos = new ObservableCollection<Ramo>((await Connection.Get<List<Ramo>>("Ramos/search?ramo=" + text)).Where((Ramo x) => RamosAdicionadas.All((Ramo y) => ((DomainBase)y).Id != ((DomainBase)x).Id)));
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/IncluirSeguradoraViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/IncluirSeguradoraViewModel.cs
new file mode 100644
index 0000000..992960f
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/IncluirSeguradoraViewModel.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Gestor.Application.Helpers;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class IncluirSeguradoraViewModel : BaseSegurosViewModel
+{
+ private Seguradora _selectedSeguradora;
+
+ private Seguradora _adicionarSeguradora;
+
+ private List<Seguradora> _seguradorasAdicionadas;
+
+ private ObservableCollection<Seguradora> _seguradoras;
+
+ private string _filtro;
+
+ public Seguradora SelectedSeguradora
+ {
+ get
+ {
+ return _selectedSeguradora;
+ }
+ set
+ {
+ _selectedSeguradora = value;
+ OnPropertyChanged("SelectedSeguradora");
+ }
+ }
+
+ public Seguradora AdicionarSeguradora
+ {
+ get
+ {
+ return _adicionarSeguradora;
+ }
+ set
+ {
+ _adicionarSeguradora = value;
+ OnPropertyChanged("AdicionarSeguradora");
+ }
+ }
+
+ public List<Seguradora> SeguradorasAdicionadas
+ {
+ get
+ {
+ return _seguradorasAdicionadas;
+ }
+ set
+ {
+ _seguradorasAdicionadas = value;
+ OnPropertyChanged("SeguradorasAdicionadas");
+ }
+ }
+
+ public ObservableCollection<Seguradora> Seguradoras
+ {
+ get
+ {
+ return _seguradoras;
+ }
+ set
+ {
+ _seguradoras = value;
+ OnPropertyChanged("Seguradoras");
+ }
+ }
+
+ public string Filtro
+ {
+ get
+ {
+ return _filtro;
+ }
+ set
+ {
+ _filtro = value;
+ OnPropertyChanged("Filtro");
+ }
+ }
+
+ public IncluirSeguradoraViewModel(List<Seguradora> seguradoras)
+ {
+ SeguradorasAdicionadas = seguradoras;
+ }
+
+ public async void Pesquisar()
+ {
+ if (string.IsNullOrWhiteSpace(Filtro) || Filtro.Length < 3)
+ {
+ return;
+ }
+ string text = Uri.EscapeDataString(Filtro);
+ Seguradoras = new ObservableCollection<Seguradora>((await Connection.Get<List<Seguradora>>("Seguradoras/search?cia=" + text)).Where((Seguradora x) => SeguradorasAdicionadas.All((Seguradora y) => ((DomainBase)y).Id != ((DomainBase)x).Id)));
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/MalaDiretaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/MalaDiretaViewModel.cs
new file mode 100644
index 0000000..7a47ab6
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/MalaDiretaViewModel.cs
@@ -0,0 +1,660 @@
+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;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.ViewModels.Generic;
+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.Ferramentas;
+
+public class MalaDiretaViewModel : BaseSegurosViewModel
+{
+ private readonly MalaDiretaServico _servico;
+
+ private readonly FiltroArquivoDigital _filtro;
+
+ private ObservableCollection<MalaDireta> _malaDireta = new ObservableCollection<MalaDireta>();
+
+ private ObservableCollection<ComboVariavel> _variaveis = new ObservableCollection<ComboVariavel>();
+
+ private bool _enableCredencial;
+
+ private ObservableCollection<ComboModelo> _modelos = new ObservableCollection<ComboModelo>();
+
+ private ComboModelo _selectedModelo = new ComboModelo();
+
+ private ComboVariavel _selectedVariavel;
+
+ private string _assunto;
+
+ private string _corpo;
+
+ private ObservableCollection<Credencial> _credenciais = new ObservableCollection<Credencial>();
+
+ private Credencial _selectedCredencial = new Credencial();
+
+ private ObservableCollection<IndiceArquivoDigital> _arquivos = new ObservableCollection<IndiceArquivoDigital>();
+
+ private ObservableCollection<ArquivoDigital> _arquivosAnexados = new ObservableCollection<ArquivoDigital>();
+
+ private ArquivoDigital _selectedAnexado = new ArquivoDigital();
+
+ private Visibility _visibilitySalvarAnexos = (Visibility)1;
+
+ private bool _enviarOriginal;
+
+ private bool _salvarArquivoDigital;
+
+ private bool _assinatura;
+
+ public bool _confirmarLeitura;
+
+ public ObservableCollection<MalaDireta> MalaDireta
+ {
+ get
+ {
+ return _malaDireta;
+ }
+ set
+ {
+ _malaDireta = value;
+ OnPropertyChanged("MalaDireta");
+ }
+ }
+
+ public ObservableCollection<ComboVariavel> Variaveis
+ {
+ get
+ {
+ return _variaveis;
+ }
+ set
+ {
+ _variaveis = new ObservableCollection<ComboVariavel>(value.OrderBy((ComboVariavel x) => x.Indisponivel).ThenBy(delegate(ComboVariavel x)
+ {
+ //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)
+ VariaveisMalaDireta variaveisMalaDireta = x.VariaveisMalaDireta;
+ return ((object)(VariaveisMalaDireta)(ref variaveisMalaDireta)).ToString();
+ }));
+ OnPropertyChanged("Variaveis");
+ }
+ }
+
+ public bool EnableCredencial
+ {
+ get
+ {
+ return _enableCredencial;
+ }
+ set
+ {
+ _enableCredencial = value;
+ OnPropertyChanged("EnableCredencial");
+ }
+ }
+
+ public ObservableCollection<ComboModelo> Modelos
+ {
+ get
+ {
+ return _modelos;
+ }
+ set
+ {
+ List<string> source = ((VariaveisMalaDireta[])Enum.GetValues(typeof(VariaveisMalaDireta))).Select((VariaveisMalaDireta variavel) => ValidationHelper.GetEntity((Enum)(object)variavel)).ToList();
+ List<string> variaveisPermitidas = (from x in Variaveis
+ where !x.Indisponivel
+ select x into v
+ select ValidationHelper.GetEntity((Enum)(object)v.VariaveisMalaDireta)).ToList();
+ List<ComboModelo> list = new List<ComboModelo>();
+ foreach (ComboModelo item2 in value)
+ {
+ if (source.Where(item2.ModeloMalaDireta.Corpo.Contains).All((string s) => variaveisPermitidas.Contains(s)))
+ {
+ list.Add(item2);
+ continue;
+ }
+ ComboModelo item = new ComboModelo
+ {
+ ModeloMalaDireta = item2.ModeloMalaDireta,
+ Indisponivel = true
+ };
+ list.Add(item);
+ }
+ _modelos = new ObservableCollection<ComboModelo>(from x in list
+ orderby x.Indisponivel, x.ModeloMalaDireta.Assunto
+ select x);
+ OnPropertyChanged("Modelos");
+ }
+ }
+
+ public ComboModelo SelectedModelo
+ {
+ get
+ {
+ return _selectedModelo;
+ }
+ set
+ {
+ _selectedModelo = value;
+ VerificarEnables((value != null) ? new long?(((DomainBase)value.ModeloMalaDireta).Id) : null);
+ WorkOnSelectedModelo(value?.ModeloMalaDireta);
+ OnPropertyChanged("SelectedModelo");
+ }
+ }
+
+ public ComboVariavel SelectedVariavel
+ {
+ get
+ {
+ return _selectedVariavel;
+ }
+ set
+ {
+ _selectedVariavel = value;
+ OnPropertyChanged("SelectedVariavel");
+ }
+ }
+
+ public string Assunto
+ {
+ get
+ {
+ return _assunto;
+ }
+ set
+ {
+ _assunto = value;
+ OnPropertyChanged("Assunto");
+ }
+ }
+
+ public string Corpo
+ {
+ get
+ {
+ return _corpo;
+ }
+ set
+ {
+ _corpo = value;
+ OnPropertyChanged("Corpo");
+ }
+ }
+
+ public ObservableCollection<Credencial> Credenciais
+ {
+ get
+ {
+ return _credenciais;
+ }
+ set
+ {
+ _credenciais = value;
+ OnPropertyChanged("Credenciais");
+ }
+ }
+
+ public Credencial SelectedCredencial
+ {
+ get
+ {
+ return _selectedCredencial;
+ }
+ set
+ {
+ _selectedCredencial = value;
+ OnPropertyChanged("SelectedCredencial");
+ }
+ }
+
+ public ObservableCollection<IndiceArquivoDigital> Arquivos
+ {
+ get
+ {
+ return _arquivos;
+ }
+ set
+ {
+ _arquivos = value;
+ OnPropertyChanged("Arquivos");
+ }
+ }
+
+ public ObservableCollection<ArquivoDigital> ArquivosAnexados
+ {
+ get
+ {
+ return _arquivosAnexados;
+ }
+ set
+ {
+ _arquivosAnexados = value;
+ OnPropertyChanged("ArquivosAnexados");
+ }
+ }
+
+ public ArquivoDigital SelectedAnexado
+ {
+ get
+ {
+ return _selectedAnexado;
+ }
+ set
+ {
+ _selectedAnexado = value;
+ OnPropertyChanged("SelectedAnexado");
+ }
+ }
+
+ public Visibility VisibilitySalvarAnexos
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilitySalvarAnexos;
+ }
+ 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)
+ _visibilitySalvarAnexos = value;
+ OnPropertyChanged("VisibilitySalvarAnexos");
+ }
+ }
+
+ public bool EnviarOriginal
+ {
+ get
+ {
+ return _enviarOriginal;
+ }
+ set
+ {
+ _enviarOriginal = value;
+ OnPropertyChanged("EnviarOriginal");
+ }
+ }
+
+ public bool SalvarArquivoDigital
+ {
+ get
+ {
+ return _salvarArquivoDigital;
+ }
+ set
+ {
+ _salvarArquivoDigital = value;
+ OnPropertyChanged("SalvarArquivoDigital");
+ }
+ }
+
+ public bool Assinatura
+ {
+ get
+ {
+ return _assinatura;
+ }
+ set
+ {
+ _assinatura = value;
+ OnPropertyChanged("Assinatura");
+ }
+ }
+
+ public bool ConfirmarLeitura
+ {
+ get
+ {
+ return _confirmarLeitura;
+ }
+ set
+ {
+ _confirmarLeitura = value;
+ }
+ }
+
+ public bool Enviado { get; set; }
+
+ public MalaDiretaViewModel(FiltroArquivoDigital filtro = null)
+ {
+ //IL_0038: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0042: Expected O, but got Unknown
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0063: Expected O, but got Unknown
+ //IL_0065: Unknown result type (might be due to invalid IL or missing references)
+ _servico = new MalaDiretaServico();
+ _filtro = filtro;
+ BuscarCredenciais();
+ }
+
+ private async void BuscarCredenciais()
+ {
+ await PermissaoTela((TipoTela)39);
+ VerificarEnables(null);
+ Credenciais = new ObservableCollection<Credencial>((await new BaseServico().BuscarCredenciais()).OrderBy((Credencial x) => x.Descricao));
+ EnableCredencial = !Restricao((TipoRestricao)110);
+ SelectedCredencial = (EnableCredencial ? (((IEnumerable<Credencial>)Credenciais).FirstOrDefault((Func<Credencial, bool>)((Credencial x) => x.IdUsuario == ((DomainBase)Recursos.Usuario).Id)) ?? Credenciais.FirstOrDefault()) : ((IEnumerable<Credencial>)Credenciais).FirstOrDefault((Func<Credencial, bool>)((Credencial x) => x.IdUsuario == ((DomainBase)Recursos.Usuario).Id)));
+ }
+
+ private async Task CarregarModelos(ModeloMalaDireta modelo = null)
+ {
+ List<ModeloMalaDireta> obj = await _servico.BuscarModelos();
+ List<ComboModelo> list = new List<ComboModelo>();
+ foreach (ModeloMalaDireta item in obj)
+ {
+ list.Add(new ComboModelo
+ {
+ ModeloMalaDireta = item
+ });
+ }
+ Modelos = new ObservableCollection<ComboModelo>(list);
+ if (modelo != null)
+ {
+ SelectedModelo = Modelos.FirstOrDefault((ComboModelo x) => ((DomainBase)x.ModeloMalaDireta).Id == ((DomainBase)modelo).Id);
+ }
+ }
+
+ private void WorkOnSelectedModelo(ModeloMalaDireta value)
+ {
+ if (value != null)
+ {
+ Corpo = SelectedModelo.ModeloMalaDireta.Corpo;
+ Assunto = SelectedModelo.ModeloMalaDireta.Assunto;
+ }
+ }
+
+ 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 async Task<bool> Enviar()
+ {
+ if (string.IsNullOrWhiteSpace(Corpo) || string.IsNullOrWhiteSpace(Assunto))
+ {
+ await ShowMessage("NECESSÁRIO CONTER ASSUNTO E MENSAGEM PARA PROSSEGUIR.");
+ return false;
+ }
+ if (SelectedCredencial == null || ((DomainBase)SelectedCredencial).Id == 0L)
+ {
+ await ShowMessage("NECESSÁRIO SELECIONAR O E-MAIL DE ENVIO PARA PROSSEGUIR.");
+ return false;
+ }
+ List<MalaDireta> list = MalaDireta.Where((MalaDireta x) => x.Selecionado).ToList();
+ if (list.Count == 0)
+ {
+ await ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM DESTINATÁRIO PARA PROSSEGUIR.");
+ return false;
+ }
+ await ShowEnviarEmailsDialog(list, Assinatura, EnviarOriginal, ArquivosAnexados.ToList(), Assunto, Corpo, SelectedCredencial, _filtro, SalvarArquivoDigital, ConfirmarLeitura);
+ Enviado = true;
+ return true;
+ }
+
+ public async Task CarregarEmails(List<MalaDireta> maladireta, string assunto = null, string corpo = null)
+ {
+ ClienteServico clienteServico = new ClienteServico();
+ List<long> list = (from x in maladireta
+ where x.Cliente != null
+ select ((DomainBase)x.Cliente).Id).ToList();
+ VisibilitySalvarAnexos = (Visibility)(list.Count > 1);
+ List<ClienteEmail> emails = await clienteServico.BuscarEmailsPorCliente(list);
+ List<MalaDireta> maladiretacompleta = new List<MalaDireta>();
+ maladireta.ForEach(delegate(MalaDireta x)
+ {
+ //IL_0105: Unknown result type (might be due to invalid IL or missing references)
+ //IL_010b: Expected O, but got Unknown
+ //IL_0120: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0125: Unknown result type (might be due to invalid IL or missing references)
+ //IL_013b: Unknown result type (might be due to invalid IL or missing references)
+ if (x.Cliente != null)
+ {
+ Assinatura = Assinatura || (x.ArquivoDigital != null && x.ArquivoDigital.Any((IndiceArquivoDigital a) => !string.IsNullOrEmpty(a.UrlAssinatura) && !a.Assinado));
+ List<ClienteEmail> source = emails.Where((ClienteEmail e) => ((DomainBase)e.Cliente).Id == ((DomainBase)x.Cliente).Id).ToList();
+ int index = 0;
+ source.OrderBy((ClienteEmail o) => o.Ordem.GetValueOrDefault()).ToList().ForEach(delegate(ClienteEmail e)
+ {
+ //IL_00c7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00cd: Expected O, but got Unknown
+ //IL_0051: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0057: Expected O, but got Unknown
+ x.Selecionado = string.IsNullOrWhiteSpace(x.Email) && x.Cliente.MalaDireta.GetValueOrDefault(true);
+ if (index > 0)
+ {
+ MalaDireta val2 = new MalaDireta();
+ DomainBase.Copy<MalaDireta, MalaDireta>(val2, x);
+ val2.Email = ((EmailBase)e).Email;
+ val2.Selecionado = false;
+ maladiretacompleta.Add(val2);
+ }
+ else
+ {
+ x.Email = ((EmailBase)e).Email;
+ x.Ordem = e.Ordem.GetValueOrDefault();
+ MalaDireta val3 = new MalaDireta();
+ DomainBase.Copy<MalaDireta, MalaDireta>(val3, x);
+ maladiretacompleta.Add(val3);
+ }
+ index++;
+ });
+ }
+ if (x.Prospeccao != null)
+ {
+ MalaDireta val = new MalaDireta();
+ x.Cliente = (Cliente)(((object)x.Cliente) ?? ((object)new Cliente
+ {
+ Nome = x.Prospeccao.Nome,
+ Documento = x.Prospeccao.Documento
+ }));
+ if (string.IsNullOrEmpty(x.Cliente.Documento))
+ {
+ x.Cliente.Documento = x.Prospeccao.Documento;
+ }
+ x.Email = x.Prospeccao.Email;
+ x.Ordem = 0;
+ x.Selecionado = true;
+ DomainBase.Copy<MalaDireta, MalaDireta>(val, x);
+ maladiretacompleta.Add(val);
+ }
+ });
+ MalaDireta = new ObservableCollection<MalaDireta>(from x in maladiretacompleta
+ orderby x.Cliente.Nome, x.Ordem
+ select x);
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)18, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)0, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)1, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)2, indisponivel: false));
+ Variaveis.Add(MalaDireta.Any((MalaDireta x) => x.Cliente.VencimentoHabilitacao.HasValue) ? new ComboVariavel((VariaveisMalaDireta)16, indisponivel: false) : new ComboVariavel((VariaveisMalaDireta)16, indisponivel: true));
+ if (MalaDireta.Any((MalaDireta x) => x.Cliente.Nascimento.HasValue))
+ {
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)14, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)15, indisponivel: false));
+ }
+ else
+ {
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)14, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)15, indisponivel: true));
+ }
+ Variaveis.Add(MalaDireta.Any((MalaDireta x) => x.ArquivoDigital != null && x.ArquivoDigital.Any((IndiceArquivoDigital z) => !string.IsNullOrWhiteSpace(z.UrlAssinatura))) ? new ComboVariavel((VariaveisMalaDireta)17, indisponivel: false) : new ComboVariavel((VariaveisMalaDireta)17, indisponivel: true));
+ if (MalaDireta.All((MalaDireta x) => x.Apolice != null))
+ {
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)3, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)4, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)7, indisponivel: false));
+ Variaveis.Add(MalaDireta.Any((MalaDireta x) => x.Apolice.Vigencia2.HasValue) ? new ComboVariavel((VariaveisMalaDireta)8, indisponivel: false) : new ComboVariavel((VariaveisMalaDireta)8, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)19, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)23, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)24, indisponivel: false));
+ if (MalaDireta.Any((MalaDireta x) => x.Apolice.Controle != null))
+ {
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)5, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)6, indisponivel: false));
+ }
+ else
+ {
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)5, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)6, indisponivel: true));
+ }
+ }
+ else
+ {
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)19, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)3, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)4, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)7, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)8, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)5, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)6, indisponivel: true));
+ }
+ if (MalaDireta.All((MalaDireta x) => x.Parcela != null))
+ {
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)9, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)10, indisponivel: false));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)13, indisponivel: false));
+ }
+ else
+ {
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)9, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)10, indisponivel: true));
+ Variaveis.Add(new ComboVariavel((VariaveisMalaDireta)13, indisponivel: true));
+ }
+ Variaveis.Add(MalaDireta.All((MalaDireta x) => x.Item != null) ? new ComboVariavel((VariaveisMalaDireta)11, indisponivel: false) : new ComboVariavel((VariaveisMalaDireta)11, indisponivel: true));
+ Variaveis.Add(MalaDireta.All((MalaDireta x) => x.Sinistro != null) ? new ComboVariavel((VariaveisMalaDireta)12, indisponivel: false) : new ComboVariavel((VariaveisMalaDireta)12, indisponivel: true));
+ Variaveis = new ObservableCollection<ComboVariavel>(Variaveis);
+ Variaveis.Add(MalaDireta.Any(delegate(MalaDireta x)
+ {
+ Documento apolice3 = x.Apolice;
+ if (apolice3 == null)
+ {
+ return false;
+ }
+ _ = apolice3.PremioLiquido;
+ return true;
+ }) ? new ComboVariavel((VariaveisMalaDireta)20, indisponivel: false) : new ComboVariavel((VariaveisMalaDireta)20, indisponivel: true));
+ Variaveis.Add(MalaDireta.Any(delegate(MalaDireta x)
+ {
+ Documento apolice2 = x.Apolice;
+ if (apolice2 == null)
+ {
+ return false;
+ }
+ _ = apolice2.PremioTotal;
+ return true;
+ }) ? new ComboVariavel((VariaveisMalaDireta)21, indisponivel: false) : new ComboVariavel((VariaveisMalaDireta)21, indisponivel: true));
+ Variaveis.Add(MalaDireta.Any(delegate(MalaDireta x)
+ {
+ Documento apolice = x.Apolice;
+ return apolice != null && apolice.FormaPagamento.HasValue;
+ }) ? new ComboVariavel((VariaveisMalaDireta)22, indisponivel: false) : new ComboVariavel((VariaveisMalaDireta)22, indisponivel: true));
+ await CarregarModelos();
+ if (assunto != null)
+ {
+ Assunto = assunto;
+ }
+ if (corpo != null)
+ {
+ Corpo = corpo;
+ }
+ }
+
+ public void Selecionar()
+ {
+ MalaDireta.ToList().ForEach(delegate(MalaDireta x)
+ {
+ x.Selecionado = !x.Selecionado;
+ });
+ MalaDireta = new ObservableCollection<MalaDireta>(MalaDireta);
+ }
+
+ 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);
+ }
+ }
+
+ public void Incluir()
+ {
+ SelectedModelo = new ComboModelo();
+ Corpo = string.Empty;
+ Alterar(alterar: true);
+ }
+
+ public void CancelarAlteracao()
+ {
+ Alterar(alterar: false);
+ SelectedModelo = null;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ if (SelectedModelo == null)
+ {
+ SelectedModelo = new ComboModelo
+ {
+ ModeloMalaDireta = new ModeloMalaDireta
+ {
+ Assunto = Assunto,
+ Corpo = Corpo
+ }
+ };
+ }
+ else
+ {
+ SelectedModelo.ModeloMalaDireta.Assunto = Assunto;
+ SelectedModelo.ModeloMalaDireta.Corpo = Corpo;
+ }
+ List<KeyValuePair<string, string>> list = SelectedModelo.ModeloMalaDireta.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ ModeloMalaDireta modelo = await _servico.Save(SelectedModelo.ModeloMalaDireta);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ Alterar(alterar: false);
+ await CarregarModelos(modelo);
+ ToggleSnackBar("MODELO SALVO COM SUCESSO");
+ return null;
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedModelo != null && ((DomainBase)SelectedModelo.ModeloMalaDireta).Id != 0L && await ShowMessage("DESEJA REALMENTE EXCLUIR O MODELO?", "SIM", "NÃO") && await _servico.Delete(SelectedModelo.ModeloMalaDireta))
+ {
+ RegistrarAcao("EXCLUIU MODELO " + SelectedModelo.ModeloMalaDireta.Assunto, ((DomainBase)SelectedModelo.ModeloMalaDireta).Id, (TipoTela)39);
+ await CarregarModelos();
+ SelectedModelo = null;
+ ToggleSnackBar("MODELO EXCLUÍDO COM SUCESSO");
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/ManutencaoPagamentosViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ManutencaoPagamentosViewModel.cs
new file mode 100644
index 0000000..93bc1d6
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ManutencaoPagamentosViewModel.cs
@@ -0,0 +1,756 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+using CsQuery.ExtensionMethods;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class ManutencaoPagamentosViewModel : BaseSegurosViewModel
+{
+ private Visibility _filtrosPersonalizados = (Visibility)2;
+
+ private Visibility _visibilityFiltroPersonalizado = (Visibility)2;
+
+ private List<FiltroPersonalizado> _filtroRelatorioPersonalizado;
+
+ private FiltroPersonalizado _filtroPersonalizado;
+
+ private Type _tipoString = typeof(string);
+
+ private Type _tipoEnum = typeof(Enum);
+
+ private Type _tipoDateTime = typeof(DateTime);
+
+ private Type _tipoDecimal = typeof(decimal);
+
+ private Type _tipoInt = typeof(int);
+
+ private Type _tipoLong = typeof(long);
+
+ private string _valorIncial = "";
+
+ private string _valorFinal = "";
+
+ private bool _semValor;
+
+ private Visibility _visibilitySemValor = (Visibility)2;
+
+ private ObservableCollection<FiltroPersonalizado> _filtroPersonalizadoSelecionado;
+
+ private ObservableCollection<FiltroRelatorio> _filtroRelatorioSelecionado = new ObservableCollection<FiltroRelatorio>();
+
+ private ObservableCollection<Vendedor> _vendedores = new ObservableCollection<Vendedor>();
+
+ private Vendedor _selectedVendedor;
+
+ private bool _enableExcluirManutPagamento;
+
+ private ObservableCollection<ManutencaoPagamentos> _pagamentos;
+
+ private ListCollectionView _view;
+
+ private bool _allSelected;
+
+ private string _selectedFiltro;
+
+ private ObservableCollection<string> _filtros;
+
+ private DateTime? _inicio;
+
+ private DateTime? _fim;
+
+ private List<ManutencaoPagamentos> _todosPagamentos;
+
+ public Visibility FiltrosPersonalizados
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _filtrosPersonalizados;
+ }
+ 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)
+ _filtrosPersonalizados = value;
+ OnPropertyChanged("FiltrosPersonalizados");
+ }
+ }
+
+ public Visibility VisibilityFiltroPersonalizado
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilityFiltroPersonalizado;
+ }
+ 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)
+ _visibilityFiltroPersonalizado = value;
+ OnPropertyChanged("VisibilityFiltroPersonalizado");
+ }
+ }
+
+ public List<FiltroPersonalizado> RelatorioFiltroPersonalizado
+ {
+ get
+ {
+ return _filtroRelatorioPersonalizado;
+ }
+ set
+ {
+ _filtroRelatorioPersonalizado = value;
+ OnPropertyChanged("RelatorioFiltroPersonalizado");
+ }
+ }
+
+ public FiltroPersonalizado FiltroPersonalizado
+ {
+ get
+ {
+ return _filtroPersonalizado;
+ }
+ set
+ {
+ _filtroPersonalizado = value;
+ VisibilitySemValor = (Visibility)((value == null) ? 2 : 0);
+ OnPropertyChanged("FiltroPersonalizado");
+ if (value == null)
+ {
+ return;
+ }
+ string name = value.Tipo.Name;
+ if (name == null)
+ {
+ return;
+ }
+ switch (name.Length)
+ {
+ default:
+ return;
+ case 4:
+ {
+ char c = name[0];
+ if (c != 'E')
+ {
+ if (c != 'l' || !(name == "long"))
+ {
+ return;
+ }
+ break;
+ }
+ if (!(name == "Enum"))
+ {
+ return;
+ }
+ goto IL_0121;
+ }
+ case 5:
+ switch (name[3])
+ {
+ default:
+ return;
+ case '3':
+ if (!(name == "int32"))
+ {
+ return;
+ }
+ break;
+ case '6':
+ if (!(name == "int64"))
+ {
+ return;
+ }
+ break;
+ }
+ break;
+ case 6:
+ if (name == "String")
+ {
+ ValorInicial = "";
+ ValorFinal = "";
+ }
+ return;
+ case 7:
+ if (name == "Decimal")
+ {
+ ValorInicial = "0,00";
+ ValorFinal = "0,00";
+ }
+ return;
+ case 8:
+ if (!(name == "DateTime"))
+ {
+ return;
+ }
+ goto IL_0121;
+ case 3:
+ {
+ if (!(name == "int"))
+ {
+ return;
+ }
+ break;
+ }
+ IL_0121:
+ ValorInicial = null;
+ ValorFinal = null;
+ return;
+ }
+ ValorInicial = "0";
+ ValorFinal = "0";
+ }
+ }
+
+ public Type TipoString
+ {
+ get
+ {
+ return _tipoString;
+ }
+ set
+ {
+ _tipoString = value;
+ OnPropertyChanged("TipoString");
+ }
+ }
+
+ public Type TipoEnum
+ {
+ get
+ {
+ return _tipoEnum;
+ }
+ set
+ {
+ _tipoEnum = value;
+ OnPropertyChanged("TipoEnum");
+ }
+ }
+
+ public Type TipoDateTime
+ {
+ get
+ {
+ return _tipoDateTime;
+ }
+ set
+ {
+ _tipoDateTime = value;
+ OnPropertyChanged("TipoDateTime");
+ }
+ }
+
+ public Type TipoDecimal
+ {
+ get
+ {
+ return _tipoDecimal;
+ }
+ set
+ {
+ _tipoDecimal = value;
+ OnPropertyChanged("TipoDecimal");
+ }
+ }
+
+ public Type TipoInt
+ {
+ get
+ {
+ return _tipoInt;
+ }
+ set
+ {
+ _tipoInt = value;
+ OnPropertyChanged("TipoInt");
+ }
+ }
+
+ public Type TipoLong
+ {
+ get
+ {
+ return _tipoLong;
+ }
+ set
+ {
+ _tipoLong = value;
+ OnPropertyChanged("TipoLong");
+ }
+ }
+
+ public string ValorInicial
+ {
+ get
+ {
+ return _valorIncial;
+ }
+ set
+ {
+ _valorIncial = value;
+ OnPropertyChanged("ValorInicial");
+ }
+ }
+
+ public string ValorFinal
+ {
+ get
+ {
+ return _valorFinal;
+ }
+ set
+ {
+ _valorFinal = value;
+ OnPropertyChanged("ValorFinal");
+ }
+ }
+
+ public bool SemValor
+ {
+ get
+ {
+ return _semValor;
+ }
+ set
+ {
+ _semValor = value;
+ if (value)
+ {
+ ValorInicial = null;
+ ValorFinal = null;
+ }
+ OnPropertyChanged("SemValor");
+ }
+ }
+
+ public Visibility VisibilitySemValor
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visibilitySemValor;
+ }
+ 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)
+ _visibilitySemValor = value;
+ OnPropertyChanged("VisibilitySemValor");
+ }
+ }
+
+ public ObservableCollection<FiltroPersonalizado> FiltroPersonalizadoSelecionado
+ {
+ get
+ {
+ return _filtroPersonalizadoSelecionado;
+ }
+ set
+ {
+ _filtroPersonalizadoSelecionado = value;
+ OnPropertyChanged("FiltroPersonalizadoSelecionado");
+ }
+ }
+
+ public ObservableCollection<FiltroRelatorio> FiltroRelatorioSelecionado
+ {
+ get
+ {
+ return _filtroRelatorioSelecionado;
+ }
+ set
+ {
+ _filtroRelatorioSelecionado = value;
+ OnPropertyChanged("FiltroRelatorioSelecionado");
+ }
+ }
+
+ public ObservableCollection<Vendedor> Vendedores
+ {
+ get
+ {
+ return _vendedores;
+ }
+ set
+ {
+ _vendedores = value;
+ SelectedVendedor = SelectedVendedor ?? value.FirstOrDefault();
+ OnPropertyChanged("Vendedores");
+ }
+ }
+
+ public Vendedor SelectedVendedor
+ {
+ get
+ {
+ return _selectedVendedor;
+ }
+ set
+ {
+ _selectedVendedor = value;
+ OnPropertyChanged("SelectedVendedor");
+ }
+ }
+
+ public bool EnableExcluirManutPagamento
+ {
+ get
+ {
+ return _enableExcluirManutPagamento;
+ }
+ set
+ {
+ _enableExcluirManutPagamento = value;
+ OnPropertyChanged("EnableExcluirManutPagamento");
+ }
+ }
+
+ public ObservableCollection<ManutencaoPagamentos> Pagamentos
+ {
+ get
+ {
+ return _pagamentos;
+ }
+ set
+ {
+ //IL_0009: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0013: Expected O, but got Unknown
+ //IL_0023: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002d: Expected O, but got Unknown
+ //IL_003d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0047: Expected O, but got Unknown
+ _pagamentos = value;
+ View = new ListCollectionView((IList)value);
+ ((CollectionView)View).GroupDescriptions.Add((GroupDescription)new PropertyGroupDescription("Pagamento"));
+ ((CollectionView)View).GroupDescriptions.Add((GroupDescription)new PropertyGroupDescription("Vendedor"));
+ OnPropertyChanged("Pagamentos");
+ }
+ }
+
+ public ListCollectionView View
+ {
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ OnPropertyChanged("View");
+ }
+ }
+
+ public bool AllSelected
+ {
+ get
+ {
+ return _allSelected;
+ }
+ set
+ {
+ _allSelected = value;
+ OnPropertyChanged("AllSelected");
+ Selecionar(value);
+ }
+ }
+
+ public string SelectedFiltro
+ {
+ get
+ {
+ return _selectedFiltro;
+ }
+ set
+ {
+ _selectedFiltro = value;
+ OnPropertyChanged("SelectedFiltro");
+ }
+ }
+
+ public ObservableCollection<string> Filtros
+ {
+ get
+ {
+ return _filtros;
+ }
+ set
+ {
+ _filtros = value;
+ OnPropertyChanged("Filtros");
+ }
+ }
+
+ public DateTime? Inicio
+ {
+ get
+ {
+ return _inicio;
+ }
+ set
+ {
+ if (value.HasValue && value.Value < new DateTime(1754, 1, 1))
+ {
+ value = new DateTime(1754, 1, 1);
+ }
+ if (value.HasValue && value.Value > new DateTime(9999, 12, 31))
+ {
+ value = new DateTime(9999, 12, 31);
+ }
+ _inicio = value;
+ OnPropertyChanged("Inicio");
+ }
+ }
+
+ public DateTime? Fim
+ {
+ get
+ {
+ return _fim;
+ }
+ set
+ {
+ if (value.HasValue && value.Value < new DateTime(1754, 1, 1))
+ {
+ value = new DateTime(1754, 1, 1);
+ }
+ if (value.HasValue && value.Value > new DateTime(9999, 12, 31))
+ {
+ value = new DateTime(9999, 12, 31);
+ }
+ _fim = value;
+ OnPropertyChanged("Fim");
+ }
+ }
+
+ private List<ManutencaoPagamentos> TodosPagamentos
+ {
+ get
+ {
+ return _todosPagamentos;
+ }
+ set
+ {
+ FiltrosPersonalizados = (Visibility)((value == null || !value.Any()) ? 2 : 0);
+ _todosPagamentos = value;
+ }
+ }
+
+ public ManutencaoPagamentosViewModel()
+ {
+ //IL_0002: 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_0086: 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_017f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0187: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0197: Expected O, but got Unknown
+ Usuario usuario = Recursos.Usuario;
+ _enableExcluirManutPagamento = usuario != null && ((DomainBase)usuario).Id > 0;
+ _inicio = Funcoes.GetNetworkTime();
+ _fim = Funcoes.GetNetworkTime().AddDays(7.0);
+ base._002Ector();
+ Filtros = new ObservableCollection<string> { "DATA DE EMISSÃO DO RECEBIMENTO", "DATA DE EMISSÃO DO RECIBO DE PAGAMENTO" };
+ SelectedFiltro = Filtros.First();
+ List<Vendedor> list = (from x in Recursos.Vendedores
+ where x.Ativo
+ orderby x.Nome
+ select x).ToList();
+ list.Insert(0, new Vendedor
+ {
+ Id = 0L,
+ Nome = "TODAS OS VENDEDORES"
+ });
+ Vendedores = new ObservableCollection<Vendedor>(list);
+ RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado<ManutencaoPagamentos>();
+ }
+
+ public void Selecionar(bool value)
+ {
+ if (Pagamentos != null && Pagamentos.Count != 0)
+ {
+ ExtensionMethods.ForEach<ManutencaoPagamentos>((IEnumerable<ManutencaoPagamentos>)Pagamentos, (Action<ManutencaoPagamentos>)delegate(ManutencaoPagamentos x)
+ {
+ x.Selecionado = value;
+ });
+ }
+ }
+
+ public async Task Buscar()
+ {
+ if (Inicio.HasValue && Fim.HasValue)
+ {
+ FiltroPersonalizadoSelecionado = null;
+ VisibilityFiltroPersonalizado = (Visibility)0;
+ Filtros val = new Filtros
+ {
+ Inicio = Inicio.Value,
+ Fim = Fim.Value
+ };
+ if (((DomainBase)SelectedVendedor).Id > 0)
+ {
+ val.Vendedores = new List<long> { ((DomainBase)SelectedVendedor).Id };
+ }
+ if (!(SelectedFiltro == "DATA DE EMISSÃO DO RECEBIMENTO"))
+ {
+ val.Referencia = "DATA PAGAMENTO";
+ }
+ else
+ {
+ val.Referencia = "DATA PREVISÃO";
+ }
+ TodosPagamentos = await new VendedorServico().BuscarPagos(val);
+ Pagamentos = new ObservableCollection<ManutencaoPagamentos>(TodosPagamentos);
+ RegistrarAcao("CONSULTOU OS PAGAMENTOS DE \"" + Inicio.Value.ToShortDateString() + "\" A \"" + Fim.Value.ToShortDateString() + "\" POR " + SelectedFiltro, 0L, (TipoTela)58);
+ }
+ }
+
+ public async Task Excluir()
+ {
+ List<ManutencaoPagamentos> selecionados = Pagamentos.Where((ManutencaoPagamentos x) => x.Selecionado).ToList();
+ if (selecionados.Count == 0)
+ {
+ return;
+ }
+ string log = "PAGAMENTOS EXCLUÍDOS:";
+ foreach (ManutencaoPagamentos item in selecionados)
+ {
+ log += $"\nID: {item.Id}, NÚMERO: {item.Parcela}, ID DOCUMENTO: {item.IdDocumento}";
+ VendedorParcela val = await new VendedorServico().BuscarVendedorParcelaCompleto(item.Id);
+ val.DataPagamento = null;
+ await new ParcelaServico().Save(val);
+ }
+ RegistrarAcao(string.Format("EXCLUIU {0} PAGAMENTO{1}", selecionados.Count, (selecionados.Count > 1) ? "S" : ""), 0L, (TipoTela)58, log);
+ for (int num = Pagamentos.Count - 1; num >= 0; num--)
+ {
+ if (Pagamentos[num].Selecionado)
+ {
+ Pagamentos.RemoveAt(num);
+ }
+ }
+ ToggleSnackBar("PAGAMENTOS EXCLUÍDOS COM SUCESSO.");
+ }
+
+ public async void AdcionarFiltroPersonalizado()
+ {
+ if (FiltroPersonalizado == null)
+ {
+ return;
+ }
+ string descricao;
+ if (!SemValor)
+ {
+ List<FiltroPersonalizado> list = ((FiltroPersonalizadoSelecionado == null) ? new List<FiltroPersonalizado>() : FiltroPersonalizadoSelecionado.Where((FiltroPersonalizado x) => x.Propriedade == FiltroPersonalizado.Propriedade && x.SemValor).ToList());
+ if (list.Count > 0)
+ {
+ list.ForEach(delegate(FiltroPersonalizado x)
+ {
+ FiltroPersonalizadoSelecionado.Remove(x);
+ });
+ }
+ switch (FiltroPersonalizado.Tipo.Name)
+ {
+ default:
+ if (string.IsNullOrEmpty(ValorInicial))
+ {
+ await ShowMessage("O VALOR DEVE SER PREENCHIDO CORRETAMENTE.");
+ return;
+ }
+ descricao = FiltroPersonalizado.Nome + " = " + ValorInicial;
+ break;
+ case "DateTime":
+ {
+ if (!DateTime.TryParse(ValorInicial, out var result3) || !DateTime.TryParse(ValorFinal, out result3) || DateTime.Parse(ValorInicial) > DateTime.Parse(ValorFinal))
+ {
+ await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.");
+ return;
+ }
+ descricao = $"{FiltroPersonalizado.Nome}: {DateTime.Parse(ValorInicial):d} até {DateTime.Parse(ValorFinal):d}";
+ break;
+ }
+ case "Decimal":
+ {
+ if (!decimal.TryParse(ValorInicial, out var result2) || !decimal.TryParse(ValorFinal, out result2) || Math.Abs(decimal.Parse(ValorInicial)) > Math.Abs(decimal.Parse(ValorFinal)))
+ {
+ await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.");
+ return;
+ }
+ descricao = $"{FiltroPersonalizado.Nome}: {decimal.Parse(ValorInicial):n2} até {decimal.Parse(ValorFinal):n2}";
+ break;
+ }
+ case "Int32":
+ {
+ if (!int.TryParse(ValorInicial, out var result4) || !int.TryParse(ValorFinal, out result4) || int.Parse(ValorInicial) > int.Parse(ValorFinal))
+ {
+ await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.");
+ return;
+ }
+ descricao = $"{FiltroPersonalizado.Nome}: {int.Parse(ValorInicial):n0} até {int.Parse(ValorFinal):n0}";
+ break;
+ }
+ case "Int64":
+ {
+ if (!long.TryParse(ValorInicial, out var result) || !long.TryParse(ValorFinal, out result) || long.Parse(ValorInicial) > int.Parse(ValorFinal))
+ {
+ await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.");
+ return;
+ }
+ descricao = $"{FiltroPersonalizado.Nome}: {long.Parse(ValorInicial):n0} até {long.Parse(ValorFinal):n0}";
+ break;
+ }
+ }
+ }
+ else
+ {
+ List<FiltroPersonalizado> list2 = ((FiltroPersonalizadoSelecionado == null) ? new List<FiltroPersonalizado>() : FiltroPersonalizadoSelecionado.Where((FiltroPersonalizado x) => x.Propriedade == FiltroPersonalizado.Propriedade).ToList());
+ if (list2.Count > 0)
+ {
+ list2.ForEach(delegate(FiltroPersonalizado x)
+ {
+ FiltroPersonalizadoSelecionado.Remove(x);
+ });
+ }
+ descricao = FiltroPersonalizado.Nome + ": EM BRANCO";
+ }
+ if (FiltroPersonalizadoSelecionado == null)
+ {
+ FiltroPersonalizadoSelecionado = new ObservableCollection<FiltroPersonalizado>();
+ }
+ FiltroPersonalizadoSelecionado.Add(new FiltroPersonalizado
+ {
+ Nome = FiltroPersonalizado.Nome,
+ Propriedade = FiltroPersonalizado.Propriedade,
+ Tipo = FiltroPersonalizado.Tipo,
+ ValorIncial = ValorInicial,
+ ValorFinal = ValorFinal,
+ SemValor = SemValor,
+ Descricao = descricao
+ });
+ FiltroPersonalizado = null;
+ ValorInicial = string.Empty;
+ ValorFinal = string.Empty;
+ PesquisaPersonalizada();
+ }
+
+ public void PesquisaPersonalizada()
+ {
+ Pagamentos = new ObservableCollection<ManutencaoPagamentos>(TodosPagamentos.CustomWhere(FiltroPersonalizadoSelecionado.ToList()));
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/NotaFiscalViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/NotaFiscalViewModel.cs
new file mode 100644
index 0000000..c2585a0
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/NotaFiscalViewModel.cs
@@ -0,0 +1,348 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class NotaFiscalViewModel : BaseSegurosViewModel
+{
+ private readonly NotaFiscalServico _servico;
+
+ private readonly ServicoExtrato _servicoExtrato;
+
+ private bool _apelido;
+
+ private List<Estipulante> _estipulantes;
+
+ private List<Seguradora> _seguradoras;
+
+ private ObservableCollection<NotaFiscal> _notasFiscaisFiltrados = new ObservableCollection<NotaFiscal>();
+
+ private bool _isExpanded;
+
+ private string _numExtrato;
+
+ private NotaFiscal _selectedNotaFiscal;
+
+ public NotaFiscal CancelNotaFiscal;
+
+ public bool Apelido
+ {
+ get
+ {
+ return _apelido;
+ }
+ set
+ {
+ _apelido = value;
+ OnPropertyChanged("Apelido");
+ }
+ }
+
+ public List<Estipulante> Estipulantes
+ {
+ get
+ {
+ return _estipulantes;
+ }
+ set
+ {
+ _estipulantes = value;
+ OnPropertyChanged("Estipulantes");
+ }
+ }
+
+ public List<Seguradora> Seguradoras
+ {
+ get
+ {
+ return _seguradoras;
+ }
+ set
+ {
+ _seguradoras = value;
+ OnPropertyChanged("Seguradoras");
+ }
+ }
+
+ public ObservableCollection<NotaFiscal> NotasFiscaisFiltrados
+ {
+ get
+ {
+ return _notasFiscaisFiltrados;
+ }
+ set
+ {
+ _notasFiscaisFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("NotasFiscaisFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public string NumExtrato
+ {
+ get
+ {
+ return _numExtrato;
+ }
+ set
+ {
+ _numExtrato = value;
+ OnPropertyChanged("NumExtrato");
+ }
+ }
+
+ public List<NotaFiscal> NotasFiscais { get; set; }
+
+ public NotaFiscal SelectedNotaFiscal
+ {
+ get
+ {
+ return _selectedNotaFiscal;
+ }
+ set
+ {
+ _selectedNotaFiscal = value;
+ WorkOnSelectedNotaFiscal(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedNotaFiscal");
+ }
+ }
+
+ public NotaFiscalViewModel()
+ {
+ _servicoExtrato = new ServicoExtrato();
+ _servico = new NotaFiscalServico();
+ Seguradoras = Recursos.Seguradoras.Where((Seguradora x) => x.Ativo).ToList();
+ Estipulantes = Recursos.Estipulantes.Where((Estipulante e) => e.Ativo).ToList();
+ Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 6);
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)55);
+ await SelecionaNotaFiscal();
+ Loading(isLoading: false);
+ }
+
+ public async Task SelecionaNotaFiscal()
+ {
+ Loading(isLoading: true);
+ NotasFiscais = (await _servico.BuscarNotasFiscais()).OrderBy((NotaFiscal x) => x.Seguradora.Nome).ToList();
+ NotasFiscaisFiltrados = new ObservableCollection<NotaFiscal>(NotasFiscais);
+ SelectedNotaFiscal = NotasFiscaisFiltrados.FirstOrDefault();
+ Loading(isLoading: false);
+ }
+
+ public async Task<List<NotaFiscal>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarNotaFiscal(value));
+ }
+
+ public List<NotaFiscal> FiltrarNotaFiscal(string filter)
+ {
+ NotasFiscaisFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<NotaFiscal>(NotasFiscais) : new ObservableCollection<NotaFiscal>(from x in NotasFiscais
+ where ValidationHelper.RemoveDiacritics(x.Seguradora.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) || ValidationHelper.RemoveDiacritics(x.ValorBruto.ToString(CultureInfo.InvariantCulture).Trim()).Contains(ValidationHelper.RemoveDiacritics(filter)) || ValidationHelper.RemoveDiacritics(x.Data.ToString().Trim()).Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Seguradora.Nome
+ select x));
+ return NotasFiscaisFiltrados.ToList();
+ }
+
+ public void Incluir()
+ {
+ //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_0011: Expected O, but got Unknown
+ //IL_0011: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0012: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001c: Expected O, but got Unknown
+ //IL_001c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0027: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0032: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004d: Expected O, but got Unknown
+ SelectedNotaFiscal = new NotaFiscal
+ {
+ Seguradora = new Seguradora(),
+ Estipulante = new Estipulante(),
+ Iss = 0m,
+ ValorLiquido = 0m,
+ ValorBruto = 0m,
+ Extrato = ""
+ };
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedNotaFiscal.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ string acao = ((((DomainBase)SelectedNotaFiscal).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ NotaFiscal selectedNotaFiscal = SelectedNotaFiscal;
+ int num;
+ if (selectedNotaFiscal == null)
+ {
+ num = 0;
+ }
+ else
+ {
+ Estipulante estipulante = selectedNotaFiscal.Estipulante;
+ num = ((((estipulante != null) ? new long?(((DomainBase)estipulante).Id) : null) <= 0) ? 1 : 0);
+ }
+ if (num != 0)
+ {
+ SelectedNotaFiscal.Estipulante = null;
+ }
+ NotaFiscal value = await _servico.Save(SelectedNotaFiscal);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao($"{acao} NOTA FISCAL DE ID \"{((DomainBase)value).Id}\"", ((DomainBase)value).Id, (TipoTela)55, string.Format("SEGURADORA: {0}\nDATA: {1}\nBRUTO: {2:c}\nISS: {3:c}\nLÍQUIDO: {4:c}", value.Seguradora.Nome, (!value.Data.HasValue) ? "-" : $"{value.Data:d}", value.ValorBruto, value.Iss, value.ValorLiquido));
+ if (NotasFiscais.Any((NotaFiscal x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<NotaFiscal, NotaFiscal>(NotasFiscais.First((NotaFiscal x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ NotasFiscais.Add(value);
+ }
+ if (NotasFiscaisFiltrados.Any((NotaFiscal x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<NotaFiscal, NotaFiscal>(NotasFiscaisFiltrados.First((NotaFiscal x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ NotasFiscaisFiltrados.Add(value);
+ }
+ NotasFiscaisFiltrados = new ObservableCollection<NotaFiscal>(NotasFiscaisFiltrados);
+ WorkOnSelectedNotaFiscal(value, registrar: false);
+ Alterar(alterar: false);
+ ToggleSnackBar("NOTA FISCAL SALVA COM SUCESSO");
+ return null;
+ }
+
+ public async Task SalvarLote(List<NotaFiscal> notas)
+ {
+ foreach (NotaFiscal nota in notas)
+ {
+ bool flag = nota.IdExtrato.HasValue;
+ if (flag)
+ {
+ flag = await _servico.Cadatrada(nota.IdExtrato.Value);
+ }
+ if (!flag)
+ {
+ SelectedNotaFiscal = nota;
+ await Salvar();
+ }
+ }
+ ToggleSnackBar("NOTAS FISCAIS SALVAS COM SUCESSO");
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelNotaFiscal != null && NotasFiscais.Any((NotaFiscal x) => ((DomainBase)x).Id == ((DomainBase)CancelNotaFiscal).Id))
+ {
+ DomainBase.Copy<NotaFiscal, NotaFiscal>(NotasFiscais.First((NotaFiscal x) => ((DomainBase)x).Id == ((DomainBase)CancelNotaFiscal).Id), CancelNotaFiscal);
+ if (NotasFiscaisFiltrados.Count > 0 && NotasFiscaisFiltrados.Any((NotaFiscal x) => ((DomainBase)x).Id == ((DomainBase)CancelNotaFiscal).Id))
+ {
+ DomainBase.Copy<NotaFiscal, NotaFiscal>(NotasFiscaisFiltrados.First((NotaFiscal x) => ((DomainBase)x).Id == ((DomainBase)CancelNotaFiscal).Id), CancelNotaFiscal);
+ }
+ else
+ {
+ NotasFiscaisFiltrados.Add(CancelNotaFiscal);
+ }
+ NotasFiscaisFiltrados = new ObservableCollection<NotaFiscal>(NotasFiscaisFiltrados);
+ SelectedNotaFiscal = NotasFiscaisFiltrados.First((NotaFiscal x) => ((DomainBase)x).Id == ((DomainBase)CancelNotaFiscal).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedNotaFiscal != null && ((DomainBase)SelectedNotaFiscal).Id != 0L && await ShowMessage("DESEJA REALMENTE EXCLUIR A NOTA FISCAL DA " + SelectedNotaFiscal.Seguradora.Nome + "?", "SIM", "NÃO"))
+ {
+ Loading(isLoading: true);
+ if (!(await _servico.Delete(SelectedNotaFiscal)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ RegistrarAcao($"EXCLUIU NOTA FISCAL DE ID \"{((DomainBase)SelectedNotaFiscal).Id}\"", ((DomainBase)SelectedNotaFiscal).Id, (TipoTela)55, string.Format("SEGURADORA: {0}\nDATA: {1}\nBRUTO: {2:c}\nISS: {3:c}\nLÍQUIDO: {4:c}", SelectedNotaFiscal.Seguradora.Nome, (!SelectedNotaFiscal.Data.HasValue) ? "-" : $"{SelectedNotaFiscal.Data:d}", SelectedNotaFiscal.ValorBruto, SelectedNotaFiscal.Iss, SelectedNotaFiscal.ValorLiquido));
+ await SelecionaNotaFiscal();
+ Loading(isLoading: false);
+ ToggleSnackBar("RECIBO EXCLUÍDO COM SUCESSO");
+ }
+ }
+
+ private async Task WorkOnSelectedNotaFiscal(NotaFiscal value, bool registrar = true)
+ {
+ CancelNotaFiscal = (NotaFiscal)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelNotaFiscal) : ((object)(NotaFiscal)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 55))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao($"ACESSOU NOTA FISCAL DE ID \"{((DomainBase)value).Id}\"", ((DomainBase)value).Id, (TipoTela)55, string.Format("SEGURADORA: {0}\nDATA: {1}\nBRUTO: {2:c}\nISS: {3:c}\nLÍQUIDO: {4:c}", value.Seguradora.Nome, (!value.Data.HasValue) ? "-" : $"{value.Data:d}", value.ValorBruto, value.Iss, value.ValorLiquido));
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)55;
+ if (string.IsNullOrEmpty(SelectedNotaFiscal.Extrato))
+ {
+ NotaFiscal selectedNotaFiscal = SelectedNotaFiscal;
+ string extrato = ((!SelectedNotaFiscal.IdExtrato.HasValue) ? "" : (await _servicoExtrato.BuscarNumExtrato(SelectedNotaFiscal.IdExtrato)));
+ selectedNotaFiscal.Extrato = extrato;
+ }
+ NotaFiscal selectedNotaFiscal2 = SelectedNotaFiscal;
+ if (((selectedNotaFiscal2 != null) ? new long?(((DomainBase)selectedNotaFiscal2).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedNotaFiscal = ((IEnumerable<NotaFiscal>)NotasFiscaisFiltrados).FirstOrDefault((Func<NotaFiscal, bool>)((NotaFiscal x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+
+ public async Task<decimal> BuscarImposto()
+ {
+ List<Imposto> source = await new ImpostoServico().Buscar(true);
+ Imposto? obj = ((IEnumerable<Imposto>)source).FirstOrDefault((Func<Imposto, bool>)((Imposto x) => x.Seguradora != null && ((DomainBase)x.Seguradora).Id == ((DomainBase)SelectedNotaFiscal.Seguradora).Id && x.Ramo == null)) ?? ((IEnumerable<Imposto>)source).FirstOrDefault((Func<Imposto, bool>)((Imposto x) => x.Seguradora == null && x.Ramo == null));
+ return (obj != null) ? obj.Iss : 0m;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/ProdutoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ProdutoViewModel.cs
new file mode 100644
index 0000000..efbb0dd
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ProdutoViewModel.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.Helpers;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class ProdutoViewModel : BaseSegurosViewModel
+{
+ private readonly ProdutoServico _servico;
+
+ private Produto _selectedProduto;
+
+ public Produto CancelProduto;
+
+ private ObservableCollection<Produto> _produtosFiltrados = new ObservableCollection<Produto>();
+
+ private bool _isExpanded;
+
+ public Produto SelectedProduto
+ {
+ get
+ {
+ return _selectedProduto;
+ }
+ set
+ {
+ _selectedProduto = value;
+ WorkOnSelectedProduto(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedProduto");
+ }
+ }
+
+ public ObservableCollection<Produto> ProdutosFiltrados
+ {
+ get
+ {
+ return _produtosFiltrados;
+ }
+ set
+ {
+ _produtosFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("ProdutosFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public List<Produto> Produtos { get; set; }
+
+ public ProdutoViewModel()
+ {
+ _servico = new ProdutoServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)10);
+ await SelecionaProdutos();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaProdutos()
+ {
+ Loading(isLoading: true);
+ Produtos = (from x in await new BaseServico().BuscarProdutosAsync()
+ orderby x.Ativo descending, x.Nome
+ select x).ToList();
+ ProdutosFiltrados = new ObservableCollection<Produto>(Produtos);
+ SelectedProduto = ProdutosFiltrados.FirstOrDefault();
+ Recursos.Produtos = Produtos.OrderBy((Produto x) => x.Nome).ToList();
+ Loading(isLoading: false);
+ Loading(isLoading: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ if (string.IsNullOrWhiteSpace(SelectedProduto.Nome))
+ {
+ return new List<KeyValuePair<string, string>>();
+ }
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ bool valida = true;
+ List<Produto> list = await new BaseServico().BuscarProduto(SelectedProduto.Nome);
+ if (list.Count > 0)
+ {
+ list.ForEach(delegate(Produto x)
+ {
+ if (((DomainBase)x).Id != ((DomainBase)SelectedProduto).Id && x.Nome == SelectedProduto.Nome)
+ {
+ valida = false;
+ }
+ });
+ }
+ if (!valida)
+ {
+ errors.Add(new KeyValuePair<string, string>("Nome", "UM PRODUTO COM O MESMO NOME JÁ EXISTE."));
+ }
+ return errors;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> errorMessages = SelectedProduto.Validate();
+ List<KeyValuePair<string, string>> list = errorMessages;
+ list.AddRange(await Validate());
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ string acao = ((((DomainBase)SelectedProduto).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Produto value = await _servico.Save(SelectedProduto);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " PRODUTO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)10, $"PRODUTO \"{value.Nome}\", ID: {((DomainBase)value).Id}");
+ if (Produtos.Any((Produto x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Produto, Produto>(Produtos.First((Produto x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ Produtos.Add(value);
+ }
+ if (ProdutosFiltrados.Any((Produto x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Produto, Produto>(ProdutosFiltrados.First((Produto x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ ProdutosFiltrados.Add(value);
+ }
+ ProdutosFiltrados = new ObservableCollection<Produto>(ProdutosFiltrados);
+ Recursos.Produtos = Produtos.OrderBy((Produto x) => x.Nome).ToList();
+ WorkOnSelectedProduto(value, registrar: false);
+ Alterar(alterar: false);
+ ToggleSnackBar("PRODUTO SALVO COM SUCESSO");
+ return null;
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelProduto != null && Produtos.Any((Produto x) => ((DomainBase)x).Id == ((DomainBase)CancelProduto).Id))
+ {
+ DomainBase.Copy<Produto, Produto>(Produtos.First((Produto x) => ((DomainBase)x).Id == ((DomainBase)CancelProduto).Id), CancelProduto);
+ if (ProdutosFiltrados.Count > 0 && ProdutosFiltrados.Any((Produto x) => ((DomainBase)x).Id == ((DomainBase)CancelProduto).Id))
+ {
+ DomainBase.Copy<Produto, Produto>(ProdutosFiltrados.First((Produto x) => ((DomainBase)x).Id == ((DomainBase)CancelProduto).Id), CancelProduto);
+ }
+ else
+ {
+ ProdutosFiltrados.Add(CancelProduto);
+ }
+ ProdutosFiltrados = new ObservableCollection<Produto>(ProdutosFiltrados);
+ SelectedProduto = ProdutosFiltrados.First((Produto x) => ((DomainBase)x).Id == ((DomainBase)CancelProduto).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ private void WorkOnSelectedProduto(Produto value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Invalid comparison between Unknown and I4
+ //IL_00d6: Unknown result type (might be due to invalid IL or missing references)
+ CancelProduto = (Produto)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelProduto) : ((object)(Produto)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 10))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU PRODUTO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)10, $"ID PRODUTO: {((DomainBase)value).Id}");
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)10;
+ Produto selectedProduto = SelectedProduto;
+ if (((selectedProduto != null) ? new long?(((DomainBase)selectedProduto).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedProduto = ((IEnumerable<Produto>)ProdutosFiltrados).FirstOrDefault((Func<Produto, bool>)((Produto x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+
+ public void Incluir()
+ {
+ //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_0012: Expected O, but got Unknown
+ SelectedProduto = new Produto
+ {
+ Ativo = true
+ };
+ Alterar(alterar: true);
+ }
+
+ internal async Task<List<Produto>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarProduto(value));
+ }
+
+ public List<Produto> FiltrarProduto(string filter)
+ {
+ ProdutosFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Produto>(Produtos) : new ObservableCollection<Produto>(from x in Produtos
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ativo descending, x.Nome
+ select x));
+ SelectedProduto = ProdutosFiltrados.FirstOrDefault();
+ return ProdutosFiltrados.ToList();
+ }
+
+ public void SelecionaProduto(Produto produto)
+ {
+ SelectedProduto = produto;
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/ProtocoloDocumentosViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ProtocoloDocumentosViewModel.cs
new file mode 100644
index 0000000..20e4e44
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ProtocoloDocumentosViewModel.cs
@@ -0,0 +1,278 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using Assinador.Infrastructure.Helpers;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.Views.Ferramentas;
+using Gestor.Application.Views.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class ProtocoloDocumentosViewModel : BaseSegurosViewModel
+{
+ private Cliente _selectedCliente = new Cliente();
+
+ private ObservableCollection<Documento> _apolicesFiltradas = new ObservableCollection<Documento>();
+
+ private ObservableCollection<ProtocoloEtiqueta> _apolicesAdicionadas = new ObservableCollection<ProtocoloEtiqueta>();
+
+ private FiltroStatusDocumento _selectedStatus;
+
+ public Cliente SelectedCliente
+ {
+ get
+ {
+ return _selectedCliente;
+ }
+ set
+ {
+ //IL_0053: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0030: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0037: Invalid comparison between Unknown and I4
+ _selectedCliente = value;
+ if (SelectedCliente != null && ((DomainBase)SelectedCliente).Id != 0L && (LastAccessId != ((DomainBase)SelectedCliente).Id || (int)LastAccessTela != 59))
+ {
+ SelecionarDocumentos();
+ LastAccessId = ((DomainBase)SelectedCliente).Id;
+ LastAccessTela = (TipoTela)59;
+ }
+ OnPropertyChanged("SelectedCliente");
+ }
+ }
+
+ public ObservableCollection<Documento> ApolicesFiltradas
+ {
+ get
+ {
+ return _apolicesFiltradas;
+ }
+ set
+ {
+ _apolicesFiltradas = value;
+ OnPropertyChanged("ApolicesFiltradas");
+ }
+ }
+
+ public ObservableCollection<ProtocoloEtiqueta> ApolicesAdicionadas
+ {
+ get
+ {
+ return _apolicesAdicionadas;
+ }
+ set
+ {
+ _apolicesAdicionadas = value;
+ OnPropertyChanged("ApolicesAdicionadas");
+ }
+ }
+
+ 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)
+ _selectedStatus = value;
+ SelectedCliente = SelectedCliente;
+ SelecionarDocumentos();
+ OnPropertyChanged("SelectedStatus");
+ }
+ }
+
+ public async void SelecionarDocumentos()
+ {
+ Loading(isLoading: true);
+ if (SelectedCliente == null)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ ApolicesFiltradas = await new ApoliceServico().BuscarApolicesComissao(((DomainBase)SelectedCliente).Id, SelectedStatus);
+ ProtocoloDocumentosViewModel protocoloDocumentosViewModel = this;
+ string arg = (((int)SelectedStatus == 4) ? "TODOS OS DOCUMENTOS" : ("OS " + Functions.GetDescription((Enum)(object)SelectedStatus)));
+ Cliente selectedCliente = SelectedCliente;
+ string arg2 = ((selectedCliente != null) ? selectedCliente.Nome : null);
+ Cliente selectedCliente2 = SelectedCliente;
+ protocoloDocumentosViewModel.RegistrarAcao($"CONSULTOU {arg} DO CLIENTE {arg2} ({((selectedCliente2 != null) ? new long?(((DomainBase)selectedCliente2).Id) : null)})", (SelectedCliente == null) ? 0 : ((DomainBase)SelectedCliente).Id, (TipoTela)59);
+ Loading(isLoading: false);
+ }
+
+ public async void AdicionarProtocolo(Documento documento)
+ {
+ bool flag = ApolicesAdicionadas.Any((ProtocoloEtiqueta x) => ((DomainBase)x.Documento).Id == ((DomainBase)documento).Id && (int)x.Tipo == 0);
+ if (flag)
+ {
+ flag = !(await ShowMessage("JÁ EXISTE UM PROTOCOLO ADICIONADO PARA O DOCUMENTO SELECIONADO, DESEJA ADICIONAR NOVAMENTE?", "SIM", "NÃO"));
+ }
+ if (!flag)
+ {
+ ObservableCollection<ProtocoloEtiqueta> apolicesAdicionadas = ApolicesAdicionadas;
+ ProtocoloEtiqueta protocoloEtiqueta = new ProtocoloEtiqueta();
+ ProtocoloEtiqueta protocoloEtiqueta2 = protocoloEtiqueta;
+ protocoloEtiqueta2.Documento = await new ApoliceServico().BuscarApoliceAsync(((DomainBase)documento).Id);
+ protocoloEtiqueta.Tipo = (TipoProtocoloEtiqueta)0;
+ apolicesAdicionadas.Add(protocoloEtiqueta);
+ ApolicesAdicionadas = new ObservableCollection<ProtocoloEtiqueta>(ApolicesAdicionadas.OrderBy((ProtocoloEtiqueta x) => ((DomainBase)x.Documento).Id));
+ }
+ }
+
+ public async void AdicionarEtiqueta(Documento documento)
+ {
+ ObservableCollection<ProtocoloEtiqueta> apolicesAdicionadas = ApolicesAdicionadas;
+ ProtocoloEtiqueta protocoloEtiqueta = new ProtocoloEtiqueta();
+ ProtocoloEtiqueta protocoloEtiqueta2 = protocoloEtiqueta;
+ protocoloEtiqueta2.Documento = await new ApoliceServico().BuscarApoliceAsync(((DomainBase)documento).Id);
+ protocoloEtiqueta.Tipo = (TipoProtocoloEtiqueta)1;
+ apolicesAdicionadas.Add(protocoloEtiqueta);
+ ApolicesAdicionadas = new ObservableCollection<ProtocoloEtiqueta>(ApolicesAdicionadas.OrderBy((ProtocoloEtiqueta x) => ((DomainBase)x.Documento).Id));
+ }
+
+ public async void AdicionarEtiquetaCliente()
+ {
+ if (SelectedCliente == null || ((DomainBase)SelectedCliente).Id == 0L)
+ {
+ return;
+ }
+ bool flag = ApolicesAdicionadas.Any((ProtocoloEtiqueta x) => ((DomainBase)x.Documento.Controle.Cliente).Id == ((DomainBase)SelectedCliente).Id && (int)x.Tipo == 1);
+ if (flag)
+ {
+ flag = !(await ShowMessage("JÁ EXISTE UMA ETIQUETA ADICIONADA PARA O CLIENTE SELECIONADO, DESEJA ADICIONAR NOVAMENTE?", "SIM", "NÃO"));
+ }
+ if (!flag)
+ {
+ ApolicesAdicionadas.Add(new ProtocoloEtiqueta
+ {
+ Documento = new Documento
+ {
+ Controle = new Controle
+ {
+ Cliente = SelectedCliente
+ }
+ },
+ Tipo = (TipoProtocoloEtiqueta)1
+ });
+ ApolicesAdicionadas = new ObservableCollection<ProtocoloEtiqueta>(from x in ApolicesAdicionadas
+ orderby x.Tipo, ((DomainBase)x.Documento.Controle.Cliente).Id
+ select x);
+ }
+ }
+
+ public async void AdicionarEtiquetaCorretora()
+ {
+ ClienteEndereco item = new ClienteEndereco
+ {
+ Endereco = ((EnderecoBase)Recursos.Empresa).Endereco,
+ Bairro = ((EnderecoBase)Recursos.Empresa).Bairro,
+ Numero = ((EnderecoBase)Recursos.Empresa).Numero,
+ Complemento = ((EnderecoBase)Recursos.Empresa).Complemento,
+ Cidade = ((EnderecoBase)Recursos.Empresa).Cidade,
+ Estado = ((EnderecoBase)Recursos.Empresa).Estado,
+ Cep = ((EnderecoBase)Recursos.Empresa).Cep
+ };
+ ObservableCollection<ClienteEndereco> observableCollection = new ObservableCollection<ClienteEndereco>();
+ observableCollection.Add(item);
+ ApolicesAdicionadas.Add(new ProtocoloEtiqueta
+ {
+ Documento = new Documento
+ {
+ Controle = new Controle
+ {
+ Cliente = new Cliente
+ {
+ Nome = Recursos.Empresa.Nome,
+ Id = -1L,
+ Enderecos = observableCollection
+ }
+ }
+ },
+ Tipo = (TipoProtocoloEtiqueta)1
+ });
+ ApolicesAdicionadas = new ObservableCollection<ProtocoloEtiqueta>(from x in ApolicesAdicionadas
+ orderby x.Tipo, ((DomainBase)x.Documento.Controle.Cliente).Id
+ select x);
+ }
+
+ public void Remover(ProtocoloEtiqueta documento)
+ {
+ ApolicesAdicionadas.Remove(documento);
+ SelecionarDocumentos();
+ }
+
+ public async void Imprimir(TipoProtocoloEtiqueta 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)
+ if (ApolicesAdicionadas.Count == 0)
+ {
+ await ShowMessage("NECESSÁRIO ADICIONAR DOCUMENTOS PARA EMISSÃO DE " + Functions.GetDescription((Enum)(object)tipo));
+ }
+ else if ((int)tipo != 0)
+ {
+ if ((int)tipo != 1)
+ {
+ return;
+ }
+ if (ApolicesAdicionadas.All((ProtocoloEtiqueta x) => (int)x.Tipo != 1))
+ {
+ await ShowMessage("NECESSÁRIO ADICIONAR DOCUMENTOS PARA EMISSÃO DE " + Functions.GetDescription((Enum)(object)tipo));
+ return;
+ }
+ if (ApolicesAdicionadas.Any((ProtocoloEtiqueta x) => (int)x.Tipo == 1 && ((DomainBase)x.Documento).Id == 0))
+ {
+ if (ApolicesAdicionadas.Any((ProtocoloEtiqueta x) => (int)x.Tipo == 1 && ((DomainBase)x.Documento).Id != 0))
+ {
+ await ShowMessage("COMO EXISTEM ETIQUETAS DE CLIENTES E DOCUMENTOS,\nPRIMEIRO CONFIGURE AS DE SOMENTE CLIENTE.\nDEPOIS DE GERAR AS ETIQUETAS DE CLIENTE, CONFIGURAR AS DE DOCUMENTOS");
+ }
+ ((Window)new HosterWindow((ContentControl)(object)new EtiquetaView((from x in ApolicesAdicionadas
+ where (int)x.Tipo == 1 && ((DomainBase)x.Documento).Id == 0
+ select x.Documento).ToList(), apenasCliente: true), "ETIQUETAS", 900.0, 600.0)).Show();
+ }
+ if (ApolicesAdicionadas.Any((ProtocoloEtiqueta x) => (int)x.Tipo == 1 && ((DomainBase)x.Documento).Id != 0))
+ {
+ ((Window)new HosterWindow((ContentControl)(object)new EtiquetaView((from x in ApolicesAdicionadas
+ where (int)x.Tipo == 1 && ((DomainBase)x.Documento).Id != 0
+ select x.Documento).ToList(), apenasCliente: false), "ETIQUETAS", 900.0, 600.0)).Show();
+ }
+ }
+ else if (ApolicesAdicionadas.All((ProtocoloEtiqueta x) => (int)x.Tipo > 0))
+ {
+ await ShowMessage("NECESSÁRIO ADICIONAR DOCUMENTOS PARA EMISSÃO DE " + Functions.GetDescription((Enum)(object)tipo));
+ }
+ else if (ApolicesAdicionadas.Any((ProtocoloEtiqueta x) => (int)x.Tipo == 0))
+ {
+ List<Documento> lista = await ShowProtocoloDialog((from x in ApolicesAdicionadas
+ where (int)x.Tipo == 0
+ select x.Documento).ToList());
+ if (lista != null)
+ {
+ PrepararProtocolo(lista, await ShowMessage("DESEJA EMITIR DOIS PROTOCOLOS POR PÁGINA?" + Environment.NewLine + "A QUANTIDADE DE INFORMÃÇÕES PODE IMPEDIR QUE ESSA FUNÇÃO FUNCIONE CORRETAMENTE", "SIM", "NÃO"));
+ }
+ }
+ }
+
+ public async void PrepararProtocolo(List<Documento> documentos, bool doisPorPagina)
+ {
+ if (await ShowMessage("DESEJA EMITIR O CHECKLIST?", "SIM", "NÃO"))
+ {
+ await EmitirCheckList(documentos);
+ }
+ if (documentos != null)
+ {
+ List<Tuple<long, string>> lista = documentos.Select((Documento x) => new Tuple<long, string>(((DomainBase)x).Id, x.ObsProtocolo)).ToList();
+ await EmitirProtocolos(lista, doisPorPagina, documentos);
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/ProtocoloEtiqueta.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ProtocoloEtiqueta.cs
new file mode 100644
index 0000000..81c1f67
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ProtocoloEtiqueta.cs
@@ -0,0 +1,11 @@
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class ProtocoloEtiqueta
+{
+ public TipoProtocoloEtiqueta Tipo { get; set; }
+
+ public Documento Documento { get; set; }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/QualificacaoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/QualificacaoViewModel.cs
new file mode 100644
index 0000000..5e79531
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/QualificacaoViewModel.cs
@@ -0,0 +1,122 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class QualificacaoViewModel : BaseSegurosViewModel
+{
+ private readonly QualificacaoServico _servico;
+
+ private Qualificacao _selectedQualificacao;
+
+ public Qualificacao CancelQualificacao;
+
+ public Qualificacao SelectedQualificacao
+ {
+ get
+ {
+ return _selectedQualificacao;
+ }
+ set
+ {
+ //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_001e: 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_003e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0065: 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_0082: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0092: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009c: Expected O, but got Unknown
+ if (value == null || ((DomainBase)value).Id == 0L)
+ {
+ value = new Qualificacao
+ {
+ Liquido1 = 0m,
+ Liquido2 = 1000m,
+ Liquido3 = 5000m,
+ Comissao1 = 10m,
+ Comissao2 = 15m,
+ Comissao3 = 20m,
+ Resultado1 = 100m,
+ Resultado2 = 200m,
+ Resultado3 = 300m,
+ Id = 1L
+ };
+ }
+ _selectedQualificacao = value;
+ VerificarEnables(((DomainBase)value).Id);
+ OnPropertyChanged("SelectedQualificacao");
+ }
+ }
+
+ public QualificacaoViewModel()
+ {
+ _servico = new QualificacaoServico();
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)48);
+ await SelecionaQualificacao();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaQualificacao()
+ {
+ Loading(isLoading: true);
+ SelectedQualificacao = await _servico.BuscarQualificacaoAsync();
+ RegistrarAcao("ACESSOU QUALIFICAÇÃO", 0L, (TipoTela)48);
+ Loading(isLoading: false);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ if (((DomainBase)(await _servico.BuscarQualificacaoAsync())).Id == 0L)
+ {
+ ((DomainBase)SelectedQualificacao).Id = 0L;
+ }
+ List<KeyValuePair<string, string>> list = SelectedQualificacao.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ SelectedQualificacao = await _servico.Save(SelectedQualificacao);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao("ALTEROU QUALIFICAÇÃO", 0L, (TipoTela)48);
+ Alterar(alterar: false);
+ ToggleSnackBar("QUALIFICACAO SALVA COM SUCESSO");
+ return null;
+ }
+
+ public void CancelarAlteracao()
+ {
+ Loading(isLoading: true);
+ if (((DomainBase)SelectedQualificacao).Id == 0L)
+ {
+ SelectedQualificacao = null;
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ Loading(isLoading: false);
+ }
+ else
+ {
+ SelectedQualificacao = CancelQualificacao;
+ }
+ Alterar(alterar: false);
+ Loading(isLoading: false);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/RamoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/RamoViewModel.cs
new file mode 100644
index 0000000..131f914
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/RamoViewModel.cs
@@ -0,0 +1,284 @@
+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.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class RamoViewModel : BaseSegurosViewModel
+{
+ private readonly RamoServico _servico;
+
+ private Ramo _selectedRamo = new Ramo();
+
+ private decimal _iof;
+
+ private ObservableCollection<Ramo> _ramosFiltrados = new ObservableCollection<Ramo>();
+
+ private bool _isExpanded;
+
+ private List<CoberturaPadrao> _coberturas = new List<CoberturaPadrao>();
+
+ private ObservableCollection<CoberturaPadrao> _coberturasFiltradas = new ObservableCollection<CoberturaPadrao>();
+
+ public Ramo CancelRamo;
+
+ public Ramo SelectedRamo
+ {
+ get
+ {
+ return _selectedRamo;
+ }
+ set
+ {
+ _selectedRamo = value;
+ WorkOnSelectedRamo(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedRamo");
+ }
+ }
+
+ public decimal Iof
+ {
+ get
+ {
+ return _iof;
+ }
+ set
+ {
+ _iof = value;
+ OnPropertyChanged("Iof");
+ }
+ }
+
+ public List<Ramo> Ramos { get; set; }
+
+ public ObservableCollection<Ramo> RamosFiltrados
+ {
+ get
+ {
+ return _ramosFiltrados;
+ }
+ set
+ {
+ _ramosFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("RamosFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public List<CoberturaPadrao> Coberturas
+ {
+ get
+ {
+ return _coberturas;
+ }
+ set
+ {
+ _coberturas = value;
+ OnPropertyChanged("Coberturas");
+ }
+ }
+
+ public ObservableCollection<CoberturaPadrao> CoberturasFiltradas
+ {
+ get
+ {
+ return _coberturasFiltradas;
+ }
+ set
+ {
+ _coberturasFiltradas = value;
+ OnPropertyChanged("CoberturasFiltradas");
+ }
+ }
+
+ public RamoViewModel()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000b: Expected O, but got Unknown
+ _servico = new RamoServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ public async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)12);
+ await SelecionaRamos();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaRamos(Ramo ramo = null)
+ {
+ Loading(isLoading: true);
+ await SelecionaCoberturas();
+ List<Ramo> list = await new BaseServico().BuscarRamosAsync();
+ Ramos = (from x in list
+ orderby x.Ativo descending, x.Nome
+ select x).ToList();
+ RamosFiltrados = new ObservableCollection<Ramo>(Ramos);
+ SelectedRamo = (Ramo)((ramo == null) ? ((object)RamosFiltrados.First()) : ((object)((IEnumerable<Ramo>)RamosFiltrados).FirstOrDefault((Func<Ramo, bool>)((Ramo x) => ((DomainBase)x).Id == ((DomainBase)ramo).Id))));
+ Recursos.Ramos = list;
+ Loading(isLoading: false);
+ }
+
+ private static async Task SelecionaCoberturas()
+ {
+ Recursos.Coberturas = await new BaseServico().BuscaCoberturas();
+ }
+
+ private void WorkOnSelectedRamo(Ramo value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Invalid comparison between Unknown and I4
+ //IL_0170: Unknown result type (might be due to invalid IL or missing references)
+ CancelRamo = (Ramo)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelRamo) : ((object)(Ramo)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 12))
+ {
+ return;
+ }
+ Coberturas = (from x in Recursos.Coberturas
+ where x.IdRamo == ((DomainBase)value).Id
+ orderby x.Padrao descending, x.Descricao
+ select x).ToList();
+ CoberturasFiltradas = new ObservableCollection<CoberturaPadrao>(Coberturas);
+ Iof = value.Iof * 0.01m;
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU RAMO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)12, $"ID RAMO: {((DomainBase)value).Id}");
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)12;
+ Ramo selectedRamo = SelectedRamo;
+ if (((selectedRamo != null) ? new long?(((DomainBase)selectedRamo).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedRamo = ((IEnumerable<Ramo>)RamosFiltrados).FirstOrDefault((Func<Ramo, bool>)((Ramo x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ SelectedRamo.Iof = Iof;
+ List<KeyValuePair<string, string>> list = SelectedRamo.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ Ramo selectedRamo = SelectedRamo;
+ selectedRamo.Iof *= 100m;
+ string acao = ((((DomainBase)SelectedRamo).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Ramo value = await _servico.Save(SelectedRamo, Coberturas);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " RAMO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)12, $"RAMO \"{value.Nome}\", ID: {((DomainBase)value).Id}");
+ if (Ramos.Any((Ramo x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Ramo, Ramo>(Ramos.First((Ramo x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ Ramos.Add(value);
+ }
+ if (RamosFiltrados.Any((Ramo x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Ramo, Ramo>(RamosFiltrados.First((Ramo x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ RamosFiltrados.Add(value);
+ }
+ RamosFiltrados = new ObservableCollection<Ramo>(RamosFiltrados);
+ Recursos.Ramos = Ramos;
+ await SelecionaCoberturas();
+ WorkOnSelectedRamo(value, registrar: false);
+ Alterar(alterar: false);
+ ToggleSnackBar("RAMO SALVO COM SUCESSO");
+ return null;
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelRamo != null && Ramos.Any((Ramo x) => ((DomainBase)x).Id == ((DomainBase)CancelRamo).Id))
+ {
+ DomainBase.Copy<Ramo, Ramo>(Ramos.First((Ramo x) => ((DomainBase)x).Id == ((DomainBase)CancelRamo).Id), CancelRamo);
+ if (RamosFiltrados.Count > 0 && RamosFiltrados.Any((Ramo x) => ((DomainBase)x).Id == ((DomainBase)CancelRamo).Id))
+ {
+ DomainBase.Copy<Ramo, Ramo>(RamosFiltrados.First((Ramo x) => ((DomainBase)x).Id == ((DomainBase)CancelRamo).Id), CancelRamo);
+ }
+ else
+ {
+ RamosFiltrados.Add(CancelRamo);
+ }
+ RamosFiltrados = new ObservableCollection<Ramo>(RamosFiltrados);
+ SelectedRamo = RamosFiltrados.First((Ramo x) => ((DomainBase)x).Id == ((DomainBase)CancelRamo).Id);
+ }
+ Alterar(alterar: false);
+ }
+
+ internal async Task<List<Ramo>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarRamo(value));
+ }
+
+ public List<Ramo> FiltrarRamo(string filter)
+ {
+ RamosFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Ramo>(Ramos) : new ObservableCollection<Ramo>(from x in Ramos
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ativo descending, x.Nome
+ select x));
+ return RamosFiltrados.ToList();
+ }
+
+ internal async Task<List<CoberturaPadrao>> FiltrarCobertura(string value)
+ {
+ return await Task.Run(() => FiltrarCoberturaRamo(value));
+ }
+
+ public List<CoberturaPadrao> FiltrarCoberturaRamo(string filter)
+ {
+ CoberturasFiltradas = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<CoberturaPadrao>(Coberturas) : new ObservableCollection<CoberturaPadrao>(Coberturas.Where((CoberturaPadrao x) => ValidationHelper.RemoveDiacritics(x.Descricao.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)))));
+ return CoberturasFiltradas.ToList();
+ }
+
+ public void SelecionaRamo(Ramo ramo)
+ {
+ SelectedRamo = ramo;
+ }
+
+ public async void Incluir(Ramo ramo)
+ {
+ ramo.Ativo = true;
+ await _servico.Insert(ramo);
+ if (_servico.Sucesso)
+ {
+ await SelecionaRamos(ramo);
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/ReciboViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ReciboViewModel.cs
new file mode 100644
index 0000000..81e4e8f
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/ReciboViewModel.cs
@@ -0,0 +1,537 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Drawing;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.ViewModels.Generic;
+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.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class ReciboViewModel : BaseSegurosViewModel
+{
+ private readonly ReciboServico _servico;
+
+ public Recibo CancelRecibo;
+
+ private Recibo _selectedRecibo = new Recibo();
+
+ private DateTime? _horaRecibo;
+
+ private ObservableCollection<Recibo> _recibosFiltrados = new ObservableCollection<Recibo>();
+
+ private bool _isExpanded;
+
+ private Cliente _pagante;
+
+ private Cliente _recebedor;
+
+ public List<Recibo> Recibos { get; set; }
+
+ public Recibo SelectedRecibo
+ {
+ get
+ {
+ return _selectedRecibo;
+ }
+ set
+ {
+ _selectedRecibo = value;
+ WorkOnSelectedRecibo(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ if (!value.DataRecibo.HasValue)
+ {
+ value.DataRecibo = DateTime.Now;
+ }
+ if (value != null)
+ {
+ HoraRecibo = value.DataRecibo;
+ }
+ OnPropertyChanged("SelectedRecibo");
+ }
+ }
+
+ public DateTime? HoraRecibo
+ {
+ get
+ {
+ return _horaRecibo;
+ }
+ set
+ {
+ _horaRecibo = value;
+ if (value.HasValue)
+ {
+ SelectedRecibo.DataRecibo = (SelectedRecibo.DataRecibo.HasValue ? new DateTime?(DateTime.Parse($"{SelectedRecibo.DataRecibo.Value:d} {value:T}")) : null);
+ OnPropertyChanged("HoraRecibo");
+ }
+ }
+ }
+
+ public ObservableCollection<Recibo> RecibosFiltrados
+ {
+ get
+ {
+ return _recibosFiltrados;
+ }
+ set
+ {
+ _recibosFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("RecibosFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public Cliente Pagante
+ {
+ get
+ {
+ return _pagante;
+ }
+ set
+ {
+ _pagante = value;
+ WorkOnSelectedPagante(value);
+ OnPropertyChanged("Pagante");
+ }
+ }
+
+ public Cliente Recebedor
+ {
+ get
+ {
+ return _recebedor;
+ }
+ set
+ {
+ _recebedor = value;
+ WorkOnSelectedRecebedor(value);
+ OnPropertyChanged("Recebedor");
+ }
+ }
+
+ public ReciboViewModel()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000b: Expected O, but got Unknown
+ _servico = new ReciboServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private void WorkOnSelectedPagante(Cliente value)
+ {
+ if (value != null)
+ {
+ SelectedRecibo.Pagante = Regex.Replace(value.NomeSocial, "\\-\\s\\d.*", "").Trim();
+ SelectedRecibo.DocumentoPagante = value.Documento;
+ SelectedRecibo = SelectedRecibo;
+ }
+ }
+
+ private void WorkOnSelectedRecebedor(Cliente value)
+ {
+ if (value != null)
+ {
+ SelectedRecibo.Recebedor = Regex.Replace(value.NomeSocial, "\\-\\s\\d.*", "").Trim();
+ SelectedRecibo.DocumentoRecebedor = value.Documento;
+ SelectedRecibo = SelectedRecibo;
+ }
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)42);
+ await SelecionaRecibo();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaRecibo()
+ {
+ Loading(isLoading: true);
+ Recibos = (await _servico.BuscarRecibos()).ToList();
+ RecibosFiltrados = new ObservableCollection<Recibo>(Recibos);
+ if (RecibosFiltrados.Count > 0)
+ {
+ SelectedRecibo = RecibosFiltrados.First();
+ }
+ else
+ {
+ SelectedRecibo = new Recibo();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Loading(isLoading: false);
+ }
+
+ public void Incluir()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000b: Expected O, but got Unknown
+ SelectedRecibo = new Recibo();
+ Alterar(alterar: true);
+ }
+
+ internal async Task<List<Recibo>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarRecibo(value));
+ }
+
+ public List<Recibo> FiltrarRecibo(string filter)
+ {
+ RecibosFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Recibo>(Recibos) : new ObservableCollection<Recibo>(Recibos.Where((Recibo x) => ValidationHelper.RemoveDiacritics(x.Pagante.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) || ValidationHelper.RemoveDiacritics(x.Recebedor).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)))));
+ return RecibosFiltrados.ToList();
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedRecibo.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ string acao = ((((DomainBase)SelectedRecibo).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Recibo value = await _servico.Save(SelectedRecibo);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ ReciboViewModel reciboViewModel = this;
+ string descricao = $"{acao} RECIBO DE NÚMERO \"{((DomainBase)value).Id}\"";
+ long id = ((DomainBase)value).Id;
+ TipoTela? tela = (TipoTela)42;
+ object[] obj = new object[9]
+ {
+ value.Tipo.HasValue ? (ValidationHelper.GetDescription((Enum)(object)value.Tipo.Value) ?? "") : "-",
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ };
+ TipoPagamento? pagamento = value.Pagamento;
+ obj[1] = (pagamento.HasValue ? ValidationHelper.GetDescription((Enum)(object)pagamento.GetValueOrDefault()) : null);
+ obj[2] = value.Valor;
+ obj[3] = value.DataRecibo;
+ obj[4] = value.Pagante;
+ obj[5] = value.DocumentoPagante;
+ obj[6] = value.Recebedor;
+ obj[7] = value.DocumentoRecebedor;
+ obj[8] = value.Referente;
+ reciboViewModel.RegistrarAcao(descricao, id, tela, string.Format("TIPO: {0}\nPAGAMENTO: {1}\nVALOR: {2:c}\nDATA RECIBO: {3:G}\nPAGANTE: {4}, {5}\nRECEBEDOR: {6}, {7}\nREFERENTE: \"{8}\"", obj));
+ if (Recibos.Any((Recibo x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Recibo, Recibo>(Recibos.First((Recibo x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ Recibos.Add(value);
+ }
+ if (RecibosFiltrados.Any((Recibo x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Recibo, Recibo>(RecibosFiltrados.First((Recibo x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ RecibosFiltrados.Add(value);
+ }
+ RecibosFiltrados = new ObservableCollection<Recibo>(RecibosFiltrados);
+ WorkOnSelectedRecibo(value, registrar: false);
+ Alterar(alterar: false);
+ ToggleSnackBar("RECIBO SALVO COM SUCESSO");
+ return null;
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedRecibo != null && ((DomainBase)SelectedRecibo).Id != 0L && await ShowMessage("DESEJA REALMENTE EXCLUIR O RECIBO PERMANENTEMENTE?", "SIM", "NÃO"))
+ {
+ Loading(isLoading: true);
+ if (!(await _servico.Delete(SelectedRecibo)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ ReciboViewModel reciboViewModel = this;
+ string descricao = $"EXCLUIU RECIBO DE NÚMERO \"{((DomainBase)SelectedRecibo).Id}\"";
+ long id = ((DomainBase)SelectedRecibo).Id;
+ TipoTela? tela = (TipoTela)42;
+ object[] obj = new object[9]
+ {
+ SelectedRecibo.Tipo.HasValue ? (ValidationHelper.GetDescription((Enum)(object)SelectedRecibo.Tipo.Value) ?? "") : "-",
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ };
+ TipoPagamento? pagamento = SelectedRecibo.Pagamento;
+ obj[1] = (pagamento.HasValue ? ValidationHelper.GetDescription((Enum)(object)pagamento.GetValueOrDefault()) : null);
+ obj[2] = SelectedRecibo.Valor;
+ obj[3] = SelectedRecibo.DataRecibo;
+ obj[4] = SelectedRecibo.Pagante;
+ obj[5] = SelectedRecibo.DocumentoPagante;
+ obj[6] = SelectedRecibo.Recebedor;
+ obj[7] = SelectedRecibo.DocumentoRecebedor;
+ obj[8] = SelectedRecibo.Referente;
+ reciboViewModel.RegistrarAcao(descricao, id, tela, string.Format("TIPO: {0}\nPAGAMENTO: {1}\nVALOR: {2:c}\nDATA RECIBO: {3:G}\nPAGANTE: {4}, {5}\nRECEBEDOR: {6}, {7}\nREFERENTE: \"{8}\"", obj));
+ await SelecionaRecibo();
+ Loading(isLoading: false);
+ ToggleSnackBar("RECIBO EXCLUÍDO COM SUCESSO");
+ }
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelRecibo != null && Recibos.Any((Recibo x) => ((DomainBase)x).Id == ((DomainBase)CancelRecibo).Id))
+ {
+ DomainBase.Copy<Recibo, Recibo>(Recibos.First((Recibo x) => ((DomainBase)x).Id == ((DomainBase)CancelRecibo).Id), CancelRecibo);
+ if (RecibosFiltrados.Count > 0 && RecibosFiltrados.Any((Recibo x) => ((DomainBase)x).Id == ((DomainBase)CancelRecibo).Id))
+ {
+ DomainBase.Copy<Recibo, Recibo>(RecibosFiltrados.First((Recibo x) => ((DomainBase)x).Id == ((DomainBase)CancelRecibo).Id), CancelRecibo);
+ }
+ else
+ {
+ RecibosFiltrados.Add(CancelRecibo);
+ }
+ RecibosFiltrados = new ObservableCollection<Recibo>(RecibosFiltrados);
+ SelectedRecibo = RecibosFiltrados.First((Recibo x) => ((DomainBase)x).Id == ((DomainBase)CancelRecibo).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ private bool IsImage(string extensao)
+ {
+ if (extensao == null)
+ {
+ return false;
+ }
+ if (extensao.ToLower().Contains("jpg"))
+ {
+ return true;
+ }
+ if (extensao.ToLower().Contains("jpeg"))
+ {
+ return true;
+ }
+ if (extensao.ToLower().Contains("png"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public async void Print()
+ {
+ Recibo selectedRecibo = SelectedRecibo;
+ if (((selectedRecibo != null) ? selectedRecibo.Referente : null) == null || SelectedRecibo.Recebedor == null)
+ {
+ return;
+ }
+ ArquivoDigital arquivo = null;
+ List<IndiceArquivoDigital> list = await ArquivoDigitalServico.BuscarPorTipo((TipoArquivoDigital)13, ((DomainBase)Recursos.Empresa).Id);
+ if (list != null && list.Any((IndiceArquivoDigital x) => x.Descricao == "LOGO"))
+ {
+ IndiceArquivoDigital? obj = ((IEnumerable<IndiceArquivoDigital>)list).FirstOrDefault((Func<IndiceArquivoDigital, bool>)((IndiceArquivoDigital x) => x.Descricao == "LOGO"));
+ long? num = ((obj != null) ? new long?(obj.IdArquivoDigital) : null);
+ IndiceArquivoDigital? obj2 = ((IEnumerable<IndiceArquivoDigital>)list).FirstOrDefault((Func<IndiceArquivoDigital, bool>)((IndiceArquivoDigital x) => x.Descricao == "LOGO"));
+ string banco = ((obj2 != null) ? obj2.Bd : null);
+ if (num.HasValue)
+ {
+ arquivo = await ArquivoDigitalServico.BuscarPorId(num.Value, banco);
+ }
+ }
+ ArquivoDigital obj3 = arquivo;
+ byte[] array = ((obj3 != null) ? obj3.Arquivo : null);
+ string image = "";
+ if (array != null && array.Length != 0)
+ {
+ ReciboViewModel reciboViewModel = this;
+ ArquivoDigital obj4 = arquivo;
+ if (reciboViewModel.IsImage((obj4 != null) ? obj4.Extensao : null))
+ {
+ ArquivoDigital obj5 = arquivo;
+ image = GetImage(array, (obj5 != null) ? obj5.Extensao : null);
+ }
+ }
+ string longDatePattern = new CultureInfo("pt-PT", useUserOverride: false).DateTimeFormat.LongDatePattern;
+ string data = SelectedRecibo.DataRecibo?.ToString(longDatePattern, new CultureInfo("pt-PT"));
+ int vias = ((!(await ShowMessage("DESEJA IMPRIMIR DUAS VIAS DO RECIBO?", "SIM", "NÃO"))) ? 1 : 2);
+ bool flag = !string.IsNullOrEmpty(image);
+ if (flag)
+ {
+ flag = await ShowMessage("DESEJA IMPRIMIR O LOGO DA CORRETORA NO RECIBO?\nPARA ADICIONAR UM LOGO, É NECESSÁRIO COLOCÁ-LO NO ARQUIVO\nDIGITAL NA TELA DE EMPRESA E FILIAIS COM DESCRIÇÃO \"LOGO\"", "SIM", "NÃO");
+ }
+ bool flag2 = flag;
+ string text = "<html><head><style type='text/css'>@page{size: A4; margin: 0cm}</style><title>RECIBO</title><link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css' integrity='sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh' crossorigin='anonymous'></head><body>";
+ for (int i = 0; i < vias; i++)
+ {
+ if (flag2)
+ {
+ text = text + "<div>" + image + "</div>";
+ text += "<div style='margin: 0px 100px 0px 100px; font-size: 20px;'>";
+ }
+ else
+ {
+ text += "<div style='margin: 50px 100px 50px 100px; font-size: 20px;'>";
+ }
+ text += $"<div style='text-align: right'><strong>N° {((DomainBase)SelectedRecibo).Id}</strong></div><br>";
+ text += "<strong>R E C I B O</strong><br><br>";
+ if ((int)SelectedRecibo.Tipo.GetValueOrDefault() == 1)
+ {
+ string text2 = ((SelectedRecibo.DocumentoRecebedor == null || SelectedRecibo.DocumentoRecebedor.Clear().Length < 12) ? "EU" : "A");
+ string text3 = ((SelectedRecibo.DocumentoRecebedor == null || SelectedRecibo.DocumentoRecebedor.Clear().Length < 12) ? "CPF" : "CNPJ");
+ string text4 = ((text2 == "EU") ? "O" : "A");
+ string text5 = ((text2 == "EU") ? "RECEBI" : "RECEBEU");
+ text += $"PELO PRESENTE, {text2}, <strong>{SelectedRecibo.Recebedor}</strong>, INSCRIT{text4} NO {text3} SOB Nº <strong>{SelectedRecibo.DocumentoRecebedor}</strong>, DECLAR{text4} QUE {text5}, NA DATA DE HOJE, <strong>{SelectedRecibo.DataRecibo:dd/MM/yyyy HH:mm}</strong>, O VALOR DE <strong>R$ {SelectedRecibo.Valor:0.00}</strong> POR MEIO DE <strong>{ValidationHelper.GetDescription((Enum)(object)SelectedRecibo.Pagamento)}</strong>, DE <strong>{SelectedRecibo.Pagante}</strong>, INSCRITO NO CPF/CNPJ SOB Nº <strong>{SelectedRecibo.DocumentoPagante}</strong>, REFERENTE À(AO) <strong>{SelectedRecibo.Referente.ToUpper()}</strong>. DANDO-LHE POR ESTE RECIBO A DEVIDA QUITAÇÃO.<br>";
+ text = text + "<strong>" + ((EnderecoBase)Recursos.Empresa).Cidade + ", " + data?.ToUpper() + ".</strong><br><br>";
+ text = text + "_________________________________<br><strong>ASSINATURA </strong>" + SelectedRecibo.Recebedor + "<br>" + SelectedRecibo.DocumentoRecebedor;
+ }
+ else
+ {
+ string text6 = ((SelectedRecibo.DocumentoPagante == null || SelectedRecibo.DocumentoPagante.Clear().Length < 12) ? "EU" : "A");
+ string text7 = ((SelectedRecibo.DocumentoPagante == null || SelectedRecibo.DocumentoPagante.Clear().Length < 12) ? "CPF" : "CNPJ");
+ string text8 = ((text6 == "EU") ? "O" : "A");
+ string text9 = ((text6 == "EU") ? "PAGUEI" : "PAGOU");
+ text += $"PELO PRESENTE, {text6}, <strong>{SelectedRecibo.Pagante}</strong>, INSCRIT{text8} NO {text7} SOB Nº <strong>{SelectedRecibo.DocumentoPagante}</strong>, DECLAR{text8} QUE {text9}, NA DATA DE HOJE, <strong>{SelectedRecibo.DataRecibo:dd/MM/yyyy HH:mm}</strong>, O VALOR DE <strong>R$ {SelectedRecibo.Valor:0.00}</strong> POR MEIO DE <strong>{ValidationHelper.GetDescription((Enum)(object)SelectedRecibo.Pagamento)}</strong>, PARA <strong>{SelectedRecibo.Recebedor}</strong>, INSCRITO NO CPF/CNPJ SOB Nº <strong>{SelectedRecibo.DocumentoRecebedor}</strong>, REFERENTE À(AO) <strong>{SelectedRecibo.Referente.ToUpper()}</strong>. DANDO-LHE POR ESTE RECIBO A DEVIDA QUITAÇÃO.<br>";
+ text = text + "<br><strong>" + ((EnderecoBase)Recursos.Empresa).Cidade + ", " + data?.ToUpper() + ".</strong><br><br>";
+ text = text + "_________________________________<br><strong>ASSINATURA </strong>" + SelectedRecibo.Recebedor + "<br>" + SelectedRecibo.DocumentoRecebedor;
+ }
+ text += "<hr /></div>";
+ }
+ text += "<script src='https://code.jquery.com/jquery-3.4.1.slim.min.js' integrity='sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n' crossorigin='anonymous'></script> <script src = 'https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js' integrity = 'sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo' crossorigin = 'anonymous' ></script><script src = 'https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js' integrity = 'sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6' crossorigin = 'anonymous' ></script> </body></html>";
+ string tempPath = Path.GetTempPath();
+ string text10 = $"{tempPath}_{Funcoes.GetNetworkTime():ddMMyyyyhhmmss}.html";
+ StreamWriter streamWriter = new StreamWriter(text10, append: true, Encoding.UTF8);
+ streamWriter.Write(text);
+ streamWriter.Close();
+ Process.Start(text10);
+ ReciboViewModel reciboViewModel2 = this;
+ string descricao = $"IMPRIMIU O RECIBO DE NÚMERO \"{((DomainBase)SelectedRecibo).Id}\"";
+ long id = ((DomainBase)SelectedRecibo).Id;
+ TipoTela? tela = (TipoTela)42;
+ object[] obj6 = new object[9]
+ {
+ SelectedRecibo.Tipo.HasValue ? (ValidationHelper.GetDescription((Enum)(object)SelectedRecibo.Tipo.Value) ?? "") : "-",
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ };
+ TipoPagamento? pagamento = SelectedRecibo.Pagamento;
+ obj6[1] = (pagamento.HasValue ? ValidationHelper.GetDescription((Enum)(object)pagamento.GetValueOrDefault()) : null);
+ obj6[2] = SelectedRecibo.Valor;
+ obj6[3] = SelectedRecibo.DataRecibo;
+ obj6[4] = SelectedRecibo.Pagante;
+ obj6[5] = SelectedRecibo.DocumentoPagante;
+ obj6[6] = SelectedRecibo.Recebedor;
+ obj6[7] = SelectedRecibo.DocumentoRecebedor;
+ obj6[8] = SelectedRecibo.Referente;
+ reciboViewModel2.RegistrarAcao(descricao, id, tela, string.Format("TIPO: {0}\nPAGAMENTO: {1}\nVALOR: {2:c}\nDATA RECIBO: {3:G}\nPAGANTE: {4}, {5}\nRECEBEDOR: {6}, {7}\nREFERENTE: \"{8}\"", obj6));
+ }
+
+ private static string GetImage(byte[] bytes, string extensao)
+ {
+ try
+ {
+ Image val = Image.FromStream((Stream)new MemoryStream(bytes));
+ string text = (extensao.ToUpper().Contains("JPG") ? ("data:image/jpeg;base64," + Convert.ToBase64String(bytes, Base64FormattingOptions.None)) : ("data:image/png;base64," + Convert.ToBase64String(bytes, Base64FormattingOptions.None)));
+ return "<img style=\"WIDTH=" + val.Width + "; HEIGHT=" + val.Height + "; max-height: 250px; max-width: 250px; margin-bottom: 0px; margin-left: 100px; margin-top: 0px;\" src=\"" + text + "\"/>";
+ }
+ catch (Exception)
+ {
+ return "";
+ }
+ }
+
+ private void WorkOnSelectedRecibo(Recibo value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Invalid comparison between Unknown and I4
+ //IL_01ad: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00de: 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)
+ CancelRecibo = (Recibo)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelRecibo) : ((object)(Recibo)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 42))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ string descricao = $"ACESSOU RECIBO DE NÚMERO \"{((DomainBase)value).Id}\"";
+ long id = ((DomainBase)value).Id;
+ TipoTela? tela = (TipoTela)42;
+ object[] obj = new object[9]
+ {
+ value.Tipo.HasValue ? (ValidationHelper.GetDescription((Enum)(object)value.Tipo.Value) ?? "") : "-",
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ };
+ TipoPagamento? pagamento = value.Pagamento;
+ obj[1] = (pagamento.HasValue ? ValidationHelper.GetDescription((Enum)(object)pagamento.GetValueOrDefault()) : null);
+ obj[2] = value.Valor;
+ obj[3] = value.DataRecibo;
+ obj[4] = value.Pagante;
+ obj[5] = value.DocumentoPagante;
+ obj[6] = value.Recebedor;
+ obj[7] = value.DocumentoRecebedor;
+ obj[8] = value.Referente;
+ RegistrarAcao(descricao, id, tela, string.Format("TIPO: {0}\nPAGAMENTO: {1}\nVALOR: {2:c}\nDATA RECIBO: {3:G}\nPAGANTE: {4}, {5}\nRECEBEDOR: {6}, {7}\nREFERENTE: \"{8}\"", obj));
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)42;
+ Recibo selectedRecibo = SelectedRecibo;
+ if (((selectedRecibo != null) ? new long?(((DomainBase)selectedRecibo).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedRecibo = ((IEnumerable<Recibo>)RecibosFiltrados).FirstOrDefault((Func<Recibo, bool>)((Recibo x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/SeguradoraViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/SeguradoraViewModel.cs
new file mode 100644
index 0000000..bae9af6
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/SeguradoraViewModel.cs
@@ -0,0 +1,535 @@
+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.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class SeguradoraViewModel : BaseSegurosViewModel
+{
+ private readonly SeguradoraServico _servico;
+
+ private bool _apelido;
+
+ private Seguradora _selectedSeguradora;
+
+ private SeguradoraEndereco _selectedEndereco = new SeguradoraEndereco();
+
+ private ObservableCollection<SeguradoraContato> _contatos = new ObservableCollection<SeguradoraContato>();
+
+ private ObservableCollection<SeguradoraEndereco> _enderecos = new ObservableCollection<SeguradoraEndereco>();
+
+ private SeguradoraContato _selectedTelefone = new SeguradoraContato();
+
+ private Visibility _tipoTelefone;
+
+ private Visibility _telefone;
+
+ private Visibility _prefixo;
+
+ private ObservableCollection<ConfigExtratoImport> _configFiltrados = new ObservableCollection<ConfigExtratoImport>();
+
+ public Seguradora CancelSeguradora;
+
+ public ObservableCollection<SeguradoraEndereco> CancelEnderecos;
+
+ public ObservableCollection<SeguradoraContato> CancelContatos;
+
+ private ObservableCollection<Seguradora> _seguradorasFiltradas = new ObservableCollection<Seguradora>();
+
+ private bool _isExpanded;
+
+ public bool Apelido
+ {
+ get
+ {
+ return _apelido;
+ }
+ set
+ {
+ _apelido = value;
+ OnPropertyChanged("Apelido");
+ }
+ }
+
+ public Seguradora SelectedSeguradora
+ {
+ get
+ {
+ return _selectedSeguradora;
+ }
+ set
+ {
+ _selectedSeguradora = value;
+ WorkOnSelectedSeguradora(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedSeguradora");
+ }
+ }
+
+ public SeguradoraEndereco SelectedEndereco
+ {
+ get
+ {
+ return _selectedEndereco;
+ }
+ set
+ {
+ _selectedEndereco = value;
+ OnPropertyChanged("SelectedEndereco");
+ }
+ }
+
+ public ObservableCollection<SeguradoraContato> Contatos
+ {
+ get
+ {
+ return _contatos;
+ }
+ set
+ {
+ _contatos = value;
+ OnPropertyChanged("Contatos");
+ }
+ }
+
+ public ObservableCollection<SeguradoraEndereco> Enderecos
+ {
+ get
+ {
+ return _enderecos;
+ }
+ set
+ {
+ _enderecos = value;
+ OnPropertyChanged("Enderecos");
+ }
+ }
+
+ public SeguradoraContato SelectedTelefone
+ {
+ get
+ {
+ return _selectedTelefone;
+ }
+ set
+ {
+ _selectedTelefone = value;
+ OnPropertyChanged("SelectedTelefone");
+ }
+ }
+
+ public Visibility TipoTelefoneVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _tipoTelefone;
+ }
+ set
+ {
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Invalid comparison between Unknown and I4
+ //IL_0019: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0010: Unknown result type (might be due to invalid IL or missing references)
+ if ((int)SelectedTelefone.TipoContato == 2)
+ {
+ _tipoTelefone = (Visibility)2;
+ }
+ else
+ {
+ _tipoTelefone = (Visibility)0;
+ }
+ OnPropertyChanged("TipoTelefoneVisibility");
+ }
+ }
+
+ public Visibility TelefoneVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _telefone;
+ }
+ set
+ {
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Invalid comparison between Unknown and I4
+ //IL_0019: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0010: Unknown result type (might be due to invalid IL or missing references)
+ if ((int)SelectedTelefone.TipoContato == 2)
+ {
+ _telefone = (Visibility)2;
+ }
+ else
+ {
+ _telefone = (Visibility)0;
+ }
+ OnPropertyChanged("TelefoneVisibility");
+ }
+ }
+
+ public Visibility PrefixoVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _prefixo;
+ }
+ set
+ {
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Invalid comparison between Unknown and I4
+ //IL_0019: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0010: Unknown result type (might be due to invalid IL or missing references)
+ if ((int)SelectedTelefone.TipoContato == 2)
+ {
+ _prefixo = (Visibility)2;
+ }
+ else
+ {
+ _prefixo = (Visibility)0;
+ }
+ OnPropertyChanged("PrefixoVisibility");
+ }
+ }
+
+ public ObservableCollection<ConfigExtratoImport> ConfigFiltrados
+ {
+ get
+ {
+ return _configFiltrados;
+ }
+ set
+ {
+ _configFiltrados = value;
+ OnPropertyChanged("ConfigFiltrados");
+ }
+ }
+
+ public string Pesquisa { get; set; }
+
+ public decimal Tolerancia { get; set; }
+
+ public ObservableCollection<Seguradora> SeguradorasFiltradas
+ {
+ get
+ {
+ return _seguradorasFiltradas;
+ }
+ set
+ {
+ _seguradorasFiltradas = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("SeguradorasFiltradas");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public List<Seguradora> Seguradoras { get; set; }
+
+ public List<ConfigExtratoImport> Config { get; set; }
+
+ public SeguradoraViewModel()
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000b: Expected O, but got Unknown
+ //IL_0022: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002c: Expected O, but got Unknown
+ _servico = new SeguradoraServico();
+ Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 6);
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)13);
+ await SelecionaSeguradoras();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaSeguradoras(Seguradora seguradora = null)
+ {
+ Loading(isLoading: true);
+ List<Seguradora> list = await new BaseServico().BuscarSeguradorasAsync();
+ Seguradoras = (from x in list
+ orderby x.Ativo descending, x.Nome
+ select x).ToList();
+ SeguradorasFiltradas = new ObservableCollection<Seguradora>(Seguradoras);
+ if (seguradora != null)
+ {
+ SelecionaSeguradora(((IEnumerable<Seguradora>)SeguradorasFiltradas).FirstOrDefault((Func<Seguradora, bool>)((Seguradora x) => ((DomainBase)x).Id == ((DomainBase)seguradora).Id)));
+ }
+ else if (SeguradorasFiltradas.Count > 0)
+ {
+ SelecionaSeguradora(SeguradorasFiltradas.First());
+ }
+ else
+ {
+ SelectedSeguradora = new Seguradora();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Recursos.Seguradoras = list;
+ Loading(isLoading: false);
+ }
+
+ public List<KeyValuePair<string, string>> Validate(List<SeguradoraEndereco> endereco)
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ endereco?.ForEach(delegate(SeguradoraEndereco x)
+ {
+ errors.AddRange(x.Validate());
+ });
+ return errors.Distinct().ToList();
+ }
+
+ public List<KeyValuePair<string, string>> Validate(List<SeguradoraContato> contatos)
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ contatos?.ForEach(delegate(SeguradoraContato x)
+ {
+ errors.AddRange(x.Validate());
+ });
+ List<SeguradoraContato> list = contatos?.Where((SeguradoraContato x) => (int)x.TipoContato == 1).ToList();
+ if (list == null)
+ {
+ return errors;
+ }
+ if (list.Count > 4)
+ {
+ errors.Add(new KeyValuePair<string, string>("ASSISTÊNCIAS 24 HORAS", "NÃO É POSSÍVEL ADICIONAR MAIS QUE 4 NUMEROS DE ASSISTÊNCIA 24 HORAS"));
+ }
+ return errors.Distinct().ToList();
+ }
+
+ public void IncluirTelefone()
+ {
+ //IL_001c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0021: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0038: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0045: Expected O, but got Unknown
+ if (SelectedSeguradora != null)
+ {
+ if (Contatos == null)
+ {
+ Contatos = new ObservableCollection<SeguradoraContato>();
+ }
+ SeguradoraContato val = new SeguradoraContato
+ {
+ Empresa = Recursos.Empresa,
+ Seguradora = SelectedSeguradora,
+ Tipo = (TipoTelefone)2
+ };
+ Contatos.Add(val);
+ SelectedTelefone = val;
+ }
+ }
+
+ public void ExcluirTelefone(SeguradoraContato contato)
+ {
+ Contatos.Remove(contato);
+ }
+
+ public void IncluirEndereco()
+ {
+ //IL_001c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0021: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0038: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0040: Expected O, but got Unknown
+ if (SelectedSeguradora != null)
+ {
+ if (Enderecos == null)
+ {
+ Enderecos = new ObservableCollection<SeguradoraEndereco>();
+ }
+ SeguradoraEndereco val = new SeguradoraEndereco
+ {
+ Empresa = Recursos.Empresa,
+ Seguradora = SelectedSeguradora,
+ Tipo = (TipoEndereco)4
+ };
+ Enderecos.Add(val);
+ SelectedEndereco = val;
+ }
+ }
+
+ public void ExcluirEndereco(SeguradoraEndereco endereco)
+ {
+ Enderecos.Remove(endereco);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedSeguradora.Validate();
+ list.AddRange(Validate(Contatos.ToList()));
+ list.AddRange(Validate(Enderecos.ToList()));
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ SelectedSeguradora.Contatos = Contatos.Where((SeguradoraContato x) => !string.IsNullOrEmpty(x.NomeContato) || (int)x.TipoContato == 1).ToList();
+ SelectedSeguradora.Enderecos = Enderecos.Where((SeguradoraEndereco x) => !string.IsNullOrEmpty(((EnderecoBase)x).Bairro)).ToList();
+ Seguradora value = await _servico.Save(SelectedSeguradora, Config);
+ string text = ((((DomainBase)SelectedSeguradora).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(text + " SEGURADORA \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)13, $"SEGURADORA \"{value.Nome}\", ID: {((DomainBase)value).Id}");
+ await SelecionaSeguradoras();
+ FiltrarSeguradora(Pesquisa);
+ SelectedSeguradora = ((IEnumerable<Seguradora>)SeguradorasFiltradas).FirstOrDefault((Func<Seguradora, bool>)((Seguradora x) => ((DomainBase)x).Id == ((DomainBase)value).Id)) ?? SeguradorasFiltradas.FirstOrDefault();
+ Alterar(alterar: false);
+ ToggleSnackBar("SEGURADORA SALVA COM SUCESSO");
+ return null;
+ }
+
+ private void WorkOnSelectedSeguradora(Seguradora value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0092: Invalid comparison between Unknown and I4
+ //IL_014c: Unknown result type (might be due to invalid IL or missing references)
+ CancelSeguradora = (Seguradora)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelSeguradora) : ((object)(Seguradora)((DomainBase)value).Clone()));
+ CancelEnderecos = new ObservableCollection<SeguradoraEndereco>(Enderecos);
+ CancelContatos = new ObservableCollection<SeguradoraContato>(Contatos);
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 13))
+ {
+ return;
+ }
+ Seguradora selectedSeguradora = SelectedSeguradora;
+ if (((selectedSeguradora != null) ? selectedSeguradora.Contatos : null) != null)
+ {
+ Contatos = new ObservableCollection<SeguradoraContato>(SelectedSeguradora.Contatos);
+ }
+ Seguradora selectedSeguradora2 = SelectedSeguradora;
+ if (((selectedSeguradora2 != null) ? selectedSeguradora2.Enderecos : null) != null)
+ {
+ Enderecos = new ObservableCollection<SeguradoraEndereco>(SelectedSeguradora.Enderecos);
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU SEGURADORA \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)13, $"ID SEGURADORA: {((DomainBase)value).Id}");
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)13;
+ Seguradora selectedSeguradora3 = SelectedSeguradora;
+ if (((selectedSeguradora3 != null) ? new long?(((DomainBase)selectedSeguradora3).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedSeguradora = ((IEnumerable<Seguradora>)SeguradorasFiltradas).FirstOrDefault((Func<Seguradora, bool>)((Seguradora x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ Seguradora selectedSeguradora4 = SelectedSeguradora;
+ Tolerancia = ((selectedSeguradora4 != null) ? selectedSeguradora4.Tolerancia : null).GetValueOrDefault();
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelSeguradora != null && Seguradoras.Any((Seguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelSeguradora).Id))
+ {
+ DomainBase.Copy<Seguradora, Seguradora>(Seguradoras.First((Seguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelSeguradora).Id), CancelSeguradora);
+ if (SeguradorasFiltradas.Count > 0 && SeguradorasFiltradas.Any((Seguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelSeguradora).Id))
+ {
+ DomainBase.Copy<Seguradora, Seguradora>(SeguradorasFiltradas.First((Seguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelSeguradora).Id), CancelSeguradora);
+ }
+ else
+ {
+ SeguradorasFiltradas.Add(CancelSeguradora);
+ }
+ SeguradorasFiltradas = new ObservableCollection<Seguradora>(SeguradorasFiltradas);
+ ConfigFiltrados = new ObservableCollection<ConfigExtratoImport>(ConfigFiltrados);
+ SelectedSeguradora = SeguradorasFiltradas.First((Seguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelSeguradora).Id);
+ Enderecos = CancelEnderecos;
+ Contatos = CancelContatos;
+ }
+ Alterar(alterar: false);
+ }
+
+ internal async Task<List<Seguradora>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarSeguradora(value));
+ }
+
+ public List<Seguradora> FiltrarSeguradora(string filter)
+ {
+ Pesquisa = filter;
+ SeguradorasFiltradas = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Seguradora>(Seguradoras) : new ObservableCollection<Seguradora>(from x in Seguradoras
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) || ValidationHelper.RemoveDiacritics(x.NomeSocial).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ativo descending, x.Nome
+ select x));
+ return SeguradorasFiltradas.ToList();
+ }
+
+ internal async Task<List<ConfigExtratoImport>> FiltrarConfig(string value)
+ {
+ return await Task.Run(() => FiltrarDescricao(value));
+ }
+
+ public List<ConfigExtratoImport> FiltrarDescricao(string filter)
+ {
+ ConfigFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<ConfigExtratoImport>(Config) : new ObservableCollection<ConfigExtratoImport>(from x in Config
+ where ValidationHelper.RemoveDiacritics(x.Descricao.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Descricao
+ select x));
+ return ConfigFiltrados.ToList();
+ }
+
+ public async void SelecionaSeguradora(Seguradora seguradora)
+ {
+ Loading(isLoading: true);
+ SelectedSeguradora = seguradora;
+ Contatos = await _servico.BuscarContatos(((DomainBase)SelectedSeguradora).Id);
+ Enderecos = await _servico.BuscarEnderecos(((DomainBase)SelectedSeguradora).Id);
+ Config = await _servico.BuscarConfig(((DomainBase)SelectedSeguradora).Id);
+ ConfigFiltrados = new ObservableCollection<ConfigExtratoImport>(Config);
+ Loading(isLoading: false);
+ }
+
+ public void Clonar()
+ {
+ //IL_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0016: Expected O, but got Unknown
+ CancelSeguradora = (Seguradora)((DomainBase)SelectedSeguradora).Clone();
+ CancelEnderecos = new ObservableCollection<SeguradoraEndereco>(Enderecos);
+ CancelContatos = new ObservableCollection<SeguradoraContato>(Contatos);
+ }
+
+ public async void Incluir(Seguradora seguradora)
+ {
+ seguradora.Tolerancia = 2;
+ seguradora.ToleranciaPremio = 2;
+ seguradora.Ativo = true;
+ await _servico.Insert(seguradora);
+ if (_servico.Sucesso)
+ {
+ await SelecionaSeguradoras(seguradora);
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/SocioViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/SocioViewModel.cs
new file mode 100644
index 0000000..4e3466e
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/SocioViewModel.cs
@@ -0,0 +1,301 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class SocioViewModel : BaseSegurosViewModel
+{
+ private readonly SocioServico _servico;
+
+ public Socio CancelSocio;
+
+ private ObservableCollection<Empresa> _empresas = new ObservableCollection<Empresa>();
+
+ private Empresa _selectedEmpresa;
+
+ private Socio _selectedSocio = new Socio();
+
+ private ObservableCollection<Socio> _sociosFiltradas = new ObservableCollection<Socio>();
+
+ private bool _isExpanded;
+
+ private bool _isLoading;
+
+ public ObservableCollection<Empresa> Empresas
+ {
+ get
+ {
+ return _empresas;
+ }
+ set
+ {
+ _empresas = value;
+ OnPropertyChanged("Empresas");
+ }
+ }
+
+ public Empresa SelectedEmpresa
+ {
+ get
+ {
+ return _selectedEmpresa;
+ }
+ set
+ {
+ _selectedEmpresa = value;
+ WorkOnSelectedEmpresa(value);
+ OnPropertyChanged("SelectedEmpresa");
+ }
+ }
+
+ public Socio SelectedSocio
+ {
+ get
+ {
+ return _selectedSocio;
+ }
+ set
+ {
+ _selectedSocio = value;
+ WorkOnSelectedSocio(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedSocio");
+ }
+ }
+
+ public ObservableCollection<Socio> SociosFiltradas
+ {
+ get
+ {
+ return _sociosFiltradas;
+ }
+ set
+ {
+ _sociosFiltradas = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("SociosFiltradas");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public List<Socio> Socios { get; set; }
+
+ public bool IsLoading
+ {
+ get
+ {
+ return _isLoading;
+ }
+ set
+ {
+ _isLoading = value;
+ OnPropertyChanged("IsLoading");
+ }
+ }
+
+ public SocioViewModel()
+ {
+ //IL_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0016: Expected O, but got Unknown
+ _servico = new SocioServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)19);
+ Empresas = new ObservableCollection<Empresa>(await new EmpresaServico().BuscarEmpresas());
+ Loading(isLoading: false);
+ SelectedEmpresa = Empresas.FirstOrDefault();
+ }
+
+ private async Task SelecionaSocios(long? id)
+ {
+ Socios = null;
+ SociosFiltradas = null;
+ if (id.HasValue && id != 0)
+ {
+ Loading(isLoading: true);
+ Socios = (await new BaseServico().BuscarSociosAsync(id.Value)).OrderBy((Socio x) => x.Nome).ToList();
+ SociosFiltradas = new ObservableCollection<Socio>(Socios);
+ SelectedSocio = SociosFiltradas.FirstOrDefault();
+ Loading(isLoading: false);
+ }
+ }
+
+ private async void WorkOnSelectedEmpresa(Empresa value)
+ {
+ if (value != null && ((DomainBase)value).Id != 0L)
+ {
+ await SelecionaSocios(((DomainBase)value).Id);
+ }
+ }
+
+ internal async Task<List<Socio>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarSocio(value));
+ }
+
+ public List<Socio> FiltrarSocio(string filter)
+ {
+ SociosFiltradas = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Socio>(Socios) : new ObservableCollection<Socio>(from x in Socios
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Nome
+ select x));
+ return SociosFiltradas.ToList();
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedSocio.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ string acao = ((((DomainBase)SelectedSocio).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Socio value = await _servico.Save(SelectedSocio);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " SÓCIO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)19, $"ID: {((DomainBase)value).Id}\nTELEFONE: ({value.Prefixo}) {value.Telefone}\nE-MAIL: {value.Email}");
+ if (Socios.Any((Socio x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Socio, Socio>(Socios.First((Socio x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ Socios.Add(value);
+ }
+ if (SociosFiltradas.Any((Socio x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Socio, Socio>(SociosFiltradas.First((Socio x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ SociosFiltradas.Add(value);
+ }
+ SociosFiltradas = new ObservableCollection<Socio>(SociosFiltradas);
+ WorkOnSelectedSocio(value, registrar: false);
+ Alterar(alterar: false);
+ ToggleSnackBar("SÓCIO SALVO COM SUCESSO");
+ return null;
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelSocio != null && Socios.Any((Socio x) => ((DomainBase)x).Id == ((DomainBase)CancelSocio).Id))
+ {
+ DomainBase.Copy<Socio, Socio>(Socios.First((Socio x) => ((DomainBase)x).Id == ((DomainBase)CancelSocio).Id), CancelSocio);
+ if (SociosFiltradas.Count > 0 && SociosFiltradas.Any((Socio x) => ((DomainBase)x).Id == ((DomainBase)CancelSocio).Id))
+ {
+ DomainBase.Copy<Socio, Socio>(SociosFiltradas.First((Socio x) => ((DomainBase)x).Id == ((DomainBase)CancelSocio).Id), CancelSocio);
+ }
+ else
+ {
+ SociosFiltradas.Add(CancelSocio);
+ }
+ SociosFiltradas = new ObservableCollection<Socio>(SociosFiltradas);
+ SelectedSocio = SociosFiltradas.First((Socio x) => ((DomainBase)x).Id == ((DomainBase)CancelSocio).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ public void Incluir()
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Expected O, but got Unknown
+ Socio selectedSocio = new Socio
+ {
+ IdEmpresa = ((DomainBase)SelectedEmpresa).Id
+ };
+ SelectedSocio = selectedSocio;
+ Alterar(alterar: true);
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedSocio == null || ((DomainBase)SelectedSocio).Id == 0L || !(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ IsLoading = true;
+ if (!(await _servico.Delete(SelectedSocio)))
+ {
+ Loading(isLoading: false);
+ IsLoading = false;
+ return;
+ }
+ RegistrarAcao("EXCLUIU SÓCIO \"" + SelectedSocio.Nome + "\"", ((DomainBase)SelectedSocio).Id, (TipoTela)19, $"ID: {((DomainBase)SelectedSocio).Id}\nTELEFONE: ({SelectedSocio.Prefixo}) {SelectedSocio.Telefone}\nE-MAIL: {SelectedSocio.Email}");
+ int num = SociosFiltradas.IndexOf(SelectedSocio);
+ Socios.Remove(SelectedSocio);
+ SociosFiltradas.Remove(SelectedSocio);
+ SociosFiltradas = new ObservableCollection<Socio>(SociosFiltradas);
+ if (SociosFiltradas.Count > 0)
+ {
+ SelectedSocio = ((num < SociosFiltradas.Count) ? SociosFiltradas.ElementAt(num) : SociosFiltradas.Last());
+ }
+ else
+ {
+ SelectedSocio = new Socio();
+ Alterar(alterar: false);
+ }
+ Loading(isLoading: false);
+ IsLoading = false;
+ ToggleSnackBar("SÓCIO EXCLUÍDO COM SUCESSO");
+ }
+
+ private void WorkOnSelectedSocio(Socio value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Invalid comparison between Unknown and I4
+ //IL_0109: Unknown result type (might be due to invalid IL or missing references)
+ CancelSocio = (Socio)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelSocio) : ((object)(Socio)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 19))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU SÓCIO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)19, $"ID: {((DomainBase)value).Id}\nTELEFONE: ({value.Prefixo}) {value.Telefone}\nE-MAIL: {value.Email}");
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)19;
+ Socio selectedSocio = SelectedSocio;
+ if (((selectedSocio != null) ? new long?(((DomainBase)selectedSocio).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedSocio = ((IEnumerable<Socio>)SociosFiltradas).FirstOrDefault((Func<Socio, bool>)((Socio x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/StatusProspeccaoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/StatusProspeccaoViewModel.cs
new file mode 100644
index 0000000..5397aca
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/StatusProspeccaoViewModel.cs
@@ -0,0 +1,263 @@
+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.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class StatusProspeccaoViewModel : BaseSegurosViewModel
+{
+ private readonly StatusProspeccaoServico _servico;
+
+ private readonly ProspeccaoServico _servicoProspeccao;
+
+ public StatusDeProspeccao CancelStatusProspeccao;
+
+ private ObservableCollection<StatusDeProspeccao> _statusProspeccaoFiltrados = new ObservableCollection<StatusDeProspeccao>();
+
+ private bool _isExpanded;
+
+ private StatusDeProspeccao _selectedStatusProspeccao;
+
+ public List<StatusDeProspeccao> StatusProspeccao { get; set; }
+
+ public ObservableCollection<StatusDeProspeccao> StatusProspeccaoFiltrados
+ {
+ get
+ {
+ return _statusProspeccaoFiltrados;
+ }
+ set
+ {
+ _statusProspeccaoFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("StatusProspeccaoFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public StatusDeProspeccao SelectedStatusProspeccao
+ {
+ get
+ {
+ return _selectedStatusProspeccao;
+ }
+ set
+ {
+ _selectedStatusProspeccao = value;
+ WorkOnSelectedStatusProspeccao(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedStatusProspeccao");
+ }
+ }
+
+ public StatusProspeccaoViewModel()
+ {
+ _servico = new StatusProspeccaoServico();
+ _servicoProspeccao = new ProspeccaoServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)57);
+ await SelecionaStatusProspeccao();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaStatusProspeccao()
+ {
+ Loading(isLoading: true);
+ StatusProspeccao = (from x in await _servico.BuscarProspeccoes()
+ where !x.Excluido
+ orderby x.Ativo descending, x.Nome
+ select x).ToList();
+ StatusProspeccaoFiltrados = new ObservableCollection<StatusDeProspeccao>(StatusProspeccao);
+ SelectedStatusProspeccao = StatusProspeccaoFiltrados.FirstOrDefault();
+ Loading(isLoading: false);
+ }
+
+ public async Task<List<StatusDeProspeccao>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarStatusProspeccao(value));
+ }
+
+ public List<StatusDeProspeccao> FiltrarStatusProspeccao(string filter)
+ {
+ StatusProspeccaoFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<StatusDeProspeccao>(StatusProspeccao) : new ObservableCollection<StatusDeProspeccao>(from x in StatusProspeccao
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ativo descending, x.Nome
+ select x));
+ SelectedStatusProspeccao = StatusProspeccaoFiltrados.FirstOrDefault();
+ return StatusProspeccaoFiltrados.ToList();
+ }
+
+ public void Incluir()
+ {
+ //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_000d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0019: Expected O, but got Unknown
+ SelectedStatusProspeccao = new StatusDeProspeccao
+ {
+ Ativo = true,
+ Excluido = false
+ };
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedStatusProspeccao.Validate();
+ list.AddRange(Validate());
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ string acao = ((((DomainBase)SelectedStatusProspeccao).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ StatusDeProspeccao value = await _servico.Save(SelectedStatusProspeccao);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " STATUS DE PROSPECÇÃO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)57, string.Format("ID: {0}\nATIVO: {1}\nDESCRIÇÃO: \"{2}\"", ((DomainBase)value).Id, value.Ativo ? "SIM" : "NÃO", value.Descricao));
+ if (StatusProspeccao.Any((StatusDeProspeccao x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<StatusDeProspeccao, StatusDeProspeccao>(StatusProspeccao.First((StatusDeProspeccao x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ StatusProspeccao.Add(value);
+ }
+ if (StatusProspeccaoFiltrados.Any((StatusDeProspeccao x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<StatusDeProspeccao, StatusDeProspeccao>(StatusProspeccaoFiltrados.First((StatusDeProspeccao x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ StatusProspeccaoFiltrados.Add(value);
+ }
+ StatusProspeccaoFiltrados = new ObservableCollection<StatusDeProspeccao>(StatusProspeccaoFiltrados);
+ WorkOnSelectedStatusProspeccao(value, registrar: false);
+ Recursos.StatusProspeccao = StatusProspeccao;
+ Alterar(alterar: false);
+ ToggleSnackBar("STATUS DE PROSPECÇÃO SALVO COM SUCESSO");
+ return null;
+ }
+
+ public List<KeyValuePair<string, string>> Validate()
+ {
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (string.IsNullOrWhiteSpace(SelectedStatusProspeccao.Nome))
+ {
+ return list;
+ }
+ if (StatusProspeccao.Any((StatusDeProspeccao x) => x.Nome.Contains(SelectedStatusProspeccao.Nome) && ((DomainBase)x).Id != ((DomainBase)SelectedStatusProspeccao).Id))
+ {
+ list.Add(new KeyValuePair<string, string>("Nome", "UM STATUS DE PROSPECÇÃO COM O MESMO NOME JÁ EXISTE."));
+ }
+ return list;
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelStatusProspeccao != null && StatusProspeccao.Any((StatusDeProspeccao x) => ((DomainBase)x).Id == ((DomainBase)CancelStatusProspeccao).Id))
+ {
+ DomainBase.Copy<StatusDeProspeccao, StatusDeProspeccao>(StatusProspeccao.First((StatusDeProspeccao x) => ((DomainBase)x).Id == ((DomainBase)CancelStatusProspeccao).Id), CancelStatusProspeccao);
+ if (StatusProspeccaoFiltrados.Count > 0 && StatusProspeccaoFiltrados.Any((StatusDeProspeccao x) => ((DomainBase)x).Id == ((DomainBase)CancelStatusProspeccao).Id))
+ {
+ DomainBase.Copy<StatusDeProspeccao, StatusDeProspeccao>(StatusProspeccaoFiltrados.First((StatusDeProspeccao x) => ((DomainBase)x).Id == ((DomainBase)CancelStatusProspeccao).Id), CancelStatusProspeccao);
+ }
+ else
+ {
+ StatusProspeccaoFiltrados.Add(CancelStatusProspeccao);
+ }
+ StatusProspeccaoFiltrados = new ObservableCollection<StatusDeProspeccao>(StatusProspeccaoFiltrados);
+ SelectedStatusProspeccao = StatusProspeccaoFiltrados.First((StatusDeProspeccao x) => ((DomainBase)x).Id == ((DomainBase)CancelStatusProspeccao).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedStatusProspeccao == null || ((DomainBase)SelectedStatusProspeccao).Id == 0L)
+ {
+ return;
+ }
+ if ((await _servicoProspeccao.BuscarProspeccoesPorStatus(SelectedStatusProspeccao)).Count > 0)
+ {
+ await ShowMessage("O STATUS " + SelectedStatusProspeccao.Nome + ", NÃO PODE SER EXCLUÍDO, POIS ESTÁ CADASTRADO EM UMA PROSPECÇÃO");
+ }
+ else if (await ShowMessage("DESEJA REALMENTE EXCLUIR O STATUS DE PROSPECÇÃO " + SelectedStatusProspeccao.Nome + "?", "SIM", "NÃO"))
+ {
+ Loading(isLoading: true);
+ SelectedStatusProspeccao.Excluido = true;
+ SelectedStatusProspeccao.Ativo = false;
+ await _servico.Save(SelectedStatusProspeccao);
+ if (!_servico.Sucesso)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ RegistrarAcao("EXCLUIU STATUS DE PROSPECÇÃO \"" + SelectedStatusProspeccao.Nome + "\"", ((DomainBase)SelectedStatusProspeccao).Id, (TipoTela)57, string.Format("ID: {0}\nATIVO: {1}\nDESCRIÇÃO: \"{2}\"", ((DomainBase)SelectedStatusProspeccao).Id, SelectedStatusProspeccao.Ativo ? "SIM" : "NÃO", SelectedStatusProspeccao.Descricao));
+ StatusProspeccao.Remove(SelectedStatusProspeccao);
+ StatusProspeccaoFiltrados.Remove(SelectedStatusProspeccao);
+ Recursos.StatusProspeccao.Remove(SelectedStatusProspeccao);
+ SelectedStatusProspeccao = StatusProspeccaoFiltrados.FirstOrDefault();
+ await SelecionaStatusProspeccao();
+ Loading(isLoading: false);
+ ToggleSnackBar("STATUS DE PROSPECÇÃO EXCLUÍDO COM SUCESSO");
+ }
+ }
+
+ private void WorkOnSelectedStatusProspeccao(StatusDeProspeccao value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Invalid comparison between Unknown and I4
+ //IL_00fa: Unknown result type (might be due to invalid IL or missing references)
+ CancelStatusProspeccao = (StatusDeProspeccao)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelStatusProspeccao) : ((object)(StatusDeProspeccao)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 57))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU STATUS DE PROSPECÇÃO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)57, string.Format("ID: {0}\nATIVO: {1}\nDESCRIÇÃO: \"{2}\"", ((DomainBase)value).Id, value.Ativo ? "SIM" : "NÃO", value.Descricao));
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)57;
+ StatusDeProspeccao selectedStatusProspeccao = SelectedStatusProspeccao;
+ if (((selectedStatusProspeccao != null) ? new long?(((DomainBase)selectedStatusProspeccao).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedStatusProspeccao = ((IEnumerable<StatusDeProspeccao>)StatusProspeccaoFiltrados).FirstOrDefault((Func<StatusDeProspeccao, bool>)((StatusDeProspeccao x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/StatusViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/StatusViewModel.cs
new file mode 100644
index 0000000..2f758d1
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/StatusViewModel.cs
@@ -0,0 +1,295 @@
+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.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class StatusViewModel : BaseSegurosViewModel
+{
+ private readonly StatusServico _servico;
+
+ private Status _selectedStatus;
+
+ public Status CancelStatus;
+
+ private ObservableCollection<Status> _statusFiltrados = new ObservableCollection<Status>();
+
+ private bool _isExpanded;
+
+ public Status SelectedStatus
+ {
+ get
+ {
+ return _selectedStatus;
+ }
+ set
+ {
+ _selectedStatus = value;
+ WorkOnSelectedStatus(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedStatus");
+ }
+ }
+
+ public ObservableCollection<Status> StatusFiltrados
+ {
+ get
+ {
+ return _statusFiltrados;
+ }
+ set
+ {
+ _statusFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("StatusFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public List<Status> Status { get; set; }
+
+ public StatusViewModel()
+ {
+ _servico = new StatusServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)11);
+ await SelecionaStatuses();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaStatuses()
+ {
+ Loading(isLoading: true);
+ Status = (from x in await new BaseServico().BuscarStatusAsync()
+ orderby x.Ativo descending, x.Nome
+ select x).ToList();
+ StatusFiltrados = new ObservableCollection<Status>(Status);
+ SelectedStatus = StatusFiltrados.FirstOrDefault();
+ Recursos.Status = Status;
+ Loading(isLoading: false);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ if (string.IsNullOrWhiteSpace(SelectedStatus.Nome))
+ {
+ return new List<KeyValuePair<string, string>>();
+ }
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ bool valida = true;
+ List<Status> list = await new BaseServico().BuscarStatus(SelectedStatus.Nome);
+ if (list.Count > 0)
+ {
+ list.ForEach(delegate(Status x)
+ {
+ if (((DomainBase)x).Id != ((DomainBase)SelectedStatus).Id && x.Nome == SelectedStatus.Nome)
+ {
+ valida = false;
+ }
+ });
+ }
+ if (!valida)
+ {
+ errors.Add(new KeyValuePair<string, string>("Nome", "UM STATUS COM O MESMO NOME JÁ EXISTE."));
+ }
+ return errors;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> errorMessages = SelectedStatus.Validate();
+ List<KeyValuePair<string, string>> list = errorMessages;
+ list.AddRange(await Validate());
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ string acao = ((((DomainBase)SelectedStatus).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Status value = await _servico.Save(SelectedStatus);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " STATUS ID \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)11, string.Format("ID: {0}\nATIVO: {1}", ((DomainBase)value).Id, value.Ativo ? "SIM" : "NÃO"));
+ if (Status.Any((Status x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Status, Status>(Status.First((Status x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ Status.Add(value);
+ }
+ if (StatusFiltrados.Any((Status x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<Status, Status>(StatusFiltrados.First((Status x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ StatusFiltrados.Add(value);
+ }
+ StatusFiltrados = new ObservableCollection<Status>(StatusFiltrados);
+ WorkOnSelectedStatus(value, registrar: false);
+ Recursos.Status = Status;
+ Alterar(alterar: false);
+ ToggleSnackBar("STATUS SALVO COM SUCESSO");
+ return null;
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelStatus != null && Status.Any((Status x) => ((DomainBase)x).Id == ((DomainBase)CancelStatus).Id))
+ {
+ DomainBase.Copy<Status, Status>(Status.First((Status x) => ((DomainBase)x).Id == ((DomainBase)CancelStatus).Id), CancelStatus);
+ if (StatusFiltrados.Count > 0 && StatusFiltrados.Any((Status x) => ((DomainBase)x).Id == ((DomainBase)CancelStatus).Id))
+ {
+ DomainBase.Copy<Status, Status>(StatusFiltrados.First((Status x) => ((DomainBase)x).Id == ((DomainBase)CancelStatus).Id), CancelStatus);
+ }
+ else
+ {
+ StatusFiltrados.Add(CancelStatus);
+ }
+ StatusFiltrados = new ObservableCollection<Status>(StatusFiltrados);
+ SelectedStatus = StatusFiltrados.First((Status x) => ((DomainBase)x).Id == ((DomainBase)CancelStatus).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ public void Incluir()
+ {
+ //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_0012: Expected O, but got Unknown
+ SelectedStatus = new Status
+ {
+ Ativo = true
+ };
+ Alterar(alterar: true);
+ }
+
+ internal async Task<List<Status>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarStatus(value));
+ }
+
+ public List<Status> FiltrarStatus(string filter)
+ {
+ StatusFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Status>(Status) : new ObservableCollection<Status>(from x in Status
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ativo descending, x.Nome
+ select x));
+ return StatusFiltrados.ToList();
+ }
+
+ public async void SelecionaStatus(Status status)
+ {
+ Status val = await _servico.BuscarStatusPorId(((DomainBase)status).Id);
+ DomainBase.Copy<Status, Status>(StatusFiltrados.First((Status x) => ((DomainBase)x).Id == ((DomainBase)status).Id), val);
+ SelectedStatus = StatusFiltrados.First((Status x) => ((DomainBase)x).Id == ((DomainBase)status).Id);
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedStatus == null || ((DomainBase)SelectedStatus).Id == 0L)
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ List<Documento> list = await new BaseServico().BuscarDocumentosPorStatus(((DomainBase)SelectedStatus).Id);
+ Loading(isLoading: false);
+ if (list.Count > 0)
+ {
+ string text = "ESTIPULANTE NÃO PODE SER EXCLUÍDO POIS ESTÁ VINCULADO AOS SEGUINTES DOCUMENTOS:";
+ foreach (Documento item in list)
+ {
+ text = ((!string.IsNullOrWhiteSpace(item.Apolice)) ? (text + $"{Environment.NewLine}DOCUMENTO {list.IndexOf(item) + 1} (NÚMERO DA PROPOSTA: {item.Proposta}, NÚMERO DA APÓLICE: {item.Apolice})") : (text + $"{Environment.NewLine}DOCUMENTO {list.IndexOf(item) + 1} (NÚMERO DA PROPOSTA: {item.Proposta})"));
+ }
+ await ShowMessage(text);
+ }
+ else
+ {
+ if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ if (!(await _servico.Delete(SelectedStatus)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ RegistrarAcao("EXCLUIU STATUS \"" + SelectedStatus.Nome + "\"", ((DomainBase)SelectedStatus).Id, (TipoTela)11, string.Format("ID: {0}\nATIVO: {1}", ((DomainBase)SelectedStatus).Id, SelectedStatus.Ativo ? "SIM" : "NÃO"));
+ int num = StatusFiltrados.IndexOf(SelectedStatus);
+ Status.Remove(SelectedStatus);
+ StatusFiltrados.Remove(SelectedStatus);
+ StatusFiltrados = new ObservableCollection<Status>(StatusFiltrados);
+ if (StatusFiltrados.Count > 0)
+ {
+ SelectedStatus = ((num < StatusFiltrados.Count) ? StatusFiltrados.ElementAt(num) : StatusFiltrados.Last());
+ }
+ else
+ {
+ SelectedStatus = new Status();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Loading(isLoading: false);
+ ToggleSnackBar("ESTIPULANTE EXCLUÍDO COM SUCESSO");
+ }
+ }
+
+ private void WorkOnSelectedStatus(Status value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Invalid comparison between Unknown and I4
+ //IL_00ef: Unknown result type (might be due to invalid IL or missing references)
+ CancelStatus = (Status)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelStatus) : ((object)(Status)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 11))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU STATUS \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)11, string.Format("ID: {0}\nATIVO: {1}", ((DomainBase)value).Id, value.Ativo ? "SIM" : "NÃO"));
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)11;
+ Status selectedStatus = SelectedStatus;
+ if (((selectedStatus != null) ? new long?(((DomainBase)selectedStatus).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedStatus = ((IEnumerable<Status>)StatusFiltrados).FirstOrDefault((Func<Status, bool>)((Status x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/TipoTarefaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/TipoTarefaViewModel.cs
new file mode 100644
index 0000000..bf0176b
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/TipoTarefaViewModel.cs
@@ -0,0 +1,263 @@
+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.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class TipoTarefaViewModel : BaseSegurosViewModel
+{
+ private readonly TipoTarefaServico _servico;
+
+ private readonly TarefaServico _servicoTarefa;
+
+ public TipoDeTarefa CancelTipoTarefa;
+
+ private ObservableCollection<TipoDeTarefa> _tiposTarefaFiltrados = new ObservableCollection<TipoDeTarefa>();
+
+ private bool _isExpanded;
+
+ private TipoDeTarefa _selectedTipoTarefa;
+
+ public List<TipoDeTarefa> TiposTarefa { get; set; }
+
+ public ObservableCollection<TipoDeTarefa> TiposTarefaFiltrados
+ {
+ get
+ {
+ return _tiposTarefaFiltrados;
+ }
+ set
+ {
+ _tiposTarefaFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("TiposTarefaFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public TipoDeTarefa SelectedTipoTarefa
+ {
+ get
+ {
+ return _selectedTipoTarefa;
+ }
+ set
+ {
+ _selectedTipoTarefa = value;
+ WorkOnSelectedTipoTarefa(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedTipoTarefa");
+ }
+ }
+
+ public TipoTarefaViewModel()
+ {
+ _servico = new TipoTarefaServico();
+ _servicoTarefa = new TarefaServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)52);
+ await SelecionaTipoTarefa();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaTipoTarefa()
+ {
+ Loading(isLoading: true);
+ TiposTarefa = (from x in await _servico.BuscarTarefas()
+ where !x.Excluido
+ orderby x.Ativo descending, x.Nome
+ select x).ToList();
+ TiposTarefaFiltrados = new ObservableCollection<TipoDeTarefa>(TiposTarefa);
+ SelectedTipoTarefa = TiposTarefaFiltrados.FirstOrDefault();
+ Loading(isLoading: false);
+ }
+
+ public async Task<List<TipoDeTarefa>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarTipoTarefa(value));
+ }
+
+ public List<TipoDeTarefa> FiltrarTipoTarefa(string filter)
+ {
+ TiposTarefaFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<TipoDeTarefa>(TiposTarefa) : new ObservableCollection<TipoDeTarefa>(from x in TiposTarefa
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ativo descending, x.Nome
+ select x));
+ SelectedTipoTarefa = TiposTarefaFiltrados.FirstOrDefault();
+ return TiposTarefaFiltrados.ToList();
+ }
+
+ public void Incluir()
+ {
+ //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_000d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0019: Expected O, but got Unknown
+ SelectedTipoTarefa = new TipoDeTarefa
+ {
+ Ativo = true,
+ Excluido = false
+ };
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedTipoTarefa.Validate();
+ list.AddRange(Validate());
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ string acao = ((((DomainBase)SelectedTipoTarefa).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ TipoDeTarefa value = await _servico.Save(SelectedTipoTarefa);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " TIPO DE TAREFA \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)52, string.Format("ID: {0}\nATIVO: {1}\nDESCRIÇÃO: \"{2}\"", ((DomainBase)value).Id, value.Ativo ? "SIM" : "NÃO", value.Descricao));
+ if (TiposTarefa.Any((TipoDeTarefa x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<TipoDeTarefa, TipoDeTarefa>(TiposTarefa.First((TipoDeTarefa x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ TiposTarefa.Add(value);
+ }
+ if (TiposTarefaFiltrados.Any((TipoDeTarefa x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<TipoDeTarefa, TipoDeTarefa>(TiposTarefaFiltrados.First((TipoDeTarefa x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ TiposTarefaFiltrados.Add(value);
+ }
+ TiposTarefaFiltrados = new ObservableCollection<TipoDeTarefa>(TiposTarefaFiltrados);
+ WorkOnSelectedTipoTarefa(value, registrar: false);
+ Recursos.TiposTarefa = TiposTarefa;
+ Alterar(alterar: false);
+ ToggleSnackBar("TIPO DE TAREFA SALVO COM SUCESSO");
+ return null;
+ }
+
+ public List<KeyValuePair<string, string>> Validate()
+ {
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (string.IsNullOrWhiteSpace(SelectedTipoTarefa.Nome))
+ {
+ return list;
+ }
+ if (TiposTarefa.Any((TipoDeTarefa x) => x.Nome.Contains(SelectedTipoTarefa.Nome) && ((DomainBase)x).Id != ((DomainBase)SelectedTipoTarefa).Id))
+ {
+ list.Add(new KeyValuePair<string, string>("Nome", "UM TIPO DE TAREFA COM O MESMO NOME JÁ EXISTE."));
+ }
+ return list;
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelTipoTarefa != null && TiposTarefa.Any((TipoDeTarefa x) => ((DomainBase)x).Id == ((DomainBase)CancelTipoTarefa).Id))
+ {
+ DomainBase.Copy<TipoDeTarefa, TipoDeTarefa>(TiposTarefa.First((TipoDeTarefa x) => ((DomainBase)x).Id == ((DomainBase)CancelTipoTarefa).Id), CancelTipoTarefa);
+ if (TiposTarefaFiltrados.Count > 0 && TiposTarefaFiltrados.Any((TipoDeTarefa x) => ((DomainBase)x).Id == ((DomainBase)CancelTipoTarefa).Id))
+ {
+ DomainBase.Copy<TipoDeTarefa, TipoDeTarefa>(TiposTarefaFiltrados.First((TipoDeTarefa x) => ((DomainBase)x).Id == ((DomainBase)CancelTipoTarefa).Id), CancelTipoTarefa);
+ }
+ else
+ {
+ TiposTarefaFiltrados.Add(CancelTipoTarefa);
+ }
+ TiposTarefaFiltrados = new ObservableCollection<TipoDeTarefa>(TiposTarefaFiltrados);
+ SelectedTipoTarefa = TiposTarefaFiltrados.First((TipoDeTarefa x) => ((DomainBase)x).Id == ((DomainBase)CancelTipoTarefa).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedTipoTarefa == null || ((DomainBase)SelectedTipoTarefa).Id == 0L)
+ {
+ return;
+ }
+ if ((await _servicoTarefa.BuscarTarefasPorTipo(SelectedTipoTarefa)).Count > 0)
+ {
+ await ShowMessage("O TIPO " + SelectedTipoTarefa.Nome + ", NÃO PODE SER EXCLUÍDO, POIS ESTÁ CADASTRADO EM UMA TAREFA");
+ }
+ else if (await ShowMessage("DESEJA REALMENTE EXCLUIR O TIPO DE TAREFA " + SelectedTipoTarefa.Nome + "?", "SIM", "NÃO"))
+ {
+ Loading(isLoading: true);
+ SelectedTipoTarefa.Excluido = true;
+ SelectedTipoTarefa.Ativo = false;
+ await _servico.Save(SelectedTipoTarefa);
+ if (!_servico.Sucesso)
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ RegistrarAcao("EXCLUIU TIPO DE TAREFA \"" + SelectedTipoTarefa.Nome + "\"", ((DomainBase)SelectedTipoTarefa).Id, (TipoTela)52, string.Format("ID: {0}\nATIVO: {1}\nDESCRIÇÃO: \"{2}\"", ((DomainBase)SelectedTipoTarefa).Id, SelectedTipoTarefa.Ativo ? "SIM" : "NÃO", SelectedTipoTarefa.Descricao));
+ TiposTarefa.Remove(SelectedTipoTarefa);
+ TiposTarefaFiltrados.Remove(SelectedTipoTarefa);
+ Recursos.TiposTarefa.Remove(SelectedTipoTarefa);
+ SelectedTipoTarefa = TiposTarefaFiltrados.FirstOrDefault();
+ await SelecionaTipoTarefa();
+ Loading(isLoading: false);
+ ToggleSnackBar("TIPO DE TAREFA EXCLUÍDO COM SUCESSO");
+ }
+ }
+
+ private void WorkOnSelectedTipoTarefa(TipoDeTarefa value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Invalid comparison between Unknown and I4
+ //IL_00fa: Unknown result type (might be due to invalid IL or missing references)
+ CancelTipoTarefa = (TipoDeTarefa)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelTipoTarefa) : ((object)(TipoDeTarefa)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 52))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU TIPO DE TAREFA \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)52, string.Format("ID: {0}\nATIVO: {1}\nDESCRIÇÃO: \"{2}\"", ((DomainBase)value).Id, value.Ativo ? "SIM" : "NÃO", value.Descricao));
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)52;
+ TipoDeTarefa selectedTipoTarefa = SelectedTipoTarefa;
+ if (((selectedTipoTarefa != null) ? new long?(((DomainBase)selectedTipoTarefa).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedTipoTarefa = ((IEnumerable<TipoDeTarefa>)TiposTarefaFiltrados).FirstOrDefault((Func<TipoDeTarefa, bool>)((TipoDeTarefa x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/TipoVendedorViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/TipoVendedorViewModel.cs
new file mode 100644
index 0000000..4d6b650
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/TipoVendedorViewModel.cs
@@ -0,0 +1,294 @@
+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.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class TipoVendedorViewModel : BaseSegurosViewModel
+{
+ private readonly TipoVendedorServico _servico;
+
+ public TipoVendedor CancelTipoVendedor;
+
+ private Visibility _ativoVisibility = (Visibility)2;
+
+ private TipoVendedor _selectedTipoVendedor = new TipoVendedor();
+
+ private ObservableCollection<TipoVendedor> _tipoVendedoresFiltrados = new ObservableCollection<TipoVendedor>();
+
+ private bool _isExpanded;
+
+ public List<TipoVendedor> TipoVendedores { get; set; }
+
+ public Visibility AtivoVisibility
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _ativoVisibility;
+ }
+ 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)
+ _ativoVisibility = value;
+ OnPropertyChanged("AtivoVisibility");
+ }
+ }
+
+ public TipoVendedor SelectedTipoVendedor
+ {
+ get
+ {
+ return _selectedTipoVendedor;
+ }
+ set
+ {
+ _selectedTipoVendedor = value;
+ WorkOnSelectedTipoVendedor(value);
+ AtivoVisibility = (Visibility)((value != null && ((DomainBase)value).Id == 1) ? 2 : 0);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedTipoVendedor");
+ }
+ }
+
+ public ObservableCollection<TipoVendedor> TipoVendedoresFiltrados
+ {
+ get
+ {
+ return _tipoVendedoresFiltrados;
+ }
+ set
+ {
+ _tipoVendedoresFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("TipoVendedoresFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public TipoVendedorViewModel()
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0008: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0012: Expected O, but got Unknown
+ _servico = new TipoVendedorServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ public async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)14);
+ await SelecionaTipoVendedores();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaTipoVendedores()
+ {
+ Loading(isLoading: true);
+ List<TipoVendedor> list = await new BaseServico().BuscarTipoVendedoresAsync();
+ TipoVendedores = (from x in list
+ orderby x.Ativo descending, x.Descricao
+ select x).ToList();
+ TipoVendedoresFiltrados = new ObservableCollection<TipoVendedor>(TipoVendedores);
+ if (TipoVendedoresFiltrados.Count > 0)
+ {
+ SelecionaTipoVendedor(TipoVendedoresFiltrados.First());
+ }
+ else
+ {
+ SelectedTipoVendedor = new TipoVendedor();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Recursos.TipoVendedor = list;
+ Loading(isLoading: false);
+ }
+
+ public void Incluir()
+ {
+ //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_0012: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0023: Expected O, but got Unknown
+ SelectedTipoVendedor = new TipoVendedor
+ {
+ Ativo = true,
+ Inserido = false
+ };
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ List<KeyValuePair<string, string>> list = SelectedTipoVendedor.Validate();
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ string acao = ((((DomainBase)SelectedTipoVendedor).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ TipoVendedor value = await _servico.Save(SelectedTipoVendedor);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " TIPO VENDEDOR \"" + value.Descricao + "\"", ((DomainBase)value).Id, (TipoTela)14, string.Format("ID: {0}\nATIVO: {1}", ((DomainBase)value).Id, (value.Ativo.HasValue && value.Ativo.Value) ? "SIM" : "NÃO"));
+ if (TipoVendedores.Any((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<TipoVendedor, TipoVendedor>(TipoVendedores.First((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ TipoVendedores.Add(value);
+ }
+ if (TipoVendedoresFiltrados.Any((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
+ {
+ DomainBase.Copy<TipoVendedor, TipoVendedor>(TipoVendedoresFiltrados.First((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
+ }
+ else
+ {
+ TipoVendedoresFiltrados.Add(value);
+ }
+ TipoVendedoresFiltrados = new ObservableCollection<TipoVendedor>(TipoVendedoresFiltrados);
+ WorkOnSelectedTipoVendedor(value, registrar: false);
+ Recursos.TipoVendedor = TipoVendedores;
+ Alterar(alterar: false);
+ ToggleSnackBar("TIPO VENDEDOR SALVO COM SUCESSO");
+ return null;
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelTipoVendedor != null && TipoVendedores.Any((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelTipoVendedor).Id))
+ {
+ DomainBase.Copy<TipoVendedor, TipoVendedor>(TipoVendedores.First((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelTipoVendedor).Id), CancelTipoVendedor);
+ if (TipoVendedoresFiltrados.Count > 0 && TipoVendedoresFiltrados.Any((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelTipoVendedor).Id))
+ {
+ DomainBase.Copy<TipoVendedor, TipoVendedor>(TipoVendedoresFiltrados.First((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelTipoVendedor).Id), CancelTipoVendedor);
+ }
+ else
+ {
+ TipoVendedoresFiltrados.Add(CancelTipoVendedor);
+ }
+ TipoVendedoresFiltrados = new ObservableCollection<TipoVendedor>(TipoVendedoresFiltrados);
+ SelectedTipoVendedor = TipoVendedoresFiltrados.First((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelTipoVendedor).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ public async void Excluir()
+ {
+ if (SelectedTipoVendedor == null || ((DomainBase)SelectedTipoVendedor).Id == 0L || ((DomainBase)SelectedTipoVendedor).Id == 1)
+ {
+ return;
+ }
+ if (await new BaseServico().TipoVendedorUtilizado(((DomainBase)SelectedTipoVendedor).Id))
+ {
+ await ShowMessage("TIPO VENDEDOR NÃO PODE SER EXCLUÍDO POIS ESTÁ SENDO UTILIZADO.");
+ }
+ else
+ {
+ if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ if (!(await _servico.Delete(SelectedTipoVendedor)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ RegistrarAcao("EXCLUIU TIPO VENDEDOR \"" + SelectedTipoVendedor.Descricao + "\"", ((DomainBase)SelectedTipoVendedor).Id, (TipoTela)14, string.Format("ID: {0}\nATIVO: {1}", ((DomainBase)SelectedTipoVendedor).Id, (SelectedTipoVendedor.Ativo.HasValue && SelectedTipoVendedor.Ativo.Value) ? "SIM" : "NÃO"));
+ int num = TipoVendedoresFiltrados.IndexOf(SelectedTipoVendedor);
+ TipoVendedores.Remove(SelectedTipoVendedor);
+ TipoVendedoresFiltrados.Remove(SelectedTipoVendedor);
+ TipoVendedoresFiltrados = new ObservableCollection<TipoVendedor>(TipoVendedoresFiltrados);
+ if (TipoVendedoresFiltrados.Count > 0)
+ {
+ SelectedTipoVendedor = ((num < TipoVendedoresFiltrados.Count) ? TipoVendedoresFiltrados.ElementAt(num) : TipoVendedoresFiltrados.Last());
+ }
+ else
+ {
+ SelectedTipoVendedor = new TipoVendedor();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Recursos.TipoVendedor = TipoVendedores;
+ Loading(isLoading: false);
+ ToggleSnackBar("TIPO VENDEDOR EXCLUÍDO COM SUCESSO");
+ }
+ }
+
+ internal async Task<List<TipoVendedor>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarTipoVendedor(value));
+ }
+
+ public List<TipoVendedor> FiltrarTipoVendedor(string filter)
+ {
+ TipoVendedoresFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<TipoVendedor>(TipoVendedores) : new ObservableCollection<TipoVendedor>(from x in TipoVendedores
+ where ValidationHelper.RemoveDiacritics(x.Descricao.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ativo descending, x.Descricao
+ select x));
+ SelectedTipoVendedor = TipoVendedoresFiltrados.FirstOrDefault();
+ return TipoVendedoresFiltrados.ToList();
+ }
+
+ public void SelecionaTipoVendedor(TipoVendedor tipoVendedor)
+ {
+ SelectedTipoVendedor = tipoVendedor;
+ }
+
+ private void WorkOnSelectedTipoVendedor(TipoVendedor value, bool registrar = true)
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Invalid comparison between Unknown and I4
+ //IL_010f: Unknown result type (might be due to invalid IL or missing references)
+ CancelTipoVendedor = (TipoVendedor)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelTipoVendedor) : ((object)(TipoVendedor)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 14))
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU TIPO VENDEDOR \"" + value.Descricao + "\"", ((DomainBase)value).Id, (TipoTela)14, string.Format("ID: {0}\nATIVO: {1}", ((DomainBase)value).Id, (value.Ativo.HasValue && value.Ativo.Value) ? "SIM" : "NÃO"));
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)14;
+ TipoVendedor selectedTipoVendedor = SelectedTipoVendedor;
+ if (((selectedTipoVendedor != null) ? new long?(((DomainBase)selectedTipoVendedor).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedTipoVendedor = ((IEnumerable<TipoVendedor>)TipoVendedoresFiltrados).FirstOrDefault((Func<TipoVendedor, bool>)((TipoVendedor x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/UsuarioViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/UsuarioViewModel.cs
new file mode 100644
index 0000000..f8f20d8
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/UsuarioViewModel.cs
@@ -0,0 +1,684 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using Agger.Registro;
+using Gestor.Application.Actions;
+using Gestor.Application.Drawers;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Helpers;
+using Gestor.Common.Security;
+using Gestor.Common.Validation;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using MaterialDesignThemes.Wpf;
+using Newtonsoft.Json;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class UsuarioViewModel : BaseSegurosViewModel
+{
+ private readonly UsuarioServico _servico;
+
+ private readonly PermissaoUsuarioServico _permissaoUsuarioServico;
+
+ public Usuario CancelUsuario;
+
+ private string _inicioAcesso;
+
+ private string _fimAcesso;
+
+ private Usuario _selectedUsuario;
+
+ private Empresa _selectedFilial;
+
+ private bool _cartaoCriado;
+
+ private ObservableCollection<Usuario> _usuariosFiltrados = new ObservableCollection<Usuario>();
+
+ private bool _isExpanded;
+
+ private bool _enableGrid = true;
+
+ private Visibility _horarioAcessoVisible;
+
+ private List<Empresa> _empresas = Recursos.Empresas;
+
+ private string _confirmaSenha;
+
+ private string _labelCartao;
+
+ public static DrawerHost Drawer { get; set; }
+
+ public List<PermissaoUsuario> PermissaoUsuario { get; set; }
+
+ public List<Usuario> Usuarios { get; set; }
+
+ public string InicioAcesso
+ {
+ get
+ {
+ return _inicioAcesso;
+ }
+ set
+ {
+ _inicioAcesso = value;
+ OnPropertyChanged("InicioAcesso");
+ }
+ }
+
+ public string FimAcesso
+ {
+ get
+ {
+ return _fimAcesso;
+ }
+ set
+ {
+ _fimAcesso = value;
+ OnPropertyChanged("FimAcesso");
+ }
+ }
+
+ public Usuario SelectedUsuario
+ {
+ get
+ {
+ return _selectedUsuario;
+ }
+ set
+ {
+ _selectedUsuario = value;
+ WorkOnSelectedUsuario(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedUsuario");
+ }
+ }
+
+ public Empresa SelectedFilial
+ {
+ get
+ {
+ return _selectedFilial;
+ }
+ set
+ {
+ _selectedFilial = value;
+ OnPropertyChanged("SelectedFilial");
+ }
+ }
+
+ public bool CartaoCriado
+ {
+ get
+ {
+ return _cartaoCriado;
+ }
+ set
+ {
+ _cartaoCriado = value;
+ OnPropertyChanged("CartaoCriado");
+ }
+ }
+
+ public ObservableCollection<Usuario> UsuariosFiltrados
+ {
+ get
+ {
+ return _usuariosFiltrados;
+ }
+ set
+ {
+ _usuariosFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("UsuariosFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public bool EnableGrid
+ {
+ get
+ {
+ return _enableGrid;
+ }
+ set
+ {
+ _enableGrid = value;
+ OnPropertyChanged("EnableGrid");
+ }
+ }
+
+ public Visibility HorarioAcessoVisible
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _horarioAcessoVisible;
+ }
+ 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)
+ _horarioAcessoVisible = value;
+ OnPropertyChanged("HorarioAcessoVisible");
+ }
+ }
+
+ public List<Empresa> Empresas
+ {
+ get
+ {
+ return _empresas;
+ }
+ set
+ {
+ _empresas = value;
+ OnPropertyChanged("Empresas");
+ }
+ }
+
+ public Visibility AddUsuarioCentralSeguradoVisibility { get; set; } = (Visibility)(string.IsNullOrEmpty(Connection.UrlCentralSegurado) ? 2 : 0);
+
+
+ private string SenhaOriginal { get; set; }
+
+ public string ConfirmaSenha
+ {
+ get
+ {
+ return _confirmaSenha;
+ }
+ set
+ {
+ _confirmaSenha = value;
+ OnPropertyChanged("ConfirmaSenha");
+ }
+ }
+
+ public string LabelCartao
+ {
+ get
+ {
+ return _labelCartao;
+ }
+ set
+ {
+ _labelCartao = value;
+ OnPropertyChanged("LabelCartao");
+ }
+ }
+
+ public UsuarioViewModel()
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ _servico = new UsuarioServico();
+ _permissaoUsuarioServico = new PermissaoUsuarioServico();
+ base.EnableMenu = true;
+ }
+
+ private async Task BuscaPermissao()
+ {
+ PermissaoUsuario = await _permissaoUsuarioServico.PermissUsuario(Recursos.Usuario);
+ }
+
+ public async Task Seleciona()
+ {
+ HorarioAcessoVisible = (Visibility)(Restricao((TipoRestricao)94) ? 2 : 0);
+ await PermissaoTela((TipoTela)16);
+ await SelecionaUsuarios();
+ }
+
+ public async Task VerificaUsuarioAdmCentralSegurado()
+ {
+ await BuscaAlteracaoUsuarios(((DomainBase)SelectedUsuario).Id);
+ }
+
+ private async Task CarregarUsuarios()
+ {
+ Usuarios = (from x in await new BaseServico().CarregarUsuarios()
+ where !x.Excluido && x.PermissaoAggilizador != 4
+ orderby x.Nome
+ select x).ToList();
+ UsuariosFiltrados = new ObservableCollection<Usuario>(Usuarios);
+ await BuscaPermissao();
+ }
+
+ private async Task SelecionaUsuarios()
+ {
+ EnableGrid = false;
+ Loading(isLoading: true);
+ await CarregarUsuarios();
+ if (UsuariosFiltrados.Count > 0)
+ {
+ await SelecionaUsuario(UsuariosFiltrados.First());
+ }
+ else
+ {
+ SelectedUsuario = new Usuario
+ {
+ Segunda = true,
+ Terca = true,
+ Quarta = true,
+ Quinta = true,
+ Sexta = true,
+ Sabado = true,
+ Domingo = true
+ };
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Loading(isLoading: false);
+ EnableGrid = true;
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ if (SenhaOriginal == null || SenhaOriginal != SelectedUsuario.Senha)
+ {
+ string b = new Token().Decrypt(SelectedUsuario.Senha) ?? SelectedUsuario.Senha;
+ if (string.IsNullOrWhiteSpace(ConfirmaSenha))
+ {
+ errors.Add(new KeyValuePair<string, string>("ConfirmaSenha|CONFIRMAÇÃO SENHA", "OBRIGATÓRIO"));
+ }
+ else if (!string.Equals(ConfirmaSenha, b))
+ {
+ errors.Add(new KeyValuePair<string, string>("ConfirmaSenha|CONFIRMAÇÃO SENHA", "INVÁLIDO"));
+ }
+ }
+ List<Usuario> list = (string.IsNullOrWhiteSpace(SelectedUsuario.Login) ? new List<Usuario>() : (await new BaseServico().BuscarUsuarioPorLoginInteiro(SelectedUsuario.Login)));
+ foreach (Usuario item in list)
+ {
+ if (((DomainBase)item).Id != ((DomainBase)SelectedUsuario).Id)
+ {
+ errors.Add(new KeyValuePair<string, string>("Login", "O LOGIN JÁ ESTÁ CADASTRADO PARA O USUÁRIO \"" + item.Nome + "\"."));
+ }
+ }
+ if (SelectedUsuario.InicioAcesso.HasValue && !SelectedUsuario.FimAcesso.HasValue)
+ {
+ errors.Add(new KeyValuePair<string, string>("FIM DO ACESSO", "NECESSÁRIO PREENCHER O CAMPO FIM DO ACESSO!"));
+ }
+ if (!SelectedUsuario.InicioAcesso.HasValue && SelectedUsuario.FimAcesso.HasValue)
+ {
+ errors.Add(new KeyValuePair<string, string>("INÍCIO DO ACESSO", "NECESSÁRIO PREENCHER O CAMPO INÍCIO DO ACESSO!"));
+ }
+ bool flag = !string.IsNullOrWhiteSpace(SelectedUsuario.Documento);
+ if (flag)
+ {
+ flag = await new BaseServico().BuscarUsuarioMesmoDocumento(ValidationHelper.OnlyNumber(SelectedUsuario.Documento), ((DomainBase)SelectedUsuario).Id, SelectedUsuario.IdEmpresa);
+ }
+ if (flag)
+ {
+ errors.Add(new KeyValuePair<string, string>("Documento", "O DOCUMENTO JÁ ESTÁ SENDO USADO EM OUTRO USUÁRIO"));
+ }
+ return errors;
+ }
+
+ public void Incluir()
+ {
+ //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_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0022: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0046: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0052: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0071: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0082: Expected O, but got Unknown
+ SelectedUsuario = new Usuario
+ {
+ IdEmpresa = Recursos.Usuario.IdEmpresa,
+ Segunda = true,
+ Terca = true,
+ Quarta = true,
+ Quinta = true,
+ Sexta = true,
+ Sabado = true,
+ Domingo = true,
+ Excluido = false,
+ FiltroInicial = (TipoFiltroCliente)0
+ };
+ SenhaOriginal = null;
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ if (DateTime.TryParse(InicioAcesso, out var result) && DateTime.TryParse(FimAcesso, out var result2))
+ {
+ SelectedUsuario.InicioAcesso = result;
+ SelectedUsuario.FimAcesso = result2;
+ }
+ else
+ {
+ SelectedUsuario.InicioAcesso = null;
+ SelectedUsuario.FimAcesso = null;
+ }
+ SelectedUsuario.Senha = ((!string.IsNullOrEmpty(SelectedUsuario.Senha)) ? SelectedUsuario.Senha : SenhaOriginal);
+ List<KeyValuePair<string, string>> errorMessages = SelectedUsuario.Validate();
+ List<KeyValuePair<string, string>> list = errorMessages;
+ list.AddRange(await Validate());
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ SelectedUsuario.Senha = new Token().AggerEncrypt(SelectedUsuario.Senha);
+ SelectedUsuario.IdEmpresa = ((SelectedUsuario.IdEmpresa == 0L) ? Recursos.Usuario.IdEmpresa : SelectedUsuario.IdEmpresa);
+ bool usuarioAlterado = await BuscaAlteracaoUsuarios(((DomainBase)SelectedUsuario).Id);
+ string acao = ((((DomainBase)SelectedUsuario).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Usuario value = await _servico.Save(SelectedUsuario);
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ RegistrarAcao(acao + " USUÁRIO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)16, $"ID: {((DomainBase)value).Id}");
+ if (usuarioAlterado)
+ {
+ await AddUsuarioAdiministadorCentralSegurado();
+ }
+ await CarregarUsuarios();
+ SelectedUsuario = ((IEnumerable<Usuario>)UsuariosFiltrados).FirstOrDefault((Func<Usuario, bool>)((Usuario x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ Recursos.Usuarios = Usuarios;
+ ConfirmaSenha = "";
+ Alterar(alterar: false);
+ ToggleSnackBar("USUÁRIO SALVO COM SUCESSO");
+ IsExpanded = true;
+ return null;
+ }
+
+ public async Task CancelarAlteracao()
+ {
+ await CarregarUsuarios();
+ if (UsuariosFiltrados.Any())
+ {
+ Usuario cancelUsuario = CancelUsuario;
+ long id = ((cancelUsuario != null) ? ((DomainBase)cancelUsuario).Id : 0);
+ SelectedUsuario = ((IEnumerable<Usuario>)UsuariosFiltrados).FirstOrDefault((Func<Usuario, bool>)((Usuario x) => ((DomainBase)x).Id == id));
+ }
+ else
+ {
+ SelectedUsuario = new Usuario();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Alterar(alterar: false);
+ ConfirmaSenha = "";
+ }
+
+ public async Task Excluir()
+ {
+ if (SelectedUsuario == null || ((DomainBase)SelectedUsuario).Id == 0L)
+ {
+ return;
+ }
+ if (await new VendedorUsuarioServico().FindVinculoByUsuario(((DomainBase)SelectedUsuario).Id))
+ {
+ await ShowMessage("O USUÁRIO POSSUI VÍNCULO DE VENDEDOR, REMOVA O VÍNCULO ANTES DE EXCLUIR.");
+ }
+ else
+ {
+ if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO")))
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ if (!(await _servico.Delete(SelectedUsuario)))
+ {
+ Loading(isLoading: false);
+ return;
+ }
+ RegistrarAcao("EXCLUIU USUÁRIO \"" + SelectedUsuario.Nome + "\"", ((DomainBase)SelectedUsuario).Id, (TipoTela)16, $"ID: {((DomainBase)SelectedUsuario).Id}");
+ await CarregarUsuarios();
+ if (UsuariosFiltrados.Any())
+ {
+ SelectedUsuario = UsuariosFiltrados.FirstOrDefault();
+ }
+ else
+ {
+ SelectedUsuario = new Usuario();
+ Alterar(alterar: false);
+ base.EnableMenu = false;
+ }
+ Loading(isLoading: false);
+ ToggleSnackBar("USUÁRIO EXCLUÍDO COM SUCESSO");
+ }
+ }
+
+ 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.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby !x.Excluido descending, x.Nome
+ select x));
+ return UsuariosFiltrados.ToList();
+ }
+
+ public async Task SelecionaUsuario(Usuario usuario)
+ {
+ Usuario val = await _servico.BuscarUsuarioPorId(((DomainBase)usuario).Id);
+ val.Segunda = val.Segunda.GetValueOrDefault(true);
+ val.Terca = val.Terca.GetValueOrDefault(true);
+ val.Quarta = val.Quarta.GetValueOrDefault(true);
+ val.Quinta = val.Quinta.GetValueOrDefault(true);
+ val.Sexta = val.Sexta.GetValueOrDefault(true);
+ val.Sabado = val.Sabado.GetValueOrDefault(true);
+ val.Domingo = val.Domingo.GetValueOrDefault(true);
+ if (((DomainBase)Recursos.Usuario).Id == ((DomainBase)usuario).Id)
+ {
+ val.Senha = new Token().AggerDecrypt(val.Senha);
+ SenhaOriginal = val.Senha;
+ ConfirmaSenha = "";
+ DomainBase.Copy<Usuario, Usuario>(UsuariosFiltrados.First((Usuario x) => ((DomainBase)x).Id == ((DomainBase)usuario).Id), val);
+ }
+ SelectedUsuario = UsuariosFiltrados.First((Usuario x) => ((DomainBase)x).Id == ((DomainBase)usuario).Id);
+ }
+
+ public async Task OpenPermissao()
+ {
+ bool flag = SelectedUsuario == null;
+ if (flag)
+ {
+ flag = await ShowMessage("É NECESSÁRIO SELECIONAR UM USUÁRIO!");
+ }
+ if (!flag)
+ {
+ Gestor.Application.Actions.Actions.AtualizaUsuario = (Action)Delegate.Remove(Gestor.Application.Actions.Actions.AtualizaUsuario, new Action(AtualizaUsuario));
+ Gestor.Application.Actions.Actions.AtualizaUsuario = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.AtualizaUsuario, new Action(AtualizaUsuario));
+ ShowDrawer(new PermissaoUsuarioDrawer(SelectedUsuario), 0, close: false);
+ }
+ }
+
+ public async void AtualizaUsuario()
+ {
+ if (!base.EnableFields)
+ {
+ await CarregarUsuarios();
+ }
+ }
+
+ public async Task OpenVinculo()
+ {
+ bool flag = SelectedUsuario == null;
+ if (flag)
+ {
+ flag = await ShowMessage("É NECESSÁRIO SELECIONAR UM USUÁRIO!");
+ }
+ if (!flag)
+ {
+ ShowDrawer(new VinculoVendedorDrawer(SelectedUsuario), 0);
+ }
+ }
+
+ private void WorkOnSelectedUsuario(Usuario value, bool registrar = true)
+ {
+ //IL_0035: 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: Invalid comparison between Unknown and I4
+ //IL_00f9: Unknown result type (might be due to invalid IL or missing references)
+ CartaoCriado = false;
+ CancelUsuario = (Usuario)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelUsuario) : ((object)(Usuario)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L)
+ {
+ return;
+ }
+ value.Senha = EncryptionHelper.Decrypt(value.Senha);
+ if (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 16)
+ {
+ return;
+ }
+ if (registrar)
+ {
+ RegistrarAcao("ACESSOU USUÁRIO \"" + value.Nome + "\"", ((DomainBase)value).Id, (TipoTela)16, $"ID USUÁRIO: {((DomainBase)value).Id}");
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)16;
+ Usuario selectedUsuario = SelectedUsuario;
+ if (((selectedUsuario != null) ? new long?(((DomainBase)selectedUsuario).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedUsuario = ((IEnumerable<Usuario>)UsuariosFiltrados).FirstOrDefault((Func<Usuario, bool>)((Usuario x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ if (SelectedUsuario.InicioAcesso.HasValue && SelectedUsuario.FimAcesso.HasValue)
+ {
+ InicioAcesso = SelectedUsuario.InicioAcesso.Value.ToString("HH:mm");
+ FimAcesso = SelectedUsuario.FimAcesso.Value.ToString("HH:mm");
+ }
+ if (!SelectedUsuario.InicioAcesso.HasValue && !SelectedUsuario.FimAcesso.HasValue)
+ {
+ InicioAcesso = null;
+ FimAcesso = null;
+ }
+ CartaoCriado = !string.IsNullOrEmpty(value.Visita);
+ LabelCartao = (CartaoCriado ? "ATUALIZAR CARTÃO" : "CRIAR CARTÃO");
+ }
+
+ public async Task CriarCartao(bool dadosUsuario)
+ {
+ await ShowMessage("CARTÃO CRIADO/ATUALIZADO COM SUCESSO");
+ }
+
+ public async Task AlterarUsuario()
+ {
+ if (SelectedUsuario != null)
+ {
+ Usuario val = await _servico.BuscarUsuarioPorId(((DomainBase)SelectedUsuario).Id);
+ SenhaOriginal = new Token().AggerDecrypt(val.Senha);
+ await SelecionaUsuario(SelectedUsuario);
+ }
+ }
+
+ private async Task<bool> BuscaAlteracaoUsuarios(long idUsuario)
+ {
+ Usuario val = await new UsuarioServico().BuscarUsuarioPorId(idUsuario);
+ bool usuarioAlteradoADMCentral = val != null && ((val != null) ? new bool?(val.AdministradorCentralSegurado) : null) != SelectedUsuario.AdministradorCentralSegurado;
+ bool novoUsuarioADMCentral = !usuarioAlteradoADMCentral && SelectedUsuario.AdministradorCentralSegurado && ((DomainBase)SelectedUsuario).Id == 0;
+ List<Usuario> list = (from x in Usuarios
+ where x.AdministradorCentralSegurado
+ orderby x.Nome
+ select x).ToList();
+ if (usuarioAlteradoADMCentral && !novoUsuarioADMCentral && list.Count == 0 && !(await ShowMessage("ESTE USUÁRIO É O ÚNICO ADM DA CENTRAL DO SEGURADO.\nTEM CERTEZA QUE DESEJA REMOVER?", "SIM", "CANCELAR")))
+ {
+ CancelarAlteracao();
+ return false;
+ }
+ if ((novoUsuarioADMCentral || usuarioAlteradoADMCentral) && string.IsNullOrEmpty(Connection.UrlCentralSegurado))
+ {
+ if (SelectedUsuario != null)
+ {
+ SelectedUsuario.AdministradorCentralSegurado = false;
+ }
+ await ShowMessage("NÃO FOI POSSÍVEL ADICIONAR UM USUÁRIO ADM CENTRAL SEGURADO, POR FAVOR ENTRE EM CONTATO COM O SUPORTE AGGER. \nURL AUSENTE!");
+ return false;
+ }
+ return usuarioAlteradoADMCentral || novoUsuarioADMCentral;
+ }
+
+ public async Task AddUsuarioAdiministadorCentralSegurado()
+ {
+ if (SelectedUsuario == null)
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ string message = "USUÁRIO CADASTRADO/ALTERADO COM SUCESSO!";
+ try
+ {
+ string text = ((SelectedUsuario.Telefone == null) ? string.Empty : ("(" + SelectedUsuario.Prefixo + ") " + SelectedUsuario.Telefone));
+ Token val = new Token();
+ UsuarioCentralSegurado val2 = new UsuarioCentralSegurado
+ {
+ Id = "",
+ Senha = "",
+ Serial = val.Encrypt(Recursos.Empresa.Serial),
+ FornecedorId = ApplicationHelper.IdFornecedor,
+ Nome = val.Encrypt(SelectedUsuario.Nome),
+ Documento = val.Encrypt(SelectedUsuario.Documento.Clear()),
+ Email = val.Encrypt(SelectedUsuario.Email),
+ IdEmpresa = SelectedUsuario.IdEmpresa,
+ Telefone = val.Encrypt(text),
+ Rua = ((((EnderecoBase)SelectedUsuario).Cidade != null) ? val.Encrypt(((EnderecoBase)SelectedUsuario).Endereco) : string.Empty),
+ Numero = ((((EnderecoBase)SelectedUsuario).Cidade != null) ? val.Encrypt(((EnderecoBase)SelectedUsuario).Numero) : string.Empty),
+ Bairro = ((((EnderecoBase)SelectedUsuario).Cidade != null) ? val.Encrypt(((EnderecoBase)SelectedUsuario).Bairro) : string.Empty),
+ Cidade = ((((EnderecoBase)SelectedUsuario).Cidade != null) ? val.Encrypt(((EnderecoBase)SelectedUsuario).Cidade) : string.Empty),
+ Estado = ((((EnderecoBase)SelectedUsuario).Cidade != null) ? val.Encrypt(((EnderecoBase)SelectedUsuario).Estado) : string.Empty),
+ Cep = ((((EnderecoBase)SelectedUsuario).Cidade != null) ? val.Encrypt(((EnderecoBase)SelectedUsuario).Cep) : string.Empty),
+ Corretora = val.Encrypt(Recursos.Empresa.Nome),
+ UriCorretora = val.Encrypt(Connection.UrlCentralSegurado),
+ Admin = SelectedUsuario.AdministradorCentralSegurado
+ };
+ HttpClient client = new HttpClient();
+ try
+ {
+ StringContent val3 = new StringContent(JsonConvert.SerializeObject((object)val2), Encoding.UTF8, "application/json");
+ Uri uri = Address.CentralSegurado.Append("Usuario").Append("AddAggerApp");
+ HttpResponseMessage response = await client.PostAsync(uri, (HttpContent)(object)val3);
+ await _servico.AddCentralSegurado(((DomainBase)SelectedUsuario).Id, response.IsSuccessStatusCode);
+ if (!response.IsSuccessStatusCode)
+ {
+ message = "HOUVE(RAM) O(S) SEGUINTE(S) ERROS: " + (await response.Content.ReadAsStringAsync()).Replace(";", ", ").ToUpper();
+ }
+ }
+ finally
+ {
+ ((IDisposable)client)?.Dispose();
+ }
+ }
+ catch
+ {
+ message = "HOUVERAM ERROS AO CADASTRAR/ALTERAR O USUÁRIO!";
+ }
+ Loading(isLoading: false);
+ await ShowMessage(message);
+ }
+}
diff --git a/Decompiler/Gestor.Application.ViewModels.Ferramentas/VendedorViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Ferramentas/VendedorViewModel.cs
new file mode 100644
index 0000000..8a7f8dd
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.Ferramentas/VendedorViewModel.cs
@@ -0,0 +1,698 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using CsQuery.ExtensionMethods.Internal;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Ferramentas;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Attributes;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.ViewModels.Ferramentas;
+
+public class VendedorViewModel : BaseSegurosViewModel
+{
+ private readonly VendedorServico _servico;
+
+ public Vendedor CancelVendedor;
+
+ private Vendedor _selectedVendedor;
+
+ private GridLength _gridHeight = new GridLength(1.0, (GridUnitType)2);
+
+ private GridLength _gridHeight2 = new GridLength(0.0);
+
+ private ObservableCollection<Vendedor> _vendedoresFiltrados = new ObservableCollection<Vendedor>();
+
+ private bool _isExpanded;
+
+ private VendedorTelefone _selectedTelefone = new VendedorTelefone();
+
+ private ObservableCollection<VendedorTelefone> _telefones = new ObservableCollection<VendedorTelefone>();
+
+ private Repasse _selectedRepasse = new Repasse();
+
+ private ObservableCollection<Repasse> _repasses = new ObservableCollection<Repasse>();
+
+ private string _pesquisa;
+
+ private Visibility _mostrarRamo;
+
+ private ObservableCollection<Ramo> _ramos = new ObservableCollection<Ramo>();
+
+ public List<Vendedor> Vendedores { get; set; }
+
+ public Vendedor SelectedVendedor
+ {
+ get
+ {
+ return _selectedVendedor;
+ }
+ set
+ {
+ _selectedVendedor = value;
+ WorkOnSelectedVendedor(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ OnPropertyChanged("SelectedVendedor");
+ }
+ }
+
+ public GridLength GridHeight
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _gridHeight;
+ }
+ 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)
+ _gridHeight = value;
+ OnPropertyChanged("GridHeight");
+ }
+ }
+
+ public GridLength GridHeight2
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _gridHeight2;
+ }
+ 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)
+ _gridHeight2 = value;
+ OnPropertyChanged("GridHeight2");
+ }
+ }
+
+ private Visibility _visualizacaoPropriaCorretora { get; set; } = (Visibility)2;
+
+
+ public Visibility VisualizacaoPropriaCorretora
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _visualizacaoPropriaCorretora;
+ }
+ set
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ _visualizacaoPropriaCorretora = value;
+ OnPropertyChanged("VisualizacaoPropriaCorretora");
+ }
+ }
+
+ public ObservableCollection<Vendedor> VendedoresFiltrados
+ {
+ get
+ {
+ return _vendedoresFiltrados;
+ }
+ set
+ {
+ _vendedoresFiltrados = value;
+ IsExpanded = value != null && value.Count > 0;
+ OnPropertyChanged("VendedoresFiltrados");
+ }
+ }
+
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ _isExpanded = value;
+ OnPropertyChanged("IsExpanded");
+ }
+ }
+
+ public VendedorTelefone SelectedTelefone
+ {
+ get
+ {
+ return _selectedTelefone;
+ }
+ set
+ {
+ _selectedTelefone = value;
+ OnPropertyChanged("SelectedTelefone");
+ }
+ }
+
+ public ObservableCollection<VendedorTelefone> Telefones
+ {
+ get
+ {
+ return _telefones;
+ }
+ set
+ {
+ _telefones = value;
+ OnPropertyChanged("Telefones");
+ }
+ }
+
+ public Repasse SelectedRepasse
+ {
+ get
+ {
+ return _selectedRepasse;
+ }
+ set
+ {
+ _selectedRepasse = value;
+ OnPropertyChanged("SelectedRepasse");
+ }
+ }
+
+ public ObservableCollection<Repasse> Repasses
+ {
+ get
+ {
+ return _repasses;
+ }
+ set
+ {
+ //IL_0025: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002f: Expected O, but got Unknown
+ if (value != null && value.Count > 0)
+ {
+ foreach (Repasse item in value)
+ {
+ if (item.Ramo == null)
+ {
+ item.Ramo = new Ramo();
+ }
+ }
+ }
+ _repasses = value;
+ OnPropertyChanged("Repasses");
+ }
+ }
+
+ public string Pesquisa
+ {
+ get
+ {
+ return _pesquisa;
+ }
+ set
+ {
+ _pesquisa = value;
+ OnPropertyChanged("Pesquisa");
+ }
+ }
+
+ public Visibility MostrarRamo
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _mostrarRamo;
+ }
+ 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)
+ _mostrarRamo = value;
+ OnPropertyChanged("MostrarRamo");
+ }
+ }
+
+ public ObservableCollection<Ramo> Ramos
+ {
+ get
+ {
+ return _ramos;
+ }
+ set
+ {
+ _ramos = value;
+ OnPropertyChanged("Ramos");
+ }
+ }
+
+ public List<TipoRepasse> TiposRepasseFiltrados => Enum.GetValues(typeof(TipoRepasse)).Cast<TipoRepasse>().Where(delegate(TipoRepasse tipo)
+ {
+ //IL_0031: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0037: Expected O, but got Unknown
+ //IL_0054: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0063: Unknown result type (might be due to invalid IL or missing references)
+ TipoAttribute val = (TipoAttribute)typeof(TipoRepasse).GetField(((object)(TipoRepasse)(ref tipo)).ToString()).GetCustomAttributes(typeof(TipoAttribute), inherit: false).FirstOrDefault();
+ return val == null || val.Tipo == "0" || CoCorretagemAtiva || (TipoRepasse?)tipo == SelectedRepasse.Tipo;
+ })
+ .ToList();
+
+ public bool CoCorretagemAtiva { get; set; } = Recursos.Configuracoes.Any((ConfiguracaoSistema config) => (int)config.Configuracao == 56);
+
+
+ public VendedorViewModel()
+ {
+ //IL_000b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0010: 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_0024: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0046: Expected O, but got Unknown
+ //IL_0052: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005c: Expected O, but got Unknown
+ _servico = new VendedorServico();
+ base.EnableMenu = true;
+ Seleciona();
+ }
+
+ private async void WorkOnSelectedVendedor(Vendedor value, bool registrar = true)
+ {
+ CancelVendedor = (Vendedor)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelVendedor) : ((object)(Vendedor)((DomainBase)value).Clone()));
+ if (value == null || ((DomainBase)value).Id == 0L)
+ {
+ return;
+ }
+ Loading(isLoading: true);
+ Repasses = new ObservableCollection<Repasse>(await _servico.BuscaRepassesPorIdVendedor(((DomainBase)value).Id));
+ Telefones = new ObservableCollection<VendedorTelefone>(await _servico.BuscarTelefonesAsync(((DomainBase)value).Id));
+ Loading(isLoading: false);
+ if (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 15)
+ {
+ return;
+ }
+ if (registrar)
+ {
+ VendedorViewModel vendedorViewModel = this;
+ string descricao = "ACESSOU VENDEDOR \"" + value.Nome + "\"";
+ long id = ((DomainBase)value).Id;
+ TipoTela? tela = (TipoTela)15;
+ object[] obj = new object[8]
+ {
+ ((DomainBase)value).Id,
+ Recursos.Empresas.First((Empresa x) => ((DomainBase)x).Id == ((value.IdEmpresa == 0L) ? 1 : value.IdEmpresa)).Nome,
+ value.Documento,
+ null,
+ null,
+ null,
+ null,
+ null
+ };
+ Banco banco = value.Banco;
+ obj[3] = ((banco != null) ? banco.Nome : null);
+ obj[4] = value.Agencia;
+ obj[5] = value.Conta;
+ obj[6] = value.Desconto;
+ obj[7] = (value.Ativo ? "SIM" : "NÃO");
+ vendedorViewModel.RegistrarAcao(descricao, id, tela, string.Format("ID: {0}\nFILIAL DO VENDEDOR: {1}\nDOCUMENTO: {2}\nBANCO: {3}\nAGÊNCIA: {4}\nCONTA: {5}\nDESCONTO: {6:N2}\nATIVO: {7}", obj));
+ }
+ LastAccessId = ((DomainBase)value).Id;
+ LastAccessTela = (TipoTela)15;
+ Vendedor selectedVendedor = SelectedVendedor;
+ if (((selectedVendedor != null) ? new long?(((DomainBase)selectedVendedor).Id) : null) != ((DomainBase)value).Id)
+ {
+ SelectedVendedor = ((IEnumerable<Vendedor>)VendedoresFiltrados).FirstOrDefault((Func<Vendedor, bool>)((Vendedor x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ }
+ VendedorViewModel vendedorViewModel2 = this;
+ Vendedor selectedVendedor2 = SelectedVendedor;
+ vendedorViewModel2.VisualizacaoPropriaCorretora = (Visibility)((selectedVendedor2 == null || !selectedVendedor2.Corretora) ? 2 : 0);
+ if (((DomainBase)Recursos.Usuario).Id == 0L)
+ {
+ Vendedor selectedVendedor3 = SelectedVendedor;
+ if (selectedVendedor3 != null && selectedVendedor3.Corretora)
+ {
+ _alterarPermissEnabled = true;
+ base.EnableAlterar = true;
+ }
+ else
+ {
+ _alterarPermissEnabled = false;
+ base.EnableAlterar = false;
+ }
+ }
+ }
+
+ private async void Seleciona()
+ {
+ Loading(isLoading: true);
+ await PermissaoTela((TipoTela)15);
+ await SelecionaVendedores();
+ await SelecionaRamos();
+ Loading(isLoading: false);
+ }
+
+ private async Task SelecionaVendedores(bool selecionar = true)
+ {
+ List<Vendedor> list = await new BaseServico().BuscarVendedoresAsync();
+ Vendedores = (from x in list
+ where Recursos.Usuario.IdEmpresa == 1 || x.IdEmpresa == Recursos.Usuario.IdEmpresa
+ orderby x.Ativo descending, x.Nome
+ select x).ToList();
+ VendedoresFiltrados = new ObservableCollection<Vendedor>(Vendedores);
+ if (selecionar)
+ {
+ SelectedVendedor = VendedoresFiltrados.FirstOrDefault();
+ }
+ Recursos.Vendedores = list;
+ }
+
+ private async Task SelecionaRamos()
+ {
+ MostrarRamo = (Visibility)(Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 20) ? 2 : 0);
+ Ramos.Add(new Ramo
+ {
+ Nome = "TODOS OS RAMOS"
+ });
+ List<Ramo> source = await new BaseServico().BuscarRamosAsync();
+ ExtensionMethods.AddRange<Ramo>((ICollection<Ramo>)Ramos, (IEnumerable<Ramo>)(from x in source
+ where x.Ativo
+ orderby x.Nome
+ select x));
+ }
+
+ public void Incluir()
+ {
+ //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_000d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0026: Expected O, but got Unknown
+ SelectedVendedor = new Vendedor
+ {
+ Ativo = true,
+ Desconto = default(decimal)
+ };
+ Telefones = new ObservableCollection<VendedorTelefone>();
+ Repasses = new ObservableCollection<Repasse>();
+ Alterar(alterar: true);
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar()
+ {
+ SelectedVendedor.Telefones = Telefones.ToList();
+ List<KeyValuePair<string, string>> errorMessages = SelectedVendedor.Validate();
+ List<KeyValuePair<string, string>> list = errorMessages;
+ list.AddRange(await Validate());
+ if (errorMessages.Count > 0)
+ {
+ return errorMessages;
+ }
+ SelectedVendedor.Telefones = Telefones.Where((VendedorTelefone x) => !string.IsNullOrEmpty(x.Nome)).ToList();
+ List<Repasse> repassesValidos = Repasses.ToList().Where(delegate(Repasse x)
+ {
+ List<KeyValuePair<string, string>> list2 = x.Validate();
+ return list2 != null && list2.Count == 0;
+ }).ToList();
+ if (repassesValidos.Count < Repasses.Count && !(await ShowMessage("HÁ REPASSES INVÁLIDOS, DESEJA PROSSEGUIR?" + Environment.NewLine + "CASO PROSSIGA OS REPASSES INVÁLIDOS NÃO SERÃO SALVOS.", "SIM", "NÃO")))
+ {
+ Repasses.ToList().ForEach(delegate(Repasse x)
+ {
+ errorMessages.AddRange(x.Validate());
+ });
+ return errorMessages;
+ }
+ Repasses = new ObservableCollection<Repasse>(repassesValidos);
+ string acao = ((((DomainBase)SelectedVendedor).Id == 0L) ? "INCLUIU" : "ALTEROU");
+ Vendedor value = await _servico.Save(SelectedVendedor, Repasses.ToList());
+ if (!_servico.Sucesso)
+ {
+ return null;
+ }
+ VendedorViewModel vendedorViewModel = this;
+ string descricao = acao + " VENDEDOR \"" + value.Nome + "\"";
+ long id = ((DomainBase)value).Id;
+ TipoTela? tela = (TipoTela)15;
+ object[] obj = new object[8]
+ {
+ ((DomainBase)value).Id,
+ Recursos.Empresas.First((Empresa x) => ((DomainBase)x).Id == ((value.IdEmpresa == 0L) ? 1 : value.IdEmpresa)).Nome,
+ value.Documento,
+ null,
+ null,
+ null,
+ null,
+ null
+ };
+ Banco banco = value.Banco;
+ obj[3] = ((banco != null) ? banco.Nome : null);
+ obj[4] = value.Agencia;
+ obj[5] = value.Conta;
+ obj[6] = value.Desconto;
+ obj[7] = (value.Ativo ? "SIM" : "NÃO");
+ vendedorViewModel.RegistrarAcao(descricao, id, tela, string.Format("ID: {0}\nFILIAL DO VENDEDOR: {1}\nDOCUMENTO: {2}\nBANCO: {3}\nAGÊNCIA: {4}\nCONTA: {5}\nDESCONTO: {6:N2}\nATIVO: {7}", obj));
+ Pesquisa = string.Empty;
+ SelectedVendedor = null;
+ await SelecionaVendedores(selecionar: false);
+ SelectedVendedor = ((IEnumerable<Vendedor>)VendedoresFiltrados).FirstOrDefault((Func<Vendedor, bool>)((Vendedor x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
+ Recursos.Vendedores = Vendedores;
+ Alterar(alterar: false);
+ ToggleSnackBar("VENDEDOR SALVO COM SUCESSO");
+ return null;
+ }
+
+ public void CancelarAlteracao()
+ {
+ if (CancelVendedor != null && Vendedores.Any((Vendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelVendedor).Id))
+ {
+ DomainBase.Copy<Vendedor, Vendedor>(Vendedores.First((Vendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelVendedor).Id), CancelVendedor);
+ if (VendedoresFiltrados.Count > 0 && VendedoresFiltrados.Any((Vendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelVendedor).Id))
+ {
+ DomainBase.Copy<Vendedor, Vendedor>(VendedoresFiltrados.First((Vendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelVendedor).Id), CancelVendedor);
+ }
+ else
+ {
+ VendedoresFiltrados.Add(CancelVendedor);
+ }
+ VendedoresFiltrados = new ObservableCollection<Vendedor>(VendedoresFiltrados);
+ SelectedVendedor = VendedoresFiltrados.First((Vendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelVendedor).Id);
+ }
+ else
+ {
+ Incluir();
+ }
+ Alterar(alterar: false);
+ }
+
+ public void IncluirTelefone()
+ {
+ //IL_001c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0021: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003a: Expected O, but got Unknown
+ if (SelectedVendedor != null)
+ {
+ if (Telefones == null)
+ {
+ Telefones = new ObservableCollection<VendedorTelefone>();
+ }
+ VendedorTelefone val = new VendedorTelefone
+ {
+ Vendedor = SelectedVendedor,
+ Tipo = (TipoTelefone)1
+ };
+ Telefones.Add(val);
+ SelectedTelefone = val;
+ }
+ }
+
+ public void ExcluirTelefone(VendedorTelefone telefone)
+ {
+ Telefones.Remove(telefone);
+ }
+
+ public void IncluirRepasse()
+ {
+ //IL_001c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0021: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002d: 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_0045: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0051: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0058: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006a: Expected O, but got Unknown
+ if (SelectedVendedor != null)
+ {
+ if (Repasses == null)
+ {
+ Repasses = new ObservableCollection<Repasse>();
+ }
+ Repasse val = new Repasse
+ {
+ Vendedor = SelectedVendedor,
+ Forma = (FormaRepasse)1,
+ Incidencia = (TipoIncidencia)1,
+ Tipo = (TipoRepasse)2,
+ Ativo = true,
+ Ramo = Ramos.First()
+ };
+ Repasses.Insert(0, val);
+ SelectedRepasse = val;
+ }
+ }
+
+ internal async Task<List<Vendedor>> Filtrar(string value)
+ {
+ return await Task.Run(() => FiltrarVendedor(value));
+ }
+
+ public List<Vendedor> FiltrarVendedor(string filter)
+ {
+ VendedoresFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Vendedor>(Vendedores) : new ObservableCollection<Vendedor>(from x in Vendedores
+ where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.Ativo descending, x.Nome
+ select x));
+ SelectedVendedor = VendedoresFiltrados.FirstOrDefault();
+ return VendedoresFiltrados.ToList();
+ }
+
+ private async Task<List<KeyValuePair<string, string>>> Validate()
+ {
+ List<KeyValuePair<string, string>> errors = new List<KeyValuePair<string, string>>();
+ List<Vendedor> source = ((!ValidationHelper.ValidateDocument(SelectedVendedor.Documento)) ? new List<Vendedor>() : (await new BaseServico().BuscarVendedor(SelectedVendedor.Documento)));
+ Vendedor val = ((IEnumerable<Vendedor>)source).FirstOrDefault((Func<Vendedor, bool>)((Vendedor x) => ((DomainBase)x).Id != ((DomainBase)SelectedVendedor).Id && x.Documento == SelectedVendedor.Documento && x.Ativo));
+ if (val != null && Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 7))
+ {
+ errors.Add(new KeyValuePair<string, string>("Documento", "O DOCUMENTO JÁ ESTÁ CADASTRADO PARA O VENDEDOR " + val.Nome + "."));
+ }
+ if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 15))
+ {
+ IEnumerable<Repasse> enumerable = Repasses?.Where((Repasse x) => (int)x.Tipo.GetValueOrDefault() == 2 && (x.ValorNovo > 100m || x.ValorRenovacao > 100m));
+ if (enumerable != null && enumerable.Any())
+ {
+ errors.Add(new KeyValuePair<string, string>("VALOR REPASSE", "O VALOR DE REPASSE NÃO PODE SER SUPERIOR A 100%"));
+ }
+ }
+ ObservableCollection<Repasse> observableCollection = await _servico.BuscaRepassesPorIdVendedor(((DomainBase)SelectedVendedor).Id);
+ if (observableCollection != null && observableCollection.Count > 0)
+ {
+ foreach (Repasse semAlteracao in observableCollection)
+ {
+ if (Repasses.Any(delegate(Repasse repasse)
+ {
+ //IL_002b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0032: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009a: 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_00d5: 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_0110: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0117: Unknown result type (might be due to invalid IL or missing references)
+ if (((DomainBase)semAlteracao).Id == ((DomainBase)repasse).Id)
+ {
+ if (semAlteracao.Tipo == repasse.Tipo && !(semAlteracao.ValorNovo != repasse.ValorNovo) && !(semAlteracao.ValorRenovacao != repasse.ValorRenovacao) && semAlteracao.Incidencia == repasse.Incidencia && semAlteracao.Forma == repasse.Forma && semAlteracao.Base == repasse.Base && semAlteracao.Seguradora == repasse.Seguradora)
+ {
+ if (semAlteracao.Ramo == null)
+ {
+ Ramo ramo = repasse.Ramo;
+ if (ramo != null && ((DomainBase)ramo).Id == 0)
+ {
+ return false;
+ }
+ }
+ Ramo ramo2 = semAlteracao.Ramo;
+ long? num = ((ramo2 != null) ? new long?(((DomainBase)ramo2).Id) : null);
+ Ramo ramo3 = repasse.Ramo;
+ return num != ((ramo3 != null) ? new long?(((DomainBase)ramo3).Id) : null);
+ }
+ return true;
+ }
+ return false;
+ }) && (await _servico.BuscarVendedorParcela(((DomainBase)semAlteracao).Id)).Count > 1)
+ {
+ errors.Add(new KeyValuePair<string, string>("REPASSE", $"O REPASSE, DE ID {((DomainBase)semAlteracao).Id}, NÃO PODE SER ALTERADO POIS JÁ ESTÁ CADASTRADO EM ALGUM DOCUMENTO!"));
+ }
+ }
+ }
+ return errors;
+ }
+
+ public async Task SalvarVinculo(VinculoRepasse vinculo)
+ {
+ await _servico.Save(vinculo);
+ Repasses = new ObservableCollection<Repasse>(await _servico.BuscaRepassesPorIdVendedor(((DomainBase)SelectedVendedor).Id));
+ ToggleSnackBar("VINCULO SALVO COM SUCESSO");
+ }
+
+ public async Task ExcluirVinculo(VinculoRepasse vinculo)
+ {
+ if (await ShowMessage("DESEJA REALMENTE EXCLUIR O VÍNCULO DO REPASSE SELECIONADO?", "SIM", "NÃO"))
+ {
+ await _servico.Delete(vinculo);
+ Repasses = new ObservableCollection<Repasse>(await _servico.BuscaRepassesPorIdVendedor(((DomainBase)SelectedVendedor).Id));
+ ToggleSnackBar("VINCULO EXCLUÍDO COM SUCESSO");
+ }
+ }
+
+ public async Task AtivarInativarVendedor(Vendedor vendedor)
+ {
+ if (vendedor != null && ((DomainBase)vendedor).Id != 0L)
+ {
+ string acao = (vendedor.Ativo ? "INATIVOU VENDEDOR" : "ATIVOU VENDEDOR");
+ vendedor.Ativo = !vendedor.Ativo;
+ vendedor = await _servico.Save(vendedor, Repasses.ToList());
+ VendedorViewModel vendedorViewModel = this;
+ string descricao = acao + " \"" + vendedor.Nome + "\"";
+ long id = ((DomainBase)vendedor).Id;
+ TipoTela? tela = (TipoTela)15;
+ object[] obj = new object[8]
+ {
+ ((DomainBase)vendedor).Id,
+ Recursos.Empresas.First((Empresa x) => ((DomainBase)x).Id == ((vendedor.IdEmpresa == 0L) ? 1 : vendedor.IdEmpresa)).Nome,
+ vendedor.Documento,
+ null,
+ null,
+ null,
+ null,
+ null
+ };
+ Banco banco = vendedor.Banco;
+ obj[3] = ((banco != null) ? banco.Nome : null);
+ obj[4] = vendedor.Agencia;
+ obj[5] = vendedor.Conta;
+ obj[6] = vendedor.Desconto;
+ obj[7] = (vendedor.Ativo ? "SIM" : "NÃO");
+ vendedorViewModel.RegistrarAcao(descricao, id, tela, string.Format("ID: {0}\nFILIAL DO VENDEDOR: {1}\nDOCUMENTO: {2}\nBANCO: {3}\nAGÊNCIA: {4}\nCONTA: {5}\nDESCONTO: {6:N2}\nATIVO: {7}", obj));
+ Pesquisa = string.Empty;
+ SelectedVendedor = null;
+ await SelecionaVendedores(selecionar: false);
+ SelectedVendedor = ((IEnumerable<Vendedor>)VendedoresFiltrados).FirstOrDefault((Func<Vendedor, bool>)((Vendedor x) => ((DomainBase)x).Id == ((DomainBase)vendedor).Id));
+ Recursos.Vendedores = Vendedores;
+ Alterar(alterar: false);
+ ToggleSnackBar("VENDEDOR SALVO COM SUCESSO");
+ }
+ }
+
+ public async Task AtivarInativarRepasse(Repasse repasse)
+ {
+ if (repasse != null && ((DomainBase)repasse).Id != 0L)
+ {
+ string acao = (repasse.Ativo ? "INATIVOU REPASSE" : "ATIVOU REPASSE");
+ repasse.Ativo = !repasse.Ativo;
+ Repasse obj = repasse;
+ Ramo ramo = repasse.Ramo;
+ obj.Ramo = ((ramo != null && ((DomainBase)ramo).Id == 0) ? null : repasse.Ramo);
+ repasse = await _servico.Save(repasse);
+ long id = ((DomainBase)SelectedVendedor).Id;
+ RegistrarAcao(acao + " \"" + SelectedVendedor.Nome + "\"", ((DomainBase)SelectedVendedor).Id, (TipoTela)15, string.Format("ID: {0}\nVALOR NOVO: {1:N2}\nVALOR RENOVAÇÃO: {2:N2}\nATIVO: {3}", ((DomainBase)repasse).Id, repasse.ValorNovo, repasse.ValorRenovacao, repasse.Ativo ? "SIM" : "NÃO"));
+ Pesquisa = string.Empty;
+ SelectedVendedor = null;
+ await SelecionaVendedores(selecionar: false);
+ SelectedVendedor = ((IEnumerable<Vendedor>)VendedoresFiltrados).FirstOrDefault((Func<Vendedor, bool>)((Vendedor x) => ((DomainBase)x).Id == id));
+ Recursos.Vendedores = Vendedores;
+ Alterar(alterar: false);
+ ToggleSnackBar("REPASSE SALVO COM SUCESSO");
+ }
+ }
+}