summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Componentes/DialogAnaliticoBi.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Componentes/DialogAnaliticoBi.cs')
-rw-r--r--Decompiler/Gestor.Application.Componentes/DialogAnaliticoBi.cs469
1 files changed, 469 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Componentes/DialogAnaliticoBi.cs b/Decompiler/Gestor.Application.Componentes/DialogAnaliticoBi.cs
new file mode 100644
index 0000000..6c50ba7
--- /dev/null
+++ b/Decompiler/Gestor.Application.Componentes/DialogAnaliticoBi.cs
@@ -0,0 +1,469 @@
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Reflection;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Input;
+using System.Windows.Markup;
+using Gestor.Application.Helpers;
+using Gestor.Application.ViewModels;
+using Gestor.Application.Views.Ferramentas;
+using Gestor.Application.Views.Generic;
+using Gestor.Application.Views.Seguros;
+using Gestor.Model.Attributes;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.BI;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.MalaDireta;
+using Gestor.Model.Domain.Seguros;
+using MaterialDesignThemes.Wpf;
+
+namespace Gestor.Application.Componentes;
+
+public class DialogAnaliticoBi : BaseUserControl, IComponentConnector, IStyleConnector
+{
+ internal AnaliticoViewModel ViewModel;
+
+ internal Grid MainGrid;
+
+ internal DataGrid Grid;
+
+ internal DataGridTemplateColumn InfoButton;
+
+ internal TextBlock Totalizacao;
+
+ private bool _contentLoaded;
+
+ public List<Analitico> Lista { get; set; }
+
+ public List<string> Campos { get; set; }
+
+ public DialogAnaliticoBi(string titulo, List<Analitico> analitico, string tipo, List<string> campos)
+ {
+ ViewModel = new AnaliticoViewModel(tipo);
+ ((FrameworkElement)this).DataContext = ViewModel;
+ InitializeComponent();
+ ViewModel.Head = titulo;
+ Lista = analitico;
+ Campos = campos;
+ ConstruirLista();
+ }
+
+ private void ConstruirLista()
+ {
+ ViewModel.Loading(isLoading: true);
+ PropertyInfo[] properties = ((object)Lista.First()).GetType().GetProperties();
+ Campos.ForEach(delegate(string x)
+ {
+ //IL_00ad: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b4: Expected O, but got Unknown
+ //IL_00c8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00cf: Expected O, but got Unknown
+ //IL_0086: Unknown result type (might be due to invalid IL or missing references)
+ //IL_014c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0153: Expected O, but got Unknown
+ //IL_0167: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016e: Expected O, but got Unknown
+ //IL_0237: Unknown result type (might be due to invalid IL or missing references)
+ //IL_023c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0243: Unknown result type (might be due to invalid IL or missing references)
+ //IL_024a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_024b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0250: Unknown result type (might be due to invalid IL or missing references)
+ //IL_025c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0266: Expected O, but got Unknown
+ //IL_0266: Unknown result type (might be due to invalid IL or missing references)
+ //IL_026e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_027a: Expected O, but got Unknown
+ //IL_027a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0282: Unknown result type (might be due to invalid IL or missing references)
+ //IL_028f: Expected O, but got Unknown
+ //IL_018e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0195: Expected O, but got Unknown
+ //IL_01a9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01b0: Expected O, but got Unknown
+ //IL_01cd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01d4: Expected O, but got Unknown
+ //IL_01e8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01ef: Expected O, but got Unknown
+ //IL_0205: Unknown result type (might be due to invalid IL or missing references)
+ //IL_020c: Expected O, but got Unknown
+ //IL_0220: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0227: Expected O, but got Unknown
+ PropertyInfo propertyInfo = properties.FirstOrDefault((PropertyInfo p) => p.Name == x);
+ if (!(propertyInfo == null))
+ {
+ object obj = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), inherit: true).FirstOrDefault();
+ string header = propertyInfo.Name.ToUpper();
+ if (obj != null)
+ {
+ header = ((DescriptionAttribute)obj).Description;
+ }
+ object obj2 = propertyInfo.GetCustomAttributes(typeof(TipoAttribute), inherit: true).FirstOrDefault();
+ string text = "";
+ if (obj2 != null)
+ {
+ text = ((TipoAttribute)obj2).Description;
+ }
+ string stringFormat = "";
+ Style elementStyle = (Style)Application.Current.Resources[(object)"VerticalCenterStyle3"];
+ Style headerStyle = (Style)Application.Current.Resources[(object)"MaterialDesignDataGridColumnHeader"];
+ switch (text)
+ {
+ case "DATA":
+ case "DATA?":
+ stringFormat = "d";
+ elementStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterStyle2"];
+ headerStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterHeaderStyle"];
+ break;
+ case "PERCENTUAL":
+ stringFormat = "{0:0.00}%";
+ elementStyle = (Style)Application.Current.Resources[(object)"HorizontalRightStyle"];
+ headerStyle = (Style)Application.Current.Resources[(object)"HorizontalRightHeaderStyle"];
+ break;
+ case "VALOR":
+ case "VALOR?":
+ stringFormat = "c";
+ elementStyle = (Style)Application.Current.Resources[(object)"HorizontalRightStyle"];
+ headerStyle = (Style)Application.Current.Resources[(object)"HorizontalRightHeaderStyle"];
+ break;
+ case "QUANTIDADE":
+ elementStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterStyle2"];
+ headerStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterHeaderStyle"];
+ break;
+ }
+ Grid.Columns.Add((DataGridColumn)new MaterialDataGridTextColumn
+ {
+ IsReadOnly = true,
+ Header = header,
+ Binding = (BindingBase)new Binding
+ {
+ Path = new PropertyPath(propertyInfo.Name, Array.Empty<object>()),
+ StringFormat = stringFormat,
+ UpdateSourceTrigger = (UpdateSourceTrigger)1
+ },
+ ElementStyle = elementStyle,
+ HeaderStyle = headerStyle
+ });
+ }
+ });
+ ((ItemsControl)Grid).ItemsSource = Lista;
+ Totalizar();
+ ViewModel.Loading(isLoading: false);
+ }
+
+ private void Totalizar()
+ {
+ switch (ViewModel.Tipo)
+ {
+ case "CLIENTES":
+ Totalizacao.Text = $"TOTAL DE {Lista.Count} CLIENTES";
+ break;
+ default:
+ Totalizacao.Text = $"TOTAL DE {Lista.Count} SEGUROS SOMANDO O VALOR DE {Lista.Sum((Analitico x) => x.PremioLiquido):c}";
+ break;
+ case "PARCELAS":
+ Totalizacao.Text = $"TOTAL DE {Lista.Count} SEGUROS SOMANDO O VALOR DE {Lista.Sum((Analitico x) => x.Valor):c}";
+ break;
+ case "COMISSÃO":
+ Totalizacao.Text = $"TOTAL DE {Lista.Count} SEGUROS SOMANDO O VALOR DE COMISSÃO RECEBIDA DE {Lista.Sum((Analitico x) => x.ValorComissao):c}";
+ break;
+ }
+ }
+
+ private void CheckBox_Checked(object sender, RoutedEventArgs e)
+ {
+ Lista.ForEach(delegate(Analitico x)
+ {
+ x.Selecionado = !x.Selecionado;
+ });
+ ((ItemsControl)Grid).ItemsSource = null;
+ ((ItemsControl)Grid).ItemsSource = Lista;
+ }
+
+ private async void Tarefas_OnClick(object sender, RoutedEventArgs e)
+ {
+ Tarefa data = new Tarefa
+ {
+ Entidade = (TipoTarefa)1,
+ Titulo = ViewModel.Head,
+ Usuario = Recursos.Usuario,
+ Agendamento = Funcoes.GetNetworkTime()
+ };
+ await AbrirTarefa(data);
+ List<Analitico> second = Lista.Where((Analitico x) => x.Selecionado).ToList();
+ Lista = Lista.Except(second).ToList();
+ ((ItemsControl)Grid).ItemsSource = null;
+ ((ItemsControl)Grid).ItemsSource = Lista;
+ Totalizar();
+ }
+
+ private async Task AbrirTarefa(Tarefa data)
+ {
+ ViewModel.Loading(isLoading: true);
+ Tarefa tarefa;
+ while (true)
+ {
+ tarefa = await ViewModel.ShowTarefaDialog(data, nota: true);
+ List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
+ if (tarefa == null)
+ {
+ ViewModel.Loading(isLoading: false);
+ return;
+ }
+ tarefa.AgendamentoRetroativo = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 45);
+ List<KeyValuePair<string, string>> list2 = tarefa.Validate();
+ if (list2 == null || list2.Count == 0)
+ {
+ break;
+ }
+ if (list2.Count > 0)
+ {
+ list.AddRange(list2);
+ }
+ await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK");
+ }
+ if (tarefa.Usuario == null)
+ {
+ tarefa.Usuario = tarefa.UsuariosVinculados.FirstOrDefault();
+ }
+ List<ResponsavelTarefa> responsaveis = ((IEnumerable<Usuario>)tarefa.UsuariosVinculados).Select((Func<Usuario, ResponsavelTarefa>)((Usuario x) => new ResponsavelTarefa
+ {
+ IdTarefa = ((DomainBase)tarefa).Id,
+ Usuario = x
+ })).ToList();
+ List<Analitico> source = Lista.Where((Analitico x) => x.Selecionado).ToList();
+ List<Tarefa> list3;
+ switch (ViewModel.Tipo)
+ {
+ case "CLIENTES":
+ list3 = ((IEnumerable<Analitico>)source).Select((Func<Analitico, Tarefa>)((Analitico x) => new Tarefa
+ {
+ Entidade = (TipoTarefa)2,
+ IdEntidade = x.Cliente.Id,
+ Agendamento = tarefa.Agendamento,
+ Titulo = tarefa.Titulo,
+ Descricao = tarefa.Anotacoes,
+ Usuario = tarefa.Usuario,
+ UsuarioCadastro = Recursos.Usuario,
+ Cliente = x.Nome,
+ IdCliente = x.Cliente.Id,
+ Responsaveis = responsaveis
+ })).ToList();
+ break;
+ default:
+ list3 = ((IEnumerable<Analitico>)source).Select((Func<Analitico, Tarefa>)((Analitico x) => new Tarefa
+ {
+ Entidade = (TipoTarefa)0,
+ IdEntidade = ((DomainBase)x.Documento).Id,
+ Agendamento = tarefa.Agendamento,
+ Titulo = tarefa.Titulo,
+ Descricao = tarefa.Anotacoes,
+ Usuario = tarefa.Usuario,
+ UsuarioCadastro = Recursos.Usuario,
+ Cliente = x.Nome,
+ IdCliente = ((DomainBase)x.Documento.Controle.Cliente).Id,
+ Referencia = ((x.Documento.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Documento.Apolice)) ? ("APÓLICE NÚMERO " + x.Documento.Apolice) : ((x.Documento.Tipo > 0) ? ("APÓLICE NÚMERO " + x.Documento.Apolice + " ENDOSSO " + x.Documento.Endosso) : ("PROPOSTA NÚMERO " + x.Documento.Proposta))),
+ Responsaveis = responsaveis
+ })).ToList();
+ break;
+ case "PARCELAS":
+ case "COMISSÃO":
+ list3 = ((IEnumerable<Analitico>)source).Select((Func<Analitico, Tarefa>)((Analitico x) => new Tarefa
+ {
+ Entidade = (TipoTarefa)3,
+ IdEntidade = ((DomainBase)x.Parcela).Id,
+ Agendamento = tarefa.Agendamento,
+ Titulo = tarefa.Titulo,
+ Descricao = tarefa.Anotacoes,
+ Usuario = tarefa.Usuario,
+ UsuarioCadastro = Recursos.Usuario,
+ Cliente = x.Nome,
+ IdCliente = ((DomainBase)x.Parcela.Documento.Controle.Cliente).Id,
+ Referencia = ((x.Parcela.Documento.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Parcela.Documento.Apolice)) ? $"PARCELA {x.NumeroParcela} DA APÓLICE {x.Parcela.Documento.Apolice}" : ((x.Documento.Tipo > 0) ? $"PARCELA {x.NumeroParcela} DA APÓLICE {x.Parcela.Documento.Apolice} ENDOSSO {x.Parcela.Documento.Endosso}" : $"PARCELA {x.NumeroParcela} DA PROPOSTA {x.Parcela.Documento.Proposta}")),
+ Responsaveis = responsaveis
+ })).ToList();
+ break;
+ }
+ if (list3.Count == 0)
+ {
+ ViewModel.Loading(isLoading: false);
+ await ViewModel.ShowMessage("FALHA AO CRIAR TAREFA.");
+ return;
+ }
+ await ViewModel.Save(list3);
+ ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.");
+ ViewModel.Alterar(alterar: false);
+ ViewModel.Loading(isLoading: false);
+ }
+
+ private async void Email_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (!Lista.Any((Analitico x) => x.Selecionado))
+ {
+ await ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR");
+ return;
+ }
+ if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL"))
+ {
+ Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL");
+ }
+ ((Window)new HosterWindow((ContentControl)(object)new MalaDiretaView(Lista.Where((Analitico x) => x.Selecionado).Select((Func<Analitico, MalaDireta>)((Analitico x) => new MalaDireta
+ {
+ Cliente = new Cliente
+ {
+ Id = x.Cliente.Id,
+ Nome = x.Cliente.Nome,
+ Nascimento = x.Cliente.Nascimento,
+ VencimentoHabilitacao = x.Cliente.VencimentoCnh
+ },
+ Apolice = x.Documento,
+ Parcela = x.Parcela,
+ Tela = ViewModel.Tela
+ })).ToList()), "ENVIO DE E-MAIL", 1200.0, 600.0, canMaximize: true)).Show();
+ }
+
+ private async void Grid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ if (((Selector)Grid).SelectedItem != null && (!(ViewModel.Tipo == "PARCELAS") || !(ViewModel.Tipo == "APOLICES")))
+ {
+ if (ViewModel.Tipo == "CLIENTES")
+ {
+ Analitico val = (Analitico)((Selector)Grid).SelectedItem;
+ Cliente val2 = await ViewModel.CarregaCliente(val.Cliente.Id);
+ ((Window)new HosterWindow((ContentControl)(object)new ClienteView(val2, lockInsert: true), "CADASTRO DE CLIENTE - " + val2.Nome)).Show();
+ }
+ else
+ {
+ Analitico val3 = (Analitico)((Selector)Grid).SelectedItem;
+ ((Window)new HosterWindow((ContentControl)(object)new ApoliceView(val3.Documento, lockInsert: true, invoke: false, (AcessoApolice)0, 0L), "CADASTRO DE APÓLICES - " + val3.Cliente.Nome)).Show();
+ }
+ }
+ }
+
+ private async void Print_OnClick(object sender, RoutedEventArgs e)
+ {
+ ViewModel.Loading(isLoading: true);
+ await ViewModel.Print(Grid);
+ ViewModel.Loading(isLoading: false);
+ }
+
+ private async void Open_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (((Selector)Grid).SelectedItem != null && (!(ViewModel.Tipo == "PARCELAS") || !(ViewModel.Tipo == "APOLICES")))
+ {
+ if (ViewModel.Tipo == "CLIENTES")
+ {
+ Analitico val = (Analitico)((Selector)Grid).SelectedItem;
+ Cliente val2 = await ViewModel.CarregaCliente(val.Cliente.Id);
+ ((Window)new HosterWindow((ContentControl)(object)new ClienteView(val2, lockInsert: true), "CADASTRO DE CLIENTE - " + val2.Nome)).Show();
+ }
+ else
+ {
+ Analitico val3 = (Analitico)((Selector)Grid).SelectedItem;
+ ((Window)new HosterWindow((ContentControl)(object)new ApoliceView(val3.Documento, lockInsert: true, invoke: false, (AcessoApolice)0, 0L), "CADASTRO DE APÓLICES - " + val3.Cliente.Nome)).Show();
+ }
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent()
+ {
+ if (!_contentLoaded)
+ {
+ _contentLoaded = true;
+ Uri uri = new Uri("/Gestor.Application;component/componentes/dialoganaliticobi.xaml", UriKind.Relative);
+ Application.LoadComponent((object)this, uri);
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ void IComponentConnector.Connect(int connectionId, object target)
+ {
+ //IL_0033: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003d: Expected O, but got Unknown
+ //IL_0040: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004a: Expected O, but got Unknown
+ //IL_0057: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0061: Expected O, but got Unknown
+ //IL_0064: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006e: Expected O, but got Unknown
+ //IL_0071: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007b: Expected O, but got Unknown
+ //IL_007d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0089: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0093: Expected O, but got Unknown
+ //IL_0095: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ab: Expected O, but got Unknown
+ //IL_00ad: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c3: Expected O, but got Unknown
+ switch (connectionId)
+ {
+ case 1:
+ MainGrid = (Grid)target;
+ break;
+ case 2:
+ Grid = (DataGrid)target;
+ ((Control)Grid).MouseDoubleClick += new MouseButtonEventHandler(Grid_OnMouseDoubleClick);
+ break;
+ case 4:
+ InfoButton = (DataGridTemplateColumn)target;
+ break;
+ case 6:
+ Totalizacao = (TextBlock)target;
+ break;
+ case 7:
+ ((MenuItem)target).Click += new RoutedEventHandler(Tarefas_OnClick);
+ break;
+ case 8:
+ ((MenuItem)target).Click += new RoutedEventHandler(Email_OnClick);
+ break;
+ case 9:
+ ((MenuItem)target).Click += new RoutedEventHandler(Print_OnClick);
+ break;
+ default:
+ _contentLoaded = true;
+ break;
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ void IStyleConnector.Connect(int connectionId, object target)
+ {
+ //IL_000a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0020: Expected O, but got Unknown
+ //IL_0021: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0037: Expected O, but got Unknown
+ //IL_0039: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0045: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004f: Expected O, but got Unknown
+ switch (connectionId)
+ {
+ case 3:
+ ((ToggleButton)(CheckBox)target).Checked += new RoutedEventHandler(CheckBox_Checked);
+ ((ToggleButton)(CheckBox)target).Unchecked += new RoutedEventHandler(CheckBox_Checked);
+ break;
+ case 5:
+ ((ButtonBase)(Button)target).Click += new RoutedEventHandler(Open_OnClick);
+ break;
+ }
+ }
+}