summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Componentes/DialogEditarParcelas.cs
blob: c0bbe85fe3fd95cd42b27184a7b42160795dc857 (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
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Markup;
using Gestor.Application.Actions;
using Gestor.Application.ViewModels.Generic;
using Gestor.Common.Validation;
using Gestor.Model.Domain.Seguros;
using MaterialDesignThemes.Wpf;

namespace Gestor.Application.Componentes;

public class DialogEditarParcelas : UserControl, IComponentConnector
{
	internal Snackbar Snackbar;

	internal DataGrid ParcelaGrid;

	internal DataGridTextColumn ParcelaColumn;

	internal Label LabelStatus;

	internal Button SalvarButton;

	internal Button FecharButton;

	private bool _contentLoaded;

	public DialogEditarParcelasViewModel ViewModel { get; set; }

	public DialogEditarParcelas(Documento documento)
	{
		ViewModel = new DialogEditarParcelasViewModel(documento);
		((FrameworkElement)this).DataContext = ViewModel;
		Gestor.Application.Actions.Actions.AcionarSnackbar = (Action<string>)Delegate.Remove(Gestor.Application.Actions.Actions.AcionarSnackbar, new Action<string>(AcionarSnackBar));
		Gestor.Application.Actions.Actions.AcionarSnackbar = (Action<string>)Delegate.Combine(Gestor.Application.Actions.Actions.AcionarSnackbar, new Action<string>(AcionarSnackBar));
		InitializeComponent();
	}

	private void AcionarSnackBar(string message)
	{
		Snackbar.IsActive = true;
		((ContentControl)Snackbar.Message).Content = message;
	}

	private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e)
	{
		Snackbar.IsActive = false;
	}

	private async void SalvarButton_OnClick(object sender, RoutedEventArgs e)
	{
		if (await ViewModel.SalvarParcelas())
		{
			DialogHost.CloseDialogCommand.Execute((object)null, (IInputElement)(object)SalvarButton);
		}
	}

	private void FecharButton_OnClick(object sender, RoutedEventArgs e)
	{
		DialogHost.CloseDialogCommand.Execute((object)null, (IInputElement)(object)SalvarButton);
	}

	private void ParcelaGrid_OnCellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Expected O, but got Unknown
		if (!(e.EditingElement is TextBox))
		{
			return;
		}
		Parcela val = (Parcela)((FrameworkElement)e.Row).DataContext;
		FrameworkElement editingElement = e.EditingElement;
		TextBox val2 = (TextBox)(object)((editingElement is TextBox) ? editingElement : null);
		if (val2 == null)
		{
			return;
		}
		if (e.Column.ClipboardContentBinding.StringFormat == "d")
		{
			val2.Text = ValidationHelper.FormatDate(val2.Text);
			if (e.Column.Header.ToString() == "VENCIMENTO")
			{
				val.Vencimento = ((string.IsNullOrWhiteSpace(val2.Text) || !DateTime.TryParse(val2.Text, out var _)) ? DateTime.MinValue : DateTime.Parse(val2.Text));
			}
		}
		string text = e.Column.Header.ToString();
		if (!(text == "VALOR"))
		{
			if (text == "VENCIMENTO")
			{
				ViewModel.AlterandoVencimento((Parcela)((FrameworkElement)e.Row).DataContext);
			}
		}
		else
		{
			ViewModel.AlterandoValor();
		}
	}

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

	[DebuggerNonUserCode]
	[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
	[EditorBrowsable(EditorBrowsableState.Never)]
	void IComponentConnector.Connect(int connectionId, object target)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Expected O, but got Unknown
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Expected O, but got Unknown
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Expected O, but got Unknown
		switch (connectionId)
		{
		case 1:
			Snackbar = (Snackbar)target;
			break;
		case 2:
			((SnackbarMessage)target).ActionClick += new RoutedEventHandler(SnackbarMessage_ActionClick);
			break;
		case 3:
			ParcelaGrid = (DataGrid)target;
			ParcelaGrid.CellEditEnding += ParcelaGrid_OnCellEditEnding;
			break;
		case 4:
			ParcelaColumn = (DataGridTextColumn)target;
			break;
		case 5:
			LabelStatus = (Label)target;
			break;
		case 6:
			SalvarButton = (Button)target;
			((ButtonBase)SalvarButton).Click += new RoutedEventHandler(SalvarButton_OnClick);
			break;
		case 7:
			FecharButton = (Button)target;
			((ButtonBase)FecharButton).Click += new RoutedEventHandler(FecharButton_OnClick);
			break;
		default:
			_contentLoaded = true;
			break;
		}
	}
}