summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/Views/Seguros/ClienteView.cs
blob: 5426996404d9eed2ba35db863ae123da9905e616 (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
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
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
using CurrencyTextBoxControl;
using Gestor.Application.Componentes;
using Gestor.Application.Drawers;
using Gestor.Application.Helpers;
using Gestor.Application.Servicos;
using Gestor.Application.ViewModels.Generic;
using Gestor.Application.ViewModels.Seguros;
using Gestor.Application.Views.Generic;
using Gestor.Common.Helpers;
using Gestor.Common.Validation;
using Gestor.Model.Common;
using Gestor.Model.Domain.Common;
using Gestor.Model.Domain.Configuracoes;
using Gestor.Model.Domain.Ferramentas;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
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.Seguros
{
	public class ClienteView : BaseUserControl, IComponentConnector, IStyleConnector
	{
		public ClienteViewModel ViewModel;

		internal Grid MainGrid;

		internal MenuItem IncluirClienteButton;

		internal ComboBox TipoDocumentoPrincipalBox;

		internal TextBox DocumentoPrincipalBox;

		internal TextBox NomeBox;

		internal TextBox NomeSocialBox;

		internal TextBox CaepfBox;

		internal TextBox RneBox;

		internal TextBox CeiBox;

		internal TextBox IdentidadeBox;

		internal TextBox EmissorBox;

		internal TextBox EstadoEmissorBox;

		internal TextBox HabilitacaoBox;

		internal TextBox CategoriaHabilitacaooBox;

		internal ComboBox SexoBox;

		internal ComboBox EstadoCivilBox;

		internal AutoCompleteBox AutoCompleteProfissao;

		internal AutoCompleteBox AutoCompleteAtividade;

		internal TextBox ResponsavelBox;

		internal TextBox DocumentoResponsavel;

		internal TextBox EmailBox;

		internal TextBox PastaBox;

		internal AutoCompleteBox AutoCompleteBanco;

		internal TextBox AgenciaBox;

		internal TextBox TipoContaBox;

		internal TextBox ContaBox;

		internal CurrencyTextBox RendaMensalBox;

		internal ListBox TelefoneListBox;

		internal ListBox EmailListBox;

		internal ListBox EnderecoListBox;

		internal AutoCompleteBox VinculoBox;

		internal TextBox NomeOrigemBox;

		internal ListBox ContatosListBox;

		private bool _contentLoaded;

		private static int Ordem
		{
			get;
			set;
		}

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

		public ClienteView(Cliente cliente = null, bool lockInsert = false, ClienteViewModel viewModel = null)
		{
			base.Tag = "CADASTRO DE CLIENTES";
			this.ViewModel = viewModel ?? new ClienteViewModel(cliente, !lockInsert);
			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
			{
			}
			if (lockInsert)
			{
				this.IncluirClienteButton.IsEnabled = false;
			}
			if (cliente != null)
			{
				this.ViewModel.RegistrarAcao(string.Concat("ACESSOU CLIENTE \"", cliente.get_Nome(), "\""), cliente.get_Id(), new TipoTela?(1), string.Format("ID CLIENTE: {0}", cliente.get_Id()));
			}
		}

		private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e)
		{
			if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 1).get_Consultar())
			{
				FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital();
				filtroArquivoDigital.set_Id(this.ViewModel.SelectedCliente.get_Id());
				filtroArquivoDigital.set_Tipo(1);
				filtroArquivoDigital.set_Parente(this.ViewModel.SelectedCliente);
				this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false);
			}
			else
			{
				await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", EnumHelper.GetDescription<TipoArquivoDigital>(1), "."), "OK", "", false);
			}
		}

		private void AbrirLog_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.AbrirLog(1, this.ViewModel.SelectedCliente.get_Id());
		}

		private void AbrirLogEmail_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.AbrirLogEmail(1, this.ViewModel.SelectedCliente.get_Id());
		}

		private void Alterar_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.Alterar(true);
			this.ClearInputFields();
			this.ValidarTela();
			this.ViewModel.SelectedCliente.Initialize();
			this.InitializeResponsavelAssinatura();
			this.ViewModel.Salvando = false;
		}

		private void AutoCompleteAtividadeBox_Populating(object sender, PopulatingEventArgs e)
		{
			if (e.get_Parameter().Length < 1)
			{
				return;
			}
			e.set_Cancel(true);
			this.ViewModel.BuscarAtividade(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task<List<Atividade>> searchResult) => {
				if (searchResult.Result == null)
				{
					return;
				}
				AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender;
				autoCompleteBox.set_ItemsSource(searchResult.Result);
				autoCompleteBox.PopulateComplete();
			}, TaskScheduler.FromCurrentSynchronizationContext());
		}

		private void AutoCompleteBanco_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
		{
			AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender;
			ClienteView.SetValid(autoCompleteBox, (string.IsNullOrWhiteSpace(autoCompleteBox.get_Text()) ? true : this.ViewModel.SelectedCliente.get_Banco() != null));
		}

		private void AutoCompleteBancoBox_Populating(object sender, PopulatingEventArgs e)
		{
			if (e.get_Parameter().Length < 3)
			{
				return;
			}
			e.set_Cancel(true);
			this.ViewModel.BuscarBanco(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task<List<Banco>> searchResult) => {
				if (searchResult.Result == null)
				{
					return;
				}
				AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender;
				autoCompleteBox.set_ItemsSource(searchResult.Result);
				autoCompleteBox.PopulateComplete();
			}, TaskScheduler.FromCurrentSynchronizationContext());
		}

		private void AutoCompleteParentescoBox_Populating(object sender, PopulatingEventArgs e)
		{
			if (e.get_Parameter().Length < 3)
			{
				return;
			}
			e.set_Cancel(true);
			this.ViewModel.BuscarClienteVinculo(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim()), this.ViewModel.SelectedCliente.get_Id()).ContinueWith((Task<List<Cliente>> searchResult) => {
				if (searchResult.Result == null)
				{
					return;
				}
				AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender;
				autoCompleteBox.set_ItemsSource(searchResult.Result);
				autoCompleteBox.PopulateComplete();
			}, TaskScheduler.FromCurrentSynchronizationContext());
		}

		private void AutoCompleteProfissaoBox_Populating(object sender, PopulatingEventArgs e)
		{
			if (e.get_Parameter().Length < 1)
			{
				return;
			}
			e.set_Cancel(true);
			this.ViewModel.BuscarProfissao(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task<List<Profissao>> searchResult) => {
				if (searchResult.Result == null)
				{
					return;
				}
				AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender;
				autoCompleteBox.set_ItemsSource(searchResult.Result);
				autoCompleteBox.PopulateComplete();
			}, TaskScheduler.FromCurrentSynchronizationContext());
		}

		private void Cancelar_OnClick(object sender, RoutedEventArgs e)
		{
			this.ClearInputFields();
			ClienteView.SetValid(this.AutoCompleteBanco, true);
			this.ViewModel.CancelarAlteracao();
		}

		private void ClearInputFields()
		{
			object nome;
			object empty;
			object obj;
			object nome1;
			AutoCompleteBox autoCompleteBanco = this.AutoCompleteBanco;
			Banco banco = this.ViewModel.SelectedCliente.get_Banco();
			if (banco != null)
			{
				nome = banco.get_Nome();
			}
			else
			{
				nome = null;
			}
			if (nome == null)
			{
				nome = string.Empty;
			}
			autoCompleteBanco.set_Text((string)nome);
			AutoCompleteBox autoCompleteProfissao = this.AutoCompleteProfissao;
			Profissao profissao = this.ViewModel.SelectedCliente.get_Profissao();
			if (profissao != null)
			{
				empty = profissao.get_Nome();
			}
			else
			{
				empty = null;
			}
			if (empty == null)
			{
				empty = string.Empty;
			}
			autoCompleteProfissao.set_Text((string)empty);
			AutoCompleteBox autoCompleteBox = this.AutoCompleteProfissao;
			Profissao profissao1 = this.ViewModel.SelectedCliente.get_Profissao();
			if (profissao1 != null)
			{
				obj = profissao1.get_Nome();
			}
			else
			{
				obj = null;
			}
			if (obj == null)
			{
				obj = string.Empty;
			}
			autoCompleteBox.set_Text((string)obj);
			AutoCompleteBox autoCompleteAtividade = this.AutoCompleteAtividade;
			Atividade atividade = this.ViewModel.SelectedCliente.get_Atividade();
			if (atividade != null)
			{
				nome1 = atividade.get_Nome();
			}
			else
			{
				nome1 = null;
			}
			if (nome1 == null)
			{
				nome1 = string.Empty;
			}
			autoCompleteAtividade.set_Text((string)nome1);
		}

		private void ContentLoad()
		{
			string nome;
			string str;
			string nome1;
			this.TelefoneListBox.DataContext = this.ViewModel;
			this.EmailListBox.DataContext = this.ViewModel;
			this.EnderecoListBox.DataContext = this.ViewModel;
			this.ContatosListBox.DataContext = this.ViewModel;
			this.DocumentoResponsavel.LostFocus += new RoutedEventHandler(this.Validar_LostFocus);
			if (this.ViewModel.SelectedCliente == null)
			{
				return;
			}
			AutoCompleteBox autoCompleteBanco = this.AutoCompleteBanco;
			Banco banco = this.ViewModel.SelectedCliente.get_Banco();
			if (banco != null)
			{
				nome = banco.get_Nome();
			}
			else
			{
				nome = null;
			}
			autoCompleteBanco.set_Text(nome);
			AutoCompleteBox autoCompleteAtividade = this.AutoCompleteAtividade;
			Atividade atividade = this.ViewModel.SelectedCliente.get_Atividade();
			if (atividade != null)
			{
				str = atividade.get_Nome();
			}
			else
			{
				str = null;
			}
			autoCompleteAtividade.set_Text(str);
			AutoCompleteBox autoCompleteProfissao = this.AutoCompleteProfissao;
			Profissao profissao = this.ViewModel.SelectedCliente.get_Profissao();
			if (profissao != null)
			{
				nome1 = profissao.get_Nome();
			}
			else
			{
				nome1 = null;
			}
			autoCompleteProfissao.set_Text(nome1);
		}

		private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e)
		{
			if (((TextBox)sender).IsReadOnly)
			{
				return;
			}
			TextBox textBox = (TextBox)sender;
			string str = ValidationHelper.Clear(textBox.Text);
			if (string.IsNullOrEmpty(str))
			{
				return;
			}
			textBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14)));
			if (textBox.Name == "DocumentoPrincipalBox")
			{
				this.ViewModel.JuridicaouFisica(this.DocumentoPrincipalBox.Text);
				if (this.ViewModel.VisibilityFisica == System.Windows.Visibility.Visible)
				{
					this.ResponsavelBox.Text = string.Empty;
					this.DocumentoResponsavel.Text = string.Empty;
					this.EmailBox.Text = string.Empty;
				}
			}
		}

		private void Excluir_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.Excluir();
		}

		private void ExcluirEmail_OnClick(object sender, RoutedEventArgs e)
		{
			Button button = sender as Button;
			if (button == null)
			{
				return;
			}
			ListBox listBox = Extentions.FindVisualAncestor<ListBox>(button);
			ClienteEmail item = (ClienteEmail)listBox.Items[listBox.Items.IndexOf(button.DataContext)];
			this.ViewModel.ExcluirEmail(item);
		}

		private void ExcluirEndereco_OnClick(object sender, RoutedEventArgs e)
		{
			Grid grid = Extentions.FindVisualAncestor<Grid>((Button)sender);
			ListBox listBox = Extentions.FindVisualAncestor<ListBox>(grid);
			ClienteEndereco item = (ClienteEndereco)listBox.Items[listBox.Items.IndexOf(grid.DataContext)];
			this.ViewModel.ExcluirEndereco(item);
		}

		private void ExcluirMaisContatos_OnClick(object sender, RoutedEventArgs e)
		{
			Button button = (Button)sender;
			if (button == null || button.DataContext == null)
			{
				return;
			}
			MaisContato dataContext = (MaisContato)button.DataContext;
			this.ViewModel.ExcluirContato(dataContext);
		}

		private async void ExcluirOrigem_OnClick(object sender, RoutedEventArgs e)
		{
			Button button = (Button)sender;
			if (button.DataContext != null)
			{
				this.ViewModel.Loading(true);
				await this.ViewModel.ExcluirOrigem((OrigemCliente)button.DataContext);
				this.ViewModel.Loading(false);
			}
		}

		private void ExcluirTelefone_OnClick(object sender, RoutedEventArgs e)
		{
			Button button = sender as Button;
			if (button == null)
			{
				return;
			}
			ListBox listBox = Extentions.FindVisualAncestor<ListBox>(button);
			ClienteTelefone item = (ClienteTelefone)listBox.Items[listBox.Items.IndexOf(button.DataContext)];
			this.ViewModel.ExcluirTelefone(item);
		}

		private void ExcluirVinculo_OnClick(object sender, RoutedEventArgs e)
		{
			Button button = (Button)sender;
			if (button == null || button.DataContext == null)
			{
				return;
			}
			ClienteVinculo dataContext = (ClienteVinculo)button.DataContext;
			this.ViewModel.ExcluirVinculo(dataContext);
		}

		public override void FormatarDocumento(object sender, RoutedEventArgs e)
		{
			TextBox textBox = (TextBox)sender;
			textBox.Text = ValidationHelper.FormatDocument(textBox.Text);
			this.ViewModel.JuridicaouFisica(textBox.Text);
		}

		private void Incluir_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.IncluirCliente();
			this.DocumentoPrincipalBox.Text = "";
			this.AutoCompleteBanco.set_Text("");
			this.AutoCompleteProfissao.set_Text("");
			this.AutoCompleteAtividade.set_Text("");
			this.DocumentoPrincipalBox.Focus();
			this.ValidarTela();
		}

		private void IncluirEmail_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.IncluirEmail();
			this.ValidarTela();
		}

		private void IncluirEndereco_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.IncluirEndereco();
			this.ValidarTela();
		}

		private void IncluirMaisContatos_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.IncluirContato();
		}

		private async void IncluirOrigem_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.Loading(true);
			await this.ViewModel.IncluirOrigem(this.NomeOrigemBox.Text.Trim());
			this.NomeOrigemBox.Text = string.Empty;
			this.ViewModel.Loading(false);
		}

		private void IncluirTelefone_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.IncluirTelefone();
		}

		private void IncluirVinculo_OnClick(object sender, RoutedEventArgs e)
		{
			if (this.ViewModel.IncluirVinculo())
			{
				this.VinculoBox.set_Text("");
			}
		}

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

		private void InitializeResponsavelAssinatura()
		{
			object nomeResponsavel;
			object documentoResponsavel;
			object emailResponsavel;
			TextBox responsavelBox = this.ResponsavelBox;
			ResponsavelAssinatura responsavelAssinatura = this.ViewModel.SelectedCliente.get_ResponsavelAssinatura();
			if (responsavelAssinatura != null)
			{
				nomeResponsavel = responsavelAssinatura.get_NomeResponsavel();
			}
			else
			{
				nomeResponsavel = null;
			}
			if (nomeResponsavel == null)
			{
				nomeResponsavel = string.Empty;
			}
			responsavelBox.Text = (string)nomeResponsavel;
			TextBox textBox = this.DocumentoResponsavel;
			ResponsavelAssinatura responsavelAssinatura1 = this.ViewModel.SelectedCliente.get_ResponsavelAssinatura();
			if (responsavelAssinatura1 != null)
			{
				documentoResponsavel = responsavelAssinatura1.get_DocumentoResponsavel();
			}
			else
			{
				documentoResponsavel = null;
			}
			if (documentoResponsavel == null)
			{
				documentoResponsavel = string.Empty;
			}
			textBox.Text = (string)documentoResponsavel;
			TextBox emailBox = this.EmailBox;
			ResponsavelAssinatura responsavelAssinatura2 = this.ViewModel.SelectedCliente.get_ResponsavelAssinatura();
			if (responsavelAssinatura2 != null)
			{
				emailResponsavel = responsavelAssinatura2.get_EmailResponsavel();
			}
			else
			{
				emailResponsavel = null;
			}
			if (emailResponsavel == null)
			{
				emailResponsavel = string.Empty;
			}
			emailBox.Text = (string)emailResponsavel;
		}

		private void MenuItem_Click(object sender, RoutedEventArgs e)
		{
			this.ViewModel.AbrirLogAntigo();
		}

		private void OrdemBox_OnLostFocus(object sender, RoutedEventArgs e)
		{
			int num;
			int num1;
			TextBox textBox = sender as TextBox;
			if (textBox == null)
			{
				return;
			}
			if (textBox.IsReadOnly)
			{
				return;
			}
			if (!int.TryParse(textBox.Text, out num))
			{
				return;
			}
			WrapPanel wrapPanel = Extentions.FindVisualAncestor<WrapPanel>(Extentions.FindVisualAncestor<CustomItemValidation>(textBox));
			ListBox listBox = Extentions.FindVisualAncestor<ListBox>(wrapPanel);
			if (listBox != null)
			{
				for (int i = 0; i < listBox.Items.Count; i++)
				{
					if (i != listBox.Items.IndexOf(wrapPanel.DataContext))
					{
						ContentPresenter contentPresenter = FindVisualChild.Find<ContentPresenter>((ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(i));
						TextBox str = (TextBox)contentPresenter.ContentTemplate.FindName("OrdemBox", contentPresenter);
						if (int.TryParse(str.Text, out num1) && num1 == num)
						{
							str.Text = ClienteView.Ordem.ToString();
						}
					}
				}
			}
		}

		private void OrdemBox_OnPreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
		{
			int num;
			TextBox textBox = sender as TextBox;
			if (textBox == null)
			{
				return;
			}
			if (!int.TryParse(textBox.Text, out num))
			{
				return;
			}
			ClienteView.Ordem = num;
		}

		private async void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e)
		{
			ContentPresenter contentPresenter;
			DataTemplate contentTemplate;
			ProgressBar progressBar;
			TextBox textBox = (TextBox)sender;
			if (!textBox.IsReadOnly)
			{
				if (!string.IsNullOrWhiteSpace(textBox.Text))
				{
					string str = ValidationHelper.FormatPostCode(textBox.Text);
					WrapPanel wrapPanel = Extentions.FindVisualAncestor<WrapPanel>(textBox);
					ListBox listBox = Extentions.FindVisualAncestor<ListBox>(wrapPanel);
					ListBoxItem listBoxItem = (ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(listBox.Items.IndexOf(wrapPanel.DataContext));
					contentPresenter = FindVisualChild.Find<ContentPresenter>(listBoxItem);
					contentTemplate = contentPresenter.ContentTemplate;
					TextBox textBox1 = (TextBox)contentTemplate.FindName("CepBox", contentPresenter);
					progressBar = (ProgressBar)contentTemplate.FindName("ProgressCep", contentPresenter);
					progressBar.Visibility = System.Windows.Visibility.Visible;
					textBox1.Text = str;
					if (ValidationHelper.ValidatePostCode(str))
					{
						EnderecoBase enderecoBase = await this.ViewModel.BuscaCep(str);
						if (enderecoBase != null)
						{
							TextBox endereco = (TextBox)contentTemplate.FindName("EnderecoBox", contentPresenter);
							TextBox cidade = (TextBox)contentTemplate.FindName("CidadeBox", contentPresenter);
							TextBox estado = (TextBox)contentTemplate.FindName("EstadoBox", contentPresenter);
							TextBox bairro = (TextBox)contentTemplate.FindName("BairroBox", contentPresenter);
							endereco.Text = enderecoBase.get_Endereco();
							cidade.Text = enderecoBase.get_Cidade();
							estado.Text = enderecoBase.get_Estado();
							bairro.Text = enderecoBase.get_Bairro();
							progressBar.Visibility = System.Windows.Visibility.Collapsed;
						}
						else
						{
							progressBar.Visibility = System.Windows.Visibility.Collapsed;
						}
					}
					else
					{
						progressBar.Visibility = System.Windows.Visibility.Collapsed;
					}
				}
			}
			contentPresenter = null;
			contentTemplate = null;
			progressBar = null;
		}

		private async void Salvar_OnClick(object sender, RoutedEventArgs e)
		{
			bool flag;
			this.ViewModel.Loading(true);
			this.ViewModel.ProfissaoText = this.AutoCompleteProfissao.get_Text();
			this.ViewModel.AtividadeText = this.AutoCompleteAtividade.get_Text();
			List<KeyValuePair<string, string>> keyValuePairs = await this.ViewModel.Salvar();
			this.ValidateFields(keyValuePairs, true);
			flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0);
			this.ViewModel.Loading(false);
			if (!flag)
			{
				await this.ViewModel.ShowMessage(keyValuePairs.Distinct<KeyValuePair<string, string>>().ToList<KeyValuePair<string, string>>(), this.ViewModel.ErroCamposInvalidos, "OK", "");
			}
			else
			{
				ClienteView.SetValid(this.AutoCompleteBanco, true);
			}
		}

		private static void SetValid(AutoCompleteBox autocomplete, bool valid)
		{
			ViewHelper.SetInvalid(autocomplete, "BANCO INVÁLIDO", valid);
		}

		[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.MainGrid = (Grid)target;
					return;
				}
				case 2:
				{
					this.IncluirClienteButton = (MenuItem)target;
					this.IncluirClienteButton.Click += new RoutedEventHandler(this.Incluir_OnClick);
					return;
				}
				case 3:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick);
					return;
				}
				case 4:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick);
					return;
				}
				case 5:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick);
					return;
				}
				case 6:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.Excluir_OnClick);
					return;
				}
				case 7:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click);
					return;
				}
				case 8:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.Tarefa_Click);
					return;
				}
				case 9:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick);
					return;
				}
				case 10:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick);
					return;
				}
				case 11:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.MenuItem_Click);
					return;
				}
				case 12:
				{
					this.TipoDocumentoPrincipalBox = (ComboBox)target;
					return;
				}
				case 13:
				{
					this.DocumentoPrincipalBox = (TextBox)target;
					ClienteView clienteView = this;
					this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(clienteView.SomenteNumeros);
					this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus);
					return;
				}
				case 14:
				{
					this.NomeBox = (TextBox)target;
					return;
				}
				case 15:
				{
					this.NomeSocialBox = (TextBox)target;
					return;
				}
				case 16:
				{
					((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
					((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					((DatePicker)target).PreviewTextInput += new TextCompositionEventHandler(this.SomenteData);
					return;
				}
				case 17:
				{
					this.CaepfBox = (TextBox)target;
					return;
				}
				case 18:
				{
					this.RneBox = (TextBox)target;
					return;
				}
				case 19:
				{
					this.CeiBox = (TextBox)target;
					return;
				}
				case 20:
				{
					this.IdentidadeBox = (TextBox)target;
					return;
				}
				case 21:
				{
					this.EmissorBox = (TextBox)target;
					this.EmissorBox.PreviewTextInput += new TextCompositionEventHandler(this.SomenteCaracteres);
					return;
				}
				case 22:
				{
					this.EstadoEmissorBox = (TextBox)target;
					this.EstadoEmissorBox.PreviewTextInput += new TextCompositionEventHandler(this.SomenteCaracteres);
					return;
				}
				case 23:
				{
					((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
					((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					((DatePicker)target).PreviewTextInput += new TextCompositionEventHandler(this.SomenteData);
					return;
				}
				case 24:
				{
					this.HabilitacaoBox = (TextBox)target;
					ClienteView clienteView1 = this;
					this.HabilitacaoBox.PreviewTextInput += new TextCompositionEventHandler(clienteView1.SomenteNumeros);
					return;
				}
				case 25:
				{
					this.CategoriaHabilitacaooBox = (TextBox)target;
					ClienteView clienteView2 = this;
					this.CategoriaHabilitacaooBox.PreviewTextInput += new TextCompositionEventHandler(clienteView2.LetrasHabilitacao);
					return;
				}
				case 26:
				{
					((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
					return;
				}
				case 27:
				{
					((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
					return;
				}
				case 28:
				{
					this.SexoBox = (ComboBox)target;
					return;
				}
				case 29:
				{
					this.EstadoCivilBox = (ComboBox)target;
					return;
				}
				case 30:
				{
					this.AutoCompleteProfissao = (AutoCompleteBox)target;
					this.AutoCompleteProfissao.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteProfissaoBox_Populating));
					return;
				}
				case 31:
				{
					this.AutoCompleteAtividade = (AutoCompleteBox)target;
					this.AutoCompleteAtividade.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteAtividadeBox_Populating));
					return;
				}
				case 32:
				{
					this.ResponsavelBox = (TextBox)target;
					this.ResponsavelBox.LostFocus += new RoutedEventHandler(this.Validar_LostFocus);
					return;
				}
				case 33:
				{
					this.DocumentoResponsavel = (TextBox)target;
					ClienteView clienteView3 = this;
					this.DocumentoResponsavel.PreviewTextInput += new TextCompositionEventHandler(clienteView3.SomenteNumeros);
					this.DocumentoResponsavel.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus);
					return;
				}
				case 34:
				{
					this.EmailBox = (TextBox)target;
					this.EmailBox.LostFocus += new RoutedEventHandler(this.Validar_LostFocus);
					return;
				}
				case 35:
				{
					((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
					return;
				}
				case 36:
				{
					this.PastaBox = (TextBox)target;
					return;
				}
				case 37:
				{
					this.AutoCompleteBanco = (AutoCompleteBox)target;
					this.AutoCompleteBanco.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteBancoBox_Populating));
					this.AutoCompleteBanco.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.AutoCompleteBanco_OnLostKeyboardFocus);
					return;
				}
				case 38:
				{
					this.AgenciaBox = (TextBox)target;
					return;
				}
				case 39:
				{
					this.TipoContaBox = (TextBox)target;
					return;
				}
				case 40:
				{
					this.ContaBox = (TextBox)target;
					return;
				}
				case 41:
				{
					this.RendaMensalBox = (CurrencyTextBox)target;
					return;
				}
				case 42:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTelefone_OnClick);
					return;
				}
				case 43:
				{
					this.TelefoneListBox = (ListBox)target;
					return;
				}
				case 44:
				case 45:
				case 46:
				case 47:
				case 48:
				case 51:
				case 52:
				case 55:
				case 56:
				case 57:
				case 60:
				case 63:
				{
					this._contentLoaded = true;
					return;
				}
				case 49:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.IncluirEmail_OnClick);
					return;
				}
				case 50:
				{
					this.EmailListBox = (ListBox)target;
					return;
				}
				case 53:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.IncluirEndereco_OnClick);
					return;
				}
				case 54:
				{
					this.EnderecoListBox = (ListBox)target;
					return;
				}
				case 58:
				{
					this.VinculoBox = (AutoCompleteBox)target;
					this.VinculoBox.add_Populating(new PopulatingEventHandler(this, ClienteView.AutoCompleteParentescoBox_Populating));
					return;
				}
				case 59:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.IncluirVinculo_OnClick);
					return;
				}
				case 61:
				{
					this.NomeOrigemBox = (TextBox)target;
					return;
				}
				case 62:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.IncluirOrigem_OnClick);
					return;
				}
				case 64:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.IncluirMaisContatos_OnClick);
					return;
				}
				case 65:
				{
					this.ContatosListBox = (ListBox)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)
		{
			switch (connectionId)
			{
				case 44:
				{
					((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBox_OnSelectionChanged);
					return;
				}
				case 45:
				{
					ClienteView clienteView = this;
					((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView.SomenteNumeros);
					return;
				}
				case 46:
				{
					ClienteView clienteView1 = this;
					((TextBox)target).LostFocus += new RoutedEventHandler(clienteView1.FormatarTelefone);
					ClienteView clienteView2 = this;
					((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView2.SomenteNumeros);
					return;
				}
				case 47:
				{
					((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus);
					((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus);
					ClienteView clienteView3 = this;
					((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView3.SomenteNumeros);
					return;
				}
				case 48:
				{
					((Button)target).Click += new RoutedEventHandler(this.ExcluirTelefone_OnClick);
					return;
				}
				case 49:
				case 50:
				case 53:
				case 54:
				case 58:
				case 59:
				case 61:
				case 62:
				case 64:
				case 65:
				{
					return;
				}
				case 51:
				{
					((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus);
					((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus);
					ClienteView clienteView4 = this;
					((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView4.SomenteNumeros);
					return;
				}
				case 52:
				{
					((Button)target).Click += new RoutedEventHandler(this.ExcluirEmail_OnClick);
					return;
				}
				case 55:
				{
					((TextBox)target).LostFocus += new RoutedEventHandler(this.PostcodeBox_OnLostFocus);
					ClienteView clienteView5 = this;
					((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView5.SomenteNumeros);
					return;
				}
				case 56:
				{
					((TextBox)target).PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler(this.OrdemBox_OnPreviewGotKeyboardFocus);
					((TextBox)target).LostFocus += new RoutedEventHandler(this.OrdemBox_OnLostFocus);
					ClienteView clienteView6 = this;
					((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView6.SomenteNumeros);
					return;
				}
				case 57:
				{
					((Button)target).Click += new RoutedEventHandler(this.ExcluirEndereco_OnClick);
					return;
				}
				case 60:
				{
					((Button)target).Click += new RoutedEventHandler(this.ExcluirVinculo_OnClick);
					return;
				}
				case 63:
				{
					((Button)target).Click += new RoutedEventHandler(this.ExcluirOrigem_OnClick);
					return;
				}
				case 66:
				{
					ClienteView clienteView7 = this;
					((TextBox)target).LostFocus += new RoutedEventHandler(clienteView7.FormatarDocumento);
					return;
				}
				case 67:
				{
					((DatePicker)target).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus);
					((DatePicker)target).PreviewKeyDown += new KeyEventHandler(this.DatePicker_PreviewKeyDown);
					((DatePicker)target).MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick);
					((DatePicker)target).PreviewTextInput += new TextCompositionEventHandler(this.SomenteData);
					return;
				}
				case 68:
				{
					((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoComboBox_OnSelectionChanged);
					return;
				}
				case 69:
				{
					ClienteView clienteView8 = this;
					((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView8.SomenteNumeros);
					return;
				}
				case 70:
				{
					ClienteView clienteView9 = this;
					((TextBox)target).LostFocus += new RoutedEventHandler(clienteView9.FormatarTelefone);
					ClienteView clienteView10 = this;
					((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(clienteView10.SomenteNumeros);
					return;
				}
				case 71:
				{
					((Button)target).Click += new RoutedEventHandler(this.ExcluirMaisContatos_OnClick);
					return;
				}
				default:
				{
					return;
				}
			}
		}

		private void Tarefa_Click(object sender, RoutedEventArgs e)
		{
			Tarefa tarefa = new Tarefa();
			tarefa.set_IdCliente(this.ViewModel.SelectedCliente.get_Id());
			tarefa.set_Cliente(this.ViewModel.SelectedCliente.get_Nome());
			tarefa.set_Entidade(2);
			tarefa.set_IdEntidade(this.ViewModel.SelectedCliente.get_Id());
			tarefa.set_Titulo(this.ViewModel.SelectedCliente.get_Nome());
			this.ViewModel.ShowDrawer(new TarefaDrawer(tarefa, true), 0, false);
		}

		private void TipoComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			int num;
			ComboBox comboBox = (ComboBox)sender;
			CustomIsReadOnlyControl customIsReadOnlyControl = Extentions.FindVisualAncestor<CustomIsReadOnlyControl>(comboBox);
			if (customIsReadOnlyControl == null)
			{
				return;
			}
			WrapPanel wrapPanel = Extentions.FindVisualAncestor<WrapPanel>(customIsReadOnlyControl);
			ListBox listBox = Extentions.FindVisualAncestor<ListBox>(wrapPanel);
			ContentPresenter contentPresenter = FindVisualChild.Find<ContentPresenter>((ListBoxItem)listBox.ItemContainerGenerator.ContainerFromIndex(listBox.Items.IndexOf(wrapPanel.DataContext)));
			DataTemplate contentTemplate = contentPresenter.ContentTemplate;
			CustomItemValidation customItemValidation = (CustomItemValidation)contentTemplate.FindName("Prefixo", contentPresenter);
			CustomItemValidation customItemValidation1 = (CustomItemValidation)contentTemplate.FindName("Telefone", contentPresenter);
			TextBox textBox = ViewHelper.FindChildren<TextBox>(customItemValidation).FirstOrDefault<TextBox>();
			TextBox textBox1 = ViewHelper.FindChildren<TextBox>(customItemValidation1).FirstOrDefault<TextBox>();
			if (textBox == null || textBox1 == null)
			{
				return;
			}
			if ((TipoTelefone)comboBox.SelectedValue == 8)
			{
				customItemValidation.Visibility = System.Windows.Visibility.Collapsed;
				textBox1.MaxLength = 20;
				return;
			}
			customItemValidation.Visibility = System.Windows.Visibility.Visible;
			textBox1.MaxLength = 10;
			num = (textBox1.Text.Length >= 10 ? 10 : textBox1.Text.Length);
			textBox1.Text = textBox1.Text.Substring(0, num);
		}

		private void Validar_LostFocus(object sender, RoutedEventArgs e)
		{
			this.ValidarTela();
		}

		private void ValidarTela()
		{
			object keyValuePairs;
			object obj;
			object keyValuePairs1;
			if (this.ViewModel.SelectedCliente == null)
			{
				return;
			}
			List<KeyValuePair<string, string>> keyValuePairs2 = this.ViewModel.SelectedCliente.Validate();
			if (Recursos.Configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 29))
			{
				List<KeyValuePair<string, string>> keyValuePairs3 = keyValuePairs2;
				ClienteEmail clienteEmail = this.ViewModel.Emails.FirstOrDefault<ClienteEmail>();
				if (clienteEmail != null)
				{
					keyValuePairs1 = clienteEmail.Validate();
				}
				else
				{
					keyValuePairs1 = null;
				}
				if (keyValuePairs1 == null)
				{
					keyValuePairs1 = new List<KeyValuePair<string, string>>();
				}
				keyValuePairs3.AddRange((IEnumerable<!0>)keyValuePairs1);
			}
			List<KeyValuePair<string, string>> keyValuePairs4 = keyValuePairs2;
			ClienteTelefone clienteTelefone = this.ViewModel.Telefones.FirstOrDefault<ClienteTelefone>();
			if (clienteTelefone != null)
			{
				keyValuePairs = clienteTelefone.Validate();
			}
			else
			{
				keyValuePairs = null;
			}
			if (keyValuePairs == null)
			{
				keyValuePairs = new List<KeyValuePair<string, string>>();
			}
			keyValuePairs4.AddRange((IEnumerable<!0>)keyValuePairs);
			List<KeyValuePair<string, string>> keyValuePairs5 = keyValuePairs2;
			ClienteEndereco clienteEndereco = this.ViewModel.Enderecos.FirstOrDefault<ClienteEndereco>();
			if (clienteEndereco != null)
			{
				obj = clienteEndereco.Validate();
			}
			else
			{
				obj = null;
			}
			if (obj == null)
			{
				obj = new List<KeyValuePair<string, string>>();
			}
			keyValuePairs5.AddRange((IEnumerable<!0>)obj);
			this.ValidateFields(keyValuePairs2, false);
		}
	}
}