diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Gestor.Application/ViewModels/Drawer/AdiantamentoViewModel.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Gestor.Application/ViewModels/Drawer/AdiantamentoViewModel.cs')
| -rw-r--r-- | Gestor.Application/ViewModels/Drawer/AdiantamentoViewModel.cs | 310 |
1 files changed, 0 insertions, 310 deletions
diff --git a/Gestor.Application/ViewModels/Drawer/AdiantamentoViewModel.cs b/Gestor.Application/ViewModels/Drawer/AdiantamentoViewModel.cs deleted file mode 100644 index 72b47ae..0000000 --- a/Gestor.Application/ViewModels/Drawer/AdiantamentoViewModel.cs +++ /dev/null @@ -1,310 +0,0 @@ -using Assinador.Infrastructure.Helpers;
-using Gestor.Application.Servicos.Ferramentas;
-using Gestor.Application.Servicos.Generic;
-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.Drawer
-{
- public class AdiantamentoViewModel : BaseSegurosViewModel
- {
- private readonly AdiantamentoServico _servico;
-
- private readonly Vendedor _selectedVendedor;
-
- private bool _carregando;
-
- private ObservableCollection<Gestor.Model.Domain.Seguros.Adiantamento> _adiantamento = new ObservableCollection<Gestor.Model.Domain.Seguros.Adiantamento>();
-
- private Gestor.Model.Domain.Seguros.Adiantamento _selectedAdiantamento = new Gestor.Model.Domain.Seguros.Adiantamento();
-
- private bool _logEnabled;
-
- public Gestor.Model.Domain.Seguros.Adiantamento CancelAdiantamento;
-
- public ObservableCollection<Gestor.Model.Domain.Seguros.Adiantamento> Adiantamento
- {
- get
- {
- return this._adiantamento;
- }
- set
- {
- this._adiantamento = value;
- base.OnPropertyChanged("Adiantamento");
- }
- }
-
- public bool Carregando
- {
- get
- {
- return this._carregando;
- }
- set
- {
- this._carregando = value;
- base.IsEnabled = !value;
- base.EnableMenu = !value;
- base.OnPropertyChanged("Carregando");
- }
- }
-
- public bool LogEnabled
- {
- get
- {
- return this._logEnabled;
- }
- set
- {
- this._logEnabled = value;
- base.OnPropertyChanged("LogEnabled");
- }
- }
-
- public Gestor.Model.Domain.Seguros.Adiantamento SelectedAdiantamento
- {
- get
- {
- return this._selectedAdiantamento;
- }
- set
- {
- long? nullable;
- this._selectedAdiantamento = value;
- this.CancelAdiantamento = (value == null || value.get_Id() <= (long)0 ? this.CancelAdiantamento : value);
- if (value != null)
- {
- nullable = new long?(value.get_Id());
- }
- else
- {
- nullable = null;
- }
- base.VerificarEnables(nullable);
- base.OnPropertyChanged("SelectedAdiantamento");
- }
- }
-
- public AdiantamentoViewModel(Vendedor vendedor)
- {
- this._servico = new AdiantamentoServico();
- this.Seleciona(vendedor);
- this._selectedVendedor = vendedor;
- }
-
- public void CancelarAlteracao()
- {
- this.Carregando = true;
- if (this.CancelAdiantamento != null && this.Adiantamento.Any<Gestor.Model.Domain.Seguros.Adiantamento>((Gestor.Model.Domain.Seguros.Adiantamento x) => x.get_Id() == this.CancelAdiantamento.get_Id()))
- {
- DomainBase.Copy<Gestor.Model.Domain.Seguros.Adiantamento, Gestor.Model.Domain.Seguros.Adiantamento>(this.Adiantamento.First<Gestor.Model.Domain.Seguros.Adiantamento>((Gestor.Model.Domain.Seguros.Adiantamento x) => x.get_Id() == this.CancelAdiantamento.get_Id()), this.CancelAdiantamento);
- this.SelectedAdiantamento = this.Adiantamento.First<Gestor.Model.Domain.Seguros.Adiantamento>((Gestor.Model.Domain.Seguros.Adiantamento x) => x.get_Id() == this.CancelAdiantamento.get_Id());
- }
- base.Alterar(false);
- this.Carregando = false;
- }
-
- public async Task CarregarAdiantamento(int index)
- {
- this.Carregando = true;
- this.Adiantamento = new ObservableCollection<Gestor.Model.Domain.Seguros.Adiantamento>(await this._servico.BuscarAdiantamentos(this._selectedVendedor.get_Id(), index != 0));
- if (this.Adiantamento == null || this.Adiantamento.Count <= 0)
- {
- this.LogEnabled = false;
- }
- else
- {
- this.SelectedAdiantamento = this.Adiantamento.First<Gestor.Model.Domain.Seguros.Adiantamento>();
- this.LogEnabled = true;
- }
- this.Carregando = false;
- }
-
- public async Task<bool> Excluir()
- {
- bool flag;
- object obj;
- object obj1;
- Gestor.Model.Domain.Seguros.Adiantamento adiantamento;
- Gestor.Model.Domain.Seguros.Adiantamento adiantamento1;
- if (this.SelectedAdiantamento == null || this.SelectedAdiantamento.get_Id() == 0)
- {
- flag = false;
- }
- else if (await base.ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO", false))
- {
- this.Carregando = true;
- if (await this._servico.Delete(this.SelectedAdiantamento))
- {
- AdiantamentoViewModel adiantamentoViewModel = this;
- string str = string.Concat("EXCLUIU O ADIANTAMENTO DO VENDEDOR \"", this.SelectedAdiantamento.get_Vendedor().get_Nome(), "\"");
- long id = this.SelectedAdiantamento.get_Id();
- TipoTela? nullable = new TipoTela?(36);
- object[] valor = new object[] { this.SelectedAdiantamento.get_Id(), null, null, null, null };
- obj = (!this.SelectedAdiantamento.get_Data().HasValue ? "-" : string.Format("{0:d}", this.SelectedAdiantamento.get_Data()));
- valor[1] = obj;
- valor[2] = this.SelectedAdiantamento.get_Valor();
- valor[3] = Functions.GetDescription(this.SelectedAdiantamento.get_TipoPagamento());
- obj1 = (this.SelectedAdiantamento.get_Pago() ? "SIM" : "NÃO");
- valor[4] = obj1;
- adiantamentoViewModel.RegistrarAcao(str, id, nullable, string.Format("ID: {0}\nDATA: {1}\nVALOR: {2:c}\nTIPO PAGAMENTO: {3}\nPAGO: {4}", valor));
- int num = this.Adiantamento.IndexOf(this.SelectedAdiantamento);
- this.Adiantamento.Remove(this.SelectedAdiantamento);
- this.Adiantamento.Remove(this.SelectedAdiantamento);
- this.Adiantamento = new ObservableCollection<Gestor.Model.Domain.Seguros.Adiantamento>(this.Adiantamento);
- if (this.Adiantamento.Count <= 0)
- {
- this.SelectedAdiantamento = new Gestor.Model.Domain.Seguros.Adiantamento();
- base.Alterar(false);
- base.EnableMenu = false;
- this.LogEnabled = false;
- }
- else
- {
- AdiantamentoViewModel adiantamentoViewModel1 = this;
- adiantamento1 = (num < this.Adiantamento.Count ? this.Adiantamento.ElementAt<Gestor.Model.Domain.Seguros.Adiantamento>(num) : this.Adiantamento.Last<Gestor.Model.Domain.Seguros.Adiantamento>());
- adiantamentoViewModel1.SelectedAdiantamento = adiantamento1;
- this.LogEnabled = true;
- }
- if (this.Adiantamento.Count <= 0)
- {
- this.SelectedAdiantamento = new Gestor.Model.Domain.Seguros.Adiantamento();
- this.LogEnabled = false;
- base.Alterar(false);
- }
- else
- {
- AdiantamentoViewModel adiantamentoViewModel2 = this;
- adiantamento = (num < this.Adiantamento.Count ? this.Adiantamento.ElementAt<Gestor.Model.Domain.Seguros.Adiantamento>(num) : this.Adiantamento.Last<Gestor.Model.Domain.Seguros.Adiantamento>());
- adiantamentoViewModel2.SelecionaAdiantamento(adiantamento);
- this.LogEnabled = true;
- }
- this.Carregando = false;
- flag = true;
- }
- else
- {
- flag = false;
- }
- }
- else
- {
- flag = false;
- }
- return flag;
- }
-
- public void Incluir()
- {
- this.SelectedAdiantamento = new Gestor.Model.Domain.Seguros.Adiantamento();
- base.Alterar(true);
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar()
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- string str;
- object obj;
- object obj1;
- string str1;
- if (!string.IsNullOrWhiteSpace(this.SelectedAdiantamento.get_Historico()))
- {
- this.SelectedAdiantamento.set_Vendedor(this._selectedVendedor);
- str = (this.SelectedAdiantamento.get_Id() == 0 ? "INCLUIU" : "ALTEROU");
- str1 = str;
- Gestor.Model.Domain.Seguros.Adiantamento adiantamento = await this._servico.Save(this.SelectedAdiantamento);
- if (this._servico.Sucesso)
- {
- AdiantamentoViewModel adiantamentoViewModel = this;
- string str2 = string.Concat(str1, " ADIANTAMENTO DO VENDEDOR \"", adiantamento.get_Vendedor().get_Nome(), "\"");
- long id = adiantamento.get_Id();
- TipoTela? nullable = new TipoTela?(36);
- object[] valor = new object[] { adiantamento.get_Id(), null, null, null, null };
- obj = (!adiantamento.get_Data().HasValue ? "-" : string.Format("{0:d}", adiantamento.get_Data()));
- valor[1] = obj;
- valor[2] = adiantamento.get_Valor();
- valor[3] = Functions.GetDescription(adiantamento.get_TipoPagamento());
- obj1 = (adiantamento.get_Pago() ? "SIM" : "NÃO");
- valor[4] = obj1;
- adiantamentoViewModel.RegistrarAcao(str2, id, nullable, string.Format("ID: {0}\nDATA: {1}\nVALOR: {2:c}\nTIPO PAGAMENTO: {3}\nPAGO: {4}", valor));
- if (!this.Adiantamento.Any<Gestor.Model.Domain.Seguros.Adiantamento>((Gestor.Model.Domain.Seguros.Adiantamento x) => x.get_Id() == adiantamento.get_Id()))
- {
- this.Adiantamento.Add(adiantamento);
- }
- else
- {
- DomainBase.Copy<Gestor.Model.Domain.Seguros.Adiantamento, Gestor.Model.Domain.Seguros.Adiantamento>(this.Adiantamento.First<Gestor.Model.Domain.Seguros.Adiantamento>((Gestor.Model.Domain.Seguros.Adiantamento x) => x.get_Id() == adiantamento.get_Id()), adiantamento);
- }
- this.Adiantamento = new ObservableCollection<Gestor.Model.Domain.Seguros.Adiantamento>(this.Adiantamento);
- this.SelectedAdiantamento = this.Adiantamento.First<Gestor.Model.Domain.Seguros.Adiantamento>((Gestor.Model.Domain.Seguros.Adiantamento x) => x.get_Id() == adiantamento.get_Id());
- this.LogEnabled = true;
- base.Alterar(false);
- keyValuePairs = null;
- }
- else
- {
- keyValuePairs = null;
- }
- }
- else
- {
- keyValuePairs = new List<KeyValuePair<string, string>>()
- {
- new KeyValuePair<string, string>("Historico|HISTÓRICO", "OBRIGATÓRIO")
- };
- }
- str1 = null;
- return keyValuePairs;
- }
-
- private async void Seleciona(Vendedor vendedor)
- {
- base.Loading(true);
- await base.PermissaoTela(15);
- await this.SelecionaAdiantamento(vendedor);
- base.Loading(false);
- }
-
- public void SelecionaAdiantamento(Gestor.Model.Domain.Seguros.Adiantamento adiantamento)
- {
- this.SelectedAdiantamento = adiantamento;
- }
-
- private async Task SelecionaAdiantamento(Vendedor vendedor)
- {
- this.Carregando = true;
- List<Gestor.Model.Domain.Seguros.Adiantamento> adiantamentos = await (new BaseServico()).BuscarAdiantamentoAsync(vendedor);
- IOrderedEnumerable<Gestor.Model.Domain.Seguros.Adiantamento> pago =
- from x in adiantamentos
- orderby x.get_Pago()
- select x;
- List<Gestor.Model.Domain.Seguros.Adiantamento> list = pago.ThenBy<Gestor.Model.Domain.Seguros.Adiantamento, decimal>((Gestor.Model.Domain.Seguros.Adiantamento x) => x.get_Valor()).ToList<Gestor.Model.Domain.Seguros.Adiantamento>();
- this.Adiantamento = new ObservableCollection<Gestor.Model.Domain.Seguros.Adiantamento>(list);
- if (this.Adiantamento.Count <= 0)
- {
- this.SelectedAdiantamento = new Gestor.Model.Domain.Seguros.Adiantamento();
- this.LogEnabled = false;
- base.Alterar(false);
- base.VerificarEnables(new long?(this.SelectedAdiantamento.get_Id()));
- base.EnableMenu = false;
- }
- else
- {
- this.SelecionaAdiantamento(this.Adiantamento.First<Gestor.Model.Domain.Seguros.Adiantamento>());
- this.LogEnabled = true;
- }
- this.Carregando = false;
- }
- }
-}
\ No newline at end of file |