diff options
Diffstat (limited to 'Gestor.Application/Views/Relatorios')
| -rw-r--r-- | Gestor.Application/Views/Relatorios/RelatorioView.cs | 1167 | ||||
| -rw-r--r-- | Gestor.Application/Views/Relatorios/SinteticoView.cs | 509 |
2 files changed, 1676 insertions, 0 deletions
diff --git a/Gestor.Application/Views/Relatorios/RelatorioView.cs b/Gestor.Application/Views/Relatorios/RelatorioView.cs new file mode 100644 index 0000000..69fdf01 --- /dev/null +++ b/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 diff --git a/Gestor.Application/Views/Relatorios/SinteticoView.cs b/Gestor.Application/Views/Relatorios/SinteticoView.cs new file mode 100644 index 0000000..9ae559f --- /dev/null +++ b/Gestor.Application/Views/Relatorios/SinteticoView.cs @@ -0,0 +1,509 @@ +using Gestor.Application;
+using Gestor.Application.Helpers;
+using Gestor.Application.Model;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.ViewModels.Relatorios;
+using Gestor.Model.Domain.Relatorios;
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+using System.Windows.Input;
+using System.Windows.Interop;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Shapes;
+using System.Windows.Shell;
+
+namespace Gestor.Application.Views.Relatorios
+{
+ public class SinteticoView : Window, IComponentConnector, IStyleConnector
+ {
+ internal SinteticoViewModel ViewModel;
+
+ private bool _buttonClickable;
+
+ private ListSortDirection _ascending;
+
+ private string _member;
+
+ internal System.Windows.Shell.WindowChrome WindowChrome;
+
+ internal TextBlock SubTitulo;
+
+ internal Grid MinimizeButton;
+
+ internal Grid MaximizeButton;
+
+ internal Grid CloseButton;
+
+ internal System.Windows.Controls.TabControl Tab;
+
+ private bool _contentLoaded;
+
+ public DateTime? DateFinal
+ {
+ get;
+ set;
+ }
+
+ public DateTime? DateStart
+ {
+ get;
+ set;
+ }
+
+ public SinteticoView(List<Sintetico> sintetico, string relatorio, DateTime? inicio, DateTime? fim)
+ {
+ DateTime valueOrDefault;
+ string str;
+ string str1;
+ this.ViewModel = new SinteticoViewModel(sintetico, relatorio);
+ base.DataContext = this.ViewModel;
+ this.InitializeComponent();
+ TextBlock subTitulo = this.SubTitulo;
+ if (inicio.HasValue)
+ {
+ valueOrDefault = inicio.GetValueOrDefault();
+ str = valueOrDefault.ToString("dd/MM/yyyy");
+ }
+ else
+ {
+ str = null;
+ }
+ if (fim.HasValue)
+ {
+ valueOrDefault = fim.GetValueOrDefault();
+ str1 = valueOrDefault.ToString("dd/MM/yyyy");
+ }
+ else
+ {
+ str1 = null;
+ }
+ subTitulo.Text = string.Concat("VALORES BASEADOS NA RELAÇÃO EMITIDA ANTERIORMENTE - INICIO: ", str, " FIM: ", str1);
+ DateTime? nullable = inicio;
+ this.DateStart = new DateTime?((nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.MinValue));
+ nullable = fim;
+ this.DateFinal = new DateTime?((nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.MinValue));
+ this.MinimizeButton.MouseEnter += new System.Windows.Input.MouseEventHandler(SinteticoView.TopControls_OnMouseEnter);
+ this.MinimizeButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave);
+ this.MaximizeButton.MouseEnter += new System.Windows.Input.MouseEventHandler(SinteticoView.TopControls_OnMouseEnter);
+ this.MaximizeButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave);
+ this.CloseButton.MouseEnter += new System.Windows.Input.MouseEventHandler(SinteticoView.TopControls_OnMouseEnter);
+ this.CloseButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave);
+ }
+
+ private void AjustaNome(SinteticoSource source)
+ {
+ foreach (ValorSintetico listum in source.Lista)
+ {
+ if (string.IsNullOrEmpty(listum.get_Porcentagem()) || listum.get_Indice().Contains(listum.get_Porcentagem()))
+ {
+ continue;
+ }
+ ValorSintetico valorSintetico = listum;
+ valorSintetico.set_Indice(string.Concat(valorSintetico.get_Indice(), " - ", listum.get_Porcentagem(), "%"));
+ }
+ }
+
+ public void CloseButton_Click()
+ {
+ base.Close();
+ }
+
+ private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e)
+ {
+ System.Windows.Controls.DataGrid dataGrid = (System.Windows.Controls.DataGrid)sender;
+ if (dataGrid == null || dataGrid.DataContext == null)
+ {
+ return;
+ }
+ if (this._member != e.Column.SortMemberPath)
+ {
+ this._ascending = ListSortDirection.Ascending;
+ }
+ else
+ {
+ this._ascending = (this._ascending == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending);
+ }
+ ObservableCollection<ValorSintetico> itemsSource = dataGrid.ItemsSource as ObservableCollection<ValorSintetico>;
+ if (itemsSource == null)
+ {
+ return;
+ }
+ IQueryable<ValorSintetico> valorSinteticos = itemsSource.AsQueryable<ValorSintetico>();
+ List<ValorSintetico> list = (
+ from x in (this._ascending == ListSortDirection.Ascending ? valorSinteticos.OrderBy<ValorSintetico>(e.Column.SortMemberPath).ToList<ValorSintetico>() : valorSinteticos.OrderByDescending<ValorSintetico>(e.Column.SortMemberPath).ToList<ValorSintetico>())
+ orderby x.get_Indice() == "TOTAL"
+ select x).ToList<ValorSintetico>();
+ itemsSource.Clear();
+ foreach (ValorSintetico valorSintetico in list)
+ {
+ itemsSource.Add(valorSintetico);
+ }
+ this.ViewModel.OnPropertyChanged("DataGrid_Sorting");
+ this._member = e.Column.SortMemberPath;
+ e.Handled = true;
+ }
+
+ private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e)
+ {
+ System.Windows.Controls.MenuItem menuItem = (System.Windows.Controls.MenuItem)sender;
+ if (menuItem != null && menuItem.DataContext != null)
+ {
+ SinteticoSource dataContext = (SinteticoSource)menuItem.DataContext;
+ await this.ViewModel.GerarExcel(dataContext);
+ }
+ }
+
+ private async void ExportarPdf_OnClick(object sender, RoutedEventArgs e)
+ {
+ System.Windows.Controls.MenuItem menuItem = (System.Windows.Controls.MenuItem)sender;
+ if (menuItem != null && menuItem.DataContext != null)
+ {
+ SinteticoSource dataContext = (SinteticoSource)menuItem.DataContext;
+ await this.ViewModel.GerarPdf(dataContext);
+ }
+ }
+
+ [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
+ private static extern bool GetCursorPos(out MainWindow.Point lpPoint);
+
+ [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
+ private static extern bool GetMonitorInfo(IntPtr hMonitor, SinteticoView.Monitorinfo lpmi);
+
+ private async void Imprimir_OnClick(object sender, RoutedEventArgs e)
+ {
+ bool flag;
+ System.Windows.Controls.MenuItem menuItem = (System.Windows.Controls.MenuItem)sender;
+ if (menuItem != null && menuItem.DataContext != null)
+ {
+ SinteticoSource dataContext = (SinteticoSource)menuItem.DataContext;
+ DateTime? dateStart = this.DateStart;
+ DateTime minValue = DateTime.MinValue;
+ flag = (dateStart.HasValue ? dateStart.GetValueOrDefault() != minValue : true);
+ if (flag)
+ {
+ dataContext.DateStart = this.DateStart;
+ dataContext.DateFinal = this.DateFinal;
+ }
+ await this.ViewModel.Print(dataContext);
+ }
+ }
+
+ private async void ImprimirUnicaPagina_OnClick(object sender, RoutedEventArgs e)
+ {
+ bool flag;
+ System.Windows.Controls.MenuItem menuItem = (System.Windows.Controls.MenuItem)sender;
+ if (menuItem != null && menuItem.DataContext != null)
+ {
+ SinteticoSource dataContext = (SinteticoSource)menuItem.DataContext;
+ DateTime? dateStart = this.DateStart;
+ DateTime minValue = DateTime.MinValue;
+ flag = (dateStart.HasValue ? dateStart.GetValueOrDefault() != minValue : true);
+ if (flag)
+ {
+ dataContext.DateStart = this.DateStart;
+ dataContext.DateFinal = this.DateFinal;
+ }
+ await this.ViewModel.PrintUnica(dataContext);
+ }
+ }
+
+ [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/sinteticoview.xaml", UriKind.Relative));
+ }
+
+ public void MaximizeButton_Click()
+ {
+ base.WindowState = (base.WindowState == System.Windows.WindowState.Normal ? System.Windows.WindowState.Maximized : System.Windows.WindowState.Normal);
+ }
+
+ public void MinimizeButton_Click()
+ {
+ base.WindowState = System.Windows.WindowState.Minimized;
+ }
+
+ [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false, SetLastError=true)]
+ private static extern IntPtr MonitorFromPoint(MainWindow.Point pt, SinteticoView.MonitorOptions dwFlags);
+
+ protected sealed override void OnStateChanged(EventArgs e)
+ {
+ object obj;
+ base.BorderThickness = new Thickness((double)(base.WindowState != System.Windows.WindowState.Maximized));
+ System.Windows.Shell.WindowChrome windowChrome = this.WindowChrome;
+ if (base.WindowState == System.Windows.WindowState.Maximized)
+ {
+ obj = null;
+ }
+ else
+ {
+ obj = 4;
+ }
+ windowChrome.ResizeBorderThickness = new Thickness((double)obj);
+ this.WindowChrome.CaptionHeight = (double)((base.WindowState == System.Windows.WindowState.Maximized ? 33 : 30));
+ this.ViewModel.MaximizeRestore = (base.WindowState == System.Windows.WindowState.Maximized ? Geometry.Parse((string)System.Windows.Application.Current.Resources["Restore"]) : Geometry.Parse((string)System.Windows.Application.Current.Resources["Maximize"]));
+ base.OnStateChanged(e);
+ }
+
+ [DebuggerNonUserCode]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
+ {
+ switch (connectionId)
+ {
+ case 1:
+ {
+ ((SinteticoView)target).Initialized += new EventHandler(this.Window_OnInitialized);
+ return;
+ }
+ case 2:
+ {
+ this.WindowChrome = (System.Windows.Shell.WindowChrome)target;
+ return;
+ }
+ case 3:
+ {
+ this.SubTitulo = (TextBlock)target;
+ return;
+ }
+ case 4:
+ {
+ this.MinimizeButton = (Grid)target;
+ this.MinimizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown);
+ this.MinimizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp);
+ return;
+ }
+ case 5:
+ {
+ this.MaximizeButton = (Grid)target;
+ this.MaximizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown);
+ this.MaximizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp);
+ return;
+ }
+ case 6:
+ {
+ this.CloseButton = (Grid)target;
+ this.CloseButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown);
+ this.CloseButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp);
+ return;
+ }
+ case 7:
+ {
+ this.Tab = (System.Windows.Controls.TabControl)target;
+ return;
+ }
+ }
+ this._contentLoaded = true;
+ }
+
+ [DebuggerNonUserCode]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target)
+ {
+ switch (connectionId)
+ {
+ case 8:
+ {
+ ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.Imprimir_OnClick);
+ return;
+ }
+ case 9:
+ {
+ ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.ExportarPdf_OnClick);
+ return;
+ }
+ case 10:
+ {
+ ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.ExportarExcel_OnClick);
+ return;
+ }
+ case 11:
+ {
+ ((System.Windows.Controls.MenuItem)target).Click += new RoutedEventHandler(this.ImprimirUnicaPagina_OnClick);
+ return;
+ }
+ case 12:
+ {
+ ((System.Windows.Controls.DataGrid)target).Sorting += new DataGridSortingEventHandler(this.DataGrid_Sorting);
+ return;
+ }
+ default:
+ {
+ return;
+ }
+ }
+ }
+
+ private static void TopControls_OnMouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
+ {
+ ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray));
+ Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path;
+ if (child != null)
+ {
+ child.Stroke = new SolidColorBrush(Colors.White);
+ }
+ }
+
+ private void TopControls_OnMouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
+ {
+ this._buttonClickable = false;
+ ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent);
+ Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path;
+ if (child != null)
+ {
+ child.Stroke = new SolidColorBrush(Colors.White);
+ }
+ }
+
+ private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ this._buttonClickable = true;
+ ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.DimGray));
+ }
+
+ private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ if (this._buttonClickable)
+ {
+ MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click"));
+ if (method == null)
+ {
+ return;
+ }
+ method.Invoke(this, null);
+ }
+ }
+
+ private void Window_OnInitialized(object sender, EventArgs e)
+ {
+ WindowInteropHelper windowInteropHelper = new WindowInteropHelper(this);
+ windowInteropHelper.EnsureHandle();
+ HwndSource hwndSource = HwndSource.FromHwnd(windowInteropHelper.Handle);
+ if (hwndSource == null)
+ {
+ return;
+ }
+ hwndSource.AddHook(new HwndSourceHook(this.WindowProc));
+ }
+
+ private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
+ {
+ if (msg == 36)
+ {
+ this.WmGetMinMaxInfo(lParam);
+ }
+ return IntPtr.Zero;
+ }
+
+ private void WmGetMinMaxInfo(IntPtr lParam)
+ {
+ MainWindow.Point point;
+ System.Drawing.Rectangle workingArea = Screen.FromHandle((new WindowInteropHelper(this)).Handle).WorkingArea;
+ base.MaxHeight = (double)workingArea.Height;
+ SinteticoView.GetCursorPos(out point);
+ IntPtr intPtr = SinteticoView.MonitorFromPoint(new MainWindow.Point(0, 0), SinteticoView.MonitorOptions.MonitorDefaulttoprimary);
+ SinteticoView.Monitorinfo monitorinfo = new SinteticoView.Monitorinfo();
+ if (!SinteticoView.GetMonitorInfo(intPtr, monitorinfo))
+ {
+ return;
+ }
+ IntPtr intPtr1 = SinteticoView.MonitorFromPoint(point, SinteticoView.MonitorOptions.MonitorDefaulttonearest);
+ SinteticoView.Minmaxinfo structure = (SinteticoView.Minmaxinfo)Marshal.PtrToStructure(lParam, typeof(SinteticoView.Minmaxinfo));
+ if (!intPtr.Equals(intPtr1))
+ {
+ structure.ptMaxPosition.X = monitorinfo.rcMonitor.Left;
+ structure.ptMaxPosition.Y = monitorinfo.rcMonitor.Top;
+ structure.ptMaxSize.X = monitorinfo.rcMonitor.Right - monitorinfo.rcMonitor.Left;
+ structure.ptMaxSize.Y = monitorinfo.rcMonitor.Bottom - monitorinfo.rcMonitor.Top;
+ }
+ else
+ {
+ structure.ptMaxPosition.X = monitorinfo.rcWork.Left;
+ structure.ptMaxPosition.Y = monitorinfo.rcWork.Top;
+ structure.ptMaxSize.X = monitorinfo.rcWork.Right - monitorinfo.rcWork.Left;
+ structure.ptMaxSize.Y = monitorinfo.rcWork.Bottom - monitorinfo.rcWork.Top;
+ }
+ Marshal.StructureToPtr<SinteticoView.Minmaxinfo>(structure, lParam, true);
+ }
+
+ private struct Minmaxinfo
+ {
+ private readonly MainWindow.Point ptReserved;
+
+ public SinteticoView.Point ptMaxSize;
+
+ public SinteticoView.Point ptMaxPosition;
+
+ private readonly MainWindow.Point ptMinTrackSize;
+
+ private readonly MainWindow.Point ptMaxTrackSize;
+ }
+
+ private class Monitorinfo
+ {
+ private readonly int cbSize;
+
+ public readonly SinteticoView.Rect rcMonitor;
+
+ public readonly SinteticoView.Rect rcWork;
+
+ private readonly int dwFlags;
+
+ public Monitorinfo()
+ {
+ }
+ }
+
+ private enum MonitorOptions : uint
+ {
+ MonitorDefaulttoprimary = 1,
+ MonitorDefaulttonearest = 2
+ }
+
+ public struct Point
+ {
+ public int X;
+
+ public int Y;
+
+ public Point(int x, int y)
+ {
+ this.X = x;
+ this.Y = y;
+ }
+ }
+
+ public struct Rect
+ {
+ public int Left;
+
+ public int Top;
+
+ public int Right;
+
+ public int Bottom;
+ }
+ }
+}
\ No newline at end of file |