summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Views.Financeiro/PlanosView.cs
blob: 42abf6dc2b621f5f2f23f9d953f58e5932056cb9 (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
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Threading;
using Gestor.Application.Helpers;
using Gestor.Application.Servicos.Generic;
using Gestor.Application.ViewModels.Financeiro;
using Gestor.Application.Views.Generic;
using Gestor.Common.Validation;
using Gestor.Model.Common;
using Gestor.Model.Domain.Financeiro;
using Gestor.Model.Domain.Generic;

namespace Gestor.Application.Views.Financeiro;

public class PlanosView : BaseUserControl, IComponentConnector
{
	[Serializable]
	[CompilerGenerated]
	private sealed class _003C_003Ec
	{
		public static readonly _003C_003Ec _003C_003E9 = new _003C_003Ec();

		public static MouseButtonEventHandler _003C_003E9__3_0;

		public static Func<Plano, bool> _003C_003E9__3_1;

		public static Func<Plano, string> _003C_003E9__3_2;

		public static Func<Plano, bool> _003C_003E9__11_6;

		public static Func<Plano, string> _003C_003E9__11_7;

		public static Func<Planos, bool> _003C_003E9__11_0;

		public static Func<Planos, string> _003C_003E9__11_1;

		public static Func<Planos, string> _003C_003E9__11_2;

		public static Func<Planos, long> _003C_003E9__11_3;

		internal void _003CContentLoad_003Eb__3_0(object sender, MouseButtonEventArgs args)
		{
		}

		internal bool _003CContentLoad_003Eb__3_1(Plano x)
		{
			return x.Ativo;
		}

		internal string _003CContentLoad_003Eb__3_2(Plano x)
		{
			return x.Descricao;
		}

		internal bool _003CPlanoButton_OnClick_003Eb__11_6(Plano x)
		{
			return x.Ativo;
		}

		internal string _003CPlanoButton_OnClick_003Eb__11_7(Plano x)
		{
			return x.Descricao;
		}

		internal bool _003CPlanoButton_OnClick_003Eb__11_0(Planos x)
		{
			return x.Ativo;
		}

		internal string _003CPlanoButton_OnClick_003Eb__11_1(Planos x)
		{
			Plano plano = x.Plano;
			if (plano == null)
			{
				return null;
			}
			return plano.Descricao;
		}

		internal string _003CPlanoButton_OnClick_003Eb__11_2(Planos x)
		{
			return x.Descricao;
		}

		internal long _003CPlanoButton_OnClick_003Eb__11_3(Planos p)
		{
			return ((DomainBase)p).Id;
		}
	}

	private bool _seleciona = true;

	public PlanosViewModel ViewModel;

	internal DataGrid PlanosGrid;

	private bool _contentLoaded;

	public PlanosView()
	{
		((FrameworkElement)this).Tag = "PLANO DE CONTAS";
		ViewModel = new PlanosViewModel();
		((FrameworkElement)this).DataContext = ViewModel;
		InitializeComponent();
		Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher;
		if (dispatcher != null)
		{
			dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad));
		}
	}

	private async void ContentLoad()
	{
		((Selector)PlanosGrid).SelectedIndex = 0;
		((Selector)PlanosGrid).SelectionChanged += new SelectionChangedEventHandler(PlanosGrid_OnSelectionChanged);
		DataGrid planosGrid = PlanosGrid;
		object obj = _003C_003Ec._003C_003E9__3_0;
		if (obj == null)
		{
			MouseButtonEventHandler val = delegate
			{
			};
			_003C_003Ec._003C_003E9__3_0 = val;
			obj = (object)val;
		}
		((Control)planosGrid).MouseDoubleClick += (MouseButtonEventHandler)obj;
		PlanosViewModel viewModel = ViewModel;
		viewModel.Plano = new ObservableCollection<Plano>((from x in await new BaseServico().BuscarPlanoAsync()
			orderby x.Ativo descending, x.Descricao
			select x).ToList());
	}

	private async void PlanosGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
	{
		if (_seleciona)
		{
			DataGrid val = (DataGrid)sender;
			if (val == null || ((Selector)val).SelectedIndex >= 0)
			{
				await ViewModel.SelecionaPlanos((Planos)((val != null) ? ((ItemsControl)val).Items[((Selector)val).SelectedIndex] : null));
			}
		}
	}

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

	private async void SalvarPlanos_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 AlterarPlanos_OnClick(object sender, RoutedEventArgs e)
	{
		ViewModel.Alterar(alterar: true);
		((DomainBase)ViewModel.SelectedPlanos).Initialize();
	}

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

	private void AutoCompleteBoxPlanos_OnTextChanged(object sender, RoutedEventArgs e)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).Text))
		{
			ViewModel.FiltrarPlanos("");
		}
	}

	private void AutoCompleteBoxPlanos_Populating(object sender, PopulatingEventArgs e)
	{
		e.Cancel = true;
		ViewModel.Filtrar(ValidationHelper.RemoveDiacritics(e.Parameter.Trim())).ContinueWith(delegate(Task<ObservableCollection<Planos>> searchResult)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (searchResult != null)
			{
				AutoCompleteBox val = (AutoCompleteBox)sender;
				val.ItemsSource = searchResult.Result;
				val.PopulateComplete();
			}
		}, TaskScheduler.FromCurrentSynchronizationContext());
	}

	private async void PlanoButton_OnClick(object sender, RoutedEventArgs e)
	{
		PlanoView planoView = new PlanoView(ViewModel.SelectedPlanos.Plano);
		((Window)new HosterWindow((ContentControl)(object)planoView, "PLANO", 500.0, 200.0)).ShowDialog();
		ViewModel.Loading(isLoading: true);
		if (((DomainBase)planoView.ViewModel.SelectedPlano).Id != 0L)
		{
			PlanosViewModel viewModel = ViewModel;
			viewModel.Plano = new ObservableCollection<Plano>((from x in await new BaseServico().BuscarPlanoAsync()
				orderby x.Ativo descending, x.Descricao
				select x).ToList());
			List<Planos> source = await new BaseServico().BuscarPlanosAsync();
			ViewModel.Planos = source.OrderByDescending((Planos x) => x.Ativo).ThenBy(delegate(Planos x)
			{
				Plano plano = x.Plano;
				return (plano == null) ? null : plano.Descricao;
			}).ThenBy((Planos x) => x.Descricao)
				.ToList();
			List<long> ids = ViewModel.PlanosFiltrados.Select((Planos p) => ((DomainBase)p).Id).ToList();
			ViewModel.PlanosFiltrados = new ObservableCollection<Planos>(ViewModel.Planos.Where((Planos x) => ids.Contains(((DomainBase)x).Id)));
			_seleciona = false;
			((Selector)PlanosGrid).SelectedItem = ViewModel.SelectedPlanos;
			ViewModel.SelectedPlano = ViewModel.Plano.First((Plano x) => ((DomainBase)x).Id == ((DomainBase)planoView.ViewModel.SelectedPlano).Id);
			_seleciona = true;
		}
		ViewModel.Loading(isLoading: false);
	}

	private void AbrirLog_OnClick(object sender, RoutedEventArgs e)
	{
		ViewModel.AbrirLog((TipoTela)28, ((DomainBase)ViewModel.SelectedPlanos).Id);
	}

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	public void InitializeComponent()
	{
		if (!_contentLoaded)
		{
			_contentLoaded = true;
			Uri uri = new Uri("/Gestor.Application;component/views/financeiro/planosview.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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Expected O, but got Unknown
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Expected O, but got Unknown
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Expected O, but got Unknown
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Expected O, but got Unknown
		switch (connectionId)
		{
		case 1:
			((AutoCompleteBox)target).Populating += new PopulatingEventHandler(AutoCompleteBoxPlanos_Populating);
			((AutoCompleteBox)target).TextChanged += new RoutedEventHandler(AutoCompleteBoxPlanos_OnTextChanged);
			break;
		case 2:
			PlanosGrid = (DataGrid)target;
			break;
		case 3:
			((MenuItem)target).Click += new RoutedEventHandler(IncluirPlanos_OnClick);
			break;
		case 4:
			((MenuItem)target).Click += new RoutedEventHandler(AlterarPlanos_OnClick);
			break;
		case 5:
			((MenuItem)target).Click += new RoutedEventHandler(SalvarPlanos_OnClick);
			break;
		case 6:
			((MenuItem)target).Click += new RoutedEventHandler(CancelarPlanos_OnClick);
			break;
		case 7:
			((MenuItem)target).Click += new RoutedEventHandler(AbrirLog_OnClick);
			break;
		case 8:
			((ButtonBase)(Button)target).Click += new RoutedEventHandler(PlanoButton_OnClick);
			break;
		default:
			_contentLoaded = true;
			break;
		}
	}
}