summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/Componentes/DialogAnaliticoBi.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
commit1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch)
treee1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/Componentes/DialogAnaliticoBi.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/Componentes/DialogAnaliticoBi.cs')
-rw-r--r--Codemerx/Gestor.Application/Componentes/DialogAnaliticoBi.cs387
1 files changed, 387 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/Componentes/DialogAnaliticoBi.cs b/Codemerx/Gestor.Application/Componentes/DialogAnaliticoBi.cs
new file mode 100644
index 0000000..61adc39
--- /dev/null
+++ b/Codemerx/Gestor.Application/Componentes/DialogAnaliticoBi.cs
@@ -0,0 +1,387 @@
+using Gestor.Application.Helpers;
+using Gestor.Application.ViewModels;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.Views.Ferramentas;
+using Gestor.Application.Views.Generic;
+using Gestor.Application.Views.Seguros;
+using Gestor.Model.Attributes;
+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.Relatorios.ClientesAtivosInativos;
+using Gestor.Model.Domain.Seguros;
+using MaterialDesignThemes.Wpf;
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+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;
+
+namespace Gestor.Application.Componentes
+{
+ public class DialogAnaliticoBi : BaseUserControl, IComponentConnector, IStyleConnector
+ {
+ internal AnaliticoViewModel ViewModel;
+
+ internal System.Windows.Controls.Grid MainGrid;
+
+ internal DataGrid Grid;
+
+ internal DataGridTemplateColumn InfoButton;
+
+ internal TextBlock Totalizacao;
+
+ private bool _contentLoaded;
+
+ public List<string> Campos
+ {
+ get;
+ set;
+ }
+
+ public List<Analitico> Lista
+ {
+ get;
+ set;
+ }
+
+ public DialogAnaliticoBi(string titulo, List<Analitico> analitico, string tipo, List<string> campos)
+ {
+ this.ViewModel = new AnaliticoViewModel(tipo);
+ base.DataContext = this.ViewModel;
+ this.InitializeComponent();
+ this.ViewModel.Head = titulo;
+ this.Lista = analitico;
+ this.Campos = campos;
+ this.ConstruirLista();
+ }
+
+ private async Task AbrirTarefa(Tarefa data)
+ {
+ //
+ // Current member / type: System.Threading.Tasks.Task Gestor.Application.Componentes.DialogAnaliticoBi::AbrirTarefa(Gestor.Model.Domain.Ferramentas.Tarefa)
+ // File path: C:\AggerSeguros\Gestor.Application.exe
+ //
+ // Product version: 0.0.0.0
+ // Exception in: System.Threading.Tasks.Task AbrirTarefa(Gestor.Model.Domain.Ferramentas.Tarefa)
+ //
+ // Collection was modified; enumeration operation may not execute.
+ // at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
+ // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(IEnumerable collection) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 384
+ // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.VisitBlockStatement(BlockStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 33
+ // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.Process(DecompilationContext context, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 21
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72
+ // at Telerik.JustDecompiler.Decompiler.Extensions.RunPipeline(DecompilationPipeline pipeline, ILanguage language, MethodBody body, DecompilationContext& context) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 95
+ // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61
+ // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 118
+ //
+ // mailto: JustDecompilePublicFeedback@telerik.com
+
+ }
+
+ private void CheckBox_Checked(object sender, RoutedEventArgs e)
+ {
+ this.Lista.ForEach((Analitico x) => x.set_Selecionado(!x.get_Selecionado()));
+ this.Grid.ItemsSource = null;
+ this.Grid.ItemsSource = this.Lista;
+ }
+
+ private void ConstruirLista()
+ {
+ this.ViewModel.Loading(true);
+ PropertyInfo[] properties = this.Lista.First<Analitico>().GetType().GetProperties();
+ this.Campos.ForEach((string x) => {
+ PropertyInfo propertyInfo = properties.FirstOrDefault<PropertyInfo>((PropertyInfo p) => p.Name == x);
+ if (propertyInfo == null)
+ {
+ return;
+ }
+ object obj = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault<object>();
+ string upper = propertyInfo.Name.ToUpper();
+ if (obj != null)
+ {
+ upper = ((DescriptionAttribute)obj).Description;
+ }
+ object obj1 = propertyInfo.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault<object>();
+ string description = "";
+ if (obj1 != null)
+ {
+ description = ((TipoAttribute)obj1).get_Description();
+ }
+ string str = "";
+ System.Windows.Style item = (System.Windows.Style)System.Windows.Application.Current.Resources["VerticalCenterStyle3"];
+ System.Windows.Style style = (System.Windows.Style)System.Windows.Application.Current.Resources["MaterialDesignDataGridColumnHeader"];
+ if (description == "DATA" || description == "DATA?")
+ {
+ str = "d";
+ item = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalCenterStyle2"];
+ style = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalCenterHeaderStyle"];
+ }
+ else if (description == "PERCENTUAL")
+ {
+ str = "{0:0.00}%";
+ item = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalRightStyle"];
+ style = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalRightHeaderStyle"];
+ }
+ else if (description == "VALOR" || description == "VALOR?")
+ {
+ str = "c";
+ item = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalRightStyle"];
+ style = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalRightHeaderStyle"];
+ }
+ else if (description == "QUANTIDADE")
+ {
+ item = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalCenterStyle2"];
+ style = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalCenterHeaderStyle"];
+ }
+ this.Grid.Columns.Add(new MaterialDataGridTextColumn()
+ {
+ IsReadOnly = true,
+ Header = upper,
+ Binding = new Binding()
+ {
+ Path = new PropertyPath(propertyInfo.Name, Array.Empty<object>()),
+ StringFormat = str,
+ UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
+ },
+ ElementStyle = item,
+ HeaderStyle = style
+ });
+ });
+ this.Grid.ItemsSource = this.Lista;
+ this.Totalizar();
+ this.ViewModel.Loading(false);
+ }
+
+ private async void Email_OnClick(object sender, RoutedEventArgs e)
+ {
+ List<Analitico> lista = this.Lista;
+ if (lista.Any<Analitico>((Analitico x) => x.get_Selecionado()))
+ {
+ if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL"))
+ {
+ Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL");
+ }
+ List<Analitico> analiticos = this.Lista;
+ (new HosterWindow(new MalaDiretaView((
+ from x in analiticos
+ where x.get_Selecionado()
+ select x).Select<Analitico, MalaDireta>((Analitico x) => {
+ MalaDireta malaDiretum = new MalaDireta();
+ Cliente cliente = new Cliente();
+ cliente.set_Id(x.get_Cliente().get_Id());
+ cliente.set_Nome(x.get_Cliente().get_Nome());
+ cliente.set_Nascimento(x.get_Cliente().get_Nascimento());
+ cliente.set_VencimentoHabilitacao(x.get_Cliente().get_VencimentoCnh());
+ malaDiretum.set_Cliente(cliente);
+ malaDiretum.set_Apolice(x.get_Documento());
+ malaDiretum.set_Parcela(x.get_Parcela());
+ malaDiretum.set_Tela(this.ViewModel.Tela);
+ return malaDiretum;
+ }).ToList<MalaDireta>(), null, null, null), "ENVIO DE E-MAIL", new double?((double)1200), new double?((double)600), true)).Show();
+ }
+ else
+ {
+ await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR", "OK", "", false);
+ }
+ }
+
+ private async void Grid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ double? nullable;
+ if (this.Grid.SelectedItem != null && (!(this.ViewModel.Tipo == "PARCELAS") || !(this.ViewModel.Tipo == "APOLICES")))
+ {
+ if (this.ViewModel.Tipo != "CLIENTES")
+ {
+ Analitico selectedItem = (Analitico)this.Grid.SelectedItem;
+ nullable = null;
+ double? nullable1 = nullable;
+ nullable = null;
+ (new HosterWindow(new ApoliceView(selectedItem.get_Documento(), true, false, 0, (long)0, false), string.Concat("CADASTRO DE APÓLICES - ", selectedItem.get_Cliente().get_Nome()), nullable1, nullable, false)).Show();
+ }
+ else
+ {
+ Analitico analitico = (Analitico)this.Grid.SelectedItem;
+ Cliente cliente = await this.ViewModel.CarregaCliente(analitico.get_Cliente().get_Id());
+ nullable = null;
+ double? nullable2 = nullable;
+ nullable = null;
+ (new HosterWindow(new ClienteView(cliente, true, null), string.Concat("CADASTRO DE CLIENTE - ", cliente.get_Nome()), nullable2, nullable, false)).Show();
+ }
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent()
+ {
+ if (this._contentLoaded)
+ {
+ return;
+ }
+ this._contentLoaded = true;
+ System.Windows.Application.LoadComponent(this, new Uri("/Gestor.Application;component/componentes/dialoganaliticobi.xaml", UriKind.Relative));
+ }
+
+ private async void Open_OnClick(object sender, RoutedEventArgs e)
+ {
+ double? nullable;
+ if (this.Grid.SelectedItem != null && (!(this.ViewModel.Tipo == "PARCELAS") || !(this.ViewModel.Tipo == "APOLICES")))
+ {
+ if (this.ViewModel.Tipo != "CLIENTES")
+ {
+ Analitico selectedItem = (Analitico)this.Grid.SelectedItem;
+ nullable = null;
+ double? nullable1 = nullable;
+ nullable = null;
+ (new HosterWindow(new ApoliceView(selectedItem.get_Documento(), true, false, 0, (long)0, false), string.Concat("CADASTRO DE APÓLICES - ", selectedItem.get_Cliente().get_Nome()), nullable1, nullable, false)).Show();
+ }
+ else
+ {
+ Analitico analitico = (Analitico)this.Grid.SelectedItem;
+ Cliente cliente = await this.ViewModel.CarregaCliente(analitico.get_Cliente().get_Id());
+ nullable = null;
+ double? nullable2 = nullable;
+ nullable = null;
+ (new HosterWindow(new ClienteView(cliente, true, null), string.Concat("CADASTRO DE CLIENTE - ", cliente.get_Nome()), nullable2, nullable, false)).Show();
+ }
+ }
+ }
+
+ private async void Print_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.Loading(true);
+ await this.ViewModel.Print(this.Grid);
+ this.ViewModel.Loading(false);
+ }
+
+ [DebuggerNonUserCode]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
+ {
+ switch (connectionId)
+ {
+ case 1:
+ {
+ this.MainGrid = (System.Windows.Controls.Grid)target;
+ return;
+ }
+ case 2:
+ {
+ this.Grid = (DataGrid)target;
+ this.Grid.MouseDoubleClick += new MouseButtonEventHandler(this.Grid_OnMouseDoubleClick);
+ return;
+ }
+ case 3:
+ case 5:
+ {
+ this._contentLoaded = true;
+ return;
+ }
+ case 4:
+ {
+ this.InfoButton = (DataGridTemplateColumn)target;
+ return;
+ }
+ case 6:
+ {
+ this.Totalizacao = (TextBlock)target;
+ return;
+ }
+ case 7:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Tarefas_OnClick);
+ return;
+ }
+ case 8:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Email_OnClick);
+ return;
+ }
+ case 9:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Print_OnClick);
+ return;
+ }
+ default:
+ {
+ this._contentLoaded = true;
+ return;
+ }
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target)
+ {
+ if (connectionId != 3)
+ {
+ if (connectionId != 5)
+ {
+ return;
+ }
+ ((Button)target).Click += new RoutedEventHandler(this.Open_OnClick);
+ return;
+ }
+ ((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBox_Checked);
+ ((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBox_Checked);
+ }
+
+ private async void Tarefas_OnClick(object sender, RoutedEventArgs e)
+ {
+ Tarefa tarefa = new Tarefa();
+ tarefa.set_Entidade(1);
+ tarefa.set_Titulo(this.ViewModel.Head);
+ tarefa.set_Usuario(Recursos.Usuario);
+ tarefa.set_Agendamento(Funcoes.GetNetworkTime());
+ await this.AbrirTarefa(tarefa);
+ List<Analitico> lista = this.Lista;
+ List<Analitico> list = (
+ from x in lista
+ where x.get_Selecionado()
+ select x).ToList<Analitico>();
+ this.Lista = this.Lista.Except<Analitico>(list).ToList<Analitico>();
+ this.Grid.ItemsSource = null;
+ this.Grid.ItemsSource = this.Lista;
+ this.Totalizar();
+ }
+
+ private void Totalizar()
+ {
+ string tipo = this.ViewModel.Tipo;
+ if (tipo == "CLIENTES")
+ {
+ this.Totalizacao.Text = string.Format("TOTAL DE {0} CLIENTES", this.Lista.Count);
+ return;
+ }
+ if (tipo == "PARCELAS")
+ {
+ this.Totalizacao.Text = string.Format("TOTAL DE {0} SEGUROS SOMANDO O VALOR DE {1:c}", this.Lista.Count, this.Lista.Sum<Analitico>((Analitico x) => x.get_Valor()));
+ return;
+ }
+ if (tipo == "COMISSÃO")
+ {
+ this.Totalizacao.Text = string.Format("TOTAL DE {0} SEGUROS SOMANDO O VALOR DE COMISSÃO RECEBIDA DE {1:c}", this.Lista.Count, this.Lista.Sum<Analitico>((Analitico x) => x.get_ValorComissao()));
+ return;
+ }
+ this.Totalizacao.Text = string.Format("TOTAL DE {0} SEGUROS SOMANDO O VALOR DE {1:c}", this.Lista.Count, this.Lista.Sum<Analitico>((Analitico x) => x.get_PremioLiquido()));
+ }
+ }
+} \ No newline at end of file