summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Views.BI/NotasView.cs
blob: 788cf192efd320401f4020a42ba29b462fd2aace (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
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
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.Media;
using Gestor.Application.Helpers;
using Gestor.Application.ViewModels.BI;
using Gestor.Application.Views.Generic;
using Gestor.Model.Common;
using Gestor.Model.Domain.Ferramentas;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;

namespace Gestor.Application.Views.BI;

public class NotasView : BaseUserControl, IComponentConnector, IStyleConnector
{
	internal ProgressBar ProgressRing;

	private bool _contentLoaded;

	public NotasViewModel ViewModel { get; set; }

	public NotasView()
	{
		ViewModel = new NotasViewModel();
		((FrameworkElement)this).DataContext = ViewModel;
		InitializeComponent();
	}

	private static object GetDataFromListBox(ItemsControl source, Point point)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		IInputElement obj = ((UIElement)source).InputHitTest(point);
		UIElement val = (UIElement)(object)((obj is UIElement) ? obj : null);
		if (val == null)
		{
			return null;
		}
		object obj2 = DependencyProperty.UnsetValue;
		while (obj2 == DependencyProperty.UnsetValue)
		{
			if (val != null)
			{
				obj2 = source.ItemContainerGenerator.ItemFromContainer((DependencyObject)(object)val);
				if (obj2 == DependencyProperty.UnsetValue)
				{
					DependencyObject parent = VisualTreeHelper.GetParent((DependencyObject)(object)val);
					val = (UIElement)(object)((parent is UIElement) ? parent : null);
				}
				if (val == source)
				{
					return null;
				}
			}
		}
		if (obj2 == DependencyProperty.UnsetValue)
		{
			return null;
		}
		return obj2;
	}

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

	private async void ListBox_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
	{
		ListBox val = (ListBox)sender;
		object dataFromListBox = GetDataFromListBox((ItemsControl)(object)val, ((MouseEventArgs)e).GetPosition((IInputElement)(object)val));
		if (dataFromListBox != null)
		{
			Tarefa val2 = new Tarefa();
			DomainBase.Copy<Tarefa, Tarefa>(val2, (Tarefa)dataFromListBox);
			val2.UsuariosVinculados = val2.Responsaveis?.Select((ResponsavelTarefa x) => x.Usuario).ToList();
			await AbrirNota(val2, (int)val2.Entidade == 1, (int)val2.Entidade == 1);
		}
	}

	private async Task AbrirNota(Tarefa data, bool notaBool = false, bool agendamento = false)
	{
		while (true)
		{
			Tarefa nota = await ViewModel.ShowTarefaDialog(data, notaBool, agendamento);
			if (nota == null)
			{
				return;
			}
			if (nota.Usuario == null)
			{
				nota.Usuario = nota.UsuariosVinculados.FirstOrDefault();
			}
			List<ResponsavelTarefa> responsaveis = ((IEnumerable<Usuario>)nota.UsuariosVinculados).Select((Func<Usuario, ResponsavelTarefa>)((Usuario x) => new ResponsavelTarefa
			{
				IdTarefa = ((DomainBase)nota).Id,
				Usuario = x
			})).ToList();
			nota.Responsaveis = responsaveis;
			ViewModel.Loading(isLoading: true);
			List<KeyValuePair<string, string>> list = await ViewModel.Salvar(nota);
			ViewModel.Loading(isLoading: false);
			if (list == null || list.Count == 0)
			{
				break;
			}
			await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK");
		}
		ViewModel.ToggleSnackBar("NOTA SALVA COM SUCESSO.");
		await ViewModel.CarregarNotas();
	}

	private async void NotaConcluida_OnClick(object sender, RoutedEventArgs e)
	{
		object dataContext = ((FrameworkElement)(Button)sender).DataContext;
		Tarefa val = (Tarefa)((dataContext is Tarefa) ? dataContext : null);
		if (val != null)
		{
			val.Conclusao = Funcoes.GetNetworkTime();
			val.Status = (StatusTarefa)2;
			await ViewModel.SalvarNota(val);
			await ViewModel.CarregarNotas();
		}
	}

	private void ToggleNotasConcluidas_OnClick(object sender, RoutedEventArgs e)
	{
		ViewModel.ToggleNotasConcluidas();
	}

	private async void ExcluirNota_OnClick(object sender, RoutedEventArgs e)
	{
		object dataContext = ((FrameworkElement)(Button)sender).DataContext;
		Tarefa val = (Tarefa)((dataContext is Tarefa) ? dataContext : null);
		if (val != null)
		{
			await ViewModel.ExcluirNota(val);
			await ViewModel.CarregarNotas();
		}
	}

	private async void SarvarNota_OnClick(object sender, RoutedEventArgs e)
	{
		object dataContext = ((FrameworkElement)(Button)sender).DataContext;
		Tarefa val = (Tarefa)((dataContext is Tarefa) ? dataContext : null);
		if (val != null)
		{
			ViewModel.Loading(isLoading: true);
			List<KeyValuePair<string, string>> list = await ViewModel.Salvar(val);
			ViewModel.Loading(isLoading: false);
			if (list == null || list.Count == 0)
			{
				ViewModel.ToggleSnackBar("NOTA SALVA COM SUCESSO.");
			}
			else
			{
				await ViewModel.CarregarNotas();
			}
		}
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	public void InitializeComponent()
	{
		if (!_contentLoaded)
		{
			_contentLoaded = true;
			Uri uri = new Uri("/Gestor.Application;component/views/bi/notasview.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_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		switch (connectionId)
		{
		case 1:
			ProgressRing = (ProgressBar)target;
			break;
		case 2:
			((Control)(ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(ListBox_OnPreviewMouseDoubleClick);
			break;
		case 6:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(AdicionarNota_OnClick);
			break;
		case 7:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(ToggleNotasConcluidas_OnClick);
			break;
		case 8:
			((Control)(ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(ListBox_OnPreviewMouseDoubleClick);
			break;
		default:
			_contentLoaded = true;
			break;
		}
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	[EditorBrowsable(EditorBrowsableState.Never)]
	void IStyleConnector.Connect(int connectionId, object target)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//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_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Expected O, but got Unknown
		switch (connectionId)
		{
		case 3:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(ExcluirNota_OnClick);
			break;
		case 4:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(NotaConcluida_OnClick);
			break;
		case 5:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(SarvarNota_OnClick);
			break;
		case 9:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(ExcluirNota_OnClick);
			break;
		case 10:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(SarvarNota_OnClick);
			break;
		case 6:
		case 7:
		case 8:
			break;
		}
	}
}