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
|
using Gestor.Application;
using Gestor.Application.Helpers;
using Gestor.Application.ViewModels.Drawer;
using Gestor.Application.ViewModels.Generic;
using Gestor.Model.Domain.Generic;
using MaterialDesignThemes.Wpf;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Markup;
using System.Windows.Threading;
namespace Gestor.Application.Drawers
{
public class ImpostoDrawer : UserControl, IComponentConnector
{
private readonly int _tipo;
private readonly long _id;
internal System.Windows.Controls.ProgressBar ProgressBar;
internal TextBlock TitleBox;
internal ComboBox SeguradoraBox;
internal ComboBox SeguradoraAlternativaBox;
internal ComboBox RamoBox;
internal DataGrid ArquivoGrid;
internal Snackbar SnackbarImposto;
private bool _contentLoaded;
public ImpostoViewModel ViewModel
{
get;
set;
}
[DebuggerNonUserCode]
[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
internal Delegate _CreateDelegate(Type delegateType, string handler)
{
return Delegate.CreateDelegate(delegateType, this, handler);
}
public ImpostoDrawer(int tipo, long id)
{
this._tipo = tipo;
this._id = id;
this.ViewModel = new ImpostoViewModel();
base.DataContext = this.ViewModel;
this.InitializeComponent();
System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher;
if (dispatcher == null)
{
return;
}
dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad));
}
private void Alterar_OnClick(object sender, RoutedEventArgs e)
{
this.ViewModel.AlterarImposto();
}
private async void Cancelar_OnClick(object sender, RoutedEventArgs e)
{
await this.ViewModel.Cancelar();
}
private void CloseSlackBar()
{
Thread.Sleep(5000);
System.Windows.Threading.Dispatcher dispatcher = App.ProgressRing.Dispatcher;
if (dispatcher == null)
{
return;
}
dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => this.Toggle("", false)));
}
private async void ContentLoad()
{
this.ViewModel.Carregando = true;
await this.ViewModel.Carregar(this._tipo, this._id);
this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Indice_OnSelectionChanged);
this.SeguradoraAlternativaBox.SelectionChanged += new SelectionChangedEventHandler(this.Indice_OnSelectionChanged);
this.RamoBox.SelectionChanged += new SelectionChangedEventHandler(this.Indice_OnSelectionChanged);
this.ViewModel.Carregando = false;
}
private void Fechar_OnClick(object sender, RoutedEventArgs e)
{
this.ViewModel.CloseDrawer();
}
private void Incluir_OnClick(object sender, RoutedEventArgs e)
{
this.ViewModel.Incluir();
}
private async void Indice_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!this.ViewModel.Carregando)
{
this.ViewModel.Carregando = true;
await this.ViewModel.Carregar((long)0);
this.ViewModel.Carregando = false;
}
}
[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/drawers/impostodrawer.xaml", UriKind.Relative));
}
private void Log_OnClick(object sender, RoutedEventArgs e)
{
this.ViewModel.AbrirLog(56, this.ViewModel.SelectedImposto.get_Id());
}
private async void Salvar_OnClick(object sender, RoutedEventArgs e)
{
bool flag;
this.ViewModel.Carregando = true;
List<KeyValuePair<string, string>> keyValuePairs = await this.ViewModel.Salvar();
this.ValidateFields(keyValuePairs, true);
flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0);
this.ViewModel.Carregando = false;
if (!flag)
{
await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", "");
}
else
{
this.Toggle("PARÂMETRO SALVO COM SUCESSO.", true);
}
}
private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e)
{
this.SnackbarImposto.set_IsActive(false);
}
private async void Status_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
bool? nullable;
string str;
ListBox listBox = (ListBox)sender;
if (listBox.SelectedItem != null)
{
ImpostoViewModel viewModel = this.ViewModel;
if (listBox.SelectedIndex == 0)
{
nullable = new bool?(true);
}
else if (listBox.SelectedIndex == 1)
{
nullable = new bool?(false);
}
else
{
nullable = null;
}
viewModel.Ativo = nullable;
TextBlock titleBox = this.TitleBox;
if (listBox.SelectedIndex == 0)
{
str = "IMPOSTOS ATIVOS";
}
else
{
str = (listBox.SelectedIndex == 1 ? "IMPOSTOS INATIVOS" : "TODOS IMPOSTOS");
}
titleBox.Text = str;
await this.ViewModel.Carregar((long)0);
}
}
[DebuggerNonUserCode]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
{
switch (connectionId)
{
case 1:
{
this.ProgressBar = (System.Windows.Controls.ProgressBar)target;
return;
}
case 2:
{
((ListBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Status_OnSelectionChanged);
return;
}
case 3:
{
((Button)target).Click += new RoutedEventHandler(this.Fechar_OnClick);
return;
}
case 4:
{
this.TitleBox = (TextBlock)target;
return;
}
case 5:
{
this.SeguradoraBox = (ComboBox)target;
return;
}
case 6:
{
this.SeguradoraAlternativaBox = (ComboBox)target;
return;
}
case 7:
{
this.RamoBox = (ComboBox)target;
return;
}
case 8:
{
((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick);
return;
}
case 9:
{
((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick);
return;
}
case 10:
{
((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick);
return;
}
case 11:
{
((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick);
return;
}
case 12:
{
((MenuItem)target).Click += new RoutedEventHandler(this.Log_OnClick);
return;
}
case 13:
{
this.ArquivoGrid = (DataGrid)target;
return;
}
case 14:
{
this.SnackbarImposto = (Snackbar)target;
return;
}
case 15:
{
((SnackbarMessage)target).add_ActionClick(new RoutedEventHandler(this.SnackbarMessage_ActionClick));
return;
}
}
this._contentLoaded = true;
}
public void Toggle(string message, bool active = true)
{
this.SnackbarImposto.get_Message().Content = message;
this.SnackbarImposto.set_IsActive(active);
if (!active)
{
return;
}
Task.Factory.StartNew(new Action(this.CloseSlackBar));
}
}
}
|