summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Views.Seguros/PerfilView.cs
blob: 54d67848c5979d27907fd11c381cfce5233233db (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
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Text.RegularExpressions;
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 Gestor.Application.Helpers;
using Gestor.Application.ViewModels.Seguros;
using Gestor.Application.Views.Generic;
using Gestor.Common.Validation;
using Gestor.Model.Common;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;

namespace Gestor.Application.Views.Seguros;

public class PerfilView : BaseUserControl, IComponentConnector
{
	public PerfilViewModel ViewModel;

	private Controle _controle;

	internal MenuItem CancelarApoliceButton;

	internal DatePicker NascimentoBox;

	private bool _contentLoaded;

	public PerfilView(Controle controle)
	{
		_controle = controle;
		((FrameworkElement)this).Tag = "CADASTRO DE PERFIL";
		ViewModel = new PerfilViewModel(controle);
		((FrameworkElement)this).DataContext = ViewModel;
		InitializeComponent();
		Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher;
		if (dispatcher != null)
		{
			dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad));
		}
	}

	private void ContentLoad()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		((UIElement)NascimentoBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(Funcoes.DatePicker_OnLostKeyboardFocus);
		((UIElement)NascimentoBox).PreviewKeyDown += new KeyEventHandler(Funcoes.DatePicker_PreviewKeyDown);
	}

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

	private void Alterar_OnClick(object sender, RoutedEventArgs e)
	{
		ViewModel.Alterar(alterar: true);
		ValidarTela();
	}

	private async void Salvar_OnClick(object sender, RoutedEventArgs e)
	{
		ViewModel.Loading(isLoading: true);
		List<KeyValuePair<string, string>> list = await ViewModel.Salvar();
		((DependencyObject)(object)this).ValidateFields(list);
		bool num = list == null || list.Count == 0;
		ViewModel.Loading(isLoading: false);
		if (!num)
		{
			await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK");
		}
	}

	private void Cancelar_OnClick(object sender, RoutedEventArgs e)
	{
		ViewModel.CancelarAlteracao();
	}

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

	private void CpfBox_OnLostFocus(object sender, RoutedEventArgs e)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		TextBox val = (TextBox)sender;
		val.Text = ValidationHelper.FormatDocument(val.Text);
	}

	private void RelacaoComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		if (((Selector)(ComboBox)sender).SelectedIndex != 0)
		{
			return;
		}
		Cliente cliente = _controle.Cliente;
		string text = ValidationHelper.FormatDocument(ValidationHelper.Clear((cliente != null) ? cliente.Documento : null));
		bool flag = Regex.IsMatch(text, "\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}");
		Perfil val = (Perfil)((DomainBase)ViewModel.SelectedPerfil).Clone();
		val.Cpf = (flag ? text : "");
		val.Nome = _controle.Cliente.Nome;
		val.Nascimento = _controle.Cliente.Nascimento;
		val.Sexo = _controle.Cliente.Sexo;
		val.EstadoCivil = _controle.Cliente.EstadoCivil;
		val.Habilitacao = _controle.Cliente.Habilitacao;
		if (_controle.Cliente.PrimeiraHabilitacao.HasValue)
		{
			DateTime networkTime = Funcoes.GetNetworkTime();
			DateTime? primeiraHabilitacao = _controle.Cliente.PrimeiraHabilitacao;
			TimeSpan? timeSpan = networkTime - primeiraHabilitacao;
			TimeSpan? timeSpan2 = timeSpan;
			if (timeSpan2.Value.Days > 3650)
			{
				val.TempoHabilitacao = (TempoHabilitacao)10;
			}
			else
			{
				TimeSpan? timeSpan3 = timeSpan;
				if (timeSpan3.Value.Days > 3285)
				{
					val.TempoHabilitacao = (TempoHabilitacao)9;
				}
				else
				{
					TimeSpan? timeSpan4 = timeSpan;
					if (timeSpan4.Value.Days > 2920)
					{
						val.TempoHabilitacao = (TempoHabilitacao)8;
					}
					else
					{
						TimeSpan? timeSpan5 = timeSpan;
						if (timeSpan5.Value.Days > 2555)
						{
							val.TempoHabilitacao = (TempoHabilitacao)7;
						}
						else
						{
							TimeSpan? timeSpan6 = timeSpan;
							if (timeSpan6.Value.Days > 2190)
							{
								val.TempoHabilitacao = (TempoHabilitacao)6;
							}
							else
							{
								TimeSpan? timeSpan7 = timeSpan;
								if (timeSpan7.Value.Days > 1825)
								{
									val.TempoHabilitacao = (TempoHabilitacao)5;
								}
								else
								{
									TimeSpan? timeSpan8 = timeSpan;
									if (timeSpan8.Value.Days > 1460)
									{
										val.TempoHabilitacao = (TempoHabilitacao)4;
									}
									else
									{
										TimeSpan? timeSpan9 = timeSpan;
										if (timeSpan9.Value.Days > 1095)
										{
											val.TempoHabilitacao = (TempoHabilitacao)3;
										}
										else
										{
											TimeSpan? timeSpan10 = timeSpan;
											if (timeSpan10.Value.Days > 730)
											{
												val.TempoHabilitacao = (TempoHabilitacao)2;
											}
											else
											{
												TimeSpan? timeSpan11 = timeSpan;
												if (timeSpan11.Value.Days > 365)
												{
													val.TempoHabilitacao = (TempoHabilitacao)1;
												}
												else
												{
													val.TempoHabilitacao = (TempoHabilitacao)0;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		ViewModel.SelectedPerfil = val;
	}

	private void ValidarTela()
	{
		if (ViewModel.SelectedPerfil != null)
		{
			List<KeyValuePair<string, string>> errorMessages = ViewModel.SelectedPerfil.Validate();
			((DependencyObject)(object)this).ValidateFields(errorMessages, focusField: false);
		}
	}

	private void PostcodeBox_OnLostFocus(object sender, RoutedEventArgs e)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		TextBox val = (TextBox)sender;
		if (!string.IsNullOrWhiteSpace(val.Text))
		{
			string text = ValidationHelper.FormatPostCode(val.Text);
			if (ValidationHelper.ValidatePostCode(text))
			{
				val.Text = text;
			}
		}
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	public void InitializeComponent()
	{
		if (!_contentLoaded)
		{
			_contentLoaded = true;
			Uri uri = new Uri("/Gestor.Application;component/views/seguros/perfilview.xaml", UriKind.Relative);
			Application.LoadComponent((object)this, uri);
		}
	}

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

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	[EditorBrowsable(EditorBrowsableState.Never)]
	void IComponentConnector.Connect(int connectionId, object target)
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Expected O, but got Unknown
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Expected O, but got Unknown
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Expected O, but got Unknown
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Expected O, but got Unknown
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Expected O, but got Unknown
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Expected O, but got Unknown
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Expected O, but got Unknown
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Expected O, but got Unknown
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Expected O, but got Unknown
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Expected O, but got Unknown
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Expected O, but got Unknown
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Expected O, but got Unknown
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Expected O, but got Unknown
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Expected O, but got Unknown
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Expected O, but got Unknown
		switch (connectionId)
		{
		case 1:
			((MenuItem)target).Click += new RoutedEventHandler(Incluir_OnClick);
			break;
		case 2:
			((MenuItem)target).Click += new RoutedEventHandler(Alterar_OnClick);
			break;
		case 3:
			((MenuItem)target).Click += new RoutedEventHandler(Salvar_OnClick);
			break;
		case 4:
			CancelarApoliceButton = (MenuItem)target;
			CancelarApoliceButton.Click += new RoutedEventHandler(Cancelar_OnClick);
			break;
		case 5:
			((MenuItem)target).Click += new RoutedEventHandler(Excluir_OnClick);
			break;
		case 6:
			((Selector)(ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(RelacaoComboBox_OnSelectionChanged);
			break;
		case 7:
			((UIElement)(TextBox)target).LostFocus += new RoutedEventHandler(CpfBox_OnLostFocus);
			((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros);
			break;
		case 8:
			NascimentoBox = (DatePicker)target;
			((UIElement)NascimentoBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(base.DatePicker_OnLostKeyboardFocus);
			((Control)NascimentoBox).MouseDoubleClick += new MouseButtonEventHandler(base.DataAtual_OnDoubleClick);
			break;
		case 9:
			((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros);
			break;
		case 10:
			((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros);
			break;
		case 11:
			((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros);
			break;
		case 12:
			((UIElement)(TextBox)target).LostFocus += new RoutedEventHandler(PostcodeBox_OnLostFocus);
			((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros);
			break;
		case 13:
			((UIElement)(TextBox)target).LostFocus += new RoutedEventHandler(PostcodeBox_OnLostFocus);
			((UIElement)(TextBox)target).PreviewTextInput += new TextCompositionEventHandler(SomenteNumeros);
			break;
		default:
			_contentLoaded = true;
			break;
		}
	}
}