summaryrefslogtreecommitdiff
path: root/Gestor.Application/Views/Ferramentas/VendedorView.cs
blob: 1c2d4b4e1d8d465ee0f41a88c1784a12a1e12bfe (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
using CurrencyTextBoxControl;
using Gestor.Application.Drawers;
using Gestor.Application.Helpers;
using Gestor.Application.Servicos;
using Gestor.Application.Servicos.Ferramentas;
using Gestor.Application.ViewModels.Ferramentas;
using Gestor.Application.ViewModels.Generic;
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.Generic;
using Gestor.Model.Domain.Seguros;
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 Xceed.Wpf.AvalonDock.Controls;

namespace Gestor.Application.Views.Ferramentas
{
	public class VendedorView : BaseUserControl, IComponentConnector, IStyleConnector
	{
		public VendedorViewModel ViewModel;

		internal DataGrid VendedorGrid;

		internal MenuItem IncluirButton;

		internal MenuItem AlterarButton;

		internal MenuItem SalvarButton;

		internal MenuItem CancelarButton;

		internal MenuItem MaisOpcoesButton;

		internal TextBox EmpresaBox;

		internal TextBox IdBox;

		internal TextBox NomeBox;

		internal TextBox DocumentoPrincipalBox;

		internal AutoCompleteBox AutoCompleteBanco;

		internal TextBox AgenciaBox;

		internal ComboBox TipoBox;

		internal TextBox ContaBox;

		internal TextBox TitularBox;

		internal TextBox TitularDocBox;

		internal ComboBox TipoIncidenciaDescontoBox;

		internal ToggleButton AtivoBox;

		internal Grid GridContatos;

		private bool _contentLoaded;

		public bool UpdatingScroll
		{
			get;
			set;
		}

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

		public VendedorView()
		{
			base.Tag = "CADASTRO DE VENDEDOR";
			this.ViewModel = new VendedorViewModel();
			base.DataContext = this.ViewModel;
			this.InitializeComponent();
		}

		private async void AbrirAquivoDigital_Click(object sender, RoutedEventArgs e)
		{
			if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 6).get_Consultar())
			{
				FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital();
				filtroArquivoDigital.set_Id(this.ViewModel.SelectedVendedor.get_Id());
				filtroArquivoDigital.set_Tipo(6);
				filtroArquivoDigital.set_Parente(this.ViewModel.SelectedVendedor);
				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>(6), "."), "OK", "", false);
			}
		}

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

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

		private void AbrirLogRepasse_OnClick(object sender, RoutedEventArgs e)
		{
			Button button = (Button)sender;
			if (button == null || button.DataContext == null)
			{
				return;
			}
			Repasse dataContext = (Repasse)button.DataContext;
			this.ViewModel.AbrirLog(54, dataContext.get_Id());
		}

		private async void Adiantamento_Click(object sender, RoutedEventArgs e)
		{
			if (this.ViewModel.SelectedVendedor == null || !this.ViewModel.SelectedVendedor.get_Corretora())
			{
				this.ViewModel.ShowDrawer(new AdiantamentoDrawerView(this.ViewModel.SelectedVendedor), 0, false);
			}
			else
			{
				await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ADICIONAR ADIANTAMENTOS PARA O VENDEDOR PRÓPRIA CORRETORA.", "OK", "", false);
			}
		}

		private async void Alterar_OnClick(object sender, RoutedEventArgs e)
		{
			bool corretora;
			object obj;
			Vendedor selectedVendedor = this.ViewModel.SelectedVendedor;
			if (selectedVendedor != null)
			{
				corretora = selectedVendedor.get_Corretora();
			}
			else
			{
				corretora = false;
			}
			bool flag = corretora;
			if (flag)
			{
				if (Recursos.Usuario.get_Id() == 0)
				{
					this.AlterarPropriaCorretora(true);
				}
				else
				{
					await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ALTERAR O VENDEDOR PRÓPRIA CORRETORA.", "OK", "", false);
					return;
				}
			}
			this.ViewModel.IsExpanded = false;
			VendedorViewModel viewModel = this.ViewModel;
			Vendedor vendedor = this.ViewModel.SelectedVendedor;
			if (vendedor != null)
			{
				obj = vendedor.Clone();
			}
			else
			{
				obj = null;
			}
			viewModel.CancelVendedor = (Vendedor)obj;
			if (!flag)
			{
				this.ViewModel.Alterar(true);
			}
			this.ValidarTela();
		}

		public void AlterarPropriaCorretora(bool habilitar = false)
		{
			if (habilitar)
			{
				this.NomeBox.IsReadOnly = false;
				this.DocumentoPrincipalBox.IsReadOnly = false;
				this.AlterarButton.IsEnabled = false;
				this.SalvarButton.IsEnabled = true;
				this.CancelarButton.IsEnabled = true;
				this.IncluirButton.IsEnabled = false;
				return;
			}
			this.NomeBox.IsReadOnly = true;
			this.DocumentoPrincipalBox.IsReadOnly = true;
			this.AlterarButton.IsEnabled = true;
			this.SalvarButton.IsEnabled = false;
			this.CancelarButton.IsEnabled = false;
			this.IncluirButton.IsEnabled = false;
		}

		private async void AtivarInativarRepasse_OnClick(object sender, RoutedEventArgs e)
		{
			if (!this.ViewModel.SelectedVendedor.get_Corretora())
			{
				Repasse dataContext = (Repasse)((Button)sender).DataContext;
				if (dataContext != null)
				{
					this.ViewModel.Loading(true);
					await this.ViewModel.AtivarInativarRepasse(dataContext);
					this.ScrollVendedor();
					this.ViewModel.Loading(false);
				}
			}
			else
			{
				await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ALTERAR O VENDEDOR PRÓPRIA CORRETORA.", "OK", "", false);
			}
		}

		private async void AtivarInativarVendedor_OnClick(object sender, RoutedEventArgs e)
		{
			if (this.ViewModel.SelectedVendedor != null)
			{
				if (this.ViewModel.SelectedVendedor.get_Corretora())
				{
					await this.ViewModel.ShowMessage("NÃO É POSSÍVEL ALTERAR O VENDEDOR PRÓPRIA CORRETORA.", "OK", "", false);
				}
				else if (!await this.BuscaVinculo(this.ViewModel.SelectedVendedor))
				{
					this.ViewModel.Loading(true);
					await this.ViewModel.AtivarInativarVendedor(this.ViewModel.SelectedVendedor);
					this.ScrollVendedor();
					this.ViewModel.Loading(false);
				}
			}
		}

		private void AutoCompleteBanco_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
		{
			AutoCompleteBox autoCompleteBox = (AutoCompleteBox)sender;
			VendedorView.SetValid(autoCompleteBox, (string.IsNullOrWhiteSpace(autoCompleteBox.get_Text()) ? true : this.ViewModel.SelectedVendedor.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 AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e)
		{
			if (!string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).get_Text()))
			{
				return;
			}
			this.ViewModel.FiltrarVendedor("");
		}

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

		private async Task<bool> BuscaVinculo(Vendedor vendedor)
		{
			bool flag;
			if (await (new VendedorUsuarioServico()).FindVinculo(vendedor))
			{
				await this.ViewModel.ShowMessage("NÃO É POSSÍVEL INATIVAR VENDEDOR QUE POSSUI VINCULO DE USUÁRIO.", "OK", "", false);
				this.ViewModel.Loading(false);
				flag = true;
			}
			else
			{
				flag = false;
			}
			return flag;
		}

		public async void Button_Click(object sender, RoutedEventArgs e)
		{
			if (this.ViewModel.SelectedVendedor == null || !this.ViewModel.SelectedVendedor.get_Corretora())
			{
				this.ViewModel.Loading(true);
				if (await this.ViewModel.VerificarPermissao(30, false))
				{
					this.ViewModel.ShowDrawer(new MetaVendedorView(this.ViewModel.SelectedVendedor), 0, false);
					this.ViewModel.Loading(false);
				}
			}
			else
			{
				await this.ViewModel.ShowMessage("NÃO É POSSÍVEL CRIAR METAS DE VENDEDOR PARA O VENDEDOR PRÓPRIA CORRETORA.", "OK", "", false);
			}
		}

		private void Cancelar_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.CancelarAlteracao();
			this.ViewModel.IsExpanded = true;
			if (Recursos.Usuario.get_Id() == 0)
			{
				this.AlterarPropriaCorretora(false);
			}
		}

		private void DocumentoPrincipalBox_LostFocus(object sender, RoutedEventArgs e)
		{
			if (((TextBox)sender).IsReadOnly)
			{
				return;
			}
			string str = ValidationHelper.Clear(this.DocumentoPrincipalBox.Text);
			if (string.IsNullOrEmpty(str))
			{
				return;
			}
			this.DocumentoPrincipalBox.Text = (str.Length == 11 ? ValidationHelper.FormatDocument(str.PadLeft(11, '0').Substring(0, 11)) : ValidationHelper.FormatDocument(str.PadLeft(14, '0').Substring(0, 14)));
		}

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

		private async void ExcluirVinculo_OnClick(object sender, RoutedEventArgs e)
		{
			Button button = (Button)sender;
			if (button != null && button.DataContext != null)
			{
				VinculoRepasse dataContext = (VinculoRepasse)button.DataContext;
				this.ViewModel.Loading(true);
				await this.ViewModel.ExcluirVinculo(dataContext);
				this.ViewModel.Loading(false);
			}
		}

		private void FormaPagtoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			ComboBox comboBox = (ComboBox)sender;
			if (comboBox.SelectedItem == null)
			{
				return;
			}
			Grid grid = ViewHelper.FindAncestor<Grid>(comboBox).FirstOrDefault<Grid>();
			if (grid == null)
			{
				return;
			}
			ComboBox comboBox1 = (ComboBox)FindVisualChild.Find<ComboBox>(grid).FindName("BasePagtoBox");
			FormaRepasse selectedItem = (FormaRepasse)comboBox.SelectedItem;
			if (comboBox1 == null)
			{
				return;
			}
			comboBox1.IsEnabled = true;
			switch (selectedItem)
			{
				case 1:
				{
					comboBox1.SelectedItem = null;
					return;
				}
				case 2:
				{
					comboBox1.SelectedItem = (BaseRepasse)1;
					return;
				}
				case 3:
				{
					comboBox1.SelectedItem = (BaseRepasse)3;
					comboBox1.IsEnabled = false;
					return;
				}
				default:
				{
					return;
				}
			}
		}

		private void Incluir_OnClick(object sender, RoutedEventArgs e)
		{
			this.ViewModel.Incluir();
			this.AutoCompleteBanco.set_Text("");
			this.ValidarTela();
		}

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

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

		private async void IncluirVinculo_OnClick(object sender, RoutedEventArgs e)
		{
			bool dataContext;
			List<Repasse> repasses;
			Repasse repasse;
			VinculoRepasse vinculoRepasse;
			Button button = (Button)sender;
			Button button1 = button;
			if (button1 != null)
			{
				dataContext = button1.DataContext;
			}
			else
			{
				dataContext = false;
			}
			if (dataContext)
			{
				this.ViewModel.Loading(true);
				repasses = await (new VendedorServico()).BuscaRepasses();
				repasse = (Repasse)button.DataContext;
				VinculoRepasse vinculoRepasse1 = new VinculoRepasse();
				vinculoRepasse1.set_IdRepasse(repasse.get_Id());
				VinculoRepasse vinculoRepasse2 = vinculoRepasse1;
				if (repasse.get_Ativo())
				{
					vinculoRepasse = await this.ViewModel.ShowVinculoDialog(vinculoRepasse2, repasses, repasse);
					if (vinculoRepasse != null)
					{
						List<KeyValuePair<string, string>> keyValuePairs = vinculoRepasse.Validate(repasse.get_Vinculo(), repasse);
						while (keyValuePairs != null && keyValuePairs.Count > 0)
						{
							await this.ViewModel.ShowMessage(keyValuePairs, "OS CAMPOS ABAIXO ESTÃO INVÁLIDOS.", "OK", "");
							vinculoRepasse = await this.ViewModel.ShowVinculoDialog(vinculoRepasse, repasses, repasse);
							if (vinculoRepasse != null)
							{
								keyValuePairs = vinculoRepasse.Validate(repasse.get_Vinculo(), repasse);
							}
							else
							{
								this.ViewModel.Loading(false);
								button = null;
								repasses = null;
								repasse = null;
								vinculoRepasse = null;
								return;
							}
						}
						await this.ViewModel.SalvarVinculo(vinculoRepasse);
						this.ViewModel.Loading(false);
					}
					else
					{
						this.ViewModel.Loading(false);
					}
				}
				else
				{
					await this.ViewModel.ShowMessage("POR FAVOR, ATIVE O REPASSE PARA VINCULÁ-LO", "OK", "", false);
					this.ViewModel.Loading(false);
				}
			}
			button = null;
			repasses = null;
			repasse = null;
			vinculoRepasse = null;
		}

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

		private async void Salvar_OnClick(object sender, RoutedEventArgs e)
		{
			bool flag;
			this.ViewModel.Loading(true);
			this.ViewModel.IsExpanded = true;
			if (!this.ViewModel.SelectedVendedor.get_Ativo())
			{
				if (await this.BuscaVinculo(this.ViewModel.SelectedVendedor))
				{
					return;
				}
			}
			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, this.ViewModel.ErroCamposInvalidos, "OK", "");
			}
			else
			{
				if (Recursos.Usuario.get_Id() == 0)
				{
					this.AlterarPropriaCorretora(false);
				}
				this.ScrollVendedor();
			}
		}

		private void ScrollVendedor()
		{
			if (!this.UpdatingScroll && this.VendedorGrid.SelectedItem != null)
			{
				this.VendedorGrid.ScrollIntoView(this.VendedorGrid.SelectedItem);
			}
			this.UpdatingScroll = false;
		}

		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:
				{
					((AutoCompleteBox)target).add_Populating(new PopulatingEventHandler(this, VendedorView.AutoCompleteBoxVendedor_Populating));
					((AutoCompleteBox)target).add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged));
					return;
				}
				case 2:
				{
					this.VendedorGrid = (DataGrid)target;
					return;
				}
				case 3:
				{
					this.IncluirButton = (MenuItem)target;
					this.IncluirButton.Click += new RoutedEventHandler(this.Incluir_OnClick);
					return;
				}
				case 4:
				{
					this.AlterarButton = (MenuItem)target;
					this.AlterarButton.Click += new RoutedEventHandler(this.Alterar_OnClick);
					return;
				}
				case 5:
				{
					this.SalvarButton = (MenuItem)target;
					this.SalvarButton.Click += new RoutedEventHandler(this.Salvar_OnClick);
					return;
				}
				case 6:
				{
					this.CancelarButton = (MenuItem)target;
					this.CancelarButton.Click += new RoutedEventHandler(this.Cancelar_OnClick);
					return;
				}
				case 7:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.Adiantamento_Click);
					return;
				}
				case 8:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.Button_Click);
					return;
				}
				case 9:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.AbrirAquivoDigital_Click);
					return;
				}
				case 10:
				{
					this.MaisOpcoesButton = (MenuItem)target;
					return;
				}
				case 11:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLog_OnClick);
					return;
				}
				case 12:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.AbrirLogEmail_OnClick);
					return;
				}
				case 13:
				{
					this.EmpresaBox = (TextBox)target;
					return;
				}
				case 14:
				{
					this.IdBox = (TextBox)target;
					return;
				}
				case 15:
				{
					this.NomeBox = (TextBox)target;
					return;
				}
				case 16:
				{
					this.DocumentoPrincipalBox = (TextBox)target;
					VendedorView vendedorView = this;
					this.DocumentoPrincipalBox.PreviewTextInput += new TextCompositionEventHandler(vendedorView.SomenteNumeros);
					this.DocumentoPrincipalBox.LostFocus += new RoutedEventHandler(this.DocumentoPrincipalBox_LostFocus);
					return;
				}
				case 17:
				{
					this.AutoCompleteBanco = (AutoCompleteBox)target;
					this.AutoCompleteBanco.add_Populating(new PopulatingEventHandler(this, VendedorView.AutoCompleteBancoBox_Populating));
					this.AutoCompleteBanco.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.AutoCompleteBanco_OnLostKeyboardFocus);
					return;
				}
				case 18:
				{
					this.AgenciaBox = (TextBox)target;
					return;
				}
				case 19:
				{
					this.TipoBox = (ComboBox)target;
					return;
				}
				case 20:
				{
					this.ContaBox = (TextBox)target;
					return;
				}
				case 21:
				{
					this.TitularBox = (TextBox)target;
					return;
				}
				case 22:
				{
					this.TitularDocBox = (TextBox)target;
					VendedorView vendedorView1 = this;
					this.TitularDocBox.PreviewTextInput += new TextCompositionEventHandler(vendedorView1.SomenteNumeros);
					return;
				}
				case 23:
				{
					this.TipoIncidenciaDescontoBox = (ComboBox)target;
					return;
				}
				case 24:
				{
					this.AtivoBox = (ToggleButton)target;
					return;
				}
				case 25:
				{
					((Button)target).Click += new RoutedEventHandler(this.AtivarInativarVendedor_OnClick);
					return;
				}
				case 26:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.IncluirRepasse_OnClick);
					return;
				}
				case 27:
				case 28:
				case 29:
				case 30:
				case 31:
				case 32:
				{
					this._contentLoaded = true;
					return;
				}
				case 33:
				{
					this.GridContatos = (Grid)target;
					return;
				}
				case 34:
				{
					((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTelefone_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)
		{
			switch (connectionId)
			{
				case 27:
				{
					((Button)target).Click += new RoutedEventHandler(this.IncluirVinculo_OnClick);
					return;
				}
				case 28:
				{
					((Button)target).Click += new RoutedEventHandler(this.AbrirLogRepasse_OnClick);
					return;
				}
				case 29:
				{
					((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.TipoBox_OnSelectionChanged);
					return;
				}
				case 30:
				{
					((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.FormaPagtoBox_OnSelectionChanged);
					return;
				}
				case 31:
				{
					((Button)target).Click += new RoutedEventHandler(this.AtivarInativarRepasse_OnClick);
					return;
				}
				case 32:
				{
					((Button)target).Click += new RoutedEventHandler(this.ExcluirVinculo_OnClick);
					return;
				}
				case 33:
				case 34:
				{
					return;
				}
				case 35:
				{
					((Button)target).Click += new RoutedEventHandler(this.ExcluirTelefone_OnClick);
					return;
				}
				case 36:
				{
					VendedorView vendedorView = this;
					((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(vendedorView.SomenteNumeros);
					return;
				}
				case 37:
				{
					VendedorView vendedorView1 = this;
					((TextBox)target).LostFocus += new RoutedEventHandler(vendedorView1.FormatarTelefone);
					VendedorView vendedorView2 = this;
					((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(vendedorView2.SomenteNumeros);
					return;
				}
				default:
				{
					return;
				}
			}
		}

		private void TipoBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			ComboBox comboBox = (ComboBox)sender;
			if (comboBox.SelectedItem == null)
			{
				return;
			}
			ListBoxItem listBoxItem = ViewHelper.FindAncestor<ListBoxItem>(comboBox).FirstOrDefault<ListBoxItem>();
			if (listBoxItem == null)
			{
				return;
			}
			ComboBox comboBox1 = (ComboBox)FindVisualChild.Find<ComboBox>(listBoxItem).FindName("FormaPagtoBox");
			if (comboBox1 == null)
			{
				return;
			}
			CurrencyTextBox currencyTextBox = (CurrencyTextBox)FindVisualChild.Find<CurrencyTextBox>(listBoxItem).FindName("ValorBox");
			CurrencyTextBox currencyTextBox1 = (CurrencyTextBox)FindVisualChild.Find<CurrencyTextBox>(listBoxItem).FindName("RenovacoesBox");
			TipoRepasse selectedItem = (TipoRepasse)comboBox.SelectedItem;
			comboBox1.SelectedItem = (FormaRepasse)1;
			if (selectedItem == 1)
			{
				if (currencyTextBox != null)
				{
					currencyTextBox.set_MaximumValue(new decimal(10000));
				}
				if (currencyTextBox1 != null)
				{
					currencyTextBox1.set_MaximumValue(new decimal(10000));
				}
			}
			else if (selectedItem == 2)
			{
				if (currencyTextBox != null)
				{
					currencyTextBox.set_MaximumValue(new decimal(100));
				}
				if (currencyTextBox1 != null)
				{
					currencyTextBox1.set_MaximumValue(new decimal(100));
					return;
				}
			}
		}

		private void ValidarTela()
		{
			object keyValuePairs;
			object obj;
			if (this.ViewModel.SelectedVendedor == null)
			{
				return;
			}
			List<KeyValuePair<string, string>> keyValuePairs1 = this.ViewModel.SelectedVendedor.Validate();
			List<KeyValuePair<string, string>> keyValuePairs2 = keyValuePairs1;
			List<VendedorTelefone> telefones = this.ViewModel.SelectedVendedor.get_Telefones();
			if (telefones != null)
			{
				VendedorTelefone vendedorTelefone = telefones.FirstOrDefault<VendedorTelefone>();
				if (vendedorTelefone != null)
				{
					keyValuePairs = vendedorTelefone.Validate();
				}
				else
				{
					keyValuePairs = null;
				}
			}
			else
			{
				keyValuePairs = null;
			}
			if (keyValuePairs == null)
			{
				keyValuePairs = new List<KeyValuePair<string, string>>();
			}
			keyValuePairs2.AddRange((IEnumerable<!0>)keyValuePairs);
			List<KeyValuePair<string, string>> keyValuePairs3 = keyValuePairs1;
			ObservableCollection<Repasse> repasses = this.ViewModel.Repasses;
			if (repasses != null)
			{
				Repasse repasse = repasses.FirstOrDefault<Repasse>();
				if (repasse != null)
				{
					obj = repasse.Validate();
				}
				else
				{
					obj = null;
				}
			}
			else
			{
				obj = null;
			}
			if (obj == null)
			{
				obj = new List<KeyValuePair<string, string>>();
			}
			keyValuePairs3.AddRange((IEnumerable<!0>)obj);
			this.ValidateFields(keyValuePairs1, false);
		}

		private void VendedorView_SizeChanged(object sender, SizeChangedEventArgs e)
		{
			if (e.NewSize.Width > 1260)
			{
				this.ViewModel.GridHeight2 = new GridLength(0);
				Grid.SetRow(this.GridContatos, 0);
				Grid.SetColumn(this.GridContatos, 1);
				return;
			}
			this.ViewModel.GridHeight2 = new GridLength(1, GridUnitType.Star);
			Grid.SetRow(this.GridContatos, 1);
			Grid.SetColumn(this.GridContatos, 0);
		}
	}
}