summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/ViewModels/Generic/ItemViewModel.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
commit1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch)
treee1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/ViewModels/Generic/ItemViewModel.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/ViewModels/Generic/ItemViewModel.cs')
-rw-r--r--Codemerx/Gestor.Application/ViewModels/Generic/ItemViewModel.cs843
1 files changed, 843 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/ViewModels/Generic/ItemViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Generic/ItemViewModel.cs
new file mode 100644
index 0000000..b8c015a
--- /dev/null
+++ b/Codemerx/Gestor.Application/ViewModels/Generic/ItemViewModel.cs
@@ -0,0 +1,843 @@
+using CsQuery.ExtensionMethods.Internal;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Application.ViewModels;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Microsoft.CSharp.RuntimeBinder;
+using Microsoft.Office.Interop.Excel;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Globalization;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+
+namespace Gestor.Application.ViewModels.Generic
+{
+ public class ItemViewModel : BaseSegurosViewModel
+ {
+ private bool _alterandoFiltros;
+
+ public Gestor.Application.ViewModels.CoberturaViewModel CoberturaViewModel;
+
+ public ItemServico _itemServico;
+
+ private Visibility _alteracaoTitularesVisibility = Visibility.Collapsed;
+
+ private bool _enableAlterarExcluirTitulares;
+
+ private List<TitularesVida> _excluirTlitulares = new List<TitularesVida>();
+
+ private TitularesVida _titularAlteracao = new TitularesVida();
+
+ private bool _codigo;
+
+ private bool _inicio;
+
+ private bool _fim;
+
+ private bool _fatura;
+
+ private bool _nome;
+
+ private bool _observacao;
+
+ private bool _nascimento;
+
+ private bool _cpf;
+
+ private bool _matricula;
+
+ private bool _premio;
+
+ private bool _capital;
+
+ private bool _tipo;
+
+ private ObservableCollection<TitularesVida> _titulares = new ObservableCollection<TitularesVida>();
+
+ private bool? _allSelected = new bool?(false);
+
+ private bool _allSelectedChanging;
+
+ private List<TitularesVida> _oldTitulares = new List<TitularesVida>();
+
+ public bool? AllSelected
+ {
+ get
+ {
+ return this._allSelected;
+ }
+ set
+ {
+ bool? nullable = value;
+ bool? nullable1 = this._allSelected;
+ if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue)
+ {
+ return;
+ }
+ nullable1 = value;
+ bool flag = false;
+ this.EnableAlterarExcluirTitulares = !(nullable1.GetValueOrDefault() == flag & nullable1.HasValue);
+ nullable1 = value;
+ if (!nullable1.GetValueOrDefault() & nullable1.HasValue)
+ {
+ this.AlteracaoTitularesVisibility = Visibility.Collapsed;
+ }
+ this._allSelected = value;
+ this.AllSelectedChanged();
+ this.Titulares = new ObservableCollection<TitularesVida>(this.Titulares);
+ base.OnPropertyChanged("AllSelected");
+ }
+ }
+
+ public Visibility AlteracaoTitularesVisibility
+ {
+ get
+ {
+ return this._alteracaoTitularesVisibility;
+ }
+ set
+ {
+ this._alteracaoTitularesVisibility = value;
+ base.OnPropertyChanged("AlteracaoTitularesVisibility");
+ }
+ }
+
+ public bool Capital
+ {
+ get
+ {
+ return this._capital;
+ }
+ set
+ {
+ this._capital = value;
+ base.OnPropertyChanged("Capital");
+ }
+ }
+
+ public bool Codigo
+ {
+ get
+ {
+ return this._codigo;
+ }
+ set
+ {
+ this._codigo = value;
+ base.OnPropertyChanged("Codigo");
+ }
+ }
+
+ public bool Cpf
+ {
+ get
+ {
+ return this._cpf;
+ }
+ set
+ {
+ this._cpf = value;
+ base.OnPropertyChanged("Cpf");
+ }
+ }
+
+ public AutoCompleteFilterPredicate<object> DependenteItemFilter
+ {
+ get
+ {
+ AutoCompleteFilterPredicate<object> u003cu003e9_980 = ItemViewModel.u003cu003ec.u003cu003e9__98_0;
+ if (u003cu003e9_980 == null)
+ {
+ u003cu003e9_980 = new AutoCompleteFilterPredicate<object>(ItemViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => {
+ if (!((TitularesVida)obj).get_Nome().ToUpper().Contains(searchText.ToUpper()))
+ {
+ return false;
+ }
+ return ((TitularesVida)obj).get_Tipo().GetValueOrDefault() != 2;
+ });
+ ItemViewModel.u003cu003ec.u003cu003e9__98_0 = u003cu003e9_980;
+ }
+ return u003cu003e9_980;
+ }
+ }
+
+ public bool EnableAlterarExcluirTitulares
+ {
+ get
+ {
+ return this._enableAlterarExcluirTitulares;
+ }
+ set
+ {
+ this._enableAlterarExcluirTitulares = value;
+ base.OnPropertyChanged("EnableAlterarExcluirTitulares");
+ }
+ }
+
+ public List<TitularesVida> ExcluirTitulares
+ {
+ get
+ {
+ return this._excluirTlitulares;
+ }
+ set
+ {
+ this._excluirTlitulares = value;
+ base.OnPropertyChanged("ExcluirTitulares");
+ }
+ }
+
+ public bool Fatura
+ {
+ get
+ {
+ return this._fatura;
+ }
+ set
+ {
+ this._fatura = value;
+ base.OnPropertyChanged("Fatura");
+ }
+ }
+
+ public bool Fim
+ {
+ get
+ {
+ return this._fim;
+ }
+ set
+ {
+ this._fim = value;
+ base.OnPropertyChanged("Fim");
+ }
+ }
+
+ public bool Inicio
+ {
+ get
+ {
+ return this._inicio;
+ }
+ set
+ {
+ this._inicio = value;
+ base.OnPropertyChanged("Inicio");
+ }
+ }
+
+ public Item ItemSubstituido
+ {
+ get;
+ set;
+ }
+
+ public bool Mantido
+ {
+ get;
+ set;
+ }
+
+ public bool Matricula
+ {
+ get
+ {
+ return this._matricula;
+ }
+ set
+ {
+ this._matricula = value;
+ base.OnPropertyChanged("Matricula");
+ }
+ }
+
+ public bool Nascimento
+ {
+ get
+ {
+ return this._nascimento;
+ }
+ set
+ {
+ this._nascimento = value;
+ base.OnPropertyChanged("Nascimento");
+ }
+ }
+
+ public bool Nome
+ {
+ get
+ {
+ return this._nome;
+ }
+ set
+ {
+ this._nome = value;
+ base.OnPropertyChanged("Nome");
+ }
+ }
+
+ public bool Observacao
+ {
+ get
+ {
+ return this._observacao;
+ }
+ set
+ {
+ this._observacao = value;
+ base.OnPropertyChanged("Observacao");
+ }
+ }
+
+ public List<TitularesVida> OldTitulares
+ {
+ get
+ {
+ return this._oldTitulares;
+ }
+ set
+ {
+ this._oldTitulares = value;
+ base.OnPropertyChanged("OldTitulares");
+ }
+ }
+
+ public bool Premio
+ {
+ get
+ {
+ return this._premio;
+ }
+ set
+ {
+ this._premio = value;
+ base.OnPropertyChanged("Premio");
+ }
+ }
+
+ public bool Tipo
+ {
+ get
+ {
+ return this._tipo;
+ }
+ set
+ {
+ this._tipo = value;
+ base.OnPropertyChanged("Tipo");
+ }
+ }
+
+ public TitularesVida TitularAlteracao
+ {
+ get
+ {
+ return this._titularAlteracao;
+ }
+ set
+ {
+ this._titularAlteracao = value;
+ base.OnPropertyChanged("TitularAlteracao");
+ }
+ }
+
+ public ObservableCollection<TitularesVida> Titulares
+ {
+ get
+ {
+ return this._titulares;
+ }
+ set
+ {
+ this._titulares = value;
+ foreach (TitularesVida titulare in this.Titulares)
+ {
+ titulare.add_PropertyChanged(new PropertyChangedEventHandler(this.TitularesOnPropertyChanged));
+ }
+ base.OnPropertyChanged("Titulares");
+ }
+ }
+
+ public ItemViewModel()
+ {
+ this.CoberturaViewModel = new Gestor.Application.ViewModels.CoberturaViewModel(null, null);
+ this._itemServico = new ItemServico();
+ }
+
+ private void AllSelectedChanged()
+ {
+ if (this._allSelectedChanging)
+ {
+ return;
+ }
+ try
+ {
+ this._alterandoFiltros = true;
+ this._allSelectedChanging = true;
+ if (this.AllSelected.HasValue)
+ {
+ foreach (TitularesVida titulare in this.Titulares)
+ {
+ titulare.set_Selecionado(this.AllSelected.Value);
+ }
+ this._alterandoFiltros = false;
+ }
+ }
+ finally
+ {
+ this._allSelectedChanging = false;
+ }
+ }
+
+ public void AlterarTitular()
+ {
+ if (this.AlteracaoTitularesVisibility == Visibility.Visible)
+ {
+ this.AlteracaoTitularesVisibility = Visibility.Collapsed;
+ return;
+ }
+ this.TitularAlteracao = new TitularesVida();
+ this.Codigo = false;
+ this.Inicio = false;
+ this.Fim = false;
+ this.Fatura = false;
+ this.Nome = false;
+ this.Nascimento = false;
+ this.Cpf = false;
+ this.Matricula = false;
+ this.Premio = false;
+ this.Capital = false;
+ this.Tipo = false;
+ this.AlteracaoTitularesVisibility = Visibility.Visible;
+ }
+
+ public void AplicarTitular()
+ {
+ foreach (TitularesVida list in (
+ from x in this.Titulares
+ where x.get_Selecionado()
+ select x).ToList<TitularesVida>())
+ {
+ if (this.Codigo)
+ {
+ list.set_Codigo(this.TitularAlteracao.get_Codigo());
+ }
+ if (this.Inicio)
+ {
+ list.set_Inicio(this.TitularAlteracao.get_Inicio());
+ }
+ if (this.Fim)
+ {
+ list.set_Fim(this.TitularAlteracao.get_Fim());
+ }
+ if (this.Fatura)
+ {
+ list.set_Fatura(this.TitularAlteracao.get_Fatura());
+ }
+ if (this.Nome)
+ {
+ list.set_Nome(this.TitularAlteracao.get_Nome());
+ }
+ if (this.Observacao)
+ {
+ list.set_Observacao(this.TitularAlteracao.get_Observacao());
+ }
+ if (this.Nascimento)
+ {
+ list.set_Nascimento(this.TitularAlteracao.get_Nascimento());
+ }
+ if (this.Cpf)
+ {
+ list.set_Cpf(this.TitularAlteracao.get_Cpf());
+ }
+ if (this.Matricula)
+ {
+ list.set_Matricula(this.TitularAlteracao.get_Matricula());
+ }
+ if (this.Premio)
+ {
+ list.set_Premio(this.TitularAlteracao.get_Premio());
+ }
+ if (this.Capital)
+ {
+ list.set_Capital(this.TitularAlteracao.get_Capital());
+ }
+ if (!this.Tipo)
+ {
+ continue;
+ }
+ list.set_Tipo(this.TitularAlteracao.get_Tipo());
+ }
+ this.Titulares = new ObservableCollection<TitularesVida>(this.Titulares);
+ this.AlteracaoTitularesVisibility = Visibility.Collapsed;
+ }
+
+ internal async Task<List<TitularesVida>> BuscarTitulares(string value)
+ {
+ Func<TitularesVida, bool> func1 = null;
+ List<TitularesVida> titularesVidas = await Task.Run<List<TitularesVida>>(() => {
+ ObservableCollection<TitularesVida> titulares = this.Titulares;
+ Func<TitularesVida, bool> u003cu003e9_1 = func1;
+ if (u003cu003e9_1 == null)
+ {
+ Func<TitularesVida, bool> valueOrDefault = (TitularesVida x) => {
+ if (x.get_Tipo().GetValueOrDefault() == 2 || x.get_Nome() == null)
+ {
+ return false;
+ }
+ return ValidationHelper.RemoveDiacritics(x.get_Nome().Trim()).ToUpper().Contains(value.ToUpper());
+ };
+ Func<TitularesVida, bool> func = valueOrDefault;
+ func1 = valueOrDefault;
+ u003cu003e9_1 = func;
+ }
+ return titulares.Where<TitularesVida>(u003cu003e9_1).ToList<TitularesVida>();
+ });
+ return titularesVidas;
+ }
+
+ public async Task CarregarTitulares(long id)
+ {
+ this.Titulares = new ObservableCollection<TitularesVida>(await this._itemServico.BuscaTitularesVida(id));
+ ItemViewModel list = this;
+ List<TitularesVida> titularesVidas = this.Titulares.ToList<TitularesVida>();
+ list.OldTitulares = titularesVidas.Select<TitularesVida, TitularesVida>((TitularesVida x) => {
+ TitularesVida titularesVida = new TitularesVida();
+ titularesVida.set_Id(x.get_Id());
+ titularesVida.set_IdItem(x.get_IdItem());
+ titularesVida.set_Codigo(x.get_Codigo());
+ titularesVida.set_Inicio(x.get_Inicio());
+ titularesVida.set_Fim(x.get_Fim());
+ titularesVida.set_Fatura(x.get_Fatura());
+ titularesVida.set_Nome(x.get_Nome());
+ titularesVida.set_Observacao(x.get_Observacao());
+ titularesVida.set_Nascimento(x.get_Nascimento());
+ titularesVida.set_Cpf(x.get_Cpf());
+ titularesVida.set_Matricula(x.get_Matricula());
+ titularesVida.set_Premio(x.get_Premio());
+ titularesVida.set_Capital(x.get_Capital());
+ titularesVida.set_Tipo(x.get_Tipo());
+ titularesVida.set_Dependente(x.get_Dependente());
+ return titularesVida;
+ }).ToList<TitularesVida>();
+ }
+
+ public void ExcluirTitular()
+ {
+ List<TitularesVida> list = (
+ from x in this.Titulares
+ where x.get_Selecionado()
+ select x).ToList<TitularesVida>();
+ this.ExcluirTitulares.AddRange(
+ from x in list
+ where x.get_Id() > (long)0
+ select x);
+ foreach (TitularesVida titularesVida in list)
+ {
+ this.Titulares.Remove(titularesVida);
+ }
+ this.AllSelected = new bool?(false);
+ }
+
+ public async Task ImportarTitulares()
+ {
+ string fileName;
+ 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
+ {
+ return;
+ }
+ }
+ base.Loading(true);
+ int num1 = 0;
+ try
+ {
+ List<TitularesVida> titularesVidas2 = await Task.Run<List<TitularesVida>>(() => {
+ string shortDateString;
+ DateTime dateTime;
+ 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>()
+ {
+ "codigo",
+ "inicio",
+ "fim",
+ "fatura",
+ "nome",
+ "nascimento",
+ "cpf",
+ "matricula",
+ "premio",
+ "capital",
+ "tipo",
+ "observacao",
+ "titulardependente"
+ };
+ 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 (ItemViewModel.u003cu003eo__93.u003cu003ep__0 == null)
+ {
+ ItemViewModel.u003cu003eo__93.u003cu003ep__0 = CallSite<Func<CallSite, object, object[,]>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(object[,]), typeof(ItemViewModel)));
+ }
+ object[,] target = ItemViewModel.u003cu003eo__93.u003cu003ep__0.Target(ItemViewModel.u003cu003eo__93.u003cu003ep__0, usedRange.Value2);
+ int num = 0;
+ if (target == null)
+ {
+ continue;
+ }
+ for (int i = 0; i <= usedRange.Columns.Count - 1; i++)
+ {
+ if (target[1, i + 1] == null || !strs.Contains(Funcoes.RemoverAcentos(target[1, i + 1].ToString().ToLower().Trim())))
+ {
+ num--;
+ }
+ else
+ {
+ DataColumn dataColumn = new DataColumn()
+ {
+ DataType = Type.GetType("System.String"),
+ ColumnName = Funcoes.RemoverAcentos(target[1, i + 1].ToString().ToLower().Trim())
+ };
+ dataTable.Columns.Add(dataColumn);
+ for (int j = 0; j <= usedRange.Rows.Count - 2; j++)
+ {
+ object obj = target[j + 2, i + 1];
+ target[1, i + 1].ToString().ToLower();
+ if (Funcoes.RemoverAcentos(target[1, i + 1].ToString().Trim().ToLower()) != "inicio" && Funcoes.RemoverAcentos(target[1, i + 1].ToString().Trim().ToLower()) != "fim" && Funcoes.RemoverAcentos(target[1, i + 1].ToString().Trim().ToLower()) != "nascimento")
+ {
+ string str = obj as string;
+ shortDateString = (str != null ? Funcoes.RemoverAcentos(str).ToUpper().Trim() : (!(obj is double) ? (!(obj is bool) ? "" : ((bool)obj ? "1" : "0")) : ((double)obj).ToString(CultureInfo.InvariantCulture)));
+ }
+ else if (obj is double)
+ {
+ dateTime = DateTime.FromOADate((double)obj);
+ shortDateString = dateTime.ToShortDateString();
+ }
+ else if (!DateTime.TryParse((string)obj, out dateTime))
+ {
+ shortDateString = "";
+ }
+ else
+ {
+ dateTime = DateTime.Parse((string)obj);
+ shortDateString = dateTime.ToShortDateString();
+ }
+ if (i + num != 0)
+ {
+ dataTable.Rows[j][i + num] = shortDateString;
+ }
+ else
+ {
+ dataTable.Rows.Add(dataTable.NewRow());
+ dataTable.Rows[j][i + num] = shortDateString;
+ }
+ }
+ }
+ }
+ dataTables.Add(dataTable);
+ }
+ variable.Quit();
+ List<TitularesVida> titularesVidas = new List<TitularesVida>();
+ foreach (DataTable dataTable1 in dataTables)
+ {
+ List<TitularesVida> titularesVidas1 = titularesVidas;
+ EnumerableRowCollection<DataRow> dataRows = dataTable1.AsEnumerable();
+ Func<DataRow, bool> u003cu003e9_931 = ItemViewModel.u003cu003ec.u003cu003e9__93_1;
+ if (u003cu003e9_931 == null)
+ {
+ u003cu003e9_931 = (DataRow x) => {
+ if (x.Field<object>("nome") == null)
+ {
+ return false;
+ }
+ return !string.IsNullOrEmpty(x.Field<object>("nome").ToString());
+ };
+ ItemViewModel.u003cu003ec.u003cu003e9__93_1 = u003cu003e9_931;
+ }
+ titularesVidas1.AddRange(dataRows.Where<DataRow>(u003cu003e9_931).ToList<DataRow>().Select<DataRow, TitularesVida>((DataRow x) => {
+ DateTime? nullable;
+ decimal? nullable1;
+ TipoTitular? nullable2;
+ DateTime? nullable3;
+ DateTime? nullable4;
+ DateTime? nullable5;
+ decimal? nullable6;
+ decimal? nullable7;
+ TipoTitular? nullable8;
+ TitularesVida titularesVida = new TitularesVida();
+ titularesVida.set_Codigo((!dataTable1.Columns.Contains("codigo") || string.IsNullOrWhiteSpace(x.Field<object>("codigo").ToString()) ? null : x.Field<object>("codigo").ToString().ToUpper()));
+ if (!dataTable1.Columns.Contains("inicio") || string.IsNullOrWhiteSpace(x.Field<object>("inicio").ToString()))
+ {
+ nullable = null;
+ nullable3 = nullable;
+ }
+ else
+ {
+ nullable3 = new DateTime?(DateTime.Parse(x.Field<object>("inicio").ToString()));
+ }
+ titularesVida.set_Inicio(nullable3);
+ if (!dataTable1.Columns.Contains("fim") | string.IsNullOrWhiteSpace(x.Field<object>("fim").ToString()))
+ {
+ nullable = null;
+ nullable4 = nullable;
+ }
+ else
+ {
+ nullable4 = new DateTime?(DateTime.Parse(x.Field<object>("fim").ToString()));
+ }
+ titularesVida.set_Fim(nullable4);
+ titularesVida.set_Fatura((!dataTable1.Columns.Contains("fatura") || string.IsNullOrWhiteSpace(x.Field<object>("fatura").ToString()) ? null : x.Field<object>("fatura").ToString().ToUpper()));
+ titularesVida.set_Nome((!dataTable1.Columns.Contains("nome") || string.IsNullOrWhiteSpace(x.Field<object>("nome").ToString()) ? null : x.Field<object>("nome").ToString().ToUpper()));
+ titularesVida.set_Observacao((!dataTable1.Columns.Contains("observacao") || string.IsNullOrWhiteSpace(x.Field<object>("observacao").ToString()) ? null : x.Field<object>("observacao").ToString().ToUpper()));
+ if (!dataTable1.Columns.Contains("nascimento") || string.IsNullOrWhiteSpace(x.Field<object>("nascimento").ToString()))
+ {
+ nullable = null;
+ nullable5 = nullable;
+ }
+ else
+ {
+ nullable5 = new DateTime?(DateTime.Parse(x.Field<object>("nascimento").ToString()));
+ }
+ titularesVida.set_Nascimento(nullable5);
+ titularesVida.set_Cpf((!dataTable1.Columns.Contains("cpf") || string.IsNullOrWhiteSpace(x.Field<object>("cpf").ToString()) ? null : x.Field<object>("cpf").ToString()));
+ titularesVida.set_Matricula((!dataTable1.Columns.Contains("matricula") || string.IsNullOrWhiteSpace(x.Field<object>("matricula").ToString()) ? null : x.Field<object>("matricula").ToString().ToUpper()));
+ if (!dataTable1.Columns.Contains("premio") || string.IsNullOrWhiteSpace(x.Field<object>("premio").ToString()))
+ {
+ nullable1 = null;
+ nullable6 = nullable1;
+ }
+ else
+ {
+ nullable6 = new decimal?(decimal.Parse(x.Field<object>("premio").ToString(), NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, CultureInfo.InvariantCulture));
+ }
+ titularesVida.set_Premio(nullable6);
+ if (!dataTable1.Columns.Contains("capital") || string.IsNullOrWhiteSpace(x.Field<object>("capital").ToString()))
+ {
+ nullable1 = null;
+ nullable7 = nullable1;
+ }
+ else
+ {
+ nullable7 = new decimal?(decimal.Parse(x.Field<object>("capital").ToString(), NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, CultureInfo.InvariantCulture));
+ }
+ titularesVida.set_Capital(nullable7);
+ if (!dataTable1.Columns.Contains("tipo") || string.IsNullOrWhiteSpace(x.Field<object>("tipo").ToString()))
+ {
+ nullable2 = null;
+ nullable8 = nullable2;
+ }
+ else if (x.Field<object>("tipo").ToString() == "SOCIO")
+ {
+ nullable8 = new TipoTitular?(0);
+ }
+ else if (x.Field<object>("tipo").ToString() == "FUNCIONARIO")
+ {
+ nullable8 = new TipoTitular?(1);
+ }
+ else
+ {
+ nullable2 = null;
+ nullable8 = nullable2;
+ }
+ titularesVida.set_Tipo(nullable8);
+ return titularesVida;
+ }).ToList<TitularesVida>());
+ }
+ return titularesVidas;
+ });
+ base.Loading(false);
+ if (titularesVidas2.Count != 0)
+ {
+ ExtensionMethods.AddRange<TitularesVida>(this.Titulares, titularesVidas2);
+ }
+ else
+ {
+ await base.ShowMessage("NENHUMA COLUNA FOI ENCONTRADA", "OK", "", false);
+ return;
+ }
+ }
+ catch
+ {
+ num1 = 1;
+ }
+ if (num1 == 1)
+ {
+ base.Loading(false);
+ await base.ShowMessage("FALHA AO IMPORTAR O EXCEL, VERIFIQUE SE O ARQUIVO POSSUI ALGUM ERRO.", "OK", "", false);
+ }
+ }
+
+ public void IncluirTitular()
+ {
+ this.Titulares.Insert(0, new TitularesVida());
+ this.Titulares = new ObservableCollection<TitularesVida>(this.Titulares);
+ }
+
+ public async Task<int> QuantidadeDeItens(long id)
+ {
+ return await (new ItemServico()).BuscarProximoItem(id);
+ }
+
+ public void RecheckAllSelected()
+ {
+ if (this._allSelectedChanging)
+ {
+ return;
+ }
+ try
+ {
+ this._allSelectedChanging = true;
+ if (this.Titulares.All<TitularesVida>((TitularesVida e) => e.get_Selecionado()))
+ {
+ this.AllSelected = new bool?(true);
+ }
+ else if (!this.Titulares.All<TitularesVida>((TitularesVida e) => !e.get_Selecionado()))
+ {
+ this.AllSelected = null;
+ }
+ else
+ {
+ this.AllSelected = new bool?(false);
+ }
+ }
+ finally
+ {
+ this._allSelectedChanging = false;
+ }
+ }
+
+ private void TitularesOnPropertyChanged(object sender, PropertyChangedEventArgs args)
+ {
+ if (this._alterandoFiltros)
+ {
+ return;
+ }
+ this.RecheckAllSelected();
+ }
+ }
+} \ No newline at end of file