diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Views.Relatorios')
| -rw-r--r-- | Decompiler/Gestor.Application.Views.Relatorios/RelatorioView.cs | 1116 | ||||
| -rw-r--r-- | Decompiler/Gestor.Application.Views.Relatorios/SinteticoView.cs | 509 |
2 files changed, 1625 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Views.Relatorios/RelatorioView.cs b/Decompiler/Gestor.Application.Views.Relatorios/RelatorioView.cs new file mode 100644 index 0000000..ba0fe27 --- /dev/null +++ b/Decompiler/Gestor.Application.Views.Relatorios/RelatorioView.cs @@ -0,0 +1,1116 @@ +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Threading; +using CurrencyTextBoxControl; +using Gestor.Application.Actions; +using Gestor.Application.Componentes; +using Gestor.Application.Drawers.Relatorios; +using Gestor.Application.Helpers; +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.Relatorios.ApolicePendente; +using Gestor.Model.Domain.Relatorios.Auditoria; +using Gestor.Model.Domain.Relatorios.Classificacao; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Relatorios.Comissao; +using Gestor.Model.Domain.Relatorios.CriticaApolice; +using Gestor.Model.Domain.Relatorios.EndossoCancelamento; +using Gestor.Model.Domain.Relatorios.ExtratoBaixado; +using Gestor.Model.Domain.Relatorios.FaturaPendente; +using Gestor.Model.Domain.Relatorios.Licenciamento; +using Gestor.Model.Domain.Relatorios.Log; +using Gestor.Model.Domain.Relatorios.LogsEnvio; +using Gestor.Model.Domain.Relatorios.MetaSeguradora; +using Gestor.Model.Domain.Relatorios.MetaVendedor; +using Gestor.Model.Domain.Relatorios.NotaFiscal; +using Gestor.Model.Domain.Relatorios.Pendente; +using Gestor.Model.Domain.Relatorios.Placa; +using Gestor.Model.Domain.Relatorios.Producao; +using Gestor.Model.Domain.Relatorios.Renovacao; +using Gestor.Model.Domain.Relatorios.Sinistro; +using Gestor.Model.Domain.Relatorios.Tarefa; +using Gestor.Model.Domain.Seguros; +using MaterialDesignThemes.Wpf; +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 WebEditor WebEditor; + + internal PopupBox HelpPopup; + + internal TextBlock NaoHaDados; + + private bool _contentLoaded; + + public RelatorioView(string opcao) + { + ViewModel = new RelatorioViewModel(opcao); + ((FrameworkElement)this).DataContext = ViewModel; + InitializeComponent(); + Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad)); + } + ViewModel.Head = Recursos.Usuario.Nome + ", VOCÊ ESTÁ EM RELATÓRIOS"; + Gestor.Application.Actions.Actions.RecarregarRelatorios = (Action<string>)Delegate.Combine(Gestor.Application.Actions.Actions.RecarregarRelatorios, new Action<string>(Recarregar)); + } + + private void Recarregar(string sessao) + { + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + //IL_0025: Expected O, but got Unknown + if (!(ViewModel.Sessao != sessao)) + { + GerarResultados_OnClick(GerarRelatorioButton, new RoutedEventArgs()); + } + } + + private void ContentLoad() + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Expected O, but got Unknown + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_002e: Expected O, but got Unknown + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_005c: Expected O, but got Unknown + //IL_0069: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: Expected O, but got Unknown + //IL_0097: Unknown result type (might be due to invalid IL or missing references) + //IL_00a1: Expected O, but got Unknown + ((UIElement)InicioBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); + ((UIElement)InicioBox).PreviewKeyDown += new KeyEventHandler(base.DatePicker_PreviewKeyDown); + InicioBox.SelectedDateChanged += Periodo_OnSelectedDateChanged; + ((UIElement)FimBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); + ((UIElement)FimBox).PreviewKeyDown += new KeyEventHandler(base.DatePicker_PreviewKeyDown); + FimBox.SelectedDateChanged += Periodo_OnSelectedDateChanged; + ((Selector)RelatorioBox).SelectionChanged += new SelectionChangedEventHandler(TipoRelatorio_OnSelectionChanged); + } + + private async void GerarResultados_OnClick(object sender, RoutedEventArgs e) + { + InicioBox.Text = ValidationHelper.FormatDate(InicioBox.Text); + FimBox.Text = ValidationHelper.FormatDate(FimBox.Text); + try + { + ViewModel.Inicio = Convert.ToDateTime(InicioBox.Text); + ViewModel.Fim = Convert.ToDateTime(FimBox.Text); + } + catch (Exception) + { + return; + } + if (ViewModel.Inicio > ViewModel.Fim) + { + await ViewModel.ShowMessage("A DATA FINAL NÃO PODE SER MENOR QUE A DATA INICIAL DO FILTRO."); + return; + } + if (((CollectionView)((ItemsControl)RelatorioBox).Items).Count == 0) + { + await ViewModel.ShowMessage("NÃO HÁ RELATÓRIOS QUE VOCÊ POSSA GERAR."); + return; + } + if (ViewModel.InicioValor > ViewModel.FimValor) + { + await ViewModel.ShowMessage("O VALOR FINAL NÃO PODE SER MENOR QUE O VALOR INICIAL DO FILTRO."); + return; + } + ViewModel.Carregando = true; + ViewModel.IsEnabled = false; + ViewModel.VisibilityHtml = false; + if (ViewModel.Report != null) + { + ViewModel.Report = null; + } + ViewModel.LimparRelatorio(); + if (!(await ViewModel.GerarRelatorio(ViewModel.Inicio, ViewModel.Fim))) + { + ((UIElement)NaoHaDados).Visibility = (Visibility)0; + ((UIElement)ReportControl).Visibility = (Visibility)2; + ViewModel.IsEnabled = true; + ViewModel.ExtratosEnabled = false; + ViewModel.Carregando = false; + ViewModel.VisibilityHtml = false; + return; + } + ((FrameworkElement)ReportControl).DataContext = ViewModel; + Relatorio relatorioTipo = ViewModel.Relatorio; + GridRelatorio gridRelatorio = new GridRelatorio(ViewModel); + switch ((int)relatorioTipo) + { + case 3: + await gridRelatorio.DataGrid.ContruirLista<ApolicePendente>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.ApolicePendenteFiltrado; + break; + case 17: + await gridRelatorio.DataGrid.ContruirLista<Licenciamento>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.LicenciamentoFiltrado; + break; + case 27: + await gridRelatorio.DataGrid.ContruirLista<Placas>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.PlacaFiltrado; + break; + case 18: + await gridRelatorio.DataGrid.ContruirLista<Tarefa>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.TarefaFiltrado; + break; + case 2: + await gridRelatorio.DataGrid.ContruirLista<Producao>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.ProducaoFiltrado; + break; + case 4: + await gridRelatorio.DataGrid.ContruirLista<Renovacao>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.RenovacaoFiltrado; + break; + case 5: + await gridRelatorio.DataGrid.ContruirLista<Comissao>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.ComissaoFiltrado; + break; + case 6: + case 16: + await gridRelatorio.DataGrid.ContruirLista<Pendente>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.PendenteFiltrado; + break; + case 9: + case 10: + await gridRelatorio.DataGrid.ContruirLista<Sinistro>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.SinistroFiltrado; + break; + case 23: + ((UIElement)gridRelatorio.Totalizacao).Visibility = (Visibility)2; + await gridRelatorio.DataGrid.ContruirLista<LogsEnvio>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.LogsEnvioFiltrado; + break; + case 0: + case 1: + ViewModel.NovosNegocios = (int)relatorioTipo == 0; + await gridRelatorio.DataGrid.ContruirLista<ClientesAtivosInativos>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.ClientesAtivosInativosFiltrado; + break; + case 7: + case 11: + case 20: + WebEditor.Initialize(ViewModel.HtmlContent); + break; + case 8: + await gridRelatorio.DataGrid.ContruirLista<Auditoria>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.AuditoriaFiltrado; + break; + case 13: + await gridRelatorio.DataGrid.ContruirLista<ExtratoBaixadoRelatorio>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.ExtratosFiltrado; + break; + case 12: + await gridRelatorio.DataGrid.ContruirLista<FaturaPendente>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.FaturaPendenteFiltrado; + break; + case 14: + await gridRelatorio.DataGrid.ContruirLista<MetaSeguradoraRelatorio>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.MetaSeguradoraFiltrado; + break; + case 15: + await gridRelatorio.DataGrid.ContruirLista<MetaVendedorRelatorio>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.MetaVendedorFiltrado; + break; + case 19: + await gridRelatorio.DataGrid.ContruirLista<NotaFiscalRelatorio>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.NotaFiscalFiltrado; + break; + case 24: + case 25: + await gridRelatorio.DataGrid.ContruirLista<LogAcaoRelatorio>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.LogUtilizacaoFiltrado; + break; + case 26: + await gridRelatorio.DataGrid.ContruirLista<ApoliceCritica>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.ApoliceCriticaFiltrado; + break; + case 28: + await gridRelatorio.DataGrid.ContruirLista<Endosso>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.EndossoFiltrado; + break; + case 29: + await gridRelatorio.DataGrid.ContruirLista<Classificacao>(ViewModel.Relatorio); + ((ItemsControl)gridRelatorio.DataGrid).ItemsSource = ViewModel.Classificacao; + break; + } + gridRelatorio.SinteticoGrid.ItemsSource = ViewModel.Sintetic; + ViewModel.Report = (((int)relatorioTipo == 11 || (int)relatorioTipo == 7 || (int)relatorioTipo == 20) ? null : gridRelatorio); + ViewModel.VisibilityHtml = (int)relatorioTipo == 11 || (int)relatorioTipo == 7 || (int)relatorioTipo == 20; + ((UIElement)NaoHaDados).Visibility = (Visibility)2; + ((UIElement)ReportControl).Visibility = (Visibility)0; + ViewModel.RelatorioVisibility = true; + ViewModel.IsEnabled = true; + ViewModel.ExtratosEnabled = true; + ViewModel.Carregando = false; + } + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + bool flag = ((int)ViewModel.VisibilityAgrupamento == 0 && (int)ViewModel.Agrupamento != 0) || ViewModel.NotaFiscalPorSeguradora; + if (flag) + { + flag = await ViewModel.ShowMessage("DESEJA SEPARAR GRUPOS POR PÁGINA?", "SIM", "NÃO"); + } + bool pageBreak = flag; + ViewModel.Carregando = true; + ViewModel.IsEnabled = false; + bool html = ViewModel.VisibilityHtml; + if (html) + { + ViewModel.VisibilityHtml = false; + } + await ViewModel.Print(pageBreak); + if (html) + { + ViewModel.VisibilityHtml = true; + } + ViewModel.Carregando = false; + ViewModel.IsEnabled = true; + if ((int)ViewModel.Relatorio == 7 || (int)ViewModel.Relatorio == 20) + { + ((UIElement)WebEditor).Visibility = (Visibility)0; + } + } + + private async void Sintetico_OnClick(object sender, RoutedEventArgs e) + { + if ((int)ViewModel.Relatorio == 7 || (int)ViewModel.Agrupamento != 0 || (int)ViewModel.Relatorio == 11) + { + await ViewModel.Sintetico(); + } + else + { + await ViewModel.ShowMessage("NECESSÁRIO SELECIONAR UM AGRUPAMENTO PARA SINTETIZAR OS RESULTADOS."); + } + } + + private void MaisFiltros_OnClick(object sender, RoutedEventArgs e) + { + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_000d: Invalid comparison between Unknown and I4 + //IL_0015: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Invalid comparison between Unknown and I4 + //IL_00ea: Unknown result type (might be due to invalid IL or missing references) + if ((int)ViewModel.Relatorio == 24 || (int)ViewModel.Relatorio == 25) + { + ViewModel.VisibilityUsuarios = true; + return; + } + ViewModel.Seguradoras = new List<Seguradora>(ViewModel.Seguradoras); + ViewModel.Ramos = new List<Ramo>(ViewModel.Ramos); + ViewModel.Vendedores = new List<Vendedor>(ViewModel.Vendedores); + ViewModel.Produtos = new List<Produto>(ViewModel.Produtos); + ViewModel.Estipulantes = new List<Estipulante>(ViewModel.Estipulantes); + ViewModel.TipoSeguros = new List<StatusRelatorio>(ViewModel.TipoSeguros); + ViewModel.RecheckAllLists(); + ViewModel.ShowDrawer(new FiltroRelatorio(ViewModel, ViewModel.Relatorio), 0, close: false); + } + + private void Periodo_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + LimparRelatorio(); + } + + private void LimparRelatorio() + { + ViewModel.LimparRelatorio(); + if (ReportControl != null) + { + ReportControl.Content = null; + ((FrameworkElement)ReportControl).DataContext = null; + } + } + + private async void ShowHelp(Relatorio relatorio) + { + if (!(await ViewModel.VerificarRestricao((TipoRestricao)61, root: true, showmessage: false))) + { + ((UIElement)HelpPopup).Visibility = (Visibility)2; + return; + } + bool flag = true; + if (HelpPopup != null) + { + ((UIElement)HelpPopup).Visibility = (Visibility)((!flag) ? 2 : 0); + } + } + + private void TipoRelatorio_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + //IL_001d: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Unknown result type (might be due to invalid IL or missing references) + //IL_003e: Unknown result type (might be due to invalid IL or missing references) + //IL_00a4: Expected I4, but got Unknown + LimparRelatorio(); + VisualizarRamosVendedoresTooltip.IsChecked = false; + Relatorio relatorio = ViewModel.Relatorio; + if (NaoHaDados != null) + { + ((UIElement)NaoHaDados).Visibility = (Visibility)2; + } + ShowHelp(relatorio); + switch ((int)relatorio) + { + case 0: + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 8: + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 1: + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 2: + ViewModel.PlanilhaVisibility = (Visibility)0; + break; + case 3: + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 4: + ViewModel.PlanilhaVisibility = (Visibility)0; + break; + case 5: + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 6: + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 7: + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 9: + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 10: + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 11: + ViewModel.PlanilhaVisibility = (Visibility)2; + ViewModel.Info = ""; + ViewModel.InfoVisibility = (Visibility)2; + break; + case 13: + ViewModel.VisibilityAgrupamento = (Visibility)2; + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 23: + ViewModel.VisibilityAgrupamento = (Visibility)2; + ViewModel.PlanilhaVisibility = (Visibility)2; + break; + case 12: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + break; + } + } + + private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Carregando = true; + ViewModel.IsEnabled = false; + await ViewModel.GerarExcel(); + ViewModel.IsEnabled = true; + ViewModel.Carregando = false; + } + + private async void Tarefas_OnClick(object sender, RoutedEventArgs e) + { + if (!(await ViewModel.ValidateTarefa())) + { + Tarefa data = new Tarefa + { + Entidade = (TipoTarefa)1, + Titulo = EnumHelper.GetDescription<Relatorio>(ViewModel.Relatorio), + Usuario = Recursos.Usuario, + Agendamento = Funcoes.GetNetworkTime() + }; + await AbrirTarefa(data); + } + } + + private async Task AbrirTarefa(Tarefa data) + { + ViewModel.IsEnabled = false; + ViewModel.Carregando = true; + Tarefa tarefa; + while (true) + { + tarefa = await ViewModel.ShowTarefaDialog(data, nota: true); + if (tarefa == null) + { + ViewModel.IsEnabled = true; + ViewModel.Carregando = false; + return; + } + if (tarefa.Usuario == null) + { + tarefa.Usuario = tarefa.UsuariosVinculados.FirstOrDefault(); + } + List<ResponsavelTarefa> responsaveis = ((IEnumerable<Usuario>)tarefa.UsuariosVinculados).Select((Func<Usuario, ResponsavelTarefa>)((Usuario x) => new ResponsavelTarefa + { + IdTarefa = ((DomainBase)tarefa).Id, + Usuario = x + })).ToList(); + tarefa.Responsaveis = responsaveis; + tarefa.Anotacoes = "<p>" + tarefa.Anotacoes + "</p>"; + tarefa.AgendamentoRetroativo = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 45); + List<KeyValuePair<string, string>> list = tarefa.Validate(); + if (string.IsNullOrWhiteSpace(tarefa.Anotacoes)) + { + list.Add(new KeyValuePair<string, string>("ANOTAÇÕES", "OBRIGATÓRIO")); + } + if (list == null || list.Count == 0) + { + break; + } + await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK"); + } + List<Tarefa> list2 = ViewModel.GerarTarefas(tarefa); + if (list2 == null || list2.Count == 0) + { + ViewModel.IsEnabled = true; + ViewModel.Carregando = false; + await ViewModel.ShowMessage("FALHA AO CRIAR TAREFA."); + } + else + { + await ViewModel.SalvarTarefas(list2); + ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO."); + ViewModel.Alterar(alterar: false); + ViewModel.IsEnabled = true; + ViewModel.Carregando = false; + } + } + + private async void Acompanhamento_OnClick(object sender, RoutedEventArgs e) + { + await ViewModel.Acompanhamento(); + } + + private async void Email_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Loading(isLoading: true); + List<MalaDireta> list = await ViewModel.CriarLista(); + if (list == null || list.Count == 0) + { + await ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR."); + ViewModel.Loading(isLoading: false); + return; + } + if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL")) + { + Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL"); + } + ViewModel.Loading(isLoading: false); + ((Window)new HosterWindow((ContentControl)(object)new MalaDiretaView(list), "ENVIO DE E-MAIL", 1200.0, 600.0, canMaximize: true)).Show(); + } + + private async void Etiquetas_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Loading(isLoading: true); + List<Documento> list = await ViewModel.CriarListaEtiqueta(); + if (list == null || list.Count == 0) + { + await ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR."); + ViewModel.Loading(isLoading: false); + } + else if (!Funcoes.IsWindowOpen<HosterWindow>("ETIQUETAS")) + { + bool apenasCliente = (int)ViewModel.Relatorio == 0 || (int)ViewModel.Relatorio == 1; + ViewModel.Loading(isLoading: false); + ((Window)new HosterWindow((ContentControl)(object)new EtiquetaView(list, apenasCliente), "ETIQUETAS", 900.0, 600.0)).Show(); + } + } + + private void Extrato_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.ExibirExtratoDrawer(); + } + + private void Protocolo_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.MostrarProtocolo(); + } + + private void AdicionarFiltro_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.AdcionarFiltroPersonalizado(); + } + + private void ExcluirFiltro_OnClick(object sender, RoutedEventArgs e) + { + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_0034: Expected O, but got Unknown + Chip val = (Chip)((sender is Chip) ? sender : null); + if (val != null) + { + ListBox val2 = Extentions.FindVisualAncestor<ListBox>((DependencyObject)(object)val); + FiltroPersonalizado val3 = (FiltroPersonalizado)((ItemsControl)val2).Items[((CollectionView)((ItemsControl)val2).Items).IndexOf(((FrameworkElement)val).DataContext)]; + if (val3 != null) + { + ViewModel.FiltroPersonalizadoSelecionado.Remove(val3); + ViewModel.PesquisaPersonalizada(); + } + } + } + + private void FecharFiltro_OnClick(object sender, RoutedEventArgs e) + { + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Invalid comparison between Unknown and I4 + ViewModel.VisibilityFiltroPersonalizado = (Visibility)(((int)ViewModel.VisibilityFiltroPersonalizado != 2) ? 2 : 0); + } + + private async void Apolice_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Loading(isLoading: true); + List<MalaDireta> list = await ViewModel.CriarLista(); + list = ((list == null) ? new List<MalaDireta>() : list.Where((MalaDireta x) => (x.Apolice.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Apolice.Apolice)) || (x.Apolice.Tipo == 1 && !string.IsNullOrWhiteSpace(x.Apolice.Endosso))).ToList()); + if (list.Count == 0) + { + await ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR."); + ViewModel.Loading(isLoading: false); + return; + } + if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL")) + { + Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL"); + } + ViewModel.Loading(isLoading: false); + ((Window)new HosterWindow((ContentControl)(object)new MalaDiretaView(list), "ENVIO DE E-MAIL", 1200.0, 600.0, canMaximize: true)).Show(); + } + + private async void Sincronizar_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Carregando = true; + ViewModel.IsEnabled = false; + await ViewModel.Sincronizar(); + ViewModel.IsEnabled = true; + ViewModel.Carregando = false; + } + + private async void ToggleComparativo_OnChecked(object sender, RoutedEventArgs e) + { + if ((int)ViewModel.Relatorio == 11) + { + ViewModel.Carregando = true; + ViewModel.IsEnabled = false; + RelatorioViewModel viewModel = ViewModel; + viewModel.HtmlContent = await ViewModel.GerarHtml(screen: true); + WebEditor.Initialize(ViewModel.HtmlContent); + ViewModel.IsEnabled = true; + ViewModel.Carregando = false; + } + } + + private async void HelpPopup_Opened(object sender, RoutedEventArgs e) + { + await ViewModel.CarregarAjuda(); + } + + private void OcultarAjuda_OnClick(object sender, RoutedEventArgs e) + { + ((UIElement)HelpPopup).Visibility = (Visibility)2; + } + + private void Fechar_OnClick(object sender, RoutedEventArgs e) + { + HelpPopup.IsPopupOpen = !HelpPopup.IsPopupOpen; + } + + private void FecharFiltroUsuario_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.VisibilityUsuarios = false; + } + + private void CopyLink_OnClick(object sender, RoutedEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Expected O, but got Unknown + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Expected O, but got Unknown + Button val = (Button)sender; + if (val != null && ((FrameworkElement)val).DataContext != null) + { + AjudaTela val2 = (AjudaTela)((FrameworkElement)val).DataContext; + string text = ""; + if (val2.Minuto > 0 || val2.Segundo > 0) + { + text = $"&start={val2.Minuto * 60 + val2.Segundo}"; + } + (val2.Link + text).CopyToClipboard(); + ViewModel.ToggleSnackBar("LINK COPIADO"); + } + } + + private void Play_Click(object sender, RoutedEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Expected O, but got Unknown + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Expected O, but got Unknown + Button val = (Button)sender; + if (val != null && ((FrameworkElement)val).DataContext != null) + { + AjudaTela val2 = (AjudaTela)((FrameworkElement)val).DataContext; + string text = ""; + if (val2.Minuto > 0 || val2.Segundo > 0) + { + text = $"&start={val2.Minuto * 60 + val2.Segundo}"; + } + Process.Start(val2.Link + text); + } + } + + private async void PlanilhaCompleta_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.Carregando = true; + await ViewModel.GerarPlanilhaCompleta(); + ViewModel.Carregando = false; + } + + private void ConfigurarRelatorio_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.ShowDrawer(new ConfiguracaoRelatorio(ViewModel), 0, close: false); + } + + private void AdicionarRamo_OnClick(object sender, RoutedEventArgs e) + { + ViewModel.AdicionarRamo(); + } + + private void ExcluirRamo_onClick(object sender, RoutedEventArgs e) + { + //IL_0011: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Expected O, but got Unknown + Chip val = (Chip)((sender is Chip) ? sender : null); + if (val != null) + { + Ramo val2 = (Ramo)((FrameworkElement)val).DataContext; + if (val2 != null) + { + ViewModel.RemoverRamo(val2); + } + } + } + + private void FecharInfo_Click(object sender, RoutedEventArgs e) + { + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Invalid comparison between Unknown and I4 + ViewModel.InfoVisibility = (Visibility)(((int)ViewModel.InfoVisibility != 2) ? 2 : 0); + } + + private void AbrirInfo_Click(object sender, RoutedEventArgs e) + { + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Invalid comparison between Unknown and I4 + ViewModel.InfoVisibility = (Visibility)(((int)ViewModel.InfoVisibility != 2) ? 2 : 0); + } + + private void AutoCompleteBoxUsuario_Populating(object sender, PopulatingEventArgs e) + { + e.Cancel = true; + ViewModel.Filtrar(ValidationHelper.RemoveDiacritics(e.Parameter.Trim())).ContinueWith(delegate(Task<List<Usuario>> searchResult) + { + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + if (searchResult.Result != null) + { + AutoCompleteBox val = (AutoCompleteBox)sender; + val.ItemsSource = searchResult.Result; + val.PopulateComplete(); + } + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + if (string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).Text)) + { + ViewModel.FiltrarUsuario(""); + } + } + + private void ReloadWindow_Click(object sender, RoutedEventArgs e) + { + LimparRelatorio(); + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + public void InitializeComponent() + { + if (!_contentLoaded) + { + _contentLoaded = true; + Uri uri = new Uri("/Gestor.Application;component/views/relatorios/relatorioview.xaml", UriKind.Relative); + Application.LoadComponent((object)this, uri); + } + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + [EditorBrowsable(EditorBrowsableState.Never)] + void IComponentConnector.Connect(int connectionId, object target) + { + //IL_00bb: Unknown result type (might be due to invalid IL or missing references) + //IL_00c5: Expected O, but got Unknown + //IL_00c8: Unknown result type (might be due to invalid IL or missing references) + //IL_00d2: Expected O, but got Unknown + //IL_00df: Unknown result type (might be due to invalid IL or missing references) + //IL_00e9: Expected O, but got Unknown + //IL_00eb: Unknown result type (might be due to invalid IL or missing references) + //IL_00f7: Unknown result type (might be due to invalid IL or missing references) + //IL_0101: Expected O, but got Unknown + //IL_0104: Unknown result type (might be due to invalid IL or missing references) + //IL_010e: Expected O, but got Unknown + //IL_0111: Unknown result type (might be due to invalid IL or missing references) + //IL_011b: Expected O, but got Unknown + //IL_011e: Unknown result type (might be due to invalid IL or missing references) + //IL_0128: Expected O, but got Unknown + //IL_0135: Unknown result type (might be due to invalid IL or missing references) + //IL_013f: Expected O, but got Unknown + //IL_014c: Unknown result type (might be due to invalid IL or missing references) + //IL_0156: Expected O, but got Unknown + //IL_0159: Unknown result type (might be due to invalid IL or missing references) + //IL_0163: Expected O, but got Unknown + //IL_0170: Unknown result type (might be due to invalid IL or missing references) + //IL_017a: Expected O, but got Unknown + //IL_0187: Unknown result type (might be due to invalid IL or missing references) + //IL_0191: Expected O, but got Unknown + //IL_0194: Unknown result type (might be due to invalid IL or missing references) + //IL_019e: Expected O, but got Unknown + //IL_01ab: Unknown result type (might be due to invalid IL or missing references) + //IL_01b5: Expected O, but got Unknown + //IL_01b8: Unknown result type (might be due to invalid IL or missing references) + //IL_01c2: Expected O, but got Unknown + //IL_01cf: Unknown result type (might be due to invalid IL or missing references) + //IL_01d9: Expected O, but got Unknown + //IL_01db: Unknown result type (might be due to invalid IL or missing references) + //IL_01e7: Unknown result type (might be due to invalid IL or missing references) + //IL_01f1: Expected O, but got Unknown + //IL_01f3: Unknown result type (might be due to invalid IL or missing references) + //IL_01ff: Unknown result type (might be due to invalid IL or missing references) + //IL_0209: Expected O, but got Unknown + //IL_020b: Unknown result type (might be due to invalid IL or missing references) + //IL_0217: Unknown result type (might be due to invalid IL or missing references) + //IL_0221: Expected O, but got Unknown + //IL_0223: Unknown result type (might be due to invalid IL or missing references) + //IL_022f: Unknown result type (might be due to invalid IL or missing references) + //IL_0239: Expected O, but got Unknown + //IL_023b: Unknown result type (might be due to invalid IL or missing references) + //IL_0247: Unknown result type (might be due to invalid IL or missing references) + //IL_0251: Expected O, but got Unknown + //IL_0253: Unknown result type (might be due to invalid IL or missing references) + //IL_025f: Unknown result type (might be due to invalid IL or missing references) + //IL_0269: Expected O, but got Unknown + //IL_026b: Unknown result type (might be due to invalid IL or missing references) + //IL_0277: Unknown result type (might be due to invalid IL or missing references) + //IL_0281: Expected O, but got Unknown + //IL_0283: Unknown result type (might be due to invalid IL or missing references) + //IL_028f: Unknown result type (might be due to invalid IL or missing references) + //IL_0299: Expected O, but got Unknown + //IL_029b: Unknown result type (might be due to invalid IL or missing references) + //IL_02a7: Unknown result type (might be due to invalid IL or missing references) + //IL_02b1: Expected O, but got Unknown + //IL_02b3: Unknown result type (might be due to invalid IL or missing references) + //IL_02bf: Unknown result type (might be due to invalid IL or missing references) + //IL_02c9: Expected O, but got Unknown + //IL_02cb: Unknown result type (might be due to invalid IL or missing references) + //IL_02d7: Unknown result type (might be due to invalid IL or missing references) + //IL_02e1: Expected O, but got Unknown + //IL_02e3: Unknown result type (might be due to invalid IL or missing references) + //IL_02ef: Unknown result type (might be due to invalid IL or missing references) + //IL_02f9: Expected O, but got Unknown + //IL_02fb: Unknown result type (might be due to invalid IL or missing references) + //IL_0307: Unknown result type (might be due to invalid IL or missing references) + //IL_0311: Expected O, but got Unknown + //IL_0313: Unknown result type (might be due to invalid IL or missing references) + //IL_031f: Unknown result type (might be due to invalid IL or missing references) + //IL_0329: Expected O, but got Unknown + //IL_032b: Unknown result type (might be due to invalid IL or missing references) + //IL_0337: Unknown result type (might be due to invalid IL or missing references) + //IL_0341: Expected O, but got Unknown + //IL_0343: Unknown result type (might be due to invalid IL or missing references) + //IL_034f: Unknown result type (might be due to invalid IL or missing references) + //IL_0359: Expected O, but got Unknown + //IL_035b: Unknown result type (might be due to invalid IL or missing references) + //IL_0367: Unknown result type (might be due to invalid IL or missing references) + //IL_0371: Expected O, but got Unknown + //IL_0372: Unknown result type (might be due to invalid IL or missing references) + //IL_037e: Unknown result type (might be due to invalid IL or missing references) + //IL_0388: Expected O, but got Unknown + //IL_038a: Unknown result type (might be due to invalid IL or missing references) + //IL_0396: Unknown result type (might be due to invalid IL or missing references) + //IL_03a0: Expected O, but got Unknown + //IL_03a1: Unknown result type (might be due to invalid IL or missing references) + //IL_03ad: Unknown result type (might be due to invalid IL or missing references) + //IL_03b7: Expected O, but got Unknown + //IL_03b9: Unknown result type (might be due to invalid IL or missing references) + //IL_03c5: Unknown result type (might be due to invalid IL or missing references) + //IL_03cf: Expected O, but got Unknown + //IL_03d2: Unknown result type (might be due to invalid IL or missing references) + //IL_03dc: Expected O, but got Unknown + //IL_03de: Unknown result type (might be due to invalid IL or missing references) + //IL_03ea: Unknown result type (might be due to invalid IL or missing references) + //IL_03f4: Expected O, but got Unknown + //IL_03f7: Unknown result type (might be due to invalid IL or missing references) + //IL_0401: Expected O, but got Unknown + //IL_0411: Unknown result type (might be due to invalid IL or missing references) + //IL_041b: Expected O, but got Unknown + //IL_0428: Unknown result type (might be due to invalid IL or missing references) + //IL_0432: Expected O, but got Unknown + //IL_0434: Unknown result type (might be due to invalid IL or missing references) + //IL_0440: Unknown result type (might be due to invalid IL or missing references) + //IL_044a: Expected O, but got Unknown + //IL_044c: Unknown result type (might be due to invalid IL or missing references) + //IL_0458: Unknown result type (might be due to invalid IL or missing references) + //IL_0462: Expected O, but got Unknown + //IL_0464: Unknown result type (might be due to invalid IL or missing references) + //IL_0470: Unknown result type (might be due to invalid IL or missing references) + //IL_047a: Expected O, but got Unknown + //IL_047c: Unknown result type (might be due to invalid IL or missing references) + //IL_0488: Unknown result type (might be due to invalid IL or missing references) + //IL_0492: Expected O, but got Unknown + //IL_0493: Unknown result type (might be due to invalid IL or missing references) + //IL_049f: Unknown result type (might be due to invalid IL or missing references) + //IL_04a9: Expected O, but got Unknown + //IL_04ab: Unknown result type (might be due to invalid IL or missing references) + //IL_04b7: Unknown result type (might be due to invalid IL or missing references) + //IL_04c1: Expected O, but got Unknown + //IL_04c4: Unknown result type (might be due to invalid IL or missing references) + //IL_04ce: Expected O, but got Unknown + switch (connectionId) + { + case 1: + ProgressRing = (Image)target; + break; + case 2: + RelatorioBox = (ComboBox)target; + ((Selector)RelatorioBox).SelectionChanged += new SelectionChangedEventHandler(TipoRelatorio_OnSelectionChanged); + break; + case 3: + ((ButtonBase)(Button)target).Click += new RoutedEventHandler(AbrirInfo_Click); + break; + case 4: + ValorInicioBox = (CurrencyTextBox)target; + break; + case 5: + ValorFimBox = (CurrencyTextBox)target; + break; + case 6: + InicioBox = (DatePicker)target; + ((UIElement)InicioBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); + ((Control)InicioBox).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick); + break; + case 7: + FimBox = (DatePicker)target; + ((UIElement)FimBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); + ((Control)FimBox).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick); + break; + case 8: + VisualizarRamosVendedoresTooltip = (ToggleButton)target; + ((ButtonBase)VisualizarRamosVendedoresTooltip).Click += new RoutedEventHandler(ReloadWindow_Click); + break; + case 9: + GerarRelatorioButton = (MenuItem)target; + GerarRelatorioButton.Click += new RoutedEventHandler(GerarResultados_OnClick); + break; + case 10: + ((MenuItem)target).Click += new RoutedEventHandler(Imprimir_OnClick); + break; + case 11: + ((MenuItem)target).Click += new RoutedEventHandler(ExportarExcel_OnClick); + break; + case 12: + ((MenuItem)target).Click += new RoutedEventHandler(PlanilhaCompleta_OnClick); + break; + case 13: + ((MenuItem)target).Click += new RoutedEventHandler(Extrato_OnClick); + break; + case 14: + ((MenuItem)target).Click += new RoutedEventHandler(MaisFiltros_OnClick); + break; + case 15: + ((MenuItem)target).Click += new RoutedEventHandler(ConfigurarRelatorio_OnClick); + break; + case 16: + ((MenuItem)target).Click += new RoutedEventHandler(Sintetico_OnClick); + break; + case 17: + ((MenuItem)target).Click += new RoutedEventHandler(Tarefas_OnClick); + break; + case 18: + ((MenuItem)target).Click += new RoutedEventHandler(Etiquetas_OnClick); + break; + case 19: + ((MenuItem)target).Click += new RoutedEventHandler(Acompanhamento_OnClick); + break; + case 20: + ((MenuItem)target).Click += new RoutedEventHandler(Email_OnClick); + break; + case 21: + ((MenuItem)target).Click += new RoutedEventHandler(Apolice_OnClick); + break; + case 22: + ((MenuItem)target).Click += new RoutedEventHandler(Protocolo_OnClick); + break; + case 23: + ((MenuItem)target).Click += new RoutedEventHandler(Sincronizar_OnClick); + break; + case 24: + ((MenuItem)target).Click += new RoutedEventHandler(FecharFiltro_OnClick); + break; + case 25: + ((ButtonBase)(Button)target).Click += new RoutedEventHandler(FecharFiltro_OnClick); + break; + case 26: + ((UIElement)(DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); + ((Control)(DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick); + break; + case 27: + ((UIElement)(DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus); + ((Control)(DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick); + break; + case 28: + ((ButtonBase)(Button)target).Click += new RoutedEventHandler(AdicionarFiltro_OnClick); + break; + case 30: + RamoBox = (ComboBox)target; + break; + case 31: + ((ButtonBase)(Button)target).Click += new RoutedEventHandler(AdicionarRamo_OnClick); + break; + case 33: + ReportControl = (ContentControl)target; + break; + case 34: + WebEditor = (WebEditor)target; + break; + case 35: + HelpPopup = (PopupBox)target; + HelpPopup.Opened += new RoutedEventHandler(HelpPopup_Opened); + break; + case 36: + ((ButtonBase)(Button)target).Click += new RoutedEventHandler(OcultarAjuda_OnClick); + break; + case 37: + ((ButtonBase)(Button)target).Click += new RoutedEventHandler(Fechar_OnClick); + break; + case 40: + ((ButtonBase)(Button)target).Click += new RoutedEventHandler(FecharFiltroUsuario_OnClick); + break; + case 41: + ((AutoCompleteBox)target).Populating += new PopulatingEventHandler(AutoCompleteBoxUsuario_Populating); + ((AutoCompleteBox)target).TextChanged += new RoutedEventHandler(AutoCompleteBox_OnTextChanged); + break; + case 42: + ((ButtonBase)(Button)target).Click += new RoutedEventHandler(FecharInfo_Click); + break; + case 43: + NaoHaDados = (TextBlock)target; + break; + default: + _contentLoaded = true; + break; + } + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + [EditorBrowsable(EditorBrowsableState.Never)] + void IStyleConnector.Connect(int connectionId, object target) + { + //IL_004c: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Expected O, but got Unknown + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Expected O, but got Unknown + //IL_0064: Unknown result type (might be due to invalid IL or missing references) + //IL_0070: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Expected O, but got Unknown + //IL_0034: Unknown result type (might be due to invalid IL or missing references) + //IL_0040: Unknown result type (might be due to invalid IL or missing references) + //IL_004a: Expected O, but got Unknown + switch (connectionId) + { + case 29: + ((Chip)target).DeleteClick += new RoutedEventHandler(ExcluirFiltro_OnClick); + break; + case 32: + ((Chip)target).DeleteClick += new RoutedEventHandler(ExcluirRamo_onClick); + break; + case 38: + ((ButtonBase)(Button)target).Click += new RoutedEventHandler(CopyLink_OnClick); + break; + case 39: + ((ButtonBase)(Button)target).Click += new RoutedEventHandler(Play_Click); + break; + } + } +} diff --git a/Decompiler/Gestor.Application.Views.Relatorios/SinteticoView.cs b/Decompiler/Gestor.Application.Views.Relatorios/SinteticoView.cs new file mode 100644 index 0000000..0cde0a8 --- /dev/null +++ b/Decompiler/Gestor.Application.Views.Relatorios/SinteticoView.cs @@ -0,0 +1,509 @@ +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.InteropServices; +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; +using Gestor.Application.Helpers; +using Gestor.Application.Model; +using Gestor.Application.ViewModels.Relatorios; +using Gestor.Model.Domain.Relatorios; + +namespace Gestor.Application.Views.Relatorios; + +public class SinteticoView : Window, IComponentConnector, IStyleConnector +{ + private enum MonitorOptions : uint + { + MonitorDefaulttoprimary = 1u, + MonitorDefaulttonearest + } + + public struct Point + { + public int X; + + public int Y; + + public Point(int x, int y) + { + X = x; + Y = y; + } + } + + private struct Minmaxinfo + { + private readonly MainWindow.Point ptReserved; + + public Point ptMaxSize; + + public Point ptMaxPosition; + + private readonly MainWindow.Point ptMinTrackSize; + + private readonly MainWindow.Point ptMaxTrackSize; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + private class Monitorinfo + { + private readonly int cbSize = Marshal.SizeOf(typeof(Monitorinfo)); + + public readonly Rect rcMonitor; + + public readonly Rect rcWork; + + private readonly int dwFlags; + } + + public struct Rect + { + public int Left; + + public int Top; + + public int Right; + + public int Bottom; + } + + internal SinteticoViewModel ViewModel; + + private bool _buttonClickable; + + private ListSortDirection _ascending; + + private string _member; + + internal WindowChrome WindowChrome; + + internal TextBlock SubTitulo; + + internal Grid MinimizeButton; + + internal Grid MaximizeButton; + + internal Grid CloseButton; + + internal TabControl Tab; + + private bool _contentLoaded; + + public DateTime? DateStart { get; set; } + + public DateTime? DateFinal { get; set; } + + private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) + { + if (msg == 36) + { + WmGetMinMaxInfo(lParam); + } + return IntPtr.Zero; + } + + private void WmGetMinMaxInfo(IntPtr lParam) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + ((FrameworkElement)this).MaxHeight = Screen.FromHandle(new WindowInteropHelper((Window)(object)this).Handle).WorkingArea.Height; + GetCursorPos(out var lpPoint); + IntPtr hMonitor = MonitorFromPoint(new MainWindow.Point(0, 0), MonitorOptions.MonitorDefaulttoprimary); + Monitorinfo monitorinfo = new Monitorinfo(); + if (GetMonitorInfo(hMonitor, monitorinfo)) + { + IntPtr intPtr = MonitorFromPoint(lpPoint, MonitorOptions.MonitorDefaulttonearest); + Minmaxinfo structure = (Minmaxinfo)Marshal.PtrToStructure(lParam, typeof(Minmaxinfo)); + if (hMonitor.Equals((object?)(nint)intPtr)) + { + 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; + } + else + { + 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; + } + Marshal.StructureToPtr(structure, lParam, fDeleteOld: true); + } + } + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool GetCursorPos(out MainWindow.Point lpPoint); + + [DllImport("user32.dll", SetLastError = true)] + private static extern IntPtr MonitorFromPoint(MainWindow.Point pt, MonitorOptions dwFlags); + + [DllImport("user32.dll")] + private static extern bool GetMonitorInfo(IntPtr hMonitor, Monitorinfo lpmi); + + public SinteticoView(List<Sintetico> sintetico, string relatorio, DateTime? inicio, DateTime? fim) + { + //IL_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00df: Expected O, but got Unknown + //IL_00ec: Unknown result type (might be due to invalid IL or missing references) + //IL_00f6: Expected O, but got Unknown + //IL_0103: Unknown result type (might be due to invalid IL or missing references) + //IL_010d: Expected O, but got Unknown + //IL_011a: Unknown result type (might be due to invalid IL or missing references) + //IL_0124: Expected O, but got Unknown + //IL_0131: Unknown result type (might be due to invalid IL or missing references) + //IL_013b: Expected O, but got Unknown + //IL_0148: Unknown result type (might be due to invalid IL or missing references) + //IL_0152: Expected O, but got Unknown + ViewModel = new SinteticoViewModel(sintetico, relatorio); + ((FrameworkElement)this).DataContext = ViewModel; + InitializeComponent(); + SubTitulo.Text = "VALORES BASEADOS NA RELAÇÃO EMITIDA ANTERIORMENTE - INICIO: " + inicio?.ToString("dd/MM/yyyy") + " FIM: " + fim?.ToString("dd/MM/yyyy"); + DateStart = inicio ?? DateTime.MinValue; + DateFinal = fim ?? DateTime.MinValue; + ((UIElement)MinimizeButton).MouseEnter += new MouseEventHandler(TopControls_OnMouseEnter); + ((UIElement)MinimizeButton).MouseLeave += new MouseEventHandler(TopControls_OnMouseLeave); + ((UIElement)MaximizeButton).MouseEnter += new MouseEventHandler(TopControls_OnMouseEnter); + ((UIElement)MaximizeButton).MouseLeave += new MouseEventHandler(TopControls_OnMouseLeave); + ((UIElement)CloseButton).MouseEnter += new MouseEventHandler(TopControls_OnMouseEnter); + ((UIElement)CloseButton).MouseLeave += new MouseEventHandler(TopControls_OnMouseLeave); + } + + private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0030: Unknown result type (might be due to invalid IL or missing references) + //IL_0035: Unknown result type (might be due to invalid IL or missing references) + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Unknown result type (might be due to invalid IL or missing references) + //IL_003f: Expected O, but got Unknown + _buttonClickable = true; + ((Panel)(Grid)sender).Background = (Brush)((((FrameworkElement)(Grid)sender).Name == "CloseButton") ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.DimGray)); + } + + private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + if (_buttonClickable) + { + ((object)this).GetType().GetMethod(((FrameworkElement)(Grid)sender).Name + "_Click")?.Invoke(this, null); + } + } + + private static void TopControls_OnMouseEnter(object sender, MouseEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Unknown result type (might be due to invalid IL or missing references) + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_001d: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Expected O, but got Unknown + //IL_0039: Unknown result type (might be due to invalid IL or missing references) + //IL_0044: Expected O, but got Unknown + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_0053: Unknown result type (might be due to invalid IL or missing references) + //IL_005d: Expected O, but got Unknown + ((Panel)(Grid)sender).Background = (Brush)((((FrameworkElement)(Grid)sender).Name == "CloseButton") ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray)); + DependencyObject child = VisualTreeHelper.GetChild((DependencyObject)(Grid)sender, 0); + Path val = (Path)(object)((child is Path) ? child : null); + if (val != null) + { + ((Shape)val).Stroke = (Brush)new SolidColorBrush(Colors.White); + } + } + + private void TopControls_OnMouseLeave(object sender, MouseEventArgs e) + { + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Expected O, but got Unknown + //IL_001d: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Expected O, but got Unknown + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_0037: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Expected O, but got Unknown + _buttonClickable = false; + ((Panel)(Grid)sender).Background = (Brush)new SolidColorBrush(Colors.Transparent); + DependencyObject child = VisualTreeHelper.GetChild((DependencyObject)(Grid)sender, 0); + Path val = (Path)(object)((child is Path) ? child : null); + if (val != null) + { + ((Shape)val).Stroke = (Brush)new SolidColorBrush(Colors.White); + } + } + + public void MinimizeButton_Click() + { + ((Window)this).WindowState = (WindowState)1; + } + + public void MaximizeButton_Click() + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + ((Window)this).WindowState = (WindowState)(((int)((Window)this).WindowState == 0) ? 2 : 0); + } + + public void CloseButton_Click() + { + ((Window)this).Close(); + } + + protected sealed override void OnStateChanged(EventArgs e) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Invalid comparison between Unknown and I4 + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + //IL_0025: Invalid comparison between Unknown and I4 + //IL_002c: Unknown result type (might be due to invalid IL or missing references) + //IL_003d: Unknown result type (might be due to invalid IL or missing references) + //IL_0043: Invalid comparison between Unknown and I4 + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Invalid comparison between Unknown and I4 + ((Control)this).BorderThickness = new Thickness((double)(((int)((Window)this).WindowState != 2) ? 1 : 0)); + WindowChrome.ResizeBorderThickness = new Thickness((double)(((int)((Window)this).WindowState != 2) ? 4 : 0)); + WindowChrome.CaptionHeight = (((int)((Window)this).WindowState == 2) ? 33 : 30); + ViewModel.MaximizeRestore = (((int)((Window)this).WindowState == 2) ? Geometry.Parse((string)Application.Current.Resources[(object)"Restore"]) : Geometry.Parse((string)Application.Current.Resources[(object)"Maximize"])); + ((Window)this).OnStateChanged(e); + } + + private void Window_OnInitialized(object sender, EventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_002d: Expected O, but got Unknown + WindowInteropHelper val = new WindowInteropHelper((Window)(object)this); + val.EnsureHandle(); + HwndSource obj = HwndSource.FromHwnd(val.Handle); + if (obj != null) + { + obj.AddHook(new HwndSourceHook(WindowProc)); + } + } + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + MenuItem val = (MenuItem)sender; + if (val != null && ((FrameworkElement)val).DataContext != null) + { + SinteticoSource sinteticoSource = (SinteticoSource)((FrameworkElement)val).DataContext; + if (DateStart != DateTime.MinValue) + { + sinteticoSource.DateStart = DateStart; + sinteticoSource.DateFinal = DateFinal; + } + await ViewModel.Print(sinteticoSource); + } + } + + private async void ImprimirUnicaPagina_OnClick(object sender, RoutedEventArgs e) + { + MenuItem val = (MenuItem)sender; + if (val != null && ((FrameworkElement)val).DataContext != null) + { + SinteticoSource sinteticoSource = (SinteticoSource)((FrameworkElement)val).DataContext; + if (DateStart != DateTime.MinValue) + { + sinteticoSource.DateStart = DateStart; + sinteticoSource.DateFinal = DateFinal; + } + await ViewModel.PrintUnica(sinteticoSource); + } + } + + private void AjustaNome(SinteticoSource source) + { + foreach (ValorSintetico listum in source.Lista) + { + if (!string.IsNullOrEmpty(listum.Porcentagem) && !listum.Indice.Contains(listum.Porcentagem)) + { + listum.Indice = listum.Indice + " - " + listum.Porcentagem + "%"; + } + } + } + + private async void ExportarPdf_OnClick(object sender, RoutedEventArgs e) + { + MenuItem val = (MenuItem)sender; + if (val != null && ((FrameworkElement)val).DataContext != null) + { + SinteticoSource sintetico = (SinteticoSource)((FrameworkElement)val).DataContext; + await ViewModel.GerarPdf(sintetico); + } + } + + private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e) + { + MenuItem val = (MenuItem)sender; + if (val != null && ((FrameworkElement)val).DataContext != null) + { + SinteticoSource sintetico = (SinteticoSource)((FrameworkElement)val).DataContext; + await ViewModel.GerarExcel(sintetico); + } + } + + private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Expected O, but got Unknown + DataGrid val = (DataGrid)sender; + if (val == null || ((FrameworkElement)val).DataContext == null) + { + return; + } + if (_member == ((DataGridColumnEventArgs)e).Column.SortMemberPath) + { + _ascending = ((_ascending == ListSortDirection.Ascending) ? ListSortDirection.Descending : ListSortDirection.Ascending); + } + else + { + _ascending = ListSortDirection.Ascending; + } + if (!(((ItemsControl)val).ItemsSource is ObservableCollection<ValorSintetico> observableCollection)) + { + return; + } + IQueryable<ValorSintetico> source = observableCollection.AsQueryable(); + List<ValorSintetico> list = ((_ascending == ListSortDirection.Ascending) ? source.OrderBy(((DataGridColumnEventArgs)e).Column.SortMemberPath).ToList() : source.OrderByDescending(((DataGridColumnEventArgs)e).Column.SortMemberPath).ToList()).OrderBy((ValorSintetico x) => x.Indice == "TOTAL").ToList(); + observableCollection.Clear(); + foreach (ValorSintetico item in list) + { + observableCollection.Add(item); + } + ViewModel.OnPropertyChanged("DataGrid_Sorting"); + _member = ((DataGridColumnEventArgs)e).Column.SortMemberPath; + e.Handled = true; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + public void InitializeComponent() + { + if (!_contentLoaded) + { + _contentLoaded = true; + Uri uri = new Uri("/Gestor.Application;component/views/relatorios/sinteticoview.xaml", UriKind.Relative); + Application.LoadComponent((object)this, uri); + } + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + [EditorBrowsable(EditorBrowsableState.Never)] + void IComponentConnector.Connect(int connectionId, object target) + { + //IL_0043: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Expected O, but got Unknown + //IL_0050: Unknown result type (might be due to invalid IL or missing references) + //IL_005a: Expected O, but got Unknown + //IL_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_0067: Expected O, but got Unknown + //IL_0074: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Expected O, but got Unknown + //IL_008b: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Expected O, but got Unknown + //IL_0098: Unknown result type (might be due to invalid IL or missing references) + //IL_00a2: Expected O, but got Unknown + //IL_00af: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: Expected O, but got Unknown + //IL_00c6: Unknown result type (might be due to invalid IL or missing references) + //IL_00d0: Expected O, but got Unknown + //IL_00d3: Unknown result type (might be due to invalid IL or missing references) + //IL_00dd: Expected O, but got Unknown + //IL_00ea: Unknown result type (might be due to invalid IL or missing references) + //IL_00f4: Expected O, but got Unknown + //IL_0101: Unknown result type (might be due to invalid IL or missing references) + //IL_010b: Expected O, but got Unknown + //IL_010e: Unknown result type (might be due to invalid IL or missing references) + //IL_0118: Expected O, but got Unknown + switch (connectionId) + { + case 1: + ((FrameworkElement)(SinteticoView)target).Initialized += Window_OnInitialized; + break; + case 2: + WindowChrome = (WindowChrome)target; + break; + case 3: + SubTitulo = (TextBlock)target; + break; + case 4: + MinimizeButton = (Grid)target; + ((UIElement)MinimizeButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown); + ((UIElement)MinimizeButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp); + break; + case 5: + MaximizeButton = (Grid)target; + ((UIElement)MaximizeButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown); + ((UIElement)MaximizeButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp); + break; + case 6: + CloseButton = (Grid)target; + ((UIElement)CloseButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown); + ((UIElement)CloseButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp); + break; + case 7: + Tab = (TabControl)target; + break; + default: + _contentLoaded = true; + break; + } + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + [EditorBrowsable(EditorBrowsableState.Never)] + void IStyleConnector.Connect(int connectionId, object target) + { + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_002a: Unknown result type (might be due to invalid IL or missing references) + //IL_0034: Expected O, but got Unknown + //IL_0036: Unknown result type (might be due to invalid IL or missing references) + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_004c: Expected O, but got Unknown + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_005a: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: Expected O, but got Unknown + //IL_0066: Unknown result type (might be due to invalid IL or missing references) + //IL_0072: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: Expected O, but got Unknown + //IL_007e: Unknown result type (might be due to invalid IL or missing references) + //IL_008a: Unknown result type (might be due to invalid IL or missing references) + //IL_0094: Expected O, but got Unknown + switch (connectionId) + { + case 8: + ((MenuItem)target).Click += new RoutedEventHandler(Imprimir_OnClick); + break; + case 9: + ((MenuItem)target).Click += new RoutedEventHandler(ExportarPdf_OnClick); + break; + case 10: + ((MenuItem)target).Click += new RoutedEventHandler(ExportarExcel_OnClick); + break; + case 11: + ((MenuItem)target).Click += new RoutedEventHandler(ImprimirUnicaPagina_OnClick); + break; + case 12: + ((DataGrid)target).Sorting += new DataGridSortingEventHandler(DataGrid_Sorting); + break; + } + } +} |