summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/Views/Menus/DashboardView.cs
blob: 1b130e6350833b192d62a2bdaa35686078cdd89a (plain)
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
using Gestor.Application.Drawers;
using Gestor.Application.Helpers;
using Gestor.Application.Servicos.Seguros;
using Gestor.Application.ViewModels;
using Gestor.Application.ViewModels.Generic;
using Gestor.Application.Views.Generic;
using Gestor.Application.Views.Seguros;
using Gestor.Common.Validation;
using Gestor.Model.Common;
using Gestor.Model.Domain.Ferramentas;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos;
using Gestor.Model.Domain.Relatorios.Dashboard;
using Gestor.Model.Domain.Relatorios.Renovacao;
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;

namespace Gestor.Application.Views.Menus
{
	public class DashboardView : BaseUserControl, IComponentConnector, IStyleConnector
	{
		internal Chip UsuarioChip;

		internal Button TileRenovacao;

		internal Button TileAniversariantes;

		internal Button TileTarefas;

		internal Button TileSinistro;

		internal Button TileProspeccao;

		internal TextBox TituloBox;

		internal TextBox DescricaoBox;

		internal Grid RenovacaoGrid;

		internal Grid AniversariantesGrid;

		internal Grid TarefasGrid;

		internal Grid ProspeccaoGrid;

		internal DatePicker InicioBox;

		internal DatePicker FimBox;

		internal ComboBox FiltroDocumento;

		internal Grid SinistroGrid;

		internal DatePicker InicioBox2;

		internal DatePicker FimBox2;

		private bool _contentLoaded;

		public DashboardViewModel ViewModel
		{
			get;
			set;
		}

		[DebuggerNonUserCode]
		[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
		internal Delegate _CreateDelegate(Type delegateType, string handler)
		{
			return Delegate.CreateDelegate(delegateType, this, handler);
		}

		public DashboardView(DashboardViewModel viewModel)
		{
			base.Tag = "DASHBOARD";
			this.ViewModel = viewModel;
			base.DataContext = this.ViewModel;
			this.InitializeComponent();
			System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher;
			if (dispatcher == null)
			{
				return;
			}
			dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad));
		}

		private async void AbrirAniversariante_OnClick(object sender, RoutedEventArgs e)
		{
			ClientesAtivosInativos dataContext = (ClientesAtivosInativos)((Button)sender).DataContext;
			Cliente cliente = await (new ClienteServico()).BuscarClienteAsync(dataContext.get_EntidadeCliente().get_Id());
			double? nullable = null;
			double? nullable1 = nullable;
			nullable = null;
			(new HosterWindow(new ClienteView(cliente, true, null), string.Concat("CADASTRO DE CLIENTES - ", cliente.get_Nome()), nullable1, nullable, false)).ShowDialog();
		}

		private async Task AbrirProspeccao(Prospeccao data)
		{
			bool flag;
			this.InicioBox.Text = ValidationHelper.FormatDate(this.InicioBox.Text);
			this.FimBox.Text = ValidationHelper.FormatDate(this.FimBox.Text);
			while (true)
			{
				data = await this.ViewModel.ShowProspeccaoDialog(data);
				if (data == null)
				{
					return;
				}
				List<KeyValuePair<string, string>> keyValuePairs = await this.ViewModel.SalvarProspeccao(data);
				flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0);
				if (flag)
				{
					break;
				}
				await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", "");
			}
			this.ViewModel.ToggleSnackBar("PROSPECÇÃO SALVA COM SUCESSO.", true);
			await this.CarregarForce();
			return;
		}

		private async void AbrirRenovacao_OnClick(object sender, RoutedEventArgs e)
		{
			Renovacao dataContext = (Renovacao)((Button)sender).DataContext;
			if (dataContext.get_Documento() != null)
			{
				Documento documento = await (new ApoliceServico()).BuscarApoliceAsync(dataContext.get_Documento().get_Id(), false, false);
				double? nullable = null;
				double? nullable1 = nullable;
				nullable = null;
				(new HosterWindow(new ApoliceView(documento, true, false, 0, (long)0, false), string.Concat("CADASTRO DE APÓLICES - ", documento.get_Controle().get_Cliente().get_Nome()), nullable1, nullable, false)).Show();
			}
			else
			{
				this.ViewModel.Loading(true);
				await this.AbrirProspeccao(dataContext.get_Prospeccao());
				this.ViewModel.Loading(false);
			}
		}

		private async void AbrirSinistro_OnClick(object sender, RoutedEventArgs e)
		{
			Button button = (Button)sender;
			if (button.DataContext != null)
			{
				Sinistro dataContext = (Sinistro)button.DataContext;
				if (dataContext != null)
				{
					dataContext = await this.ViewModel.CarregaSinistroApolice(dataContext.get_Id());
					Item item = dataContext.get_ControleSinistro().get_Item();
					SinistroView sinistroView = new SinistroView(item, false);
					string[] nome = new string[] { "CADASTRO DE SINISTROS - ", item.get_Documento().get_Controle().get_Cliente().get_Nome(), " - ", item.get_Documento().get_Apolice(), " ", item.get_Documento().get_Endosso() };
					double? nullable = null;
					double? nullable1 = nullable;
					nullable = null;
					(new HosterWindow(sinistroView, string.Concat(nome), nullable1, nullable, false)).Show();
				}
			}
		}

		private void AbrirTarefa_OnClick(object sender, RoutedEventArgs e)
		{
			Tarefa dataContext = (Tarefa)((Button)sender).DataContext;
			this.ViewModel.ShowDrawer(new TarefaDrawer(dataContext, true), 0, false);
		}

		private void AdicionarNota_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.EnableFields = true;
			this.TituloBox.Text = string.Empty;
			this.DescricaoBox.Text = string.Empty;
			this.ViewModel.Publica = false;
		}

		private void Cancelar_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.EnableFields = false;
		}

		private async Task Carregar()
		{
			this.ViewModel.Loading(true);
			this.RenovacaoGrid.Visibility = System.Windows.Visibility.Collapsed;
			this.AniversariantesGrid.Visibility = System.Windows.Visibility.Collapsed;
			this.TarefasGrid.Visibility = System.Windows.Visibility.Collapsed;
			this.ProspeccaoGrid.Visibility = System.Windows.Visibility.Collapsed;
			this.SinistroGrid.Visibility = System.Windows.Visibility.Collapsed;
			if (this.ViewModel.Filtros == null)
			{
				await this.ViewModel.CarregarFiltros();
			}
			await this.ViewModel.CarregarNotas();
			switch (this.ViewModel.SelectedTile)
			{
				case 1:
				{
					await this.ViewModel.CarregarRenovacoes(false);
					this.RenovacaoGrid.Visibility = System.Windows.Visibility.Visible;
					break;
				}
				case 2:
				{
					await this.ViewModel.CarregarAniversariantes(false);
					this.AniversariantesGrid.Visibility = System.Windows.Visibility.Visible;
					break;
				}
				case 3:
				{
					await this.ViewModel.CarregarTarefas(false);
					this.TarefasGrid.Visibility = System.Windows.Visibility.Visible;
					break;
				}
				case 4:
				{
					DashboardViewModel viewModel = this.ViewModel;
					DateTime value = this.InicioBox.SelectedDate.Value;
					await viewModel.CarregarProspect(value, this.FimBox.SelectedDate.Value);
					this.ProspeccaoGrid.Visibility = System.Windows.Visibility.Visible;
					break;
				}
				case 5:
				{
					await this.ViewModel.CarregarSinistros(false);
					this.SinistroGrid.Visibility = System.Windows.Visibility.Visible;
					break;
				}
			}
			this.ViewModel.Loading(false);
		}

		private async Task CarregarForce()
		{
			this.ViewModel.Loading(true);
			this.RenovacaoGrid.Visibility = System.Windows.Visibility.Collapsed;
			this.AniversariantesGrid.Visibility = System.Windows.Visibility.Collapsed;
			this.TarefasGrid.Visibility = System.Windows.Visibility.Collapsed;
			this.ProspeccaoGrid.Visibility = System.Windows.Visibility.Collapsed;
			this.SinistroGrid.Visibility = System.Windows.Visibility.Collapsed;
			await this.ViewModel.CarregarFiltros();
			List<RestricaoUsuario> restricoes = this.ViewModel.Restricoes;
			bool flag = restricoes.Any<RestricaoUsuario>((RestricaoUsuario x) => {
				if (x.get_Tipo() != 24)
				{
					return false;
				}
				return x.get_Restricao();
			});
			List<RestricaoUsuario> restricaoUsuarios = this.ViewModel.Restricoes;
			bool flag1 = restricaoUsuarios.Any<RestricaoUsuario>((RestricaoUsuario x) => {
				if (x.get_Tipo() != 49)
				{
					return false;
				}
				return x.get_Restricao();
			});
			List<RestricaoUsuario> restricoes1 = this.ViewModel.Restricoes;
			bool flag2 = restricoes1.Any<RestricaoUsuario>((RestricaoUsuario x) => {
				if (x.get_Tipo() != 19)
				{
					return false;
				}
				return x.get_Restricao();
			});
			List<RestricaoUsuario> restricaoUsuarios1 = this.ViewModel.Restricoes;
			bool flag3 = restricaoUsuarios1.Any<RestricaoUsuario>((RestricaoUsuario x) => {
				if (x.get_Tipo() != 25)
				{
					return false;
				}
				return x.get_Restricao();
			});
			if (!flag)
			{
				await this.ViewModel.CarregarRenovacoes(true);
			}
			if (!flag1)
			{
				await this.ViewModel.CarregarAniversariantes(true);
			}
			if (!flag2)
			{
				await this.ViewModel.CarregarTarefas(true);
			}
			if (!flag3)
			{
				await this.ViewModel.CarregarSinistros(true);
			}
			await this.ViewModel.CarregarNotas();
			switch (this.ViewModel.SelectedTile)
			{
				case 1:
				{
					this.RenovacaoGrid.Visibility = System.Windows.Visibility.Visible;
					break;
				}
				case 2:
				{
					this.AniversariantesGrid.Visibility = System.Windows.Visibility.Visible;
					break;
				}
				case 3:
				{
					this.TarefasGrid.Visibility = System.Windows.Visibility.Visible;
					break;
				}
				case 4:
				{
					this.ProspeccaoGrid.Visibility = System.Windows.Visibility.Visible;
					break;
				}
				case 5:
				{
					this.SinistroGrid.Visibility = System.Windows.Visibility.Visible;
					break;
				}
			}
			this.ViewModel.Loading(false);
		}

		private async void ContentLoad()
		{
			DateTime? selectedDate;
			this.UsuarioChip.Content = Recursos.Usuario.get_Nome();
			await this.ViewModel.BuscarRestricoes();
			await this.ViewModel.CarregarNotas();
			await this.ViewModel.CarregarFiltros();
			List<RestricaoUsuario> restricoes = this.ViewModel.Restricoes;
			bool flag = restricoes.Any<RestricaoUsuario>((RestricaoUsuario x) => {
				if (x.get_Tipo() != 24)
				{
					return false;
				}
				return x.get_Restricao();
			});
			List<RestricaoUsuario> restricaoUsuarios = this.ViewModel.Restricoes;
			bool flag1 = restricaoUsuarios.Any<RestricaoUsuario>((RestricaoUsuario x) => {
				if (x.get_Tipo() != 49)
				{
					return false;
				}
				return x.get_Restricao();
			});
			List<PermissaoUsuario> permissoes = this.ViewModel.Permissoes;
			bool flag2 = permissoes.Any<PermissaoUsuario>((PermissaoUsuario x) => {
				if (x.get_Tela() != 38)
				{
					return false;
				}
				return !x.get_Consultar();
			});
			bool hasValue = !Recursos.Usuario.get_PermissaoAggilizador().HasValue;
			List<RestricaoUsuario> restricoes1 = this.ViewModel.Restricoes;
			bool flag3 = restricoes1.Any<RestricaoUsuario>((RestricaoUsuario x) => {
				if (x.get_Tipo() != 25)
				{
					return false;
				}
				return x.get_Restricao();
			});
			this.FiltroDocumento.SelectedIndex = 0;
			List<Task> tasks = new List<Task>();
			if (hasValue)
			{
				this.TileProspeccao.Visibility = System.Windows.Visibility.Collapsed;
			}
			else
			{
				this.ViewModel.CarregarRamos();
				this.TileProspeccao.Visibility = System.Windows.Visibility.Visible;
				if (!this.InicioBox.SelectedDate.HasValue)
				{
					this.InicioBox.SelectedDate = new DateTime?(DateTime.Today);
				}
				if (!this.FimBox.SelectedDate.HasValue)
				{
					DatePicker fimBox = this.FimBox;
					selectedDate = this.InicioBox.SelectedDate;
					fimBox.SelectedDate = new DateTime?(selectedDate.Value);
				}
				DashboardViewModel viewModel = this.ViewModel;
				DateTime value = this.InicioBox.SelectedDate.Value;
				selectedDate = this.FimBox.SelectedDate;
				tasks.Add(viewModel.CarregarProspect(value, selectedDate.Value));
			}
			if (flag2)
			{
				this.TileTarefas.Visibility = System.Windows.Visibility.Collapsed;
			}
			else
			{
				this.TileTarefas.Visibility = System.Windows.Visibility.Visible;
				this.ViewModel.SelectedTile = 3;
				tasks.Add(this.ViewModel.CarregarTarefas(false));
			}
			if (flag1)
			{
				this.TileAniversariantes.Visibility = System.Windows.Visibility.Collapsed;
			}
			else
			{
				this.TileAniversariantes.Visibility = System.Windows.Visibility.Visible;
				this.ViewModel.SelectedTile = 2;
				tasks.Add(this.ViewModel.CarregarAniversariantes(false));
			}
			if (flag3)
			{
				this.TileSinistro.Visibility = System.Windows.Visibility.Collapsed;
			}
			else
			{
				this.TileSinistro.Visibility = System.Windows.Visibility.Visible;
				this.ViewModel.SelectedTile = 5;
				tasks.Add(this.ViewModel.CarregarSinistros(false));
			}
			if (flag)
			{
				this.TileRenovacao.Visibility = System.Windows.Visibility.Collapsed;
			}
			else
			{
				this.TileRenovacao.Visibility = System.Windows.Visibility.Visible;
				this.ViewModel.SelectedTile = 1;
				tasks.Add(this.ViewModel.CarregarRenovacoes(false));
			}
			await Task.WhenAll(tasks);
			this.ViewModel.Load = false;
		}

		private void DatePicker_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e)
		{
			this.ViewModel.LimparProspeccao();
		}

		private async void EnviarPorWhatsApp_OnClick(object sender, RoutedEventArgs e)
		{
			string str;
			if (!this.ViewModel.Restricao(32))
			{
				Button button = (Button)sender;
				if (button.DataContext != null)
				{
					ClienteTelefone dataContext = button.DataContext as ClienteTelefone;
					if (dataContext != null)
					{
						str = (!dataContext.get_Tipo().HasValue || dataContext.get_Tipo().GetValueOrDefault() != 8 ? string.Concat("55", dataContext.get_Prefixo(), dataContext.get_Numero().Clear()) : string.Concat(dataContext.get_Prefixo(), dataContext.get_Numero()).Clear());
						if (!str.EnviarWhatsapp(this.ViewModel.Anotacoes))
						{
							await this.ViewModel.ShowMessage("HOUVE UM PROBLEMA AO ABRIR LINK DO WHATSAPP, O LINK FOI COPIADO EM SUA MAQUINA, BASTA ABRIR O NAVEGADOR DE INTERNET E COLAR NA BARRA DE ENDEREÇOS", "OK", "", false);
						}
						return;
					}
				}
			}
			else
			{
				await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR O WHATSAPP", "OK", "", false);
			}
		}

		private async void ExcluirNota_OnClick(object sender, RoutedEventArgs e)
		{
			Tarefa dataContext = ((Button)sender).DataContext as Tarefa;
			if (dataContext != null)
			{
				await this.ViewModel.ExcluirNota(dataContext);
				await this.ViewModel.CarregarNotas();
			}
		}

		private void FiltroCliente_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			this.ViewModel.LimparProspeccao();
		}

		private async void GerarCsv_OnClick(object sender, RoutedEventArgs e)
		{
			DateTime date = DateTime.Now.Date;
			string.Concat("NovosNegocios", date.ToString("d").Replace("/", ""), ".csv");
			if (this.ViewModel.Prospeccoes.Count != 0)
			{
				this.ViewModel.Loading(true);
				await this.ViewModel.GerarCsv();
				this.ViewModel.Loading(false);
			}
			else
			{
				await this.ViewModel.ShowMessage("NÃO HÁ DADOS A SEREM EXPORTADOS NO .CSV", "OK", "", false);
			}
		}

		[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/menus/dashboardview.xaml", UriKind.Relative));
		}

		private async void NotaConcluida_OnClick(object sender, RoutedEventArgs e)
		{
			Tarefa dataContext = ((Button)sender).DataContext as Tarefa;
			if (dataContext != null)
			{
				dataContext.set_Conclusao(new DateTime?(Funcoes.GetNetworkTime()));
				dataContext.set_Status(2);
				await this.ViewModel.SalvarNota(dataContext);
				await this.ViewModel.CarregarNotas();
			}
		}

		private void PopupBox_OnClosed(object sender, RoutedEventArgs e)
		{
			this.ViewModel.Anotacoes = "";
		}

		private void PopupBoxAniversariante_OnOpened(object sender, RoutedEventArgs e)
		{
			ClientesAtivosInativos dataContext = (ClientesAtivosInativos)((PopupBox)sender).DataContext;
			this.ViewModel.Telefones = dataContext.get_EntidadeCliente().get_Telefones();
		}

		private void PopupBoxProspeccao_OnOpened(object sender, RoutedEventArgs e)
		{
			Prospectar dataContext = (Prospectar)((PopupBox)sender).DataContext;
			this.ViewModel.Telefones = dataContext.get_EntidadeCliente().get_Telefones();
		}

		private void PopupBoxRenovacao_OnOpened(object sender, RoutedEventArgs e)
		{
			PopupBox popupBox = (PopupBox)sender;
			ObservableCollection<ClienteTelefone> observableCollection = new ObservableCollection<ClienteTelefone>();
			Renovacao dataContext = (Renovacao)popupBox.DataContext;
			if (dataContext.get_Documento() == null)
			{
				if (!string.IsNullOrEmpty(dataContext.get_Prospeccao().get_Telefone1()))
				{
					ClienteTelefone clienteTelefone = new ClienteTelefone();
					clienteTelefone.set_Prefixo(dataContext.get_Prospeccao().get_Prefixo1());
					clienteTelefone.set_Numero(dataContext.get_Prospeccao().get_Telefone1());
					observableCollection.Add(clienteTelefone);
				}
				if (!string.IsNullOrEmpty(dataContext.get_Prospeccao().get_Telefone2()))
				{
					ClienteTelefone clienteTelefone1 = new ClienteTelefone();
					clienteTelefone1.set_Prefixo(dataContext.get_Prospeccao().get_Prefixo2());
					clienteTelefone1.set_Numero(dataContext.get_Prospeccao().get_Telefone2());
					observableCollection.Add(clienteTelefone1);
				}
			}
			else
			{
				observableCollection = dataContext.get_Documento().get_Controle().get_Cliente().get_Telefones();
			}
			this.ViewModel.Telefones = observableCollection;
		}

		private void Ramo_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			this.ViewModel.LimparProspeccao();
		}

		private void Referencia_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			this.ViewModel.LimparProspeccao();
		}

		private async void Refresh_OnClick(object sender, RoutedEventArgs e)
		{
			await this.CarregarForce();
		}

		private async void RefreshProspectar_OnClick(object sender, RoutedEventArgs e)
		{
			if (!this.InicioBox.SelectedDate.HasValue || !this.FimBox.SelectedDate.HasValue)
			{
				await this.ViewModel.ShowMessage("INÍCIO E FIM DEVEM ESTAR PREENCHIDOS.", "OK", "", false);
			}
			else if (this.InicioBox.SelectedDate.Value > this.FimBox.SelectedDate.Value)
			{
				await this.ViewModel.ShowMessage("INÍCIO NÃO DEVE SER MAIOR QUE O FIM.", "OK", "", false);
			}
			else if ((this.FimBox.SelectedDate.Value - this.InicioBox.SelectedDate.Value).TotalDays <= 31)
			{
				this.ViewModel.Loading(true);
				DashboardViewModel viewModel = this.ViewModel;
				DateTime value = this.InicioBox.SelectedDate.Value;
				await viewModel.CarregarProspect(value, this.FimBox.SelectedDate.Value);
				this.ProspeccaoGrid.Visibility = System.Windows.Visibility.Visible;
				this.ViewModel.Loading(false);
			}
			else
			{
				await this.ViewModel.ShowMessage("O PERIODO TOTAL DO RELATÓRIO NÃO PODE SER MAIOR QUE 30 DIAS.", "OK", "", false);
			}
		}

		private async void RefreshSinsitro_OnClick(object sender, RoutedEventArgs e)
		{
			if (!this.InicioBox2.SelectedDate.HasValue || !this.FimBox2.SelectedDate.HasValue)
			{
				await this.ViewModel.ShowMessage("INÍCIO E FIM DEVEM ESTAR PREENCHIDOS.", "OK", "", false);
			}
			else if (this.InicioBox2.SelectedDate.Value > this.FimBox2.SelectedDate.Value)
			{
				await this.ViewModel.ShowMessage("INÍCIO NÃO DEVE SER MAIOR QUE O FIM.", "OK", "", false);
			}
			else if ((this.FimBox2.SelectedDate.Value - this.InicioBox2.SelectedDate.Value).TotalDays <= 31)
			{
				this.ViewModel.Loading(true);
				DashboardViewModel viewModel = this.ViewModel;
				DateTime value = this.InicioBox2.SelectedDate.Value;
				await viewModel.CarregarSinistros(value, this.FimBox2.SelectedDate.Value);
				this.SinistroGrid.Visibility = System.Windows.Visibility.Visible;
				this.ViewModel.Loading(false);
			}
			else
			{
				await this.ViewModel.ShowMessage("O PERIODO TOTAL DO RELATÓRIO NÃO PODE SER MAIOR QUE 30 DIAS.", "OK", "", false);
			}
		}

		private async void SalvarNota_OnClick(object sender, RoutedEventArgs e)
		{
			bool flag;
			Tarefa tarefa = new Tarefa();
			tarefa.set_Agendamento(Funcoes.GetNetworkTime());
			tarefa.set_Titulo(this.TituloBox.Text);
			tarefa.set_Anotacoes(this.DescricaoBox.Text);
			tarefa.set_Usuario(Recursos.Usuario);
			tarefa.set_UsuarioCadastro(Recursos.Usuario);
			tarefa.set_Entidade(1);
			tarefa.set_Status(0);
			List<KeyValuePair<string, string>> keyValuePairs = await this.ViewModel.Salvar(tarefa);
			flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0);
			if (!flag)
			{
				await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", "");
			}
			else
			{
				this.ViewModel.ToggleSnackBar("NOTA SALVA COM SUCESSO.", true);
				this.ViewModel.EnableFields = false;
				await this.ViewModel.CarregarNotas();
			}
		}

		private async void SarvarNota_OnClick(object sender, RoutedEventArgs e)
		{
			Tarefa dataContext = ((Button)sender).DataContext as Tarefa;
			if (dataContext != null)
			{
				List<KeyValuePair<string, string>> keyValuePairs = await this.ViewModel.Salvar(dataContext);
				if (keyValuePairs != null && keyValuePairs.Count != 0)
				{
					await this.ViewModel.CarregarNotas();
				}
			}
		}

		[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.UsuarioChip = (Chip)target;
					return;
				}
				case 2:
				{
					((Button)target).Click += new RoutedEventHandler(this.Refresh_OnClick);
					return;
				}
				case 3:
				{
					this.TileRenovacao = (Button)target;
					this.TileRenovacao.Click += new RoutedEventHandler(this.TileRenovacao_OnClick);
					return;
				}
				case 4:
				{
					this.TileAniversariantes = (Button)target;
					this.TileAniversariantes.Click += new RoutedEventHandler(this.TileAniversariantes_OnClick);
					return;
				}
				case 5:
				{
					this.TileTarefas = (Button)target;
					this.TileTarefas.Click += new RoutedEventHandler(this.TileTarefas_OnClick);
					return;
				}
				case 6:
				{
					this.TileSinistro = (Button)target;
					this.TileSinistro.Click += new RoutedEventHandler(this.TileSinistro_OnClick);
					return;
				}
				case 7:
				{
					this.TileProspeccao = (Button)target;
					this.TileProspeccao.Click += new RoutedEventHandler(this.TileProspeccao_OnClick);
					return;
				}
				case 8:
				{
					((Button)target).Click += new RoutedEventHandler(this.AdicionarNota_OnClick);
					return;
				}
				case 9:
				{
					((Button)target).Click += new RoutedEventHandler(this.SalvarNota_OnClick);
					return;
				}
				case 10:
				{
					((Button)target).Click += new RoutedEventHandler(this.Cancelar_OnClick);
					return;
				}
				case 11:
				{
					this.TituloBox = (TextBox)target;
					return;
				}
				case 12:
				{
					this.DescricaoBox = (TextBox)target;
					return;
				}
				case 13:
				case 14:
				case 16:
				case 17:
				case 18:
				case 20:
				case 21:
				case 22:
				case 24:
				case 33:
				case 34:
				{
					this._contentLoaded = true;
					return;
				}
				case 15:
				{
					this.RenovacaoGrid = (Grid)target;
					return;
				}
				case 19:
				{
					this.AniversariantesGrid = (Grid)target;
					return;
				}
				case 23:
				{
					this.TarefasGrid = (Grid)target;
					return;
				}
				case 25:
				{
					this.ProspeccaoGrid = (Grid)target;
					return;
				}
				case 26:
				{
					((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Ramo_OnSelectionChanged);
					return;
				}
				case 27:
				{
					((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Referencia_OnSelectionChanged);
					return;
				}
				case 28:
				{
					this.InicioBox = (DatePicker)target;
					this.InicioBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					this.InicioBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					this.InicioBox.SelectedDateChanged += new EventHandler<SelectionChangedEventArgs>(this.DatePicker_OnSelectedDateChanged);
					return;
				}
				case 29:
				{
					this.FimBox = (DatePicker)target;
					this.FimBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					this.FimBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					this.FimBox.SelectedDateChanged += new EventHandler<SelectionChangedEventArgs>(this.DatePicker_OnSelectedDateChanged);
					return;
				}
				case 30:
				{
					this.FiltroDocumento = (ComboBox)target;
					this.FiltroDocumento.SelectionChanged += new SelectionChangedEventHandler(this.FiltroCliente_OnSelectionChanged);
					return;
				}
				case 31:
				{
					((Button)target).Click += new RoutedEventHandler(this.RefreshProspectar_OnClick);
					return;
				}
				case 32:
				{
					((Button)target).Click += new RoutedEventHandler(this.GerarCsv_OnClick);
					return;
				}
				case 35:
				{
					this.SinistroGrid = (Grid)target;
					return;
				}
				case 36:
				{
					this.InicioBox2 = (DatePicker)target;
					this.InicioBox2.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					this.InicioBox2.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					this.InicioBox2.SelectedDateChanged += new EventHandler<SelectionChangedEventArgs>(this.DatePicker_OnSelectedDateChanged);
					return;
				}
				case 37:
				{
					this.FimBox2 = (DatePicker)target;
					this.FimBox2.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					this.FimBox2.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					this.FimBox2.SelectedDateChanged += new EventHandler<SelectionChangedEventArgs>(this.DatePicker_OnSelectedDateChanged);
					return;
				}
				case 38:
				{
					((Button)target).Click += new RoutedEventHandler(this.RefreshSinsitro_OnClick);
					return;
				}
				default:
				{
					this._contentLoaded = true;
					return;
				}
			}
		}

		[DebuggerNonUserCode]
		[EditorBrowsable(EditorBrowsableState.Never)]
		[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
		void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target)
		{
			if (connectionId > 33)
			{
				if (connectionId == 34)
				{
					((Button)target).Click += new RoutedEventHandler(this.EnviarPorWhatsApp_OnClick);
					return;
				}
				if (connectionId != 39)
				{
					return;
				}
				((Button)target).Click += new RoutedEventHandler(this.AbrirSinistro_OnClick);
			}
			else
			{
				switch (connectionId)
				{
					case 13:
					{
						((Button)target).Click += new RoutedEventHandler(this.ExcluirNota_OnClick);
						return;
					}
					case 14:
					{
						((Button)target).Click += new RoutedEventHandler(this.NotaConcluida_OnClick);
						return;
					}
					case 15:
					case 19:
					case 23:
					{
						return;
					}
					case 16:
					{
						((Button)target).Click += new RoutedEventHandler(this.AbrirRenovacao_OnClick);
						return;
					}
					case 17:
					{
						((PopupBox)target).add_Opened(new RoutedEventHandler(this.PopupBoxRenovacao_OnOpened));
						((PopupBox)target).add_Closed(new RoutedEventHandler(this.PopupBox_OnClosed));
						return;
					}
					case 18:
					{
						((Button)target).Click += new RoutedEventHandler(this.EnviarPorWhatsApp_OnClick);
						return;
					}
					case 20:
					{
						((Button)target).Click += new RoutedEventHandler(this.AbrirAniversariante_OnClick);
						return;
					}
					case 21:
					{
						((PopupBox)target).add_Opened(new RoutedEventHandler(this.PopupBoxAniversariante_OnOpened));
						((PopupBox)target).add_Closed(new RoutedEventHandler(this.PopupBox_OnClosed));
						return;
					}
					case 22:
					{
						((Button)target).Click += new RoutedEventHandler(this.EnviarPorWhatsApp_OnClick);
						return;
					}
					case 24:
					{
						((Button)target).Click += new RoutedEventHandler(this.AbrirTarefa_OnClick);
						return;
					}
					default:
					{
						if (connectionId == 33)
						{
							break;
						}
						else
						{
							return;
						}
					}
				}
				((PopupBox)target).add_Opened(new RoutedEventHandler(this.PopupBoxProspeccao_OnOpened));
				((PopupBox)target).add_Closed(new RoutedEventHandler(this.PopupBox_OnClosed));
				return;
			}
		}

		private async void TileAniversariantes_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.SelectedTile = 2;
			await this.Carregar();
		}

		private async void TileProspeccao_OnClick(object sender, RoutedEventArgs e)
		{
			if (!this.InicioBox.SelectedDate.HasValue)
			{
				this.InicioBox.SelectedDate = new DateTime?(DateTime.Today);
			}
			if (!this.FimBox.SelectedDate.HasValue)
			{
				DatePicker fimBox = this.FimBox;
				fimBox.SelectedDate = new DateTime?(this.InicioBox.SelectedDate.Value);
			}
			this.ViewModel.SelectedTile = 4;
			await this.Carregar();
		}

		private async void TileRenovacao_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.SelectedTile = 1;
			await this.Carregar();
		}

		private async void TileSinistro_OnClick(object sender, RoutedEventArgs e)
		{
			if (!this.InicioBox2.SelectedDate.HasValue)
			{
				this.InicioBox2.SelectedDate = new DateTime?(DateTime.Today);
			}
			if (!this.FimBox2.SelectedDate.HasValue)
			{
				this.FimBox2.SelectedDate = new DateTime?(DateTime.Today);
			}
			this.ViewModel.SelectedTile = 5;
			await this.Carregar();
		}

		private async void TileTarefas_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.SelectedTile = 3;
			await this.Carregar();
		}
	}
}