diff options
Diffstat (limited to 'Gestor.Application/ViewModels/Seguros')
16 files changed, 0 insertions, 15127 deletions
diff --git a/Gestor.Application/ViewModels/Seguros/ApoliceViewModel.cs b/Gestor.Application/ViewModels/Seguros/ApoliceViewModel.cs deleted file mode 100644 index 94fc4be..0000000 --- a/Gestor.Application/ViewModels/Seguros/ApoliceViewModel.cs +++ /dev/null @@ -1,124 +0,0 @@ -using Gestor.Application.Drawers;
-using Gestor.Application.Helpers;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-
-namespace Gestor.Application.ViewModels.Seguros
-{
- public class ApoliceViewModel : BaseApoliceViewModel
- {
- private bool _documentoExcluido;
-
- public bool DocumentoExcluido
- {
- get
- {
- return this._documentoExcluido;
- }
- set
- {
- this._documentoExcluido = value;
- base.OnPropertyChanged("DocumentoExcluido");
- }
- }
-
- public ApoliceViewModel(AcessoApolice acesso, Documento documentoSelecionado, bool invoke = true, long idparcela = 0L)
- {
- long id;
- base.Invoke = invoke;
- base.Acesso = acesso;
- base.DocumentoSelecionado = documentoSelecionado;
- if (invoke)
- {
- Parcela parcelaSelecionada = ConsultaViewModel.ParcelaSelecionada;
- if (parcelaSelecionada != null)
- {
- id = parcelaSelecionada.get_Id();
- }
- else
- {
- id = (long)0;
- }
- }
- else
- {
- id = idparcela;
- }
- base.ParcelaSelecionada = id;
- this.DocumentoExcluido = (base.DocumentoSelecionado != null ? base.DocumentoSelecionado.get_Excluido() : false);
- base.Seleciona(base.DocumentoSelecionado);
- }
-
- public void AbrirInfo()
- {
- base.ShowDrawer(new InfoDrawer(base.SelectedDocumento, true), 0, false);
- }
-
- public async Task Alteracao(bool alterar)
- {
- if (base.AllowEditApolice)
- {
- ObservableCollection<Parcela> parcelas = base.Parcelas;
- if (!parcelas.Any<Parcela>((Parcela x) => x.get_DataRecebimento().HasValue))
- {
- List<VendedorParcela> repasses = base.Repasses;
- if (!repasses.Any<VendedorParcela>((VendedorParcela x) => x.get_DataPagamento().HasValue))
- {
- List<Seguradora> list = Recursos.Seguradoras.Where<Seguradora>((Seguradora x) => {
- if (x.get_Ativo())
- {
- return true;
- }
- return x.get_Id() == base.SelectedDocumento.get_Controle().get_Seguradora().get_Id();
- }).ToList<Seguradora>();
- base.Seguradoras = list;
- base.SeguradorasAnteriores = Recursos.Seguradoras;
- List<Ramo> ramos = Recursos.Ramos.Where<Ramo>((Ramo x) => {
- if (x.get_Ativo())
- {
- return true;
- }
- return x.get_Id() == base.SelectedDocumento.get_Controle().get_Ramo().get_Id();
- }).ToList<Ramo>();
- base.Ramos = ramos;
- List<Produto> produtos = Recursos.Produtos.Where<Produto>((Produto x) => {
- if (x.get_Ativo())
- {
- return true;
- }
- if (base.SelectedDocumento.get_Controle().get_Produto() == null)
- {
- return false;
- }
- return x.get_Id() == base.SelectedDocumento.get_Controle().get_Produto().get_Id();
- }).ToList<Produto>();
- base.Produtos = produtos;
- List<Gestor.Model.Domain.Seguros.Status> statuses = Recursos.Status.Where<Gestor.Model.Domain.Seguros.Status>((Gestor.Model.Domain.Seguros.Status x) => {
- if (x.get_Ativo())
- {
- return true;
- }
- if (base.SelectedDocumento.get_Status() == null)
- {
- return false;
- }
- return x.get_Id() == base.SelectedDocumento.get_Status().get_Id();
- }).ToList<Gestor.Model.Domain.Seguros.Status>();
- base.Status = statuses;
- return;
- }
- }
- }
- await base.ShowMessage("DOCUMENTO POSSUI BAIXAS DE COMISSÃO OU PAGAMENTO DE VENDEDORES.\nNÃO SERÁ POSSÍVEL ALTERAR ALGUMAS INFORMAÇÕES DO DOCUMENTO.\nPARA ISSO, EXCLUA AS BAIXAS E O PAGAMENTO DO VENDEDOR", "OK", "", false);
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/ClienteViewModel.cs b/Gestor.Application/ViewModels/Seguros/ClienteViewModel.cs deleted file mode 100644 index b68e57d..0000000 --- a/Gestor.Application/ViewModels/Seguros/ClienteViewModel.cs +++ /dev/null @@ -1,1787 +0,0 @@ -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.Servicos.Seguros;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Command;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Common.Security;
-using Gestor.Common.Validation;
-using Gestor.Model.API;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Common;
-using Gestor.Model.Domain.Configuracoes;
-using Gestor.Model.Domain.Ferramentas;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Net.Http;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Input;
-
-namespace Gestor.Application.ViewModels.Seguros
-{
- public class ClienteViewModel : BaseSegurosViewModel
- {
- private const int NumeroMaximoCadastros = 9;
-
- private readonly ClienteServico _servico;
-
- private const string AddCentralSegurado = "ADICIONAR CENTRAL SEGURADO";
-
- private const string UpdateCentralSegurado = "ALTERAR DADOS/SENHA CENTRAL SEGURADO";
-
- private bool _visibilityLogAntigo = Recursos.Configuracoes.Any<ConfiguracaoSistema>(new Func<ConfiguracaoSistema, bool>((ConfiguracaoSistema x) => x.get_Configuracao() == 22));
-
- private ObservableCollection<ClienteTelefone> _telefones = new ObservableCollection<ClienteTelefone>();
-
- private ObservableCollection<ClienteEmail> _emails = new ObservableCollection<ClienteEmail>();
-
- private ObservableCollection<ClienteEndereco> _enderecos = new ObservableCollection<ClienteEndereco>();
-
- private ObservableCollection<MaisContato> _contatos = new ObservableCollection<MaisContato>();
-
- private ObservableCollection<ClienteVinculo> _vinculos = new ObservableCollection<ClienteVinculo>();
-
- private Cliente _vinculo;
-
- private bool _isLoading;
-
- private bool _clienteExcluido;
-
- private DateTime? _nascimentoCliente;
-
- private DateTime? _habilitaCliente;
-
- private DateTime? _vencimentoHabCliente;
-
- private DateTime? _expedicaoCliente;
-
- private Cliente _selectedCliente;
-
- private string _fieldNascimento = "NASCIMENTO";
-
- private string _fieldDocumento = "CPF";
-
- private Visibility _visibilityJuridica = Visibility.Collapsed;
-
- private Visibility _visibilityFisica = Visibility.Collapsed;
-
- private bool _enableAddTelephone = true;
-
- private bool _enableAddAddress = true;
-
- private bool _enableAddEmail = true;
-
- private bool _enableAddContact = true;
-
- private string _profissaoText;
-
- private string _atividadeText;
-
- private bool _saving;
-
- private ObservableCollection<OrigemCliente> _origens;
-
- private OrigemCliente _selectedOrigem;
-
- public Visibility AddUsuarioCentralSeguradoVisibility { get; set; } = (string.IsNullOrEmpty(Connection.UrlCentralSegurado) ? Visibility.Collapsed : Visibility.Visible);
-
- public string AtividadeText
- {
- get
- {
- return this._atividadeText;
- }
- set
- {
- this._atividadeText = value;
- base.OnPropertyChanged("AtividadeText");
- }
- }
-
- public bool ClienteExcluido
- {
- get
- {
- return this._clienteExcluido;
- }
- set
- {
- this._clienteExcluido = value;
- base.OnPropertyChanged("ClienteExcluido");
- }
- }
-
- private Cliente ClienteSelecionado
- {
- get;
- set;
- }
-
- public ICommand CommandAddUsuarioCentralSegurado
- {
- get;
- set;
- }
-
- public ObservableCollection<MaisContato> Contatos
- {
- get
- {
- return this._contatos;
- }
- set
- {
- this._contatos = value;
- base.OnPropertyChanged("Contatos");
- }
- }
-
- public ObservableCollection<ClienteEmail> Emails
- {
- get
- {
- return this._emails;
- }
- set
- {
- this._emails = value;
- base.OnPropertyChanged("Emails");
- }
- }
-
- public bool EnableAddAddress
- {
- get
- {
- return this._enableAddAddress;
- }
- set
- {
- this._enableAddAddress = value;
- base.OnPropertyChanged("EnableAddAddress");
- }
- }
-
- public bool EnableAddContact
- {
- get
- {
- return this._enableAddContact;
- }
- set
- {
- this._enableAddContact = value;
- base.OnPropertyChanged("EnableAddContact");
- }
- }
-
- public bool EnableAddEmail
- {
- get
- {
- return this._enableAddEmail;
- }
- set
- {
- this._enableAddEmail = value;
- base.OnPropertyChanged("EnableAddEmail");
- }
- }
-
- public bool EnableAddTelephone
- {
- get
- {
- return this._enableAddTelephone;
- }
- set
- {
- this._enableAddTelephone = value;
- base.OnPropertyChanged("EnableAddTelephone");
- }
- }
-
- public ObservableCollection<ClienteEndereco> Enderecos
- {
- get
- {
- return this._enderecos;
- }
- set
- {
- this._enderecos = value;
- base.OnPropertyChanged("Enderecos");
- }
- }
-
- public DateTime? ExpedicaoCliente
- {
- get
- {
- return this._expedicaoCliente;
- }
- set
- {
- this._expedicaoCliente = value;
- base.OnPropertyChanged("ExpedicaoCliente");
- }
- }
-
- public string FieldDocumento
- {
- get
- {
- return this._fieldDocumento;
- }
- set
- {
- this._fieldDocumento = value;
- base.OnPropertyChanged("FieldDocumento");
- }
- }
-
- public string FieldNascimento
- {
- get
- {
- return this._fieldNascimento;
- }
- set
- {
- this._fieldNascimento = value;
- base.OnPropertyChanged("FieldNascimento");
- }
- }
-
- public DateTime? HabilitaCliente
- {
- get
- {
- return this._habilitaCliente;
- }
- set
- {
- this._habilitaCliente = value;
- base.OnPropertyChanged("HabilitaCliente");
- }
- }
-
- private bool Invoke
- {
- get;
- }
-
- private bool IsJuridica
- {
- get;
- set;
- }
-
- public bool IsLoading
- {
- get
- {
- return this._isLoading;
- }
- set
- {
- this._isLoading = value;
- base.OnPropertyChanged("IsLoading");
- }
- }
-
- public string LabelAddUsuarioCentralSegurado
- {
- get
- {
- if (this.SelectedCliente != null && this.SelectedCliente.get_EstaNaCentralSegurado())
- {
- return "ALTERAR DADOS/SENHA CENTRAL SEGURADO";
- }
- return "ADICIONAR CENTRAL SEGURADO";
- }
- }
-
- public DateTime? NascimentoCliente
- {
- get
- {
- return this._nascimentoCliente;
- }
- set
- {
- this._nascimentoCliente = value;
- base.OnPropertyChanged("NascimentoCliente");
- }
- }
-
- public ObservableCollection<OrigemCliente> Origens
- {
- get
- {
- return this._origens;
- }
- set
- {
- this._origens = value;
- base.OnPropertyChanged("Origens");
- if (this.Origens != null)
- {
- this.SelectedOrigem = this.Origens.FirstOrDefault<OrigemCliente>();
- }
- }
- }
-
- public string ProfissaoText
- {
- get
- {
- return this._profissaoText;
- }
- set
- {
- this._profissaoText = value;
- base.OnPropertyChanged("ProfissaoText");
- }
- }
-
- public bool Salvando
- {
- get;
- set;
- }
-
- public Cliente SelectedCliente
- {
- get
- {
- return this._selectedCliente;
- }
- set
- {
- long? nullable;
- this._selectedCliente = value;
- this.WorkOnSelectedCliente(value);
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedCliente");
- base.OnPropertyChanged("LabelAddUsuarioCentralSegurado");
- }
- }
-
- public OrigemCliente SelectedOrigem
- {
- get
- {
- return this._selectedOrigem;
- }
- set
- {
- this._selectedOrigem = value;
- base.OnPropertyChanged("SelectedOrigem");
- }
- }
-
- public ObservableCollection<ClienteTelefone> Telefones
- {
- get
- {
- return this._telefones;
- }
- set
- {
- this._telefones = value;
- base.OnPropertyChanged("Telefones");
- }
- }
-
- public DateTime? VencimentoHabCliente
- {
- get
- {
- return this._vencimentoHabCliente;
- }
- set
- {
- this._vencimentoHabCliente = value;
- base.OnPropertyChanged("VencimentoHabCliente");
- }
- }
-
- public Cliente Vinculo
- {
- get
- {
- return this._vinculo;
- }
- set
- {
- this._vinculo = value;
- base.OnPropertyChanged("Vinculo");
- }
- }
-
- public ObservableCollection<ClienteVinculo> Vinculos
- {
- get
- {
- return this._vinculos;
- }
- set
- {
- if (value != null && value.Count > 0 && this.SelectedCliente != null)
- {
- foreach (ClienteVinculo clienteVinculo in value)
- {
- if (clienteVinculo.get_Cliente2().get_Id() != this.SelectedCliente.get_Id())
- {
- continue;
- }
- clienteVinculo.set_Parentesco(Funcoes.ParentescoInverso(clienteVinculo.get_Parentesco()));
- }
- }
- this._vinculos = value;
- base.OnPropertyChanged("Vinculos");
- }
- }
-
- public Visibility VisibilityFisica
- {
- get
- {
- return this._visibilityFisica;
- }
- set
- {
- this._visibilityFisica = value;
- base.OnPropertyChanged("VisibilityFisica");
- }
- }
-
- public Visibility VisibilityJuridica
- {
- get
- {
- return this._visibilityJuridica;
- }
- set
- {
- this._visibilityJuridica = value;
- base.OnPropertyChanged("VisibilityJuridica");
- }
- }
-
- public bool VisibilityLogAntigo
- {
- get
- {
- return this._visibilityLogAntigo;
- }
- set
- {
- this._visibilityLogAntigo = value;
- base.OnPropertyChanged("VisibilityLogAntigo");
- }
- }
-
- public ClienteViewModel(Cliente cliente = null, bool invoke = true)
- {
- this.Invoke = invoke;
- this._servico = new ClienteServico();
- this.ClienteSelecionado = cliente ?? MainViewModel.ClienteSelecionado;
- this.SelecionaCliente(this.ClienteSelecionado);
- this.CommandAddUsuarioCentralSegurado = new RelayCommand(() => this.AddUsuarioCentralSegurado());
- }
-
- public async void AbrirLogAntigo()
- {
- base.Loading(true);
- string str = await this._servico.BuscarLogAntigo(this.SelectedCliente.get_Id());
- base.Loading(false);
- if (!string.IsNullOrEmpty(str))
- {
- base.ShowDrawer(new LogSistemaAntigo(this.SelectedCliente.get_Id(), str), 0, false);
- }
- else
- {
- await base.ShowMessage("NÃO HÁ LOG PARA ESSE CLIENTE", "OK", "", false);
- }
- }
-
- public async void AddUsuarioCentralSegurado()
- {
- string str;
- string str1;
- string str2;
- string str3;
- string str4;
- string str5;
- string str6;
- string str7;
- if (this.SelectedCliente != null && this.SelectedCliente.get_Emails().Count != 0)
- {
- base.Loading(true);
- str7 = "CLIENTE CADASTRADO/ALTERADO COM SUCESSO!";
- try
- {
- str = (this.SelectedCliente.get_Telefones().Count == 0 ? string.Empty : string.Concat("(", this.SelectedCliente.get_Telefones()[0].get_Prefixo(), ") ", this.SelectedCliente.get_Telefones()[0].get_Numero()));
- string str8 = str;
- bool count = this.SelectedCliente.get_Enderecos().Count > 0;
- Token token = new Token();
- UsuarioCentralSegurado usuarioCentralSegurado = new UsuarioCentralSegurado();
- usuarioCentralSegurado.set_Id("");
- usuarioCentralSegurado.set_Senha("");
- usuarioCentralSegurado.set_Serial(token.Encrypt(Recursos.Empresa.get_Serial()));
- usuarioCentralSegurado.set_FornecedorId(ApplicationHelper.IdFornecedor);
- usuarioCentralSegurado.set_Nome(token.Encrypt(this.SelectedCliente.get_Nome()));
- usuarioCentralSegurado.set_Documento(token.Encrypt(this.SelectedCliente.get_Documento().Clear()));
- usuarioCentralSegurado.set_Email(token.Encrypt(this.SelectedCliente.get_Emails()[0].get_Email()));
- usuarioCentralSegurado.set_IdEmpresa(this.SelectedCliente.get_IdEmpresa());
- usuarioCentralSegurado.set_Telefone(token.Encrypt(str8));
- str1 = (count ? token.Encrypt(this.SelectedCliente.get_Enderecos()[0].get_Endereco()) : string.Empty);
- usuarioCentralSegurado.set_Rua(str1);
- str2 = (count ? token.Encrypt(this.SelectedCliente.get_Enderecos()[0].get_Numero()) : string.Empty);
- usuarioCentralSegurado.set_Numero(str2);
- str3 = (count ? token.Encrypt(this.SelectedCliente.get_Enderecos()[0].get_Bairro()) : string.Empty);
- usuarioCentralSegurado.set_Bairro(str3);
- str4 = (count ? token.Encrypt(this.SelectedCliente.get_Enderecos()[0].get_Cidade()) : string.Empty);
- usuarioCentralSegurado.set_Cidade(str4);
- str5 = (count ? token.Encrypt(this.SelectedCliente.get_Enderecos()[0].get_Estado()) : string.Empty);
- usuarioCentralSegurado.set_Estado(str5);
- str6 = (count ? token.Encrypt(this.SelectedCliente.get_Enderecos()[0].get_Cep()) : string.Empty);
- usuarioCentralSegurado.set_Cep(str6);
- usuarioCentralSegurado.set_Corretora(token.Encrypt(Recursos.Empresa.get_Nome()));
- usuarioCentralSegurado.set_UriCorretora(token.Encrypt(Connection.UrlCentralSegurado));
- UsuarioCentralSegurado usuarioCentralSegurado1 = usuarioCentralSegurado;
- using (HttpClient httpClient = new HttpClient())
- {
- StringContent stringContent = new StringContent(JsonConvert.SerializeObject(usuarioCentralSegurado1), Encoding.UTF8, "application/json");
- Uri centralSegurado = Address.get_CentralSegurado();
- string[] strArrays = new string[] { "Usuario" };
- Uri uri = centralSegurado.Append(strArrays);
- string[] strArrays1 = new string[] { "AddAggerApp" };
- Uri uri1 = uri.Append(strArrays1);
- HttpResponseMessage httpResponseMessage = await httpClient.PostAsync(uri1, stringContent);
- await this._servico.AddCentralSegurado(this.SelectedCliente.get_Id(), httpResponseMessage.get_IsSuccessStatusCode());
- if (!httpResponseMessage.get_IsSuccessStatusCode())
- {
- string str9 = await httpResponseMessage.get_Content().ReadAsStringAsync();
- str7 = string.Concat("HOUVE(RAM) O(S) SEGUINTE(S) ERROS: ", str9.Replace(";", ", ").ToUpper());
- }
- httpResponseMessage = null;
- }
- httpClient = null;
- }
- catch
- {
- str7 = "HOUVERAM ERROS AO CADASTRAR/ALTERAR O CLIENTE!";
- }
- base.OnPropertyChanged("LabelAddUsuarioCentralSegurado");
- base.Loading(false);
- await base.ShowMessage(str7, "OK", "", false);
- }
- str7 = null;
- }
-
- public async void CancelarAlteracao()
- {
- base.Loading(true);
- this.IsLoading = true;
- base.Alterar(false);
- await this.CarregaCliente(this.ClienteSelecionado);
- this.Salvando = false;
- this.IsLoading = false;
- base.Loading(false);
- }
-
- public async Task CarregaCliente(Cliente value)
- {
- bool count;
- bool flag;
- bool count1;
- bool flag1;
- bool count2;
- bool flag2;
- bool count3;
- Cliente cliente;
- if (value == null || value.get_Id() == 0)
- {
- this.SelectedCliente = null;
- this.Telefones = null;
- this.Enderecos = null;
- this.Emails = null;
- this.Contatos = null;
- this.Vinculos = null;
- this.Origens = null;
- }
- else
- {
- cliente = value;
- if (value.get_Id() != 0)
- {
- cliente = await this._servico.BuscarCliente(value.get_Id());
- Cliente cliente1 = cliente;
- ObservableCollection<ClienteTelefone> observableCollection = await this._servico.BuscarTelefonesAsync(value.get_Id());
- cliente1.set_Telefones(observableCollection);
- cliente1 = null;
- ClienteViewModel clienteViewModel = this;
- ObservableCollection<ClienteTelefone> telefones = cliente.get_Telefones();
- if (telefones != null)
- {
- count = telefones.Count <= 9;
- }
- else
- {
- count = false;
- }
- clienteViewModel.EnableAddTelephone = count;
- cliente1 = cliente;
- ObservableCollection<ClienteEmail> observableCollection1 = await this._servico.BuscarEmailsAsync(value.get_Id());
- cliente1.set_Emails(observableCollection1);
- cliente1 = null;
- ClienteViewModel clienteViewModel1 = this;
- ObservableCollection<ClienteEmail> emails = cliente.get_Emails();
- if (emails != null)
- {
- flag = emails.Count <= 9;
- }
- else
- {
- flag = false;
- }
- clienteViewModel1.EnableAddEmail = flag;
- cliente1 = cliente;
- ObservableCollection<ClienteEndereco> observableCollection2 = await this._servico.BuscarEnderecosAsync(value.get_Id());
- cliente1.set_Enderecos(observableCollection2);
- cliente1 = null;
- ClienteViewModel clienteViewModel2 = this;
- ObservableCollection<ClienteEndereco> enderecos = cliente.get_Enderecos();
- if (enderecos != null)
- {
- count1 = enderecos.Count <= 9;
- }
- else
- {
- count1 = false;
- }
- clienteViewModel2.EnableAddAddress = count1;
- cliente1 = cliente;
- ObservableCollection<MaisContato> observableCollection3 = await this._servico.BuscarContatosAsync(value.get_Id());
- cliente1.set_Contatos(observableCollection3);
- cliente1 = null;
- ClienteViewModel clienteViewModel3 = this;
- ObservableCollection<MaisContato> contatos = cliente.get_Contatos();
- if (contatos != null)
- {
- flag1 = contatos.Count <= 9;
- }
- else
- {
- flag1 = false;
- }
- clienteViewModel3.EnableAddContact = flag1;
- cliente1 = cliente;
- ObservableCollection<ClienteVinculo> observableCollection4 = await this._servico.BuscarVinculosAsync(value.get_Id());
- cliente1.set_Vinculos(observableCollection4);
- cliente1 = null;
- this.Origens = await this._servico.BuscarOrigens(value.get_Id());
- this.Telefones = cliente.get_Telefones();
- ObservableCollection<ClienteTelefone> telefones1 = this.Telefones;
- if (telefones1 != null)
- {
- count2 = telefones1.Count == 0;
- }
- else
- {
- count2 = false;
- }
- if (count2)
- {
- this.IncluirTelefone();
- }
- this.Emails = cliente.get_Emails();
- ObservableCollection<ClienteEmail> emails1 = this.Emails;
- if (emails1 != null)
- {
- flag2 = emails1.Count == 0;
- }
- else
- {
- flag2 = false;
- }
- if (flag2)
- {
- this.IncluirEmail();
- }
- this.Enderecos = cliente.get_Enderecos();
- ObservableCollection<ClienteEndereco> enderecos1 = this.Enderecos;
- if (enderecos1 != null)
- {
- count3 = enderecos1.Count == 0;
- }
- else
- {
- count3 = false;
- }
- if (count3)
- {
- this.IncluirEndereco();
- }
- this.Contatos = cliente.get_Contatos();
- this.Vinculos = cliente.get_Vinculos();
- }
- if (!cliente.get_DocumentoPrincipal().HasValue)
- {
- cliente.set_DocumentoPrincipal(new TipoDocumento?(0));
- }
- if (cliente.get_ResponsavelAssinatura() == null)
- {
- Cliente cliente2 = cliente;
- ResponsavelAssinatura responsavelAssinatura = new ResponsavelAssinatura();
- responsavelAssinatura.set_IdCliente(cliente.get_Id());
- cliente2.set_ResponsavelAssinatura(responsavelAssinatura);
- }
- this.SelectedCliente = cliente;
- this.JuridicaouFisica(this.SelectedCliente.get_Documento());
- this.SelectedCliente.Initialize();
- ObservableCollection<ClienteTelefone> telefones2 = this.SelectedCliente.get_Telefones();
- if (telefones2 != null)
- {
- List<ClienteTelefone> list = telefones2.ToList<ClienteTelefone>();
- list.ForEach((ClienteTelefone telefone) => telefone.Initialize());
- }
- else
- {
- }
- ObservableCollection<ClienteEndereco> enderecos2 = this.SelectedCliente.get_Enderecos();
- if (enderecos2 != null)
- {
- List<ClienteEndereco> clienteEnderecos = enderecos2.ToList<ClienteEndereco>();
- clienteEnderecos.ForEach((ClienteEndereco endereco) => endereco.Initialize());
- }
- else
- {
- }
- ObservableCollection<MaisContato> contatos1 = this.SelectedCliente.get_Contatos();
- if (contatos1 != null)
- {
- List<MaisContato> maisContatos = contatos1.ToList<MaisContato>();
- maisContatos.ForEach((MaisContato contato) => contato.Initialize());
- }
- else
- {
- }
- ObservableCollection<ClienteEmail> emails2 = this.SelectedCliente.get_Emails();
- if (emails2 != null)
- {
- List<ClienteEmail> clienteEmails = emails2.ToList<ClienteEmail>();
- clienteEmails.ForEach((ClienteEmail email) => email.Initialize());
- }
- else
- {
- }
- ObservableCollection<ClienteVinculo> vinculos = this.SelectedCliente.get_Vinculos();
- if (vinculos != null)
- {
- List<ClienteVinculo> clienteVinculos = vinculos.ToList<ClienteVinculo>();
- clienteVinculos.ForEach((ClienteVinculo vinculo) => vinculo.Initialize());
- }
- else
- {
- }
- this.Initialized = true;
- }
- cliente = null;
- }
-
- public async void Excluir()
- {
- Cliente selectedCliente;
- if (this.SelectedCliente != null && this.SelectedCliente.get_Id() != 0)
- {
- if (await (new ApoliceServico()).BuscarApolicesAsync(this.SelectedCliente.get_Id(), 4, null).Count > 0)
- {
- await base.ShowMessage("NÃO É POSSÍVEL EXCLUIR O CLIENTE POIS POSSUI APÓLICES CADASTRADAS.", "OK", "", false);
- }
- else if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- selectedCliente = this.SelectedCliente;
- selectedCliente.set_Excluido(true);
- if (await this._servico.Delete(selectedCliente))
- {
- this.ClienteSelecionado = null;
- MainViewModel.ClienteSelecionado = null;
- Action limparCliente = Gestor.Application.Actions.Actions.LimparCliente;
- if (limparCliente != null)
- {
- limparCliente();
- }
- else
- {
- }
- Cliente cliente = new Cliente();
- cliente.set_IdEmpresa(Recursos.Usuario.get_IdEmpresa());
- cliente.set_DocumentoPrincipal(new TipoDocumento?(0));
- cliente.set_ClienteDesde(new DateTime?(Funcoes.GetNetworkTime().Date));
- this.SelectedCliente = cliente;
- ObservableCollection<ClienteTelefone> observableCollection = new ObservableCollection<ClienteTelefone>();
- ClienteTelefone clienteTelefone = new ClienteTelefone();
- clienteTelefone.set_Cliente(this.SelectedCliente);
- clienteTelefone.set_Tipo(new TipoTelefone?(1));
- clienteTelefone.set_Ordem(new int?(1));
- observableCollection.Add(clienteTelefone);
- this.Telefones = observableCollection;
- ObservableCollection<ClienteEndereco> observableCollection1 = new ObservableCollection<ClienteEndereco>();
- ClienteEndereco clienteEndereco = new ClienteEndereco();
- clienteEndereco.set_Cliente(this.SelectedCliente);
- clienteEndereco.set_Ordem(new int?(1));
- observableCollection1.Add(clienteEndereco);
- this.Enderecos = observableCollection1;
- ObservableCollection<ClienteEmail> observableCollection2 = new ObservableCollection<ClienteEmail>();
- ClienteEmail clienteEmail = new ClienteEmail();
- clienteEmail.set_Cliente(this.SelectedCliente);
- clienteEmail.set_Ordem(new int?(1));
- observableCollection2.Add(clienteEmail);
- this.Emails = observableCollection2;
- this.Contatos = new ObservableCollection<MaisContato>();
- this.Vinculos = new ObservableCollection<ClienteVinculo>();
- this.Origens = new ObservableCollection<OrigemCliente>();
- string str = string.Format("EXCLUIU CLIENTE \"{0}\", ID: {1}", selectedCliente.get_Nome(), selectedCliente.get_Id());
- base.RegistrarAcao(str, selectedCliente.get_Id(), new TipoTela?(1), string.Format("CLIENTE \"{0}\", ID: {1}", this.SelectedCliente.get_Nome(), this.SelectedCliente.get_Id()));
- base.ToggleSnackBar("CLIENTE EXCLUÍDO COM SUCESSO", true);
- }
- }
- }
- selectedCliente = null;
- }
-
- public void ExcluirContato(MaisContato contato)
- {
- this.EnableAddContact = this.Contatos.Count <= 9;
- this.Contatos.Remove(contato);
- }
-
- public async void ExcluirEmail(ClienteEmail email)
- {
- if (this.Emails.Count < 2)
- {
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 29))
- {
- await base.ShowMessage("É NECESSÁRIO TER AO MENOS UM CONTATO DE E-MAIL CADASTRADO.", "OK", "", false);
- return;
- }
- }
- this.EnableAddEmail = this.Emails.Count <= 9;
- this.Emails.Remove(email);
- }
-
- public async void ExcluirEndereco(ClienteEndereco endereco)
- {
- if (this.Enderecos.Count >= 2)
- {
- this.EnableAddAddress = this.Enderecos.Count <= 9;
- this.Enderecos.Remove(endereco);
- }
- else
- {
- await base.ShowMessage("É NECESSÁRIO TER AO MENOS UM ENDEREÇO CADASTRADO.", "OK", "", false);
- }
- }
-
- public async Task ExcluirOrigem(OrigemCliente origem)
- {
- ClienteViewModel clienteViewModel = this;
- clienteViewModel.Origens.Remove(origem);
- clienteViewModel.OnPropertyChanged("Origens");
- }
-
- public async void ExcluirTelefone(ClienteTelefone telefone)
- {
- if (this.Telefones.Count >= 2)
- {
- this.EnableAddTelephone = this.Telefones.Count <= 9;
- this.Telefones.Remove(telefone);
- }
- else
- {
- await base.ShowMessage("É NECESSÁRIO TER AO MENOS UM CONTATO TELEFÔNICO CADASTRADO.", "OK", "", false);
- }
- }
-
- public void ExcluirVinculo(ClienteVinculo vinculo)
- {
- this.Vinculos.Remove(vinculo);
- }
-
- public void IncluirCliente()
- {
- DateTime date = Funcoes.GetNetworkTime().Date;
- Cliente cliente = new Cliente();
- cliente.set_IdEmpresa(Recursos.Usuario.get_IdEmpresa());
- cliente.set_DocumentoPrincipal(new TipoDocumento?(0));
- cliente.set_ClienteDesde(new DateTime?(date));
- cliente.set_ResponsavelAssinatura(new ResponsavelAssinatura());
- this.SelectedCliente = cliente;
- this.NascimentoCliente = new DateTime?(date);
- this.HabilitaCliente = new DateTime?(date);
- this.VencimentoHabCliente = new DateTime?(date);
- this.ExpedicaoCliente = new DateTime?(date);
- ObservableCollection<ClienteTelefone> observableCollection = new ObservableCollection<ClienteTelefone>();
- ClienteTelefone clienteTelefone = new ClienteTelefone();
- clienteTelefone.set_Cliente(this.SelectedCliente);
- clienteTelefone.set_Tipo(new TipoTelefone?(1));
- clienteTelefone.set_Ordem(new int?(1));
- observableCollection.Add(clienteTelefone);
- this.Telefones = observableCollection;
- ObservableCollection<ClienteEndereco> observableCollection1 = new ObservableCollection<ClienteEndereco>();
- ClienteEndereco clienteEndereco = new ClienteEndereco();
- clienteEndereco.set_Cliente(this.SelectedCliente);
- clienteEndereco.set_Ordem(new int?(1));
- observableCollection1.Add(clienteEndereco);
- this.Enderecos = observableCollection1;
- ObservableCollection<ClienteEmail> observableCollection2 = new ObservableCollection<ClienteEmail>();
- ClienteEmail clienteEmail = new ClienteEmail();
- clienteEmail.set_Cliente(this.SelectedCliente);
- clienteEmail.set_Ordem(new int?(1));
- observableCollection2.Add(clienteEmail);
- this.Emails = observableCollection2;
- this.Contatos = new ObservableCollection<MaisContato>();
- this.Vinculos = new ObservableCollection<ClienteVinculo>();
- this.Origens = new ObservableCollection<OrigemCliente>();
- this.Salvando = true;
- base.Alterar(true);
- }
-
- public void IncluirContato()
- {
- if (this.SelectedCliente == null)
- {
- return;
- }
- if (this.Contatos == null)
- {
- this.Contatos = new ObservableCollection<MaisContato>();
- }
- MaisContato maisContato = new MaisContato();
- maisContato.set_Cliente(this.SelectedCliente);
- MaisContato maisContato1 = maisContato;
- this.EnableAddContact = this.Contatos.Count < 9;
- this.Contatos.Add(maisContato1);
- base.OnPropertyChanged("IncluirContato");
- }
-
- public void IncluirEmail()
- {
- if (this.SelectedCliente == null)
- {
- return;
- }
- if (this.Emails == null)
- {
- this.Emails = new ObservableCollection<ClienteEmail>();
- }
- this.EnableAddEmail = this.Emails.Count < 9;
- ClienteEmail clienteEmail = new ClienteEmail();
- clienteEmail.set_Cliente(this.SelectedCliente);
- clienteEmail.set_Ordem(new int?(this.Emails.Count + 1));
- this.Emails.Add(clienteEmail);
- base.OnPropertyChanged("IncluirEmail");
- }
-
- public void IncluirEndereco()
- {
- if (this.SelectedCliente == null)
- {
- return;
- }
- if (this.Enderecos == null)
- {
- this.Enderecos = new ObservableCollection<ClienteEndereco>();
- }
- this.EnableAddAddress = this.Enderecos.Count < 9;
- ClienteEndereco clienteEndereco = new ClienteEndereco();
- clienteEndereco.set_Cliente(this.SelectedCliente);
- clienteEndereco.set_Ordem(new int?(this.Enderecos.Count + 1));
- this.Enderecos.Add(clienteEndereco);
- base.OnPropertyChanged("IncluirEndereco");
- }
-
- public async Task IncluirOrigem(string name)
- {
- if (this.SelectedCliente != null && !string.IsNullOrWhiteSpace(name))
- {
- if (this.Origens == null)
- {
- this.Origens = new ObservableCollection<OrigemCliente>();
- }
- if (!this.Origens.Any<OrigemCliente>((OrigemCliente x) => {
- string str;
- string nome = x.get_Nome();
- if (nome != null)
- {
- str = nome.Trim();
- }
- else
- {
- str = null;
- }
- return str == name.Trim();
- }))
- {
- ObservableCollection<OrigemCliente> origens = this.Origens;
- OrigemCliente origemCliente = new OrigemCliente();
- origemCliente.set_Cliente(this.SelectedCliente);
- origemCliente.set_Nome(name);
- origemCliente.set_TipoOrigem((long)1);
- origens.Insert(0, origemCliente);
- base.OnPropertyChanged("Origens");
- }
- else
- {
- await base.ShowMessage(string.Concat("JÁ EXISTE UMA ORIGEM ", name, ". PROCESSO CANCELADO."), "OK", "", false);
- }
- }
- }
-
- public void IncluirTelefone()
- {
- if (this.SelectedCliente == null)
- {
- return;
- }
- if (this.Telefones == null)
- {
- this.Telefones = new ObservableCollection<ClienteTelefone>();
- }
- this.EnableAddTelephone = this.Telefones.Count < 9;
- ClienteTelefone clienteTelefone = new ClienteTelefone();
- clienteTelefone.set_Cliente(this.SelectedCliente);
- clienteTelefone.set_Tipo(new TipoTelefone?(1));
- clienteTelefone.set_Ordem(new int?(this.Telefones.Count + 1));
- this.Telefones.Add(clienteTelefone);
- base.OnPropertyChanged("IncluirTelefone");
- }
-
- public bool IncluirVinculo()
- {
- if (this.Vinculo == null || this.Vinculo.get_Id() == this.SelectedCliente.get_Id())
- {
- return false;
- }
- if (this.Vinculos == null)
- {
- this.Vinculos = new ObservableCollection<ClienteVinculo>();
- }
- if (this.Vinculos.Any<ClienteVinculo>((ClienteVinculo x) => {
- if (x.get_Cliente1().get_Id() == this.Vinculo.get_Id())
- {
- return true;
- }
- return x.get_Cliente2().get_Id() == this.Vinculo.get_Id();
- }))
- {
- return false;
- }
- ClienteVinculo clienteVinculo = new ClienteVinculo();
- clienteVinculo.set_Cliente1(this.SelectedCliente);
- clienteVinculo.set_Cliente2(this.Vinculo);
- this.Vinculos.Add(clienteVinculo);
- this.Vinculo = null;
- base.OnPropertyChanged("IncluirVinculo");
- return true;
- }
-
- public void JuridicaouFisica(string documento)
- {
- if (this.SelectedCliente == null)
- {
- return;
- }
- this.ProfissaoText = "";
- this.AtividadeText = "";
- if (documento != null && ValidationHelper.OnlyNumber(documento).Length <= 11)
- {
- this.VisibilityJuridica = Visibility.Collapsed;
- this.VisibilityFisica = Visibility.Visible;
- this.FieldNascimento = "NASCIMENTO";
- this.FieldDocumento = "CPF";
- this.SelectedCliente.set_Atividade(null);
- this.IsJuridica = false;
- return;
- }
- this.VisibilityJuridica = Visibility.Visible;
- this.VisibilityFisica = Visibility.Collapsed;
- this.FieldNascimento = "FUNDAÇÃO";
- this.FieldDocumento = "CNPJ";
- this.SelectedCliente.set_Profissao(null);
- this.IsJuridica = true;
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- long num;
- long? nullable;
- List<MaisContato> list;
- List<ClienteVinculo> clienteVinculos;
- ObservableCollection<MaisContato> observableCollection;
- ObservableCollection<ClienteVinculo> observableCollection1;
- List<OrigemCliente> origemClientes;
- bool id;
- bool salvando;
- long? nullable1;
- long? nullable2;
- ClienteViewModel.u003cu003ec__DisplayClass146_0 variable;
- Cliente selectedCliente;
- Func<ClienteVinculo, bool> func = null;
- ObservableCollection<ClienteTelefone> telefones = this.Telefones;
- List<ClienteTelefone> clienteTelefones = (
- from x in telefones
- where !string.IsNullOrEmpty(x.get_Numero())
- select x).ToList<ClienteTelefone>();
- ObservableCollection<ClienteEndereco> enderecos = this.Enderecos;
- List<ClienteEndereco> clienteEnderecos = (
- from x in enderecos
- where !string.IsNullOrEmpty(x.get_Endereco())
- select x).ToList<ClienteEndereco>();
- ObservableCollection<MaisContato> contatos = this.Contatos;
- if (contatos != null)
- {
- list = (
- from x in contatos
- where !string.IsNullOrEmpty(x.get_Nome())
- select x).ToList<MaisContato>();
- }
- else
- {
- list = null;
- }
- List<MaisContato> maisContatos = list;
- ObservableCollection<ClienteEmail> emails = this.Emails;
- List<ClienteEmail> clienteEmails = (
- from x in emails
- where !string.IsNullOrEmpty(x.get_Email())
- select x).ToList<ClienteEmail>();
- ObservableCollection<ClienteVinculo> vinculos = this.Vinculos;
- if (vinculos != null)
- {
- clienteVinculos = vinculos.Where<ClienteVinculo>((ClienteVinculo x) => {
- if (x.get_Cliente2() == null)
- {
- return false;
- }
- return x.get_Parentesco().HasValue;
- }).ToList<ClienteVinculo>();
- }
- else
- {
- clienteVinculos = null;
- }
- List<ClienteVinculo> clienteVinculos1 = clienteVinculos;
- if (clienteVinculos1 != null && this.ClienteSelecionado != null)
- {
- List<ClienteVinculo> clienteVinculos2 = clienteVinculos1;
- Func<ClienteVinculo, bool> func1 = func;
- if (func1 == null)
- {
- Func<ClienteVinculo, bool> id1 = (ClienteVinculo c) => c.get_Cliente2().get_Id() == this.ClienteSelecionado.get_Id();
- Func<ClienteVinculo, bool> func2 = id1;
- func = id1;
- func1 = func2;
- }
- foreach (ClienteVinculo clienteVinculo in clienteVinculos2.Where<ClienteVinculo>(func1))
- {
- clienteVinculo.set_Parentesco(Funcoes.ParentescoInverso(clienteVinculo.get_Parentesco()));
- }
- }
- this.SelectedCliente.set_Telefones(new ObservableCollection<ClienteTelefone>(clienteTelefones));
- this.SelectedCliente.set_Enderecos(new ObservableCollection<ClienteEndereco>(clienteEnderecos));
- Cliente cliente = this.SelectedCliente;
- if (maisContatos != null)
- {
- observableCollection = new ObservableCollection<MaisContato>(maisContatos);
- }
- else
- {
- observableCollection = null;
- }
- cliente.set_Contatos(observableCollection);
- this.SelectedCliente.set_Emails(new ObservableCollection<ClienteEmail>(clienteEmails));
- Cliente selectedCliente1 = this.SelectedCliente;
- if (clienteVinculos1 != null)
- {
- observableCollection1 = new ObservableCollection<ClienteVinculo>(clienteVinculos1);
- }
- else
- {
- observableCollection1 = null;
- }
- selectedCliente1.set_Vinculos(observableCollection1);
- Cliente cliente1 = this.SelectedCliente;
- ObservableCollection<OrigemCliente> origens = this.Origens;
- if (origens != null)
- {
- origemClientes = origens.ToList<OrigemCliente>();
- }
- else
- {
- origemClientes = null;
- }
- cliente1.set_Origens(origemClientes);
- if (ValidationHelper.OnlyNumber(this.SelectedCliente.get_Documento()).Length <= 11 && !string.IsNullOrWhiteSpace(this.ProfissaoText) && this.SelectedCliente.get_Profissao() == null)
- {
- ProfissaoServico profissaoServico = new ProfissaoServico();
- selectedCliente = this.SelectedCliente;
- ProfissaoServico profissaoServico1 = profissaoServico;
- Profissao profissao = new Profissao();
- profissao.set_Nome(this.ProfissaoText);
- profissao.set_Codigo("0");
- Profissao profissao1 = profissao;
- num = await profissaoServico.FindLastId();
- profissao1.set_Id(num + (long)1);
- Profissao profissao2 = await profissaoServico1.Save(profissao);
- profissaoServico1 = null;
- profissao1 = null;
- profissao = null;
- selectedCliente.set_Profissao(profissao2);
- selectedCliente = null;
- if (profissaoServico.Sucesso)
- {
- profissaoServico = null;
- }
- else
- {
- keyValuePairs = null;
- variable = null;
- clienteEmails = null;
- return keyValuePairs;
- }
- }
- if (ValidationHelper.OnlyNumber(this.SelectedCliente.get_Documento()).Length > 11 && !string.IsNullOrWhiteSpace(this.AtividadeText) && this.SelectedCliente.get_Atividade() == null)
- {
- AtividadeServico atividadeServico = new AtividadeServico();
- selectedCliente = this.SelectedCliente;
- AtividadeServico atividadeServico1 = atividadeServico;
- Atividade atividade = new Atividade();
- atividade.set_Nome(this.AtividadeText);
- atividade.set_Cnac("0");
- Atividade atividade1 = atividade;
- num = await atividadeServico.FindLastId();
- atividade1.set_Id(num + (long)1);
- Atividade atividade2 = await atividadeServico1.Save(atividade);
- atividadeServico1 = null;
- atividade1 = null;
- atividade = null;
- selectedCliente.set_Atividade(atividade2);
- selectedCliente = null;
- if (atividadeServico.Sucesso)
- {
- atividadeServico = null;
- }
- else
- {
- keyValuePairs = null;
- variable = null;
- clienteEmails = null;
- return keyValuePairs;
- }
- }
- if (this.IsJuridica)
- {
- this.SelectedCliente.set_Cei(null);
- this.SelectedCliente.set_Rne(null);
- this.SelectedCliente.set_Caepf(null);
- }
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedCliente.Validate();
- clienteEmails.ForEach((ClienteEmail x) => keyValuePairs1.AddRange(x.Validate()));
- List<KeyValuePair<string, string>> keyValuePairs2 = keyValuePairs1;
- keyValuePairs2.AddRange(await this.Validate());
- keyValuePairs2 = null;
- foreach (MaisContato contato in this.Contatos)
- {
- keyValuePairs1.AddRange(contato.Validate());
- }
- foreach (ClienteVinculo vinculo in this.Vinculos)
- {
- keyValuePairs1.AddRange(vinculo.Validate());
- }
- if (keyValuePairs1.Count <= 0)
- {
- bool flag = this.SelectedCliente.get_Id() == (long)0;
- this._saving = true;
- Cliente clienteSelecionado = this.ClienteSelecionado;
- if (clienteSelecionado != null)
- {
- id = clienteSelecionado.get_Id() != (long)0;
- }
- else
- {
- id = true;
- }
- if (id)
- {
- Cliente clienteSelecionado1 = this.ClienteSelecionado;
- if (clienteSelecionado1 != null)
- {
- nullable1 = new long?(clienteSelecionado1.get_Id());
- }
- else
- {
- nullable = null;
- nullable1 = nullable;
- }
- long? nullable3 = nullable1;
- Cliente selectedCliente2 = this.SelectedCliente;
- if (selectedCliente2 != null)
- {
- nullable2 = new long?(selectedCliente2.get_Id());
- }
- else
- {
- nullable = null;
- nullable2 = nullable;
- }
- long? nullable4 = nullable2;
- if (nullable3.GetValueOrDefault() != nullable4.GetValueOrDefault() | nullable3.HasValue != nullable4.HasValue)
- {
- goto Label2;
- }
- salvando = this.Salvando;
- goto Label1;
- }
- Label2:
- salvando = false;
- Label1:
- bool flag1 = salvando;
- if (flag1)
- {
- flag1 = await base.ShowMessage("NÃO FOI POSSIVEL INCLUIR UM NOVO SEGURADO, TENTE NOVAMENTE", "OK", "", false);
- }
- if (!flag1)
- {
- this.SelectedCliente = await this._servico.Save(this.SelectedCliente, this.Salvando);
- if (this._servico.Sucesso)
- {
- if (this.Invoke)
- {
- Action<Cliente> selectCliente = Gestor.Application.Actions.Actions.SelectCliente;
- if (selectCliente != null)
- {
- selectCliente(this.SelectedCliente);
- }
- else
- {
- }
- }
- await this.CarregaCliente(this.SelectedCliente);
- string str = (flag ? "INCLUIU" : "ALTEROU");
- base.RegistrarAcao(string.Concat(str, " CLIENTE \"", this.SelectedCliente.get_Nome(), "\""), this.SelectedCliente.get_Id(), new TipoTela?(1), string.Format("CLIENTE \"{0}\", ID: {1}", this.SelectedCliente.get_Nome(), this.SelectedCliente.get_Id()));
- base.ToggleSnackBar("CLIENTE SALVO COM SUCESSO", true);
- if (this.Invoke)
- {
- ConsultaViewModel.DocumentoSelecionado = null;
- Action atualizaContatos = Gestor.Application.Actions.Actions.AtualizaContatos;
- if (atualizaContatos != null)
- {
- atualizaContatos();
- }
- else
- {
- }
- if (flag)
- {
- MainViewModel.ClienteSelecionado = this.SelectedCliente;
- if (await base.ShowMessage("DESEJA INCLUIR UMA APÓLICE AGORA?", "SIM", "NÃO", false))
- {
- Action<TipoTela, string> acessaTela = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela != null)
- {
- acessaTela(2, "");
- }
- else
- {
- }
- }
- }
- }
- this.Salvando = false;
- base.Alterar(false);
- this._saving = false;
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- variable = null;
- clienteEmails = null;
- return keyValuePairs;
- }
-
- public async void SelecionaCliente(Cliente value)
- {
- if (!this._saving || !this.Invoke)
- {
- if (value == null)
- {
- this.ClienteSelecionado = new Cliente();
- value = this.ClienteSelecionado;
- }
- base.Loading(true);
- await base.PermissaoTela(1);
- await this.CarregaCliente(value);
- base.Loading(false);
- }
- }
-
- public async Task<bool> Validate(ClienteEmail item)
- {
- bool flag;
- if (!ValidationHelper.ValidateMail(item.get_Email()))
- {
- await base.ShowMessage("ENDEREÇO DE E-MAIL INVÁLIDO", "OK", "", false);
- flag = false;
- }
- else
- {
- flag = true;
- }
- return flag;
- }
-
- private async Task<List<KeyValuePair<string, string>>> Validate()
- {
- List<Cliente> clientes;
- long id;
- List<KeyValuePair<string, string>> keyValuePairs = new List<KeyValuePair<string, string>>();
- bool flag = !string.IsNullOrEmpty(this.SelectedCliente.get_Nome());
- TipoDocumento? documentoPrincipal = this.SelectedCliente.get_DocumentoPrincipal();
- if (documentoPrincipal.HasValue)
- {
- switch (documentoPrincipal.GetValueOrDefault())
- {
- case 0:
- {
- if (ValidationHelper.ValidateDocument(this.SelectedCliente.get_Documento()))
- {
- break;
- }
- flag = false;
- break;
- }
- case 1:
- {
- if (ValidationHelper.ValidateRne(this.SelectedCliente.get_Rne()))
- {
- break;
- }
- flag = false;
- break;
- }
- case 2:
- {
- if (ValidationHelper.ValidateCei(this.SelectedCliente.get_Cei()))
- {
- break;
- }
- flag = false;
- break;
- }
- case 3:
- {
- if (ValidationHelper.ValidateCaepf(this.SelectedCliente.get_Caepf()))
- {
- break;
- }
- flag = false;
- break;
- }
- }
- }
- if (ValidationHelper.ValidateDocument(this.SelectedCliente.get_Documento()))
- {
- documentoPrincipal = this.SelectedCliente.get_DocumentoPrincipal();
- if (documentoPrincipal.GetValueOrDefault() == 0 & documentoPrincipal.HasValue)
- {
- this.SelectedCliente.set_Documento(ValidationHelper.FormatDocument(this.SelectedCliente.get_Documento()));
- }
- }
- if (!ValidationHelper.ValidateDocument(this.SelectedCliente.get_Documento()))
- {
- clientes = new List<Cliente>();
- }
- else
- {
- clientes = await (new ClienteServico()).BuscarCliente(this.SelectedCliente.get_Documento(), null, 2);
- }
- List<Cliente> clientes1 = clientes;
- if (!this.IsJuridica)
- {
- if (!ValidationHelper.ValidateCei(this.SelectedCliente.get_Cei()))
- {
- clientes = new List<Cliente>();
- }
- else
- {
- clientes = await (new ClienteServico()).BuscarCliente(this.SelectedCliente.get_Cei(), null, 2);
- }
- List<Cliente> clientes2 = clientes;
- if (!ValidationHelper.ValidateRne(this.SelectedCliente.get_Rne()))
- {
- clientes = new List<Cliente>();
- }
- else
- {
- clientes = await (new ClienteServico()).BuscarCliente(this.SelectedCliente.get_Rne(), null, 2);
- }
- List<Cliente> clientes3 = clientes;
- if (!ValidationHelper.ValidateCaepf(this.SelectedCliente.get_Caepf()))
- {
- clientes = new List<Cliente>();
- }
- else
- {
- clientes = await (new ClienteServico()).BuscarCliente(this.SelectedCliente.get_Caepf(), null, 2);
- }
- List<Cliente> clientes4 = clientes;
- List<Cliente> clientes5 = clientes1;
- List<Cliente> clientes6 = clientes2;
- if (clientes6 == null)
- {
- clientes6 = new List<Cliente>();
- }
- clientes5.AddRange(clientes6);
- List<Cliente> clientes7 = clientes1;
- List<Cliente> clientes8 = clientes3;
- if (clientes8 == null)
- {
- clientes8 = new List<Cliente>();
- }
- clientes7.AddRange(clientes8);
- List<Cliente> clientes9 = clientes1;
- List<Cliente> clientes10 = clientes4;
- if (clientes10 == null)
- {
- clientes10 = new List<Cliente>();
- }
- clientes9.AddRange(clientes10);
- clientes2 = null;
- clientes3 = null;
- }
- string nome = "";
- string str = "";
- if (clientes1.Count > 0)
- {
- clientes1.ForEach((Cliente x) => {
- if (x.get_Id() == this.SelectedCliente.get_Id())
- {
- return;
- }
- if (x.get_IdEmpresa() != this.SelectedCliente.get_IdEmpresa())
- {
- return;
- }
- if (!string.IsNullOrEmpty(this.SelectedCliente.get_Documento()) && x.get_Documento() == this.SelectedCliente.get_Documento())
- {
- flag = false;
- nome = x.get_Nome();
- }
- if (!string.IsNullOrEmpty(this.SelectedCliente.get_Cei()) && x.get_Cei() == this.SelectedCliente.get_Cei())
- {
- str = " (CEI)";
- flag = false;
- nome = x.get_Nome();
- }
- if (!string.IsNullOrEmpty(this.SelectedCliente.get_Rne()) && x.get_Rne() == this.SelectedCliente.get_Rne())
- {
- str = " (RNE)";
- flag = false;
- nome = x.get_Nome();
- }
- if (!string.IsNullOrEmpty(this.SelectedCliente.get_Caepf()) && x.get_Caepf() == this.SelectedCliente.get_Caepf())
- {
- str = " (CAEPF)";
- flag = false;
- nome = x.get_Nome();
- }
- });
- }
- if (!flag && clientes1.Count<Cliente>((Cliente x) => x.get_Id() != this.SelectedCliente.get_Id()) > 0)
- {
- if (await (new VendedorUsuarioServico()).FindVinculoByUsuario(Recursos.Usuario.get_Id()))
- {
- Cliente cliente = clientes1.FirstOrDefault<Cliente>();
- if (cliente != null)
- {
- id = cliente.get_Id();
- }
- else
- {
- id = (long)0;
- }
- List<Vendedor> vendedors = await (new VendedorServico()).BuscarVinculosCliente(id);
- string str1 = string.Join("|",
- from vendedor in vendedors
- select vendedor.get_Nome());
- List<KeyValuePair<string, string>> keyValuePairs1 = keyValuePairs;
- string[] strArrays = new string[] { "O DOCUMENTO", str, " JÁ ESTÁ CADASTRADO PARA O CLIENTE ", nome, ".\nEXISTENTE NO VINCULO COM VENDEDORES: ", str1, " " };
- keyValuePairs1.Add(new KeyValuePair<string, string>("Documento", string.Concat(strArrays)));
- }
- else
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Documento", string.Concat("O DOCUMENTO", str, " JÁ ESTÁ CADASTRADO PARA O CLIENTE ", nome)));
- }
- }
- if (this.SelectedCliente.get_Telefones() == null || this.SelectedCliente.get_Telefones().Count == 0)
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Telefones", "NECESSITA-SE AO MENOS UM TELEFONE VÁLIDO."));
- }
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 29) && (this.SelectedCliente.get_Emails() == null || this.SelectedCliente.get_Emails().Count == 0))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Emails|E-MAILS", "NECESSITA-SE AO MENOS UM E-MAIL VÁLIDO."));
- }
- if (this.SelectedCliente.get_Enderecos() == null || this.SelectedCliente.get_Enderecos().Count == 0)
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Enderecos|ENDEREÇOS", "NECESSITA-SE AO MENOS UM ENDEREÇO VÁLIDO."));
- }
- List<KeyValuePair<string, string>> keyValuePairs2 = keyValuePairs;
- keyValuePairs = null;
- clientes1 = null;
- return keyValuePairs2;
- }
-
- private async void WorkOnSelectedCliente(Cliente value)
- {
- DateTime networkTime;
- DateTime? nullable;
- DateTime? primeiraHabilitacao;
- DateTime? vencimentoHabilitacao;
- DateTime? expedicao;
- Cliente cliente;
- if (value != null && value.get_Id() != 0 && !this.IsLoading)
- {
- base.Loading(true);
- cliente = await this._servico.BuscarCliente(value.get_Id());
- if (cliente.get_ResponsavelAssinatura() == null)
- {
- Cliente cliente1 = cliente;
- ResponsavelAssinatura responsavelAssinatura = new ResponsavelAssinatura();
- responsavelAssinatura.set_IdCliente(cliente.get_Id());
- cliente1.set_ResponsavelAssinatura(responsavelAssinatura);
- }
- Cliente cliente2 = cliente;
- ObservableCollection<ClienteTelefone> observableCollection = await this._servico.BuscarTelefonesAsync(value.get_Id());
- cliente2.set_Telefones(observableCollection);
- cliente2 = null;
- cliente2 = cliente;
- ObservableCollection<ClienteEmail> observableCollection1 = await this._servico.BuscarEmailsAsync(value.get_Id());
- cliente2.set_Emails(observableCollection1);
- cliente2 = null;
- cliente2 = cliente;
- ObservableCollection<ClienteEndereco> observableCollection2 = await this._servico.BuscarEnderecosAsync(value.get_Id());
- cliente2.set_Enderecos(observableCollection2);
- cliente2 = null;
- cliente2 = cliente;
- ObservableCollection<MaisContato> observableCollection3 = await this._servico.BuscarContatosAsync(value.get_Id());
- cliente2.set_Contatos(observableCollection3);
- cliente2 = null;
- cliente2 = cliente;
- ObservableCollection<ClienteVinculo> observableCollection4 = await this._servico.BuscarVinculosAsync(value.get_Id());
- cliente2.set_Vinculos(observableCollection4);
- cliente2 = null;
- this.Origens = await this._servico.BuscarOrigens(value.get_Id());
- Cliente cliente3 = cliente;
- TipoDocumento? documentoPrincipal = cliente.get_DocumentoPrincipal();
- cliente3.set_DocumentoPrincipal(new TipoDocumento?(documentoPrincipal.GetValueOrDefault()));
- this.ClienteExcluido = cliente.get_Excluido();
- if (this.SelectedCliente != null)
- {
- DomainBase.Copy<Cliente, Cliente>(this.SelectedCliente, cliente);
- this.JuridicaouFisica(this.SelectedCliente.get_Documento());
- this.SelectedCliente.Initialize();
- this.ClienteSelecionado = cliente;
- }
- ClienteViewModel clienteViewModel = this;
- if (value == null || !value.get_Nascimento().HasValue)
- {
- networkTime = Funcoes.GetNetworkTime();
- nullable = new DateTime?(networkTime.Date);
- }
- else
- {
- nullable = value.get_Nascimento();
- }
- clienteViewModel.NascimentoCliente = nullable;
- ClienteViewModel clienteViewModel1 = this;
- if (value == null || !value.get_PrimeiraHabilitacao().HasValue)
- {
- networkTime = Funcoes.GetNetworkTime();
- primeiraHabilitacao = new DateTime?(networkTime.Date);
- }
- else
- {
- primeiraHabilitacao = value.get_PrimeiraHabilitacao();
- }
- clienteViewModel1.HabilitaCliente = primeiraHabilitacao;
- ClienteViewModel clienteViewModel2 = this;
- if (value == null || !value.get_VencimentoHabilitacao().HasValue)
- {
- networkTime = Funcoes.GetNetworkTime();
- vencimentoHabilitacao = new DateTime?(networkTime.Date);
- }
- else
- {
- vencimentoHabilitacao = value.get_VencimentoHabilitacao();
- }
- clienteViewModel2.VencimentoHabCliente = vencimentoHabilitacao;
- ClienteViewModel clienteViewModel3 = this;
- if (value == null || !value.get_Expedicao().HasValue)
- {
- networkTime = Funcoes.GetNetworkTime();
- expedicao = new DateTime?(networkTime.Date);
- }
- else
- {
- expedicao = value.get_Expedicao();
- }
- clienteViewModel3.ExpedicaoCliente = expedicao;
- this.Initialized = true;
- base.Loading(false);
- }
- cliente = null;
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/ConsultaViewModel.cs b/Gestor.Application/ViewModels/Seguros/ConsultaViewModel.cs deleted file mode 100644 index ad65045..0000000 --- a/Gestor.Application/ViewModels/Seguros/ConsultaViewModel.cs +++ /dev/null @@ -1,2425 +0,0 @@ -using Assinador.Infrastructure.Helpers;
-using ClosedXML.Excel;
-using Gestor.Application.Actions;
-using Gestor.Application.Helpers;
-using Gestor.Application.Model;
-using Gestor.Application.Servicos;
-using Gestor.Application.Servicos.Ferramentas;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Common;
-using Gestor.Model.Domain.Configuracoes;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Forms;
-using System.Windows.Threading;
-
-namespace Gestor.Application.ViewModels.Seguros
-{
- public class ConsultaViewModel : BaseSegurosViewModel
- {
- private readonly ApoliceServico _apoliceServico;
-
- private readonly ParcelaServico _parcelaServico;
-
- private readonly ItemServico _itemServico;
-
- private readonly VendedorServico _vendedorServico;
-
- public bool UpdatingScroll;
-
- public static Parcela ParcelaSelecionada;
-
- public static Item ItemSelecionado;
-
- private static Documento _documentoSelecionado;
-
- private bool _apelido;
-
- private Visibility _semDocumentos = Visibility.Collapsed;
-
- private Cliente _selectedCliente = new Cliente();
-
- private bool _carregando;
-
- private bool _isLoading;
-
- private Visibility _visibilityParcelasVendedores;
-
- private ObservableCollection<Documento> _apolices = new ObservableCollection<Documento>();
-
- private ObservableCollection<Documento> _endossos = new ObservableCollection<Documento>();
-
- private Documento _selectedEndosso = new Documento();
-
- private string _parcelasLabel = "PARCELAS";
-
- private Documento _selectedControle = new Documento();
-
- private bool _isFatura;
-
- private bool _isEnabledParcelaItem = true;
-
- private Item _selectedItem = new Item();
-
- private ObservableCollection<Item> _itens = new ObservableCollection<Item>();
-
- private Parcela _selectedParcela = new Parcela();
-
- private ObservableCollection<Parcela> _parcelas = new ObservableCollection<Parcela>();
-
- private Visibility _isVisibleRadioEndosso = Visibility.Collapsed;
-
- private Visibility _isVisibleEndosso = Visibility.Collapsed;
-
- private Visibility _isVisibleApolice;
-
- private string _pendenciaApolice = "";
-
- private Visibility _isVisiblePendenciaApolice = Visibility.Collapsed;
-
- private decimal _gerada;
-
- private decimal _recebida;
-
- private decimal _pendente;
-
- private bool _isLoadingParcelas = true;
-
- private bool _isLoadingItens = true;
-
- private int _filterItens;
-
- private int _filterDocumento;
-
- private Visibility _manutencaoItemVisibility;
-
- private Visibility _recusaVisibility;
-
- private Visibility _renovarVisibility;
-
- private Visibility _endossarVisibility;
-
- private Visibility _trocarClienteVisibility;
-
- private Visibility _tarefasVisibility;
-
- private Visibility _comissaoVisibility;
-
- private Visibility _comissaoValorVisibility;
-
- private Visibility _mostrarItensVisibility = Visibility.Collapsed;
-
- private Visibility _mostrarSinistroVisibility;
-
- private ObservableCollection<ClienteTelefone> _telefones = new ObservableCollection<ClienteTelefone>();
-
- public bool Apelido
- {
- get
- {
- return this._apelido;
- }
- set
- {
- this._apelido = value;
- base.OnPropertyChanged("Apelido");
- }
- }
-
- public ObservableCollection<Documento> Apolices
- {
- get
- {
- return this._apolices;
- }
- set
- {
- this._apolices = value;
- base.OnPropertyChanged("Apolices");
- }
- }
-
- public bool Carregando
- {
- get
- {
- return this._carregando;
- }
- set
- {
- this._carregando = value;
- this.SemDocumentos = (value || this.Apolices != null && this.Apolices.Count != 0 ? Visibility.Collapsed : Visibility.Visible);
- }
- }
-
- public Visibility ComissaoValorVisibility
- {
- get
- {
- return this._comissaoValorVisibility;
- }
- set
- {
- this._comissaoValorVisibility = (!base.Restricao(14) ? value : Visibility.Collapsed);
- base.OnPropertyChanged("ComissaoValorVisibility");
- }
- }
-
- public Visibility ComissaoVisibility
- {
- get
- {
- return this._comissaoVisibility;
- }
- set
- {
- this._comissaoVisibility = (!base.Restricao(95) ? value : Visibility.Collapsed);
- base.OnPropertyChanged("ComissaoVisibility");
- }
- }
-
- public static Documento DocumentoRenovado
- {
- get;
- set;
- }
-
- public static Documento DocumentoSelecionado
- {
- get
- {
- return ConsultaViewModel._documentoSelecionado;
- }
- set
- {
- ConsultaViewModel._documentoSelecionado = value;
- Action<bool> enableItens = Gestor.Application.Actions.Actions.EnableItens;
- if (enableItens != null)
- {
- enableItens((value == null ? false : value.get_Id() > (long)0));
- }
- else
- {
- }
- Action<bool> enableDocumento = Gestor.Application.Actions.Actions.EnableDocumento;
- if (enableDocumento == null)
- {
- return;
- }
- enableDocumento((value == null ? false : value.get_Id() > (long)0));
- }
- }
-
- public Visibility EndossarVisibility
- {
- get
- {
- return this._endossarVisibility;
- }
- set
- {
- this._endossarVisibility = (!base.Restricao(33) ? value : Visibility.Collapsed);
- base.OnPropertyChanged("EndossarVisibility");
- }
- }
-
- public ObservableCollection<Documento> Endossos
- {
- get
- {
- return this._endossos;
- }
- set
- {
- this._endossos = value;
- base.OnPropertyChanged("Endossos");
- }
- }
-
- public int FilterDocumento
- {
- get
- {
- return this._filterDocumento;
- }
- set
- {
- this._filterDocumento = value;
- Action<int> updateRadioApolice = Gestor.Application.Actions.Actions.UpdateRadioApolice;
- if (updateRadioApolice != null)
- {
- updateRadioApolice(this._filterDocumento);
- }
- else
- {
- }
- base.OnPropertyChanged("FilterDocumento");
- }
- }
-
- public int FilterItens
- {
- get
- {
- return this._filterItens;
- }
- set
- {
- this._filterItens = value;
- ConsultaViewModel.FiltrarItens = value;
- base.OnPropertyChanged("FilterItens");
- }
- }
-
- public static int FiltrarItens
- {
- get;
- set;
- }
-
- public decimal Gerada
- {
- get
- {
- return this._gerada;
- }
- set
- {
- this._gerada = value;
- base.OnPropertyChanged("Gerada");
- }
- }
-
- public bool IsEnabledParcelaItem
- {
- get
- {
- return this._isEnabledParcelaItem;
- }
- set
- {
- this._isEnabledParcelaItem = value;
- base.OnPropertyChanged("IsEnabledParcelaItem");
- }
- }
-
- public bool IsFatura
- {
- get
- {
- return this._isFatura;
- }
- set
- {
- if (!value)
- {
- value = this.ComissaoValorVisibility == Visibility.Collapsed;
- }
- this._isFatura = value;
- base.OnPropertyChanged("IsFatura");
- }
- }
-
- public bool IsLoading
- {
- get
- {
- return this._isLoading;
- }
- set
- {
- this._isLoading = value;
- base.OnPropertyChanged("IsLoading");
- }
- }
-
- public bool IsLoadingItens
- {
- get
- {
- return this._isLoadingItens;
- }
- set
- {
- this._isLoadingItens = value;
- base.OnPropertyChanged("IsLoadingItens");
- }
- }
-
- public bool IsLoadingParcelas
- {
- get
- {
- return this._isLoadingParcelas;
- }
- set
- {
- this._isLoadingParcelas = value;
- base.OnPropertyChanged("IsLoadingParcelas");
- }
- }
-
- public Visibility IsVisibleApolice
- {
- get
- {
- return this._isVisibleApolice;
- }
- set
- {
- this._isVisibleApolice = value;
- base.OnPropertyChanged("IsVisibleApolice");
- }
- }
-
- public Visibility IsVisibleEndosso
- {
- get
- {
- return this._isVisibleEndosso;
- }
- set
- {
- this._isVisibleEndosso = value;
- base.OnPropertyChanged("IsVisibleEndosso");
- }
- }
-
- public Visibility IsVisiblePendenciaApolice
- {
- get
- {
- return this._isVisiblePendenciaApolice;
- }
- set
- {
- this._isVisiblePendenciaApolice = value;
- base.OnPropertyChanged("IsVisiblePendenciaApolice");
- }
- }
-
- public Visibility IsVisibleRadioEndosso
- {
- get
- {
- return this._isVisibleRadioEndosso;
- }
- set
- {
- this._isVisibleRadioEndosso = value;
- base.OnPropertyChanged("IsVisibleRadioEndosso");
- }
- }
-
- public ObservableCollection<Item> Itens
- {
- get
- {
- return this._itens;
- }
- set
- {
- this._itens = value;
- base.OnPropertyChanged("Itens");
- }
- }
-
- public bool ItensRevelados
- {
- get;
- set;
- }
-
- public Visibility ManutencaoItemVisibility
- {
- get
- {
- return this._manutencaoItemVisibility;
- }
- set
- {
- this._manutencaoItemVisibility = (!base.Restricao(22) ? value : Visibility.Collapsed);
- base.OnPropertyChanged("ManutencaoItemVisibility");
- }
- }
-
- public Visibility MostrarItensVisibility
- {
- get
- {
- return this._mostrarItensVisibility;
- }
- set
- {
- this._mostrarItensVisibility = value;
- base.OnPropertyChanged("MostrarItensVisibility");
- }
- }
-
- public Visibility MostrarSinistroVisibility
- {
- get
- {
- return this._mostrarSinistroVisibility;
- }
- set
- {
- this._mostrarSinistroVisibility = value;
- base.OnPropertyChanged("MostrarSinistroVisibility");
- }
- }
-
- public ObservableCollection<Parcela> Parcelas
- {
- get
- {
- return this._parcelas;
- }
- set
- {
- this._parcelas = value;
- base.OnPropertyChanged("Parcelas");
- }
- }
-
- public string ParcelasLabel
- {
- get
- {
- return this._parcelasLabel;
- }
- set
- {
- this._parcelasLabel = value;
- base.OnPropertyChanged("ParcelasLabel");
- }
- }
-
- public string PendenciaApolice
- {
- get
- {
- return this._pendenciaApolice;
- }
- set
- {
- this._pendenciaApolice = value;
- this.IsVisiblePendenciaApolice = (string.IsNullOrEmpty(this._pendenciaApolice) ? Visibility.Collapsed : Visibility.Visible);
- base.OnPropertyChanged("PendenciaApolice");
- }
- }
-
- public decimal Pendente
- {
- get
- {
- return this._pendente;
- }
- set
- {
- this._pendente = value;
- base.OnPropertyChanged("Pendente");
- }
- }
-
- public bool Pesquisando
- {
- get;
- set;
- }
-
- public bool Recarregando
- {
- get;
- set;
- }
-
- public decimal Recebida
- {
- get
- {
- return this._recebida;
- }
- set
- {
- this._recebida = value;
- base.OnPropertyChanged("Recebida");
- }
- }
-
- public Visibility RecusaVisibility
- {
- get
- {
- return this._recusaVisibility;
- }
- set
- {
- this._recusaVisibility = (!base.Restricao(18) ? value : Visibility.Collapsed);
- base.OnPropertyChanged("RecusaVisibility");
- }
- }
-
- public Visibility RenovarVisibility
- {
- get
- {
- return this._renovarVisibility;
- }
- set
- {
- this._renovarVisibility = (!base.Restricao(17) ? value : Visibility.Collapsed);
- base.OnPropertyChanged("RenovarVisibility");
- }
- }
-
- public Cliente SelectedCliente
- {
- get
- {
- return this._selectedCliente;
- }
- set
- {
- this._selectedCliente = value;
- base.OnPropertyChanged("SelectedCliente");
- }
- }
-
- public Documento SelectedControle
- {
- get
- {
- return this._selectedControle;
- }
- set
- {
- bool id;
- bool flag;
- Visibility visibility;
- string apolice;
- this._selectedControle = value;
- if (value == null || value.get_Id() <= (long)0)
- {
- id = false;
- }
- else
- {
- Usuario usuario = Recursos.Usuario;
- if (usuario != null)
- {
- id = usuario.get_Id() > (long)0;
- }
- else
- {
- id = false;
- }
- }
- base.EnableButtons = id;
- bool flag1 = Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 13);
- if (value == null || value.get_Id() <= (long)0)
- {
- flag = false;
- }
- else if (flag1)
- {
- flag = true;
- }
- else
- {
- flag = (string.IsNullOrWhiteSpace(value.get_Apolice()) || string.IsNullOrWhiteSpace(value.get_Proposta()) ? false : value.get_Emissao().HasValue);
- }
- base.EnableEndossar = flag;
- base.EnableRenovar = (value == null || value.get_Id() <= (long)0 || !value.get_Vigencia2().HasValue ? false : !string.IsNullOrWhiteSpace(value.get_Apolice()));
- this.WorkOnSelectedDocumento(value);
- if (Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 19))
- {
- if (value != null)
- {
- apolice = value.get_Apolice();
- }
- else
- {
- apolice = null;
- }
- if (string.IsNullOrWhiteSpace(apolice) || !value.get_Emissao().HasValue)
- {
- visibility = Visibility.Visible;
- this.RecusaVisibility = visibility;
- this.ItensRevelados = false;
- this.MostrarItensVisibility = Visibility.Collapsed;
- this.MostrarSinistroVisibility = Visibility.Visible;
- base.OnPropertyChanged("SelectedControle");
- return;
- }
- visibility = Visibility.Collapsed;
- this.RecusaVisibility = visibility;
- this.ItensRevelados = false;
- this.MostrarItensVisibility = Visibility.Collapsed;
- this.MostrarSinistroVisibility = Visibility.Visible;
- base.OnPropertyChanged("SelectedControle");
- return;
- }
- visibility = Visibility.Visible;
- this.RecusaVisibility = visibility;
- this.ItensRevelados = false;
- this.MostrarItensVisibility = Visibility.Collapsed;
- this.MostrarSinistroVisibility = Visibility.Visible;
- base.OnPropertyChanged("SelectedControle");
- }
- }
-
- public Documento SelectedEndosso
- {
- get
- {
- return this._selectedEndosso;
- }
- set
- {
- this._selectedEndosso = value;
- this.WorkOnSelectedDocumento(value);
- base.OnPropertyChanged("SelectedEndosso");
- }
- }
-
- public Item SelectedItem
- {
- get
- {
- return this._selectedItem;
- }
- set
- {
- this._selectedItem = value;
- ConsultaViewModel.WorkOnSelectedItem(value);
- base.OnPropertyChanged("SelectedItem");
- }
- }
-
- public Parcela SelectedParcela
- {
- get
- {
- return this._selectedParcela;
- }
- set
- {
- this._selectedParcela = value;
- base.OnPropertyChanged("SelectedParcela");
- }
- }
-
- public Visibility SemDocumentos
- {
- get
- {
- return this._semDocumentos;
- }
- set
- {
- this._semDocumentos = value;
- base.OnPropertyChanged("SemDocumentos");
- }
- }
-
- public Visibility TarefasVisibility
- {
- get
- {
- return this._tarefasVisibility;
- }
- set
- {
- this._tarefasVisibility = (base.Permissao(38) ? value : Visibility.Collapsed);
- base.OnPropertyChanged("TarefasVisibility");
- }
- }
-
- public ObservableCollection<ClienteTelefone> Telefones
- {
- get
- {
- return this._telefones;
- }
- set
- {
- this._telefones = value;
- base.OnPropertyChanged("Telefones");
- }
- }
-
- public Visibility TrocarClienteVisibility
- {
- get
- {
- return this._trocarClienteVisibility;
- }
- set
- {
- this._trocarClienteVisibility = (!base.Restricao(21) ? value : Visibility.Collapsed);
- base.OnPropertyChanged("TrocarClienteVisibility");
- }
- }
-
- public Visibility VisibilityParcelasVendedores
- {
- get
- {
- return this._visibilityParcelasVendedores;
- }
- set
- {
- this._visibilityParcelasVendedores = value;
- base.OnPropertyChanged("VisibilityParcelasVendedores");
- }
- }
-
- public ConsultaViewModel()
- {
- this._apoliceServico = new ApoliceServico();
- this._parcelaServico = new ParcelaServico();
- this._vendedorServico = new VendedorServico();
- this._itemServico = new ItemServico();
- this.Apelido = Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 6);
- this.SemDocumentos = Visibility.Visible;
- base.EnableButtons = false;
- if (MainViewModel.ClienteSelecionado != null && MainViewModel.ClienteSelecionado.get_Id() > (long)0)
- {
- this.SelecionarCliente(MainViewModel.ClienteSelecionado);
- }
- }
-
- public async Task<Documento> AbrirDetalhes()
- {
- Documento selectedControle = this.SelectedControle;
- if (this.FilterDocumento == 1)
- {
- Documento selectedEndosso = this.SelectedEndosso;
- if (selectedEndosso == null)
- {
- selectedEndosso = this.SelectedControle;
- }
- selectedControle = selectedEndosso;
- }
- Documento documento = selectedControle;
- List<VendedorParcela> vendedorParcelas = await this._vendedorServico.BuscaRepasse(selectedControle.get_Id());
- documento.set_Pagamentos(vendedorParcelas);
- documento = null;
- documento = selectedControle;
- ObservableCollection<Parcela> observableCollection = await this._parcelaServico.BuscarParcelasAsync(selectedControle.get_Id());
- documento.set_Parcelas(observableCollection);
- documento = null;
- Documento documento1 = selectedControle;
- selectedControle = null;
- return documento1;
- }
-
- public async Task<Parcela> AbrirDetalhesParcela()
- {
- Parcela selectedParcela = this.SelectedParcela;
- List<VendedorParcela> vendedorParcelas = await this._vendedorServico.BuscaRepasseParcela(selectedParcela.get_Id());
- selectedParcela.set_Vendedores(new ObservableCollection<VendedorParcela>(vendedorParcelas));
- Parcela parcela = selectedParcela;
- selectedParcela = null;
- return parcela;
- }
-
- private void CalculaComissao(Documento documento, ObservableCollection<Parcela> parcelas)
- {
- decimal num = (documento.get_AdicionalComiss() ? documento.get_PremioLiquido() + documento.get_PremioAdicional() : documento.get_PremioLiquido());
- decimal comissao = documento.get_Comissao() * new decimal(1, 0, 0, false, 2);
- this.Gerada = num * comissao;
- this.Recebida = (Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 32) ? parcelas.Where<Parcela>((Parcela x) => {
- if (x.get_SubTipo() == 1)
- {
- return true;
- }
- return x.get_SubTipo() == 6;
- }).Sum<Parcela>((Parcela x) => x.get_ValorComissao()) : (
- from x in parcelas
- where x.get_SubTipo() == 1
- select x).Sum<Parcela>((Parcela x) => x.get_ValorComissao()));
- this.Pendente = this.Gerada - this.Recebida;
- this.Pendente = (this.Pendente < new decimal(1, 0, 0, false, 2) ? new decimal(0, 0, 0, false, 2) : this.Pendente);
- }
-
- public void CarregaDocumentos(int type)
- {
- this.IsVisibleApolice = Visibility.Collapsed;
- this.IsVisibleEndosso = Visibility.Collapsed;
- if (type != 1)
- {
- this.IsVisibleApolice = Visibility.Visible;
- return;
- }
- this.IsVisibleEndosso = Visibility.Visible;
- }
-
- public async Task CarregaItens(int type, Documento documento)
- {
- this.FilterItens = 0;
- switch (type)
- {
- case 0:
- {
- this.Itens = await this._itemServico.BuscarItens(documento.get_Controle().get_Id(), 0);
- break;
- }
- case 1:
- {
- this.FilterItens = 1;
- this.Itens = await this._itemServico.BuscarItens(documento.get_Id(), 2);
- break;
- }
- case 2:
- {
- this.FilterItens = 2;
- Documento selectedEndosso = this.SelectedEndosso;
- if (selectedEndosso == null)
- {
- selectedEndosso = documento;
- }
- documento = selectedEndosso;
- this.Itens = await this._itemServico.BuscarItens(documento.get_Id(), 2);
- break;
- }
- case 3:
- {
- this.FilterItens = 3;
- this.Itens = await this._itemServico.BuscarItens(documento.get_Controle().get_Id(), 1);
- break;
- }
- }
- }
-
- private void Clear()
- {
- this.Apolices = null;
- this.Parcelas = null;
- this.Itens = null;
- }
-
- public async Task<string> CreateLink(Documento documento)
- {
- string str;
- string descricao;
- if (documento == null || this.SelectedCliente == null)
- {
- str = "";
- }
- else
- {
- this.Telefones = new ObservableCollection<ClienteTelefone>((IEnumerable<!0>)await (new ClienteServico()).BuscarTelefonesAsync(this.SelectedCliente.get_Id()));
- if (this.Itens == null)
- {
- descricao = "";
- }
- else if (this.Itens.Count > 1)
- {
- descricao = "APÓLICE COLETIVA";
- }
- else
- {
- Item item = this.Itens.FirstOrDefault<Item>();
- if (item != null)
- {
- descricao = item.get_Descricao();
- }
- else
- {
- descricao = null;
- }
- }
- str = await base.CreateLinkAssistencia(documento, descricao, true);
- }
- return str;
- }
-
- public async Task EditarParcelas()
- {
- await base.ShowEditarParcelasDialog(ConsultaViewModel.DocumentoSelecionado);
- await this.SelecionaParcelas(ConsultaViewModel.DocumentoSelecionado);
- }
-
- public async Task GerarExcel(int type)
- {
- ObservableCollection<Item> observableCollection;
- string str1;
- ConsultaViewModel.u003cu003ec__DisplayClass212_0 variable;
- string str2;
- string str3;
- if (this.SelectedControle != null)
- {
- base.Loading(true);
- bool typeFromProgID = Type.GetTypeFromProgID("Excel.Application") != null;
- str2 = "ATIVOS";
- switch (type)
- {
- case 1:
- {
- str2 = "DA APÓLICE";
- observableCollection = await this._itemServico.BuscarItems(this.SelectedControle.get_Id(), 2, true);
- break;
- }
- case 2:
- {
- Documento selectedEndosso = this.SelectedEndosso;
- if (selectedEndosso == null)
- {
- selectedEndosso = this.SelectedControle;
- }
- Documento documento = selectedEndosso;
- str2 = (this.SelectedEndosso == null ? "DA APÓLICE" : "DO ENDOSSO");
- observableCollection = await this._itemServico.BuscarItems(documento.get_Id(), 2, true);
- break;
- }
- case 3:
- {
- str2 = "INATIVOS";
- observableCollection = await this._itemServico.BuscarItems(this.SelectedControle.get_Controle().get_Id(), 1, true);
- break;
- }
- default:
- {
- observableCollection = await this._itemServico.BuscarItems(this.SelectedControle.get_Controle().get_Id(), 0, true);
- break;
- }
- }
- if (observableCollection == null || observableCollection.Count == 0)
- {
- base.Loading(false);
- await base.ShowMessage("NÃO HÁ ITENS PARA EXIBIR A RELAÇÃO", "OK", "", false);
- }
- else
- {
- List<RelacaoItens> relacaoItens = new List<RelacaoItens>();
- observableCollection.ToList<Item>().ForEach((Item x) => {
- DateTime? nullable;
- StatusSinistro? nullable1;
- decimal? nullable2;
- DateTime? dataSinistro;
- string numero;
- StatusSinistro? statusSinistro;
- string itemSinistrado;
- decimal? nullable3;
- DateTime? dataLiquidacao;
- DateTime? dataReclamacao;
- string motivo;
- string descricao;
- string str = "";
- if (x.get_Coberturas().Count<Cobertura>() > 0)
- {
- x.get_Coberturas().ToList<Cobertura>().ForEach((Cobertura c) => str = string.Concat(str, string.Format("Cobertura: {0} | Premio: {1} | Franquia: {2} | LMI: {3}\n", new object[] { c.get_Observacao(), c.get_Premio(), c.get_Franquia(), c.get_Lmi() })));
- }
- RelacaoItens relacaoIten = new RelacaoItens()
- {
- Nome = this.SelectedCliente.get_Nome(),
- Documento = this.SelectedCliente.get_Documento(),
- Apolice = this.SelectedControle.get_Apolice(),
- VigenciaInicial = this.SelectedControle.get_Vigencia1(),
- VigenciaFinal = this.SelectedControle.get_Vigencia2(),
- Ordem = x.get_Ordem(),
- Sinistrado = (x.get_Sinistrado() ? "SIM" : "NÃO")
- };
- ControleSinistro controleSinistro = x.get_Sinistros().FirstOrDefault<ControleSinistro>();
- if (controleSinistro != null)
- {
- dataSinistro = controleSinistro.get_DataSinistro();
- }
- else
- {
- nullable = null;
- dataSinistro = nullable;
- }
- relacaoIten.DataSinistro = dataSinistro;
- ControleSinistro controleSinistro1 = x.get_Sinistros().FirstOrDefault<ControleSinistro>();
- if (controleSinistro1 != null)
- {
- Sinistro sinistro = controleSinistro1.get_Sinistros().FirstOrDefault<Sinistro>();
- if (sinistro != null)
- {
- numero = sinistro.get_Numero();
- }
- else
- {
- numero = null;
- }
- }
- else
- {
- numero = null;
- }
- relacaoIten.NumSinistro = numero;
- ControleSinistro controleSinistro2 = x.get_Sinistros().FirstOrDefault<ControleSinistro>();
- if (controleSinistro2 != null)
- {
- Sinistro sinistro1 = controleSinistro2.get_Sinistros().FirstOrDefault<Sinistro>();
- if (sinistro1 != null)
- {
- statusSinistro = sinistro1.get_StatusSinistro();
- }
- else
- {
- nullable1 = null;
- statusSinistro = nullable1;
- }
- }
- else
- {
- nullable1 = null;
- statusSinistro = nullable1;
- }
- relacaoIten.StatusSinistro = statusSinistro;
- ControleSinistro controleSinistro3 = x.get_Sinistros().FirstOrDefault<ControleSinistro>();
- if (controleSinistro3 != null)
- {
- Sinistro sinistro2 = controleSinistro3.get_Sinistros().FirstOrDefault<Sinistro>();
- if (sinistro2 != null)
- {
- itemSinistrado = sinistro2.get_ItemSinistrado();
- }
- else
- {
- itemSinistrado = null;
- }
- }
- else
- {
- itemSinistrado = null;
- }
- relacaoIten.ItemSinistrado = itemSinistrado;
- ControleSinistro controleSinistro4 = x.get_Sinistros().FirstOrDefault<ControleSinistro>();
- if (controleSinistro4 != null)
- {
- Sinistro sinistro3 = controleSinistro4.get_Sinistros().FirstOrDefault<Sinistro>();
- if (sinistro3 != null)
- {
- nullable3 = new decimal?(sinistro3.get_Valor());
- }
- else
- {
- nullable2 = null;
- nullable3 = nullable2;
- }
- }
- else
- {
- nullable2 = null;
- nullable3 = nullable2;
- }
- relacaoIten.Valor = nullable3;
- ControleSinistro controleSinistro5 = x.get_Sinistros().FirstOrDefault<ControleSinistro>();
- if (controleSinistro5 != null)
- {
- Sinistro sinistro4 = controleSinistro5.get_Sinistros().FirstOrDefault<Sinistro>();
- if (sinistro4 != null)
- {
- dataLiquidacao = sinistro4.get_DataLiquidacao();
- }
- else
- {
- nullable = null;
- dataLiquidacao = nullable;
- }
- }
- else
- {
- nullable = null;
- dataLiquidacao = nullable;
- }
- relacaoIten.DataLiq = dataLiquidacao;
- ControleSinistro controleSinistro6 = x.get_Sinistros().FirstOrDefault<ControleSinistro>();
- if (controleSinistro6 != null)
- {
- Sinistro sinistro5 = controleSinistro6.get_Sinistros().FirstOrDefault<Sinistro>();
- if (sinistro5 != null)
- {
- dataReclamacao = sinistro5.get_DataReclamacao();
- }
- else
- {
- nullable = null;
- dataReclamacao = nullable;
- }
- }
- else
- {
- nullable = null;
- dataReclamacao = nullable;
- }
- relacaoIten.DataRec = dataReclamacao;
- ControleSinistro controleSinistro7 = x.get_Sinistros().FirstOrDefault<ControleSinistro>();
- if (controleSinistro7 != null)
- {
- Sinistro sinistro6 = controleSinistro7.get_Sinistros().FirstOrDefault<Sinistro>();
- if (sinistro6 != null)
- {
- motivo = sinistro6.get_Motivo();
- }
- else
- {
- motivo = null;
- }
- }
- else
- {
- motivo = null;
- }
- relacaoIten.Motivo = motivo;
- relacaoIten.Status = (string.IsNullOrEmpty(x.get_Status()) ? x.get_StatusInclusao() : x.get_Status());
- relacaoIten.Cobertura = (str.Length > 4000 ? str.Substring(0, 4000) : str);
- RelacaoItens endereco = relacaoIten;
- long id = this.SelectedControle.get_Controle().get_Ramo().get_Id();
- if (id > (long)5)
- {
- if (id == (long)18)
- {
- endereco.Endereco = x.get_Patrimonial().get_Endereco();
- endereco.Numero = x.get_Patrimonial().get_Numero();
- endereco.Bairro = x.get_Patrimonial().get_Bairro();
- endereco.Cidade = x.get_Patrimonial().get_Cidade();
- endereco.Estado = x.get_Patrimonial().get_Estado();
- endereco.Cep = x.get_Patrimonial().get_Cep();
- endereco.Complemento = x.get_Patrimonial().get_Complemento();
- endereco.Bens = x.get_Patrimonial().get_Bens();
- endereco.Descricao = x.get_Descricao();
- relacaoItens.Add(endereco);
- return;
- }
- if (id == (long)37)
- {
- goto Label1;
- }
- }
- else
- {
- if (id - (long)1 <= (long)2)
- {
- endereco.Endereco = x.get_Patrimonial().get_Endereco();
- endereco.Numero = x.get_Patrimonial().get_Numero();
- endereco.Bairro = x.get_Patrimonial().get_Bairro();
- endereco.Cidade = x.get_Patrimonial().get_Cidade();
- endereco.Estado = x.get_Patrimonial().get_Estado();
- endereco.Cep = x.get_Patrimonial().get_Cep();
- endereco.Complemento = x.get_Patrimonial().get_Complemento();
- endereco.Bens = x.get_Patrimonial().get_Bens();
- endereco.Descricao = x.get_Descricao();
- relacaoItens.Add(endereco);
- return;
- }
- if (id == (long)5)
- {
- goto Label1;
- }
- }
- endereco.Descricao = x.get_Descricao();
- relacaoItens.Add(endereco);
- return;
- Label1:
- endereco.Fipe = x.get_Auto().get_Fipe();
- RelacaoItens relacaoIten1 = endereco;
- Fabricante fabricante = x.get_Auto().get_Fabricante();
- if (fabricante != null)
- {
- descricao = fabricante.get_Descricao();
- }
- else
- {
- descricao = null;
- }
- relacaoIten1.Fabricante = descricao;
- endereco.Modelo = x.get_Auto().get_Modelo();
- endereco.AnoFab = x.get_Auto().get_AnoFabricacao();
- endereco.AnoMod = x.get_Auto().get_AnoModelo();
- endereco.Chassi = x.get_Auto().get_Chassi();
- endereco.Placa = x.get_Auto().get_Placa();
- endereco.RegiaoCirculacao = x.get_Auto().get_RegiaoCirculacao();
- endereco.Bonus = x.get_Auto().get_Bonus();
- endereco.Descricao = x.get_Descricao();
- relacaoItens.Add(endereco);
- });
- string tempPath = "";
- str3 = "";
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (!configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 41))
- {
- tempPath = Path.GetTempPath();
- str3 = string.Format("{0}{1}.xlsx", tempPath, Guid.NewGuid());
- }
- else
- {
- using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
- {
- if (DialogResult.OK == folderBrowserDialog.ShowDialog())
- {
- tempPath = string.Concat(folderBrowserDialog.SelectedPath, "\\");
- Directory.CreateDirectory(tempPath);
- }
- else
- {
- variable = null;
- str2 = null;
- str3 = null;
- return;
- }
- }
- object[] objArray = new object[] { tempPath, str2, this.SelectedControle.get_Apolice().Replace("/", ""), Guid.NewGuid() };
- str3 = string.Format("{0}ITENS - {1} {2} {3}.xlsx", objArray);
- }
- XLWorkbook xLWorkbook = new XLWorkbook();
- string apolice = this.SelectedControle.get_Apolice();
- if (apolice != null)
- {
- str1 = apolice.Replace("/", "");
- }
- else
- {
- str1 = null;
- }
- await Funcoes.GerarXls<RelacaoItens>(xLWorkbook, string.Concat("ITENS - ", str1), relacaoItens, null).SaveAs(str3);
- if (!typeFromProgID)
- {
- await base.ShowMessage(string.Concat("ARQUIVO SALVO NO CAMINHO ", str3), "OK", "", false);
- }
- else
- {
- Process.Start(str3);
- }
- base.RegistrarAcao(string.Format("GEROU A RELAÇÃO DOS ITENS DO DOCUMENTO DE ID {0}", this.SelectedControle.get_Id()), this.SelectedControle.get_Id(), new TipoTela?(21), null);
- base.Loading(false);
- }
- }
- variable = null;
- str2 = null;
- str3 = null;
- }
-
- public void ManutecaoItens()
- {
- Action<TipoTela, string> acessaTela = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela == null)
- {
- return;
- }
- acessaTela(3, "Manutencao");
- }
-
- public async Task MostrarItens(int type = 0)
- {
- bool count;
- Item item;
- this.IsLoadingItens = false;
- this.MostrarItensVisibility = Visibility.Collapsed;
- this.MostrarSinistroVisibility = Visibility.Visible;
- this.ItensRevelados = true;
- Documento documentoSelecionado = ConsultaViewModel.DocumentoSelecionado;
- if (type == 1 && ConsultaViewModel.DocumentoSelecionado.get_Tipo() == 1)
- {
- documentoSelecionado = this.SelectedControle;
- }
- await this.CarregaItens(type, documentoSelecionado);
- ObservableCollection<Item> itens = this.Itens;
- if (itens != null)
- {
- count = itens.Count > 1;
- }
- else
- {
- count = false;
- }
- if (count)
- {
- ConsultaViewModel consultaViewModel = this;
- ObservableCollection<Item> observableCollection = this.Itens;
- if (observableCollection != null)
- {
- item = observableCollection.FirstOrDefault<Item>();
- }
- else
- {
- item = null;
- }
- consultaViewModel.SelectedItem = item;
- }
- this.IsLoadingItens = true;
- }
-
- public async Task Pesquisar(PesquisaAvancada pesquisa)
- {
- TimeSpan vigencia1;
- string str;
- Visibility visibility;
- int num;
- int num1;
- string str1;
- ConsultaViewModel.u003cu003ec__DisplayClass24_0 variable;
- MainViewModel.StatusSelecionado = pesquisa.get_Status();
- if (pesquisa.get_IdDocumento() != 0)
- {
- this.Pesquisando = true;
- await this.SelecionarCliente(pesquisa.get_IdCliente(), false);
- base.Loading(true);
- Documento documento = await this._apoliceServico.BuscarApoliceAsync(pesquisa.get_IdDocumento(), false, false);
- Documento documento1 = documento;
- if (documento1 == null || this.Apolices.Count == 0 || this.Apolices == null)
- {
- this.Pesquisando = false;
- base.Loading(false);
- }
- else
- {
- Documento documento2 = this.Apolices.FirstOrDefault<Documento>((Documento x) => x.get_Controle().get_Id() == documento1.get_Controle().get_Id());
- if (documento2 == null && documento1.get_Tipo() == 1)
- {
- documento2 = documento1;
- documento2.set_TemEndosso(true);
- if (documento2 == null)
- {
- this.Pesquisando = false;
- base.Loading(false);
- variable = null;
- return;
- }
- }
- this.SelectedControle = documento2;
- this.IsVisibleApolice = Visibility.Visible;
- this.VisibilityParcelasVendedores = Visibility.Collapsed;
- DateTime date = Funcoes.GetNetworkTime().Date;
- ConsultaViewModel consultaViewModel = this;
- if (string.IsNullOrEmpty(documento2.get_Apolice()))
- {
- vigencia1 = date - documento2.get_Vigencia1();
- str = string.Format("{0} DIAS DE PENDÊNCIA", vigencia1.TotalDays);
- }
- else
- {
- str = "";
- }
- consultaViewModel.PendenciaApolice = str;
- ConsultaViewModel consultaViewModel1 = this;
- visibility = (documento2.get_TemEndosso() ? Visibility.Visible : Visibility.Collapsed);
- consultaViewModel1.IsVisibleRadioEndosso = visibility;
- if (documento2.get_TemEndosso())
- {
- this.IsVisibleRadioEndosso = Visibility.Visible;
- ConsultaViewModel observableCollection = this;
- IList<Documento> documentos = documento2.get_Controle().get_Documentos();
- observableCollection.Endossos = new ObservableCollection<Documento>(documentos.Where<Documento>((Documento x) => {
- if (x.get_Tipo() != 1)
- {
- return false;
- }
- return !x.get_Excluido();
- }));
- }
- if (documento1.get_Tipo() == 1)
- {
- documento1 = this.Endossos.First<Documento>((Documento x) => x.get_Id() == documento1.get_Id());
- this.FilterDocumento = 1;
- this.IsVisibleEndosso = Visibility.Visible;
- this.SelectedEndosso = documento1;
- ConsultaViewModel consultaViewModel2 = this;
- if (string.IsNullOrEmpty(documento1.get_Endosso()))
- {
- vigencia1 = date - documento1.get_Vigencia1();
- str1 = string.Format("{0} DIAS DE PENDÊNCIA", vigencia1.TotalDays);
- }
- else
- {
- str1 = "";
- }
- consultaViewModel2.PendenciaApolice = str1;
- }
- this.CarregaDocumentos(documento1.get_Tipo());
- await this.SelecionaParcelas(documento1);
- this.VisibilityParcelasVendedores = Visibility.Visible;
- this.Pesquisando = false;
- if (pesquisa.get_IdItem() != 0)
- {
- ConsultaViewModel consultaViewModel3 = this;
- num = (documento1.get_Tipo() == 0 ? 1 : 2);
- await consultaViewModel3.SelecionaItens(num, documento1, pesquisa.get_IdItem(), true);
- this.SelecionaItem(this.Itens.FirstOrDefault<Item>((Item x) => x.get_Id() == pesquisa.get_IdItem()));
- base.Loading(false);
- if (pesquisa.get_IdSinistro() != 0)
- {
- Action<TipoTela, string> acessaTela = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela != null)
- {
- acessaTela(7, "");
- }
- else
- {
- }
- }
- }
- else
- {
- ConsultaViewModel consultaViewModel4 = this;
- num1 = (documento1.get_Tipo() == 0 ? 1 : 2);
- await consultaViewModel4.SelecionaItens(num1, documento1, (long)0, false);
- base.Loading(false);
- }
- }
- }
- else
- {
- await this.SelecionarCliente(pesquisa.get_IdCliente(), true);
- }
- variable = null;
- }
-
- public async Task RecusarDocumento()
- {
- bool flag;
- IList<Documento> list;
- string str;
- Documento documento;
- if (ConsultaViewModel.DocumentoSelecionado != null)
- {
- bool[] flagArray = await Funcoes.VerificarPagamento(ConsultaViewModel.DocumentoSelecionado.get_Id());
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 23))
- {
- bool[] flagArray1 = flagArray;
- if (((IEnumerable<bool>)flagArray1).Any<bool>((bool x) => x))
- {
- await base.ShowMessage("NÃO É POSSÍVEL RECUSAR UMA APÓLICE ENQUANTO HOUVER RECEBIMENTO DE COMISSÃO OU PAGAMENTO DE VENDEDORES", "OK", "", false);
- documento = null;
- return;
- }
- }
- List<ConfiguracaoSistema> configuracaoSistemas = Recursos.Configuracoes;
- flag = (!configuracaoSistemas.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 23) ? false : flagArray[1]);
- bool flag1 = flag;
- if (flag1)
- {
- flag1 = await base.ShowMessage("EXISTEM PAGAMENTOS PARA OS VENDEDORES DO CONTRATO, DESEJA CRIAR ESTORNOS PARA ESSES PAGAMENTOS?", "SIM", "NÃO", false);
- }
- bool flag2 = flag1;
- documento = await this._apoliceServico.BuscarApoliceAsync(ConsultaViewModel.DocumentoSelecionado.get_Id(), false, false);
- if (documento.get_Controle().get_Documentos().Count > 1)
- {
- IList<Documento> documentos = documento.get_Controle().get_Documentos();
- IEnumerable<Documento> excluido =
- from x in documentos
- where !x.get_Excluido()
- select x;
- list = (
- from x in excluido
- orderby x.get_Ordem()
- select x).ToList<Documento>();
- }
- else
- {
- list = documento.get_Controle().get_Documentos();
- }
- IList<Documento> documentos1 = list;
- if (documentos1.Count > 1)
- {
- IList<Documento> documentos2 = documentos1;
- if (documentos2.Last<Documento>((Documento x) => x.get_Situacao() != 7).get_Id() != ConsultaViewModel.DocumentoSelecionado.get_Id())
- {
- await base.ShowMessage("NÃO É POSSÍVEL RECUSAR UM DOCUMENTO ENQUANTO HOUVER ENDOSSOS EM CIMA DO MESMO.", "OK", "", false);
- documento = null;
- return;
- }
- }
- if (documento.get_Situacao() != 7)
- {
- if (documento.get_Tipo() != 0 || !string.IsNullOrEmpty(documento.get_Apolice()))
- {
- str = (documento.get_Tipo() != 0 || string.IsNullOrEmpty(documento.get_Apolice()) ? "O ENDOSSO SELECIONADO" : "A APÓLICE SELECIONADA");
- }
- else
- {
- str = "A PROPOSTA SELECIONADA";
- }
- string str1 = str;
- if (await base.ShowMessage(string.Concat("DESEJA REALMENTE RECUSAR ", str1, "?"), "SIM", "NÃO", false))
- {
- string str2 = null;
- str2 = await base.ShowObservacaoDialog();
- if (str2 != null)
- {
- base.Loading(true);
- await Funcoes.RecusarApolice(documento, str2, flag2);
- ConsultaViewModel.DocumentoSelecionado = null;
- await this.SelecionaCliente(this.SelectedCliente, true);
- base.Loading(false);
- }
- }
- }
- else
- {
- await base.ShowMessage("NÃO É POSSÍVEL RECUSAR UM DOCUMENTO JÁ RECUSADO.", "OK", "", false);
- }
- }
- documento = null;
- }
-
- public async void SalvarOrdem(ObservableCollection<Item> itens)
- {
- if (itens != null)
- {
- ObservableCollection<Item> observableCollection = itens;
- if (!observableCollection.Any<Item>((Item x) => {
- int? ordem = x.get_Ordem();
- return ordem.GetValueOrDefault() == 0 & ordem.HasValue;
- }))
- {
- ObservableCollection<Item> observableCollection1 = itens;
- IEnumerable<IGrouping<int?, Item>> groupings =
- from item in observableCollection1
- group item by item.get_Ordem();
- if (!groupings.Any<IGrouping<int?, Item>>((IGrouping<int?, Item> x) => x.Count<Item>() > 1))
- {
- base.Loading(true);
- foreach (Item iten in itens)
- {
- await this._itemServico.Save(iten);
- }
- await this.SelecionaItens(this.FilterItens, null, (long)0, false);
- base.Loading(false);
- }
- else
- {
- await base.ShowMessage("EXISTEM ITENS COM ORDEM REPETIDA. \nDEFINA UMA SEQUÊNCIA DIFERENTE PARA CADA ITEM.", "OK", "", false);
- }
- }
- else
- {
- await base.ShowMessage("O CAMPO ORDEM DEVE SER MAIOR QUE ZERO.", "OK", "", false);
- }
- }
- }
-
- public void ScrollDocumento()
- {
- if (this.UpdatingScroll)
- {
- return;
- }
- this.UpdatingScroll = true;
- Task.Run(async () => {
- await Task.Delay(300);
- System.Windows.Application.Current.Dispatcher.Invoke(() => {
- Action scrollDocumento = Gestor.Application.Actions.Actions.ScrollDocumento;
- if (scrollDocumento == null)
- {
- return;
- }
- scrollDocumento();
- });
- });
- }
-
- public async Task SelecionaCliente(Cliente value, bool selecionar = true)
- {
- List<VendedorUsuario> vendedorUsuarios;
- long? nullable1;
- long? nullable2;
- string str;
- long? nullable3;
- Documento documento;
- long? nullable4;
- long? nullable5;
- long? nullable6;
- bool flag;
- Documento documento1;
- this.Clear();
- if (value == null || value.get_Id() == 0)
- {
- base.IsVisible = Visibility.Collapsed;
- }
- else
- {
- try
- {
- this.Carregando = true;
- base.Loading(true);
- this.SelectedCliente = value;
- ApoliceServico apoliceServico = this._apoliceServico;
- long num = value.get_Id();
- FiltroStatusDocumento statusSelecionado = MainViewModel.StatusSelecionado;
- if (Recursos.Usuario != null)
- {
- vendedorUsuarios = await base.VerificaVinculoVendedor(Recursos.Usuario);
- }
- else
- {
- vendedorUsuarios = new List<VendedorUsuario>();
- }
- ObservableCollection<Documento> observableCollection = await apoliceServico.BuscarApolicesAsync(num, statusSelecionado, vendedorUsuarios);
- apoliceServico = null;
- this.Apolices = observableCollection;
- ConsultaViewModel consultaViewModel = this;
- string[] nome = new string[] { "CONSULTOU ", null, null, null, null };
- str = (MainViewModel.StatusSelecionado != 4 ? string.Concat("OS ", Functions.GetDescription(MainViewModel.StatusSelecionado)) : "TODOS OS DOCUMENTOS");
- nome[1] = str;
- nome[2] = " DO CLIENTE \"";
- nome[3] = this.SelectedCliente.get_Nome();
- nome[4] = "\"";
- string str1 = string.Concat(nome);
- long num1 = this.SelectedCliente.get_Id();
- TipoTela? nullable7 = new TipoTela?(21);
- Cliente selectedCliente = this.SelectedCliente;
- if (selectedCliente != null)
- {
- nullable3 = new long?(selectedCliente.get_Id());
- }
- else
- {
- nullable1 = null;
- nullable3 = nullable1;
- }
- consultaViewModel.RegistrarAcao(str1, num1, nullable7, string.Format("ID CLIENTE: {0}", nullable3));
- if (this.Apolices == null || this.Apolices.Count <= 0)
- {
- this.SelectedControle = null;
- this.SelectedEndosso = null;
- this.SelectedItem = null;
- this.SelectedParcela = null;
- ConsultaViewModel.DocumentoSelecionado = null;
- ConsultaViewModel.ItemSelecionado = null;
- this.FilterDocumento = 0;
- this.IsVisibleRadioEndosso = Visibility.Collapsed;
- Action<Documento> updateDocumento = Gestor.Application.Actions.Actions.UpdateDocumento;
- if (updateDocumento != null)
- {
- updateDocumento(null);
- }
- else
- {
- }
- }
- else if (selecionar)
- {
- if (ConsultaViewModel.DocumentoSelecionado != null && ConsultaViewModel.DocumentoSelecionado.get_Tipo() != 0)
- {
- Controle controle = ConsultaViewModel.DocumentoSelecionado.get_Controle();
- if (controle != null)
- {
- Cliente cliente = controle.get_Cliente();
- if (cliente != null)
- {
- nullable4 = new long?(cliente.get_Id());
- }
- else
- {
- nullable2 = null;
- nullable4 = nullable2;
- }
- }
- else
- {
- nullable2 = null;
- nullable4 = nullable2;
- }
- nullable1 = nullable4;
- long num2 = value.get_Id();
- if (nullable1.GetValueOrDefault() != num2 | !nullable1.HasValue)
- {
- goto Label2;
- }
- Controle controle1 = ConsultaViewModel.DocumentoSelecionado.get_Controle();
- if (controle1 != null)
- {
- IList<Documento> documentos = controle1.get_Documentos();
- if (documentos != null)
- {
- Documento documento2 = documentos.FirstOrDefault<Documento>((Documento x) => x.get_Tipo() == 0);
- if (documento2 != null)
- {
- nullable5 = new long?(documento2.get_Id());
- }
- else
- {
- nullable1 = null;
- nullable5 = nullable1;
- }
- }
- else
- {
- nullable1 = null;
- nullable5 = nullable1;
- }
- }
- else
- {
- nullable1 = null;
- nullable5 = nullable1;
- }
- nullable1 = nullable5;
- long valueOrDefault = nullable1.GetValueOrDefault();
- Documento documentoSelecionado = ConsultaViewModel.DocumentoSelecionado;
- if (documentoSelecionado != null)
- {
- nullable6 = new long?(documentoSelecionado.get_Id());
- }
- else
- {
- nullable1 = null;
- nullable6 = nullable1;
- }
- long? nullable8 = nullable6;
- if (valueOrDefault > (long)0)
- {
- flag = this.Apolices.FirstOrDefault<Documento>((Documento x) => x.get_Id() == valueOrDefault);
- }
- else
- {
- flag = false;
- }
- if (!flag)
- {
- ConsultaViewModel consultaViewModel1 = this;
- if (ConsultaViewModel.DocumentoSelecionado != null)
- {
- ObservableCollection<Documento> apolices = this.Apolices;
- documento1 = apolices.FirstOrDefault<Documento>((Documento x) => x.get_Id() == ConsultaViewModel.DocumentoSelecionado.get_Id());
- if (documento1 == null)
- {
- documento1 = this.Apolices.FirstOrDefault<Documento>();
- }
- }
- else
- {
- documento1 = this.Apolices.FirstOrDefault<Documento>();
- }
- await consultaViewModel1.SelecionaDocumento(0, documento1);
- this.CarregaDocumentos(0);
- }
- else
- {
- await this.SelecionaDocumento(0, this.Apolices.FirstOrDefault<Documento>((Documento x) => x.get_Id() == valueOrDefault));
- this.FilterDocumento = 1;
- this.IsVisibleEndosso = Visibility.Visible;
- ConsultaViewModel consultaViewModel2 = this;
- Documento item = this.Endossos.FirstOrDefault<Documento>((Documento x) => {
- long id = x.get_Id();
- long? nullable = nullable8;
- return id == nullable.GetValueOrDefault() & nullable.HasValue;
- });
- if (item == null)
- {
- item = this.Endossos[0];
- }
- consultaViewModel2.SelectedEndosso = item;
- this.IsLoading = false;
- await this.WorkOnSelectedEndosso(this.SelectedEndosso);
- this.CarregaDocumentos(1);
- }
- goto Label1;
- }
- Label2:
- ConsultaViewModel consultaViewModel3 = this;
- if (ConsultaViewModel.DocumentoSelecionado != null)
- {
- ObservableCollection<Documento> apolices1 = this.Apolices;
- documento = apolices1.FirstOrDefault<Documento>((Documento x) => x.get_Id() == ConsultaViewModel.DocumentoSelecionado.get_Id());
- if (documento == null)
- {
- documento = this.Apolices.FirstOrDefault<Documento>();
- }
- }
- else
- {
- documento = this.Apolices.FirstOrDefault<Documento>();
- }
- await consultaViewModel3.SelecionaDocumento(0, documento);
- this.CarregaDocumentos(0);
- }
- else
- {
- base.Loading(false);
- this.Carregando = false;
- return;
- }
- Label1:
- this.ManutencaoItemVisibility = Visibility.Visible;
- this.RenovarVisibility = Visibility.Visible;
- this.TrocarClienteVisibility = Visibility.Visible;
- this.TarefasVisibility = Visibility.Visible;
- this.EndossarVisibility = Visibility.Visible;
- this.ComissaoVisibility = Visibility.Visible;
- base.Loading(false);
- }
- catch (Exception exception1)
- {
- Exception exception = exception1;
- this.Clear();
- this.SelectedControle = null;
- this.SelectedEndosso = null;
- this.SelectedItem = null;
- this.SelectedParcela = null;
- ConsultaViewModel.DocumentoSelecionado = null;
- ConsultaViewModel.ItemSelecionado = null;
- this.FilterDocumento = 0;
- this.IsVisibleRadioEndosso = Visibility.Collapsed;
- Action<Documento> action = Gestor.Application.Actions.Actions.UpdateDocumento;
- if (action != null)
- {
- action(null);
- }
- else
- {
- }
- (new BaseServico()).Registrar(exception, 1, 3, new { @value = value, selecionar = selecionar }, true);
- }
- this.Carregando = false;
- }
- }
-
- public async Task SelecionaDocumento(int type, Documento documento)
- {
- if (!this.Pesquisando)
- {
- if (documento != null)
- {
- documento.get_Controle().get_Cliente().set_Nome(this.SelectedCliente.get_Nome());
- if (type == 1)
- {
- this.FilterDocumento = 1;
- this.IsVisibleEndosso = Visibility.Visible;
- this.SelectedEndosso = documento;
- await this.WorkOnSelectedEndosso(documento);
- }
- else
- {
- this.FilterDocumento = 0;
- this.IsVisibleRadioEndosso = Visibility.Collapsed;
- this.IsVisibleApolice = Visibility.Visible;
- this.SelectedControle = documento;
- await this.WorkOnSelectedControle(documento);
- if (documento.get_TemEndosso())
- {
- this.IsVisibleRadioEndosso = Visibility.Visible;
- ConsultaViewModel observableCollection = this;
- IList<Documento> documentos = documento.get_Controle().get_Documentos();
- observableCollection.Endossos = new ObservableCollection<Documento>(documentos.Where<Documento>((Documento x) => {
- if (x.get_Tipo() != 1)
- {
- return false;
- }
- if (Recursos.Usuario.get_Id() == 0)
- {
- return true;
- }
- return !x.get_Excluido();
- }));
- }
- else
- {
- return;
- }
- }
- }
- else
- {
- this.FilterDocumento = 0;
- this.IsVisibleRadioEndosso = Visibility.Collapsed;
- this.IsVisibleApolice = Visibility.Visible;
- }
- }
- }
-
- public void SelecionaItem(Item item)
- {
- int num;
- if (item == null || item.get_Id() == 0)
- {
- return;
- }
- if (item != null)
- {
- long? substituido = item.get_Substituido();
- long num1 = (long)0;
- if (substituido.GetValueOrDefault() <= num1 | !substituido.HasValue)
- {
- num = 0;
- this.FilterItens = num;
- this.SelectedItem = item;
- return;
- }
- num = 3;
- this.FilterItens = num;
- this.SelectedItem = item;
- return;
- }
- num = 0;
- this.FilterItens = num;
- this.SelectedItem = item;
- }
-
- public async Task SelecionaItens(int type, Documento documento = null, long iditem = 0L, bool pesquisaAvancada = false)
- {
- long? substituido;
- long num;
- Item item;
- Item item1;
- bool valueOrDefault;
- Item item2;
- Item item3;
- bool flag;
- Item item4;
- Item item5;
- if (documento == null)
- {
- documento = this.SelectedControle;
- }
- if (documento != null)
- {
- this.IsLoadingItens = false;
- bool flag1 = !pesquisaAvancada;
- if (flag1)
- {
- flag1 = await this.VerificaItens(documento);
- }
- if (!flag1)
- {
- await this.CarregaItens(type, documento);
- int filterItens = this.FilterItens;
- if (iditem == 0 && filterItens != 2)
- {
- ObservableCollection<Item> itens = this.Itens;
- if (itens != null)
- {
- item = itens.FirstOrDefault<Item>((Item i) => {
- long? nullable;
- long id = i.get_Id();
- Item selectedItem = this.SelectedItem;
- if (selectedItem != null)
- {
- nullable = new long?(selectedItem.get_Id());
- }
- else
- {
- nullable = null;
- }
- long? nullable1 = nullable;
- return id == nullable1.GetValueOrDefault() & nullable1.HasValue;
- });
- }
- else
- {
- item = null;
- }
- Item item6 = item;
- if (item6 != null || filterItens == 0)
- {
- ConsultaViewModel consultaViewModel = this;
- if (item6 != null)
- {
- item1 = item6;
- }
- else
- {
- ObservableCollection<Item> observableCollection = this.Itens;
- if (observableCollection != null)
- {
- item1 = observableCollection.FirstOrDefault<Item>();
- }
- else
- {
- item1 = null;
- }
- }
- consultaViewModel.SelectedItem = item1;
- }
- else if (item6 == null && filterItens == 1)
- {
- Item item7 = this.SelectedItem;
- if (item7 != null)
- {
- substituido = item7.get_Substituicao();
- num = (long)0;
- flag = substituido.GetValueOrDefault() > num & substituido.HasValue;
- }
- else
- {
- flag = false;
- }
- if (flag)
- {
- ObservableCollection<Item> itens1 = this.Itens;
- if (itens1 != null)
- {
- item5 = itens1.FirstOrDefault<Item>((Item i) => {
- long? substituicao;
- long id = i.get_Id();
- Item selectedItem = this.SelectedItem;
- if (selectedItem != null)
- {
- substituicao = selectedItem.get_Substituicao();
- }
- else
- {
- substituicao = null;
- }
- long? nullable = substituicao;
- return id == nullable.GetValueOrDefault() & nullable.HasValue;
- });
- }
- else
- {
- item5 = null;
- }
- item6 = item5;
- }
- ConsultaViewModel consultaViewModel1 = this;
- if (item6 != null)
- {
- item4 = item6;
- }
- else
- {
- ObservableCollection<Item> observableCollection1 = this.Itens;
- if (observableCollection1 != null)
- {
- item4 = observableCollection1.FirstOrDefault<Item>();
- }
- else
- {
- item4 = null;
- }
- }
- consultaViewModel1.SelectedItem = item4;
- }
- Item item8 = this.SelectedItem;
- if (item8 != null)
- {
- substituido = item8.get_Substituido();
- num = (long)0;
- valueOrDefault = substituido.GetValueOrDefault() > num & substituido.HasValue;
- }
- else
- {
- valueOrDefault = false;
- }
- if (valueOrDefault && filterItens != 1)
- {
- this.FilterItens = 3;
- this.Itens = await this._itemServico.BuscarItens(documento.get_Controle().get_Id(), 1);
- ObservableCollection<Item> itens2 = this.Itens;
- if (itens2 != null)
- {
- item2 = itens2.FirstOrDefault<Item>((Item i) => {
- long? nullable;
- long id = i.get_Id();
- Item selectedItem = this.SelectedItem;
- if (selectedItem != null)
- {
- nullable = new long?(selectedItem.get_Id());
- }
- else
- {
- nullable = null;
- }
- long? nullable1 = nullable;
- return id == nullable1.GetValueOrDefault() & nullable1.HasValue;
- });
- }
- else
- {
- item2 = null;
- }
- item6 = item2;
- ConsultaViewModel consultaViewModel2 = this;
- if (item6 != null)
- {
- item3 = item6;
- }
- else
- {
- ObservableCollection<Item> observableCollection2 = this.Itens;
- if (observableCollection2 != null)
- {
- item3 = observableCollection2.FirstOrDefault<Item>();
- }
- else
- {
- item3 = null;
- }
- }
- consultaViewModel2.SelectedItem = item3;
- }
- }
- this.IsLoadingItens = true;
- }
- }
- }
-
- public async Task SelecionaParcelas(Documento documento = null)
- {
- ObservableCollection<Parcela> observableCollection;
- Parcela item;
- if (documento == null)
- {
- documento = this.SelectedControle;
- }
- ObservableCollection<Parcela> observableCollection1 = await this._parcelaServico.BuscarParcelasPorDocumento(documento);
- ConsultaViewModel consultaViewModel = this;
- if (documento.get_TipoRecebimento().GetValueOrDefault() == 2)
- {
- ObservableCollection<Parcela> observableCollection2 = observableCollection1;
- observableCollection = new ObservableCollection<Parcela>(
- from x in observableCollection2
- orderby x.get_NumeroParcela() descending
- select x);
- }
- else
- {
- observableCollection = observableCollection1;
- }
- consultaViewModel.Parcelas = observableCollection;
- ConsultaViewModel consultaViewModel1 = this;
- if (this.Parcelas == null || this.Parcelas.Count <= 0)
- {
- item = null;
- }
- else
- {
- item = this.Parcelas[0];
- }
- consultaViewModel1.SelectedParcela = item;
- this.CalculaComissao(documento, this.Parcelas);
- this.IsLoadingParcelas = true;
- }
-
- public async void SelecionarCliente(Cliente cliente)
- {
- await this.SelecionaCliente(cliente, true);
- this.ScrollDocumento();
- }
-
- public async Task SelecionarCliente(long id, bool selecionar)
- {
- Cliente cliente = await (new ClienteServico()).BuscarCliente(id);
- await this.SelecionaCliente(cliente, selecionar);
- }
-
- public async Task<bool> VerificaItens(Documento documento)
- {
- bool flag;
- if (!this.ItensRevelados)
- {
- if (await this._itemServico.ChecarQuantidade(documento.get_Id()) > 2)
- {
- this.Itens = new ObservableCollection<Item>();
- ObservableCollection<Item> itens = this.Itens;
- Item item = new Item();
- item.set_Id((long)0);
- item.set_Descricao("Item - Apólice Coletiva");
- itens.Add(item);
- this.MostrarItensVisibility = Visibility.Visible;
- this.MostrarSinistroVisibility = Visibility.Collapsed;
- flag = true;
- return flag;
- }
- }
- flag = false;
- return flag;
- }
-
- private async Task WorkOnSelectedControle(Documento value)
- {
- string str;
- Visibility visibility;
- long id;
- if (value != null && value.get_Id() != 0 && !this.IsLoading)
- {
- ConsultaViewModel.DocumentoSelecionado = value;
- this.IsEnabledParcelaItem = false;
- this.IsLoading = true;
- this.VisibilityParcelasVendedores = Visibility.Collapsed;
- ConsultaViewModel consultaViewModel = this;
- if (string.IsNullOrEmpty(value.get_Apolice()))
- {
- DateTime networkTime = Funcoes.GetNetworkTime();
- TimeSpan date = networkTime.Date - value.get_Vigencia1();
- str = string.Format("{0} DIAS DE PENDÊNCIA", date.TotalDays);
- }
- else
- {
- str = "";
- }
- consultaViewModel.PendenciaApolice = str;
- ConsultaViewModel consultaViewModel1 = this;
- visibility = (value.get_TemEndosso() ? Visibility.Visible : Visibility.Collapsed);
- consultaViewModel1.IsVisibleRadioEndosso = visibility;
- await this.SelecionaParcelas(value);
- this.VisibilityParcelasVendedores = Visibility.Visible;
- this.FilterItens = 0;
- Item itemSelecionado = ConsultaViewModel.ItemSelecionado;
- if (itemSelecionado != null)
- {
- id = itemSelecionado.get_Id();
- }
- else
- {
- id = (long)0;
- }
- long num = id;
- await this.SelecionaItens(this.FilterItens, value, (long)0, false);
- if (num > (long)0 && this.Itens != null && this.Itens.Any<Item>((Item x) => x.get_Id() == num))
- {
- ConsultaViewModel.ItemSelecionado = this.Itens.First<Item>((Item x) => x.get_Id() == num);
- this.SelecionaItem(ConsultaViewModel.ItemSelecionado);
- Action scrollToItem = Gestor.Application.Actions.Actions.ScrollToItem;
- if (scrollToItem != null)
- {
- scrollToItem();
- }
- else
- {
- }
- }
- this.IsLoading = false;
- this.IsEnabledParcelaItem = true;
- }
- }
-
- private void WorkOnSelectedDocumento(Documento value)
- {
- if (value == null || value.get_Id() == 0 || this.Recarregando)
- {
- return;
- }
- ConsultaViewModel.DocumentoSelecionado = value;
- this.ParcelasLabel = (ConsultaViewModel.DocumentoSelecionado.get_TipoRecebimento().GetValueOrDefault() == 2 ? "FATURAS" : "PARCELAS");
- TipoRecebimento? tipoRecebimento = ConsultaViewModel.DocumentoSelecionado.get_TipoRecebimento();
- this.IsFatura = tipoRecebimento.GetValueOrDefault() == 2;
- Action<Documento> updateDocumento = Gestor.Application.Actions.Actions.UpdateDocumento;
- if (updateDocumento == null)
- {
- return;
- }
- updateDocumento(value);
- }
-
- private async Task WorkOnSelectedEndosso(Documento value)
- {
- string str;
- long id;
- Visibility visibility;
- string apolice;
- if (value != null && value.get_Id() != 0 && !this.IsLoading)
- {
- ConsultaViewModel.DocumentoSelecionado = value;
- base.IsEnabled = false;
- this.IsLoading = true;
- this.VisibilityParcelasVendedores = Visibility.Collapsed;
- ConsultaViewModel consultaViewModel = this;
- if (string.IsNullOrEmpty(value.get_Endosso()))
- {
- DateTime networkTime = Funcoes.GetNetworkTime();
- TimeSpan date = networkTime.Date - value.get_Vigencia1();
- str = string.Format("{0} DIAS DE PENDÊNCIA", date.TotalDays);
- }
- else
- {
- str = "";
- }
- consultaViewModel.PendenciaApolice = str;
- await this.SelecionaParcelas(value);
- Item itemSelecionado = ConsultaViewModel.ItemSelecionado;
- if (itemSelecionado != null)
- {
- id = itemSelecionado.get_Id();
- }
- else
- {
- id = (long)0;
- }
- long num = id;
- await this.SelecionaItens(this.FilterItens, null, (long)0, false);
- if (num > (long)0 && this.Itens != null && this.Itens.Any<Item>((Item x) => x.get_Id() == num))
- {
- ConsultaViewModel.ItemSelecionado = this.Itens.First<Item>((Item x) => x.get_Id() == num);
- this.SelecionaItem(ConsultaViewModel.ItemSelecionado);
- Action scrollToItem = Gestor.Application.Actions.Actions.ScrollToItem;
- if (scrollToItem != null)
- {
- scrollToItem();
- }
- else
- {
- }
- }
- this.VisibilityParcelasVendedores = Visibility.Visible;
- ConsultaViewModel consultaViewModel1 = this;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 19))
- {
- Documento documento = value;
- if (documento != null)
- {
- apolice = documento.get_Apolice();
- }
- else
- {
- apolice = null;
- }
- if (string.IsNullOrWhiteSpace(apolice) || !value.get_Emissao().HasValue)
- {
- goto Label1;
- }
- visibility = Visibility.Collapsed;
- goto Label0;
- }
- Label1:
- visibility = Visibility.Visible;
- Label0:
- consultaViewModel1.RecusaVisibility = visibility;
- base.IsEnabled = true;
- this.IsLoading = false;
- }
- }
-
- private static void WorkOnSelectedItem(Item value)
- {
- long? nullable;
- if (value != null)
- {
- Item itemSelecionado = ConsultaViewModel.ItemSelecionado;
- if (itemSelecionado != null)
- {
- nullable = new long?(itemSelecionado.get_Id());
- }
- else
- {
- nullable = null;
- }
- long? nullable1 = nullable;
- long id = value.get_Id();
- if (nullable1.GetValueOrDefault() == id & nullable1.HasValue)
- {
- return;
- }
- }
- ConsultaViewModel.ItemSelecionado = value;
- Action<Item> updateItem = Gestor.Application.Actions.Actions.UpdateItem;
- if (updateItem == null)
- {
- return;
- }
- updateItem(value);
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/CriticaApoliceViewModel.cs b/Gestor.Application/ViewModels/Seguros/CriticaApoliceViewModel.cs deleted file mode 100644 index 7ec09a7..0000000 --- a/Gestor.Application/ViewModels/Seguros/CriticaApoliceViewModel.cs +++ /dev/null @@ -1,1486 +0,0 @@ -using Gestor.Application.Helpers;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Common.Validation;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Configuracoes;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Gestor.Application.ViewModels.Seguros
-{
- public class CriticaApoliceViewModel : BaseApoliceViewModel
- {
- private readonly CriticaApoliceServico _criticaServico;
-
- private readonly ClienteServico _clienteServico;
-
- private readonly ItemServico _itemServico;
-
- private List<VendedorUsuario> Vinculos;
-
- private ObservableCollection<Usuario> _usuarios = new ObservableCollection<Usuario>();
-
- private ObservableCollection<Seguradora> _seguradorasFiltro = new ObservableCollection<Seguradora>();
-
- private string _fieldNascimento = "NASCIMENTO";
-
- private bool _isExpanded = true;
-
- private DateTime _inicio = Funcoes.GetNetworkTime().Date.AddDays(-7);
-
- private DateTime _fim = Funcoes.GetNetworkTime().Date;
-
- private Usuario _selectedUsuario;
-
- private Seguradora _selectedSeguradora;
-
- private bool _criticado;
-
- private ObservableCollection<CriticaApolice> _criticas = new ObservableCollection<CriticaApolice>();
-
- private ObservableCollection<CriticaApolice> _criticaFiltrada = new ObservableCollection<CriticaApolice>();
-
- private bool _isCriticaSelected;
-
- private CriticaApolice _selectedCritica;
-
- private bool _hasChange;
-
- private bool _isParcela;
-
- private DateTime? _emissaoCritica;
-
- private DateTime? _transmissaoCritica;
-
- private DateTime? _nascimentoCritica;
-
- private TipoSeguro? _situacao;
-
- private Cliente _selectedCliente;
-
- private string _documentoPrincipal;
-
- private Visibility _visibilityFisica = Visibility.Collapsed;
-
- private ObservableCollection<ClienteTelefone> _telefones = new ObservableCollection<ClienteTelefone>();
-
- private ObservableCollection<ClienteEmail> _emails = new ObservableCollection<ClienteEmail>();
-
- private ObservableCollection<Item> _itens = new ObservableCollection<Item>();
-
- private bool _enableGrid = true;
-
- private string _pesquisa = "";
-
- private ObservableCollection<string> _pesquisaCritica = new ObservableCollection<string>();
-
- private string _profissaoText;
-
- private string _atividadeText;
-
- private Visibility _visibilityJuridica = Visibility.Collapsed;
-
- private string _fieldDocumento = "CPF";
-
- private Visibility _valorComissao;
-
- public string AtividadeText
- {
- get
- {
- return this._atividadeText;
- }
- set
- {
- this._atividadeText = value;
- base.OnPropertyChanged("AtividadeText");
- }
- }
-
- public bool BuscaInicial { get; set; } = true;
-
- public bool Criticado
- {
- get
- {
- return this._criticado;
- }
- set
- {
- this._criticado = value;
- base.OnPropertyChanged("Criticado");
- }
- }
-
- public ObservableCollection<CriticaApolice> CriticaFiltrada
- {
- get
- {
- return this._criticaFiltrada;
- }
- set
- {
- this._criticaFiltrada = value;
- base.OnPropertyChanged("CriticaFiltrada");
- }
- }
-
- public ObservableCollection<CriticaApolice> Criticas
- {
- get
- {
- return this._criticas;
- }
- set
- {
- this._criticas = value;
- base.OnPropertyChanged("Criticas");
- }
- }
-
- public string DocumentoPrincipal
- {
- get
- {
- return this._documentoPrincipal;
- }
- set
- {
- if (value == null || ValidationHelper.OnlyNumber(value).Length > 11)
- {
- this.VisibilityFisica = Visibility.Collapsed;
- this.FieldNascimento = "FUNDAÇÃO";
- }
- else
- {
- this.VisibilityFisica = Visibility.Visible;
- this.FieldNascimento = "NASCIMENTO";
- }
- this._documentoPrincipal = value;
- if (this.SelectedCliente != null)
- {
- TipoDocumento? documentoPrincipal = this.SelectedCliente.get_DocumentoPrincipal();
- if (documentoPrincipal.HasValue)
- {
- TipoDocumento valueOrDefault = documentoPrincipal.GetValueOrDefault();
- if (valueOrDefault == 1)
- {
- this.SelectedCliente.set_Rne(value);
- base.OnPropertyChanged("DocumentoPrincipal");
- return;
- }
- else
- {
- if (valueOrDefault != 2)
- {
- goto Label1;
- }
- this.SelectedCliente.set_Cei(value);
- base.OnPropertyChanged("DocumentoPrincipal");
- return;
- }
- }
- Label1:
- this.SelectedCliente.set_Documento(value);
- }
- base.OnPropertyChanged("DocumentoPrincipal");
- }
- }
-
- public ObservableCollection<ClienteEmail> Emails
- {
- get
- {
- return this._emails;
- }
- set
- {
- this._emails = value;
- base.OnPropertyChanged("Emails");
- }
- }
-
- public DateTime? EmissaoCritica
- {
- get
- {
- return this._emissaoCritica;
- }
- set
- {
- this._emissaoCritica = value;
- base.OnPropertyChanged("EmissaoCritica");
- }
- }
-
- public bool EnableGrid
- {
- get
- {
- return this._enableGrid;
- }
- set
- {
- this._enableGrid = value;
- base.OnPropertyChanged("EnableGrid");
- }
- }
-
- public string FieldDocumento
- {
- get
- {
- return this._fieldDocumento;
- }
- set
- {
- this._fieldDocumento = value;
- base.OnPropertyChanged("FieldDocumento");
- }
- }
-
- public string FieldNascimento
- {
- get
- {
- return this._fieldNascimento;
- }
- set
- {
- this._fieldNascimento = value;
- base.OnPropertyChanged("FieldNascimento");
- }
- }
-
- public DateTime Fim
- {
- get
- {
- return this._fim;
- }
- set
- {
- this._fim = value;
- base.OnPropertyChanged("Fim");
- }
- }
-
- public bool HasChange
- {
- get
- {
- return this._hasChange;
- }
- set
- {
- this._hasChange = value;
- base.OnPropertyChanged("HasChange");
- }
- }
-
- public int Index { get; set; } = -1;
-
- public DateTime Inicio
- {
- get
- {
- return this._inicio;
- }
- set
- {
- this._inicio = value;
- base.OnPropertyChanged("Inicio");
- }
- }
-
- public bool IsCriticaSelected
- {
- get
- {
- return this._isCriticaSelected;
- }
- set
- {
- this._isCriticaSelected = value;
- base.OnPropertyChanged("IsCriticaSelected");
- }
- }
-
- public bool IsExpanded
- {
- get
- {
- return this._isExpanded;
- }
- set
- {
- this._isExpanded = value;
- base.OnPropertyChanged("IsExpanded");
- }
- }
-
- public bool IsLoading
- {
- get;
- set;
- }
-
- public bool IsParcela
- {
- get
- {
- return this._isParcela;
- }
- set
- {
- this._isParcela = value;
- base.OnPropertyChanged("IsParcela");
- }
- }
-
- public ObservableCollection<Item> Itens
- {
- get
- {
- return this._itens;
- }
- set
- {
- this._itens = value;
- base.OnPropertyChanged("Itens");
- }
- }
-
- public DateTime? NascimentoCritica
- {
- get
- {
- return this._nascimentoCritica;
- }
- set
- {
- this._nascimentoCritica = value;
- base.OnPropertyChanged("NascimentoCritica");
- }
- }
-
- public string Pesquisa
- {
- get
- {
- return this._pesquisa;
- }
- set
- {
- this._pesquisa = value;
- base.OnPropertyChanged("Pesquisa");
- }
- }
-
- public ObservableCollection<string> PesquisaCritica
- {
- get
- {
- return this._pesquisaCritica;
- }
- set
- {
- this._pesquisaCritica = value;
- base.OnPropertyChanged("PesquisaCritica");
- }
- }
-
- public string ProfissaoText
- {
- get
- {
- return this._profissaoText;
- }
- set
- {
- this._profissaoText = value;
- base.OnPropertyChanged("ProfissaoText");
- }
- }
-
- public ObservableCollection<Seguradora> SeguradorasFiltro
- {
- get
- {
- return this._seguradorasFiltro;
- }
- set
- {
- this._seguradorasFiltro = value;
- this.SelectedSeguradora = this.SelectedSeguradora ?? value.FirstOrDefault<Seguradora>();
- base.OnPropertyChanged("SeguradorasFiltro");
- }
- }
-
- public bool SeguroCombinado
- {
- get;
- set;
- }
-
- public Cliente SelectedCliente
- {
- get
- {
- return this._selectedCliente;
- }
- set
- {
- this._selectedCliente = value;
- base.OnPropertyChanged("SelectedCliente");
- }
- }
-
- public CriticaApolice SelectedCritica
- {
- get
- {
- return this._selectedCritica;
- }
- set
- {
- this._selectedCritica = value;
- this.IsCriticaSelected = value != null;
- base.OnPropertyChanged("SelectedCritica");
- }
- }
-
- public Seguradora SelectedSeguradora
- {
- get
- {
- return this._selectedSeguradora;
- }
- set
- {
- this._selectedSeguradora = value;
- base.OnPropertyChanged("SelectedSeguradora");
- }
- }
-
- public Usuario SelectedUsuario
- {
- get
- {
- return this._selectedUsuario;
- }
- set
- {
- this._selectedUsuario = value;
- base.OnPropertyChanged("SelectedUsuario");
- }
- }
-
- public TipoSeguro? StatusDocumento
- {
- get
- {
- return this._situacao;
- }
- set
- {
- this._situacao = value;
- base.OnPropertyChanged("StatusDocumento");
- }
- }
-
- public ObservableCollection<ClienteTelefone> Telefones
- {
- get
- {
- return this._telefones;
- }
- set
- {
- this._telefones = value;
- base.OnPropertyChanged("Telefones");
- }
- }
-
- public DateTime? TransmissaoCritica
- {
- get
- {
- return this._transmissaoCritica;
- }
- set
- {
- this._transmissaoCritica = value;
- base.OnPropertyChanged("TransmissaoCritica");
- }
- }
-
- public ObservableCollection<Usuario> Usuarios
- {
- get
- {
- return this._usuarios;
- }
- set
- {
- this._usuarios = value;
- this.SelectedUsuario = this.SelectedUsuario ?? value.FirstOrDefault<Usuario>();
- base.OnPropertyChanged("Usuarios");
- }
- }
-
- public Visibility ValorComissao
- {
- get
- {
- return this._valorComissao;
- }
- set
- {
- this._valorComissao = value;
- base.OnPropertyChanged("ValorComissao");
- }
- }
-
- public Visibility VisibilityFisica
- {
- get
- {
- return this._visibilityFisica;
- }
- set
- {
- this._visibilityFisica = value;
- base.OnPropertyChanged("VisibilityFisica");
- }
- }
-
- public Visibility VisibilityJuridica
- {
- get
- {
- return this._visibilityJuridica;
- }
- set
- {
- this._visibilityJuridica = value;
- base.OnPropertyChanged("VisibilityJuridica");
- }
- }
-
- public CriticaApoliceViewModel()
- {
- base.Invoke = false;
- this._criticaServico = new CriticaApoliceServico();
- this._clienteServico = new ClienteServico();
- this._itemServico = new ItemServico();
- }
-
- public void AdcionarFiltro()
- {
- if (string.IsNullOrEmpty(this.Pesquisa))
- {
- return;
- }
- if (string.IsNullOrWhiteSpace(this.Pesquisa.Replace("+", "")))
- {
- return;
- }
- if (this.PesquisaCritica == null)
- {
- this.PesquisaCritica = new ObservableCollection<string>();
- }
- this.PesquisaCritica.Add(this.Pesquisa);
- this.Pesquisa = string.Empty;
- this.Pesquisar();
- }
-
- public void AlteraDocumentoPrincipal()
- {
- if (this.SelectedCliente == null)
- {
- return;
- }
- TipoDocumento? documentoPrincipal = this.SelectedCliente.get_DocumentoPrincipal();
- if (documentoPrincipal.HasValue)
- {
- TipoDocumento valueOrDefault = documentoPrincipal.GetValueOrDefault();
- if (valueOrDefault == 1)
- {
- this.DocumentoPrincipal = this.SelectedCliente.get_Rne();
- return;
- }
- if (valueOrDefault == 2)
- {
- this.DocumentoPrincipal = this.SelectedCliente.get_Cei();
- return;
- }
- }
- this.DocumentoPrincipal = this.SelectedCliente.get_Documento();
- this.SelectedCliente.set_DocumentoPrincipal(new TipoDocumento?(0));
- }
-
- public async Task CarregaCritica(long usuario, long seguradora, bool criticado = false)
- {
- bool count;
- Usuario usuario1;
- Seguradora seguradora1;
- object nome;
- long num;
- object obj;
- long num1;
- object obj1;
- object obj2;
- object nome1;
- long num2;
- object nome2;
- long num3;
- object obj3;
- if (!this.IsLoading || this.BuscaInicial)
- {
- this.BuscaInicial = false;
- this.EnableGrid = false;
- base.Loading(true);
- this.Criticado = criticado;
- await this.CarregarUsuarios(usuario, this.Criticado);
- List<CriticaApolice> criticaApolices = await this._criticaServico.BuscarCritica(usuario, this.Inicio, this.Fim, (long)0, this.Criticado, this.Vinculos);
- CriticaApoliceViewModel observableCollection = this;
- IEnumerable<CriticaApolice> criticaApolices1 = criticaApolices.Where<CriticaApolice>((CriticaApolice x) => {
- if (usuario != 0 && x.get_UsuarioImportacao().get_Id() != usuario)
- {
- return false;
- }
- if (seguradora == 0)
- {
- return true;
- }
- return x.get_Documento().get_Controle().get_Seguradora().get_Id() == seguradora;
- });
- IOrderedEnumerable<CriticaApolice> dataImportacao =
- from x in criticaApolices1
- orderby x.get_DataImportacao()
- select x;
- observableCollection.Criticas = new ObservableCollection<CriticaApolice>(dataImportacao.ThenByDescending<CriticaApolice, string>((CriticaApolice x) => x.get_Documento().get_Controle().get_Cliente().get_Nome()));
- this.CriticaFiltrada = this.Criticas;
- if (this.CriticaFiltrada == null || this.CriticaFiltrada.Count <= 0)
- {
- this.IsCriticaSelected = false;
- }
- else
- {
- await this.SelecionaCritica(this.CriticaFiltrada.First<CriticaApolice>());
- }
- CriticaApoliceViewModel criticaApoliceViewModel = this;
- ObservableCollection<CriticaApolice> criticaFiltrada = this.CriticaFiltrada;
- if (criticaFiltrada != null)
- {
- count = criticaFiltrada.Count > 0;
- }
- else
- {
- count = false;
- }
- criticaApoliceViewModel.IsExpanded = count;
- base.Loading(false);
- ObservableCollection<Usuario> usuarios = this.Usuarios;
- if (usuarios != null)
- {
- usuario1 = usuarios.FirstOrDefault<Usuario>((Usuario x) => x.get_Id() == usuario);
- }
- else
- {
- usuario1 = null;
- }
- Usuario usuario2 = usuario1;
- List<Seguradora> seguradoras = base.Seguradoras;
- if (seguradoras != null)
- {
- seguradora1 = seguradoras.FirstOrDefault<Seguradora>((Seguradora x) => x.get_Id() == seguradora);
- }
- else
- {
- seguradora1 = null;
- }
- Seguradora seguradora2 = seguradora1;
- CriticaApoliceViewModel criticaApoliceViewModel1 = this;
- string str = string.Format("CONSULTOU CRÍTICAS NO PERÍODO ENTRE {0:d} E {1:d}", this.Inicio, this.Fim);
- long num4 = (long)0;
- TipoTela? nullable = new TipoTela?(20);
- if (this.PesquisaCritica == null || this.PesquisaCritica.Count <= 0)
- {
- object[] objArray = new object[5];
- if (usuario2 != null)
- {
- nome = usuario2.get_Nome();
- }
- else
- {
- nome = null;
- }
- if (nome == null)
- {
- nome = "TODOS USUÁRIOS";
- }
- objArray[0] = nome;
- num = (usuario2 != null ? usuario2.get_Id() : (long)0);
- objArray[1] = num;
- if (seguradora2 != null)
- {
- obj = seguradora2.get_Nome();
- }
- else
- {
- obj = null;
- }
- if (obj == null)
- {
- obj = "TODAS AS SEGURADORAS";
- }
- objArray[2] = obj;
- num1 = (seguradora2 != null ? seguradora2.get_Id() : (long)0);
- objArray[3] = num1;
- obj1 = (this.Criticado ? "SIM" : "NÃO");
- objArray[4] = obj1;
- obj2 = string.Format("USUÁRIO IMPORTAÇÃO: {0} ({1})\nSEGURADORA: {2} ({3})\nCRITICADOS: {4}", objArray);
- }
- else
- {
- object[] objArray1 = new object[6];
- if (usuario2 != null)
- {
- nome1 = usuario2.get_Nome();
- }
- else
- {
- nome1 = null;
- }
- if (nome1 == null)
- {
- nome1 = "TODOS USUÁRIOS";
- }
- objArray1[0] = nome1;
- num2 = (usuario2 != null ? usuario2.get_Id() : (long)0);
- objArray1[1] = num2;
- if (seguradora2 != null)
- {
- nome2 = seguradora2.get_Nome();
- }
- else
- {
- nome2 = null;
- }
- if (nome2 == null)
- {
- nome2 = "TODAS AS SEGURADORAS";
- }
- objArray1[2] = nome2;
- num3 = (seguradora2 != null ? seguradora2.get_Id() : (long)0);
- objArray1[3] = num3;
- obj3 = (this.Criticado ? "SIM" : "NÃO");
- objArray1[4] = obj3;
- objArray1[5] = ValidationHelper.Join(this.PesquisaCritica, ", ");
- obj2 = string.Format("USUÁRIO IMPORTAÇÃO: {0} ({1})\nSEGURADORA: {2} ({3})\nCRITICADOS: {4}\nPESQUISA PERSONALIZADA: \"{5}\"", objArray1);
- }
- criticaApoliceViewModel1.RegistrarAcao(str, num4, nullable, obj2);
- this.EnableGrid = true;
- }
- }
-
- public async Task CarregarSeguradoras()
- {
- this.IsLoading = true;
- List<Seguradora> list = await this._criticaServico.BuscarSeguradorasAsync();
- List<Seguradora> seguradoras = list;
- list = (
- from x in seguradoras
- orderby x.get_Nome()
- select x).ToList<Seguradora>();
- Seguradora seguradora = new Seguradora();
- seguradora.set_Id((long)0);
- seguradora.set_Nome("TODAS AS SEGURADORAS");
- seguradora.set_Ativo(true);
- list.Insert(0, seguradora);
- CriticaApoliceViewModel observableCollection = this;
- List<Seguradora> seguradoras1 = list;
- observableCollection.SeguradorasFiltro = new ObservableCollection<Seguradora>(
- from x in seguradoras1
- where x.get_Ativo()
- select x);
- this.SelectedSeguradora = this.SeguradorasFiltro.FirstOrDefault<Seguradora>();
- this.IsLoading = false;
- }
-
- public async Task CarregarUsuarios(long selected = 0L, bool criticado = false)
- {
- bool count;
- this.IsLoading = true;
- this.Criticado = criticado;
- List<Usuario> usuarios = new List<Usuario>();
- List<VendedorUsuario> vinculos = this.Vinculos;
- if (vinculos != null)
- {
- count = vinculos.Count > 0;
- }
- else
- {
- count = false;
- }
- if (!count)
- {
- usuarios = await this._criticaServico.BuscarUsuarioCritica(this.Inicio, this.Fim, this.Criticado);
- Usuario usuario = new Usuario();
- usuario.set_Id((long)0);
- usuario.set_Nome("TODOS OS USUÁRIOS");
- usuarios.Insert(0, usuario);
- }
- else
- {
- Usuario usuario1 = new Usuario();
- usuario1.set_Id(Recursos.Usuario.get_Id());
- usuario1.set_Nome(Recursos.Usuario.get_Nome());
- usuarios.Insert(0, usuario1);
- }
- this.Usuarios = new ObservableCollection<Usuario>(usuarios);
- CriticaApoliceViewModel criticaApoliceViewModel = this;
- Usuario usuario2 = this.Usuarios.FirstOrDefault<Usuario>((Usuario x) => x.get_Id() == selected);
- if (usuario2 == null)
- {
- usuario2 = this.Usuarios.FirstOrDefault<Usuario>();
- }
- criticaApoliceViewModel.SelectedUsuario = usuario2;
- this.IsLoading = false;
- }
-
- public async Task ConcluirCritica()
- {
- List<CriticaApolice> criticaApolices;
- string str;
- string descricao;
- DateTime networkTime = Funcoes.GetNetworkTime();
- this.SelectedCritica.set_Critica(new bool?(true));
- this.SelectedCritica.set_DataCritica(new DateTime?(networkTime));
- this.SelectedCritica.set_UsuarioCritica(new long?(Recursos.Usuario.get_Id()));
- foreach (CriticaApolice criticaApolouse in await this._criticaServico.BuscarCritica(this.SelectedCritica.get_Documento().get_Id()))
- {
- criticaApolouse.set_Critica(new bool?(true));
- criticaApolouse.set_DataCritica(new DateTime?(networkTime));
- criticaApolouse.set_UsuarioCritica(new long?(Recursos.Usuario.get_Id()));
- await this._criticaServico.Save(criticaApolouse);
- }
- if (this.SeguroCombinado)
- {
- List<CriticaApolice> list = ((IEnumerable<CriticaApolice>)await this._criticaServico.BuscarSeguroCombinado(this.SelectedCritica.get_Documento().get_Controle().get_Cliente().get_Id(), this.SelectedCritica.get_Documento().get_Vigencia1())).Where<CriticaApolice>((CriticaApolice duo) => {
- if (duo.get_Documento().get_Controle().get_Seguradora().get_Id() == this.SelectedCritica.get_Documento().get_Controle().get_Seguradora().get_Id() && duo.get_Documento().get_Controle().get_Cliente().get_Id() == this.SelectedCritica.get_Documento().get_Controle().get_Cliente().get_Id() && duo.get_Documento().get_Vigencia1() == this.SelectedCritica.get_Documento().get_Vigencia1())
- {
- DateTime? vigencia2 = duo.get_Documento().get_Vigencia2();
- DateTime? nullable = this.SelectedCritica.get_Documento().get_Vigencia2();
- if ((vigencia2.HasValue == nullable.HasValue ? (vigencia2.HasValue ? vigencia2.GetValueOrDefault() == nullable.GetValueOrDefault() : true) : false) && duo.get_Documento().get_Id() != this.SelectedCritica.get_Documento().get_Id() && duo.get_Documento().get_Apolice() == this.SelectedCritica.get_Documento().get_Apolice() && duo.get_Documento().get_Proposta() == null)
- {
- return true;
- }
- }
- return Regex.Replace(duo.get_Documento().get_Proposta(), "[^.'-,/]", "") == Regex.Replace(this.SelectedCritica.get_Documento().get_Proposta(), "[^.'-,/]", "");
- }).ToList<CriticaApolice>();
- if (list == null || list.Count<CriticaApolice>() <= 0)
- {
- criticaApolices = null;
- }
- else
- {
- criticaApolices = await this._criticaServico.BuscarCritica(list.FirstOrDefault<CriticaApolice>().get_Documento().get_Id());
- }
- list = criticaApolices;
- if (list != null && list.Any<CriticaApolice>())
- {
- foreach (CriticaApolice criticaApolouse1 in list)
- {
- criticaApolouse1.set_Critica(new bool?(true));
- criticaApolouse1.set_DataCritica(new DateTime?(networkTime));
- criticaApolouse1.get_Documento().set_PremioLiquido(new decimal(1, 0, 0, false, 2));
- criticaApolouse1.get_Documento().set_PremioTotal(new decimal(1, 0, 0, false, 2));
- criticaApolouse1.get_Documento().set_Comissao(new decimal(1, 0, 0, false, 2));
- criticaApolouse1.set_UsuarioCritica(new long?(Recursos.Usuario.get_Id()));
- await this._criticaServico.Save(criticaApolouse1);
- await this.Servico.Save(criticaApolouse1.get_Documento(), false, false);
- }
- }
- }
- if (this.SelectedCritica.get_Tipo() == "0")
- {
- str = string.Concat("A PROPOSTA \"", this.CancelDocumento.get_Proposta(), "\"");
- }
- else
- {
- str = (this.SelectedCritica.get_Tipo() == "1" ? string.Concat("A APÓLICE \"", this.CancelDocumento.get_Apolice(), "\"") : string.Concat("O ENDOSSO \"", this.CancelDocumento.get_Endosso(), "\""));
- }
- string str1 = str;
- base.RegistrarAcao(string.Concat("CONCLUIU A CRÍTICA D", str1), this.SelectedCritica.get_Id(), new TipoTela?(20), null);
- if (this.Itens == null)
- {
- descricao = "";
- }
- else if (this.Itens.Count > 1)
- {
- descricao = "APÓLICE COLETIVA";
- }
- else
- {
- Item item = this.Itens.FirstOrDefault<Item>();
- if (item != null)
- {
- descricao = item.get_Descricao();
- }
- else
- {
- descricao = null;
- }
- }
- string str2 = descricao;
- try
- {
- if (string.IsNullOrEmpty(base.SelectedDocumento.get_Controle().get_AssistenciaId()))
- {
- await base.CreateLinkAssistencia(base.SelectedDocumento, str2, false);
- }
- }
- catch (Exception exception)
- {
- }
- base.SelectedDocumento = null;
- this.SelectedCliente = null;
- this.Telefones = null;
- this.Emails = null;
- this.Itens = null;
- await this.CarregaCritica(this.SelectedUsuario.get_Id(), this.SelectedSeguradora.get_Id(), this.Criticado);
- }
-
- public async void ExcluirEmail(ClienteEmail email)
- {
- if (this.Emails.Count >= 2)
- {
- this.HasChange = true;
- int? nullable = email.get_Ordem();
- int count = this.Emails.Count;
- int count1 = this.Emails.Count;
- this.Emails.Remove(email);
- if (!(nullable.GetValueOrDefault() == count & nullable.HasValue))
- {
- if (this.Emails.FirstOrDefault<ClienteEmail>((ClienteEmail x) => {
- int? ordem = x.get_Ordem();
- int num = count1;
- return ordem.GetValueOrDefault() == num & ordem.HasValue;
- }) != null)
- {
- this.Emails.First<ClienteEmail>((ClienteEmail x) => {
- int? ordem = x.get_Ordem();
- int num = count1;
- return ordem.GetValueOrDefault() == num & ordem.HasValue;
- }).set_Ordem(email.get_Ordem());
- CriticaApoliceViewModel observableCollection = this;
- ObservableCollection<ClienteEmail> emails = this.Emails;
- observableCollection.Emails = new ObservableCollection<ClienteEmail>(
- from x in emails
- orderby x.get_Ordem()
- select x);
- }
- }
- }
- else
- {
- await base.ShowMessage("É NECESSÁRIO TER AO MENOS UM CONTATO DE E-MAIL CADASTRADO.", "OK", "", false);
- }
- }
-
- public async void ExcluirTelefone(ClienteTelefone telefone)
- {
- if (this.Telefones.Count >= 2)
- {
- this.HasChange = true;
- int? nullable = telefone.get_Ordem();
- int count = this.Telefones.Count;
- int count1 = this.Telefones.Count;
- this.Telefones.Remove(telefone);
- if (!(nullable.GetValueOrDefault() == count & nullable.HasValue))
- {
- if (this.Telefones.FirstOrDefault<ClienteTelefone>((ClienteTelefone x) => {
- int? ordem = x.get_Ordem();
- int num = count1;
- return ordem.GetValueOrDefault() == num & ordem.HasValue;
- }) != null)
- {
- this.Telefones.First<ClienteTelefone>((ClienteTelefone x) => {
- int? ordem = x.get_Ordem();
- int num = count1;
- return ordem.GetValueOrDefault() == num & ordem.HasValue;
- }).set_Ordem(telefone.get_Ordem());
- CriticaApoliceViewModel observableCollection = this;
- ObservableCollection<ClienteTelefone> telefones = this.Telefones;
- observableCollection.Telefones = new ObservableCollection<ClienteTelefone>(
- from x in telefones
- orderby x.get_Ordem()
- select x);
- }
- }
- }
- else
- {
- await base.ShowMessage("É NECESSÁRIO TER AO MENOS UM TELEFONE CADASTRADO.", "OK", "", false);
- }
- }
-
- public async Task InitialLoad()
- {
- long id;
- this.IsLoading = true;
- base.Loading(true);
- await base.PermissaoTela(2);
- await this.SelecionaUsuario();
- await this.CarregarUsuarios((long)0, false);
- await this.CarregarSeguradoras();
- CriticaApoliceViewModel criticaApoliceViewModel = this;
- Usuario selectedUsuario = this.SelectedUsuario;
- if (selectedUsuario != null)
- {
- id = selectedUsuario.get_Id();
- }
- else
- {
- id = (long)0;
- }
- await criticaApoliceViewModel.CarregaCritica(id, (long)0, false);
- base.Loading(false);
- this.IsLoading = false;
- }
-
- public void JuridicaouFisica(string documento)
- {
- if (this.SelectedCliente == null)
- {
- return;
- }
- this.ProfissaoText = "";
- this.AtividadeText = "";
- if (documento != null && ValidationHelper.OnlyNumber(documento).Length <= 11)
- {
- this.VisibilityJuridica = Visibility.Collapsed;
- this.VisibilityFisica = Visibility.Visible;
- this.FieldNascimento = "NASCIMENTO";
- this.FieldDocumento = "CPF";
- this.SelectedCliente.set_Atividade(null);
- return;
- }
- this.VisibilityJuridica = Visibility.Visible;
- this.VisibilityFisica = Visibility.Collapsed;
- this.FieldNascimento = "FUNDAÇÃO";
- this.FieldDocumento = "CNPJ";
- this.SelectedCliente.set_Profissao(null);
- }
-
- public async void Pesquisar()
- {
- this.EnableGrid = false;
- if (this.PesquisaCritica == null || this.PesquisaCritica.Count == 0)
- {
- this.CriticaFiltrada = new ObservableCollection<CriticaApolice>(this.Criticas);
- }
- else
- {
- CriticaApoliceViewModel observableCollection = this;
- IEnumerable<CriticaApolice> criticaApolices = this.Criticas.Where<CriticaApolice>((CriticaApolice x) => {
- Func<string, bool> func2 = null;
- return this.PesquisaCritica.All<string>((string s) => {
- List<string> list = s.Split(new char[] { '+' }).ToList<string>();
- Func<string, bool> u003cu003e9_1484 = CriticaApoliceViewModel.u003cu003ec.u003cu003e9__148_4;
- if (u003cu003e9_1484 == null)
- {
- u003cu003e9_1484 = (string f) => !string.IsNullOrWhiteSpace(f);
- CriticaApoliceViewModel.u003cu003ec.u003cu003e9__148_4 = u003cu003e9_1484;
- }
- IEnumerable<string> strs = list.Where<string>(u003cu003e9_1484);
- Func<string, bool> u003cu003e9_5 = func2;
- if (u003cu003e9_5 == null)
- {
- Func<string, bool> func = (string f) => {
- if (ValidationHelper.RemoveDiacritics(x.get_Documento().get_Controle().get_Cliente().get_Nome()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(f)) || x.get_Documento().get_Controle().get_Cliente().get_Documento() != null && x.get_Documento().get_Controle().get_Cliente().get_Documento().Contains(f) || x.get_Documento().get_Controle().get_Cliente().get_Cei() != null && x.get_Documento().get_Controle().get_Cliente().get_Cei().Contains(f) || x.get_Documento().get_Controle().get_Cliente().get_Rne() != null && x.get_Documento().get_Controle().get_Cliente().get_Rne().Contains(f) || x.get_UsuarioImportacao() != null && x.get_UsuarioImportacao().get_Nome().Contains(f) || x.get_DataImportacao().HasValue && x.get_DataImportacao().ToString().Contains(f) || x.get_Documento().get_Apolice() != null && x.get_Documento().get_Apolice().ToUpper().Contains(f.ToUpper()))
- {
- return true;
- }
- if (x.get_Documento().get_Proposta() == null)
- {
- return false;
- }
- return x.get_Documento().get_Proposta().ToUpper().Contains(f.ToUpper());
- };
- Func<string, bool> func1 = func;
- func2 = func;
- u003cu003e9_5 = func1;
- }
- return strs.Any<string>(u003cu003e9_5);
- });
- });
- IOrderedEnumerable<CriticaApolice> dataImportacao =
- from x in criticaApolices
- orderby x.get_DataImportacao()
- select x;
- observableCollection.CriticaFiltrada = new ObservableCollection<CriticaApolice>(dataImportacao.ThenByDescending<CriticaApolice, string>((CriticaApolice x) => x.get_Documento().get_Controle().get_Cliente().get_Nome()));
- }
- await this.SelecionaCritica(this.CriticaFiltrada.FirstOrDefault<CriticaApolice>());
- this.EnableGrid = true;
- }
-
- public async Task<List<KeyValuePair<string, string>>> SalvarCliente()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- List<KeyValuePair<string, string>> keyValuePairs1;
- Cliente cliente;
- CriticaApoliceViewModel.u003cu003ec__DisplayClass132_0 variable;
- List<KeyValuePair<string, string>> keyValuePairs2;
- List<KeyValuePair<string, string>> keyValuePairs3;
- if (!this.HasChange && !this.SelectedCliente.HasChange())
- {
- ObservableCollection<ClienteTelefone> telefones = this.Telefones;
- if (telefones.All<ClienteTelefone>((ClienteTelefone x) => !x.HasChange()))
- {
- ObservableCollection<ClienteEmail> emails = this.Emails;
- if (emails.All<ClienteEmail>((ClienteEmail x) => !x.HasChange()))
- {
- keyValuePairs = null;
- variable = null;
- return keyValuePairs;
- }
- }
- }
- ObservableCollection<ClienteTelefone> observableCollection = this.Telefones;
- List<ClienteTelefone> list = (
- from x in observableCollection
- where !string.IsNullOrEmpty(x.get_Numero())
- select x).ToList<ClienteTelefone>();
- ObservableCollection<ClienteEmail> emails1 = this.Emails;
- List<ClienteEmail> clienteEmails = (
- from x in emails1
- where !string.IsNullOrEmpty(x.get_Email())
- select x).ToList<ClienteEmail>();
- this.SelectedCliente.set_Telefones(new ObservableCollection<ClienteTelefone>(list));
- this.SelectedCliente.set_Emails(new ObservableCollection<ClienteEmail>(clienteEmails));
- TipoDocumento? documentoPrincipal = this.SelectedCliente.get_DocumentoPrincipal();
- if (documentoPrincipal.HasValue)
- {
- TipoDocumento valueOrDefault = documentoPrincipal.GetValueOrDefault();
- if (valueOrDefault == 1)
- {
- this.SelectedCliente.set_Rne(this.DocumentoPrincipal);
- keyValuePairs3 = this.SelectedCliente.Validate();
- list.ForEach((ClienteTelefone x) => keyValuePairs3.AddRange(x.Validate()));
- clienteEmails.ForEach((ClienteEmail x) => keyValuePairs3.AddRange(x.Validate()));
- keyValuePairs2 = keyValuePairs3;
- keyValuePairs1 = await this.Validate();
- keyValuePairs2.AddRange(keyValuePairs1);
- keyValuePairs2 = null;
- if (keyValuePairs3.Count <= 0)
- {
- cliente = await this._clienteServico.Save(this.SelectedCliente, false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = keyValuePairs3;
- }
- variable = null;
- return keyValuePairs;
- }
- else
- {
- if (valueOrDefault != 2)
- {
- goto Label2;
- }
- this.SelectedCliente.set_Cei(this.DocumentoPrincipal);
- keyValuePairs3 = this.SelectedCliente.Validate();
- list.ForEach((ClienteTelefone x) => keyValuePairs3.AddRange(x.Validate()));
- clienteEmails.ForEach((ClienteEmail x) => keyValuePairs3.AddRange(x.Validate()));
- keyValuePairs2 = keyValuePairs3;
- keyValuePairs1 = await this.Validate();
- keyValuePairs2.AddRange(keyValuePairs1);
- keyValuePairs2 = null;
- if (keyValuePairs3.Count <= 0)
- {
- cliente = await this._clienteServico.Save(this.SelectedCliente, false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = keyValuePairs3;
- }
- variable = null;
- return keyValuePairs;
- }
- }
- Label2:
- this.SelectedCliente.set_Documento(this.DocumentoPrincipal);
- keyValuePairs3 = this.SelectedCliente.Validate();
- list.ForEach((ClienteTelefone x) => keyValuePairs3.AddRange(x.Validate()));
- clienteEmails.ForEach((ClienteEmail x) => keyValuePairs3.AddRange(x.Validate()));
- keyValuePairs2 = keyValuePairs3;
- keyValuePairs1 = await this.Validate();
- keyValuePairs2.AddRange(keyValuePairs1);
- keyValuePairs2 = null;
- if (keyValuePairs3.Count <= 0)
- {
- cliente = await this._clienteServico.Save(this.SelectedCliente, false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = keyValuePairs3;
- }
- variable = null;
- return keyValuePairs;
- }
-
- public async Task SelecionaCliente(Cliente cliente)
- {
- DateTime? nullable;
- TipoDocumento? documentoPrincipal = cliente.get_DocumentoPrincipal();
- if (documentoPrincipal.HasValue)
- {
- TipoDocumento valueOrDefault = documentoPrincipal.GetValueOrDefault();
- if (valueOrDefault == 1)
- {
- this.DocumentoPrincipal = cliente.get_Rne();
- goto Label0;
- }
- else
- {
- if (valueOrDefault != 2)
- {
- goto Label1;
- }
- this.DocumentoPrincipal = cliente.get_Cei();
- goto Label0;
- }
- }
- Label1:
- this.DocumentoPrincipal = cliente.get_Documento();
- cliente.set_DocumentoPrincipal(new TipoDocumento?(0));
- Label0:
- CriticaApoliceViewModel criticaApoliceViewModel = this;
- nullable = (cliente == null || !cliente.get_Nascimento().HasValue ? new DateTime?(Funcoes.GetNetworkTime().Date) : cliente.get_Nascimento());
- criticaApoliceViewModel.NascimentoCritica = nullable;
- this.SelectedCliente = cliente;
- this.SelectedCliente.Initialize();
- this.Telefones = await this._clienteServico.BuscarTelefonesAsync(this.SelectedCliente.get_Id());
- if (this.Telefones.Count == 0)
- {
- ObservableCollection<ClienteTelefone> telefones = this.Telefones;
- ClienteTelefone clienteTelefone = new ClienteTelefone();
- clienteTelefone.set_Cliente(this.SelectedCliente);
- telefones.Add(clienteTelefone);
- }
- List<ClienteTelefone> list = this.Telefones.ToList<ClienteTelefone>();
- list.ForEach((ClienteTelefone x) => x.Initialize());
- this.Emails = await this._clienteServico.BuscarEmailsAsync(this.SelectedCliente.get_Id());
- if (this.Emails.Count == 0)
- {
- ObservableCollection<ClienteEmail> emails = this.Emails;
- ClienteEmail clienteEmail = new ClienteEmail();
- clienteEmail.set_Cliente(this.SelectedCliente);
- emails.Add(clienteEmail);
- }
- List<ClienteEmail> clienteEmails = this.Emails.ToList<ClienteEmail>();
- clienteEmails.ForEach((ClienteEmail x) => x.Initialize());
- }
-
- public async Task SelecionaCritica(CriticaApolice critica)
- {
- DateTime networkTime;
- DateTime? nullable;
- DateTime? remessa;
- TipoSeguro? nullable1;
- if (critica != null && !this.IsLoading)
- {
- this.IsLoading = true;
- base.Loading(true);
- CriticaApolice criticaApolouse = critica;
- Documento documento = await this.Servico.BuscarApoliceAsync(critica.get_Documento().get_Id(), false, false);
- criticaApolouse.set_Documento(documento);
- criticaApolouse = null;
- base.SelectedDocumento = null;
- base.Repasses = null;
- base.Parcelas = null;
- base.Pagamentos = null;
- base.SelectedParcela = null;
- base.SelectedPagamento = null;
- this.SelectedCritica = critica;
- await base.SelecionaDocumento(critica.get_Documento());
- CriticaApoliceViewModel criticaApoliceViewModel = this;
- if (critica.get_Documento() == null || !critica.get_Documento().get_Emissao().HasValue)
- {
- networkTime = Funcoes.GetNetworkTime();
- nullable = new DateTime?(networkTime.Date);
- }
- else
- {
- nullable = critica.get_Documento().get_Emissao();
- }
- criticaApoliceViewModel.EmissaoCritica = nullable;
- CriticaApoliceViewModel criticaApoliceViewModel1 = this;
- if (critica.get_Documento() == null || !critica.get_Documento().get_Remessa().HasValue)
- {
- networkTime = Funcoes.GetNetworkTime();
- remessa = new DateTime?(networkTime.Date);
- }
- else
- {
- remessa = critica.get_Documento().get_Remessa();
- }
- criticaApoliceViewModel1.TransmissaoCritica = remessa;
- CriticaApoliceViewModel criticaApoliceViewModel2 = this;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 3))
- {
- nullable1 = new TipoSeguro?(base.SelectedDocumento.get_Situacao());
- }
- else
- {
- nullable1 = null;
- }
- criticaApoliceViewModel2.StatusDocumento = nullable1;
- if (base.SelectedDocumento != null)
- {
- TipoRecebimento? tipoRecebimento = base.SelectedDocumento.get_TipoRecebimento();
- this.IsParcela = tipoRecebimento.GetValueOrDefault() == 1;
- await this.SelecionaCliente(base.SelectedDocumento.get_Controle().get_Cliente());
- await this.SelecionaItens(base.SelectedDocumento.get_Controle().get_Id());
- this.HasChange = false;
- base.Loading(false);
- this.IsLoading = false;
- }
- else
- {
- this.IsParcela = true;
- this.HasChange = false;
- base.Loading(false);
- }
- }
- }
-
- public async Task SelecionaItens(long id)
- {
- this.Itens = await this._itemServico.BuscarItens(id, 0);
- }
-
- public async Task SelecionaUsuario()
- {
- this.IsLoading = true;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => {
- if (x.get_Configuracao() == 38)
- {
- return true;
- }
- return x.get_Configuracao() == 43;
- }) && Recursos.Usuario.get_Id() != 0)
- {
- this.Vinculos = await base.VerificaVinculoVendedor(Recursos.Usuario);
- }
- this.IsLoading = false;
- }
-
- private async Task<List<KeyValuePair<string, string>>> Validate()
- {
- List<Cliente> clientes;
- List<KeyValuePair<string, string>> keyValuePairs = new List<KeyValuePair<string, string>>();
- bool flag = !string.IsNullOrEmpty(this.SelectedCliente.get_Nome());
- TipoDocumento? documentoPrincipal = this.SelectedCliente.get_DocumentoPrincipal();
- if (documentoPrincipal.HasValue)
- {
- switch (documentoPrincipal.GetValueOrDefault())
- {
- case 0:
- {
- if (ValidationHelper.ValidateDocument(this.SelectedCliente.get_Documento()))
- {
- break;
- }
- flag = false;
- break;
- }
- case 1:
- {
- if (ValidationHelper.ValidateRne(this.SelectedCliente.get_Rne()))
- {
- break;
- }
- flag = false;
- break;
- }
- case 2:
- {
- if (ValidationHelper.ValidateCei(this.SelectedCliente.get_Cei()))
- {
- break;
- }
- flag = false;
- break;
- }
- }
- }
- if (!ValidationHelper.ValidateDocument(this.SelectedCliente.get_Documento()))
- {
- clientes = new List<Cliente>();
- }
- else
- {
- clientes = await (new ClienteServico()).BuscarClientePorDocumento(this.SelectedCliente.get_Documento());
- }
- List<Cliente> clientes1 = clientes;
- string nome = "";
- if (clientes1.Count > 0)
- {
- clientes1.ForEach((Cliente x) => {
- if (x.get_Id() == this.SelectedCliente.get_Id())
- {
- return;
- }
- if (this.SelectedCliente.get_IdEmpresa() != x.get_IdEmpresa())
- {
- return;
- }
- if (!string.IsNullOrEmpty(this.SelectedCliente.get_Documento()) && x.get_Documento() == this.SelectedCliente.get_Documento())
- {
- flag = false;
- nome = x.get_Nome();
- }
- });
- }
- if (!flag)
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Documento", string.Concat("O DOCUMENTO JÁ ESTÁ CADASTRADO PARA O CLIENTE ", nome, ".")));
- }
- if (this.SelectedCliente.get_Telefones() == null || this.SelectedCliente.get_Telefones().Count == 0)
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Telefones", "NECESSITA-SE AO MENOS UM TELEFONE VÁLIDO."));
- }
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 29) && (this.SelectedCliente.get_Emails() == null || this.SelectedCliente.get_Emails().Count == 0))
- {
- keyValuePairs.Add(new KeyValuePair<string, string>("Emails", "NECESSITA-SE AO MENOS UM E-MAIL VÁLIDO."));
- }
- List<KeyValuePair<string, string>> keyValuePairs1 = keyValuePairs;
- keyValuePairs = null;
- return keyValuePairs1;
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/Itens/AeronauticoViewModel.cs b/Gestor.Application/ViewModels/Seguros/Itens/AeronauticoViewModel.cs deleted file mode 100644 index ded661f..0000000 --- a/Gestor.Application/ViewModels/Seguros/Itens/AeronauticoViewModel.cs +++ /dev/null @@ -1,554 +0,0 @@ -using Gestor.Application.Actions;
-using Gestor.Application.Componentes;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Application.ViewModels.Seguros;
-using Gestor.Common.Validation;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Gestor.Application.ViewModels.Seguros.Itens
-{
- public class AeronauticoViewModel : ItemViewModel, IDisposable
- {
- private readonly ItemServico _itemServico;
-
- private readonly AeronauticoServico _servico;
-
- private bool _allowAlterarExcluir = true;
-
- private object _cobertura;
-
- private string _codigoItem;
-
- private Item _selectedItem = new Item();
-
- private bool _aero = true;
-
- private string _serie = "REGISTRO";
-
- private string _prefixo = "PREFIXO";
-
- private string _marinaAero = "AERÓDROMO";
-
- public bool Aero
- {
- get
- {
- return this._aero;
- }
- set
- {
- this._aero = value;
- base.OnPropertyChanged("Aero");
- }
- }
-
- public bool AllowAlterarExcluir
- {
- get
- {
- return this._allowAlterarExcluir;
- }
- set
- {
- this._allowAlterarExcluir = value;
- base.OnPropertyChanged("AllowAlterarExcluir");
- }
- }
-
- public object Cobertura
- {
- get
- {
- return this._cobertura;
- }
- set
- {
- this._cobertura = value;
- base.OnPropertyChanged("Cobertura");
- }
- }
-
- public string CodigoItem
- {
- get
- {
- return this._codigoItem;
- }
- set
- {
- this._codigoItem = value;
- base.OnPropertyChanged("CodigoItem");
- }
- }
-
- public bool Invoke
- {
- get;
- set;
- }
-
- private Item ItemSelecionado
- {
- get;
- set;
- }
-
- public string MarinaAero
- {
- get
- {
- return this._marinaAero;
- }
- set
- {
- this._marinaAero = value;
- base.OnPropertyChanged("MarinaAero");
- }
- }
-
- public string Prefixo
- {
- get
- {
- return this._prefixo;
- }
- set
- {
- this._prefixo = value;
- base.OnPropertyChanged("Prefixo");
- }
- }
-
- private Gestor.Model.Domain.Seguros.Ramo Ramo
- {
- get;
- }
-
- public Item SelectedItem
- {
- get
- {
- return this._selectedItem;
- }
- set
- {
- long? nullable;
- this._selectedItem = value;
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedItem");
- }
- }
-
- public string Serie
- {
- get
- {
- return this._serie;
- }
- set
- {
- this._serie = value;
- base.OnPropertyChanged("Serie");
- }
- }
-
- public AeronauticoViewModel(bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Gestor.Model.Domain.Seguros.Ramo ramo = null, bool endossoRenovacao = false)
- {
- this.Invoke = itemSelecionado == null;
- this.ItemSelecionado = itemSelecionado ?? ConsultaViewModel.ItemSelecionado;
- this.Ramo = ramo ?? ConsultaViewModel.DocumentoSelecionado.get_Controle().get_Ramo();
- if (this.Invoke)
- {
- this.ItemSelecionado = this.ItemSelecionado ?? new Item();
- this.ItemSelecionado.set_Documento(ConsultaViewModel.DocumentoSelecionado);
- }
- this._itemServico = new ItemServico();
- this._servico = new AeronauticoServico();
- this.Seleciona(this.ItemSelecionado);
- if (substituir)
- {
- this.Substituir(this.ItemSelecionado);
- }
- if (manutencao != null)
- {
- this.Manter(this.ItemSelecionado, manutencao);
- }
- this.AllowAlterarExcluir = !endossoRenovacao;
- this.CarregaCobertura();
- }
-
- public async void CancelarAlteracao()
- {
- base.Loading(true);
- await this.SelecionaItem(this.ItemSelecionado, false);
- await this.CoberturaViewModel.CancelarAlteracao();
- base.Alterar(false);
- base.Loading(false);
- }
-
- public void CarregaCobertura()
- {
- this.CoberturaViewModel.Item = this.ItemSelecionado;
- this.CoberturaViewModel.Ramo = this.Ramo;
- this.Cobertura = new CoberturaView(this.CoberturaViewModel);
- }
-
- public void Descarregar()
- {
- this.Cobertura = null;
- }
-
- public void Dispose()
- {
- Gestor.Application.Actions.Actions.UpdateItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.UpdateItem, new Action<Item>(this.Seleciona));
- Gestor.Application.Actions.Actions.SubstituirItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.SubstituirItem, new Action<Item>(this.Substituir));
- Gestor.Application.Actions.Actions.ManterItem = (Action<Item, ManutencaoItem>)Delegate.Remove(Gestor.Application.Actions.Actions.ManterItem, new Action<Item, ManutencaoItem>(this.Manter));
- }
-
- public async Task<bool> Excluir()
- {
- bool flag;
- if (this.SelectedItem == null || this.SelectedItem.get_Id() == 0)
- {
- flag = false;
- }
- else if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- bool flag1 = await this._servico.Delete(this.SelectedItem);
- base.Loading(false);
- if (flag1)
- {
- string str = string.Concat("EXCLUIU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " EXCLUÍDO COM SUCESSO"), true);
- flag = true;
- }
- else
- {
- await base.ShowMessage("NÃO POSSÍVEL EXCLUIR O ITEM", "OK", "", false);
- flag = false;
- }
- }
- else
- {
- flag = false;
- }
- return flag;
- }
-
- public async Task Incluir(bool substituir = false)
- {
- int? ordem;
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas;
- long? nullable;
- coberturas = (this.CoberturaViewModel.Coberturas == null ? this.CoberturaViewModel.CarregaCoberturaPadrao().ToList<Gestor.Model.Domain.Seguros.Cobertura>() : this.CoberturaViewModel.Coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>());
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas1 = coberturas;
- Item item = new Item();
- item.set_Documento(this.ItemSelecionado.get_Documento());
- Item item1 = item;
- ordem = (substituir ? base.ItemSubstituido.get_Ordem() : new int?(await base.QuantidadeDeItens(this.ItemSelecionado.get_Documento().get_Controle().get_Id())));
- item1.set_Ordem(ordem);
- Item item2 = item;
- Aeronautico aeronautico = new Aeronautico();
- aeronautico.set_Tipo(1);
- item2.set_Aeronautico(aeronautico);
- Item item3 = item;
- if (substituir)
- {
- nullable = new long?(base.ItemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- item3.set_Substituicao(nullable);
- Item item4 = item;
- item1 = null;
- item = null;
- ordem = item4.get_Ordem();
- if (ordem.GetValueOrDefault() == 2)
- {
- if (!await base.ShowMessage("ESTA APÓLICE SERÁ UMA FROTA, DESEJA CONTINUAR?", "SIM", "NÃO", false))
- {
- coberturas1 = null;
- item4 = null;
- return;
- }
- }
- bool valueOrDefault = substituir;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA COPIAR OS DADOS DO ITEM?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.SelectedItem = item4;
- this.SelectedItem.get_Aeronautico().set_Item(item4);
- }
- else
- {
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- }
- ordem = item4.get_Ordem();
- int num = 1;
- valueOrDefault = ordem.GetValueOrDefault() > num & ordem.HasValue;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA REPLICAR AS COBERTURAS DO ITEM SELECIONADO?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.CoberturaViewModel.CarregaPadrao();
- }
- else
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- if (substituir)
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- base.Alterar(true);
- coberturas1 = null;
- item4 = null;
- }
-
- public void Manter(Item item, ManutencaoItem manutencao)
- {
- if (manutencao.get_Tipo() == 1)
- {
- base.ItemSubstituido = item;
- }
- this.Manter(manutencao);
- base.Mantido = true;
- }
-
- public void Manter(ManutencaoItem manutencao)
- {
- long? nullable;
- object list;
- ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura> coberturas = this.CoberturaViewModel.Coberturas;
- if (coberturas != null)
- {
- list = coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>();
- }
- else
- {
- list = null;
- }
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.get_Aeronautico().set_Id((long)0);
- Item selectedItem = this.SelectedItem;
- Item itemSubstituido = base.ItemSubstituido;
- if (itemSubstituido != null)
- {
- nullable = new long?(itemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- selectedItem.set_Substituicao(nullable);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- if (manutencao.get_Tipo() == null)
- {
- this.SelectedItem.set_Sinistrado(false);
- this.SelectedItem.set_Status("");
- this.SelectedItem.set_Sinistro(null);
- this.SelectedItem.set_Sinistros(null);
- }
- this.CoberturaViewModel.CarregaPadrao();
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- if (list != null)
- {
- ((List<Gestor.Model.Domain.Seguros.Cobertura>)list).ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- else
- {
- }
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- string str;
- string str1;
- string str2;
- string str3;
- this.SelectedItem.set_Descricao(string.Format("{0} - FABRICANTE: {1} - MODELO: {2}", this.SelectedItem.get_Aeronautico().get_Tipo(), this.SelectedItem.get_Aeronautico().get_Fabricante(), this.SelectedItem.get_Aeronautico().get_Modelo()));
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedItem.Validate();
- if (keyValuePairs1.Count <= 0)
- {
- Item selectedItem = this.SelectedItem;
- selectedItem.set_Coberturas(await this.CoberturaViewModel.LimpaCoberturas());
- selectedItem = null;
- if (this.SelectedItem.get_Documento().get_Ordem() <= 0)
- {
- str = "";
- }
- else if (base.Mantido)
- {
- str = string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem());
- }
- else
- {
- str = (base.ItemSubstituido != null ? string.Format("SUBSTITUIÇÃO DO ITEM {0} NO ENDOSSO ORDEM {1}", base.ItemSubstituido.get_Ordem(), this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM INCLUÍDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- }
- string str4 = str;
- if (this.SelectedItem.get_Id() == 0)
- {
- this.SelectedItem.set_Status(str4);
- }
- str1 = (this.SelectedItem.get_Id() == 0 ? "INCLUIU" : "ALTEROU");
- str3 = str1;
- this.SelectedItem = await this._itemServico.Save(this.SelectedItem);
- if (this._itemServico.Sucesso)
- {
- if (base.ItemSubstituido != null)
- {
- str2 = (base.Mantido ? string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM SUBSTITUIDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- string str5 = str2;
- await this._itemServico.Substituir(base.ItemSubstituido, this.SelectedItem.get_Id(), str5);
- }
- base.Mantido = false;
- await this.SelecionaItem(this.SelectedItem, false);
- this.ItemSelecionado = this.SelectedItem;
- if (this.Invoke)
- {
- ConsultaViewModel.ItemSelecionado = this.SelectedItem;
- }
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " SALVO COM SUCESSO"), true);
- string str6 = string.Concat(str3, " ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str6, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- str3 = null;
- return keyValuePairs;
- }
-
- private async void Seleciona(Item item)
- {
- base.Loading(true);
- await base.PermissaoTela(3);
- await this.SelecionaItem(item, true);
- base.Loading(false);
- }
-
- public async Task SelecionaItem(Item item, bool registrar = true)
- {
- if (item == null || this.LastAccessId != item.get_Id() || this.LastAccessTela != 9)
- {
- base.Mantido = false;
- List<long> nums = new List<long>()
- {
- (long)13
- };
- if (nums.Contains(this.Ramo.get_Id()))
- {
- this.CoberturaViewModel.Ramo = this.Ramo;
- if (this.CoberturaViewModel.CoberturasPadrao == null)
- {
- await this.CoberturaViewModel.SelectionaCoberturas();
- }
- if (item == null || item.get_Id() == 0)
- {
- this.SelectedItem = null;
- this.CoberturaViewModel.Coberturas = null;
- base.IsVisible = Visibility.Visible;
- }
- else
- {
- base.Loading(true);
- item = await this._itemServico.BuscarItemPorIdAsync(item.get_Id());
- Item item1 = item;
- Aeronautico aeronautico = await this._itemServico.BuscaAeronautico(item.get_Id());
- item1.set_Aeronautico(aeronautico);
- item1 = null;
- this.SelectedItem = item;
- this.SelectedItem.Initialize();
- this.Initialized = true;
- this.CoberturaViewModel.Item = item;
- await this.CoberturaViewModel.CancelarAlteracao();
- if (registrar)
- {
- string str = string.Concat("ACESSOU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- }
- this.LastAccessId = this.SelectedItem.get_Id();
- this.LastAccessTela = 3;
- this.CodigoItem = this.SelectedItem.get_Id().ToString();
- base.Loading(false);
- }
- }
- }
- }
-
- public async void Substituir(Item item)
- {
- base.ItemSubstituido = item;
- await this.Incluir(true);
- }
-
- public void UpdateAero()
- {
- this.Aero = ValidationHelper.GetCategory(this.SelectedItem.get_Aeronautico().get_Tipo()) == "Aero";
- this.Serie = (this.Aero ? "REGISTRO" : "SÉRIE");
- this.Prefixo = (this.Aero ? "PREFIXO" : "NOME");
- this.MarinaAero = (this.Aero ? "AERÓDROMO" : "MARINA");
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/Itens/AutoViewModel.cs b/Gestor.Application/ViewModels/Seguros/Itens/AutoViewModel.cs deleted file mode 100644 index 735d4a7..0000000 --- a/Gestor.Application/ViewModels/Seguros/Itens/AutoViewModel.cs +++ /dev/null @@ -1,3018 +0,0 @@ -using ClosedXML.Excel;
-using Gestor.Application.Actions;
-using Gestor.Application.Componentes;
-using Gestor.Application.Helpers;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Application.ViewModels.Seguros;
-using Gestor.Common.Validation;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Common;
-using Gestor.Model.Domain.Configuracoes;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using Gestor.Model.Helper;
-using Microsoft.CSharp.RuntimeBinder;
-using Microsoft.Office.Interop.Excel;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Data;
-using System.Diagnostics;
-using System.Globalization;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Forms;
-
-namespace Gestor.Application.ViewModels.Seguros.Itens
-{
- public class AutoViewModel : ItemViewModel, IDisposable
- {
- private readonly ItemServico _itemServico;
-
- private readonly AutoServico _servico;
-
- private bool _allowAlterarExcluir = true;
-
- private Visibility _isVisiblePorcentagemReferencia = Visibility.Collapsed;
-
- private Visibility _isVisibleValorDeterminado = Visibility.Collapsed;
-
- private object _cobertura;
-
- private List<Gestor.Model.Common.Combustivel> _combustivel = ((Gestor.Model.Common.Combustivel[])Enum.GetValues(typeof(Gestor.Model.Common.Combustivel))).OrderBy<Gestor.Model.Common.Combustivel, string>(new Func<Gestor.Model.Common.Combustivel, string>((Gestor.Model.Common.Combustivel x) => Gestor.Common.Validation.ValidationHelper.GetCategory(x))).ToList<Gestor.Model.Common.Combustivel>();
-
- private Item _selectedItem = new Item();
-
- private List<Fabricante> _fabricantes;
-
- private Fabricante _selectedFabricante;
-
- private string _codigoItem;
-
- private Gestor.Model.Common.Categoria? _categocia;
-
- private Gestor.Model.Common.UsoVeiculo? _usoVeiculo;
-
- public bool AllowAlterarExcluir
- {
- get
- {
- return this._allowAlterarExcluir;
- }
- set
- {
- this._allowAlterarExcluir = value;
- base.OnPropertyChanged("AllowAlterarExcluir");
- }
- }
-
- public Gestor.Model.Common.Categoria? Categoria
- {
- get
- {
- return this._categocia;
- }
- set
- {
- bool auto;
- this._categocia = value;
- Item selectedItem = this.SelectedItem;
- if (selectedItem != null)
- {
- auto = selectedItem.get_Auto();
- }
- else
- {
- auto = false;
- }
- if (auto)
- {
- this.SelectedItem.get_Auto().set_Categoria(value);
- }
- base.OnPropertyChanged("Categoria");
- }
- }
-
- public object Cobertura
- {
- get
- {
- return this._cobertura;
- }
- set
- {
- this._cobertura = value;
- base.OnPropertyChanged("Cobertura");
- }
- }
-
- public string CodigoItem
- {
- get
- {
- return this._codigoItem;
- }
- set
- {
- this._codigoItem = value;
- base.OnPropertyChanged("CodigoItem");
- }
- }
-
- public List<Gestor.Model.Common.Combustivel> Combustivel
- {
- get
- {
- return this._combustivel;
- }
- set
- {
- this._combustivel = value;
- base.OnPropertyChanged("Combustivel");
- }
- }
-
- public List<Fabricante> Fabricantes
- {
- get
- {
- return this._fabricantes;
- }
- set
- {
- this._fabricantes = value;
- base.OnPropertyChanged("Fabricantes");
- }
- }
-
- public bool Invoke
- {
- get;
- set;
- }
-
- public Visibility IsVisiblePorcentagemReferencia
- {
- get
- {
- return this._isVisiblePorcentagemReferencia;
- }
- set
- {
- this._isVisiblePorcentagemReferencia = value;
- base.OnPropertyChanged("IsVisiblePorcentagemReferencia");
- }
- }
-
- public Visibility IsVisibleValorDeterminado
- {
- get
- {
- return this._isVisibleValorDeterminado;
- }
- set
- {
- this._isVisibleValorDeterminado = value;
- base.OnPropertyChanged("IsVisibleValorDeterminado");
- }
- }
-
- private Item ItemSelecionado
- {
- get;
- set;
- }
-
- private Gestor.Model.Domain.Seguros.Ramo Ramo
- {
- get;
- }
-
- public Fabricante SelectedFabricante
- {
- get
- {
- return this._selectedFabricante;
- }
- set
- {
- this._selectedFabricante = value;
- base.OnPropertyChanged("SelectedFabricante");
- }
- }
-
- public Item SelectedItem
- {
- get
- {
- return this._selectedItem;
- }
- set
- {
- long? nullable;
- this._selectedItem = value;
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedItem");
- }
- }
-
- public Gestor.Model.Common.UsoVeiculo? UsoVeiculo
- {
- get
- {
- return this._usoVeiculo;
- }
- set
- {
- bool auto;
- if (value.GetValueOrDefault() == 2 || value.GetValueOrDefault() == 3)
- {
- this.SelectedItem.get_Auto().set_Categoria(new Gestor.Model.Common.Categoria?(3));
- this.Categoria = new Gestor.Model.Common.Categoria?(3);
- }
- Item selectedItem = this.SelectedItem;
- if (selectedItem != null)
- {
- auto = selectedItem.get_Auto();
- }
- else
- {
- auto = false;
- }
- if (auto && value.HasValue)
- {
- this.SelectedItem.get_Auto().set_UsoVeiculo(value);
- }
- this._usoVeiculo = value;
- base.OnPropertyChanged("UsoVeiculo");
- }
- }
-
- public AutoViewModel(bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Gestor.Model.Domain.Seguros.Ramo ramo = null, bool endossoRenovacao = false)
- {
- this.Invoke = itemSelecionado == null;
- this.ItemSelecionado = itemSelecionado ?? ConsultaViewModel.ItemSelecionado;
- this.Ramo = ramo ?? ConsultaViewModel.DocumentoSelecionado.get_Controle().get_Ramo();
- if (this.Invoke)
- {
- this.ItemSelecionado = this.ItemSelecionado ?? new Item();
- this.ItemSelecionado.set_Documento(ConsultaViewModel.DocumentoSelecionado);
- }
- this._itemServico = new ItemServico();
- this._servico = new AutoServico();
- this.Seleciona(this.ItemSelecionado);
- if (substituir)
- {
- this.Substituir(this.ItemSelecionado);
- }
- if (manutencao != null)
- {
- this.Manter(this.ItemSelecionado, manutencao);
- }
- this.AllowAlterarExcluir = !endossoRenovacao;
- this.CarregaCobertura();
- }
-
- public void Atualiza(string valorSelecionado)
- {
- if (valorSelecionado == "MERCADO")
- {
- this.IsVisiblePorcentagemReferencia = Visibility.Visible;
- this.IsVisibleValorDeterminado = Visibility.Collapsed;
- return;
- }
- this.IsVisiblePorcentagemReferencia = Visibility.Collapsed;
- this.IsVisibleValorDeterminado = Visibility.Visible;
- }
-
- public async void BaixarXls()
- {
- char chr;
- object obj;
- object obj1;
- object obj2;
- object obj3;
- object obj4;
- object obj5;
- object obj6;
- object obj7;
- object obj8;
- object obj9;
- object obj10;
- object obj11;
- object obj12;
- object obj13;
- object obj14;
- object obj15;
- object obj16;
- object obj17;
- object obj18;
- object obj19;
- object obj20;
- object obj21;
- object obj22;
- object obj23;
- object obj24;
- object obj25;
- object obj26;
- object obj27;
- object obj28;
- object obj29;
- object obj30;
- object obj31;
- object obj32;
- object obj33;
- object obj34;
- object obj35;
- object obj36;
- object obj37;
- object obj38;
- object obj39;
- object obj40;
- object obj41;
- object obj42;
- object obj43;
- object obj44;
- object obj45;
- object obj46;
- object obj47;
- object obj48;
- object obj49;
- object obj50;
- object obj51;
- object obj52;
- object obj53;
- object obj54;
- object obj55;
- object obj56;
- object obj57;
- object obj58;
- object obj59;
- object obj60;
- object obj61;
- object obj62;
- object obj63;
- object obj64;
- object obj65;
- object obj66;
- object obj67;
- object obj68;
- object obj69;
- object obj70;
- object obj71;
- object obj72;
- using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
- {
- folderBrowserDialog.SelectedPath = Environment.SpecialFolder.Desktop.ToString();
- if (folderBrowserDialog.ShowDialog() == DialogResult.OK && !string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath))
- {
- XLWorkbook xLWorkbook = new XLWorkbook();
- DataTable dataTable = new DataTable();
- List<string> strs = new List<string>()
- {
- "placa",
- "fabricante",
- "modelo",
- "fipe",
- "chassi",
- "anofabricacao",
- "anomodelo",
- "cor",
- "categoria",
- "combustivel",
- "zerokm",
- "renavam",
- "capacidade",
- "portas",
- "bonus",
- "ceppernoite",
- "ci",
- "financiado",
- "correcao",
- "isencao",
- "pcd",
- "cepcirculacao",
- "tipocobertura",
- "porcentagemreferencia",
- "tabelareferencia",
- "valordeterminado",
- "observacao",
- "pr casco",
- "fr casco",
- "lmi casco",
- "obs casco",
- "pr dm",
- "fr dm",
- "lmi dm",
- "obs dm",
- "pr dc",
- "fr dc",
- "lmi dc",
- "obs dc",
- "pr morte",
- "fr morte",
- "lmi morte",
- "obs morte",
- "pr invalidez",
- "fr invalidez",
- "lmi invalidez",
- "obs invalidez",
- "pr carro reserva",
- "fr carro reserva",
- "lmi carro reserva",
- "obs carro reserva",
- "pr vidros",
- "fr vidros",
- "lmi vidros",
- "obs vidros",
- "pr carroceria",
- "fr carroceria",
- "lmi carroceria",
- "obs carroceria",
- "pr Ass 24Horas",
- "fr Ass 24Horas",
- "lmi Ass 24Horas",
- "obs Ass 24Horas",
- "pr Danos Morais",
- "fr Danos Morais",
- "lmi Danos Morais",
- "obs Danos Morais",
- "pr app",
- "fr app",
- "lmi app",
- "obs app",
- "pr equipamentos",
- "fr equipamentos",
- "lmi equipamentos",
- "obs equipamentos"
- };
- List<string> strs1 = strs;
- List<List<string>> lists = new List<List<string>>();
- List<string> strs2 = new List<string>()
- {
- "XXX0X00",
- "FORD",
- "MODELO",
- "000000-0",
- "75F 8C33MP Y2 W12900",
- "2000",
- "2001",
- "PRETO",
- "PASSEIO",
- "FLEX",
- "SIM",
- "00000000000",
- "5",
- "5",
- "100",
- "00.000-000",
- "000000",
- "NÃO",
- "MERCADO",
- "SEM",
- "NÃO",
- "00.000-000",
- "COMPREENSIVA",
- "100",
- "FIPE",
- "",
- "OBSERVAÇÕES",
- "1000",
- "2000",
- "3000",
- "teste obs",
- "",
- "",
- "",
- "",
- "2000",
- "3000",
- "4000",
- "teste obs",
- "100000",
- "200000",
- "300000",
- "teste obs",
- "2000",
- "3000",
- "4000",
- "teste obs",
- "",
- "",
- "",
- "",
- "1000",
- "2000",
- "3000",
- "teste obs",
- "2000",
- "3000",
- "4000",
- "teste obs",
- "",
- "",
- "",
- "",
- "1000",
- "2000",
- "3000",
- "teste obs",
- "",
- "",
- "",
- "",
- "2000",
- "3000",
- "4000",
- "teste obs",
- "1000",
- "2000",
- "3000",
- "teste obs"
- };
- lists.Add(strs2);
- List<string> strs3 = new List<string>()
- {
- "XXX0X01",
- "CHEVROLET",
- "MODELO",
- "000000-1",
- "4EL ZBE75H B5 A65693",
- "2000",
- "2001",
- "VERDE",
- "PICKUP",
- "GASOLINA/ÁLCOOL/GNV",
- "NÃO",
- "00000000000",
- "5",
- "2",
- "100",
- "00.000-000",
- "000000",
- "SIM",
- "DETERMINADO",
- "IPI E ICMS",
- "NÃO",
- "00.000-000",
- "INCÊNDIO E ROUBO/FURTO",
- "100",
- "MOLICAR",
- "19767,34",
- "OBSERVAÇÕES",
- "1000",
- "2000",
- "3000",
- "teste obs",
- "",
- "",
- "",
- "",
- "2000",
- "3000",
- "4000",
- "teste obs",
- "100000",
- "200000",
- "300000",
- "teste obs",
- "2000",
- "3000",
- "4000",
- "teste obs",
- "",
- "",
- "",
- "",
- "1000",
- "2000",
- "3000",
- "teste obs",
- "2000",
- "3000",
- "4000",
- "teste obs",
- "",
- "",
- "",
- "",
- "1000",
- "2000",
- "3000",
- "teste obs",
- "",
- "",
- "",
- "",
- "2000",
- "3000",
- "4000",
- "teste obs",
- "1000",
- "2000",
- "3000",
- "teste obs"
- };
- lists.Add(strs3);
- List<List<string>> lists1 = lists;
- List<string> strs4 = new List<string>()
- {
- "BRANCO",
- "CINZA",
- "PRATA",
- "VERMELHO",
- "AMARELO",
- "OURO",
- "LARANJA",
- "ROSA",
- "VERDE",
- "AZUL",
- "VINHO",
- "MARROM",
- "BEGE",
- "DOURADO",
- "OUTROS"
- };
- List<string> strs5 = strs4;
- List<string> strs6 = new List<string>()
- {
- "PICKUP",
- "OUTROS",
- "PASSEIO",
- "CAMINHÃO",
- "CAMINHONETE",
- "ÔNIBUS",
- "UTILITÁRIO",
- "CARGA",
- "MOTOCICLETA",
- "TAXI",
- "UBER",
- "REBOCADOR",
- "REBOQUE/SEMI REBOQUE"
- };
- List<string> strs7 = strs6;
- List<string> strs8 = new List<string>()
- {
- "ÁLCOOL",
- "GASOLINA",
- "DIESEL",
- "FLEX",
- "GNV",
- "OUTROS",
- "GASOLINA/GNV",
- "GASOLINA/ÁLCOOL/GNV",
- "GASOLINA/ELÉTRICO",
- "HÍBRIDO",
- "ELÉTRICO",
- "GASOLINA/ÁLCOOL/ELÉTRICO"
- };
- List<string> strs9 = strs8;
- List<string> strs10 = new List<string>()
- {
- "MERCADO",
- "DETERMINADO"
- };
- List<string> strs11 = new List<string>()
- {
- "SEM ISENÇÃO",
- "ICMS",
- "IPI",
- "IPI E ICMS"
- };
- List<string> strs12 = new List<string>()
- {
- "COMPREENSIVA",
- "INCÊNDIO E ROUBO/FURTO",
- "DANOS A TERCEIROS",
- "PASSAGEIROS",
- "ROUBO/FURTO"
- };
- List<string> strs13 = new List<string>()
- {
- "MOLICAR",
- "FIPE"
- };
- List<string> strs14 = new List<string>()
- {
- "SIM",
- "NÃO"
- };
- foreach (string str in strs1)
- {
- DataColumn dataColumn = new DataColumn()
- {
- DataType = Type.GetType("System.String"),
- ColumnName = str
- };
- dataTable.Columns.Add(dataColumn);
- }
- foreach (List<string> strs15 in lists1)
- {
- DataRow item = dataTable.NewRow();
- foreach (string str1 in strs1)
- {
- item[str1] = strs15[strs1.IndexOf(str1)];
- }
- dataTable.Rows.Add(item);
- }
- xLWorkbook.get_Worksheets().Add(dataTable, "EXEMPLO AUTO EXCEL");
- xLWorkbook.SaveAs(string.Concat(folderBrowserDialog.SelectedPath, "\\EXEMPLO AUTO EXCEL.xlsx"));
- xLWorkbook = new XLWorkbook();
- dataTable = new DataTable();
- foreach (string str2 in strs1)
- {
- DataColumn dataColumn1 = new DataColumn()
- {
- DataType = Type.GetType("System.String"),
- ColumnName = str2
- };
- dataTable.Columns.Add(dataColumn1);
- }
- foreach (string str3 in strs5)
- {
- DataRow dataRow = dataTable.NewRow();
- Label2:
- foreach (string str4 in strs1)
- {
- int num = strs5.IndexOf(str3);
- if (str4 == null)
- {
- continue;
- }
- switch (str4.Length)
- {
- case 2:
- {
- if (str4 == "ci")
- {
- DataRow dataRow1 = dataRow;
- string str5 = str4;
- obj = (num == 0 ? "000000" : "");
- dataRow1[str5] = obj;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 3:
- {
- chr = str4[0];
- if (chr != 'c')
- {
- if (chr == 'p')
- {
- if (str4 == "pcd")
- {
- break;
- }
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (str4 == "cor")
- {
- DataRow dataRow2 = dataRow;
- string str6 = str4;
- obj1 = (strs5.Count >= num + 1 ? strs5[num] : "");
- dataRow2[str6] = obj1;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 4:
- {
- if (str4 == "fipe")
- {
- DataRow dataRow3 = dataRow;
- string str7 = str4;
- obj3 = (num == 0 ? "000000-0" : "");
- dataRow3[str7] = obj3;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 5:
- {
- chr = str4[4];
- if (chr > 'c')
- {
- if (chr != 'm')
- {
- if (chr != 's')
- {
- continue;
- }
- else if (str4 == "bonus")
- {
- DataRow dataRow4 = dataRow;
- string str8 = str4;
- obj6 = (num == 0 ? "0" : "");
- dataRow4[str8] = obj6;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (str4 == "pr dm")
- {
- DataRow dataRow5 = dataRow;
- string str9 = str4;
- obj4 = (num == 0 ? "0" : "");
- dataRow5[str9] = obj4;
- continue;
- }
- else if (str4 == "fr dm")
- {
- DataRow dataRow6 = dataRow;
- string str10 = str4;
- obj5 = (num == 0 ? "0" : "");
- dataRow6[str10] = obj5;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr == 'a')
- {
- if (str4 == "placa")
- {
- DataRow dataRow7 = dataRow;
- string str11 = str4;
- obj7 = (num == 0 ? "XXX0X00" : "");
- dataRow7[str11] = obj7;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'c')
- {
- continue;
- }
- else if (str4 == "pr dc")
- {
- DataRow dataRow8 = dataRow;
- string str12 = str4;
- obj8 = (num == 0 ? "0" : "");
- dataRow8[str12] = obj8;
- continue;
- }
- else if (str4 == "fr dc")
- {
- DataRow dataRow9 = dataRow;
- string str13 = str4;
- obj9 = (num == 0 ? "0" : "");
- dataRow9[str13] = obj9;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 6:
- {
- chr = str4[0];
- if (chr > 'f')
- {
- switch (chr)
- {
- case 'l':
- {
- if (str4 == "lmi dm")
- {
- DataRow dataRow10 = dataRow;
- string str14 = str4;
- obj10 = (num == 0 ? "0" : "");
- dataRow10[str14] = obj10;
- continue;
- }
- else if (str4 == "lmi dc")
- {
- DataRow dataRow11 = dataRow;
- string str15 = str4;
- obj11 = (num == 0 ? "0" : "");
- dataRow11[str15] = obj11;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'm':
- {
- if (str4 == "modelo")
- {
- DataRow dataRow12 = dataRow;
- string str16 = str4;
- obj12 = (num == 0 ? "MODELO" : "");
- dataRow12[str16] = obj12;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'n':
- {
- continue;
- }
- case 'o':
- {
- if (str4 == "obs dm")
- {
- DataRow dataRow13 = dataRow;
- string str17 = str4;
- obj13 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow13[str17] = obj13;
- continue;
- }
- else if (str4 == "obs dc")
- {
- DataRow dataRow14 = dataRow;
- string str18 = str4;
- obj14 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow14[str18] = obj14;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'p':
- {
- if (str4 == "portas")
- {
- DataRow dataRow15 = dataRow;
- string str19 = str4;
- obj15 = (num == 0 ? "00" : "");
- dataRow15[str19] = obj15;
- continue;
- }
- else if (str4 == "pr app")
- {
- DataRow dataRow16 = dataRow;
- string str20 = str4;
- obj16 = (num == 0 ? "0" : "");
- dataRow16[str20] = obj16;
- continue;
- }
- else
- {
- continue;
- }
- }
- default:
- {
- if (chr == 'z')
- {
- if (str4 == "zerokm")
- {
- goto Label0;
- }
- continue;
- }
- else
- {
- continue;
- }
- }
- }
- }
- else if (chr == 'c')
- {
- if (str4 == "chassi")
- {
- DataRow dataRow17 = dataRow;
- string str21 = str4;
- obj17 = (num == 0 ? "XXX XXXXXX XX XXXXXX" : "");
- dataRow17[str21] = obj17;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'f')
- {
- continue;
- }
- else if (str4 == "fr app")
- {
- DataRow dataRow18 = dataRow;
- string str22 = str4;
- obj18 = (num == 0 ? "0" : "");
- dataRow18[str22] = obj18;
- continue;
- }
- else
- {
- continue;
- }
- break;
- }
- case 7:
- {
- chr = str4[0];
- if (chr <= 'l')
- {
- if (chr == 'i')
- {
- if (str4 == "isencao")
- {
- DataRow dataRow19 = dataRow;
- string str23 = str4;
- obj21 = (strs11.Count >= num + 1 ? strs11[num] : "");
- dataRow19[str23] = obj21;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'l')
- {
- continue;
- }
- else if (str4 == "lmi app")
- {
- DataRow dataRow20 = dataRow;
- string str24 = str4;
- obj22 = (num == 0 ? "0" : "");
- dataRow20[str24] = obj22;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr == 'o')
- {
- if (str4 == "obs app")
- {
- DataRow dataRow21 = dataRow;
- string str25 = str4;
- obj19 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow21[str25] = obj19;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'r')
- {
- continue;
- }
- else if (str4 == "renavam")
- {
- DataRow dataRow22 = dataRow;
- string str26 = str4;
- obj20 = (num == 0 ? "00000000000" : "");
- dataRow22[str26] = obj20;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 8:
- {
- chr = str4[0];
- if (chr == 'c')
- {
- if (str4 == "correcao")
- {
- DataRow dataRow23 = dataRow;
- string str27 = str4;
- obj23 = (strs10.Count >= num + 1 ? strs10[num] : "");
- dataRow23[str27] = obj23;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr == 'f')
- {
- if (str4 == "fr casco")
- {
- DataRow dataRow24 = dataRow;
- string str28 = str4;
- obj24 = (num == 0 ? "0" : "");
- dataRow24[str28] = obj24;
- continue;
- }
- else if (str4 == "fr morte")
- {
- DataRow dataRow25 = dataRow;
- string str29 = str4;
- obj25 = (num == 0 ? "0" : "");
- dataRow25[str29] = obj25;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'p')
- {
- continue;
- }
- else if (str4 == "pr casco")
- {
- DataRow dataRow26 = dataRow;
- string str30 = str4;
- obj26 = (num == 0 ? "0" : "");
- dataRow26[str30] = obj26;
- continue;
- }
- else if (str4 == "pr morte")
- {
- DataRow dataRow27 = dataRow;
- string str31 = str4;
- obj27 = (num == 0 ? "0" : "");
- dataRow27[str31] = obj27;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 9:
- {
- chr = str4[0];
- if (chr > 'c')
- {
- if (chr != 'f')
- {
- switch (chr)
- {
- case 'l':
- {
- if (str4 == "lmi casco")
- {
- DataRow dataRow28 = dataRow;
- string str32 = str4;
- obj29 = (num == 0 ? "0" : "");
- dataRow28[str32] = obj29;
- continue;
- }
- else if (str4 == "lmi morte")
- {
- DataRow dataRow29 = dataRow;
- string str33 = str4;
- obj30 = (num == 0 ? "0" : "");
- dataRow29[str33] = obj30;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'o':
- {
- if (str4 == "obs casco")
- {
- DataRow dataRow30 = dataRow;
- string str34 = str4;
- obj31 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow30[str34] = obj31;
- continue;
- }
- else if (str4 == "obs morte")
- {
- DataRow dataRow31 = dataRow;
- string str35 = str4;
- obj32 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow31[str35] = obj32;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'p':
- {
- if (str4 == "pr vidros")
- {
- DataRow dataRow32 = dataRow;
- string str36 = str4;
- obj33 = (num == 0 ? "0" : "");
- dataRow32[str36] = obj33;
- continue;
- }
- else
- {
- continue;
- }
- }
- default:
- {
- continue;
- }
- }
- }
- else if (str4 == "fr vidros")
- {
- DataRow dataRow33 = dataRow;
- string str37 = str4;
- obj28 = (num == 0 ? "0" : "");
- dataRow33[str37] = obj28;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr == 'a')
- {
- if (str4 == "anomodelo")
- {
- DataRow dataRow34 = dataRow;
- string str38 = str4;
- obj34 = (num == 0 ? "0000" : "");
- dataRow34[str38] = obj34;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'c')
- {
- continue;
- }
- else if (str4 == "categoria")
- {
- DataRow dataRow35 = dataRow;
- string str39 = str4;
- obj35 = (strs7.Count >= num + 1 ? strs7[num] : "");
- dataRow35[str39] = obj35;
- continue;
- }
- else
- {
- continue;
- }
- break;
- }
- case 10:
- {
- chr = str4[2];
- if (chr <= 'i')
- {
- if (chr == 'b')
- {
- if (str4 == "fabricante")
- {
- DataRow dataRow36 = dataRow;
- string str40 = str4;
- obj39 = (num == 0 ? "FABRICANTE" : "");
- dataRow36[str40] = obj39;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'i')
- {
- continue;
- }
- else if (str4 == "lmi vidros")
- {
- DataRow dataRow37 = dataRow;
- string str41 = str4;
- obj40 = (num == 0 ? "0" : "");
- dataRow37[str41] = obj40;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr == 'n')
- {
- if (str4 == "financiado")
- {
- break;
- }
- continue;
- }
- else if (chr == 'p')
- {
- if (str4 == "capacidade")
- {
- DataRow dataRow38 = dataRow;
- string str42 = str4;
- obj36 = (num == 0 ? "000" : "");
- dataRow38[str42] = obj36;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 's')
- {
- continue;
- }
- else if (str4 == "observacao")
- {
- DataRow dataRow39 = dataRow;
- string str43 = str4;
- obj37 = (num == 0 ? "OBSERVAÇÕES" : "");
- dataRow39[str43] = obj37;
- continue;
- }
- else if (str4 == "obs vidros")
- {
- DataRow dataRow40 = dataRow;
- string str44 = str4;
- obj38 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow40[str44] = obj38;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 11:
- {
- chr = str4[1];
- if (chr == 'e')
- {
- if (str4 == "ceppernoite")
- {
- DataRow dataRow41 = dataRow;
- string str45 = str4;
- obj41 = (num == 0 ? "00.000-000" : "");
- dataRow41[str45] = obj41;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'o')
- {
- continue;
- }
- else if (str4 == "combustivel")
- {
- DataRow dataRow42 = dataRow;
- string str46 = str4;
- obj42 = (strs9.Count >= num + 1 ? strs9[num] : "");
- dataRow42[str46] = obj42;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 12:
- {
- chr = str4[0];
- if (chr == 'f')
- {
- if (str4 == "fr invalidez")
- {
- DataRow dataRow43 = dataRow;
- string str47 = str4;
- obj43 = (num == 0 ? "0" : "");
- dataRow43[str47] = obj43;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'p')
- {
- continue;
- }
- else if (str4 == "pr invalidez")
- {
- DataRow dataRow44 = dataRow;
- string str48 = str4;
- obj44 = (num == 0 ? "0" : "");
- dataRow44[str48] = obj44;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 13:
- {
- chr = str4[0];
- if (chr > 'c')
- {
- if (chr != 'f')
- {
- switch (chr)
- {
- case 'l':
- {
- if (str4 == "lmi invalidez")
- {
- DataRow dataRow45 = dataRow;
- string str49 = str4;
- obj46 = (num == 0 ? "0" : "");
- dataRow45[str49] = obj46;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'm':
- case 'n':
- {
- continue;
- }
- case 'o':
- {
- if (str4 == "obs invalidez")
- {
- DataRow dataRow46 = dataRow;
- string str50 = str4;
- obj47 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow46[str50] = obj47;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'p':
- {
- if (str4 == "pr carroceria")
- {
- DataRow dataRow47 = dataRow;
- string str51 = str4;
- obj48 = (num == 0 ? "0" : "");
- dataRow47[str51] = obj48;
- continue;
- }
- else
- {
- continue;
- }
- }
- default:
- {
- if (chr == 't')
- {
- break;
- }
- else
- {
- goto Label2;
- }
- }
- }
- if (str4 == "tipocobertura")
- {
- DataRow dataRow48 = dataRow;
- string str52 = str4;
- obj49 = (strs12.Count >= num + 1 ? strs12[num] : "");
- dataRow48[str52] = obj49;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (str4 == "fr carroceria")
- {
- DataRow dataRow49 = dataRow;
- string str53 = str4;
- obj45 = (num == 0 ? "0" : "");
- dataRow49[str53] = obj45;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr == 'a')
- {
- if (str4 == "anofabricacao")
- {
- DataRow dataRow50 = dataRow;
- string str54 = str4;
- obj50 = (num == 0 ? "0000" : "");
- dataRow50[str54] = obj50;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'c')
- {
- continue;
- }
- else if (str4 == "cepcirculacao")
- {
- DataRow dataRow51 = dataRow;
- string str55 = str4;
- obj51 = (num == 0 ? "00.000-000" : "");
- dataRow51[str55] = obj51;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 14:
- {
- chr = str4[0];
- if (chr != 'f')
- {
- switch (chr)
- {
- case 'l':
- {
- if (str4 == "lmi carroceria")
- {
- DataRow dataRow52 = dataRow;
- string str56 = str4;
- obj53 = (num == 0 ? "0" : "");
- dataRow52[str56] = obj53;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'o':
- {
- if (str4 == "obs carroceria")
- {
- DataRow dataRow53 = dataRow;
- string str57 = str4;
- obj54 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow53[str57] = obj54;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'p':
- {
- if (str4 == "pr Ass 24Horas")
- {
- DataRow dataRow54 = dataRow;
- string str58 = str4;
- obj55 = (num == 0 ? "0" : "");
- dataRow54[str58] = obj55;
- continue;
- }
- else
- {
- continue;
- }
- }
- default:
- {
- continue;
- }
- }
- }
- else if (str4 == "fr Ass 24Horas")
- {
- DataRow dataRow55 = dataRow;
- string str59 = str4;
- obj52 = (num == 0 ? "0" : "");
- dataRow55[str59] = obj52;
- continue;
- }
- else
- {
- continue;
- }
- break;
- }
- case 15:
- {
- chr = str4[0];
- if (chr != 'f')
- {
- switch (chr)
- {
- case 'l':
- {
- if (str4 == "lmi Ass 24Horas")
- {
- DataRow dataRow56 = dataRow;
- string str60 = str4;
- obj58 = (num == 0 ? "0" : "");
- dataRow56[str60] = obj58;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'o':
- {
- if (str4 == "obs Ass 24Horas")
- {
- DataRow dataRow57 = dataRow;
- string str61 = str4;
- obj59 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow57[str61] = obj59;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'p':
- {
- if (str4 == "pr Danos Morais")
- {
- DataRow dataRow58 = dataRow;
- string str62 = str4;
- obj60 = (num == 0 ? "0" : "");
- dataRow58[str62] = obj60;
- continue;
- }
- else if (str4 == "pr equipamentos")
- {
- DataRow dataRow59 = dataRow;
- string str63 = str4;
- obj61 = (num == 0 ? "0" : "");
- dataRow59[str63] = obj61;
- continue;
- }
- else
- {
- continue;
- }
- }
- default:
- {
- continue;
- }
- }
- }
- else if (str4 == "fr Danos Morais")
- {
- DataRow dataRow60 = dataRow;
- string str64 = str4;
- obj56 = (num == 0 ? "0" : "");
- dataRow60[str64] = obj56;
- continue;
- }
- else if (str4 == "fr equipamentos")
- {
- DataRow dataRow61 = dataRow;
- string str65 = str4;
- obj57 = (num == 0 ? "0" : "");
- dataRow61[str65] = obj57;
- continue;
- }
- else
- {
- continue;
- }
- break;
- }
- case 16:
- {
- chr = str4[0];
- if (chr <= 'p')
- {
- if (chr != 'f')
- {
- switch (chr)
- {
- case 'l':
- {
- if (str4 == "lmi Danos Morais")
- {
- DataRow dataRow62 = dataRow;
- string str66 = str4;
- obj65 = (num == 0 ? "0" : "");
- dataRow62[str66] = obj65;
- continue;
- }
- else if (str4 == "lmi equipamentos")
- {
- DataRow dataRow63 = dataRow;
- string str67 = str4;
- obj66 = (num == 0 ? "0" : "");
- dataRow63[str67] = obj66;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'o':
- {
- if (str4 == "obs Danos Morais")
- {
- DataRow dataRow64 = dataRow;
- string str68 = str4;
- obj67 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow64[str68] = obj67;
- continue;
- }
- else if (str4 == "obs equipamentos")
- {
- DataRow dataRow65 = dataRow;
- string str69 = str4;
- obj68 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow65[str69] = obj68;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 'p':
- {
- if (str4 == "pr carro reserva")
- {
- DataRow dataRow66 = dataRow;
- string str70 = str4;
- obj69 = (num == 0 ? "0" : "");
- dataRow66[str70] = obj69;
- continue;
- }
- else
- {
- continue;
- }
- }
- default:
- {
- continue;
- }
- }
- }
- else if (str4 == "fr carro reserva")
- {
- DataRow dataRow67 = dataRow;
- string str71 = str4;
- obj64 = (num == 0 ? "0" : "");
- dataRow67[str71] = obj64;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr == 't')
- {
- if (str4 == "tabelareferencia")
- {
- DataRow dataRow68 = dataRow;
- string str72 = str4;
- obj62 = (strs13.Count >= num + 1 ? strs13[num] : "");
- dataRow68[str72] = obj62;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'v')
- {
- continue;
- }
- else if (str4 == "valordeterminado")
- {
- DataRow dataRow69 = dataRow;
- string str73 = str4;
- obj63 = (num == 0 ? "000000" : "");
- dataRow69[str73] = obj63;
- continue;
- }
- else
- {
- continue;
- }
- break;
- }
- case 17:
- {
- chr = str4[0];
- if (chr == 'l')
- {
- if (str4 == "lmi carro reserva")
- {
- DataRow dataRow70 = dataRow;
- string str74 = str4;
- obj70 = (num == 0 ? "0" : "");
- dataRow70[str74] = obj70;
- continue;
- }
- else
- {
- continue;
- }
- }
- else if (chr != 'o')
- {
- continue;
- }
- else if (str4 == "obs carro reserva")
- {
- DataRow dataRow71 = dataRow;
- string str75 = str4;
- obj71 = (num == 0 ? "OBSERVAÇÃO" : "");
- dataRow71[str75] = obj71;
- continue;
- }
- else
- {
- continue;
- }
- }
- case 21:
- {
- if (str4 == "porcentagemreferencia")
- {
- DataRow dataRow72 = dataRow;
- string str76 = str4;
- obj72 = (num == 0 ? "000" : "");
- dataRow72[str76] = obj72;
- continue;
- }
- else
- {
- continue;
- }
- }
- default:
- {
- continue;
- }
- }
- Label0:
- DataRow dataRow73 = dataRow;
- string str77 = str4;
- obj2 = (strs14.Count >= num + 1 ? strs14[num] : "");
- dataRow73[str77] = obj2;
- }
- dataTable.Rows.Add(dataRow);
- }
- xLWorkbook.get_Worksheets().Add(dataTable, "VALORES PERMITIDOS AUTO EXCEL");
- xLWorkbook.SaveAs(string.Concat(folderBrowserDialog.SelectedPath, "\\VALORES PERMITIDOS AUTO EXCEL.xlsx"));
- }
- await base.ShowMessage(string.Concat("\"EXEMPLO AUTO EXCEL.xlsx\" E \"VALORES PERMITIDOS AUTO EXCEL.xlsx\"\nFORAM SALVOS EM \"", folderBrowserDialog.SelectedPath, "\""), "OK", "", false);
- }
- folderBrowserDialog = null;
- return;
- goto Label2;
- }
-
- public async Task<Fipe> BuscaModelo(string fipe)
- {
- return await this._itemServico.BuscarModelo(fipe);
- }
-
- public async void CancelarAlteracao()
- {
- base.Loading(true);
- await this.SelecionaItem(this.ItemSelecionado, false);
- await this.CoberturaViewModel.CancelarAlteracao();
- base.Alterar(false);
- base.Loading(false);
- }
-
- public void CarregaCobertura()
- {
- this.CoberturaViewModel.Item = this.ItemSelecionado;
- this.CoberturaViewModel.Ramo = this.Ramo;
- this.Cobertura = new CoberturaView(this.CoberturaViewModel);
- }
-
- public List<Gestor.Model.Domain.Seguros.Cobertura> Coberturas(DataRow row)
- {
- char chr;
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas = new List<Gestor.Model.Domain.Seguros.Cobertura>();
- foreach (DataColumn column in row.Table.Columns)
- {
- if (!Regex.IsMatch(column.ColumnName, "pr .+"))
- {
- continue;
- }
- string value = Regex.Match(column.ColumnName, "pr (.+)").Groups[1].Value;
- if (value != "casco" && value != "dm" && value != "dc" && value != "morte" && value != "invalidez" && value != "carro reserva" && value != "vidros" && value != "carroceria" && value != "ass 24horas" && value != "danos morais" && value != "app" && value != "equipamentos")
- {
- continue;
- }
- int num = 0;
- string str = "";
- if (value != null)
- {
- switch (value.Length)
- {
- case 2:
- {
- chr = value[1];
- if (chr == 'c')
- {
- if (value == "dc")
- {
- num = 3;
- str = "Danos Corporais";
- break;
- }
- else
- {
- break;
- }
- }
- else if (chr != 'm')
- {
- break;
- }
- else if (value == "dm")
- {
- num = 2;
- str = "Danos Materiais";
- break;
- }
- else
- {
- break;
- }
- }
- case 3:
- {
- if (value == "app")
- {
- num = 53;
- str = "Acidentes Pessoais";
- break;
- }
- else
- {
- break;
- }
- }
- case 5:
- {
- chr = value[0];
- if (chr == 'c')
- {
- if (value == "casco")
- {
- num = 1;
- str = "Veiculo (Casco)";
- break;
- }
- else
- {
- break;
- }
- }
- else if (chr != 'm')
- {
- break;
- }
- else if (value == "morte")
- {
- num = 4;
- str = "Morte";
- break;
- }
- else
- {
- break;
- }
- }
- case 6:
- {
- if (value == "vidros")
- {
- num = 6;
- str = "Vidros";
- break;
- }
- else
- {
- break;
- }
- }
- case 9:
- {
- if (value == "invalidez")
- {
- num = 5;
- str = "Invalidez";
- break;
- }
- else
- {
- break;
- }
- }
- case 10:
- {
- if (value == "carroceria")
- {
- num = 25;
- str = "Carroceria";
- break;
- }
- else
- {
- break;
- }
- }
- case 11:
- {
- if (value == "ass 24horas")
- {
- num = 19;
- str = "Assistência (Guincho)";
- break;
- }
- else
- {
- break;
- }
- }
- case 12:
- {
- chr = value[0];
- if (chr == 'd')
- {
- if (value == "danos morais")
- {
- num = 17;
- str = "Danos Morais";
- break;
- }
- else
- {
- break;
- }
- }
- else if (chr != 'e')
- {
- break;
- }
- else if (value == "equipamentos")
- {
- num = 54;
- str = "Equipamentos";
- break;
- }
- else
- {
- break;
- }
- }
- case 13:
- {
- if (value == "carro reserva")
- {
- num = 7;
- str = "Carro Reserva";
- break;
- }
- else
- {
- break;
- }
- }
- }
- }
- decimal num1 = (string.IsNullOrWhiteSpace(row.Field<object>(string.Concat("pr ", value)).ToString()) ? decimal.Zero : Gestor.Model.Helper.ValidationHelper.ToDecimal(row.Field<object>(string.Concat("pr ", value)).ToString(), "pt-BR"));
- decimal num2 = (string.IsNullOrWhiteSpace(row.Field<object>(string.Concat("lmi ", value)).ToString()) ? decimal.Zero : Gestor.Model.Helper.ValidationHelper.ToDecimal(row.Field<object>(string.Concat("lmi ", value)).ToString(), "pt-BR"));
- decimal num3 = (string.IsNullOrWhiteSpace(row.Field<object>(string.Concat("fr ", value)).ToString()) ? decimal.Zero : Gestor.Model.Helper.ValidationHelper.ToDecimal(row.Field<object>(string.Concat("fr ", value)).ToString(), "pt-BR"));
- string str1 = (string.IsNullOrWhiteSpace(row.Field<object>(string.Concat("obs ", value)).ToString()) ? "" : row.Field<object>(string.Concat("obs ", value)).ToString());
- if (!(num2 > decimal.Zero) && !(num3 > decimal.Zero) && !(num1 > decimal.Zero))
- {
- continue;
- }
- Gestor.Model.Domain.Seguros.Cobertura cobertura = new Gestor.Model.Domain.Seguros.Cobertura();
- CoberturaPadrao coberturaPadrao = new CoberturaPadrao();
- coberturaPadrao.set_Id((long)num);
- cobertura.set_CoberturaPadrao(coberturaPadrao);
- cobertura.set_Observacao(string.Concat(str, " - ", str1));
- cobertura.set_Premio(num1);
- cobertura.set_Lmi(num2);
- cobertura.set_Franquia(num3);
- coberturas.Add(cobertura);
- }
- return coberturas;
- }
-
- public void Descarregar()
- {
- this.Cobertura = null;
- }
-
- public void Dispose()
- {
- Gestor.Application.Actions.Actions.UpdateItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.UpdateItem, new Action<Item>(this.Seleciona));
- Gestor.Application.Actions.Actions.SubstituirItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.SubstituirItem, new Action<Item>(this.Substituir));
- Gestor.Application.Actions.Actions.ManterItem = (Action<Item, ManutencaoItem>)Delegate.Remove(Gestor.Application.Actions.Actions.ManterItem, new Action<Item, ManutencaoItem>(this.Manter));
- }
-
- public async Task<bool> Excluir()
- {
- bool flag;
- if (this.SelectedItem == null || this.SelectedItem.get_Id() == 0)
- {
- flag = false;
- }
- else if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- bool flag1 = await this._servico.Delete(this.SelectedItem);
- base.Loading(false);
- if (flag1)
- {
- string str = string.Concat("EXCLUIU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " EXCLUÍDO COM SUCESSO"), true);
- flag = true;
- }
- else
- {
- await base.ShowMessage("NÃO POSSÍVEL EXCLUIR O ITEM", "OK", "", false);
- flag = false;
- }
- }
- else
- {
- flag = false;
- }
- return flag;
- }
-
- public async Task<List<KeyValuePair<string, string>>> ImportarXls()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- string fileName;
- List<KeyValuePair<string, string>> keyValuePairs1 = new List<KeyValuePair<string, string>>();
- using (OpenFileDialog openFileDialog = new OpenFileDialog())
- {
- openFileDialog.Filter = "Excel|*.xls;*.xlsx";
- openFileDialog.InitialDirectory = Environment.SpecialFolder.Desktop.ToString();
- if (DialogResult.OK == openFileDialog.ShowDialog())
- {
- fileName = openFileDialog.FileName;
- }
- else
- {
- keyValuePairs1.Add(new KeyValuePair<string, string>("EXCEL", "ERRO AO SELECIONAR DOCUMENTO"));
- keyValuePairs = keyValuePairs1;
- keyValuePairs1 = null;
- return keyValuePairs;
- }
- }
- try
- {
- List<Task<Item>> tasks1 = await Task.Run<List<Task<Item>>>(() => {
- string upper;
- Microsoft.Office.Interop.Excel.Application variable = (Microsoft.Office.Interop.Excel.Application)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
- Workbook variable1 = variable.Workbooks.Open(fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
- List<string> strs = new List<string>()
- {
- "placa",
- "fabricante",
- "modelo",
- "fipe",
- "chassi",
- "anofabricacao",
- "anomodelo",
- "cor",
- "categoria",
- "combustivel",
- "zerokm",
- "renavam",
- "capacidade",
- "portas",
- "bonus",
- "ceppernoite",
- "ci",
- "financiado",
- "correcao",
- "isencao",
- "pcd",
- "cepcirculacao",
- "tipocobertura",
- "porcentagemreferencia",
- "tabelareferencia",
- "valordeterminado",
- "observacao",
- "usoveiculos"
- };
- List<DataTable> dataTables = new List<DataTable>();
- foreach (object worksheet in variable1.Worksheets)
- {
- DataTable dataTable = new DataTable();
- Microsoft.Office.Interop.Excel.Range usedRange = ((Worksheet)worksheet).UsedRange;
- if (AutoViewModel.u003cu003eo__77.u003cu003ep__0 == null)
- {
- AutoViewModel.u003cu003eo__77.u003cu003ep__0 = CallSite<Func<CallSite, object, object[,]>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(object[,]), typeof(AutoViewModel)));
- }
- object[,] target = AutoViewModel.u003cu003eo__77.u003cu003ep__0.Target(AutoViewModel.u003cu003eo__77.u003cu003ep__0, usedRange.Value2);
- int num1 = 0;
- for (int i = 0; i <= usedRange.Columns.Count - 1; i++)
- {
- if (target[1, i + 1] != null)
- {
- DataColumn dataColumn = new DataColumn()
- {
- DataType = Type.GetType("System.String"),
- ColumnName = Funcoes.RemoverAcentos(target[1, i + 1].ToString().ToLower())
- };
- dataTable.Columns.Add(dataColumn);
- for (int j = 0; j <= usedRange.Rows.Count - 2; j++)
- {
- object obj = target[j + 2, i + 1];
- string str = obj as string;
- if (str != null)
- {
- upper = Funcoes.RemoverAcentos(str).ToUpper();
- }
- else if (!(obj is double))
- {
- upper = (!(obj is bool) ? "" : ((bool)obj ? "1" : "0"));
- }
- else
- {
- double num2 = (double)obj;
- upper = (!num2.ToString(CultureInfo.InvariantCulture).Contains("+") ? num2.ToString(CultureInfo.InvariantCulture) : ".");
- }
- if (i + num1 != 0)
- {
- dataTable.Rows[j][i + num1] = upper;
- }
- else
- {
- dataTable.Rows.Add(dataTable.NewRow());
- dataTable.Rows[j][i + num1] = upper;
- }
- }
- }
- else
- {
- num1--;
- }
- }
- dataTables.Add(dataTable);
- }
- variable.Quit();
- List<Task<Item>> tasks = new List<Task<Item>>();
- foreach (DataTable dataTable1 in dataTables)
- {
- for (int k = dataTable1.Rows.Count - 1; k >= 0; k--)
- {
- object[] itemArray = dataTable1.Rows[k].ItemArray;
- Func<object, bool> u003cu003e9_772 = AutoViewModel.u003cu003ec.u003cu003e9__77_2;
- if (u003cu003e9_772 == null)
- {
- u003cu003e9_772 = (object item) => string.IsNullOrEmpty((item != null ? item.ToString() : null));
- AutoViewModel.u003cu003ec.u003cu003e9__77_2 = u003cu003e9_772;
- }
- if (((IEnumerable<object>)itemArray).All<object>(u003cu003e9_772))
- {
- dataTable1.Rows.RemoveAt(k);
- }
- }
- tasks.AddRange(dataTable1.AsEnumerable().ToList<DataRow>().Select<DataRow, Task<Item>>(async (DataRow x) => {
- decimal num;
- bool? nullable;
- bool? nullable1;
- bool? nullable2;
- bool? nullable3;
- bool? nullable4;
- Item item2 = new Item();
- Item item1 = item2;
- Auto auto = new Auto();
- auto.set_Placa((!dataTable1.Columns.Contains("placa") || string.IsNullOrWhiteSpace(x.Field<object>("placa").ToString()) ? null : x.Field<object>("placa").ToString().ToUpper()));
- auto.set_AnoFabricacao((!dataTable1.Columns.Contains("anofabricacao") || string.IsNullOrWhiteSpace(x.Field<object>("anofabricacao").ToString()) ? null : (new Regex("[^0-9]")).Replace(x.Field<object>("anofabricacao").ToString(), "")));
- auto.set_AnoModelo((!dataTable1.Columns.Contains("anomodelo") || string.IsNullOrWhiteSpace(x.Field<object>("anomodelo").ToString()) ? null : (new Regex("[^0-9]")).Replace(x.Field<object>("anomodelo").ToString(), "")));
- auto.set_Bonus((!dataTable1.Columns.Contains("bonus") || string.IsNullOrWhiteSpace(x.Field<object>("bonus").ToString()) ? null : new int?(int.Parse((new Regex("[^0-9]")).Replace(x.Field<object>("bonus").ToString(), "")))));
- auto.set_Capacidade((!dataTable1.Columns.Contains("capacidade") || string.IsNullOrWhiteSpace(x.Field<object>("capacidade").ToString()) ? null : (new Regex("[^0-9]")).Replace(x.Field<object>("capacidade").ToString(), "")));
- auto.set_CepPernoite((!dataTable1.Columns.Contains("ceppernoite") || string.IsNullOrWhiteSpace(x.Field<object>("ceppernoite").ToString()) ? Gestor.Common.Validation.ValidationHelper.FormatPostCode((new Regex("[^0-9]")).Replace(x.Field<object>("cepcirculacao").ToString(), "")) : Gestor.Common.Validation.ValidationHelper.FormatPostCode((new Regex("[^0-9]")).Replace(x.Field<object>("ceppernoite").ToString(), ""))));
- auto.set_Chassi((!dataTable1.Columns.Contains("chassi") || string.IsNullOrWhiteSpace(x.Field<object>("chassi").ToString()) ? null : x.Field<object>("chassi").ToString()));
- auto.set_Ci((!dataTable1.Columns.Contains("ci") || string.IsNullOrWhiteSpace(x.Field<object>("ci").ToString()) ? null : (new Regex("[^0-9]")).Replace(x.Field<object>("ci").ToString(), "")));
- auto.set_Observacao((!dataTable1.Columns.Contains("observacao") || string.IsNullOrWhiteSpace(x.Field<object>("observacao").ToString()) ? null : x.Field<object>("observacao").ToString()));
- auto.set_Cor((!dataTable1.Columns.Contains("cor") || string.IsNullOrWhiteSpace(x.Field<object>("cor").ToString()) ? null : Funcoes.GetCor(x.Field<object>("cor").ToString().ToLower())));
- Auto auto1 = auto;
- if (!dataTable1.Columns.Contains("financiado") || string.IsNullOrWhiteSpace(x.Field<object>("financiado").ToString()))
- {
- nullable = null;
- nullable1 = nullable;
- }
- else
- {
- nullable1 = new bool?(x.Field<object>("financiado").ToString().ToLower() == "sim");
- }
- auto1.set_Financiado(nullable1);
- Auto auto2 = auto;
- if (!dataTable1.Columns.Contains("zerokm") || string.IsNullOrWhiteSpace(x.Field<object>("zerokm").ToString()))
- {
- nullable = null;
- nullable2 = nullable;
- }
- else
- {
- nullable2 = new bool?(x.Field<object>("zerokm").ToString().ToLower() == "sim");
- }
- auto2.set_ZeroKm(nullable2);
- auto.set_Combustivel((!dataTable1.Columns.Contains("combustivel") || string.IsNullOrWhiteSpace(x.Field<object>("combustivel").ToString()) ? null : Funcoes.GetCombustivel(x.Field<object>("combustivel").ToString().ToLower())));
- auto.set_Correcao((!dataTable1.Columns.Contains("correcao") || string.IsNullOrWhiteSpace(x.Field<object>("correcao").ToString()) ? null : Funcoes.GetCorrecao(x.Field<object>("correcao").ToString().ToLower())));
- auto.set_Fabricante((!dataTable1.Columns.Contains("fabricante") || string.IsNullOrWhiteSpace(x.Field<object>("fabricante").ToString()) ? null : await Funcoes.GetFabricante(x.Field<object>("fabricante").ToString().ToLower())));
- auto.set_Fipe((!dataTable1.Columns.Contains("fipe") || string.IsNullOrWhiteSpace(x.Field<object>("fipe").ToString()) ? null : Gestor.Model.Helper.ValidationHelper.FormataFipe((new Regex("[^0-9]")).Replace(x.Field<object>("fipe").ToString(), ""))));
- auto.set_Isencao((!dataTable1.Columns.Contains("isencao") || string.IsNullOrWhiteSpace(x.Field<object>("isencao").ToString()) ? null : Funcoes.GetIsencao(x.Field<object>("isencao").ToString().ToLower())));
- auto.set_Modelo((!dataTable1.Columns.Contains("modelo") || string.IsNullOrWhiteSpace(x.Field<object>("modelo").ToString()) ? null : x.Field<object>("modelo").ToString()));
- Auto auto3 = auto;
- if (!dataTable1.Columns.Contains("pcd") || string.IsNullOrWhiteSpace(x.Field<object>("pcd").ToString()))
- {
- nullable = null;
- nullable3 = nullable;
- }
- else
- {
- nullable3 = new bool?(x.Field<object>("pcd").ToString().ToLower() == "sim");
- }
- auto3.set_Pcd(nullable3);
- auto.set_PorcentagemReferencia((!dataTable1.Columns.Contains("porcentagemreferencia") || string.IsNullOrWhiteSpace(x.Field<object>("porcentagemreferencia").ToString()) ? decimal.Zero : (decimal.TryParse(x.Field<object>("porcentagemreferencia").ToString(), out num) ? decimal.Parse(x.Field<object>("porcentagemreferencia").ToString()) : decimal.Zero)));
- auto.set_Portas((!dataTable1.Columns.Contains("portas") || string.IsNullOrWhiteSpace(x.Field<object>("portas").ToString()) ? null : (new Regex("[^0-9]")).Replace(x.Field<object>("portas").ToString(), "")));
- auto.set_RegiaoCirculacao((!dataTable1.Columns.Contains("cepcirculacao") || string.IsNullOrWhiteSpace(x.Field<object>("cepcirculacao").ToString()) ? null : Gestor.Common.Validation.ValidationHelper.FormatPostCode((new Regex("[^0-9]")).Replace(x.Field<object>("cepcirculacao").ToString(), ""))));
- auto.set_Renavam((!dataTable1.Columns.Contains("renavam") || string.IsNullOrWhiteSpace(x.Field<object>("renavam").ToString()) ? null : (new Regex("[^0-9]")).Replace(x.Field<object>("renavam").ToString(), "")));
- auto.set_TabelaReferencia((!dataTable1.Columns.Contains("tabelareferencia") || string.IsNullOrWhiteSpace(x.Field<object>("tabelareferencia").ToString()) ? null : Funcoes.GetTabelaReferencia(x.Field<object>("tabelareferencia").ToString().ToLower())));
- auto.set_TipoCobertura((!dataTable1.Columns.Contains("tipocobertura") || string.IsNullOrWhiteSpace(x.Field<object>("tipocobertura").ToString()) ? null : Funcoes.GetTipoCobertura(x.Field<object>("tipocobertura").ToString().ToLower())));
- auto.set_ValorDeterminado((!dataTable1.Columns.Contains("valordeterminado") || string.IsNullOrWhiteSpace(x.Field<object>("valordeterminado").ToString()) || !Gestor.Common.Validation.ValidationHelper.ValidateValor(x.Field<object>("valordeterminado").ToString()) ? decimal.Zero : decimal.Parse(x.Field<object>("valordeterminado").ToString())));
- auto.set_Categoria((!dataTable1.Columns.Contains("categoria") || string.IsNullOrWhiteSpace(x.Field<object>("categoria").ToString()) ? null : Funcoes.GetCategoria(x.Field<object>("categoria").ToString().ToLower())));
- auto.set_UsoVeiculo((!dataTable1.Columns.Contains("usoveiculo") || string.IsNullOrWhiteSpace(x.Field<object>("usoveiculo").ToString()) ? null : Funcoes.GetUsoveiculo(x.Field<object>("usoveiculo").ToString().ToUpper())));
- Auto auto4 = auto;
- if (!dataTable1.Columns.Contains("KitGas") || string.IsNullOrWhiteSpace(x.Field<object>("KitGas").ToString()))
- {
- nullable = null;
- nullable4 = nullable;
- }
- else
- {
- nullable4 = new bool?(x.Field<object>("KitGas").ToString().ToLower() == "sim");
- }
- auto4.set_KitGas(nullable4);
- item1.set_Auto(auto);
- item2.set_Coberturas(this.Coberturas(x));
- item2.set_Documento(this.ItemSelecionado.get_Documento());
- item2.set_Substituicao(null);
- return item2;
- }).ToList<Task<Item>>());
- }
- return tasks;
- });
- if (tasks1.Count != 0)
- {
- Item[] itemArray1 = await Task.WhenAll<Item>(tasks1);
- keyValuePairs1 = await this.SalvarRange(itemArray1);
- }
- else
- {
- keyValuePairs1.Add(new KeyValuePair<string, string>("EXCEL", "NENHUMA COLUNA FOI ENCONTRADA"));
- keyValuePairs = keyValuePairs1;
- keyValuePairs1 = null;
- return keyValuePairs;
- }
- }
- catch (Exception exception)
- {
- keyValuePairs1.Add(new KeyValuePair<string, string>("EXCEL", "FALHA AO IMPORTAR O EXCEL,\nVERIFIQUE SE O ARQUIVO POSSUI ALGUM ERRO"));
- }
- keyValuePairs = keyValuePairs1;
- keyValuePairs1 = null;
- return keyValuePairs;
- }
-
- public async Task Incluir(bool substituir = false)
- {
- int? ordem;
- long? nullable;
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas;
- long? nullable1;
- long? nullable2;
- coberturas = (this.CoberturaViewModel.Coberturas == null ? this.CoberturaViewModel.CarregaCoberturaPadrao().ToList<Gestor.Model.Domain.Seguros.Cobertura>() : this.CoberturaViewModel.Coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>());
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas1 = coberturas;
- Item item = new Item();
- item.set_Documento(this.ItemSelecionado.get_Documento());
- Item item1 = item;
- ordem = (substituir ? base.ItemSubstituido.get_Ordem() : new int?(await base.QuantidadeDeItens(this.ItemSelecionado.get_Documento().get_Controle().get_Id())));
- item1.set_Ordem(ordem);
- Item item2 = item;
- Auto auto = new Auto();
- auto.set_Isencao(new Isencao?(0));
- auto.set_ZeroKm(new bool?(false));
- auto.set_Financiado(new bool?(false));
- auto.set_UsoVeiculo(new Gestor.Model.Common.UsoVeiculo?(0));
- auto.set_Categoria(new Gestor.Model.Common.Categoria?(3));
- item2.set_Auto(auto);
- Item item3 = item;
- if (substituir)
- {
- nullable1 = new long?(base.ItemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- nullable1 = nullable;
- }
- item3.set_Substituicao(nullable1);
- Item item4 = item;
- item1 = null;
- item = null;
- bool valueOrDefault = substituir;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA COPIAR OS DADOS DO ITEM?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.SelectedItem = item4;
- this.SelectedItem.get_Auto().set_Item(item4);
- this.UsoVeiculo = this.SelectedItem.get_Auto().get_UsoVeiculo();
- this.Categoria = this.SelectedItem.get_Auto().get_Categoria();
- }
- else
- {
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.get_Auto().set_Id((long)0);
- Item selectedItem = this.SelectedItem;
- Item itemSubstituido = base.ItemSubstituido;
- if (itemSubstituido != null)
- {
- nullable2 = new long?(itemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- nullable2 = nullable;
- }
- selectedItem.set_Substituicao(nullable2);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- }
- ordem = item4.get_Ordem();
- if (ordem.GetValueOrDefault() == 2 && !substituir)
- {
- if (!await base.ShowMessage("ESTA APÓLICE SERÁ UMA FROTA, DESEJA CONTINUAR?", "SIM", "NÃO", false))
- {
- coberturas1 = null;
- item4 = null;
- return;
- }
- }
- ordem = item4.get_Ordem();
- int num = 1;
- valueOrDefault = ordem.GetValueOrDefault() > num & ordem.HasValue;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA REPLICAR AS COBERTURAS DO ITEM SELECIONADO?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.CoberturaViewModel.CarregaPadrao();
- }
- else
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- if (substituir)
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- base.Alterar(true);
- coberturas1 = null;
- item4 = null;
- }
-
- public void Manter(Item item, ManutencaoItem manutencao)
- {
- if (manutencao.get_Tipo() == 1)
- {
- base.ItemSubstituido = item;
- }
- this.Manter(manutencao);
- base.Mantido = true;
- }
-
- public void Manter(ManutencaoItem manutencao)
- {
- long? nullable;
- object list;
- ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura> coberturas = this.CoberturaViewModel.Coberturas;
- if (coberturas != null)
- {
- list = coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>();
- }
- else
- {
- list = null;
- }
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.get_Auto().set_Id((long)0);
- Item selectedItem = this.SelectedItem;
- Item itemSubstituido = base.ItemSubstituido;
- if (itemSubstituido != null)
- {
- nullable = new long?(itemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- selectedItem.set_Substituicao(nullable);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- if (manutencao.get_Tipo() == null)
- {
- this.SelectedItem.set_Sinistrado(false);
- this.SelectedItem.set_Status("");
- this.SelectedItem.set_Sinistro(null);
- this.SelectedItem.set_Sinistros(null);
- }
- this.CoberturaViewModel.CarregaPadrao();
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- if (list != null)
- {
- ((List<Gestor.Model.Domain.Seguros.Cobertura>)list).ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- else
- {
- }
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- string str;
- string descricao;
- string str1;
- string str2;
- string str3;
- string str4;
- Auto auto = this.SelectedItem.get_Auto();
- str = (!string.IsNullOrEmpty(this.SelectedItem.get_Auto().get_Placa()) ? Gestor.Model.Helper.ValidationHelper.FormataPlaca(this.SelectedItem.get_Auto().get_Placa()) : string.Empty);
- auto.set_Placa(str);
- Item selectedItem = this.SelectedItem;
- string[] modelo = new string[7];
- Fabricante fabricante = this.SelectedItem.get_Auto().get_Fabricante();
- if (fabricante != null)
- {
- descricao = fabricante.get_Descricao();
- }
- else
- {
- descricao = null;
- }
- modelo[0] = descricao;
- modelo[1] = " ";
- modelo[2] = this.SelectedItem.get_Auto().get_Modelo();
- modelo[3] = " / ";
- modelo[4] = this.SelectedItem.get_Auto().get_Chassi();
- modelo[5] = " / ";
- modelo[6] = this.SelectedItem.get_Auto().get_Placa();
- selectedItem.set_Descricao(string.Concat(modelo));
- Item item = this.SelectedItem;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- bool flag = configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 18);
- List<ConfiguracaoSistema> configuracaoSistemas = Recursos.Configuracoes;
- List<KeyValuePair<string, string>> keyValuePairs1 = item.Validate(flag, configuracaoSistemas.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 27));
- List<KeyValuePair<string, string>> keyValuePairs2 = keyValuePairs1;
- keyValuePairs2.AddRange(await this.Validate());
- keyValuePairs2 = null;
- if (keyValuePairs1.Count <= 0)
- {
- Item selectedItem1 = this.SelectedItem;
- selectedItem1.set_Coberturas(await this.CoberturaViewModel.LimpaCoberturas());
- selectedItem1 = null;
- str1 = (this.SelectedItem.get_Id() == 0 ? "INCLUIU" : "ALTEROU");
- str4 = str1;
- if (this.SelectedItem.get_Documento().get_Ordem() <= 0)
- {
- str2 = "";
- }
- else if (base.Mantido)
- {
- str2 = string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem());
- }
- else
- {
- str2 = (base.ItemSubstituido != null ? string.Format("SUBSTITUIÇÃO DO ITEM {0} NO ENDOSSO ORDEM {1}", base.ItemSubstituido.get_Ordem(), this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM INCLUÍDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- }
- string str5 = str2;
- if (this.SelectedItem.get_Id() == 0)
- {
- this.SelectedItem.set_Status(str5);
- }
- this.SelectedItem = await this._itemServico.Save(this.SelectedItem);
- if (this._itemServico.Sucesso)
- {
- if (base.ItemSubstituido != null)
- {
- str3 = (base.Mantido ? string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM SUBSTITUIDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- string str6 = str3;
- await this._itemServico.Substituir(base.ItemSubstituido, this.SelectedItem.get_Id(), str6);
- }
- base.Mantido = false;
- await this.SelecionaItem(this.SelectedItem, false);
- this.ItemSelecionado = this.SelectedItem;
- if (this.Invoke)
- {
- ConsultaViewModel.ItemSelecionado = this.SelectedItem;
- }
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " SALVO COM SUCESSO"), true);
- string str7 = string.Concat(str4, " ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str7, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- keyValuePairs1 = null;
- str4 = null;
- return keyValuePairs;
- }
-
- public async Task<List<KeyValuePair<string, string>>> SalvarRange(IEnumerable<Item> list)
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- string str;
- string descricao;
- string str1;
- string str2;
- Item item = null;
- Item item1 = new Item();
- List<KeyValuePair<string, string>> keyValuePairs1 = new List<KeyValuePair<string, string>>();
- int num = await base.QuantidadeDeItens(list.First<Item>().get_Documento().get_Controle().get_Id());
- foreach (Item item in list)
- {
- if (!item.get_Auto().get_Isencao().HasValue)
- {
- item.get_Auto().set_Isencao(new Isencao?(0));
- }
- if (!item.get_Auto().get_ZeroKm().HasValue)
- {
- item.get_Auto().set_ZeroKm(new bool?(false));
- }
- if (!item.get_Auto().get_Financiado().HasValue)
- {
- item.get_Auto().set_Financiado(new bool?(false));
- }
- if (!item.get_Auto().get_UsoVeiculo().HasValue)
- {
- item.get_Auto().set_UsoVeiculo(new Gestor.Model.Common.UsoVeiculo?(0));
- }
- item.set_Ordem(new int?(num));
- num++;
- item.get_Auto().set_Item(item);
- Auto auto = item.get_Auto();
- str = (!string.IsNullOrEmpty(item.get_Auto().get_Placa()) ? Gestor.Model.Helper.ValidationHelper.FormataPlaca(item.get_Auto().get_Placa()) : string.Empty);
- auto.set_Placa(str);
- Item item2 = item;
- string[] modelo = new string[7];
- Fabricante fabricante = item.get_Auto().get_Fabricante();
- if (fabricante != null)
- {
- descricao = fabricante.get_Descricao();
- }
- else
- {
- descricao = null;
- }
- modelo[0] = descricao;
- modelo[1] = " ";
- modelo[2] = item.get_Auto().get_Modelo();
- modelo[3] = " / ";
- modelo[4] = item.get_Auto().get_Chassi();
- modelo[5] = " / ";
- modelo[6] = item.get_Auto().get_Placa();
- item2.set_Descricao(string.Concat(modelo));
- Item item3 = item;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- List<KeyValuePair<string, string>> keyValuePairs2 = item3.Validate(configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 18), false);
- List<KeyValuePair<string, string>> keyValuePairs3 = keyValuePairs2;
- keyValuePairs3.AddRange(await this.Validate(item));
- keyValuePairs3 = null;
- Item item4 = item;
- str1 = (item.get_Documento().get_Ordem() > 0 ? string.Format("ITEM INCLUÍDO NO ENDOSSO ORDEM {0}", item.get_Documento().get_Ordem()) : "");
- item4.set_Status(str1);
- if (keyValuePairs2.Count <= 0)
- {
- continue;
- }
- keyValuePairs1.Add(new KeyValuePair<string, string>("", item.get_Descricao()));
- keyValuePairs1.AddRange(keyValuePairs2);
- keyValuePairs2 = null;
- }
- if (keyValuePairs1.Count <= 0)
- {
- foreach (Item item5 in list)
- {
- str2 = (item5.get_Id() == 0 ? "INCLUIU" : "ALTEROU");
- string str3 = str2;
- item1 = await this._itemServico.Save(item5);
- string str4 = string.Concat(str3, " ITEM DE DESCRIÇÃO \"", item5.get_Descricao(), "\"");
- long id = item5.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { item5.get_Id(), item5.get_Documento().get_Id(), item5.get_Documento().get_Controle().get_Ramo().get_Nome(), item5.get_Documento().get_Controle().get_Cliente().get_Nome(), item5.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str4, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- str3 = null;
- }
- this.SelectedItem = item1;
- await this.SelecionaItem(this.SelectedItem, false);
- this.ItemSelecionado = this.SelectedItem;
- if (this.Invoke)
- {
- ConsultaViewModel.ItemSelecionado = this.SelectedItem;
- }
- base.ToggleSnackBar("ITENS SALVOS COM SUCESSO", true);
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- item1 = null;
- keyValuePairs1 = null;
- return keyValuePairs;
- }
-
- public async void Seleciona(Item item)
- {
- base.Loading(true);
- await base.PermissaoTela(3);
- await this.SelecionaItem(item, true);
- base.Loading(false);
- }
-
- public async Task SelecionaItem(Item item, bool registrar = true)
- {
- if (item == null || this.LastAccessId != item.get_Id() || this.LastAccessTela != 9)
- {
- base.Mantido = false;
- this.Fabricantes = Recursos.Fabricantes;
- List<long> nums = new List<long>()
- {
- (long)5,
- (long)37
- };
- if (nums.Contains(this.Ramo.get_Id()))
- {
- this.CoberturaViewModel.Ramo = this.Ramo;
- if (this.CoberturaViewModel.CoberturasPadrao == null)
- {
- await this.CoberturaViewModel.SelectionaCoberturas();
- }
- if (item == null || item.get_Id() == 0)
- {
- this.SelectedItem = null;
- this.CoberturaViewModel.Coberturas = null;
- base.IsVisible = Visibility.Visible;
- }
- else
- {
- base.Loading(true);
- item = await this._itemServico.BuscarItemPorIdAsync(item.get_Id());
- Item item1 = item;
- Auto auto = await this._itemServico.BuscaAuto(item.get_Id());
- item1.set_Auto(auto);
- item1 = null;
- this.SelectedItem = item;
- this.SelectedItem.Initialize();
- this.Initialized = true;
- this.WorkOnSelectedAuto(this.SelectedItem.get_Auto());
- this.CoberturaViewModel.Item = item;
- await this.CoberturaViewModel.CancelarAlteracao();
- if (registrar)
- {
- string str = string.Concat("ACESSOU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- }
- this.LastAccessId = this.SelectedItem.get_Id();
- this.LastAccessTela = 3;
- this.CodigoItem = this.SelectedItem.get_Id().ToString();
- this.UsoVeiculo = this.SelectedItem.get_Auto().get_UsoVeiculo();
- this.Categoria = this.SelectedItem.get_Auto().get_Categoria();
- base.Loading(false);
- }
- }
- }
- }
-
- public async void Substituir(Item item)
- {
- base.ItemSubstituido = item;
- await this.Incluir(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Validate()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- List<KeyValuePair<string, string>> keyValuePairs1 = new List<KeyValuePair<string, string>>();
- if (!string.IsNullOrEmpty(this.SelectedItem.get_Auto().get_Chassi()))
- {
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (!configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 26))
- {
- Documento documento = await (new AutoServico()).BuscarAuto(this.SelectedItem.get_Auto().get_Chassi(), this.SelectedItem.get_Auto().get_Id(), this.SelectedItem.get_Documento().get_Vigencia1(), this.SelectedItem.get_Documento().get_Vigencia2(), this.SelectedItem.get_Documento().get_Controle().get_Seguradora().get_Id());
- if (documento == null)
- {
- keyValuePairs = keyValuePairs1;
- }
- else if (this.AllowAlterarExcluir || this.SelectedItem.get_Documento().get_Controle().get_Id() != documento.get_Controle().get_Id())
- {
- List<KeyValuePair<string, string>> keyValuePairs2 = keyValuePairs1;
- string[] apolice = new string[] { "CHASSI JÁ CADASTRADO NA APÓLICE ", documento.get_Apolice(), " DO CLIENTE ", documento.get_Controle().get_Cliente().get_Nome(), "." };
- keyValuePairs2.Add(new KeyValuePair<string, string>("Chassi", string.Concat(apolice)));
- keyValuePairs = keyValuePairs1;
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- keyValuePairs1 = null;
- return keyValuePairs;
- }
-
- public async Task<List<KeyValuePair<string, string>>> Validate(Item item)
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- List<KeyValuePair<string, string>> keyValuePairs1 = new List<KeyValuePair<string, string>>();
- if (!string.IsNullOrEmpty(item.get_Auto().get_Chassi()))
- {
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (!configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 26))
- {
- Documento documento = await (new AutoServico()).BuscarAuto(item.get_Auto().get_Chassi(), item.get_Auto().get_Id(), item.get_Documento().get_Vigencia1(), item.get_Documento().get_Vigencia2(), item.get_Documento().get_Controle().get_Seguradora().get_Id());
- if (documento == null)
- {
- keyValuePairs = keyValuePairs1;
- }
- else if (this.AllowAlterarExcluir || item.get_Documento().get_Controle().get_Id() != documento.get_Controle().get_Id())
- {
- List<KeyValuePair<string, string>> keyValuePairs2 = keyValuePairs1;
- string[] apolice = new string[] { "CHASSI JÁ CADASTRADO NA APÓLICE ", documento.get_Apolice(), " DO CLIENTE ", documento.get_Controle().get_Cliente().get_Nome(), "." };
- keyValuePairs2.Add(new KeyValuePair<string, string>("Chassi", string.Concat(apolice)));
- keyValuePairs = keyValuePairs1;
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- keyValuePairs1 = null;
- return keyValuePairs;
- }
-
- private void WorkOnSelectedAuto(Auto value)
- {
- if (value == null || value.get_Id() == 0)
- {
- return;
- }
- this.SelectedFabricante = this.Fabricantes.FirstOrDefault<Fabricante>((Fabricante x) => {
- int? nullable;
- int id = x.get_Id();
- Fabricante fabricante = value.get_Fabricante();
- if (fabricante != null)
- {
- nullable = new int?(fabricante.get_Id());
- }
- else
- {
- nullable = null;
- }
- int? nullable1 = nullable;
- return id == nullable1.GetValueOrDefault() & nullable1.HasValue;
- });
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/Itens/BuscarModeloViewModel.cs b/Gestor.Application/ViewModels/Seguros/Itens/BuscarModeloViewModel.cs deleted file mode 100644 index b97c9ea..0000000 --- a/Gestor.Application/ViewModels/Seguros/Itens/BuscarModeloViewModel.cs +++ /dev/null @@ -1,95 +0,0 @@ -using CsQuery.ExtensionMethods.Internal;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Common.Validation;
-using Gestor.Model.Domain.Common;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-
-namespace Gestor.Application.ViewModels.Seguros.Itens
-{
- public class BuscarModeloViewModel : BaseSegurosViewModel
- {
- private Auto _selectedBuscaModelo = new Auto();
-
- private ObservableCollection<Fipe> _modelosAutos = new ObservableCollection<Fipe>();
-
- private Fipe _resultado = new Fipe();
-
- public ObservableCollection<Fipe> ModelosAutos
- {
- get
- {
- return this._modelosAutos;
- }
- set
- {
- this._modelosAutos = value;
- base.OnPropertyChanged("ModelosAutos");
- }
- }
-
- public Fipe Resultado
- {
- get
- {
- return this._resultado;
- }
- set
- {
- this._resultado = value;
- base.OnPropertyChanged("Resultado");
- }
- }
-
- public Auto SelectedBuscaModelo
- {
- get
- {
- return this._selectedBuscaModelo;
- }
- set
- {
- this._selectedBuscaModelo = value;
- base.OnPropertyChanged("SelectedBuscaModelo");
- }
- }
-
- public BuscarModeloViewModel(string modelo, string ano)
- {
- Auto auto = new Auto();
- auto.set_AnoModelo(ano);
- auto.set_Modelo(modelo);
- this.SelectedBuscaModelo = auto;
- }
-
- public async void Pesquisar()
- {
- string modelo = this.SelectedBuscaModelo.get_Modelo();
- int num = ValidationHelper.ToInt(this.SelectedBuscaModelo.get_AnoModelo());
- List<Fipe> list = await (new ItemServico()).BuscarPorModelo(modelo);
- if ((this.SelectedBuscaModelo.get_AnoModelo() != null || ExtensionMethods.IsNullOrEmpty<Fipe>(list)) && this.SelectedBuscaModelo.get_Id() != 0)
- {
- list = list.Where<Fipe>((Fipe x) => {
- if (x.get_AnoMinimo() > num)
- {
- return false;
- }
- return x.get_AnoMaximo() >= num;
- }).ToList<Fipe>();
- this.ModelosAutos = new ObservableCollection<Fipe>(list);
- }
- else
- {
- this.ModelosAutos = new ObservableCollection<Fipe>(list);
- }
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/Itens/ConsorcioViewModel.cs b/Gestor.Application/ViewModels/Seguros/Itens/ConsorcioViewModel.cs deleted file mode 100644 index 0470058..0000000 --- a/Gestor.Application/ViewModels/Seguros/Itens/ConsorcioViewModel.cs +++ /dev/null @@ -1,520 +0,0 @@ -using Gestor.Application.Actions;
-using Gestor.Application.Componentes;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Application.ViewModels.Seguros;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Gestor.Application.ViewModels.Seguros.Itens
-{
- public class ConsorcioViewModel : ItemViewModel, IDisposable
- {
- private readonly ItemServico _itemServico;
-
- private readonly ConsorcioServico _servico;
-
- private bool _visibilityTitulares;
-
- private bool _allowAlterarExcluir = true;
-
- private object _cobertura;
-
- private object _sinistro;
-
- private string _codigoItem;
-
- private Item _selectedItem = new Item();
-
- public bool AllowAlterarExcluir
- {
- get
- {
- return this._allowAlterarExcluir;
- }
- set
- {
- this._allowAlterarExcluir = value;
- base.OnPropertyChanged("AllowAlterarExcluir");
- }
- }
-
- public object Cobertura
- {
- get
- {
- return this._cobertura;
- }
- set
- {
- this._cobertura = value;
- base.OnPropertyChanged("Cobertura");
- }
- }
-
- public string CodigoItem
- {
- get
- {
- return this._codigoItem;
- }
- set
- {
- this._codigoItem = value;
- base.OnPropertyChanged("CodigoItem");
- }
- }
-
- public bool Invoke
- {
- get;
- set;
- }
-
- private Item ItemSelecionado
- {
- get;
- set;
- }
-
- private Gestor.Model.Domain.Seguros.Ramo Ramo
- {
- get;
- }
-
- public Item SelectedItem
- {
- get
- {
- return this._selectedItem;
- }
- set
- {
- long? nullable;
- this._selectedItem = value;
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedItem");
- }
- }
-
- public object Sinistro
- {
- get
- {
- return this._sinistro;
- }
- set
- {
- this._sinistro = value;
- base.OnPropertyChanged("Sinistro");
- }
- }
-
- public bool VisibilityTitulares
- {
- get
- {
- return this._visibilityTitulares;
- }
- set
- {
- this._visibilityTitulares = value;
- base.OnPropertyChanged("VisibilityTitulares");
- }
- }
-
- public ConsorcioViewModel(bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Gestor.Model.Domain.Seguros.Ramo ramo = null, bool endossoRenovacao = false)
- {
- this.Invoke = itemSelecionado == null;
- this.ItemSelecionado = itemSelecionado ?? ConsultaViewModel.ItemSelecionado;
- this.Ramo = ramo ?? ConsultaViewModel.DocumentoSelecionado.get_Controle().get_Ramo();
- if (this.Invoke)
- {
- this.ItemSelecionado = this.ItemSelecionado ?? new Item();
- this.ItemSelecionado.set_Documento(ConsultaViewModel.DocumentoSelecionado);
- }
- this._itemServico = new ItemServico();
- this._servico = new ConsorcioServico();
- this.Seleciona(this.ItemSelecionado);
- if (substituir)
- {
- this.Substituir(this.ItemSelecionado);
- }
- if (manutencao != null)
- {
- this.Manter(this.ItemSelecionado, manutencao);
- }
- this.AllowAlterarExcluir = !endossoRenovacao;
- this.CarregaCobertura();
- this.VisibilityTitulares = this.Ramo.get_Id() == (long)31;
- }
-
- public async void CancelarAlteracao()
- {
- base.Loading(true);
- await this.SelecionaItem(this.ItemSelecionado, false);
- await this.CoberturaViewModel.CancelarAlteracao();
- base.Alterar(false);
- base.Loading(false);
- }
-
- public void CarregaCobertura()
- {
- this.CoberturaViewModel.Item = this.ItemSelecionado;
- this.CoberturaViewModel.Ramo = this.Ramo;
- this.Cobertura = new CoberturaView(this.CoberturaViewModel);
- }
-
- public void Descarregar()
- {
- this.Cobertura = null;
- this.Sinistro = null;
- }
-
- public void Dispose()
- {
- Gestor.Application.Actions.Actions.UpdateItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.UpdateItem, new Action<Item>(this.Seleciona));
- Gestor.Application.Actions.Actions.SubstituirItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.SubstituirItem, new Action<Item>(this.Substituir));
- Gestor.Application.Actions.Actions.ManterItem = (Action<Item, ManutencaoItem>)Delegate.Remove(Gestor.Application.Actions.Actions.ManterItem, new Action<Item, ManutencaoItem>(this.Manter));
- }
-
- public async Task<bool> Excluir()
- {
- bool flag;
- if (this.SelectedItem == null || this.SelectedItem.get_Id() == 0)
- {
- flag = false;
- }
- else if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- bool flag1 = await this._servico.Delete(this.SelectedItem);
- base.Loading(false);
- if (flag1)
- {
- string str = string.Concat("EXCLUIU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " EXCLUÍDO COM SUCESSO"), true);
- flag = true;
- }
- else
- {
- await base.ShowMessage("NÃO POSSÍVEL EXCLUIR O ITEM", "OK", "", false);
- flag = false;
- }
- }
- else
- {
- flag = false;
- }
- return flag;
- }
-
- public async Task Incluir(bool substituir = false)
- {
- int? ordem;
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas;
- long? nullable;
- coberturas = (this.CoberturaViewModel.Coberturas == null ? this.CoberturaViewModel.CarregaCoberturaPadrao().ToList<Gestor.Model.Domain.Seguros.Cobertura>() : this.CoberturaViewModel.Coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>());
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas1 = coberturas;
- Item item = new Item();
- item.set_Documento(this.ItemSelecionado.get_Documento());
- Item item1 = item;
- ordem = (substituir ? base.ItemSubstituido.get_Ordem() : new int?(await base.QuantidadeDeItens(this.ItemSelecionado.get_Documento().get_Controle().get_Id())));
- item1.set_Ordem(ordem);
- item.set_Consorcio(new Consorcio());
- Item item2 = item;
- if (substituir)
- {
- nullable = new long?(base.ItemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- item2.set_Substituicao(nullable);
- Item item3 = item;
- item1 = null;
- item = null;
- base.Titulares = new ObservableCollection<TitularesVida>();
- ordem = item3.get_Ordem();
- if (ordem.GetValueOrDefault() == 2)
- {
- if (!await base.ShowMessage("ESTA APÓLICE SERÁ UMA FROTA, DESEJA CONTINUAR?", "SIM", "NÃO", false))
- {
- coberturas1 = null;
- item3 = null;
- return;
- }
- }
- bool valueOrDefault = substituir;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA COPIAR OS DADOS DO ITEM?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.SelectedItem = item3;
- this.SelectedItem.get_Consorcio().set_Item(item3);
- }
- else
- {
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- }
- ordem = item3.get_Ordem();
- int num = 1;
- valueOrDefault = ordem.GetValueOrDefault() > num & ordem.HasValue;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA REPLICAR AS COBERTURAS DO ITEM SELECIONADO?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.CoberturaViewModel.CarregaPadrao();
- }
- else
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- if (substituir)
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- base.Alterar(true);
- coberturas1 = null;
- item3 = null;
- }
-
- public void Manter(Item item, ManutencaoItem manutencao)
- {
- if (manutencao.get_Tipo() == 1)
- {
- base.ItemSubstituido = item;
- }
- this.Manter(manutencao);
- base.Mantido = true;
- }
-
- public void Manter(ManutencaoItem manutencao)
- {
- long? nullable;
- object list;
- ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura> coberturas = this.CoberturaViewModel.Coberturas;
- if (coberturas != null)
- {
- list = coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>();
- }
- else
- {
- list = null;
- }
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.get_Consorcio().set_Id((long)0);
- Item selectedItem = this.SelectedItem;
- Item itemSubstituido = base.ItemSubstituido;
- if (itemSubstituido != null)
- {
- nullable = new long?(itemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- selectedItem.set_Substituicao(nullable);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- if (manutencao.get_Tipo() == null)
- {
- this.SelectedItem.set_Sinistrado(false);
- this.SelectedItem.set_Status("");
- this.SelectedItem.set_Sinistro(null);
- this.SelectedItem.set_Sinistros(null);
- }
- this.CoberturaViewModel.CarregaPadrao();
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- if (list != null)
- {
- ((List<Gestor.Model.Domain.Seguros.Cobertura>)list).ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- else
- {
- }
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- string str;
- string str1;
- string str2;
- string str3;
- this.SelectedItem.set_Descricao(this.SelectedItem.get_Consorcio().get_BensConsorcio());
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedItem.Validate();
- if (keyValuePairs1.Count <= 0)
- {
- Item selectedItem = this.SelectedItem;
- selectedItem.set_Coberturas(await this.CoberturaViewModel.LimpaCoberturas());
- selectedItem = null;
- if (this.SelectedItem.get_Documento().get_Ordem() <= 0)
- {
- str = "";
- }
- else if (base.Mantido)
- {
- str = string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem());
- }
- else
- {
- str = (base.ItemSubstituido != null ? string.Format("SUBSTITUIÇÃO DO ITEM {0} NO ENDOSSO ORDEM {1}", base.ItemSubstituido.get_Ordem(), this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM INCLUÍDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- }
- string str4 = str;
- if (this.SelectedItem.get_Id() == 0)
- {
- this.SelectedItem.set_Status(str4);
- }
- str1 = (this.SelectedItem.get_Id() == 0 ? "INCLUIU" : "ALTEROU");
- str3 = str1;
- this.SelectedItem = await this._itemServico.Save(this.SelectedItem);
- if (this._itemServico.Sucesso)
- {
- if (base.ItemSubstituido != null)
- {
- str2 = (base.Mantido ? string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM SUBSTITUIDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- string str5 = str2;
- await this._itemServico.Substituir(base.ItemSubstituido, this.SelectedItem.get_Id(), str5);
- }
- base.Mantido = false;
- await this.SelecionaItem(this.SelectedItem, false);
- this.ItemSelecionado = this.SelectedItem;
- if (this.Invoke)
- {
- ConsultaViewModel.ItemSelecionado = this.SelectedItem;
- }
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " SALVO COM SUCESSO"), true);
- string str6 = string.Concat(str3, " ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str6, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- str3 = null;
- return keyValuePairs;
- }
-
- private async void Seleciona(Item item)
- {
- base.Loading(true);
- await base.PermissaoTela(3);
- await this.SelecionaItem(item, true);
- base.Loading(false);
- }
-
- public async Task SelecionaItem(Item item, bool registrar = true)
- {
- if (item == null || this.LastAccessId != item.get_Id() || this.LastAccessTela != 9)
- {
- base.Mantido = false;
- this.CoberturaViewModel.Ramo = this.Ramo;
- if (this.CoberturaViewModel.CoberturasPadrao == null)
- {
- await this.CoberturaViewModel.SelectionaCoberturas();
- }
- if (item == null || item.get_Id() == 0)
- {
- this.SelectedItem = null;
- this.CoberturaViewModel.Coberturas = null;
- base.IsVisible = Visibility.Visible;
- base.Titulares = new ObservableCollection<TitularesVida>();
- }
- else
- {
- base.Loading(true);
- item = await this._itemServico.BuscarItemPorIdAsync(item.get_Id());
- Item item1 = item;
- Consorcio consorcio = await this._itemServico.BuscaConsorcio(item.get_Id());
- Item item2 = item1;
- Consorcio consorcio1 = consorcio;
- if (consorcio1 == null)
- {
- consorcio1 = new Consorcio();
- consorcio1.set_Item(item);
- }
- item2.set_Consorcio(consorcio1);
- item1 = null;
- if (this.VisibilityTitulares)
- {
- await base.CarregarTitulares(item.get_Id());
- }
- this.SelectedItem = item;
- this.SelectedItem.Initialize();
- this.Initialized = true;
- this.CoberturaViewModel.Item = item;
- await this.CoberturaViewModel.CancelarAlteracao();
- if (registrar)
- {
- string str = string.Concat("ACESSOU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- }
- this.LastAccessId = this.SelectedItem.get_Id();
- this.LastAccessTela = 3;
- this.CodigoItem = this.SelectedItem.get_Id().ToString();
- base.Loading(false);
- }
- }
- }
-
- public async void Substituir(Item item)
- {
- base.ItemSubstituido = item;
- await this.Incluir(true);
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/Itens/GranizoViewModel.cs b/Gestor.Application/ViewModels/Seguros/Itens/GranizoViewModel.cs deleted file mode 100644 index b40ea83..0000000 --- a/Gestor.Application/ViewModels/Seguros/Itens/GranizoViewModel.cs +++ /dev/null @@ -1,500 +0,0 @@ -using Gestor.Application.Actions;
-using Gestor.Application.Componentes;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Application.ViewModels.Seguros;
-using Gestor.Common.Validation;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Gestor.Application.ViewModels.Seguros.Itens
-{
- public class GranizoViewModel : ItemViewModel, IDisposable
- {
- private readonly ItemServico _itemServico;
-
- private readonly GranizoServico _servico;
-
- private bool _allowAlterarExcluir = true;
-
- private object _cobertura;
-
- private string _codigoItem;
-
- private Item _selectedItem = new Item();
-
- private Visibility _visibilityMaisInformacoes = Visibility.Collapsed;
-
- public bool AllowAlterarExcluir
- {
- get
- {
- return this._allowAlterarExcluir;
- }
- set
- {
- this._allowAlterarExcluir = value;
- base.OnPropertyChanged("AllowAlterarExcluir");
- }
- }
-
- public object Cobertura
- {
- get
- {
- return this._cobertura;
- }
- set
- {
- this._cobertura = value;
- base.OnPropertyChanged("Cobertura");
- }
- }
-
- public string CodigoItem
- {
- get
- {
- return this._codigoItem;
- }
- set
- {
- this._codigoItem = value;
- base.OnPropertyChanged("CodigoItem");
- }
- }
-
- public bool Invoke
- {
- get;
- set;
- }
-
- private Item ItemSelecionado
- {
- get;
- }
-
- private Gestor.Model.Domain.Seguros.Ramo Ramo
- {
- get;
- }
-
- public Item SelectedItem
- {
- get
- {
- return this._selectedItem;
- }
- set
- {
- long? nullable;
- this._selectedItem = value;
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedItem");
- }
- }
-
- public Visibility VisibilityMaisInformacoes
- {
- get
- {
- return this._visibilityMaisInformacoes;
- }
- set
- {
- this._visibilityMaisInformacoes = value;
- base.OnPropertyChanged("VisibilityMaisInformacoes");
- }
- }
-
- public GranizoViewModel(bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Gestor.Model.Domain.Seguros.Ramo ramo = null, bool endossoRenovacao = false)
- {
- this.Invoke = itemSelecionado == null;
- this.ItemSelecionado = itemSelecionado ?? ConsultaViewModel.ItemSelecionado;
- this.Ramo = ramo ?? ConsultaViewModel.DocumentoSelecionado.get_Controle().get_Ramo();
- if (this.Invoke)
- {
- this.ItemSelecionado = this.ItemSelecionado ?? new Item();
- this.ItemSelecionado.set_Documento(ConsultaViewModel.DocumentoSelecionado);
- }
- this._itemServico = new ItemServico();
- this._servico = new GranizoServico();
- this.Seleciona(this.ItemSelecionado);
- if (substituir)
- {
- this.Substituir(this.ItemSelecionado);
- }
- if (manutencao != null)
- {
- this.Manter(this.ItemSelecionado, manutencao);
- }
- this.AllowAlterarExcluir = !endossoRenovacao;
- this.CarregaCobertura();
- }
-
- public async void CancelarAlteracao()
- {
- base.Loading(true);
- await this.SelecionaItem(this.ItemSelecionado, false);
- await this.CoberturaViewModel.CancelarAlteracao();
- base.Alterar(false);
- base.Loading(false);
- }
-
- public void CarregaCobertura()
- {
- this.CoberturaViewModel.Item = this.ItemSelecionado;
- this.CoberturaViewModel.Ramo = this.Ramo;
- this.Cobertura = new CoberturaView(this.CoberturaViewModel);
- }
-
- public void Descarregar()
- {
- this.Cobertura = null;
- }
-
- public void Dispose()
- {
- Gestor.Application.Actions.Actions.UpdateItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.UpdateItem, new Action<Item>(this.Seleciona));
- Gestor.Application.Actions.Actions.SubstituirItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.SubstituirItem, new Action<Item>(this.Substituir));
- Gestor.Application.Actions.Actions.ManterItem = (Action<Item, ManutencaoItem>)Delegate.Remove(Gestor.Application.Actions.Actions.ManterItem, new Action<Item, ManutencaoItem>(this.Manter));
- }
-
- public async Task<bool> Excluir()
- {
- bool flag;
- if (this.SelectedItem == null || this.SelectedItem.get_Id() == 0)
- {
- flag = false;
- }
- else if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- bool flag1 = await this._servico.Delete(this.SelectedItem);
- base.Loading(false);
- if (flag1)
- {
- string str = string.Concat("EXCLUIU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " EXCLUÍDO COM SUCESSO"), true);
- flag = true;
- }
- else
- {
- await base.ShowMessage("NÃO POSSÍVEL EXCLUIR O ITEM", "OK", "", false);
- flag = false;
- }
- }
- else
- {
- flag = false;
- }
- return flag;
- }
-
- public async Task IncluirItem(bool substituir = false)
- {
- int? ordem;
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas;
- long? nullable;
- coberturas = (this.CoberturaViewModel.Coberturas == null ? this.CoberturaViewModel.CarregaCoberturaPadrao().ToList<Gestor.Model.Domain.Seguros.Cobertura>() : this.CoberturaViewModel.Coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>());
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas1 = coberturas;
- Item item = new Item();
- item.set_Documento(this.ItemSelecionado.get_Documento());
- Item item1 = item;
- ordem = (substituir ? base.ItemSubstituido.get_Ordem() : new int?(await base.QuantidadeDeItens(this.ItemSelecionado.get_Documento().get_Controle().get_Id())));
- item1.set_Ordem(ordem);
- Item item2 = item;
- Granizo granizo = new Granizo();
- granizo.set_Item(this.SelectedItem);
- item2.set_Granizo(granizo);
- Item item3 = item;
- if (substituir)
- {
- nullable = new long?(base.ItemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- item3.set_Substituicao(nullable);
- Item item4 = item;
- item1 = null;
- item = null;
- ordem = item4.get_Ordem();
- if (ordem.GetValueOrDefault() == 2)
- {
- if (!await base.ShowMessage("ESTA APÓLICE SERÁ UMA FROTA, DESEJA CONTINUAR?", "SIM", "NÃO", false))
- {
- coberturas1 = null;
- item4 = null;
- return;
- }
- }
- bool valueOrDefault = substituir;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA COPIAR OS DADOS DO ITEM?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.SelectedItem = item4;
- this.SelectedItem.get_Granizo().set_Item(item4);
- }
- else
- {
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- }
- ordem = item4.get_Ordem();
- int num = 1;
- valueOrDefault = ordem.GetValueOrDefault() > num & ordem.HasValue;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA REPLICAR AS COBERTURAS DO ITEM SELECIONADO?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.CoberturaViewModel.CarregaPadrao();
- }
- else
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- if (substituir)
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- base.Alterar(true);
- coberturas1 = null;
- item4 = null;
- }
-
- public void Manter(Item item, ManutencaoItem manutencao)
- {
- if (manutencao.get_Tipo() == 1)
- {
- base.ItemSubstituido = item;
- }
- this.Manter(manutencao);
- base.Mantido = true;
- }
-
- public void Manter(ManutencaoItem manutencao)
- {
- long? nullable;
- object list;
- ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura> coberturas = this.CoberturaViewModel.Coberturas;
- if (coberturas != null)
- {
- list = coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>();
- }
- else
- {
- list = null;
- }
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.get_Granizo().set_Id((long)0);
- Item selectedItem = this.SelectedItem;
- Item itemSubstituido = base.ItemSubstituido;
- if (itemSubstituido != null)
- {
- nullable = new long?(itemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- selectedItem.set_Substituicao(nullable);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- if (manutencao.get_Tipo() == null)
- {
- this.SelectedItem.set_Sinistrado(false);
- this.SelectedItem.set_Status("");
- this.SelectedItem.set_Sinistro(null);
- this.SelectedItem.set_Sinistros(null);
- }
- this.CoberturaViewModel.CarregaPadrao();
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- if (list != null)
- {
- ((List<Gestor.Model.Domain.Seguros.Cobertura>)list).ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- else
- {
- }
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- string str;
- string str1;
- string str2;
- string str3;
- string str4;
- Item selectedItem = this.SelectedItem;
- string cultura = this.SelectedItem.get_Granizo().get_Cultura();
- string sitio = this.SelectedItem.get_Granizo().get_Sitio();
- str = (ValidationHelper.IsNotNullOrEmpty(this.SelectedItem.get_Granizo().get_Area()) ? "" : string.Concat(" / ", this.SelectedItem.get_Granizo().get_Area()));
- selectedItem.set_Descricao(string.Concat(cultura, " ", sitio, str));
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedItem.get_Granizo().Validate();
- if (keyValuePairs1.Count <= 0)
- {
- Item item = this.SelectedItem;
- item.set_Coberturas(await this.CoberturaViewModel.LimpaCoberturas());
- item = null;
- if (this.SelectedItem.get_Documento().get_Ordem() <= 0)
- {
- str1 = "";
- }
- else if (base.Mantido)
- {
- str1 = string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem());
- }
- else
- {
- str1 = (base.ItemSubstituido != null ? string.Format("SUBSTITUIÇÃO DO ITEM {0} NO ENDOSSO ORDEM {1}", base.ItemSubstituido.get_Ordem(), this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM INCLUÍDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- }
- string str5 = str1;
- if (this.SelectedItem.get_Id() == 0)
- {
- this.SelectedItem.set_Status(str5);
- }
- str2 = (this.SelectedItem.get_Id() == 0 ? "INCLUIU" : "ALTEROU");
- str4 = str2;
- this.SelectedItem = await this._itemServico.Save(this.SelectedItem);
- if (this._itemServico.Sucesso)
- {
- if (base.ItemSubstituido != null)
- {
- str3 = (base.Mantido ? string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM SUBSTITUIDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- string str6 = str3;
- await this._itemServico.Substituir(base.ItemSubstituido, this.SelectedItem.get_Id(), str6);
- }
- base.Mantido = false;
- await this.SelecionaItem(this.SelectedItem, false);
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " SALVO COM SUCESSO"), true);
- string str7 = string.Concat(str4, " ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str7, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- str4 = null;
- return keyValuePairs;
- }
-
- private async void Seleciona(Item item)
- {
- base.Loading(true);
- await base.PermissaoTela(3);
- await this.SelecionaItem(item, true);
- base.Loading(false);
- }
-
- public async Task SelecionaItem(Item item, bool registrar = true)
- {
- if (item == null || this.LastAccessId != item.get_Id() || this.LastAccessTela != 9)
- {
- base.Mantido = false;
- List<long> nums = new List<long>()
- {
- (long)20
- };
- if (nums.Contains(this.Ramo.get_Id()))
- {
- this.CoberturaViewModel.Ramo = this.Ramo;
- if (this.CoberturaViewModel.CoberturasPadrao == null)
- {
- await this.CoberturaViewModel.SelectionaCoberturas();
- }
- if (item == null || item.get_Id() == 0)
- {
- this.SelectedItem = null;
- this.CoberturaViewModel.Coberturas = null;
- base.IsVisible = Visibility.Visible;
- }
- else
- {
- base.Loading(true);
- item = await this._itemServico.BuscarItemPorIdAsync(item.get_Id());
- Item item1 = item;
- Granizo granizo = await this._itemServico.BuscaGranizo(item.get_Id());
- item1.set_Granizo(granizo);
- item1 = null;
- this.SelectedItem = item;
- this.SelectedItem.Initialize();
- this.Initialized = true;
- this.CoberturaViewModel.Item = item;
- await this.CoberturaViewModel.CancelarAlteracao();
- if (registrar)
- {
- string str = string.Concat("ACESSOU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- }
- this.LastAccessId = this.SelectedItem.get_Id();
- this.LastAccessTela = 3;
- this.CodigoItem = this.SelectedItem.get_Id().ToString();
- base.Loading(false);
- }
- }
- }
- }
-
- public async void Substituir(Item item)
- {
- base.ItemSubstituido = item;
- await this.IncluirItem(true);
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/Itens/PatrimonialViewModel.cs b/Gestor.Application/ViewModels/Seguros/Itens/PatrimonialViewModel.cs deleted file mode 100644 index caf28fa..0000000 --- a/Gestor.Application/ViewModels/Seguros/Itens/PatrimonialViewModel.cs +++ /dev/null @@ -1,678 +0,0 @@ -using Gestor.Application.Actions;
-using Gestor.Application.Componentes;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Application.ViewModels.Seguros;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Gestor.Application.ViewModels.Seguros.Itens
-{
- public class PatrimonialViewModel : ItemViewModel, IDisposable
- {
- private readonly ItemServico _itemServico;
-
- private readonly PatrimonialServico _servico;
-
- private bool _allowAlterarExcluir = true;
-
- private object _cobertura;
-
- private string _codigoItem;
-
- private Item _selectedItem = new Item();
-
- private Visibility _visibilityTipoMoradia = Visibility.Collapsed;
-
- private Visibility _visibilityFianca = Visibility.Collapsed;
-
- private Visibility _visibilityPatrimonial;
-
- private string _bensInformacoes = "BENS/INFORMAÇÕES";
-
- private string _locatarioTomador1 = "LOCATÁRIO 1:";
-
- private string _locatarioTomador2 = "LOCATÁRIO 2:";
-
- private string _locatarioTomador3 = "LOCATÁRIO 3:";
-
- private Visibility _visibilityDescricao = Visibility.Collapsed;
-
- public bool AllowAlterarExcluir
- {
- get
- {
- return this._allowAlterarExcluir;
- }
- set
- {
- this._allowAlterarExcluir = value;
- base.OnPropertyChanged("AllowAlterarExcluir");
- }
- }
-
- public string BensInformacoes
- {
- get
- {
- return this._bensInformacoes;
- }
- set
- {
- this._bensInformacoes = value;
- base.OnPropertyChanged("BensInformacoes");
- }
- }
-
- public object Cobertura
- {
- get
- {
- return this._cobertura;
- }
- set
- {
- this._cobertura = value;
- base.OnPropertyChanged("Cobertura");
- }
- }
-
- public string CodigoItem
- {
- get
- {
- return this._codigoItem;
- }
- set
- {
- this._codigoItem = value;
- base.OnPropertyChanged("CodigoItem");
- }
- }
-
- public bool Garantia
- {
- get;
- set;
- }
-
- public bool Invoke
- {
- get;
- set;
- }
-
- private Item ItemSelecionado
- {
- get;
- set;
- }
-
- public string LocatarioTomador1
- {
- get
- {
- return this._locatarioTomador1;
- }
- set
- {
- this._locatarioTomador1 = value;
- base.OnPropertyChanged("LocatarioTomador1");
- }
- }
-
- public string LocatarioTomador2
- {
- get
- {
- return this._locatarioTomador2;
- }
- set
- {
- this._locatarioTomador2 = value;
- base.OnPropertyChanged("LocatarioTomador2");
- }
- }
-
- public string LocatarioTomador3
- {
- get
- {
- return this._locatarioTomador3;
- }
- set
- {
- this._locatarioTomador3 = value;
- base.OnPropertyChanged("LocatarioTomador3");
- }
- }
-
- private Gestor.Model.Domain.Seguros.Ramo Ramo
- {
- get;
- }
-
- public Item SelectedItem
- {
- get
- {
- return this._selectedItem;
- }
- set
- {
- long? nullable;
- this._selectedItem = value;
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedItem");
- }
- }
-
- public Visibility VisibilityDescricao
- {
- get
- {
- return this._visibilityDescricao;
- }
- set
- {
- this._visibilityDescricao = value;
- base.OnPropertyChanged("VisibilityDescricao");
- }
- }
-
- public Visibility VisibilityFianca
- {
- get
- {
- return this._visibilityFianca;
- }
- set
- {
- this._visibilityFianca = value;
- base.OnPropertyChanged("VisibilityFianca");
- }
- }
-
- public Visibility VisibilityPatrimonial
- {
- get
- {
- return this._visibilityPatrimonial;
- }
- set
- {
- this._visibilityPatrimonial = value;
- base.OnPropertyChanged("VisibilityPatrimonial");
- }
- }
-
- public Visibility VisibilityTipoMoradia
- {
- get
- {
- return this._visibilityTipoMoradia;
- }
- set
- {
- this._visibilityTipoMoradia = value;
- base.OnPropertyChanged("VisibilityTipoMoradia");
- }
- }
-
- public PatrimonialViewModel(bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Gestor.Model.Domain.Seguros.Ramo ramo = null, bool endossoRenovacao = false)
- {
- this.Invoke = itemSelecionado == null;
- this.ItemSelecionado = itemSelecionado ?? ConsultaViewModel.ItemSelecionado;
- this.Ramo = ramo ?? ConsultaViewModel.DocumentoSelecionado.get_Controle().get_Ramo();
- if (this.Invoke)
- {
- this.ItemSelecionado = this.ItemSelecionado ?? new Item();
- this.ItemSelecionado.set_Documento(ConsultaViewModel.DocumentoSelecionado);
- }
- this._itemServico = new ItemServico();
- this._servico = new PatrimonialServico();
- this.Seleciona(this.ItemSelecionado);
- if (substituir)
- {
- this.Substituir(this.ItemSelecionado);
- }
- if (manutencao != null)
- {
- this.Manter(this.ItemSelecionado, manutencao);
- }
- this.AllowAlterarExcluir = !endossoRenovacao;
- this.CarregaCobertura();
- }
-
- public async void CancelarAlteracao()
- {
- base.Loading(true);
- await this.SelecionaItem(this.ItemSelecionado, false);
- await this.CoberturaViewModel.CancelarAlteracao();
- base.Alterar(false);
- base.Loading(false);
- }
-
- public void CarregaCobertura()
- {
- this.CoberturaViewModel.Item = this.ItemSelecionado;
- this.CoberturaViewModel.Ramo = this.Ramo;
- this.Cobertura = new CoberturaView(this.CoberturaViewModel);
- }
-
- public void Descarregar()
- {
- this.Cobertura = null;
- }
-
- public void Dispose()
- {
- Gestor.Application.Actions.Actions.UpdateItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.UpdateItem, new Action<Item>(this.Seleciona));
- Gestor.Application.Actions.Actions.SubstituirItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.SubstituirItem, new Action<Item>(this.Substituir));
- Gestor.Application.Actions.Actions.ManterItem = (Action<Item, ManutencaoItem>)Delegate.Remove(Gestor.Application.Actions.Actions.ManterItem, new Action<Item, ManutencaoItem>(this.Manter));
- }
-
- public async Task<bool> Excluir()
- {
- bool flag;
- if (this.SelectedItem == null || this.SelectedItem.get_Id() == 0)
- {
- flag = false;
- }
- else if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- bool flag1 = await this._servico.Delete(this.SelectedItem);
- base.Loading(false);
- if (flag1)
- {
- string str = string.Concat("EXCLUIU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " EXCLUÍDO COM SUCESSO"), true);
- flag = true;
- }
- else
- {
- await base.ShowMessage("NÃO POSSÍVEL EXCLUIR O ITEM", "OK", "", false);
- flag = false;
- }
- }
- else
- {
- flag = false;
- }
- return flag;
- }
-
- private void HabilitaCamposGarantia()
- {
- this.VisibilityPatrimonial = (this.Ramo.get_Id() == (long)38 ? Visibility.Collapsed : Visibility.Visible);
- this.BensInformacoes = "OBSERVAÇÕES";
- this.LocatarioTomador1 = "TOMADOR 1:";
- this.LocatarioTomador2 = "TOMADOR 2:";
- this.LocatarioTomador3 = "TOMADOR 3:";
- this.VisibilityDescricao = Visibility.Visible;
- this.Garantia = true;
- }
-
- public async Task Incluir(bool substituir = false)
- {
- int? ordem;
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas;
- long? nullable;
- Patrimonial patrimonial1;
- coberturas = (this.CoberturaViewModel.Coberturas == null ? this.CoberturaViewModel.CarregaCoberturaPadrao().ToList<Gestor.Model.Domain.Seguros.Cobertura>() : this.CoberturaViewModel.Coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>());
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas1 = coberturas;
- Item item = new Item();
- item.set_Documento(this.ItemSelecionado.get_Documento());
- Item item1 = item;
- ordem = (substituir ? base.ItemSubstituido.get_Ordem() : new int?(await base.QuantidadeDeItens(this.ItemSelecionado.get_Documento().get_Controle().get_Id())));
- item1.set_Ordem(ordem);
- Item item2 = item;
- Patrimonial patrimonial2 = new Patrimonial();
- patrimonial2.set_Item(this.SelectedItem);
- item2.set_Patrimonial(patrimonial2);
- Item item3 = item;
- if (substituir)
- {
- nullable = new long?(base.ItemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- item3.set_Substituicao(nullable);
- Item item4 = item;
- item1 = null;
- item = null;
- bool garantia = !this.Garantia;
- if (garantia)
- {
- garantia = await base.ShowMessage("COPIAR OS DADOS DE ENDEREÇO DO CLIENTE?", "SIM", "NÃO", false);
- }
- if (garantia)
- {
- ObservableCollection<ClienteEndereco> observableCollection = await (new ClienteServico()).BuscarEnderecosAsync(item4.get_Documento().get_Controle().get_Cliente().get_Id());
- if (observableCollection != null && observableCollection.Any<ClienteEndereco>())
- {
- ObservableCollection<ClienteEndereco> observableCollection1 = observableCollection;
- IOrderedEnumerable<ClienteEndereco> valueOrDefault =
- from x in observableCollection1
- orderby x.get_Ordem().GetValueOrDefault() == 1
- select x;
- List<Patrimonial> list = valueOrDefault.Select<ClienteEndereco, Patrimonial>((ClienteEndereco e) => {
- Patrimonial patrimonial = new Patrimonial();
- patrimonial.set_Endereco(e.get_Endereco());
- patrimonial.set_Numero(e.get_Numero());
- patrimonial.set_Complemento(e.get_Complemento());
- patrimonial.set_Bairro(e.get_Bairro());
- patrimonial.set_Cidade(e.get_Cidade());
- patrimonial.set_Estado(e.get_Estado());
- patrimonial.set_Cep(e.get_Cep());
- return patrimonial;
- }).ToList<Patrimonial>();
- Item item5 = item4;
- if (list.Any<Patrimonial>())
- {
- patrimonial1 = list.Last<Patrimonial>();
- }
- else
- {
- patrimonial1 = null;
- }
- item5.set_Patrimonial(patrimonial1);
- }
- }
- ordem = item4.get_Ordem();
- if (ordem.GetValueOrDefault() == 2)
- {
- if (!await base.ShowMessage("ESTA APÓLICE SERÁ UMA FROTA, DESEJA CONTINUAR?", "SIM", "NÃO", false))
- {
- coberturas1 = null;
- item4 = null;
- return;
- }
- }
- this.SelectedItem = item4;
- this.SelectedItem.get_Patrimonial().set_Item(item4);
- ordem = item4.get_Ordem();
- int num = 1;
- garantia = ordem.GetValueOrDefault() > num & ordem.HasValue;
- if (garantia)
- {
- garantia = await base.ShowMessage("DESEJA REPLICAR AS COBERTURAS DO ITEM SELECIONADO?", "SIM", "NÃO", false);
- }
- if (!garantia)
- {
- this.CoberturaViewModel.CarregaPadrao();
- }
- else
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- if (substituir)
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- base.Alterar(true);
- coberturas1 = null;
- item4 = null;
- }
-
- public void Manter(Item item, ManutencaoItem manutencao)
- {
- if (manutencao.get_Tipo() == 1)
- {
- base.ItemSubstituido = item;
- }
- this.Manter(manutencao);
- base.Mantido = true;
- }
-
- public void Manter(ManutencaoItem manutencao)
- {
- long? nullable;
- object list;
- ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura> coberturas = this.CoberturaViewModel.Coberturas;
- if (coberturas != null)
- {
- list = coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>();
- }
- else
- {
- list = null;
- }
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.get_Patrimonial().set_Id((long)0);
- Item selectedItem = this.SelectedItem;
- Item itemSubstituido = base.ItemSubstituido;
- if (itemSubstituido != null)
- {
- nullable = new long?(itemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- selectedItem.set_Substituicao(nullable);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- if (manutencao.get_Tipo() == null)
- {
- this.SelectedItem.set_Sinistrado(false);
- this.SelectedItem.set_Status("");
- this.SelectedItem.set_Sinistro(null);
- this.SelectedItem.set_Sinistros(null);
- }
- this.CoberturaViewModel.CarregaPadrao();
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- if (list != null)
- {
- ((List<Gestor.Model.Domain.Seguros.Cobertura>)list).ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- else
- {
- }
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- string descricao;
- string str;
- string str1;
- string str2;
- string str3;
- Item selectedItem = this.SelectedItem;
- if (this.VisibilityPatrimonial == Visibility.Visible)
- {
- string[] endereco = new string[] { this.SelectedItem.get_Patrimonial().get_Endereco(), ", ", this.SelectedItem.get_Patrimonial().get_Numero(), " - ", this.SelectedItem.get_Patrimonial().get_Complemento(), " - ", this.SelectedItem.get_Patrimonial().get_Bairro(), ", ", this.SelectedItem.get_Patrimonial().get_Cidade(), " / ", this.SelectedItem.get_Patrimonial().get_Estado() };
- descricao = string.Concat(endereco);
- }
- else
- {
- descricao = this.SelectedItem.get_Descricao();
- }
- selectedItem.set_Descricao(descricao);
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedItem.Validate();
- if (keyValuePairs1.Count <= 0)
- {
- Item item = this.SelectedItem;
- item.set_Coberturas(await this.CoberturaViewModel.LimpaCoberturas());
- item = null;
- if (this.SelectedItem.get_Documento().get_Ordem() <= 0)
- {
- str = "";
- }
- else if (base.Mantido)
- {
- str = string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem());
- }
- else
- {
- str = (base.ItemSubstituido != null ? string.Format("SUBSTITUIÇÃO DO ITEM {0} NO ENDOSSO ORDEM {1}", base.ItemSubstituido.get_Ordem(), this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM INCLUÍDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- }
- string str4 = str;
- if (this.SelectedItem.get_Id() == 0)
- {
- this.SelectedItem.set_Status(str4);
- }
- str1 = (this.SelectedItem.get_Id() == 0 ? "INCLUIU" : "ALTEROU");
- str3 = str1;
- this.SelectedItem = await this._itemServico.Save(this.SelectedItem);
- if (this._itemServico.Sucesso)
- {
- if (base.ItemSubstituido != null)
- {
- str2 = (base.Mantido ? string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM SUBSTITUIDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- string str5 = str2;
- await this._itemServico.Substituir(base.ItemSubstituido, this.SelectedItem.get_Id(), str5);
- }
- base.Mantido = false;
- await this.SelecionaItem(this.SelectedItem, false);
- this.ItemSelecionado = this.SelectedItem;
- if (this.Invoke)
- {
- ConsultaViewModel.ItemSelecionado = this.SelectedItem;
- }
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " SALVO COM SUCESSO"), true);
- string str6 = string.Concat(str3, " ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str6, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- str3 = null;
- return keyValuePairs;
- }
-
- private async void Seleciona(Item item)
- {
- base.Loading(true);
- await base.PermissaoTela(3);
- await this.SelecionaItem(item, true);
- base.Loading(false);
- }
-
- public async Task SelecionaItem(Item item, bool registrar = true)
- {
- Visibility visibility;
- Visibility visibility1;
- if (item == null || this.LastAccessId != item.get_Id() || this.LastAccessTela != 9)
- {
- base.Mantido = false;
- List<long> nums = new List<long>()
- {
- (long)1,
- (long)2,
- (long)3,
- (long)15,
- (long)18,
- (long)30,
- (long)38
- };
- if (nums.Contains(this.Ramo.get_Id()))
- {
- PatrimonialViewModel patrimonialViewModel = this;
- visibility = (this.Ramo.get_Id() == (long)1 ? Visibility.Visible : Visibility.Collapsed);
- patrimonialViewModel.VisibilityTipoMoradia = visibility;
- this.CoberturaViewModel.Ramo = this.Ramo;
- if (this.CoberturaViewModel.CoberturasPadrao == null)
- {
- await this.CoberturaViewModel.SelectionaCoberturas();
- }
- PatrimonialViewModel patrimonialViewModel1 = this;
- visibility1 = (this.Ramo.get_Id() == (long)15 || this.Ramo.get_Id() == (long)38 ? Visibility.Visible : Visibility.Collapsed);
- patrimonialViewModel1.VisibilityFianca = visibility1;
- if (this.Ramo.get_Id() == (long)38)
- {
- this.HabilitaCamposGarantia();
- }
- if (item == null || item.get_Id() == 0)
- {
- this.SelectedItem = null;
- this.CoberturaViewModel.Coberturas = null;
- base.IsVisible = Visibility.Visible;
- }
- else
- {
- base.Loading(true);
- item = await this._itemServico.BuscarItemPorIdAsync(item.get_Id());
- Item item1 = item;
- Patrimonial patrimonial = await this._itemServico.BuscaPatrimonial(item.get_Id());
- item1.set_Patrimonial(patrimonial);
- item1 = null;
- this.SelectedItem = item;
- this.SelectedItem.Initialize();
- this.Initialized = true;
- this.CoberturaViewModel.Item = item;
- await this.CoberturaViewModel.CancelarAlteracao();
- if (registrar)
- {
- string str = string.Concat("ACESSOU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- }
- this.LastAccessId = this.SelectedItem.get_Id();
- this.LastAccessTela = 3;
- this.CodigoItem = this.SelectedItem.get_Id().ToString();
- base.Loading(false);
- }
- }
- }
- }
-
- public async void Substituir(Item item)
- {
- base.ItemSubstituido = item;
- await this.Incluir(true);
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/Itens/RiscosDiversosViewModel.cs b/Gestor.Application/ViewModels/Seguros/Itens/RiscosDiversosViewModel.cs deleted file mode 100644 index 7469ac9..0000000 --- a/Gestor.Application/ViewModels/Seguros/Itens/RiscosDiversosViewModel.cs +++ /dev/null @@ -1,626 +0,0 @@ -using Gestor.Application.Actions;
-using Gestor.Application.Componentes;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Application.ViewModels.Seguros;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Gestor.Application.ViewModels.Seguros.Itens
-{
- public class RiscosDiversosViewModel : ItemViewModel, IDisposable
- {
- private readonly ItemServico _itemServico;
-
- private readonly RiscosDiversosServico _servico;
-
- private bool _visibilityTitulares;
-
- private bool _allowAlterarExcluir = true;
-
- private object _cobertura;
-
- private object _sinistro;
-
- private string _codigoItem;
-
- private Item _selectedItem = new Item();
-
- public Visibility _visibilityMultRisco { get; set; } = Visibility.Collapsed;
-
- public bool AllowAlterarExcluir
- {
- get
- {
- return this._allowAlterarExcluir;
- }
- set
- {
- this._allowAlterarExcluir = value;
- base.OnPropertyChanged("AllowAlterarExcluir");
- }
- }
-
- public object Cobertura
- {
- get
- {
- return this._cobertura;
- }
- set
- {
- this._cobertura = value;
- base.OnPropertyChanged("Cobertura");
- }
- }
-
- public string CodigoItem
- {
- get
- {
- return this._codigoItem;
- }
- set
- {
- this._codigoItem = value;
- base.OnPropertyChanged("CodigoItem");
- }
- }
-
- public bool Invoke
- {
- get;
- set;
- }
-
- private Item ItemSelecionado
- {
- get;
- set;
- }
-
- private Gestor.Model.Domain.Seguros.Ramo Ramo
- {
- get;
- }
-
- public Item SelectedItem
- {
- get
- {
- return this._selectedItem;
- }
- set
- {
- long? nullable;
- this._selectedItem = value;
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedItem");
- }
- }
-
- public object Sinistro
- {
- get
- {
- return this._sinistro;
- }
- set
- {
- this._sinistro = value;
- base.OnPropertyChanged("Sinistro");
- }
- }
-
- public Visibility VisibilityMultRisco
- {
- get
- {
- return this._visibilityMultRisco;
- }
- set
- {
- this._visibilityMultRisco = value;
- base.OnPropertyChanged("VisibilityMultRisco");
- }
- }
-
- public bool VisibilityTitulares
- {
- get
- {
- return this._visibilityTitulares;
- }
- set
- {
- this._visibilityTitulares = value;
- base.OnPropertyChanged("VisibilityTitulares");
- }
- }
-
- public RiscosDiversosViewModel(bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Gestor.Model.Domain.Seguros.Ramo ramo = null, bool endossoRenovacao = false)
- {
- this.Invoke = itemSelecionado == null;
- this.ItemSelecionado = itemSelecionado ?? ConsultaViewModel.ItemSelecionado;
- this.Ramo = ramo ?? ConsultaViewModel.DocumentoSelecionado.get_Controle().get_Ramo();
- if (this.Invoke)
- {
- this.ItemSelecionado = this.ItemSelecionado ?? new Item();
- this.ItemSelecionado.set_Documento(ConsultaViewModel.DocumentoSelecionado);
- }
- this._itemServico = new ItemServico();
- this._servico = new RiscosDiversosServico();
- this.Seleciona(this.ItemSelecionado);
- if (substituir)
- {
- this.Substituir(this.ItemSelecionado);
- }
- if (manutencao != null)
- {
- this.Manter(this.ItemSelecionado, manutencao);
- }
- this.AllowAlterarExcluir = !endossoRenovacao;
- this.CarregaCobertura();
- this.VisibilityTitulares = this.Ramo.get_Id() == (long)31;
- this.VisibilityMultRisco = (this.Ramo.get_Id() == (long)33 ? Visibility.Visible : Visibility.Collapsed);
- }
-
- public async void CancelarAlteracao()
- {
- base.Loading(true);
- await this.SelecionaItem(this.ItemSelecionado, false);
- await this.CoberturaViewModel.CancelarAlteracao();
- base.Alterar(false);
- base.Loading(false);
- }
-
- public void CarregaCobertura()
- {
- this.CoberturaViewModel.Item = this.ItemSelecionado;
- this.CoberturaViewModel.Ramo = this.Ramo;
- this.Cobertura = new CoberturaView(this.CoberturaViewModel);
- }
-
- public void Descarregar()
- {
- this.Cobertura = null;
- this.Sinistro = null;
- }
-
- public void Dispose()
- {
- Gestor.Application.Actions.Actions.UpdateItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.UpdateItem, new Action<Item>(this.Seleciona));
- Gestor.Application.Actions.Actions.SubstituirItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.SubstituirItem, new Action<Item>(this.Substituir));
- Gestor.Application.Actions.Actions.ManterItem = (Action<Item, ManutencaoItem>)Delegate.Remove(Gestor.Application.Actions.Actions.ManterItem, new Action<Item, ManutencaoItem>(this.Manter));
- }
-
- public async Task<bool> Excluir()
- {
- bool flag;
- if (this.SelectedItem == null || this.SelectedItem.get_Id() == 0)
- {
- flag = false;
- }
- else if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- bool flag1 = await this._servico.Delete(this.SelectedItem);
- base.Loading(false);
- if (flag1)
- {
- string str = string.Concat("EXCLUIU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " EXCLUÍDO COM SUCESSO"), true);
- flag = true;
- }
- else
- {
- await base.ShowMessage("NÃO POSSÍVEL EXCLUIR O ITEM", "OK", "", false);
- flag = false;
- }
- }
- else
- {
- flag = false;
- }
- return flag;
- }
-
- public async Task Incluir(bool substituir = false)
- {
- int? ordem;
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas;
- long? nullable;
- coberturas = (this.CoberturaViewModel.Coberturas == null ? this.CoberturaViewModel.CarregaCoberturaPadrao().ToList<Gestor.Model.Domain.Seguros.Cobertura>() : this.CoberturaViewModel.Coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>());
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas1 = coberturas;
- Item item = new Item();
- item.set_Documento(this.ItemSelecionado.get_Documento());
- Item item1 = item;
- ordem = (substituir ? base.ItemSubstituido.get_Ordem() : new int?(await base.QuantidadeDeItens(this.ItemSelecionado.get_Documento().get_Controle().get_Id())));
- item1.set_Ordem(ordem);
- item.set_RiscosDiversos(new RiscosDiversos());
- Item item2 = item;
- if (substituir)
- {
- nullable = new long?(base.ItemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- item2.set_Substituicao(nullable);
- Item item3 = item;
- item1 = null;
- item = null;
- base.Titulares = new ObservableCollection<TitularesVida>();
- ordem = item3.get_Ordem();
- if (ordem.GetValueOrDefault() == 2)
- {
- if (!await base.ShowMessage("ESTA APÓLICE SERÁ UMA FROTA, DESEJA CONTINUAR?", "SIM", "NÃO", false))
- {
- coberturas1 = null;
- item3 = null;
- return;
- }
- }
- bool valueOrDefault = substituir;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA COPIAR OS DADOS DO ITEM?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.SelectedItem = item3;
- this.SelectedItem.get_RiscosDiversos().set_Item(item3);
- }
- else
- {
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- }
- ordem = item3.get_Ordem();
- int num = 1;
- valueOrDefault = ordem.GetValueOrDefault() > num & ordem.HasValue;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA REPLICAR AS COBERTURAS DO ITEM SELECIONADO?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.CoberturaViewModel.CarregaPadrao();
- }
- else
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- if (substituir)
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- base.Alterar(true);
- coberturas1 = null;
- item3 = null;
- }
-
- public void Manter(Item item, ManutencaoItem manutencao)
- {
- if (manutencao.get_Tipo() == 1)
- {
- base.ItemSubstituido = item;
- }
- this.Manter(manutencao);
- base.Mantido = true;
- }
-
- public void Manter(ManutencaoItem manutencao)
- {
- long? nullable;
- object list;
- ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura> coberturas = this.CoberturaViewModel.Coberturas;
- if (coberturas != null)
- {
- list = coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>();
- }
- else
- {
- list = null;
- }
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.get_RiscosDiversos().set_Id((long)0);
- Item selectedItem = this.SelectedItem;
- Item itemSubstituido = base.ItemSubstituido;
- if (itemSubstituido != null)
- {
- nullable = new long?(itemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- selectedItem.set_Substituicao(nullable);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- if (manutencao.get_Tipo() == null)
- {
- this.SelectedItem.set_Sinistrado(false);
- this.SelectedItem.set_Status("");
- this.SelectedItem.set_Sinistro(null);
- this.SelectedItem.set_Sinistros(null);
- }
- this.CoberturaViewModel.CarregaPadrao();
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- if (list != null)
- {
- ((List<Gestor.Model.Domain.Seguros.Cobertura>)list).ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- else
- {
- }
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar(List<TitularesVida> titularesGrid)
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- string str;
- string str1;
- string str2;
- bool flag;
- bool flag1;
- bool flag2;
- string str3;
- if (this.VisibilityTitulares)
- {
- this.SelectedItem.set_Titulares(titularesGrid);
- }
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedItem.Validate();
- if (keyValuePairs1.Count <= 0)
- {
- Item selectedItem = this.SelectedItem;
- selectedItem.set_Coberturas(await this.CoberturaViewModel.LimpaCoberturas());
- selectedItem = null;
- if (this.SelectedItem.get_Documento().get_Ordem() <= 0)
- {
- str = "";
- }
- else if (base.Mantido)
- {
- str = string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem());
- }
- else
- {
- str = (base.ItemSubstituido != null ? string.Format("SUBSTITUIÇÃO DO ITEM {0} NO ENDOSSO ORDEM {1}", base.ItemSubstituido.get_Ordem(), this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM INCLUÍDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- }
- string str4 = str;
- if (this.SelectedItem.get_Id() == 0)
- {
- this.SelectedItem.set_Status(str4);
- }
- if (this.VisibilityTitulares)
- {
- await this._itemServico.DeleteTitulares(base.ExcluirTitulares);
- base.ExcluirTitulares = new List<TitularesVida>();
- }
- str1 = (this.SelectedItem.get_Id() == 0 ? "INCLUIU" : "ALTEROU");
- str3 = str1;
- this.SelectedItem = await this._itemServico.Save(this.SelectedItem);
- if (this.VisibilityTitulares)
- {
- foreach (TitularesVida titularesVida in titularesGrid)
- {
- titularesVida.set_IdItem(this.SelectedItem.get_Id());
- }
- List<TitularesVida> titularesVidas = new List<TitularesVida>();
- foreach (TitularesVida titularesVida1 in titularesGrid)
- {
- if (titularesVida1.get_Id() != 0)
- {
- TitularesVida titularesVida2 = base.OldTitulares.First<TitularesVida>((TitularesVida x) => x.get_Id() == titularesVida1.get_Id());
- if (titularesVida1.get_Codigo() == titularesVida2.get_Codigo())
- {
- DateTime? inicio = titularesVida1.get_Inicio();
- DateTime? fim = titularesVida2.get_Inicio();
- if (inicio.HasValue == fim.HasValue)
- {
- flag = (inicio.HasValue ? inicio.GetValueOrDefault() != fim.GetValueOrDefault() : false);
- }
- else
- {
- flag = true;
- }
- if (!flag)
- {
- fim = titularesVida1.get_Fim();
- inicio = titularesVida2.get_Fim();
- if (fim.HasValue == inicio.HasValue)
- {
- flag1 = (fim.HasValue ? fim.GetValueOrDefault() != inicio.GetValueOrDefault() : false);
- }
- else
- {
- flag1 = true;
- }
- if (!flag1 && !(titularesVida1.get_Fatura() != titularesVida2.get_Fatura()) && !(titularesVida1.get_Nome() != titularesVida2.get_Nome()) && !(titularesVida1.get_Observacao() != titularesVida2.get_Observacao()))
- {
- inicio = titularesVida1.get_Nascimento();
- fim = titularesVida2.get_Nascimento();
- if (inicio.HasValue == fim.HasValue)
- {
- flag2 = (inicio.HasValue ? inicio.GetValueOrDefault() != fim.GetValueOrDefault() : false);
- }
- else
- {
- flag2 = true;
- }
- if (!flag2 && !(titularesVida1.get_Cpf() != titularesVida2.get_Cpf()) && !(titularesVida1.get_Matricula() != titularesVida2.get_Matricula()))
- {
- decimal? premio = titularesVida1.get_Premio();
- decimal? capital = titularesVida2.get_Premio();
- if ((premio.GetValueOrDefault() == capital.GetValueOrDefault()) & premio.HasValue == capital.HasValue)
- {
- capital = titularesVida1.get_Capital();
- premio = titularesVida2.get_Capital();
- if ((capital.GetValueOrDefault() == premio.GetValueOrDefault()) & capital.HasValue == premio.HasValue)
- {
- TipoTitular? tipo = titularesVida1.get_Tipo();
- TipoTitular? nullable = titularesVida2.get_Tipo();
- if (tipo.GetValueOrDefault() == nullable.GetValueOrDefault() & tipo.HasValue == nullable.HasValue && (object)titularesVida1.get_Dependente() == (object)titularesVida2.get_Dependente())
- {
- continue;
- }
- }
- }
- }
- }
- }
- }
- titularesVidas.Add(titularesVida1);
- }
- else
- {
- titularesVidas.Add(titularesVida1);
- }
- }
- base.Titulares = new ObservableCollection<TitularesVida>(await this._itemServico.SaveTitulares(titularesVidas));
- }
- if (this._itemServico.Sucesso)
- {
- if (base.ItemSubstituido != null)
- {
- str2 = (base.Mantido ? string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM SUBSTITUIDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- string str5 = str2;
- await this._itemServico.Substituir(base.ItemSubstituido, this.SelectedItem.get_Id(), str5);
- }
- base.Mantido = false;
- await this.SelecionaItem(this.SelectedItem, false);
- this.ItemSelecionado = this.SelectedItem;
- if (this.Invoke)
- {
- ConsultaViewModel.ItemSelecionado = this.SelectedItem;
- }
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " SALVO COM SUCESSO"), true);
- string str6 = string.Concat(str3, " ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable1 = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str6, id, nullable1, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- str3 = null;
- return keyValuePairs;
- }
-
- private async void Seleciona(Item item)
- {
- base.Loading(true);
- await base.PermissaoTela(3);
- await this.SelecionaItem(item, true);
- base.Loading(false);
- }
-
- public async Task SelecionaItem(Item item, bool registrar = true)
- {
- if (item == null || this.LastAccessId != item.get_Id() || this.LastAccessTela != 9)
- {
- base.Mantido = false;
- this.CoberturaViewModel.Ramo = this.Ramo;
- if (this.CoberturaViewModel.CoberturasPadrao == null)
- {
- await this.CoberturaViewModel.SelectionaCoberturas();
- }
- if (item == null || item.get_Id() == 0)
- {
- this.SelectedItem = null;
- this.CoberturaViewModel.Coberturas = null;
- base.IsVisible = Visibility.Visible;
- base.Titulares = new ObservableCollection<TitularesVida>();
- }
- else
- {
- base.Loading(true);
- item = await this._itemServico.BuscarItemPorIdAsync(item.get_Id());
- Item item1 = item;
- RiscosDiversos riscosDiverso = await this._itemServico.BuscaRiscosDiversos(item.get_Id());
- Item item2 = item1;
- RiscosDiversos riscosDiverso1 = riscosDiverso;
- if (riscosDiverso1 == null)
- {
- riscosDiverso1 = new RiscosDiversos();
- riscosDiverso1.set_Item(item);
- }
- item2.set_RiscosDiversos(riscosDiverso1);
- item1 = null;
- if (this.VisibilityTitulares)
- {
- await base.CarregarTitulares(item.get_Id());
- }
- this.SelectedItem = item;
- this.SelectedItem.Initialize();
- this.Initialized = true;
- this.CoberturaViewModel.Item = item;
- await this.CoberturaViewModel.CancelarAlteracao();
- if (registrar)
- {
- string str = string.Concat("ACESSOU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- }
- this.LastAccessId = this.SelectedItem.get_Id();
- this.LastAccessTela = 3;
- this.CodigoItem = this.SelectedItem.get_Id().ToString();
- base.Loading(false);
- }
- }
- }
-
- public async void Substituir(Item item)
- {
- base.ItemSubstituido = item;
- await this.Incluir(true);
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/Itens/VidaViewModel.cs b/Gestor.Application/ViewModels/Seguros/Itens/VidaViewModel.cs deleted file mode 100644 index e128b48..0000000 --- a/Gestor.Application/ViewModels/Seguros/Itens/VidaViewModel.cs +++ /dev/null @@ -1,661 +0,0 @@ -using Gestor.Application.Actions;
-using Gestor.Application.Componentes;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Application.ViewModels.Seguros;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Gestor.Application.ViewModels.Seguros.Itens
-{
- public class VidaViewModel : ItemViewModel, IDisposable
- {
- private readonly ItemServico _itemServico;
-
- private readonly VidaServico _servico;
-
- private bool _allowAlterarExcluir = true;
-
- private object _cobertura;
-
- private string _codigoItem;
-
- private Item _selectedItem = new Item();
-
- private Visibility _atualizarCamposSaude;
-
- public bool AllowAlterarExcluir
- {
- get
- {
- return this._allowAlterarExcluir;
- }
- set
- {
- this._allowAlterarExcluir = value;
- base.OnPropertyChanged("AllowAlterarExcluir");
- }
- }
-
- public Visibility AtualizarCamposSaude
- {
- get
- {
- return this._atualizarCamposSaude;
- }
- set
- {
- this._atualizarCamposSaude = value;
- base.OnPropertyChanged("AtualizarCamposSaude");
- }
- }
-
- public object Cobertura
- {
- get
- {
- return this._cobertura;
- }
- set
- {
- this._cobertura = value;
- base.OnPropertyChanged("Cobertura");
- }
- }
-
- public string CodigoItem
- {
- get
- {
- return this._codigoItem;
- }
- set
- {
- this._codigoItem = value;
- base.OnPropertyChanged("CodigoItem");
- }
- }
-
- public bool Invoke
- {
- get;
- set;
- }
-
- private Item ItemSelecionado
- {
- get;
- set;
- }
-
- private Gestor.Model.Domain.Seguros.Ramo Ramo
- {
- get;
- }
-
- public Item SelectedItem
- {
- get
- {
- return this._selectedItem;
- }
- set
- {
- long? nullable;
- this._selectedItem = value;
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedItem");
- }
- }
-
- public VidaViewModel(bool substituir = false, ManutencaoItem manutencao = null, Item itemSelecionado = null, Gestor.Model.Domain.Seguros.Ramo ramo = null, bool endossoRenovacao = false)
- {
- this.Invoke = itemSelecionado == null;
- this.ItemSelecionado = itemSelecionado ?? ConsultaViewModel.ItemSelecionado;
- this.Ramo = ramo ?? ConsultaViewModel.DocumentoSelecionado.get_Controle().get_Ramo();
- if (this.Invoke)
- {
- this.ItemSelecionado = this.ItemSelecionado ?? new Item();
- this.ItemSelecionado.set_Documento(ConsultaViewModel.DocumentoSelecionado);
- }
- this._itemServico = new ItemServico();
- this._servico = new VidaServico();
- Gestor.Application.Actions.Actions.UpdateItem = (Action<Item>)Delegate.Combine(Gestor.Application.Actions.Actions.UpdateItem, new Action<Item>(this.Seleciona));
- Gestor.Application.Actions.Actions.SubstituirItem = (Action<Item>)Delegate.Combine(Gestor.Application.Actions.Actions.SubstituirItem, new Action<Item>(this.Substituir));
- Gestor.Application.Actions.Actions.ManterItem = (Action<Item, ManutencaoItem>)Delegate.Combine(Gestor.Application.Actions.Actions.ManterItem, new Action<Item, ManutencaoItem>(this.Manter));
- this.Seleciona(this.ItemSelecionado);
- if (substituir)
- {
- this.Substituir(this.ItemSelecionado);
- }
- if (manutencao != null)
- {
- this.Manter(this.ItemSelecionado, manutencao);
- }
- this.AllowAlterarExcluir = !endossoRenovacao;
- this.CarregaCobertura();
- }
-
- public async void CancelarAlteracao()
- {
- base.Loading(true);
- base.AllSelected = new bool?(false);
- await this.SelecionaItem(this.ItemSelecionado, false);
- await this.CoberturaViewModel.CancelarAlteracao();
- base.Alterar(false);
- base.Loading(false);
- }
-
- public void CarregaCobertura()
- {
- this.CoberturaViewModel.Item = this.ItemSelecionado;
- this.CoberturaViewModel.Ramo = this.Ramo;
- this.Cobertura = new CoberturaView(this.CoberturaViewModel);
- }
-
- public void Descarregar()
- {
- this.Cobertura = null;
- }
-
- public void Dispose()
- {
- Gestor.Application.Actions.Actions.UpdateItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.UpdateItem, new Action<Item>(this.Seleciona));
- Gestor.Application.Actions.Actions.SubstituirItem = (Action<Item>)Delegate.Remove(Gestor.Application.Actions.Actions.SubstituirItem, new Action<Item>(this.Substituir));
- Gestor.Application.Actions.Actions.ManterItem = (Action<Item, ManutencaoItem>)Delegate.Remove(Gestor.Application.Actions.Actions.ManterItem, new Action<Item, ManutencaoItem>(this.Manter));
- }
-
- public async Task<bool> Excluir()
- {
- bool flag;
- if (this.SelectedItem == null || this.SelectedItem.get_Id() == 0)
- {
- flag = false;
- }
- else if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- bool flag1 = await this._servico.Delete(this.SelectedItem);
- base.Loading(false);
- if (flag1)
- {
- string str = string.Concat("EXCLUIU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " EXCLUÍDO COM SUCESSO"), true);
- flag = true;
- }
- else
- {
- await base.ShowMessage("NÃO POSSÍVEL EXCLUIR O ITEM", "OK", "", false);
- flag = false;
- }
- }
- else
- {
- flag = false;
- }
- return flag;
- }
-
- public async Task Incluir(bool substituir = false)
- {
- int? ordem;
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas;
- long? nullable;
- coberturas = (this.CoberturaViewModel.Coberturas == null ? this.CoberturaViewModel.CarregaCoberturaPadrao().ToList<Gestor.Model.Domain.Seguros.Cobertura>() : this.CoberturaViewModel.Coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>());
- List<Gestor.Model.Domain.Seguros.Cobertura> coberturas1 = coberturas;
- Item item = new Item();
- item.set_Documento(this.ItemSelecionado.get_Documento());
- Item item1 = item;
- ordem = (substituir ? base.ItemSubstituido.get_Ordem() : new int?(await base.QuantidadeDeItens(this.ItemSelecionado.get_Documento().get_Controle().get_Id())));
- item1.set_Ordem(ordem);
- Item item2 = item;
- Vida vida = new Vida();
- vida.set_Item(this.SelectedItem);
- item2.set_Vida(vida);
- Item item3 = item;
- if (substituir)
- {
- nullable = new long?(base.ItemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- item3.set_Substituicao(nullable);
- Item item4 = item;
- item1 = null;
- item = null;
- base.Titulares = new ObservableCollection<TitularesVida>();
- ordem = item4.get_Ordem();
- if (ordem.GetValueOrDefault() == 2)
- {
- if (!await base.ShowMessage("ESTA APÓLICE SERÁ UMA FROTA, DESEJA CONTINUAR?", "SIM", "NÃO", false))
- {
- coberturas1 = null;
- item4 = null;
- return;
- }
- }
- bool valueOrDefault = substituir;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA COPIAR OS DADOS DO ITEM?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.SelectedItem = item4;
- this.SelectedItem.get_Vida().set_Item(item4);
- }
- else
- {
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- }
- ordem = item4.get_Ordem();
- int num = 1;
- valueOrDefault = ordem.GetValueOrDefault() > num & ordem.HasValue;
- if (valueOrDefault)
- {
- valueOrDefault = await base.ShowMessage("DESEJA REPLICAR AS COBERTURAS DO ITEM SELECIONADO?", "SIM", "NÃO", false);
- }
- if (!valueOrDefault)
- {
- this.CoberturaViewModel.CarregaPadrao();
- }
- else
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- if (substituir)
- {
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- coberturas1.ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- base.Alterar(true);
- coberturas1 = null;
- item4 = null;
- }
-
- public void Manter(Item item, ManutencaoItem manutencao)
- {
- if (manutencao.get_Tipo() == 1)
- {
- base.ItemSubstituido = item;
- }
- this.Manter(manutencao);
- base.Mantido = true;
- }
-
- public void Manter(ManutencaoItem manutencao)
- {
- long? nullable;
- object list;
- bool flag;
- ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura> coberturas = this.CoberturaViewModel.Coberturas;
- if (coberturas != null)
- {
- list = coberturas.ToList<Gestor.Model.Domain.Seguros.Cobertura>();
- }
- else
- {
- list = null;
- }
- List<long> nums = new List<long>()
- {
- (long)6,
- (long)7,
- (long)9,
- (long)10,
- (long)47,
- (long)53,
- (long)66
- };
- if (this.SelectedItem.get_Vida() == null)
- {
- this.SelectedItem.set_Vida(new Vida());
- }
- if (this.ItemSelecionado.get_Documento().get_Controle().get_Id() != this.SelectedItem.get_Documento().get_Controle().get_Id())
- {
- Item selectedItem = this.SelectedItem;
- if (selectedItem != null)
- {
- flag = selectedItem.get_Sinistros().Count<ControleSinistro>() > 0;
- }
- else
- {
- flag = false;
- }
- if (flag && manutencao.get_Tipo() == null)
- {
- goto Label1;
- }
- if (!nums.Contains(this.Ramo.get_Id()))
- {
- this.SelectedItem.set_Id((long)0);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- Label1:
- this.SelectedItem.set_Id((long)0);
- this.SelectedItem.get_Vida().set_Id((long)0);
- Label0:
- Item item = this.SelectedItem;
- Item itemSubstituido = base.ItemSubstituido;
- if (itemSubstituido != null)
- {
- nullable = new long?(itemSubstituido.get_Id());
- }
- else
- {
- nullable = null;
- }
- item.set_Substituicao(nullable);
- this.SelectedItem.set_Documento(this.ItemSelecionado.get_Documento());
- if (manutencao.get_Tipo() == null)
- {
- this.SelectedItem.set_Sinistrado(false);
- this.SelectedItem.set_Status("");
- this.SelectedItem.set_Sinistro(null);
- this.SelectedItem.set_Sinistros(null);
- }
- this.CoberturaViewModel.CarregaPadrao();
- this.CoberturaViewModel.Coberturas = new ObservableCollection<Gestor.Model.Domain.Seguros.Cobertura>();
- if (list != null)
- {
- ((List<Gestor.Model.Domain.Seguros.Cobertura>)list).ForEach((Gestor.Model.Domain.Seguros.Cobertura x) => {
- x.set_Item(this.SelectedItem);
- this.CoberturaViewModel.Coberturas.Add(x);
- });
- }
- else
- {
- }
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar(List<TitularesVida> titularesGrid)
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- DateTime? inicio;
- string plano;
- string str;
- string str1;
- bool flag;
- bool flag1;
- bool flag2;
- string str2;
- string str3;
- Item selectedItem = this.SelectedItem;
- if (string.IsNullOrWhiteSpace(this.SelectedItem.get_Descricao()))
- {
- plano = this.SelectedItem.get_Vida().get_Plano();
- if (plano == null)
- {
- plano = "";
- }
- }
- else
- {
- plano = this.SelectedItem.get_Descricao();
- }
- selectedItem.set_Descricao(plano);
- this.SelectedItem.set_Titulares(titularesGrid);
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedItem.Validate();
- if (keyValuePairs1.Count <= 0)
- {
- Item item = this.SelectedItem;
- item.set_Coberturas(await this.CoberturaViewModel.LimpaCoberturas());
- item = null;
- if (this.SelectedItem.get_Documento().get_Ordem() <= 0)
- {
- str = "";
- }
- else if (base.Mantido)
- {
- str = string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem());
- }
- else
- {
- str = (base.ItemSubstituido != null ? string.Format("SUBSTITUIÇÃO DO ITEM {0} NO ENDOSSO ORDEM {1}", base.ItemSubstituido.get_Ordem(), this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM INCLUÍDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- }
- string str4 = str;
- if (this.SelectedItem.get_Id() == 0)
- {
- this.SelectedItem.set_Status(str4);
- }
- await this._itemServico.DeleteTitulares(base.ExcluirTitulares);
- base.ExcluirTitulares = new List<TitularesVida>();
- str1 = (this.SelectedItem.get_Id() == 0 ? "INCLUIU" : "ALTEROU");
- str3 = str1;
- this.SelectedItem = await this._itemServico.Save(this.SelectedItem);
- foreach (TitularesVida titularesVida in titularesGrid)
- {
- titularesVida.set_IdItem(this.SelectedItem.get_Id());
- }
- List<TitularesVida> titularesVidas = new List<TitularesVida>();
- foreach (TitularesVida titularesVida1 in titularesGrid)
- {
- if (titularesVida1.get_Id() != 0)
- {
- TitularesVida titularesVida2 = base.OldTitulares.First<TitularesVida>((TitularesVida x) => x.get_Id() == titularesVida1.get_Id());
- if (titularesVida1.get_Codigo() == titularesVida2.get_Codigo())
- {
- inicio = titularesVida1.get_Inicio();
- DateTime? fim = titularesVida2.get_Inicio();
- if (inicio.HasValue == fim.HasValue)
- {
- flag = (inicio.HasValue ? inicio.GetValueOrDefault() != fim.GetValueOrDefault() : false);
- }
- else
- {
- flag = true;
- }
- if (!flag)
- {
- fim = titularesVida1.get_Fim();
- inicio = titularesVida2.get_Fim();
- if (fim.HasValue == inicio.HasValue)
- {
- flag1 = (fim.HasValue ? fim.GetValueOrDefault() != inicio.GetValueOrDefault() : false);
- }
- else
- {
- flag1 = true;
- }
- if (!flag1 && !(titularesVida1.get_Fatura() != titularesVida2.get_Fatura()) && !(titularesVida1.get_Nome() != titularesVida2.get_Nome()) && !(titularesVida1.get_Observacao() != titularesVida2.get_Observacao()))
- {
- inicio = titularesVida1.get_Nascimento();
- fim = titularesVida2.get_Nascimento();
- if (inicio.HasValue == fim.HasValue)
- {
- flag2 = (inicio.HasValue ? inicio.GetValueOrDefault() != fim.GetValueOrDefault() : false);
- }
- else
- {
- flag2 = true;
- }
- if (!flag2 && !(titularesVida1.get_Cpf() != titularesVida2.get_Cpf()) && !(titularesVida1.get_Matricula() != titularesVida2.get_Matricula()))
- {
- decimal? premio = titularesVida1.get_Premio();
- decimal? capital = titularesVida2.get_Premio();
- if ((premio.GetValueOrDefault() == capital.GetValueOrDefault()) & premio.HasValue == capital.HasValue)
- {
- capital = titularesVida1.get_Capital();
- premio = titularesVida2.get_Capital();
- if ((capital.GetValueOrDefault() == premio.GetValueOrDefault()) & capital.HasValue == premio.HasValue)
- {
- TipoTitular? tipo = titularesVida1.get_Tipo();
- TipoTitular? nullable = titularesVida2.get_Tipo();
- if (tipo.GetValueOrDefault() == nullable.GetValueOrDefault() & tipo.HasValue == nullable.HasValue && (object)titularesVida1.get_Dependente() == (object)titularesVida2.get_Dependente())
- {
- continue;
- }
- }
- }
- }
- }
- }
- }
- titularesVidas.Add(titularesVida1);
- }
- else
- {
- inicio = titularesVida1.get_Inicio();
- if (!inicio.HasValue)
- {
- continue;
- }
- titularesVidas.Add(titularesVida1);
- }
- }
- base.Titulares = new ObservableCollection<TitularesVida>(await this._itemServico.SaveTitulares(titularesVidas));
- if (this._itemServico.Sucesso)
- {
- if (base.ItemSubstituido != null)
- {
- str2 = (base.Mantido ? string.Format("ITEM ALTERADO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()) : string.Format("ITEM SUBSTITUIDO NO ENDOSSO ORDEM {0}", this.SelectedItem.get_Documento().get_Ordem()));
- string str5 = str2;
- await this._itemServico.Substituir(base.ItemSubstituido, this.SelectedItem.get_Id(), str5);
- }
- base.Mantido = false;
- await this.SelecionaItem(this.SelectedItem, false);
- this.ItemSelecionado = this.SelectedItem;
- if (this.Invoke)
- {
- ConsultaViewModel.ItemSelecionado = this.SelectedItem;
- }
- base.ToggleSnackBar(string.Concat(this.Ramo.get_Nome(), " SALVO COM SUCESSO"), true);
- string str6 = string.Concat(str3, " ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable1 = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str6, id, nullable1, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- str3 = null;
- return keyValuePairs;
- }
-
- private async void Seleciona(Item item)
- {
- base.Loading(true);
- await base.PermissaoTela(3);
- await this.SelecionaItem(item, true);
- base.Loading(false);
- }
-
- public async Task SelecionaItem(Item item, bool registrar = true)
- {
- Visibility visibility;
- if (item == null || this.LastAccessId != item.get_Id() || this.LastAccessTela != 9)
- {
- base.Mantido = false;
- List<long> nums = new List<long>()
- {
- (long)6,
- (long)7,
- (long)9,
- (long)10,
- (long)47,
- (long)53,
- (long)66
- };
- if (nums.Contains(this.Ramo.get_Id()))
- {
- VidaViewModel vidaViewModel = this;
- visibility = (this.Ramo.get_Id() == (long)9 ? Visibility.Collapsed : Visibility.Visible);
- vidaViewModel.AtualizarCamposSaude = visibility;
- this.CoberturaViewModel.Ramo = this.Ramo;
- if (this.CoberturaViewModel.CoberturasPadrao == null)
- {
- await this.CoberturaViewModel.SelectionaCoberturas();
- }
- if (item == null || item.get_Id() == 0)
- {
- this.SelectedItem = null;
- this.CoberturaViewModel.Coberturas = null;
- base.IsVisible = Visibility.Visible;
- base.Titulares = new ObservableCollection<TitularesVida>();
- }
- else
- {
- base.Loading(true);
- item = await this._itemServico.BuscarItemPorIdAsync(item.get_Id());
- Item item1 = item;
- Vida vida = await this._itemServico.BuscaVida(item.get_Id());
- item1.set_Vida(vida);
- item1 = null;
- await base.CarregarTitulares(item.get_Id());
- this.SelectedItem = item;
- this.SelectedItem.Initialize();
- this.Initialized = true;
- this.CoberturaViewModel.Item = item;
- await this.CoberturaViewModel.CancelarAlteracao();
- if (registrar)
- {
- string str = string.Concat("ACESSOU ITEM DE DESCRIÇÃO \"", this.SelectedItem.get_Descricao(), "\"");
- long id = this.SelectedItem.get_Id();
- TipoTela? nullable = new TipoTela?(3);
- object[] objArray = new object[] { this.SelectedItem.get_Id(), this.SelectedItem.get_Documento().get_Id(), this.SelectedItem.get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedItem.get_Documento().get_Controle().get_Cliente().get_Id() };
- base.RegistrarAcao(str, id, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}", objArray));
- }
- this.LastAccessId = this.SelectedItem.get_Id();
- this.LastAccessTela = 3;
- this.CodigoItem = this.SelectedItem.get_Id().ToString();
- base.Loading(false);
- }
- }
- }
- }
-
- public async void Substituir(Item item)
- {
- base.ItemSubstituido = item;
- await this.Incluir(true);
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/PerfilEmpresaViewModel.cs b/Gestor.Application/ViewModels/Seguros/PerfilEmpresaViewModel.cs deleted file mode 100644 index 0c116ab..0000000 --- a/Gestor.Application/ViewModels/Seguros/PerfilEmpresaViewModel.cs +++ /dev/null @@ -1,274 +0,0 @@ -using Gestor.Application.Helpers;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using Gestor.Model.Helper;
-using Gestor.Model.Resources;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Gestor.Application.ViewModels.Seguros
-{
- public class PerfilEmpresaViewModel : BaseViewModel
- {
- private readonly PerfilEmpresaServico _servico;
-
- private readonly Controle _controle;
-
- private Visibility _ativaCampos = Visibility.Collapsed;
-
- private string _equipamentoSeguranca = "";
-
- private string _equipamentoIncendio = "";
-
- private bool _enableIncluirPerfil;
-
- private string _dataConstrucao;
-
- public long CancelPerfil;
-
- private PerfilEmpresa _selectedPerfilEmpresa = new PerfilEmpresa();
-
- public Visibility AtivaCampos
- {
- get
- {
- return this._ativaCampos;
- }
- set
- {
- this._ativaCampos = value;
- base.OnPropertyChanged("AtivaCampos");
- }
- }
-
- public string DataConstrucao
- {
- get
- {
- return this._dataConstrucao;
- }
- set
- {
- string str;
- if (value != null)
- {
- str = value.Replace(" ", "");
- }
- else
- {
- str = null;
- }
- this._dataConstrucao = str;
- base.OnPropertyChanged("DataConstrucao");
- }
- }
-
- public bool EnableIncluirPerfil
- {
- get
- {
- return this._enableIncluirPerfil;
- }
- set
- {
- this._enableIncluirPerfil = value;
- base.OnPropertyChanged("EnableIncluirPerfil");
- }
- }
-
- public string EquipamentoIncendio
- {
- get
- {
- return this._equipamentoIncendio;
- }
- set
- {
- this._equipamentoIncendio = value;
- base.OnPropertyChanged("EquipamentoIncendio");
- }
- }
-
- public string EquipamentoSeguranca
- {
- get
- {
- return this._equipamentoSeguranca;
- }
- set
- {
- this._equipamentoSeguranca = value;
- base.OnPropertyChanged("EquipamentoSeguranca");
- }
- }
-
- public PerfilEmpresa SelectedPerfilEmpresa
- {
- get
- {
- return this._selectedPerfilEmpresa;
- }
- set
- {
- long? nullable;
- this._selectedPerfilEmpresa = value;
- if (value != null && value.get_Id() > (long)0)
- {
- this.CancelPerfil = value.get_Id();
- }
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedPerfilEmpresa");
- }
- }
-
- public PerfilEmpresaViewModel(Controle controle)
- {
- this._servico = new PerfilEmpresaServico();
- this._controle = controle;
- this.Seleciona(controle.get_Id());
- }
-
- public void CancelarAlteracao()
- {
- base.Loading(true);
- base.Alterar(false);
- base.Loading(false);
- }
-
- public async Task Excluir()
- {
- if (this.SelectedPerfilEmpresa != null && this.SelectedPerfilEmpresa.get_Id() != 0)
- {
- if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- if (await this._servico.Delete(this.SelectedPerfilEmpresa))
- {
- await this.SelecionaPerfil(this._controle.get_Id());
- base.Loading(false);
- this.EnableIncluirPerfil = true;
- this.AtivaCampos = Visibility.Collapsed;
- this.DataConstrucao = null;
- base.ToggleSnackBar("PERFIL EXCLUÍDO COM SUCESSO", true);
- }
- else
- {
- base.Loading(false);
- }
- }
- }
- }
-
- public void Incluir()
- {
- PerfilEmpresa perfilEmpresa = new PerfilEmpresa();
- perfilEmpresa.set_Controle(this._controle);
- perfilEmpresa.set_Cliente(this._controle.get_Cliente());
- perfilEmpresa.set_ExclusivoDeposito(new bool?(false));
- perfilEmpresa.set_DivisaTerrenoBaldio(new bool?(false));
- perfilEmpresa.set_PatrimonioHistorio(new bool?(false));
- perfilEmpresa.set_PossuiTelhado(new bool?(false));
- perfilEmpresa.set_CaixasEletronicos(new bool?(false));
- perfilEmpresa.set_Isopainel(new bool?(false));
- perfilEmpresa.set_ConstrucaoReforma(new bool?(false));
- this.SelectedPerfilEmpresa = perfilEmpresa;
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedPerfilEmpresa.Validate();
- keyValuePairs1 = this.ValidateCampos(keyValuePairs1);
- if (keyValuePairs1.Count <= 0)
- {
- if (this.DataConstrucao != null && this.DataConstrucao != "")
- {
- this.SelectedPerfilEmpresa.set_AnoConstrucao(new DateTime?(DateTime.Parse(string.Concat("01/01/", this.DataConstrucao))));
- }
- this.SelectedPerfilEmpresa = await this._servico.Save(this.SelectedPerfilEmpresa);
- if (this._servico.Sucesso)
- {
- await this.SelecionaPerfil(this._controle.get_Id());
- base.ToggleSnackBar("PERFIL SALVO COM SUCESSO", true);
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- return keyValuePairs;
- }
-
- private async void Seleciona(long id)
- {
- base.Loading(true);
- await base.PermissaoTela(32);
- await this.SelecionaPerfil(id);
- base.Loading(false);
- }
-
- private async Task SelecionaPerfil(long id)
- {
- base.Loading(true);
- this.SelectedPerfilEmpresa = await this._servico.BuscarPerfis(id);
- if (this.SelectedPerfilEmpresa == null)
- {
- this.EnableIncluirPerfil = true;
- this.EquipamentoSeguranca = "";
- this.EquipamentoIncendio = "";
- }
- else
- {
- this.EquipamentoSeguranca = BindingEnumHelper.ConcatenarDescricoesEnum<Gestor.Model.Common.EquipamentoSeguranca>(this.SelectedPerfilEmpresa.get_EquipamentoSeguranca());
- this.EquipamentoIncendio = BindingEnumHelper.ConcatenarDescricoesEnum<Gestor.Model.Common.EquipamentoIncendio>(this.SelectedPerfilEmpresa.get_EquipamentoIncendio());
- if (this.SelectedPerfilEmpresa.get_AnoConstrucao().HasValue)
- {
- DateTime? anoConstrucao = this.SelectedPerfilEmpresa.get_AnoConstrucao();
- this.DataConstrucao = anoConstrucao.Value.Year.ToString();
- }
- }
- base.Loading(false);
- }
-
- private List<KeyValuePair<string, string>> ValidateCampos(List<KeyValuePair<string, string>> errorMessages)
- {
- int num;
- int num1;
- if (this.DataConstrucao == null)
- {
- ValidationHelper.AddValue<string, string>(errorMessages, "ANO DA CONSTRUÇÃO", Messages.get_DataInvalida(), true);
- }
- if (!int.TryParse(this.DataConstrucao, out num))
- {
- ValidationHelper.AddValue<string, string>(errorMessages, "ANO DA CONSTRUÇÃO", Messages.get_DataInvalida(), true);
- }
- if (this.DataConstrucao != null && int.TryParse(this.DataConstrucao, out num1) && (int.Parse(this.DataConstrucao) <= 1755 || int.Parse(this.DataConstrucao) >= 9999))
- {
- ValidationHelper.AddValue<string, string>(errorMessages, "ANO DA CONSTRUÇÃO", Messages.get_DataInvalida(), true);
- }
- return errorMessages;
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/PerfilViewModel.cs b/Gestor.Application/ViewModels/Seguros/PerfilViewModel.cs deleted file mode 100644 index dd3313a..0000000 --- a/Gestor.Application/ViewModels/Seguros/PerfilViewModel.cs +++ /dev/null @@ -1,183 +0,0 @@ -using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-
-namespace Gestor.Application.ViewModels.Seguros
-{
- public class PerfilViewModel : BaseViewModel
- {
- private readonly PerfilServico _servico;
-
- private readonly Controle _controle;
-
- public long CancelPerfil;
-
- private Perfil _selectedPerfil = new Perfil();
-
- private ObservableCollection<Perfil> _perfis;
-
- public ObservableCollection<Perfil> Perfis
- {
- get
- {
- return this._perfis;
- }
- set
- {
- this._perfis = value;
- base.OnPropertyChanged("Perfis");
- }
- }
-
- public Perfil SelectedPerfil
- {
- get
- {
- return this._selectedPerfil;
- }
- set
- {
- long? nullable;
- this._selectedPerfil = value;
- if (value != null && value.get_Id() > (long)0)
- {
- this.CancelPerfil = value.get_Id();
- }
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedPerfil");
- }
- }
-
- public PerfilViewModel(Controle controle)
- {
- this._servico = new PerfilServico();
- this._controle = controle;
- this.Seleciona(controle.get_Id());
- }
-
- public void CancelarAlteracao()
- {
- base.Loading(true);
- if (this.CancelPerfil > (long)0)
- {
- this.SelectedPerfil = this.Perfis.FirstOrDefault<Perfil>((Perfil x) => x.get_Id() == this.CancelPerfil);
- }
- base.Alterar(false);
- base.Loading(false);
- }
-
- public async Task Excluir()
- {
- if (this.SelectedPerfil != null && this.SelectedPerfil.get_Id() != 0)
- {
- if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- bool selectedPerfil = (object)this.SelectedPerfil == (object)this.Perfis.Last<Perfil>();
- if (await this._servico.Delete(this.SelectedPerfil))
- {
- if (selectedPerfil)
- {
- int num = this.Perfis.IndexOf(this.SelectedPerfil);
- if (num <= 0)
- {
- await this.SelecionaPerfis(this._controle.get_Id(), (long)0);
- }
- else
- {
- await this.SelecionaPerfis(this._controle.get_Id(), this.Perfis[num - 1].get_Id());
- }
- }
- else if (this.Perfis.Count > 0)
- {
- await this.SelecionaPerfis(this._controle.get_Id(), this.Perfis[this.Perfis.IndexOf(this.SelectedPerfil) + 1].get_Id());
- }
- base.Loading(false);
- base.ToggleSnackBar("PERFIL EXCLUÍDO COM SUCESSO", true);
- }
- else
- {
- base.Loading(false);
- }
- }
- }
- }
-
- public void Incluir()
- {
- Perfil perfil = new Perfil();
- perfil.set_Controle(this._controle);
- perfil.set_Cliente(this._controle.get_Cliente());
- perfil.set_UsoProfissional(new bool?(false));
- perfil.set_AntiFurto(new Antifurto?(0));
- perfil.set_Isencao(new bool?(false));
- perfil.set_SeguroVida(new bool?(false));
- perfil.set_EstenderCobertura(new bool?(false));
- this.SelectedPerfil = perfil;
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedPerfil.Validate();
- if (keyValuePairs1.Count <= 0)
- {
- this.SelectedPerfil = await this._servico.Save(this.SelectedPerfil);
- if (this._servico.Sucesso)
- {
- await this.SelecionaPerfis(this._controle.get_Id(), this.SelectedPerfil.get_Id());
- base.ToggleSnackBar("PERFIL SALVO COM SUCESSO", true);
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- return keyValuePairs;
- }
-
- private async void Seleciona(long id)
- {
- base.Loading(true);
- await base.PermissaoTela(32);
- await this.SelecionaPerfis(id, (long)0);
- base.Loading(false);
- }
-
- private async Task SelecionaPerfis(long id, long perfilId = 0L)
- {
- Perfil perfil;
- base.Loading(true);
- this.Perfis = new ObservableCollection<Perfil>(await this._servico.BuscarPerfis(id));
- PerfilViewModel perfilViewModel = this;
- perfil = (perfilId == 0 ? this.Perfis.FirstOrDefault<Perfil>() : this.Perfis.First<Perfil>((Perfil x) => x.get_Id() == perfilId));
- perfilViewModel.SelectedPerfil = perfil;
- base.Loading(false);
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/SinistroViewModel.cs b/Gestor.Application/ViewModels/Seguros/SinistroViewModel.cs deleted file mode 100644 index c7359e8..0000000 --- a/Gestor.Application/ViewModels/Seguros/SinistroViewModel.cs +++ /dev/null @@ -1,2104 +0,0 @@ -using Gestor.Application.Drawers;
-using Gestor.Application.Helpers;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Application.Views.Ferramentas;
-using Gestor.Application.Views.Generic;
-using Gestor.Common.Validation;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Configuracoes;
-using Gestor.Model.Domain.Ferramentas;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.MalaDireta;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-using System.Windows;
-
-namespace Gestor.Application.ViewModels.Seguros
-{
- public class SinistroViewModel : BaseSegurosViewModel
- {
- private readonly SinistroServico _servico;
-
- private readonly ItemServico _itemServico;
-
- private readonly Documento _documentoSelecionado;
-
- private readonly ClienteServico _clienteServico;
-
- private bool _editarObservacao = Recursos.Configuracoes.Any<ConfiguracaoSistema>(new Func<ConfiguracaoSistema, bool>((ConfiguracaoSistema x) => x.get_Configuracao() == 49));
-
- private bool _isAnotacoes = true;
-
- private List<TipoPerda> _tipoPerdaAuto = new List<TipoPerda>()
- {
- 1,
- 2,
- 4,
- 3,
- 8
- };
-
- private List<TipoPerda> _tipoPerdaVida = new List<TipoPerda>()
- {
- 5,
- 6,
- 7,
- 8
- };
-
- private Credencial _selectedCredencial = new Credencial();
-
- private List<Credencial> _credenciais = new List<Credencial>();
-
- private ObservableCollection<Item> _itens = new ObservableCollection<Item>();
-
- private ObservableCollection<Item> _itensFiltrados = new ObservableCollection<Item>();
-
- private ObservableCollection<Parceiro> _parceiros = new ObservableCollection<Parceiro>(SinistroViewModel.GerarParceiros());
-
- private bool _habilitarImprimirHistorico;
-
- private bool _habilitarEnviarHistorico;
-
- private Visibility _isVisibleImprimirHistorico;
-
- private Visibility _isVisibleIncluir;
-
- private Visibility _isVisibleTerceiro = Visibility.Collapsed;
-
- private Visibility _visibilityAuto = Visibility.Collapsed;
-
- private Visibility _visibilityVida = Visibility.Collapsed;
-
- private Visibility _liquidacaoVisibility;
-
- private bool _isReadOnlyItem = true;
-
- private bool _tipoSinistroEnabled;
-
- private Item _selectedItem = new Item();
-
- private bool _mostrarLista;
-
- private bool _isExpandedItem = true;
-
- private bool _isExpandedSinistro = true;
-
- private List<ControleSinistro> _controles = new List<ControleSinistro>();
-
- private ObservableCollection<ControleSinistro> _controlesFiltrados = new ObservableCollection<ControleSinistro>();
-
- private ControleSinistro _selectedControle = new ControleSinistro();
-
- private Sinistro _selectedSinistro;
-
- private string _codigoSinistro;
-
- private string _anotacoes;
-
- private string _anotacoesInternas;
-
- private string _telefonesMecanica;
-
- private string _telefonesFunileiro;
-
- public new string Anotacoes
- {
- get
- {
- return this._anotacoes;
- }
- set
- {
- this._anotacoes = value;
- base.OnPropertyChanged("Anotacoes");
- }
- }
-
- public string AnotacoesInternas
- {
- get
- {
- return this._anotacoesInternas;
- }
- set
- {
- this._anotacoesInternas = value;
- base.OnPropertyChanged("AnotacoesInternas");
- }
- }
-
- private bool Carregando
- {
- get;
- set;
- }
-
- public string CodigoSinistro
- {
- get
- {
- return this._codigoSinistro;
- }
- set
- {
- this._codigoSinistro = value;
- base.OnPropertyChanged("CodigoSinistro");
- }
- }
-
- public List<ControleSinistro> Controles
- {
- get
- {
- return this._controles;
- }
- set
- {
- this._controles = value;
- base.EnableIncluir = (value == null ? true : value.Count == 0);
- base.OnPropertyChanged("Controles");
- }
- }
-
- public ObservableCollection<ControleSinistro> ControlesFiltrados
- {
- get
- {
- return this._controlesFiltrados;
- }
- set
- {
- this._controlesFiltrados = value;
- this.IsExpandedSinistro = (value != null ? value.Count > 0 : false);
- base.OnPropertyChanged("ControlesFiltrados");
- }
- }
-
- public List<Credencial> Credenciais
- {
- get
- {
- return this._credenciais;
- }
- set
- {
- this._credenciais = value;
- base.OnPropertyChanged("Credenciais");
- }
- }
-
- public bool EditarObservacao
- {
- get
- {
- return this._editarObservacao;
- }
- set
- {
- this._editarObservacao = value;
- base.OnPropertyChanged("EditarObservacao");
- }
- }
-
- public int FiltroItens
- {
- get;
- set;
- }
-
- public bool HabilitarEnviarHistorico
- {
- get
- {
- return this._habilitarEnviarHistorico;
- }
- set
- {
- this._habilitarEnviarHistorico = value;
- base.OnPropertyChanged("HabilitarEnviarHistorico");
- }
- }
-
- public bool HabilitarImprimirHistorico
- {
- get
- {
- return this._habilitarImprimirHistorico;
- }
- set
- {
- this._habilitarImprimirHistorico = value;
- base.OnPropertyChanged("HabilitarImprimirHistorico");
- }
- }
-
- public bool IsAnotacoes
- {
- get
- {
- return this._isAnotacoes;
- }
- set
- {
- this._isAnotacoes = value;
- base.OnPropertyChanged("IsAnotacoes");
- }
- }
-
- public bool IsExpandedItem
- {
- get
- {
- return this._isExpandedItem;
- }
- set
- {
- this._isExpandedItem = value;
- base.OnPropertyChanged("IsExpandedItem");
- }
- }
-
- public bool IsExpandedSinistro
- {
- get
- {
- return this._isExpandedSinistro;
- }
- set
- {
- this._isExpandedSinistro = value;
- base.OnPropertyChanged("IsExpandedSinistro");
- }
- }
-
- public bool IsReadOnlyItem
- {
- get
- {
- return this._isReadOnlyItem;
- }
- set
- {
- this._isReadOnlyItem = value;
- base.OnPropertyChanged("IsReadOnlyItem");
- }
- }
-
- public Visibility IsVisibleImprimirHistorico
- {
- get
- {
- return this._isVisibleImprimirHistorico;
- }
- set
- {
- this._isVisibleImprimirHistorico = value;
- base.OnPropertyChanged("IsVisibleImprimirHistorico");
- }
- }
-
- public Visibility IsVisibleIncluir
- {
- get
- {
- return this._isVisibleIncluir;
- }
- set
- {
- this._isVisibleIncluir = value;
- base.OnPropertyChanged("IsVisibleIncluir");
- }
- }
-
- public Visibility IsVisibleTerceiro
- {
- get
- {
- return this._isVisibleTerceiro;
- }
- set
- {
- this._isVisibleTerceiro = value;
- base.OnPropertyChanged("IsVisibleTerceiro");
- }
- }
-
- public Item ItemSelecionado
- {
- get;
- set;
- }
-
- public ObservableCollection<Item> Itens
- {
- get
- {
- return this._itens;
- }
- set
- {
- this._itens = value;
- base.OnPropertyChanged("Itens");
- }
- }
-
- public ObservableCollection<Item> ItensFiltrados
- {
- get
- {
- return this._itensFiltrados;
- }
- set
- {
- this._itensFiltrados = value;
- this.IsExpandedItem = (value != null ? value.Count > 0 : false);
- base.OnPropertyChanged("ItensFiltrados");
- }
- }
-
- public Visibility LiquidacaoVisibility
- {
- get
- {
- return this._liquidacaoVisibility;
- }
- set
- {
- this._liquidacaoVisibility = value;
- base.OnPropertyChanged("LiquidacaoVisibility");
- }
- }
-
- public bool MostrarLista
- {
- get
- {
- return this._mostrarLista;
- }
- set
- {
- this._mostrarLista = value;
- base.OnPropertyChanged("MostrarLista");
- }
- }
-
- public ObservableCollection<Parceiro> Parceiros
- {
- get
- {
- return this._parceiros;
- }
- set
- {
- this._parceiros = value;
- base.OnPropertyChanged("Parceiros");
- }
- }
-
- public ControleSinistro SelectedControle
- {
- get
- {
- return this._selectedControle;
- }
- set
- {
- bool count;
- this._selectedControle = value;
- if (value != null)
- {
- base.EnableButtons = value.get_Id() > (long)0;
- base.EnableIncluir = value.get_Id() > (long)0;
- this.IsVisibleTerceiro = (value.get_Sinistros() == null || value.get_Sinistros() != null && value.get_Sinistros().Count < 2 ? Visibility.Collapsed : Visibility.Visible);
- this.IsVisibleIncluir = (value.get_Sinistros() == null || !value.get_Sinistros().Any<Sinistro>() ? Visibility.Visible : Visibility.Collapsed);
- if (this.MostrarLista)
- {
- count = true;
- }
- else
- {
- List<ControleSinistro> controles = this.Controles;
- if (controles != null)
- {
- count = controles.Count > 1;
- }
- else
- {
- count = false;
- }
- }
- this.MostrarLista = count;
- }
- base.OnPropertyChanged("SelectedControle");
- }
- }
-
- public Credencial SelectedCredencial
- {
- get
- {
- return this._selectedCredencial;
- }
- set
- {
- this._selectedCredencial = value;
- base.OnPropertyChanged("SelectedCredencial");
- }
- }
-
- public Item SelectedItem
- {
- get
- {
- return this._selectedItem;
- }
- set
- {
- long? nullable;
- this._selectedItem = value;
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedItem");
- }
- }
-
- public Sinistro SelectedSinistro
- {
- get
- {
- return this._selectedSinistro;
- }
- set
- {
- long? nullable;
- this._selectedSinistro = value;
- this.Anotacoes = string.Empty;
- this.AnotacoesInternas = string.Empty;
- this.HabilitarImprimirHistorico = value != null;
- this.HabilitarEnviarHistorico = value != null;
- this.CodigoSinistro = (this.SelectedSinistro == null || this.SelectedSinistro.get_Id() == 0 ? "" : string.Format("CÓDIGO SINISTRO {0}", this.SelectedSinistro.get_Id()));
- if (value != null && value.get_Id() != 0 && (this.LastAccessId != value.get_Id() || this.LastAccessTela != 7))
- {
- base.RegistrarAcao(string.Format("ACESSOU SINISTRO DE ID \"{0}\"", value.get_Id()), value.get_Id(), new TipoTela?(7), string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}\nDESCRIÇÃO: \"{5}\"", new object[] { value.get_ControleSinistro().get_Item().get_Id(), value.get_ControleSinistro().get_Item().get_Documento().get_Id(), value.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Ramo().get_Nome(), value.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Nome(), value.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Id(), value.get_Descricao() }));
- this.LastAccessId = value.get_Id();
- this.LastAccessTela = 7;
- }
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedSinistro");
- }
- }
-
- public string TelefonesFunileiro
- {
- get
- {
- return this._telefonesFunileiro;
- }
- set
- {
- this._telefonesFunileiro = value;
- base.OnPropertyChanged("TelefonesFunileiro");
- }
- }
-
- public string TelefonesMecanica
- {
- get
- {
- return this._telefonesMecanica;
- }
- set
- {
- this._telefonesMecanica = value;
- base.OnPropertyChanged("TelefonesMecanica");
- }
- }
-
- public List<TipoPerda> TipoPerdaAuto
- {
- get
- {
- return this._tipoPerdaAuto;
- }
- set
- {
- this._tipoPerdaAuto = value;
- base.OnPropertyChanged("TipoPerdaAuto");
- }
- }
-
- public List<TipoPerda> TipoPerdaVida
- {
- get
- {
- return this._tipoPerdaVida;
- }
- set
- {
- this._tipoPerdaVida = value;
- base.OnPropertyChanged("TipoPerdaVida");
- }
- }
-
- public bool TipoSinistroEnabled
- {
- get
- {
- return this._tipoSinistroEnabled;
- }
- set
- {
- this._tipoSinistroEnabled = value;
- base.OnPropertyChanged("TipoSinistroEnabled");
- }
- }
-
- public Visibility VisibilityAuto
- {
- get
- {
- return this._visibilityAuto;
- }
- set
- {
- this._visibilityAuto = value;
- base.OnPropertyChanged("VisibilityAuto");
- }
- }
-
- public Visibility VisibilityVida
- {
- get
- {
- return this._visibilityVida;
- }
- set
- {
- this._visibilityVida = value;
- base.OnPropertyChanged("VisibilityVida");
- }
- }
-
- public SinistroViewModel(Item item, bool attached)
- {
- bool documento;
- bool vendedorPrincipal;
- this._servico = new SinistroServico();
- this._itemServico = new ItemServico();
- this._clienteServico = new ClienteServico();
- this._documentoSelecionado = (attached ? ConsultaViewModel.DocumentoSelecionado : item.get_Documento());
- this.FiltroItens = ConsultaViewModel.FiltrarItens;
- this.ItemSelecionado = ConsultaViewModel.ItemSelecionado;
- if (!attached)
- {
- this.FiltroItens = 4;
- this.ItemSelecionado = item;
- }
- if (item != null)
- {
- documento = item.get_Documento();
- }
- else
- {
- documento = false;
- }
- if (documento)
- {
- Documento documentoSelecionado = ConsultaViewModel.DocumentoSelecionado;
- if (documentoSelecionado != null)
- {
- vendedorPrincipal = documentoSelecionado.get_VendedorPrincipal();
- }
- else
- {
- vendedorPrincipal = false;
- }
- if (vendedorPrincipal)
- {
- item.get_Documento().set_VendedorPrincipal(ConsultaViewModel.DocumentoSelecionado.get_VendedorPrincipal());
- }
- }
- this.Seleciona(item);
- }
-
- public void AbrirInfo()
- {
- base.ShowDrawer(new InfoDrawer(this._documentoSelecionado, false), 0, false);
- }
-
- public async Task<Cliente> BuscarClienteSinistro()
- {
- Cliente cliente = await this._itemServico.BuscarCliente(this.SelectedItem.get_Id());
- return cliente;
- }
-
- public async void CancelarAlteracao()
- {
- //
- // Current member / type: System.Void Gestor.Application.ViewModels.Seguros.SinistroViewModel::CancelarAlteracao()
- // File path: C:\AggerSeguros\Gestor.Application.exe
- //
- // Product version: 0.0.0.0
- // Exception in: System.Void CancelarAlteracao()
- //
- // Object reference not set to an instance of an object.
- // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.FindLowestCommonAncestor(ICollection`1 typeNodes) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 515
- // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.MergeWithLowestCommonAncestor() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 459
- // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.ProcessSingleConstraints() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 378
- // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.InferTypes() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 331
- // at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.Process(DecompilationContext theContext, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\ExpressionDecompilerStep.cs:line 104
- // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100
- // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72
- // at Telerik.JustDecompiler.Decompiler.Extensions.DecompileStateMachine(MethodBody body, DecompilationContext enclosingContext, BaseStateMachineRemoverStep removeStateMachineStep, Func`2 stateMachineDataSelector, DecompilationContext& decompilationContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 112
- // at Telerik.JustDecompiler.Decompiler.Extensions.DecompileAsyncStateMachine(MethodBody body, DecompilationContext enclosingContext, AsyncData& asyncData) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 150
- // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.GetMoveNextStatements() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 161
- // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.Match() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 76
- // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.Process(DecompilationContext context, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 36
- // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100
- // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72
- // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61
- // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 133
- //
- // mailto: JustDecompilePublicFeedback@telerik.com
-
- }
-
- private async Task CarregarControles(Item item)
- {
- List<ControleSinistro> controleSinistros = await this._servico.BuscarControles(item.get_Id());
- SinistroViewModel list = this;
- List<ControleSinistro> controleSinistros1 = controleSinistros;
- list.Controles = (
- from x in controleSinistros1
- orderby x.get_DataSinistro() descending
- select x).ToList<ControleSinistro>();
- this.ControlesFiltrados = new ObservableCollection<ControleSinistro>(this.Controles);
- }
-
- public void CarregarParceiros()
- {
- List<Parceiro> parceiros = new List<Parceiro>();
- Parceiro parceiro = new Parceiro();
- parceiro.set_Nome("NENHUM");
- parceiros.Add(parceiro);
- List<Parceiro> parceiros1 = parceiros;
- parceiros1.AddRange(
- from x in Recursos.Parceiros
- orderby x.get_Nome()
- select x);
- this.Parceiros = new ObservableCollection<Parceiro>(parceiros1);
- }
-
- public async void EnviarLogEmail()
- {
- int? nullable;
- string nome;
- string email;
- int? ordem;
- List<Credencial> credenciais = this.Credenciais;
- if (credenciais == null)
- {
- credenciais = await (new BaseServico()).BuscarCredenciais();
- }
- this.Credenciais = credenciais;
- SinistroViewModel sinistroViewModel = this;
- List<Credencial> credencials = this.Credenciais;
- Credencial credencial = credencials.FirstOrDefault<Credencial>((Credencial x) => x.get_IdUsuario() == Recursos.Usuario.get_Id());
- if (credencial == null)
- {
- credencial = this.Credenciais.FirstOrDefault<Credencial>();
- }
- sinistroViewModel.SelectedCredencial = credencial;
- ObservableCollection<ClienteEmail> observableCollection = await this._clienteServico.BuscarEmailsAsync(this.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Id());
- if (observableCollection.Count != 0)
- {
- Documento documento = await (new ApoliceServico()).BuscarApoliceAsync(this._documentoSelecionado.get_Id(), false, false);
- SinistroViewModel sinistroViewModel1 = this;
- Vendedor vendedorPrincipal = documento.get_VendedorPrincipal();
- if (vendedorPrincipal != null)
- {
- nome = vendedorPrincipal.get_Nome();
- }
- else
- {
- nome = null;
- }
- string str = sinistroViewModel1.GerarHtmlSinistro(nome);
- string str1 = (new Regex("<title>.*<\\/title>")).Replace(str, " ").Trim();
- str1 = (new Regex("(<[^>]*>)|(p\\s?{[^}]*})|(\\r)|(\\n)")).Replace(str1, " ").Trim();
- str1 = str1.Replace("@page{ size: A4;} body; -webkit-print-color-adjust: exact; }", " ");
- str1 = str1.Replace("NEW P { MARGIN-BOTTOM: 0; MARGIN-TOP: 0; }", " ");
- MalaDireta malaDiretum = new MalaDireta();
- malaDiretum.set_Cliente(documento.get_Controle().get_Cliente());
- malaDiretum.set_ArquivoDigital(null);
- malaDiretum.set_Sinistro(this.SelectedSinistro);
- malaDiretum.set_Item(this.SelectedItem);
- malaDiretum.set_Apolice(documento);
- malaDiretum.set_Tela(7);
- ClienteEmail clienteEmail = observableCollection.FirstOrDefault<ClienteEmail>();
- if (clienteEmail != null)
- {
- email = clienteEmail.get_Email();
- }
- else
- {
- email = null;
- }
- malaDiretum.set_Email(email);
- ClienteEmail clienteEmail1 = observableCollection.FirstOrDefault<ClienteEmail>();
- if (clienteEmail1 != null)
- {
- ordem = clienteEmail1.get_Ordem();
- }
- else
- {
- nullable = null;
- ordem = nullable;
- }
- nullable = ordem;
- malaDiretum.set_Ordem(nullable.GetValueOrDefault());
- MalaDireta malaDiretum1 = malaDiretum;
- if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL"))
- {
- Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL");
- }
- List<MalaDireta> malaDiretas = new List<MalaDireta>()
- {
- malaDiretum1
- };
- (new HosterWindow(new MalaDiretaView(malaDiretas, string.Concat("HISTÓRICO DO SINISTRO DO ITEM ", this.SelectedItem.get_Descricao()), str, null), "ENVIO DE E-MAIL", new double?((double)1200), new double?((double)600), true)).ShowDialog();
- }
- else
- {
- await base.ShowMessage("O CLIENTE NÃO POSSUI NENHUM E-MAIL CADASTRADO", "OK", "", false);
- }
- observableCollection = null;
- }
-
- public async void Excluir()
- {
- Sinistro sinistro;
- int? nullable;
- bool valueOrDefault;
- bool flag;
- Sinistro sinistro1;
- int num;
- ControleSinistro controleSinistro;
- if (this.SelectedSinistro != null && this.SelectedSinistro.get_Id() != 0)
- {
- if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- base.Loading(true);
- string str = string.Format("EXCLUIU SINISTRO DE ID \"{0}\"", this.SelectedSinistro.get_Id());
- long id = this.SelectedSinistro.get_Id();
- TipoTela? nullable1 = new TipoTela?(7);
- object[] objArray = new object[] { this.SelectedSinistro.get_ControleSinistro().get_Item().get_Id(), this.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Id(), this.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Ramo().get_Nome(), this.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Nome(), this.SelectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Id(), this.SelectedSinistro.get_Id() };
- base.RegistrarAcao(str, id, nullable1, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}\nDESCRIÇÃO: {5}", objArray));
- if (this.SelectedControle.get_Sinistros().Count == 1)
- {
- List<ControleSinistro> controles = this.Controles;
- controles.Remove(this.SelectedControle);
- SinistroServico sinistroServico = this._servico;
- ControleSinistro selectedControle = this.SelectedControle;
- flag = (controles == null ? true : controles.Count == 0);
- if (await sinistroServico.DeleteControle(selectedControle, flag))
- {
- int num1 = this.ControlesFiltrados.IndexOf(this.SelectedControle);
- this.Controles.Remove(this.SelectedControle);
- this.ControlesFiltrados.Remove(this.SelectedControle);
- this.ControlesFiltrados = new ObservableCollection<ControleSinistro>(this.ControlesFiltrados);
- if (this.ControlesFiltrados.Count <= 0)
- {
- this.SelectedControle = new ControleSinistro();
- base.Alterar(false);
- base.EnableMenu = false;
- }
- else
- {
- SinistroViewModel sinistroViewModel = this;
- if (num1 < this.ControlesFiltrados.Count)
- {
- ObservableCollection<ControleSinistro> controlesFiltrados = this.ControlesFiltrados;
- num = (num1 == 0 ? 1 : num1);
- controleSinistro = controlesFiltrados.ElementAt<ControleSinistro>(num - 1);
- }
- else
- {
- controleSinistro = this.ControlesFiltrados.Last<ControleSinistro>();
- }
- sinistroViewModel.SelectedControle = controleSinistro;
- }
- SinistroViewModel sinistroViewModel1 = this;
- ControleSinistro selectedControle1 = this.SelectedControle;
- if (selectedControle1 != null)
- {
- List<Sinistro> sinistros = selectedControle1.get_Sinistros();
- if (sinistros != null)
- {
- sinistro1 = sinistros.FirstOrDefault<Sinistro>();
- }
- else
- {
- sinistro1 = null;
- }
- }
- else
- {
- sinistro1 = null;
- }
- sinistroViewModel1.SelectedSinistro = sinistro1;
- }
- else
- {
- return;
- }
- }
- else if (await this._servico.Delete(this.SelectedSinistro))
- {
- int num2 = this.SelectedControle.get_Sinistros().IndexOf(this.SelectedSinistro);
- this.SelectedControle.get_Sinistros().Remove(this.SelectedSinistro);
- long id1 = this.SelectedControle.get_Id();
- this.SelectedControle = null;
- this.SelectedControle = this.ControlesFiltrados.First<ControleSinistro>((ControleSinistro x) => x.get_Id() == id1);
- SinistroViewModel sinistroViewModel2 = this;
- sinistro = (num2 < this.SelectedControle.get_Sinistros().Count ? this.SelectedControle.get_Sinistros().ElementAt<Sinistro>(num2) : this.SelectedControle.get_Sinistros().Last<Sinistro>());
- sinistroViewModel2.SelectedSinistro = sinistro;
- }
- else
- {
- return;
- }
- if (this.Controles == null || this.Controles.Count == 0)
- {
- ItemServico itemServico = new ItemServico();
- Item item = await itemServico.BuscarItemPorIdAsync(this.SelectedItem.get_Id());
- item.set_Sinistrado(false);
- await itemServico.Save(item);
- itemServico = null;
- }
- if (this.ItensFiltrados.Count > 0 && this.ItensFiltrados != null)
- {
- Item item1 = this.ItensFiltrados.First<Item>((Item x) => x.get_Id() == this.SelectedItem.get_Id());
- ControleSinistro controleSinistro1 = this.SelectedControle;
- if (controleSinistro1 != null)
- {
- List<Sinistro> sinistros1 = controleSinistro1.get_Sinistros();
- if (sinistros1 != null)
- {
- nullable = new int?(sinistros1.Count);
- }
- else
- {
- nullable = null;
- }
- int? nullable2 = nullable;
- int num3 = 0;
- valueOrDefault = nullable2.GetValueOrDefault() > num3 & nullable2.HasValue;
- }
- else
- {
- valueOrDefault = false;
- }
- item1.set_Sinistrado(valueOrDefault);
- }
- this.ItensFiltrados = new ObservableCollection<Item>(this.ItensFiltrados);
- base.Loading(false);
- base.ToggleSnackBar("SINISTRO EXCLUÍDO COM SUCESSO", true);
- }
- }
- }
-
- public List<Item> FiltrarItem(string filter)
- {
- this.ItensFiltrados = (string.IsNullOrWhiteSpace(filter) ? this.Itens : new ObservableCollection<Item>(
- from x in this.Itens
- where ValidationHelper.RemoveDiacritics(x.get_Descricao().Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
- orderby x.get_Ordem()
- select x));
- return this.ItensFiltrados.ToList<Item>();
- }
-
- public List<ControleSinistro> FiltrarSinistro(string filter)
- {
- ControleSinistro controleSinistro;
- this.ControlesFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<ControleSinistro>(this.Controles) : new ObservableCollection<ControleSinistro>(this.Controles.Where<ControleSinistro>((ControleSinistro x) => {
- if (ValidationHelper.RemoveDiacritics(x.get_DataSinistro().ToString().Trim()).Contains(filter))
- {
- return true;
- }
- if (x.get_Sinistros() == null || x.get_Sinistros().Count <= 0)
- {
- return false;
- }
- return ValidationHelper.RemoveDiacritics(x.get_Sinistros()[0].get_Numero().Trim()).Contains(filter);
- }).OrderBy<ControleSinistro, DateTime?>((ControleSinistro x) => x.get_DataSinistro())));
- if (this.ControlesFiltrados.Count > 0)
- {
- controleSinistro = this.ControlesFiltrados.First<ControleSinistro>();
- }
- else
- {
- controleSinistro = null;
- }
- this.SelectedControle = controleSinistro;
- return this.ControlesFiltrados.ToList<ControleSinistro>();
- }
-
- public string GerarHtmlSinistro(string vendedorPrincipal = "")
- {
- DateTime? vigencia2;
- bool? culpado;
- string shortDateString;
- string shortTimeString;
- string str;
- string str1;
- string str2;
- bool valueOrDefault;
- string shortDateString1;
- string str3 = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><meta http-equiv='Content-Language' content='pt-br'><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=yes'><link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'><style type='text/css' media='print'>@page{ size: A4;} body; -webkit-print-color-adjust: exact; }</style><title> HISTÓRICO DO SINISTRO </title></head><body ><div class='-2'>";
- string str4 = "";
- foreach (Sinistro sinistro in
- from x in this.SelectedControle.get_Sinistros()
- orderby x.get_TipoSinistro()
- select x)
- {
- str3 = string.Concat(str3, "<h2 style='text-align: center'>");
- str4 = (string.IsNullOrEmpty(str4) ? "CLIENTE" : string.Concat("TERCEIRO Nº ", sinistro.get_Numero()));
- str3 = string.Concat(str3, str4, "</h2>");
- str3 = string.Concat(str3, "<div class='table-responsive'><table class='table table-bordered' style='width:100%'>");
- int num = 0;
- if (str4 == "CLIENTE")
- {
- string[] nome = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- nome[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- nome[3] = "'><b>CLIENTE: </b>";
- nome[4] = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Nome();
- nome[5] = "</td></tr>";
- str3 = string.Concat(nome);
- num = 1;
- string[] documento = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- documento[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- documento[3] = "'><b>DOCUMENTO DO SEGURADO: </b>";
- documento[4] = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Documento();
- documento[5] = "</td></tr>";
- str3 = string.Concat(documento);
- num = 0;
- string[] apolice = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- apolice[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- apolice[3] = "'><b>APÓLICE: </b>";
- apolice[4] = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Apolice();
- apolice[5] = "</td></tr>";
- str3 = string.Concat(apolice);
- num = 1;
- string[] strArrays = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays[3] = "'><b>VIGÊNCIA INICIAL: </b>";
- DateTime vigencia1 = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Vigencia1();
- strArrays[4] = vigencia1.ToShortDateString();
- strArrays[5] = "</td></tr>";
- str3 = string.Concat(strArrays);
- num = 0;
- vigencia2 = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Vigencia2();
- if (vigencia2.GetValueOrDefault().ToString(new CultureInfo("pt-BR")) != "01/01/0001 00:00:00")
- {
- vigencia2 = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Vigencia2();
- if (vigencia2.HasValue)
- {
- shortDateString1 = vigencia2.GetValueOrDefault().ToShortDateString();
- }
- else
- {
- shortDateString1 = null;
- }
- }
- else
- {
- shortDateString1 = "NÃO POSSUI";
- }
- string str5 = shortDateString1;
- string[] strArrays1 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays1[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays1[3] = "'><b>VIGÊNCIA FINAL: </b>";
- strArrays1[4] = str5;
- strArrays1[5] = "</td></tr>";
- str3 = string.Concat(strArrays1);
- num = 1;
- vendedorPrincipal = (sinistro.get_ControleSinistro().get_Item().get_Documento().get_VendedorPrincipal() == null ? vendedorPrincipal : sinistro.get_ControleSinistro().get_Item().get_Documento().get_VendedorPrincipal().get_Nome());
- string[] strArrays2 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays2[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays2[3] = "'><b>VENDEDOR PRINCIPAL: </b>";
- strArrays2[4] = vendedorPrincipal;
- strArrays2[5] = "</td></tr>";
- str3 = string.Concat(strArrays2);
- num = 0;
- string[] nome1 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- nome1[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- nome1[3] = "'><b>SEGURADORA: </b>";
- nome1[4] = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Seguradora().get_Nome();
- nome1[5] = "</td></tr>";
- str3 = string.Concat(nome1);
- }
- num = 1;
- string[] numero = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- numero[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- numero[3] = "'><b>NÚMERO SINISTRO: </b>";
- numero[4] = sinistro.get_Numero();
- numero[5] = "</td></tr>";
- str3 = string.Concat(numero);
- num = 0;
- string[] strArrays3 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays3[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays3[3] = "'><b>DATA DO SINISTRO: </b>";
- vigencia2 = sinistro.get_ControleSinistro().get_DataSinistro();
- if (vigencia2.HasValue)
- {
- shortDateString = vigencia2.GetValueOrDefault().ToShortDateString();
- }
- else
- {
- shortDateString = null;
- }
- strArrays3[4] = shortDateString;
- strArrays3[5] = "</td></tr>";
- str3 = string.Concat(strArrays3);
- num = 1;
- string[] strArrays4 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays4[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays4[3] = "'><b>HORA DO SINISTRO: </b>";
- vigencia2 = sinistro.get_ControleSinistro().get_HoraSinistro();
- if (vigencia2.HasValue)
- {
- shortTimeString = vigencia2.GetValueOrDefault().ToShortTimeString();
- }
- else
- {
- shortTimeString = null;
- }
- strArrays4[4] = shortTimeString;
- strArrays4[5] = "</td></tr>";
- str3 = string.Concat(strArrays4);
- num = 0;
- string[] strArrays5 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays5[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays5[3] = "'><b>DATA/HORA ABERTURA: </b>";
- vigencia2 = sinistro.get_DataReclamacao();
- strArrays5[4] = vigencia2.ToString();
- strArrays5[5] = "</td></tr>";
- str3 = string.Concat(strArrays5);
- num = 1;
- string[] str6 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- str6[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- str6[3] = "'><b>DATA LIQUIDAÇÃO: </b>";
- vigencia2 = sinistro.get_DataLiquidacao();
- str6[4] = vigencia2.ToString();
- str6[5] = "</td></tr>";
- str3 = string.Concat(str6);
- num = 0;
- string[] itemSinistrado = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- itemSinistrado[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- itemSinistrado[3] = "'><b>DESCRIÇÃO DO BEM SINISTRADO: </b>";
- itemSinistrado[4] = sinistro.get_ItemSinistrado();
- itemSinistrado[5] = "</td></tr>";
- str3 = string.Concat(itemSinistrado);
- num = 1;
- string[] strArrays6 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays6[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays6[3] = "'><b>VALOR ORÇADO: </b>";
- decimal valorOrcado = sinistro.get_ValorOrcado();
- strArrays6[4] = valorOrcado.ToString("C", new CultureInfo("pt-BR", false));
- strArrays6[5] = "</td></tr>";
- str3 = string.Concat(strArrays6);
- num = 0;
- string[] str7 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- str7[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- str7[3] = "'><b>VALOR LIBERADO: </b>";
- valorOrcado = sinistro.get_ValorLiberado();
- str7[4] = valorOrcado.ToString("C", new CultureInfo("pt-BR", false));
- str7[5] = "</td></tr>";
- str3 = string.Concat(str7);
- num = 1;
- string[] strArrays7 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays7[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays7[3] = "'><b>VALOR PAGO: </b>";
- valorOrcado = sinistro.get_ValorPago();
- strArrays7[4] = valorOrcado.ToString("C", new CultureInfo("pt-BR", false));
- strArrays7[5] = "</td></tr>";
- str3 = string.Concat(strArrays7);
- num = 0;
- string[] str8 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- str8[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- str8[3] = "'><b>VALOR FRANQUIA: </b>";
- valorOrcado = sinistro.get_ValorFranquia();
- str8[4] = valorOrcado.ToString("C", new CultureInfo("pt-BR", false));
- str8[5] = "</td></tr>";
- str3 = string.Concat(str8);
- num = 1;
- string[] description = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- description[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- description[3] = "'><b>SITUAÇÃO: </b>";
- description[4] = ValidationHelper.GetDescription(sinistro.get_StatusSinistro());
- description[5] = "</td></tr>";
- str3 = string.Concat(description);
- str3 = string.Concat(str3, "</table></div>");
- if (sinistro.get_SinistroAuto() != null)
- {
- str3 = string.Concat(str3, "<div class='table-responsive'><table class='table table-bordered' style='width:100%'>");
- num = 0;
- string[] numeroBo = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- numeroBo[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- numeroBo[3] = "'><b>NÚMERO B.O.: </b>";
- numeroBo[4] = sinistro.get_SinistroAuto().get_NumeroBo();
- numeroBo[5] = "</td></tr>";
- str3 = string.Concat(numeroBo);
- num = 1;
- string[] description1 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- description1[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- description1[3] = "'><b>TIPO PERDA: </b>";
- description1[4] = ValidationHelper.GetDescription(sinistro.get_SinistroAuto().get_TipoPerda());
- description1[5] = "</td></tr>";
- str3 = string.Concat(description1);
- num = 0;
- string str9 = str3;
- str1 = (num % 2 == 0 ? "WhiteSmoke" : "White");
- culpado = sinistro.get_SinistroAuto().get_Culpado();
- if (string.Concat("<tr><td bgcolor='", str1, "'><b>CONSIDERA-SE CULPADO? </b>", culpado.ToString()) != null)
- {
- SinistroAuto sinistroAuto = sinistro.get_SinistroAuto();
- if (sinistroAuto != null)
- {
- culpado = sinistroAuto.get_Culpado();
- bool flag = false;
- valueOrDefault = culpado.GetValueOrDefault() == flag & culpado.HasValue;
- }
- else
- {
- valueOrDefault = false;
- }
- if (valueOrDefault)
- {
- goto Label1;
- }
- str2 = "SIM</td></tr>";
- goto Label0;
- }
- Label1:
- str2 = "NÃO";
- Label0:
- str3 = string.Concat(str9, str2);
- num = 1;
- string[] strArrays8 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays8[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays8[3] = "'><b>ÚLTIMO DOC. ENVIADO: </b>";
- strArrays8[4] = string.Format("{0:dd/MM/yyyy}", sinistro.get_SinistroAuto().get_UltimoDocEnviado());
- strArrays8[5] = "</td></tr>";
- str3 = string.Concat(strArrays8);
- num = 0;
- string[] endereco = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- endereco[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- endereco[3] = "'><b>ENDEREÇO: </b>";
- endereco[4] = sinistro.get_SinistroAuto().get_Endereco();
- endereco[5] = "</td></tr>";
- str3 = string.Concat(endereco);
- num = 1;
- string[] envolvido = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- envolvido[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- envolvido[3] = "'><b>ENVOLVIDO/PROPRIETÁRIO: </b>";
- envolvido[4] = sinistro.get_SinistroAuto().get_Envolvido();
- envolvido[5] = "</td></tr>";
- str3 = string.Concat(envolvido);
- num = 0;
- string[] motorista = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- motorista[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- motorista[3] = "'><b>MOTORISTA: </b>";
- motorista[4] = sinistro.get_SinistroAuto().get_Motorista();
- motorista[5] = "</td></tr>";
- str3 = string.Concat(motorista);
- num = 1;
- string[] ddd = new string[] { str3, "<tr><td bgcolor='", null, null, null, null, null, null };
- ddd[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- ddd[3] = "'><b>TELEFONE: </b>(";
- ddd[4] = sinistro.get_SinistroAuto().get_Ddd();
- ddd[5] = ") ";
- ddd[6] = sinistro.get_SinistroAuto().get_Telefone();
- ddd[7] = "</td></tr>";
- str3 = string.Concat(ddd);
- num = 0;
- string[] email = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- email[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- email[3] = "'><b>E-MAIL: </b>";
- email[4] = sinistro.get_SinistroAuto().get_Email();
- email[5] = "</td></tr>";
- str3 = string.Concat(email);
- str3 = string.Concat(str3, "</table></div>");
- str3 = string.Concat(str3, "<div class='table-responsive'><table class='table table-bordered' style='width:100%'>");
- num = 1;
- string str10 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() != null ? sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Nome() : "");
- string[] strArrays9 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays9[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays9[3] = "'><b>PARCEIRO MECÂNICA: </b>";
- strArrays9[4] = str10;
- strArrays9[5] = "</td></tr>";
- str3 = string.Concat(strArrays9);
- num = 0;
- string str11 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd1()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone1()) ? "" : string.Concat("(", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd1(), ") ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone1()));
- string str12 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd2()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone2()) ? "" : string.Concat(" / (", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd2(), ") ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone2()));
- string str13 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd3()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone3()) ? "" : string.Concat(" / (", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Ddd3(), ") ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Telefone3()));
- string[] strArrays10 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null, null, null };
- strArrays10[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays10[3] = "'><b>CONTATOS: </b>";
- strArrays10[4] = str11;
- strArrays10[5] = str12;
- strArrays10[6] = str13;
- strArrays10[7] = "</td></tr>";
- str3 = string.Concat(strArrays10);
- num = 1;
- string str14 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null ? "" : sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Email());
- string[] strArrays11 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays11[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays11[3] = "'><b>EMAIL: </b>";
- strArrays11[4] = str14;
- strArrays11[5] = "</td></tr>";
- str3 = string.Concat(strArrays11);
- num = 0;
- string str15 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Endereco()) ? "" : sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Endereco() ?? "");
- string str16 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Numero()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Numero()));
- string str17 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Complemento()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Complemento()));
- string str18 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Bairro()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Bairro()));
- string str19 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Cidade()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Cidade()));
- string str20 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Uf()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Uf()));
- string str21 = (sinistro.get_SinistroAuto().get_ParceiroMecanica() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Cep()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroMecanica().get_Cep()));
- string[] strArrays12 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null, null, null, null, null, null, null };
- strArrays12[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays12[3] = "'><b>ENDEREÇO: </b>";
- strArrays12[4] = str15;
- strArrays12[5] = str16;
- strArrays12[6] = str17;
- strArrays12[7] = str18;
- strArrays12[8] = str19;
- strArrays12[9] = str20;
- strArrays12[10] = str21;
- strArrays12[11] = "</td></tr>";
- str3 = string.Concat(strArrays12);
- str3 = string.Concat(str3, "</table></div>");
- str3 = string.Concat(str3, "<div class='table-responsive'><table class='table table-bordered' style='width:100%'>");
- num = 1;
- str10 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() != null ? sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Nome() : "");
- string[] strArrays13 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays13[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays13[3] = "'><b>PARCEIRO FUNILARIA: </b>";
- strArrays13[4] = str10;
- strArrays13[5] = "</td></tr>";
- str3 = string.Concat(strArrays13);
- num = 0;
- str11 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd1()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone1()) ? "" : string.Concat("(", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd1(), ") ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone1()));
- str12 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd2()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone2()) ? "" : string.Concat(" / (", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd2(), ") ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone2()));
- str13 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd3()) && string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone3()) ? "" : string.Concat(" / (", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Ddd3(), ") ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Telefone3()));
- string[] strArrays14 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null, null, null };
- strArrays14[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays14[3] = "'><b>CONTATOS: </b>";
- strArrays14[4] = str11;
- strArrays14[5] = str12;
- strArrays14[6] = str13;
- strArrays14[7] = "</td></tr>";
- str3 = string.Concat(strArrays14);
- num = 1;
- str14 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null ? "" : sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Email());
- string[] strArrays15 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays15[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays15[3] = "'><b>EMAIL: </b>";
- strArrays15[4] = str14;
- strArrays15[5] = "</td></tr>";
- str3 = string.Concat(strArrays15);
- num = 0;
- str15 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Endereco()) ? "" : sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Endereco() ?? "");
- str16 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Numero()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Numero()));
- str17 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Complemento()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Complemento()));
- str18 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Bairro()) ? "" : string.Concat(", ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Bairro()));
- str19 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Cidade()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Cidade()));
- str20 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Uf()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Uf()));
- str21 = (sinistro.get_SinistroAuto().get_ParceiroFunilaria() == null || string.IsNullOrEmpty(sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Cep()) ? "" : string.Concat(" - ", sinistro.get_SinistroAuto().get_ParceiroFunilaria().get_Cep()));
- string[] strArrays16 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null, null, null, null, null, null, null };
- strArrays16[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays16[3] = "'><b>ENDEREÇO: </b>";
- strArrays16[4] = str15;
- strArrays16[5] = str16;
- strArrays16[6] = str17;
- strArrays16[7] = str18;
- strArrays16[8] = str19;
- strArrays16[9] = str20;
- strArrays16[10] = str21;
- strArrays16[11] = "</td></tr>";
- str3 = string.Concat(strArrays16);
- str3 = string.Concat(str3, "</table></div>");
- }
- if (sinistro.get_SinistroVida() != null)
- {
- str3 = string.Concat(str3, "<div class='table-responsive'><table class='table table-bordered' style='width:100%'>");
- num = 1;
- string[] description2 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- description2[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- description2[3] = "'><b>TIPO PERDA: </b>";
- description2[4] = ValidationHelper.GetDescription(sinistro.get_SinistroVida().get_TipoPerda());
- description2[5] = "</td></tr>";
- str3 = string.Concat(description2);
- num = 0;
- string[] strArrays17 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- strArrays17[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- strArrays17[3] = "'><b>AUXÍLIO FUNERAL: </b>";
- culpado = sinistro.get_SinistroVida().get_AuxFuneral();
- if (culpado.HasValue)
- {
- culpado = sinistro.get_SinistroVida().get_AuxFuneral();
- if (!culpado.Value)
- {
- goto Label3;
- }
- str = "SIM";
- goto Label2;
- }
- Label3:
- str = "NÃO";
- Label2:
- strArrays17[4] = str;
- strArrays17[5] = "</td></tr>";
- str3 = string.Concat(strArrays17);
- num = 1;
- string[] description3 = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- description3[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- description3[3] = "'><b>ESTADO CIVIL: </b>";
- description3[4] = ValidationHelper.GetDescription(sinistro.get_SinistroVida().get_EstadoCivil());
- description3[5] = "</td></tr>";
- str3 = string.Concat(description3);
- num = 0;
- string[] certObito = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- certObito[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- certObito[3] = "'><b>CERTIDÃO DE ÓBITO: </b>";
- certObito[4] = sinistro.get_SinistroVida().get_CertObito();
- certObito[5] = "</td></tr>";
- str3 = string.Concat(certObito);
- num = 1;
- string[] beneficiario = new string[] { str3, "<tr><td bgcolor='", null, null, null, null };
- beneficiario[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
- beneficiario[3] = "'><b>BENEFICIÁRIO: </b>";
- beneficiario[4] = sinistro.get_SinistroVida().get_Beneficiario();
- beneficiario[5] = "</td></tr>";
- str3 = string.Concat(beneficiario);
- str3 = string.Concat(str3, "</table></div>");
- }
- if (!string.IsNullOrWhiteSpace(sinistro.get_Descricao()))
- {
- str3 = string.Concat(str3, "<hr/>");
- str3 = string.Concat(str3, "<h4>DESCRIÇÃO</h4>");
- str3 = string.Concat(str3, "<br>");
- str3 = string.Concat(str3, "<div>", sinistro.get_Descricao(), "</div>");
- }
- if (string.IsNullOrWhiteSpace(sinistro.get_Observacao()))
- {
- continue;
- }
- str3 = string.Concat(str3, "<hr/>");
- str3 = string.Concat(str3, "<h4>HISTÓRICO</h4>");
- str3 = string.Concat(str3, "<br>");
- str3 = string.Concat(str3, "<div>", sinistro.get_Observacao().Replace("<BODY>", "").Replace("</BODY>", ""), "</div>");
- }
- str3 = string.Concat(str3, "</div></body></html>");
- return str3;
- }
-
- private static List<Parceiro> GerarParceiros()
- {
- List<Parceiro> parceiros = new List<Parceiro>();
- Parceiro parceiro = new Parceiro();
- parceiro.set_Nome("NENHUM");
- parceiros.Add(parceiro);
- parceiros.AddRange(
- from x in Recursos.Parceiros
- orderby x.get_Nome()
- select x);
- return parceiros;
- }
-
- internal void ImprimirHistorico()
- {
- string nome;
- Vendedor vendedorPrincipal = this._documentoSelecionado.get_VendedorPrincipal();
- if (vendedorPrincipal != null)
- {
- nome = vendedorPrincipal.get_Nome();
- }
- else
- {
- nome = null;
- }
- string str = this.GerarHtmlSinistro(nome);
- string tempPath = Path.GetTempPath();
- string str1 = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, (TipoTela)7, Funcoes.GetNetworkTime());
- StreamWriter streamWriter = new StreamWriter(str1, true, Encoding.UTF8);
- streamWriter.Write(str);
- streamWriter.Close();
- Process.Start(str1);
- }
-
- public async void IncluirEnvolvido()
- {
- Sinistro sinistro = new Sinistro();
- sinistro.set_ControleSinistro(this.SelectedControle);
- sinistro.set_TipoSinistro(new TipoSinistro?(1));
- sinistro.set_Ativo(true);
- sinistro.set_StatusSinistro(new StatusSinistro?(1));
- Sinistro sinistro1 = sinistro;
- long id = this._documentoSelecionado.get_Controle().get_Ramo().get_Id();
- long num = id - (long)5;
- if (num <= (long)5)
- {
- switch ((uint)num)
- {
- case 0:
- {
- sinistro1.set_SinistroAuto(new SinistroAuto());
- if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false))
- {
- sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime()));
- }
- else
- {
- sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao());
- sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao());
- sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao());
- if (sinistro1.get_SinistroAuto() != null)
- {
- if (this.SelectedSinistro.get_SinistroAuto() == null)
- {
- this.SelectedSinistro.set_SinistroAuto(new SinistroAuto());
- }
- sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco());
- }
- }
- this.IsReadOnlyItem = false;
- this.SelectedSinistro = sinistro1;
- base.Alterar(true);
- sinistro1 = null;
- return;
- }
- case 1:
- case 2:
- case 4:
- case 5:
- {
- sinistro1.set_SinistroVida(new SinistroVida());
- if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false))
- {
- sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime()));
- }
- else
- {
- sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao());
- sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao());
- sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao());
- if (sinistro1.get_SinistroAuto() != null)
- {
- if (this.SelectedSinistro.get_SinistroAuto() == null)
- {
- this.SelectedSinistro.set_SinistroAuto(new SinistroAuto());
- }
- sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco());
- }
- }
- this.IsReadOnlyItem = false;
- this.SelectedSinistro = sinistro1;
- base.Alterar(true);
- sinistro1 = null;
- return;
- }
- case 3:
- {
- if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false))
- {
- sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime()));
- }
- else
- {
- sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao());
- sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao());
- sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao());
- if (sinistro1.get_SinistroAuto() != null)
- {
- if (this.SelectedSinistro.get_SinistroAuto() == null)
- {
- this.SelectedSinistro.set_SinistroAuto(new SinistroAuto());
- }
- sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco());
- }
- }
- this.IsReadOnlyItem = false;
- this.SelectedSinistro = sinistro1;
- base.Alterar(true);
- sinistro1 = null;
- return;
- }
- }
- }
- else
- {
- }
- if (id != (long)37)
- {
- goto Label3;
- }
- sinistro1.set_SinistroAuto(new SinistroAuto());
- if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false))
- {
- sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime()));
- }
- else
- {
- sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao());
- sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao());
- sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao());
- if (sinistro1.get_SinistroAuto() != null)
- {
- if (this.SelectedSinistro.get_SinistroAuto() == null)
- {
- this.SelectedSinistro.set_SinistroAuto(new SinistroAuto());
- }
- sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco());
- }
- }
- this.IsReadOnlyItem = false;
- this.SelectedSinistro = sinistro1;
- base.Alterar(true);
- sinistro1 = null;
- return;
- sinistro1.set_SinistroVida(new SinistroVida());
- if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false))
- {
- sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime()));
- }
- else
- {
- sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao());
- sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao());
- sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao());
- if (sinistro1.get_SinistroAuto() != null)
- {
- if (this.SelectedSinistro.get_SinistroAuto() == null)
- {
- this.SelectedSinistro.set_SinistroAuto(new SinistroAuto());
- }
- sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco());
- }
- }
- this.IsReadOnlyItem = false;
- this.SelectedSinistro = sinistro1;
- base.Alterar(true);
- sinistro1 = null;
- return;
- Label3:
- if (id != (long)53)
- {
- if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false))
- {
- sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime()));
- }
- else
- {
- sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao());
- sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao());
- sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao());
- if (sinistro1.get_SinistroAuto() != null)
- {
- if (this.SelectedSinistro.get_SinistroAuto() == null)
- {
- this.SelectedSinistro.set_SinistroAuto(new SinistroAuto());
- }
- sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco());
- }
- }
- this.IsReadOnlyItem = false;
- this.SelectedSinistro = sinistro1;
- base.Alterar(true);
- sinistro1 = null;
- return;
- }
- else
- {
- sinistro1.set_SinistroVida(new SinistroVida());
- if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false))
- {
- sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime()));
- }
- else
- {
- sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao());
- sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao());
- sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao());
- if (sinistro1.get_SinistroAuto() != null)
- {
- if (this.SelectedSinistro.get_SinistroAuto() == null)
- {
- this.SelectedSinistro.set_SinistroAuto(new SinistroAuto());
- }
- sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco());
- }
- }
- this.IsReadOnlyItem = false;
- this.SelectedSinistro = sinistro1;
- base.Alterar(true);
- sinistro1 = null;
- return;
- }
- if (!await base.ShowMessage("VOCÊ DESEJA COPIAR OS DADOS DO SINISTRADO PARA O TERCEIRO?", "SIM", "NÃO", false))
- {
- sinistro1.set_DataReclamacao(new DateTime?(Funcoes.GetNetworkTime()));
- }
- else
- {
- sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao());
- sinistro1.set_Descricao(this.SelectedSinistro.get_Descricao());
- sinistro1.set_DataReclamacao(this.SelectedSinistro.get_DataReclamacao());
- if (sinistro1.get_SinistroAuto() != null)
- {
- if (this.SelectedSinistro.get_SinistroAuto() == null)
- {
- this.SelectedSinistro.set_SinistroAuto(new SinistroAuto());
- }
- sinistro1.get_SinistroAuto().set_Endereco(this.SelectedSinistro.get_SinistroAuto().get_Endereco());
- }
- }
- this.IsReadOnlyItem = false;
- this.SelectedSinistro = sinistro1;
- base.Alterar(true);
- sinistro1 = null;
- }
-
- public async Task IncluirSinistro()
- {
- Sinistro sinistro;
- long id;
- decimal num;
- ControleSinistro controleSinistro;
- if (this.SelectedItem != null)
- {
- DateTime networkTime = Funcoes.GetNetworkTime();
- ControleSinistro controleSinistro1 = new ControleSinistro();
- controleSinistro1.set_DataSinistro(new DateTime?(networkTime));
- controleSinistro1.set_Item(this.SelectedItem);
- controleSinistro = controleSinistro1;
- ObservableCollection<Cobertura> observableCollection = await this._itemServico.BuscarCoberturasPorItemAsync(this.SelectedItem.get_Id());
- Cobertura cobertura = observableCollection.FirstOrDefault<Cobertura>((Cobertura x) => {
- if (x.get_CoberturaPadrao() == null)
- {
- return false;
- }
- return x.get_CoberturaPadrao().get_Id() == (long)1;
- });
- Sinistro sinistro1 = new Sinistro();
- sinistro1.set_ControleSinistro(controleSinistro);
- sinistro1.set_TipoSinistro(new TipoSinistro?(0));
- sinistro1.set_Ativo(true);
- sinistro1.set_DataReclamacao(new DateTime?(networkTime));
- sinistro1.set_StatusSinistro(new StatusSinistro?(1));
- sinistro1.set_ItemSinistrado(this.SelectedItem.get_Descricao());
- num = (cobertura != null ? cobertura.get_Franquia() : decimal.Zero);
- sinistro1.set_ValorFranquia(num);
- sinistro = sinistro1;
- id = this._documentoSelecionado.get_Controle().get_Ramo().get_Id();
- long num1 = id - (long)5;
- if (num1 <= (long)5)
- {
- switch ((uint)num1)
- {
- case 0:
- {
- goto Label0;
- }
- case 1:
- case 2:
- case 4:
- case 5:
- {
- goto Label1;
- }
- case 3:
- {
- goto Label2;
- }
- }
- }
- else
- {
- }
- if (id != (long)37)
- {
- goto Label3;
- }
- Label0:
- SinistroAuto sinistroAuto = new SinistroAuto();
- sinistroAuto.set_Culpado(new bool?(false));
- sinistro.set_SinistroAuto(sinistroAuto);
- Label2:
- this.IsReadOnlyItem = true;
- this.SelectedControle = controleSinistro;
- this.SelectedSinistro = sinistro;
- base.Alterar(true);
- }
- else
- {
- await base.ShowMessage("NECESSÁRIO INCLUIR O ITEM ANTES DE INCLUIR UM SINISTRO.", "OK", "", false);
- }
- controleSinistro = null;
- return;
- Label1:
- sinistro.set_SinistroVida(new SinistroVida());
- goto Label2;
- Label3:
- if (id != (long)53)
- {
- goto Label2;
- }
- else
- {
- goto Label1;
- }
- goto Label2;
- }
-
- internal async Task<List<Item>> ItemFiltrar(string value)
- {
- List<Item> items = await Task.Run<List<Item>>(() => this.FiltrarItem(value));
- return items;
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- string str;
- bool id;
- bool flag;
- string str1;
- List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedSinistro.Validate();
- if (keyValuePairs1.Count <= 0)
- {
- Sinistro selectedSinistro = this.SelectedSinistro;
- if (selectedSinistro.get_SinistroAuto() != null)
- {
- Parceiro parceiroFunilaria = selectedSinistro.get_SinistroAuto().get_ParceiroFunilaria();
- if (parceiroFunilaria != null)
- {
- id = parceiroFunilaria.get_Id() == (long)0;
- }
- else
- {
- id = false;
- }
- if (id)
- {
- selectedSinistro.get_SinistroAuto().set_ParceiroFunilaria(null);
- }
- Parceiro parceiroMecanica = selectedSinistro.get_SinistroAuto().get_ParceiroMecanica();
- if (parceiroMecanica != null)
- {
- flag = parceiroMecanica.get_Id() == (long)0;
- }
- else
- {
- flag = false;
- }
- if (flag)
- {
- selectedSinistro.get_SinistroAuto().set_ParceiroMecanica(null);
- }
- }
- DateTime networkTime = Funcoes.GetNetworkTime();
- if (!string.IsNullOrWhiteSpace(this.Anotacoes) && !this.Anotacoes.IsEmpty())
- {
- Sinistro sinistro = selectedSinistro;
- object[] nome = new object[] { Recursos.Usuario.get_Nome(), Recursos.Usuario.get_Id(), networkTime, this.Anotacoes, selectedSinistro.get_Observacao() };
- sinistro.set_Observacao(string.Format("<p>{0}, ID: {1}, {2:g}<br>{3}<p/><br><br>{4}", nome));
- }
- if (!string.IsNullOrWhiteSpace(this.AnotacoesInternas) && !this.AnotacoesInternas.IsEmpty())
- {
- Sinistro sinistro1 = selectedSinistro;
- object[] objArray = new object[] { Recursos.Usuario.get_Nome(), Recursos.Usuario.get_Id(), networkTime, this.AnotacoesInternas, selectedSinistro.get_ObservacaoInterna() };
- sinistro1.set_ObservacaoInterna(string.Format("<p>{0}, ID: {1}, {2:g}<br>{3}<p/><br><br>{4}", objArray));
- }
- if (selectedSinistro.get_Id() != 0)
- {
- selectedSinistro.set_DataAlteracao(new DateTime?(DateTime.Now));
- selectedSinistro.set_IdUsuarioAlteracao(Recursos.Usuario.get_Id());
- }
- else
- {
- selectedSinistro.set_DataCriacao(new DateTime?(DateTime.Now));
- selectedSinistro.set_IdUsuarioCriacao(Recursos.Usuario.get_Id());
- }
- str = (selectedSinistro.get_Id() == 0 ? "INCLUIU" : "ALTEROU");
- str1 = str;
- Sinistro sinistro2 = await this._servico.Save(selectedSinistro, this._documentoSelecionado.get_Controle().get_Ramo().get_Id());
- selectedSinistro = sinistro2;
- if (this._servico.Sucesso)
- {
- await this.CarregarControles(selectedSinistro.get_ControleSinistro().get_Item());
- this.SelectedControle = this.ControlesFiltrados.First<ControleSinistro>((ControleSinistro x) => x.get_Id() == selectedSinistro.get_ControleSinistro().get_Id());
- this.SelectedSinistro = this.SelectedControle.get_Sinistros().First<Sinistro>((Sinistro x) => x.get_Id() == selectedSinistro.get_Id());
- Recursos.Parceiros = this.Parceiros.ToList<Parceiro>();
- base.Alterar(false);
- base.ToggleSnackBar("SINISTRO SALVO COM SUCESSO", true);
- string str2 = string.Format("{0} SINISTRO DE ID \"{1}\"", str1, selectedSinistro.get_Id());
- long num = selectedSinistro.get_Id();
- TipoTela? nullable = new TipoTela?(7);
- object[] id1 = new object[] { selectedSinistro.get_ControleSinistro().get_Item().get_Id(), selectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Id(), selectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Ramo().get_Nome(), selectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Nome(), selectedSinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Id(), selectedSinistro.get_Descricao() };
- base.RegistrarAcao(str2, num, nullable, string.Format("ID ITEM: {0}\nID DOCUMENTO: {1}\nRAMO: {2}\nCLIENTE: {3}\nID CLIENTE: {4}\nDESCRIÇÃO: \"{5}\"", id1));
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = keyValuePairs1;
- }
- str1 = null;
- return keyValuePairs;
- }
-
- public async void Seleciona(Item item)
- {
- Visibility visibility;
- Visibility visibility1;
- base.Loading(true);
- await base.PermissaoTela(7);
- this.SelectedItem = this.ItemSelecionado;
- SinistroViewModel sinistroViewModel = this;
- visibility = (this._documentoSelecionado.get_Controle().get_Ramo().get_Id() == (long)5 ? Visibility.Visible : Visibility.Collapsed);
- sinistroViewModel.VisibilityAuto = visibility;
- SinistroViewModel sinistroViewModel1 = this;
- visibility1 = (this._documentoSelecionado.get_Controle().get_Ramo().get_Id() == (long)6 ? Visibility.Visible : Visibility.Collapsed);
- sinistroViewModel1.VisibilityVida = visibility1;
- if (item != null)
- {
- await this.SelecionaControles(item);
- base.Loading(false);
- }
- else
- {
- base.Loading(false);
- }
- }
-
- public void SelecionaControle(ControleSinistro controle)
- {
- List<Sinistro> list;
- bool sinistros;
- if (this.Carregando)
- {
- return;
- }
- this.SelectedControle = controle;
- ControleSinistro selectedControle = this.SelectedControle;
- ControleSinistro controleSinistro = this.SelectedControle;
- if (controleSinistro != null)
- {
- List<Sinistro> sinistros1 = controleSinistro.get_Sinistros();
- if (sinistros1 != null)
- {
- list = (
- from x in sinistros1
- orderby x.get_Id()
- select x).ToList<Sinistro>();
- }
- else
- {
- list = null;
- }
- }
- else
- {
- list = null;
- }
- selectedControle.set_Sinistros(list);
- if (this.Carregando)
- {
- return;
- }
- if (controle.get_Id() != this.SelectedControle.get_Id())
- {
- this.SelectedControle = controle;
- }
- ControleSinistro selectedControle1 = this.SelectedControle;
- if (selectedControle1 != null)
- {
- sinistros = selectedControle1.get_Sinistros();
- }
- else
- {
- sinistros = false;
- }
- if (sinistros)
- {
- this.TipoSinistroEnabled = (!this.SelectedControle.get_Sinistros().Any<Sinistro>((Sinistro x) => {
- TipoSinistro? tipoSinistro = x.get_TipoSinistro();
- return tipoSinistro.GetValueOrDefault() == 0 & tipoSinistro.HasValue;
- }) ? true : this.SelectedControle.get_Sinistros().Count <= 1);
- }
- }
-
- public async Task SelecionaControles(Item item)
- {
- Sinistro sinistro;
- base.Loading(true);
- await this.CarregarControles(item);
- if (this.ControlesFiltrados.Count <= 0)
- {
- this.SelectedControle = new ControleSinistro();
- base.Alterar(false);
- }
- else
- {
- this.SelectedControle = this.ControlesFiltrados.FirstOrDefault<ControleSinistro>();
- }
- SinistroViewModel sinistroViewModel = this;
- ControleSinistro selectedControle = this.SelectedControle;
- if (selectedControle != null)
- {
- List<Sinistro> sinistros = selectedControle.get_Sinistros();
- if (sinistros != null)
- {
- sinistro = sinistros.FirstOrDefault<Sinistro>();
- }
- else
- {
- sinistro = null;
- }
- }
- else
- {
- sinistro = null;
- }
- sinistroViewModel.SelectedSinistro = sinistro;
- base.Loading(false);
- }
-
- public async void SelecionaItem(Item item)
- {
- if (!this.Carregando)
- {
- this.SelectedItem = item;
- if (this.SelectedItem != null)
- {
- if (!this.Carregando)
- {
- if (item.get_Id() != this.SelectedItem.get_Id())
- {
- this.SelectedItem = this.ItensFiltrados.FirstOrDefault<Item>((Item x) => x.get_Id() == item.get_Id());
- }
- await this.SelecionaControles(item);
- }
- }
- }
- }
-
- public async Task SelecionaItens(int type, Item item = null)
- {
- bool count;
- Item item1;
- base.Loading(true);
- this.Carregando = true;
- switch (type)
- {
- case 1:
- case 2:
- {
- this.Itens = await this._itemServico.BuscarItens(this._documentoSelecionado.get_Id(), 2);
- break;
- }
- case 3:
- {
- this.Itens = await this._itemServico.BuscarItens(this._documentoSelecionado.get_Controle().get_Id(), 1);
- break;
- }
- case 4:
- {
- this.Itens = await this._itemServico.BuscarItens(this._documentoSelecionado.get_Controle().get_Id(), 3);
- break;
- }
- default:
- {
- this.Itens = await this._itemServico.BuscarItens(this._documentoSelecionado.get_Controle().get_Id(), 0);
- break;
- }
- }
- this.ItensFiltrados = this.Itens;
- if (item != null && item.get_Id() > (long)0)
- {
- SinistroViewModel sinistroViewModel = this;
- if (this.ItensFiltrados == null || this.ItensFiltrados.Count <= 0)
- {
- item1 = null;
- }
- else
- {
- item1 = this.ItensFiltrados.FirstOrDefault<Item>((Item x) => x.get_Id() == item.get_Id());
- }
- sinistroViewModel.SelectedItem = item1;
- }
- SinistroViewModel sinistroViewModel1 = this;
- if (this.MostrarLista)
- {
- count = true;
- }
- else
- {
- ObservableCollection<Item> itens = this.Itens;
- if (itens != null)
- {
- count = itens.Count > 1;
- }
- else
- {
- count = false;
- }
- }
- sinistroViewModel1.MostrarLista = count;
- this.Carregando = false;
- base.Loading(false);
- }
-
- internal async Task<List<ControleSinistro>> SinistroFiltrar(string value)
- {
- List<ControleSinistro> controleSinistros = await Task.Run<List<ControleSinistro>>(() => this.FiltrarSinistro(value));
- return controleSinistros;
- }
- }
-}
\ No newline at end of file diff --git a/Gestor.Application/ViewModels/Seguros/TrocarClienteViewModel.cs b/Gestor.Application/ViewModels/Seguros/TrocarClienteViewModel.cs deleted file mode 100644 index 35881fd..0000000 --- a/Gestor.Application/ViewModels/Seguros/TrocarClienteViewModel.cs +++ /dev/null @@ -1,92 +0,0 @@ -using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Seguros;
-using System;
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-
-namespace Gestor.Application.ViewModels.Seguros
-{
- public class TrocarClienteViewModel : BaseSegurosViewModel
- {
- private readonly ApoliceServico _apoliceServico;
-
- private readonly ClienteServico _clienteServico;
-
- private Documento _selectedDocumento;
-
- private Cliente _selectedCliente;
-
- public Cliente SelectedCliente
- {
- get
- {
- return this._selectedCliente;
- }
- set
- {
- base.OnPropertyChanged("SelectedCliente");
- this._selectedCliente = value;
- }
- }
-
- public Documento SelectedDocumento
- {
- get
- {
- return this._selectedDocumento;
- }
- set
- {
- base.OnPropertyChanged("SelectedDocumento");
- this._selectedDocumento = value;
- }
- }
-
- public TrocarClienteViewModel()
- {
- this._apoliceServico = new ApoliceServico();
- this._clienteServico = new ClienteServico();
- }
-
- public async Task<bool> Salvar()
- {
- bool flag;
- Cliente cliente;
- Documento selectedDocumento;
- if (this.SelectedCliente == null)
- {
- flag = false;
- }
- else if (this.SelectedCliente.get_Id() != this.SelectedDocumento.get_Controle().get_Cliente().get_Id())
- {
- cliente = await this._clienteServico.BuscarCliente(this.SelectedDocumento.get_Controle().get_Cliente().get_Id());
- selectedDocumento = this.SelectedDocumento;
- this._apoliceServico.Sucesso = true;
- await this._apoliceServico.Save(selectedDocumento.get_Controle(), this.SelectedCliente);
- if (this._apoliceServico.Sucesso)
- {
- base.RegistrarAcao(string.Format("TROCOU O CLIENTE DO DOCUMENTO DE ID {0}", this.SelectedDocumento.get_Id()), this.SelectedDocumento.get_Id(), new TipoTela?(41), string.Format("CLIENTE ANTIGO: {0}\nNOVO CLIENTE: {1} ({2})", cliente.get_Nome(), this.SelectedCliente.get_Nome(), this.SelectedCliente.get_Id()));
- this.SelectedCliente = selectedDocumento.get_Controle().get_Cliente();
- this.SelectedDocumento = selectedDocumento;
- flag = true;
- }
- else
- {
- flag = false;
- }
- }
- else
- {
- flag = false;
- }
- cliente = null;
- selectedDocumento = null;
- return flag;
- }
- }
-}
\ No newline at end of file |