summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/Views/Relatorios/RelatorioView.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/Views/Relatorios/RelatorioView.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/Views/Relatorios/RelatorioView.cs')
-rw-r--r--Codemerx/Gestor.Application/Views/Relatorios/RelatorioView.cs1167
1 files changed, 1167 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/Views/Relatorios/RelatorioView.cs b/Codemerx/Gestor.Application/Views/Relatorios/RelatorioView.cs
new file mode 100644
index 0000000..69fdf01
--- /dev/null
+++ b/Codemerx/Gestor.Application/Views/Relatorios/RelatorioView.cs
@@ -0,0 +1,1167 @@
+using CurrencyTextBoxControl;
+using Gestor.Application.Actions;
+using Gestor.Application.Componentes;
+using Gestor.Application.Drawers.Relatorios;
+using Gestor.Application.Helpers;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.ViewModels.Relatorios;
+using Gestor.Application.Views.Ferramentas;
+using Gestor.Application.Views.Generic;
+using Gestor.Common.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+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;
+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.Runtime.CompilerServices;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Threading;
+using Xceed.Wpf.AvalonDock.Controls;
+
+namespace Gestor.Application.Views.Relatorios
+{
+ public class RelatorioView : BaseUserControl, IComponentConnector, IStyleConnector
+ {
+ internal RelatorioViewModel ViewModel;
+
+ internal Image ProgressRing;
+
+ internal ComboBox RelatorioBox;
+
+ internal CurrencyTextBox ValorInicioBox;
+
+ internal CurrencyTextBox ValorFimBox;
+
+ internal DatePicker InicioBox;
+
+ internal DatePicker FimBox;
+
+ internal ToggleButton VisualizarRamosVendedoresTooltip;
+
+ internal MenuItem GerarRelatorioButton;
+
+ internal ComboBox RamoBox;
+
+ internal ContentControl ReportControl;
+
+ internal Gestor.Application.Componentes.WebEditor WebEditor;
+
+ internal PopupBox HelpPopup;
+
+ internal TextBlock NaoHaDados;
+
+ private bool _contentLoaded;
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ internal Delegate _CreateDelegate(Type delegateType, string handler)
+ {
+ return Delegate.CreateDelegate(delegateType, this, handler);
+ }
+
+ public RelatorioView(string opcao)
+ {
+ this.ViewModel = new RelatorioViewModel(opcao);
+ base.DataContext = this.ViewModel;
+ this.InitializeComponent();
+ System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher;
+ if (dispatcher != null)
+ {
+ dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad));
+ }
+ else
+ {
+ }
+ this.ViewModel.Head = string.Concat(Recursos.Usuario.get_Nome(), ", VOCÊ ESTÁ EM RELATÓRIOS");
+ Gestor.Application.Actions.Actions.RecarregarRelatorios = (Action<string>)Delegate.Combine(Gestor.Application.Actions.Actions.RecarregarRelatorios, new Action<string>(this.Recarregar));
+ }
+
+ private void AbrirInfo_Click(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.InfoVisibility = (this.ViewModel.InfoVisibility == System.Windows.Visibility.Collapsed ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed);
+ }
+
+ private async Task AbrirTarefa(Tarefa data)
+ {
+ Tarefa tarefa;
+ this.ViewModel.IsEnabled = false;
+ this.ViewModel.Carregando = true;
+ while (true)
+ {
+ Tarefa tarefa1 = await this.ViewModel.ShowTarefaDialog(data, true, false);
+ tarefa = tarefa1;
+ if (tarefa == null)
+ {
+ this.ViewModel.IsEnabled = true;
+ this.ViewModel.Carregando = false;
+ return;
+ }
+ if (tarefa.get_Usuario() == null)
+ {
+ tarefa.set_Usuario(tarefa.get_UsuariosVinculados().FirstOrDefault<Usuario>());
+ }
+ List<ResponsavelTarefa> list = tarefa.get_UsuariosVinculados().Select<Usuario, ResponsavelTarefa>((Usuario x) => {
+ ResponsavelTarefa responsavelTarefa = new ResponsavelTarefa();
+ responsavelTarefa.set_IdTarefa(tarefa.get_Id());
+ responsavelTarefa.set_Usuario(x);
+ return responsavelTarefa;
+ }).ToList<ResponsavelTarefa>();
+ tarefa.set_Responsaveis(list);
+ tarefa.set_Anotacoes(string.Concat("<p>", tarefa.get_Anotacoes(), "</p>"));
+ Tarefa tarefa2 = tarefa;
+ List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
+ tarefa2.set_AgendamentoRetroativo(configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 45));
+ List<KeyValuePair<string, string>> keyValuePairs = tarefa.Validate();
+ if (string.IsNullOrWhiteSpace(tarefa.get_Anotacoes()))
+ {
+ keyValuePairs.Add(new KeyValuePair<string, string>("ANOTAÇÕES", "OBRIGATÓRIO"));
+ }
+ if (keyValuePairs == null || keyValuePairs.Count == 0)
+ {
+ break;
+ }
+ await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", "");
+ }
+ List<Tarefa> tarefas = this.ViewModel.GerarTarefas(tarefa);
+ if (tarefas == null || tarefas.Count == 0)
+ {
+ this.ViewModel.IsEnabled = true;
+ this.ViewModel.Carregando = false;
+ await this.ViewModel.ShowMessage("FALHA AO CRIAR TAREFA.", "OK", "", false);
+ }
+ else
+ {
+ await this.ViewModel.SalvarTarefas(tarefas);
+ this.ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.", true);
+ this.ViewModel.Alterar(false);
+ this.ViewModel.IsEnabled = true;
+ this.ViewModel.Carregando = false;
+ }
+ return;
+ this.ViewModel.IsEnabled = true;
+ this.ViewModel.Carregando = false;
+ }
+
+ private async void Acompanhamento_OnClick(object sender, RoutedEventArgs e)
+ {
+ await this.ViewModel.Acompanhamento();
+ }
+
+ private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.AdcionarFiltroPersonalizado();
+ }
+
+ private void AdicionarRamo_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.AdicionarRamo();
+ }
+
+ private async void Apolice_OnClick(object sender, RoutedEventArgs e)
+ {
+ List<MalaDireta> malaDiretas;
+ this.ViewModel.Loading(true);
+ List<MalaDireta> malaDiretas1 = await this.ViewModel.CriarLista();
+ if (malaDiretas1 == null)
+ {
+ malaDiretas = new List<MalaDireta>();
+ }
+ else
+ {
+ List<MalaDireta> malaDiretas2 = malaDiretas1;
+ malaDiretas = malaDiretas2.Where<MalaDireta>((MalaDireta x) => {
+ if (x.get_Apolice().get_Tipo() == 0 && !string.IsNullOrWhiteSpace(x.get_Apolice().get_Apolice()))
+ {
+ return true;
+ }
+ if (x.get_Apolice().get_Tipo() != 1)
+ {
+ return false;
+ }
+ return !string.IsNullOrWhiteSpace(x.get_Apolice().get_Endosso());
+ }).ToList<MalaDireta>();
+ }
+ malaDiretas1 = malaDiretas;
+ if (malaDiretas1.Count != 0)
+ {
+ if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL"))
+ {
+ Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL");
+ }
+ this.ViewModel.Loading(false);
+ (new HosterWindow(new MalaDiretaView(malaDiretas1, 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);
+ this.ViewModel.Loading(false);
+ }
+ }
+
+ private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e)
+ {
+ if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text()))
+ {
+ return;
+ }
+ this.ViewModel.FiltrarUsuario("");
+ }
+
+ private void AutoCompleteBoxUsuario_Populating(object sender, PopulatingEventArgs e)
+ {
+ e.set_Cancel(true);
+ this.ViewModel.Filtrar(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task<List<Usuario>> searchResult) => {
+ if (searchResult.Result == null)
+ {
+ return;
+ }
+ AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender;
+ autoCompleteBox.set_ItemsSource(searchResult.Result);
+ autoCompleteBox.PopulateComplete();
+ }, TaskScheduler.FromCurrentSynchronizationContext());
+ }
+
+ private void ConfigurarRelatorio_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.ShowDrawer(new ConfiguracaoRelatorio(this.ViewModel), 0, false);
+ }
+
+ private void ContentLoad()
+ {
+ this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
+ this.InicioBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
+ this.InicioBox.SelectedDateChanged += new EventHandler<SelectionChangedEventArgs>(this.Periodo_OnSelectedDateChanged);
+ this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
+ this.FimBox.PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
+ this.FimBox.SelectedDateChanged += new EventHandler<SelectionChangedEventArgs>(this.Periodo_OnSelectedDateChanged);
+ this.RelatorioBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoRelatorio_OnSelectionChanged);
+ }
+
+ private void CopyLink_OnClick(object sender, RoutedEventArgs e)
+ {
+ Button button = (Button)sender;
+ if (button == null || button.DataContext == null)
+ {
+ return;
+ }
+ AjudaTela dataContext = (AjudaTela)button.DataContext;
+ string str = "";
+ if (dataContext.get_Minuto() > 0 || dataContext.get_Segundo() > 0)
+ {
+ str = string.Format("&start={0}", dataContext.get_Minuto() * 60 + dataContext.get_Segundo());
+ }
+ string.Concat(dataContext.get_Link(), str).CopyToClipboard();
+ this.ViewModel.ToggleSnackBar("LINK COPIADO", true);
+ }
+
+ private async void Email_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.Loading(true);
+ List<MalaDireta> malaDiretas = await this.ViewModel.CriarLista();
+ if (malaDiretas == null || malaDiretas.Count == 0)
+ {
+ await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR.", "OK", "", false);
+ this.ViewModel.Loading(false);
+ }
+ else
+ {
+ if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL"))
+ {
+ Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL");
+ }
+ this.ViewModel.Loading(false);
+ (new HosterWindow(new MalaDiretaView(malaDiretas, null, null, null), "ENVIO DE E-MAIL", new double?((double)1200), new double?((double)600), true)).Show();
+ }
+ }
+
+ private async void Etiquetas_OnClick(object sender, RoutedEventArgs e)
+ {
+ bool flag;
+ this.ViewModel.Loading(true);
+ List<Documento> documentos = await this.ViewModel.CriarListaEtiqueta();
+ if (documentos == null || documentos.Count == 0)
+ {
+ await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR.", "OK", "", false);
+ this.ViewModel.Loading(false);
+ }
+ else if (!Funcoes.IsWindowOpen<HosterWindow>("ETIQUETAS"))
+ {
+ flag = (this.ViewModel.Relatorio == null ? true : this.ViewModel.Relatorio == 1);
+ bool flag1 = flag;
+ this.ViewModel.Loading(false);
+ (new HosterWindow(new EtiquetaView(documentos, flag1), "ETIQUETAS", new double?((double)900), new double?((double)600), false)).Show();
+ }
+ }
+
+ private void ExcluirFiltro_OnClick(object sender, RoutedEventArgs e)
+ {
+ Chip chip = sender as Chip;
+ if (chip == null)
+ {
+ return;
+ }
+ ListBox listBox = Extentions.FindVisualAncestor<ListBox>(chip);
+ FiltroPersonalizado item = (FiltroPersonalizado)listBox.Items[listBox.Items.IndexOf(chip.DataContext)];
+ if (item == null)
+ {
+ return;
+ }
+ this.ViewModel.FiltroPersonalizadoSelecionado.Remove(item);
+ this.ViewModel.PesquisaPersonalizada();
+ }
+
+ private void ExcluirRamo_onClick(object sender, RoutedEventArgs e)
+ {
+ Chip chip = sender as Chip;
+ if (chip == null)
+ {
+ return;
+ }
+ Ramo dataContext = (Ramo)chip.DataContext;
+ if (dataContext == null)
+ {
+ return;
+ }
+ this.ViewModel.RemoverRamo(dataContext);
+ }
+
+ private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.Carregando = true;
+ this.ViewModel.IsEnabled = false;
+ await this.ViewModel.GerarExcel();
+ this.ViewModel.IsEnabled = true;
+ this.ViewModel.Carregando = false;
+ }
+
+ private void Extrato_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.ExibirExtratoDrawer();
+ }
+
+ private void Fechar_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.HelpPopup.set_IsPopupOpen(!this.HelpPopup.get_IsPopupOpen());
+ }
+
+ private void FecharFiltro_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.VisibilityFiltroPersonalizado = (this.ViewModel.VisibilityFiltroPersonalizado == System.Windows.Visibility.Collapsed ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed);
+ }
+
+ private void FecharFiltroUsuario_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.VisibilityUsuarios = false;
+ }
+
+ private void FecharInfo_Click(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.InfoVisibility = (this.ViewModel.InfoVisibility == System.Windows.Visibility.Collapsed ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed);
+ }
+
+ private async void GerarResultados_OnClick(object sender, RoutedEventArgs e)
+ {
+ object obj;
+ bool flag;
+ GridRelatorio gridRelatorio;
+ this.InicioBox.Text = ValidationHelper.FormatDate(this.InicioBox.Text);
+ this.FimBox.Text = ValidationHelper.FormatDate(this.FimBox.Text);
+ try
+ {
+ this.ViewModel.Inicio = Convert.ToDateTime(this.InicioBox.Text);
+ this.ViewModel.Fim = Convert.ToDateTime(this.FimBox.Text);
+ }
+ catch (Exception exception)
+ {
+ gridRelatorio = null;
+ return;
+ }
+ if (this.ViewModel.Inicio > this.ViewModel.Fim)
+ {
+ await this.ViewModel.ShowMessage("A DATA FINAL NÃO PODE SER MENOR QUE A DATA INICIAL DO FILTRO.", "OK", "", false);
+ }
+ else if (this.RelatorioBox.Items.Count == 0)
+ {
+ await this.ViewModel.ShowMessage("NÃO HÁ RELATÓRIOS QUE VOCÊ POSSA GERAR.", "OK", "", false);
+ }
+ else if (this.ViewModel.InicioValor <= this.ViewModel.FimValor)
+ {
+ this.ViewModel.Carregando = true;
+ this.ViewModel.IsEnabled = false;
+ this.ViewModel.VisibilityHtml = false;
+ if (this.ViewModel.Report != null)
+ {
+ this.ViewModel.Report = null;
+ }
+ this.ViewModel.LimparRelatorio();
+ if (await this.ViewModel.GerarRelatorio(new DateTime?(this.ViewModel.Inicio), new DateTime?(this.ViewModel.Fim)))
+ {
+ this.ReportControl.DataContext = this.ViewModel;
+ Relatorio relatorio = this.ViewModel.Relatorio;
+ gridRelatorio = new GridRelatorio(this.ViewModel);
+ switch (relatorio)
+ {
+ case 0:
+ case 1:
+ {
+ this.ViewModel.NovosNegocios = relatorio == 0;
+ await Funcoes.ContruirLista<ClientesAtivosInativos>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ClientesAtivosInativosFiltrado;
+ goto case 22;
+ }
+ case 2:
+ {
+ await Funcoes.ContruirLista<Producao>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ProducaoFiltrado;
+ goto case 22;
+ }
+ case 3:
+ {
+ await Funcoes.ContruirLista<ApolicePendente>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ApolicePendenteFiltrado;
+ goto case 22;
+ }
+ case 4:
+ {
+ await Funcoes.ContruirLista<Renovacao>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.RenovacaoFiltrado;
+ goto case 22;
+ }
+ case 5:
+ {
+ await Funcoes.ContruirLista<Comissao>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ComissaoFiltrado;
+ goto case 22;
+ }
+ case 6:
+ case 16:
+ {
+ await Funcoes.ContruirLista<Pendente>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.PendenteFiltrado;
+ goto case 22;
+ }
+ case 7:
+ case 11:
+ case 20:
+ {
+ this.WebEditor.Initialize(this.ViewModel.HtmlContent);
+ goto case 22;
+ }
+ case 8:
+ {
+ await Funcoes.ContruirLista<Auditoria>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.AuditoriaFiltrado;
+ goto case 22;
+ }
+ case 9:
+ case 10:
+ {
+ await Funcoes.ContruirLista<Sinistro>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.SinistroFiltrado;
+ goto case 22;
+ }
+ case 12:
+ {
+ await Funcoes.ContruirLista<FaturaPendente>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.FaturaPendenteFiltrado;
+ goto case 22;
+ }
+ case 13:
+ {
+ await Funcoes.ContruirLista<ExtratoBaixadoRelatorio>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ExtratosFiltrado;
+ goto case 22;
+ }
+ case 14:
+ {
+ await Funcoes.ContruirLista<MetaSeguradoraRelatorio>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.MetaSeguradoraFiltrado;
+ goto case 22;
+ }
+ case 15:
+ {
+ await Funcoes.ContruirLista<MetaVendedorRelatorio>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.MetaVendedorFiltrado;
+ goto case 22;
+ }
+ case 17:
+ {
+ await Funcoes.ContruirLista<Licenciamento>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.LicenciamentoFiltrado;
+ goto case 22;
+ }
+ case 18:
+ {
+ await Funcoes.ContruirLista<Tarefa>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.TarefaFiltrado;
+ goto case 22;
+ }
+ case 19:
+ {
+ await Funcoes.ContruirLista<NotaFiscalRelatorio>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.NotaFiscalFiltrado;
+ goto case 22;
+ }
+ case 21:
+ case 22:
+ {
+ gridRelatorio.SinteticoGrid.ItemsSource = this.ViewModel.Sintetic;
+ RelatorioViewModel viewModel = this.ViewModel;
+ if (relatorio == 11 || relatorio == 7 || relatorio == 20)
+ {
+ obj = null;
+ }
+ else
+ {
+ obj = gridRelatorio;
+ }
+ viewModel.Report = obj;
+ RelatorioViewModel relatorioViewModel = this.ViewModel;
+ flag = (relatorio == 11 || relatorio == 7 ? true : relatorio == 20);
+ relatorioViewModel.VisibilityHtml = flag;
+ this.NaoHaDados.Visibility = System.Windows.Visibility.Collapsed;
+ this.ReportControl.Visibility = System.Windows.Visibility.Visible;
+ this.ViewModel.RelatorioVisibility = true;
+ this.ViewModel.IsEnabled = true;
+ this.ViewModel.ExtratosEnabled = true;
+ this.ViewModel.Carregando = false;
+ break;
+ }
+ case 23:
+ {
+ gridRelatorio.Totalizacao.Visibility = System.Windows.Visibility.Collapsed;
+ await Funcoes.ContruirLista<LogsEnvio>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.LogsEnvioFiltrado;
+ goto case 22;
+ }
+ case 24:
+ case 25:
+ {
+ await Funcoes.ContruirLista<LogAcaoRelatorio>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.LogUtilizacaoFiltrado;
+ goto case 22;
+ }
+ case 26:
+ {
+ await Funcoes.ContruirLista<ApoliceCritica>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.ApoliceCriticaFiltrado;
+ goto case 22;
+ }
+ case 27:
+ {
+ await Funcoes.ContruirLista<Placas>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.PlacaFiltrado;
+ goto case 22;
+ }
+ case 28:
+ {
+ await Funcoes.ContruirLista<Endosso>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.EndossoFiltrado;
+ goto case 22;
+ }
+ case 29:
+ {
+ await Funcoes.ContruirLista<Classificacao>(gridRelatorio.DataGrid, this.ViewModel.Relatorio);
+ gridRelatorio.DataGrid.ItemsSource = this.ViewModel.Classificacao;
+ goto case 22;
+ }
+ default:
+ {
+ goto case 22;
+ }
+ }
+ }
+ else
+ {
+ this.NaoHaDados.Visibility = System.Windows.Visibility.Visible;
+ this.ReportControl.Visibility = System.Windows.Visibility.Collapsed;
+ this.ViewModel.IsEnabled = true;
+ this.ViewModel.ExtratosEnabled = false;
+ this.ViewModel.Carregando = false;
+ this.ViewModel.VisibilityHtml = false;
+ }
+ }
+ else
+ {
+ await this.ViewModel.ShowMessage("O VALOR FINAL NÃO PODE SER MENOR QUE O VALOR INICIAL DO FILTRO.", "OK", "", false);
+ }
+ gridRelatorio = null;
+ }
+
+ private async void HelpPopup_Opened(object sender, RoutedEventArgs e)
+ {
+ await this.ViewModel.CarregarAjuda();
+ }
+
+ private async void Imprimir_OnClick(object sender, RoutedEventArgs e)
+ {
+ bool flag;
+ flag = (this.ViewModel.VisibilityAgrupamento != System.Windows.Visibility.Visible || this.ViewModel.Agrupamento == null ? this.ViewModel.NotaFiscalPorSeguradora : true);
+ bool flag1 = flag;
+ if (flag1)
+ {
+ flag1 = await this.ViewModel.ShowMessage("DESEJA SEPARAR GRUPOS POR PÁGINA?", "SIM", "NÃO", false);
+ }
+ bool flag2 = flag1;
+ this.ViewModel.Carregando = true;
+ this.ViewModel.IsEnabled = false;
+ bool visibilityHtml = this.ViewModel.VisibilityHtml;
+ if (visibilityHtml)
+ {
+ this.ViewModel.VisibilityHtml = false;
+ }
+ await this.ViewModel.Print(flag2);
+ if (visibilityHtml)
+ {
+ this.ViewModel.VisibilityHtml = true;
+ }
+ this.ViewModel.Carregando = false;
+ this.ViewModel.IsEnabled = true;
+ if (this.ViewModel.Relatorio == 7 || this.ViewModel.Relatorio == 20)
+ {
+ this.WebEditor.Visibility = System.Windows.Visibility.Visible;
+ }
+ }
+
+ [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/views/relatorios/relatorioview.xaml", UriKind.Relative));
+ }
+
+ private void LimparRelatorio()
+ {
+ this.ViewModel.LimparRelatorio();
+ if (this.ReportControl == null)
+ {
+ return;
+ }
+ this.ReportControl.Content = null;
+ this.ReportControl.DataContext = null;
+ }
+
+ private void MaisFiltros_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (this.ViewModel.Relatorio == 24 || this.ViewModel.Relatorio == 25)
+ {
+ this.ViewModel.VisibilityUsuarios = true;
+ return;
+ }
+ this.ViewModel.Seguradoras = new List<Seguradora>(this.ViewModel.Seguradoras);
+ this.ViewModel.Ramos = new List<Ramo>(this.ViewModel.Ramos);
+ this.ViewModel.Vendedores = new List<Vendedor>(this.ViewModel.Vendedores);
+ this.ViewModel.Produtos = new List<Produto>(this.ViewModel.Produtos);
+ this.ViewModel.Estipulantes = new List<Estipulante>(this.ViewModel.Estipulantes);
+ this.ViewModel.TipoSeguros = new List<StatusRelatorio>(this.ViewModel.TipoSeguros);
+ this.ViewModel.RecheckAllLists();
+ this.ViewModel.ShowDrawer(new Gestor.Application.Drawers.Relatorios.FiltroRelatorio(this.ViewModel, this.ViewModel.Relatorio), 0, false);
+ }
+
+ private void OcultarAjuda_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.HelpPopup.Visibility = System.Windows.Visibility.Collapsed;
+ }
+
+ private void Periodo_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e)
+ {
+ this.LimparRelatorio();
+ }
+
+ private async void PlanilhaCompleta_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.Carregando = true;
+ await this.ViewModel.GerarPlanilhaCompleta();
+ this.ViewModel.Carregando = false;
+ }
+
+ private void Play_Click(object sender, RoutedEventArgs e)
+ {
+ Button button = (Button)sender;
+ if (button == null || button.DataContext == null)
+ {
+ return;
+ }
+ AjudaTela dataContext = (AjudaTela)button.DataContext;
+ string str = "";
+ if (dataContext.get_Minuto() > 0 || dataContext.get_Segundo() > 0)
+ {
+ str = string.Format("&start={0}", dataContext.get_Minuto() * 60 + dataContext.get_Segundo());
+ }
+ Process.Start(string.Concat(dataContext.get_Link(), str));
+ }
+
+ private void Protocolo_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.MostrarProtocolo();
+ }
+
+ private void Recarregar(string sessao)
+ {
+ if (this.ViewModel.Sessao != sessao)
+ {
+ return;
+ }
+ this.GerarResultados_OnClick(this.GerarRelatorioButton, new RoutedEventArgs());
+ }
+
+ private void ReloadWindow_Click(object sender, RoutedEventArgs e)
+ {
+ this.LimparRelatorio();
+ }
+
+ private async void ShowHelp(Relatorio relatorio)
+ {
+ if (await this.ViewModel.VerificarRestricao(61, true, false))
+ {
+ bool flag = true;
+ if (this.HelpPopup != null)
+ {
+ this.HelpPopup.Visibility = (flag ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed);
+ }
+ }
+ else
+ {
+ this.HelpPopup.Visibility = System.Windows.Visibility.Collapsed;
+ }
+ }
+
+ private async void Sincronizar_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.ViewModel.Carregando = true;
+ this.ViewModel.IsEnabled = false;
+ await this.ViewModel.Sincronizar();
+ this.ViewModel.IsEnabled = true;
+ this.ViewModel.Carregando = false;
+ }
+
+ private async void Sintetico_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (this.ViewModel.Relatorio == 7 || this.ViewModel.Agrupamento != null || this.ViewModel.Relatorio == 11)
+ {
+ await this.ViewModel.Sintetico();
+ }
+ else
+ {
+ await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR UM AGRUPAMENTO PARA SINTETIZAR OS RESULTADOS.", "OK", "", 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.ProgressRing = (Image)target;
+ return;
+ }
+ case 2:
+ {
+ this.RelatorioBox = (ComboBox)target;
+ this.RelatorioBox.SelectionChanged += new SelectionChangedEventHandler(this.TipoRelatorio_OnSelectionChanged);
+ return;
+ }
+ case 3:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.AbrirInfo_Click);
+ return;
+ }
+ case 4:
+ {
+ this.ValorInicioBox = (CurrencyTextBox)target;
+ return;
+ }
+ case 5:
+ {
+ this.ValorFimBox = (CurrencyTextBox)target;
+ return;
+ }
+ case 6:
+ {
+ this.InicioBox = (DatePicker)target;
+ this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
+ this.InicioBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
+ return;
+ }
+ case 7:
+ {
+ this.FimBox = (DatePicker)target;
+ this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
+ this.FimBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
+ return;
+ }
+ case 8:
+ {
+ this.VisualizarRamosVendedoresTooltip = (ToggleButton)target;
+ this.VisualizarRamosVendedoresTooltip.Click += new RoutedEventHandler(this.ReloadWindow_Click);
+ return;
+ }
+ case 9:
+ {
+ this.GerarRelatorioButton = (MenuItem)target;
+ this.GerarRelatorioButton.Click += new RoutedEventHandler(this.GerarResultados_OnClick);
+ return;
+ }
+ case 10:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick);
+ return;
+ }
+ case 11:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.ExportarExcel_OnClick);
+ return;
+ }
+ case 12:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.PlanilhaCompleta_OnClick);
+ return;
+ }
+ case 13:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Extrato_OnClick);
+ return;
+ }
+ case 14:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.MaisFiltros_OnClick);
+ return;
+ }
+ case 15:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.ConfigurarRelatorio_OnClick);
+ return;
+ }
+ case 16:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Sintetico_OnClick);
+ return;
+ }
+ case 17:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Tarefas_OnClick);
+ return;
+ }
+ case 18:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Etiquetas_OnClick);
+ return;
+ }
+ case 19:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Acompanhamento_OnClick);
+ return;
+ }
+ case 20:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Email_OnClick);
+ return;
+ }
+ case 21:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Apolice_OnClick);
+ return;
+ }
+ case 22:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Protocolo_OnClick);
+ return;
+ }
+ case 23:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.Sincronizar_OnClick);
+ return;
+ }
+ case 24:
+ {
+ ((MenuItem)target).Click += new RoutedEventHandler(this.FecharFiltro_OnClick);
+ return;
+ }
+ case 25:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.FecharFiltro_OnClick);
+ return;
+ }
+ case 26:
+ {
+ ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
+ ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
+ return;
+ }
+ case 27:
+ {
+ ((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
+ ((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
+ return;
+ }
+ case 28:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.AdicionarFiltro_OnClick);
+ return;
+ }
+ case 29:
+ case 32:
+ case 38:
+ case 39:
+ {
+ this._contentLoaded = true;
+ return;
+ }
+ case 30:
+ {
+ this.RamoBox = (ComboBox)target;
+ return;
+ }
+ case 31:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.AdicionarRamo_OnClick);
+ return;
+ }
+ case 33:
+ {
+ this.ReportControl = (ContentControl)target;
+ return;
+ }
+ case 34:
+ {
+ this.WebEditor = (Gestor.Application.Componentes.WebEditor)target;
+ return;
+ }
+ case 35:
+ {
+ this.HelpPopup = (PopupBox)target;
+ this.HelpPopup.add_Opened(new RoutedEventHandler(this.HelpPopup_Opened));
+ return;
+ }
+ case 36:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.OcultarAjuda_OnClick);
+ return;
+ }
+ case 37:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.Fechar_OnClick);
+ return;
+ }
+ case 40:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.FecharFiltroUsuario_OnClick);
+ return;
+ }
+ case 41:
+ {
+ ((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, RelatorioView.AutoCompleteBoxUsuario_Populating));
+ ((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged));
+ return;
+ }
+ case 42:
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.FecharInfo_Click);
+ return;
+ }
+ case 43:
+ {
+ this.NaoHaDados = (TextBlock)target;
+ 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 <= 32)
+ {
+ if (connectionId == 29)
+ {
+ ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirFiltro_OnClick));
+ return;
+ }
+ if (connectionId != 32)
+ {
+ return;
+ }
+ ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirRamo_onClick));
+ return;
+ }
+ if (connectionId == 38)
+ {
+ ((Button)target).Click += new RoutedEventHandler(this.CopyLink_OnClick);
+ return;
+ }
+ if (connectionId != 39)
+ {
+ return;
+ }
+ ((Button)target).Click += new RoutedEventHandler(this.Play_Click);
+ }
+
+ private async void Tarefas_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (!await this.ViewModel.ValidateTarefa())
+ {
+ Tarefa tarefa = new Tarefa();
+ tarefa.set_Entidade(1);
+ tarefa.set_Titulo(EnumHelper.GetDescription<Relatorio>(this.ViewModel.Relatorio));
+ tarefa.set_Usuario(Recursos.Usuario);
+ tarefa.set_Agendamento(Funcoes.GetNetworkTime());
+ await this.AbrirTarefa(tarefa);
+ }
+ }
+
+ private void TipoRelatorio_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ this.LimparRelatorio();
+ this.VisualizarRamosVendedoresTooltip.IsChecked = new bool?(false);
+ Relatorio relatorio = this.ViewModel.Relatorio;
+ if (this.NaoHaDados != null)
+ {
+ this.NaoHaDados.Visibility = System.Windows.Visibility.Collapsed;
+ }
+ this.ShowHelp(relatorio);
+ switch (relatorio)
+ {
+ case 0:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 1:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 2:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Visible;
+ return;
+ }
+ case 3:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 4:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Visible;
+ return;
+ }
+ case 5:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 6:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 7:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 8:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 9:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 10:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 11:
+ {
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ this.ViewModel.Info = "";
+ this.ViewModel.InfoVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 12:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 21:
+ case 22:
+ {
+ return;
+ }
+ case 13:
+ {
+ this.ViewModel.VisibilityAgrupamento = System.Windows.Visibility.Collapsed;
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ case 23:
+ {
+ this.ViewModel.VisibilityAgrupamento = System.Windows.Visibility.Collapsed;
+ this.ViewModel.PlanilhaVisibility = System.Windows.Visibility.Collapsed;
+ return;
+ }
+ default:
+ {
+ return;
+ }
+ }
+ }
+
+ private async void ToggleComparativo_OnChecked(object sender, RoutedEventArgs e)
+ {
+ if (this.ViewModel.Relatorio == 11)
+ {
+ this.ViewModel.Carregando = true;
+ this.ViewModel.IsEnabled = false;
+ RelatorioViewModel viewModel = this.ViewModel;
+ string str = await this.ViewModel.GerarHtml(true, false, null, false);
+ viewModel.HtmlContent = str;
+ viewModel = null;
+ this.WebEditor.Initialize(this.ViewModel.HtmlContent);
+ this.ViewModel.IsEnabled = true;
+ this.ViewModel.Carregando = false;
+ }
+ }
+ }
+} \ No newline at end of file