summaryrefslogtreecommitdiff
path: root/Gestor.Application/ViewModels/Seguros/Itens/AutoViewModel.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:35:25 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:35:25 +0000
commit674ca83ba9243a9e95a7568c797668dab6aee26a (patch)
tree4a905b3fb1d827665a34d63f67bc5559f8e7235b /Gestor.Application/ViewModels/Seguros/Itens/AutoViewModel.cs
downloadgestor-674ca83ba9243a9e95a7568c797668dab6aee26a.tar.gz
gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.zip
feat: upload files
Diffstat (limited to 'Gestor.Application/ViewModels/Seguros/Itens/AutoViewModel.cs')
-rw-r--r--Gestor.Application/ViewModels/Seguros/Itens/AutoViewModel.cs3018
1 files changed, 3018 insertions, 0 deletions
diff --git a/Gestor.Application/ViewModels/Seguros/Itens/AutoViewModel.cs b/Gestor.Application/ViewModels/Seguros/Itens/AutoViewModel.cs
new file mode 100644
index 0000000..735d4a7
--- /dev/null
+++ b/Gestor.Application/ViewModels/Seguros/Itens/AutoViewModel.cs
@@ -0,0 +1,3018 @@
+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