summaryrefslogtreecommitdiff
path: root/Gestor.Application/ViewModels/Ferramentas/EtiquetaViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Application/ViewModels/Ferramentas/EtiquetaViewModel.cs')
-rw-r--r--Gestor.Application/ViewModels/Ferramentas/EtiquetaViewModel.cs1163
1 files changed, 1163 insertions, 0 deletions
diff --git a/Gestor.Application/ViewModels/Ferramentas/EtiquetaViewModel.cs b/Gestor.Application/ViewModels/Ferramentas/EtiquetaViewModel.cs
new file mode 100644
index 0000000..c19b97e
--- /dev/null
+++ b/Gestor.Application/ViewModels/Ferramentas/EtiquetaViewModel.cs
@@ -0,0 +1,1163 @@
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.Servicos.Seguros.Itens;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace Gestor.Application.ViewModels.Ferramentas
+{
+ public class EtiquetaViewModel : BaseSegurosViewModel
+ {
+ private bool _allSelectedChanging;
+
+ private List<string> _tiposEtiqueta = new List<string>()
+ {
+ "CLIENTE",
+ "APÓLICE"
+ };
+
+ private string _tipoEtiqueta = "CLIENTE";
+
+ private bool? _allSelected;
+
+ private ObservableCollection<Documento> _apolicesFiltrados = new ObservableCollection<Documento>();
+
+ private bool _duasColunas = true;
+
+ private bool _tresColunas;
+
+ private bool _umaPagina;
+
+ private bool _mostrarNascimento;
+
+ private int _pular;
+
+ private object _visibilityColunas;
+
+ private bool _mostrarApolice = true;
+
+ private bool _mostrarVendedor = true;
+
+ private bool _mostrarItem = true;
+
+ public bool? AllSelected
+ {
+ get
+ {
+ return this._allSelected;
+ }
+ set
+ {
+ bool? nullable = value;
+ bool? nullable1 = this._allSelected;
+ if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue)
+ {
+ return;
+ }
+ this._allSelected = value;
+ this.AllSelectedChanged();
+ this.Apolices = new List<Documento>(this.Apolices);
+ base.OnPropertyChanged("AllSelected");
+ }
+ }
+
+ public List<Documento> Apolices
+ {
+ get;
+ set;
+ }
+
+ public ObservableCollection<Documento> ApolicesFiltrados
+ {
+ get
+ {
+ return this._apolicesFiltrados;
+ }
+ set
+ {
+ this._apolicesFiltrados = value;
+ foreach (Documento apolicesFiltrado in this.ApolicesFiltrados)
+ {
+ apolicesFiltrado.add_PropertyChanged(new PropertyChangedEventHandler(this.EntryOnPropertyChanged));
+ }
+ base.OnPropertyChanged("ApolicesFiltrados");
+ }
+ }
+
+ public bool DuasColunas
+ {
+ get
+ {
+ return this._duasColunas;
+ }
+ set
+ {
+ this._duasColunas = value;
+ base.OnPropertyChanged("DuasColunas");
+ }
+ }
+
+ public Visibility ExibirControlesEtiquetaApolice
+ {
+ get
+ {
+ if (this.TipoEtiqueta != "APÓLICE")
+ {
+ return Visibility.Collapsed;
+ }
+ return Visibility.Visible;
+ }
+ }
+
+ public Visibility ExibirControlesEtiquetaCliente
+ {
+ get
+ {
+ if (this.TipoEtiqueta != "CLIENTE")
+ {
+ return Visibility.Collapsed;
+ }
+ return Visibility.Visible;
+ }
+ }
+
+ public bool MostrarApolice
+ {
+ get
+ {
+ return this._mostrarApolice;
+ }
+ set
+ {
+ this._mostrarApolice = value;
+ base.OnPropertyChanged("MostrarApolice");
+ }
+ }
+
+ public bool MostrarItem
+ {
+ get
+ {
+ return this._mostrarItem;
+ }
+ set
+ {
+ this._mostrarItem = value;
+ base.OnPropertyChanged("MostrarItem");
+ }
+ }
+
+ public bool MostrarNascimento
+ {
+ get
+ {
+ return this._mostrarNascimento;
+ }
+ set
+ {
+ this._mostrarNascimento = value;
+ base.OnPropertyChanged("MostrarNascimento");
+ }
+ }
+
+ public bool MostrarVendedor
+ {
+ get
+ {
+ return this._mostrarVendedor;
+ }
+ set
+ {
+ this._mostrarVendedor = value;
+ base.OnPropertyChanged("MostrarVendedor");
+ }
+ }
+
+ public int Pular
+ {
+ get
+ {
+ return this._pular;
+ }
+ set
+ {
+ this._pular = value;
+ base.OnPropertyChanged("Pular");
+ }
+ }
+
+ public string TipoEtiqueta
+ {
+ get
+ {
+ return this._tipoEtiqueta;
+ }
+ set
+ {
+ this._tipoEtiqueta = value;
+ base.OnPropertyChanged("TipoEtiqueta");
+ base.OnPropertyChanged("ExibirControlesEtiquetaApolice");
+ base.OnPropertyChanged("ExibirControlesEtiquetaCliente");
+ }
+ }
+
+ public List<string> TiposEtiqueta
+ {
+ get
+ {
+ return this._tiposEtiqueta;
+ }
+ set
+ {
+ this._tiposEtiqueta = value;
+ base.OnPropertyChanged("TiposEtiqueta");
+ }
+ }
+
+ public bool TresColunas
+ {
+ get
+ {
+ return this._tresColunas;
+ }
+ set
+ {
+ this._tresColunas = value;
+ base.OnPropertyChanged("TresColunas");
+ }
+ }
+
+ public bool UmaPagina
+ {
+ get
+ {
+ return this._umaPagina;
+ }
+ set
+ {
+ this._umaPagina = value;
+ this.VisibilityColunas = (value ? Visibility.Collapsed : Visibility.Visible);
+ base.OnPropertyChanged("UmaPagina");
+ }
+ }
+
+ public object VisibilityColunas
+ {
+ get
+ {
+ return this._visibilityColunas;
+ }
+ set
+ {
+ this._visibilityColunas = value;
+ base.OnPropertyChanged("VisibilityColunas");
+ }
+ }
+
+ public EtiquetaViewModel()
+ {
+ }
+
+ private void AllSelectedChanged()
+ {
+ if (this._allSelectedChanging)
+ {
+ return;
+ }
+ try
+ {
+ this._allSelectedChanging = true;
+ if (this.AllSelected.HasValue)
+ {
+ foreach (Documento apolice in this.Apolices)
+ {
+ apolice.set_Selecionado(this.AllSelected.Value);
+ }
+ }
+ }
+ finally
+ {
+ this._allSelectedChanging = false;
+ }
+ }
+
+ public async Task CarregarDados(List<Documento> list, bool apenasCliente)
+ {
+ ObservableCollection<Item> observableCollection;
+ List<Documento> documentos = list.ToList<Documento>();
+ List<Cliente> clientes = documentos.Select<Documento, Cliente>((Documento x) => {
+ Cliente cliente = new Cliente();
+ cliente.set_Id(x.get_Controle().get_Cliente().get_Id());
+ return cliente;
+ }).ToList<Cliente>();
+ ClienteServico clienteServico = new ClienteServico();
+ ItemServico itemServico = new ItemServico();
+ List<Cliente> clientes1 = clientes;
+ List<ClienteEndereco> clienteEnderecos = await clienteServico.BuscarEnderecosPorCliente((
+ from x in clientes1
+ where x.get_Id() > (long)0
+ select x).ToList<Cliente>());
+ if (!apenasCliente)
+ {
+ observableCollection = await itemServico.BuscarItens(list.ToList<Documento>());
+ }
+ else
+ {
+ observableCollection = null;
+ }
+ ObservableCollection<Item> observableCollection1 = observableCollection;
+ foreach (Documento documento in list)
+ {
+ if ((
+ from y in clienteEnderecos
+ where y.get_Cliente().get_Id() == documento.get_Controle().get_Cliente().get_Id()
+ select y).Count<ClienteEndereco>() == 0)
+ {
+ continue;
+ }
+ if (documento.get_Controle().get_Cliente().get_Id() > (long)0)
+ {
+ Cliente cliente2 = documento.get_Controle().get_Cliente();
+ List<ClienteEndereco> clienteEnderecos1 = (
+ from y in clienteEnderecos
+ where y.get_Cliente().get_Id() == documento.get_Controle().get_Cliente().get_Id()
+ select y).ToList<ClienteEndereco>();
+ cliente2.set_Enderecos(new ObservableCollection<ClienteEndereco>(
+ from y in clienteEnderecos1
+ orderby y.get_Ordem()
+ select y));
+ }
+ if (apenasCliente)
+ {
+ continue;
+ }
+ documento.set_ItensAtivo((
+ from y in observableCollection1
+ where y.get_Documento().get_Id() == documento.get_Id()
+ select y).ToList<Item>());
+ }
+ this.TipoEtiqueta = (apenasCliente ? "CLIENTE" : "APÓLICE");
+ EtiquetaViewModel etiquetaViewModel = this;
+ List<Documento> documentos1 = list;
+ IEnumerable<Documento> documentos2 = documentos1.Where<Documento>((Documento x) => {
+ bool enderecos;
+ Cliente cliente = x.get_Controle().get_Cliente();
+ if (cliente != null)
+ {
+ enderecos = cliente.get_Enderecos();
+ }
+ else
+ {
+ enderecos = false;
+ }
+ if (!enderecos)
+ {
+ return false;
+ }
+ Cliente cliente1 = x.get_Controle().get_Cliente();
+ if (cliente1 == null)
+ {
+ return false;
+ }
+ return cliente1.get_Enderecos().Count<ClienteEndereco>() > 0;
+ });
+ etiquetaViewModel.Apolices = (
+ from x in documentos2
+ orderby x.get_Controle().get_Cliente().get_Nome()
+ select x).ToList<Documento>();
+ this.ApolicesFiltrados = new ObservableCollection<Documento>(this.Apolices);
+ this.AllSelected = new bool?(true);
+ this.RecheckAllSelected();
+ itemServico = null;
+ clienteEnderecos = null;
+ }
+
+ public void EmitirEtiquetas()
+ {
+ double num;
+ DateTime? nascimento;
+ DateTime valueOrDefault;
+ string str;
+ string str1;
+ object obj;
+ string str2;
+ string str3;
+ string complemento;
+ string str4;
+ string str5;
+ string str6;
+ string cidade;
+ string str7;
+ string estado;
+ string str8;
+ string str9;
+ string str10;
+ object obj1;
+ string str11;
+ string str12;
+ string complemento1;
+ string str13;
+ string str14;
+ string str15;
+ string str16;
+ string str17;
+ object obj2;
+ object obj3;
+ object obj4;
+ string upper;
+ object obj5;
+ object obj6;
+ object obj7;
+ string upper1;
+ string str18 = "";
+ List<Documento> list = (
+ from x in this.Apolices
+ where x.get_Selecionado()
+ select x).ToList<Documento>();
+ string tipoEtiqueta = this.TipoEtiqueta;
+ if (tipoEtiqueta == "CLIENTE")
+ {
+ list = this.Apolices.Where<Documento>((Documento x) => {
+ if (!x.get_Selecionado())
+ {
+ return false;
+ }
+ return x.get_Controle().get_Cliente().get_Enderecos() != null;
+ }).ToList<Documento>();
+ if (!this.UmaPagina)
+ {
+ int num1 = 0;
+ int num2 = 0;
+ double num3 = 0;
+ if (this.DuasColunas)
+ {
+ num1 = 10;
+ num2 = 2;
+ num3 = 10.52;
+ }
+ else if (this.TresColunas)
+ {
+ num1 = 10;
+ num2 = 3;
+ num3 = 6.82;
+ }
+ this.Pular = this.Pular % (num1 * num2);
+ int pular = this.Pular;
+ str18 = "<html><head><style type='text/css'>@page{size: Letter; margin: 0cm}</style><title>ETIQUETAS</title></head><body><div align='center'>";
+ int num4 = 0;
+ while (num4 < list.Count)
+ {
+ str18 = string.Concat(str18, "<div style='clear: both; page-break-after:always;'>");
+ bool flag = (num4 == 0 ? true : num4 == num1 * num2);
+ str18 = string.Concat(str18, "<table><tr style='height: ", (flag ? "0.55" : "0.85"), "cm;'></tr>");
+ for (int i = 0; i < num1 * num2; i += num2)
+ {
+ str18 = string.Concat(str18, "<tr style='height: 2.60cm;'>");
+ if (this.DuasColunas)
+ {
+ str18 = string.Concat(str18, "<td style='width: 0.4cm;'>");
+ }
+ else if (this.TresColunas)
+ {
+ str18 = string.Concat(str18, "<td style='width: 0.05cm;'>");
+ }
+ str18 = string.Concat(str18, "</td>");
+ for (int j = 0; j < num2; j++)
+ {
+ str18 = string.Concat(str18, "<td style='width: ", num3.ToString(CultureInfo.InvariantCulture), "cm;'><font size='1px' face='Arial'>");
+ if (i + j >= this.Pular)
+ {
+ if (num4 < list.Count)
+ {
+ Documento item = list[num4];
+ if (this.MostrarNascimento)
+ {
+ item.get_Controle().get_Cliente().set_Nascimento((new ClienteServico()).BuscarNascimento(item.get_Controle().get_Cliente().get_Id()));
+ }
+ if (item.get_Controle().get_Cliente().get_Enderecos().Count<ClienteEndereco>() > 0)
+ {
+ string[] strArrays = new string[] { str18, item.get_Controle().get_Cliente().get_Nome().Trim(), " ", null, null, null, null, null };
+ nascimento = item.get_Controle().get_Cliente().get_Nascimento();
+ if (!nascimento.HasValue || !this.MostrarNascimento)
+ {
+ str = "";
+ }
+ else
+ {
+ nascimento = item.get_Controle().get_Cliente().get_Nascimento();
+ if (nascimento.HasValue)
+ {
+ valueOrDefault = nascimento.GetValueOrDefault();
+ str = valueOrDefault.ToString("dd/MM");
+ }
+ else
+ {
+ str = null;
+ }
+ }
+ strArrays[3] = str;
+ strArrays[4] = " <br>";
+ if (item.get_Controle().get_Cliente().get_Id() == 0)
+ {
+ str1 = "";
+ }
+ else
+ {
+ string[] strArrays1 = new string[10];
+ ClienteEndereco clienteEndereco = item.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco != null)
+ {
+ string endereco = clienteEndereco.get_Endereco();
+ if (endereco != null)
+ {
+ str2 = endereco.Trim();
+ }
+ else
+ {
+ str2 = null;
+ }
+ }
+ else
+ {
+ str2 = null;
+ }
+ strArrays1[0] = str2;
+ strArrays1[1] = ", ";
+ ClienteEndereco clienteEndereco1 = item.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco1 != null)
+ {
+ string numero = clienteEndereco1.get_Numero();
+ if (numero != null)
+ {
+ str3 = numero.Trim();
+ }
+ else
+ {
+ str3 = null;
+ }
+ }
+ else
+ {
+ str3 = null;
+ }
+ strArrays1[2] = str3;
+ ClienteEndereco clienteEndereco2 = item.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco2 != null)
+ {
+ complemento = clienteEndereco2.get_Complemento();
+ }
+ else
+ {
+ complemento = null;
+ }
+ if (!string.IsNullOrWhiteSpace(complemento))
+ {
+ ClienteEndereco clienteEndereco3 = item.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco3 != null)
+ {
+ str4 = clienteEndereco3.get_Complemento().Trim();
+ }
+ else
+ {
+ str4 = null;
+ }
+ str5 = string.Concat("<br>", str4);
+ }
+ else
+ {
+ str5 = "";
+ }
+ strArrays1[3] = str5;
+ strArrays1[4] = "<br>";
+ ClienteEndereco clienteEndereco4 = item.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco4 != null)
+ {
+ string bairro = clienteEndereco4.get_Bairro();
+ if (bairro != null)
+ {
+ str6 = bairro.Trim();
+ }
+ else
+ {
+ str6 = null;
+ }
+ }
+ else
+ {
+ str6 = null;
+ }
+ strArrays1[5] = str6;
+ strArrays1[6] = " - ";
+ ClienteEndereco clienteEndereco5 = item.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco5 != null)
+ {
+ cidade = clienteEndereco5.get_Cidade();
+ }
+ else
+ {
+ cidade = null;
+ }
+ if (!string.IsNullOrEmpty(cidade))
+ {
+ ClienteEndereco clienteEndereco6 = item.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco6 != null)
+ {
+ str7 = clienteEndereco6.get_Cidade().Trim();
+ }
+ else
+ {
+ str7 = null;
+ }
+ }
+ else
+ {
+ str7 = "";
+ }
+ strArrays1[7] = str7;
+ strArrays1[8] = "/";
+ ClienteEndereco clienteEndereco7 = item.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco7 != null)
+ {
+ estado = clienteEndereco7.get_Estado();
+ }
+ else
+ {
+ estado = null;
+ }
+ if (!string.IsNullOrEmpty(estado))
+ {
+ ClienteEndereco clienteEndereco8 = item.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco8 != null)
+ {
+ str8 = clienteEndereco8.get_Estado().Trim();
+ }
+ else
+ {
+ str8 = null;
+ }
+ }
+ else
+ {
+ str8 = "";
+ }
+ strArrays1[9] = str8;
+ str1 = string.Concat(strArrays1);
+ }
+ strArrays[5] = str1;
+ strArrays[6] = " <br>";
+ if (item.get_Controle().get_Cliente().get_Id() == 0)
+ {
+ obj = "";
+ }
+ else
+ {
+ ClienteEndereco clienteEndereco9 = item.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco9 != null)
+ {
+ obj = clienteEndereco9.get_Cep().Trim();
+ }
+ else
+ {
+ obj = null;
+ }
+ if (obj == null)
+ {
+ obj = "";
+ }
+ }
+ strArrays[7] = (string)obj;
+ str18 = string.Concat(strArrays);
+ }
+ num4++;
+ }
+ this.Pular = 0;
+ }
+ str18 = string.Concat(str18, "</font></td>");
+ if (j < num2 - 1)
+ {
+ if (this.DuasColunas)
+ {
+ str18 = string.Concat(str18, "<td style='width: 0.5cm;'>");
+ }
+ else if (this.TresColunas)
+ {
+ str18 = string.Concat(str18, "<td style='width: 0.3cm;'>");
+ }
+ }
+ str18 = string.Concat(str18, "</td>");
+ }
+ }
+ str18 = string.Concat(str18, "</table>");
+ str18 = string.Concat(str18, "</div>");
+ }
+ this.Pular = (pular + list.Count) % (num1 * num2);
+ }
+ else
+ {
+ str18 = "<html><head><style type='text/css'>@page{size: landscape}</style><title>ETIQUETAS</title></head><body>";
+ for (int k = 0; k < list.Count; k++)
+ {
+ str18 = string.Concat(str18, "<div style='clear: both; page-break-after:always; margin-top:");
+ str18 = string.Concat(str18, (k == 0 ? "25%'>" : "30%'>"));
+ str18 = string.Concat(str18, "<div align='center'>");
+ str18 = string.Concat(str18, "<table style='text-align: center;'>");
+ str18 = string.Concat(str18, "<tr style='height: 2.48cm;'>");
+ num = 10.7;
+ str18 = string.Concat(str18, "<td style='width: ", num.ToString(CultureInfo.InvariantCulture), "cm;'><font size='3px' face='Arial'>");
+ Documento documento = list[k];
+ if (this.MostrarNascimento)
+ {
+ documento.get_Controle().get_Cliente().set_Nascimento((new ClienteServico()).BuscarNascimento(documento.get_Controle().get_Cliente().get_Id()));
+ }
+ string[] strArrays2 = new string[] { str18, documento.get_Controle().get_Cliente().get_Nome().Trim(), " ", null, null, null, null, null, null };
+ nascimento = documento.get_Controle().get_Cliente().get_Nascimento();
+ if (!nascimento.HasValue || !this.MostrarNascimento)
+ {
+ str9 = "";
+ }
+ else
+ {
+ nascimento = documento.get_Controle().get_Cliente().get_Nascimento();
+ if (nascimento.HasValue)
+ {
+ valueOrDefault = nascimento.GetValueOrDefault();
+ str9 = valueOrDefault.ToString("dd/MM");
+ }
+ else
+ {
+ str9 = null;
+ }
+ }
+ strArrays2[3] = str9;
+ strArrays2[4] = " <br>";
+ if (documento.get_Controle().get_Cliente().get_Id() == 0)
+ {
+ str10 = "";
+ }
+ else
+ {
+ string[] strArrays3 = new string[10];
+ ClienteEndereco clienteEndereco10 = (
+ from x in documento.get_Controle().get_Cliente().get_Enderecos()
+ orderby x.get_Ordem()
+ select x).FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco10 != null)
+ {
+ string endereco1 = clienteEndereco10.get_Endereco();
+ if (endereco1 != null)
+ {
+ str11 = endereco1.Trim();
+ }
+ else
+ {
+ str11 = null;
+ }
+ }
+ else
+ {
+ str11 = null;
+ }
+ strArrays3[0] = str11;
+ strArrays3[1] = ", ";
+ ClienteEndereco clienteEndereco11 = documento.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco11 != null)
+ {
+ string numero1 = clienteEndereco11.get_Numero();
+ if (numero1 != null)
+ {
+ str12 = numero1.Trim();
+ }
+ else
+ {
+ str12 = null;
+ }
+ }
+ else
+ {
+ str12 = null;
+ }
+ strArrays3[2] = str12;
+ ClienteEndereco clienteEndereco12 = documento.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco12 != null)
+ {
+ complemento1 = clienteEndereco12.get_Complemento();
+ }
+ else
+ {
+ complemento1 = null;
+ }
+ if (!string.IsNullOrWhiteSpace(complemento1))
+ {
+ ClienteEndereco clienteEndereco13 = documento.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco13 != null)
+ {
+ string complemento2 = clienteEndereco13.get_Complemento();
+ if (complemento2 != null)
+ {
+ str13 = complemento2.Trim();
+ }
+ else
+ {
+ str13 = null;
+ }
+ }
+ else
+ {
+ str13 = null;
+ }
+ str14 = string.Concat("<br>", str13);
+ }
+ else
+ {
+ str14 = "";
+ }
+ strArrays3[3] = str14;
+ strArrays3[4] = "<br>";
+ ClienteEndereco clienteEndereco14 = documento.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco14 != null)
+ {
+ string bairro1 = clienteEndereco14.get_Bairro();
+ if (bairro1 != null)
+ {
+ str15 = bairro1.Trim();
+ }
+ else
+ {
+ str15 = null;
+ }
+ }
+ else
+ {
+ str15 = null;
+ }
+ strArrays3[5] = str15;
+ strArrays3[6] = " - ";
+ ClienteEndereco clienteEndereco15 = documento.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco15 != null)
+ {
+ string cidade1 = clienteEndereco15.get_Cidade();
+ if (cidade1 != null)
+ {
+ str16 = cidade1.Trim();
+ }
+ else
+ {
+ str16 = null;
+ }
+ }
+ else
+ {
+ str16 = null;
+ }
+ strArrays3[7] = str16;
+ strArrays3[8] = "/";
+ ClienteEndereco clienteEndereco16 = documento.get_Controle().get_Cliente().get_Enderecos().FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco16 != null)
+ {
+ string estado1 = clienteEndereco16.get_Estado();
+ if (estado1 != null)
+ {
+ str17 = estado1.Trim();
+ }
+ else
+ {
+ str17 = null;
+ }
+ }
+ else
+ {
+ str17 = null;
+ }
+ strArrays3[9] = str17;
+ str10 = string.Concat(strArrays3);
+ }
+ strArrays2[5] = str10;
+ strArrays2[6] = " <br>";
+ if (documento.get_Controle().get_Cliente().get_Id() == 0)
+ {
+ obj1 = "";
+ }
+ else
+ {
+ ClienteEndereco clienteEndereco17 = (
+ from x in documento.get_Controle().get_Cliente().get_Enderecos()
+ orderby x.get_Ordem()
+ select x).FirstOrDefault<ClienteEndereco>();
+ if (clienteEndereco17 != null)
+ {
+ obj1 = clienteEndereco17.get_Cep().Trim();
+ }
+ else
+ {
+ obj1 = null;
+ }
+ if (obj1 == null)
+ {
+ obj1 = "";
+ }
+ }
+ strArrays2[7] = (string)obj1;
+ strArrays2[8] = " <br>";
+ str18 = string.Concat(strArrays2);
+ str18 = string.Concat(str18, "</font></td>");
+ str18 = string.Concat(str18, "</tr>");
+ str18 = string.Concat(str18, "</table>");
+ str18 = string.Concat(str18, "</div>");
+ str18 = string.Concat(str18, "</div>");
+ }
+ }
+ base.RegistrarAcao(string.Format("EMITIU ETIQUETA DE {0} CLIENTE{1}", list.Count, (list.Count == 1 ? "" : "S")), (long)0, new TipoTela?(59), string.Concat("IDS E NOMES DOS CLIENTES:\n", string.Join("\n",
+ from x in list
+ select string.Concat(x.get_Controle().get_Cliente().get_Id().ToString(), ": \"", x.get_Controle().get_Cliente().get_Nome(), "\""))));
+ }
+ else if (tipoEtiqueta == "APÓLICE")
+ {
+ if (!this.UmaPagina)
+ {
+ int num5 = 0;
+ int num6 = 0;
+ double num7 = 0;
+ if (this.DuasColunas)
+ {
+ num5 = 10;
+ num6 = 2;
+ num7 = 10.52;
+ }
+ else if (this.TresColunas)
+ {
+ num5 = 10;
+ num6 = 3;
+ num7 = 6.87;
+ }
+ this.Pular = this.Pular % (num5 * num6);
+ int pular1 = this.Pular;
+ str18 = "<html><head><style type='text/css'>@page{size: Letter; margin: 0cm}</style><title>ETIQUETAS</title></head><body><div align='center'>";
+ int num8 = 0;
+ while (num8 < list.Count)
+ {
+ str18 = string.Concat(str18, "<div style='clear: both; page-break-after:always;'>");
+ str18 = string.Concat(str18, "<table><tr style='height: ", (num8 == 0 ? "0.55" : "0.8"), "cm;'></tr>");
+ for (int l = 0; l < num5 * num6; l += num6)
+ {
+ str18 = string.Concat(str18, "<tr style='height: 2.6cm;'>");
+ for (int m = 0; m < num6; m++)
+ {
+ str18 = string.Concat(str18, "<td style='width: ", num7.ToString(CultureInfo.InvariantCulture), "cm; padding: 10px;'><font size='1px' face='Arial'>");
+ if (l + m >= this.Pular)
+ {
+ if (num8 < list.Count)
+ {
+ Documento item1 = list[num8];
+ string[] strArrays4 = new string[] { str18, item1.get_Controle().get_Cliente().get_Nome().Trim(), " <br>", null, null, null, null };
+ if (this.MostrarItem)
+ {
+ if (item1.get_ItensAtivo().Count > 1)
+ {
+ obj2 = "APÓLICE COLETIVA <br>";
+ }
+ else
+ {
+ Item item2 = item1.get_ItensAtivo().FirstOrDefault<Item>();
+ if (item2 != null)
+ {
+ upper = item2.get_Descricao().ToUpper();
+ }
+ else
+ {
+ upper = null;
+ }
+ obj2 = string.Concat(upper, "<br>");
+ }
+ if (obj2 == null)
+ {
+ obj2 = "";
+ }
+ }
+ else
+ {
+ obj2 = null;
+ }
+ strArrays4[3] = (string)obj2;
+ if (this.MostrarApolice)
+ {
+ obj3 = (item1.get_Apolice() == "PROSPECÇÃO" ? string.Format("{0:d} - APÓLICE: {1} <br>", item1.get_Vigencia2(), item1.get_Apolice()) : string.Concat(string.Format("{0:d} - {1:d} - APÓLICE: {2}", item1.get_Vigencia1(), item1.get_Vigencia2(), item1.get_Apolice()), (string.IsNullOrEmpty(item1.get_Endosso()) ? "<br>" : string.Concat(" /", item1.get_Endosso(), " <br>")))) ?? "";
+ }
+ else
+ {
+ obj3 = null;
+ }
+ strArrays4[4] = (string)obj3;
+ strArrays4[5] = (item1.get_Apolice() == "PROSPECÇÃO" ? "" : string.Concat(item1.get_Controle().get_Seguradora().get_Nome(), " - ", item1.get_Controle().get_Ramo().get_Nome(), " <br>"));
+ if (this.MostrarVendedor)
+ {
+ obj4 = (item1.get_VendedorPrincipal() == null ? "" : string.Concat("VENDEDOR: ", item1.get_VendedorPrincipal().get_Nome())) ?? "";
+ }
+ else
+ {
+ obj4 = null;
+ }
+ strArrays4[6] = (string)obj4;
+ str18 = string.Concat(strArrays4);
+ num8++;
+ }
+ this.Pular = 0;
+ }
+ str18 = string.Concat(str18, "</font></td>");
+ }
+ }
+ str18 = string.Concat(str18, "</table>");
+ str18 = string.Concat(str18, "</div>");
+ }
+ this.Pular = (pular1 + list.Count) % (num5 * num6);
+ }
+ else
+ {
+ str18 = "<html><head><style type='text/css'>@page{size: landscape}</style><title>ETIQUETAS</title></head><body>";
+ for (int n = 0; n < list.Count; n++)
+ {
+ str18 = string.Concat(str18, "<div style='clear: both; page-break-after:always; margin-top:");
+ str18 = string.Concat(str18, (n == 0 ? "25%'>" : "30%'>"));
+ str18 = string.Concat(str18, "<div align='center'>");
+ str18 = string.Concat(str18, "<table style='text-align: center;'>");
+ str18 = string.Concat(str18, "<tr style='height: 2.5cm;'>");
+ num = 10.7;
+ str18 = string.Concat(str18, "<td style='width: ", num.ToString(CultureInfo.InvariantCulture), "cm;'><font size='1px' face='Arial'>");
+ Documento documento1 = list[n];
+ string[] strArrays5 = new string[] { str18, documento1.get_Controle().get_Cliente().get_Nome().Trim(), " <br>", null, null, null, null };
+ if (this.MostrarItem)
+ {
+ if (documento1.get_ItensAtivo().Count > 1)
+ {
+ obj5 = "APÓLICE COLETIVA <br>";
+ }
+ else
+ {
+ Item item3 = documento1.get_ItensAtivo().FirstOrDefault<Item>();
+ if (item3 != null)
+ {
+ upper1 = item3.get_Descricao().ToUpper();
+ }
+ else
+ {
+ upper1 = null;
+ }
+ obj5 = string.Concat(upper1, "<br>");
+ }
+ if (obj5 == null)
+ {
+ obj5 = "";
+ }
+ }
+ else
+ {
+ obj5 = null;
+ }
+ strArrays5[3] = (string)obj5;
+ if (this.MostrarApolice)
+ {
+ obj6 = (documento1.get_Apolice() == "PROSPECÇÃO" ? string.Format("{0:d} - APÓLICE: {1} <br>", documento1.get_Vigencia2(), documento1.get_Apolice()) : string.Concat(string.Format("{0:d} - {1:d} - APÓLICE: {2}", documento1.get_Vigencia1(), documento1.get_Vigencia2(), documento1.get_Apolice()), (string.IsNullOrEmpty(documento1.get_Endosso()) ? "<br>" : string.Concat(" /", documento1.get_Endosso(), " <br>")))) ?? "";
+ }
+ else
+ {
+ obj6 = null;
+ }
+ strArrays5[4] = (string)obj6;
+ strArrays5[5] = (documento1.get_Apolice() == "PROSPECÇÃO" ? "" : string.Concat(documento1.get_Controle().get_Seguradora().get_Nome(), " - ", documento1.get_Controle().get_Ramo().get_Nome(), " <br>"));
+ if (this.MostrarVendedor)
+ {
+ obj7 = (documento1.get_VendedorPrincipal() == null ? "" : string.Concat("VENDEDOR: ", documento1.get_VendedorPrincipal().get_Nome())) ?? "";
+ }
+ else
+ {
+ obj7 = null;
+ }
+ strArrays5[6] = (string)obj7;
+ str18 = string.Concat(strArrays5);
+ str18 = string.Concat(str18, "</font></td>");
+ str18 = string.Concat(str18, "</tr>");
+ str18 = string.Concat(str18, "</table>");
+ str18 = string.Concat(str18, "</div>");
+ str18 = string.Concat(str18, "</div>");
+ }
+ }
+ base.RegistrarAcao(string.Format("EMITIU ETIQUETA DE {0} DOCUMENTO{1}", list.Count, (list.Count == 1 ? "" : "S")), (long)0, new TipoTela?(59), string.Concat("IDS DOS DOCUMENTOS:\n", string.Join<long>(", ",
+ from x in list
+ select x.get_Id())));
+ }
+ str18 = string.Concat(str18, "</body></html>");
+ string tempPath = Path.GetTempPath();
+ string str19 = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, (TipoExtrato)0, Funcoes.GetNetworkTime());
+ StreamWriter streamWriter = new StreamWriter(str19, true, Encoding.UTF8);
+ streamWriter.Write(str18);
+ streamWriter.Close();
+ Process.Start(str19);
+ }
+
+ private void EntryOnPropertyChanged(object sender, PropertyChangedEventArgs args)
+ {
+ if (args.PropertyName == "Selecionado")
+ {
+ this.RecheckAllSelected();
+ }
+ }
+
+ internal async Task<List<Documento>> Filtrar(string value)
+ {
+ List<Documento> documentos = await Task.Run<List<Documento>>(() => this.FiltrarApolice(value));
+ return documentos;
+ }
+
+ public List<Documento> FiltrarApolice(string filter)
+ {
+ this.ApolicesFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Documento>(this.Apolices) : new ObservableCollection<Documento>(
+ from x in this.Apolices
+ where ValidationHelper.RemoveDiacritics(x.get_Controle().get_Cliente().get_Nome().Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))
+ orderby x.get_Controle().get_Cliente().get_Nome() descending, x.get_Id()
+ select x));
+ return this.ApolicesFiltrados.ToList<Documento>();
+ }
+
+ private void RecheckAllSelected()
+ {
+ if (this._allSelectedChanging)
+ {
+ return;
+ }
+ try
+ {
+ this._allSelectedChanging = true;
+ if (this.Apolices.All<Documento>((Documento e) => e.get_Selecionado()))
+ {
+ this.AllSelected = new bool?(true);
+ }
+ else if (!this.Apolices.All<Documento>((Documento e) => !e.get_Selecionado()))
+ {
+ this.AllSelected = null;
+ }
+ else
+ {
+ this.AllSelected = new bool?(false);
+ }
+ }
+ finally
+ {
+ this._allSelectedChanging = false;
+ }
+ }
+ }
+} \ No newline at end of file