1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
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;
}
}
}
}
|