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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
using Gestor.Application.Helpers;
using Gestor.Application.ViewModels;
using Gestor.Application.ViewModels.Generic;
using Gestor.Application.Views.Ferramentas;
using Gestor.Application.Views.Generic;
using Gestor.Application.Views.Seguros;
using Gestor.Model.Attributes;
using Gestor.Model.Domain.BI;
using Gestor.Model.Domain.Configuracoes;
using Gestor.Model.Domain.Ferramentas;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.MalaDireta;
using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos;
using Gestor.Model.Domain.Seguros;
using MaterialDesignThemes.Wpf;
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.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Markup;
namespace Gestor.Application.Componentes
{
public class DialogAnaliticoBi : BaseUserControl, IComponentConnector, IStyleConnector
{
internal AnaliticoViewModel ViewModel;
internal System.Windows.Controls.Grid MainGrid;
internal DataGrid Grid;
internal DataGridTemplateColumn InfoButton;
internal TextBlock Totalizacao;
private bool _contentLoaded;
public List<string> Campos
{
get;
set;
}
public List<Analitico> Lista
{
get;
set;
}
public DialogAnaliticoBi(string titulo, List<Analitico> analitico, string tipo, List<string> campos)
{
this.ViewModel = new AnaliticoViewModel(tipo);
base.DataContext = this.ViewModel;
this.InitializeComponent();
this.ViewModel.Head = titulo;
this.Lista = analitico;
this.Campos = campos;
this.ConstruirLista();
}
private async Task AbrirTarefa(Tarefa data)
{
//
// Current member / type: System.Threading.Tasks.Task Gestor.Application.Componentes.DialogAnaliticoBi::AbrirTarefa(Gestor.Model.Domain.Ferramentas.Tarefa)
// File path: C:\AggerSeguros\Gestor.Application.exe
//
// Product version: 0.0.0.0
// Exception in: System.Threading.Tasks.Task AbrirTarefa(Gestor.Model.Domain.Ferramentas.Tarefa)
//
// Collection was modified; enumeration operation may not execute.
// at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
// at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(IEnumerable collection) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 384
// at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.VisitBlockStatement(BlockStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 33
// at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.Process(DecompilationContext context, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 21
// at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100
// at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72
// at Telerik.JustDecompiler.Decompiler.Extensions.RunPipeline(DecompilationPipeline pipeline, ILanguage language, MethodBody body, DecompilationContext& context) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 95
// at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61
// at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 118
//
// mailto: JustDecompilePublicFeedback@telerik.com
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
this.Lista.ForEach((Analitico x) => x.set_Selecionado(!x.get_Selecionado()));
this.Grid.ItemsSource = null;
this.Grid.ItemsSource = this.Lista;
}
private void ConstruirLista()
{
this.ViewModel.Loading(true);
PropertyInfo[] properties = this.Lista.First<Analitico>().GetType().GetProperties();
this.Campos.ForEach((string x) => {
PropertyInfo propertyInfo = properties.FirstOrDefault<PropertyInfo>((PropertyInfo p) => p.Name == x);
if (propertyInfo == null)
{
return;
}
object obj = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault<object>();
string upper = propertyInfo.Name.ToUpper();
if (obj != null)
{
upper = ((DescriptionAttribute)obj).Description;
}
object obj1 = propertyInfo.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault<object>();
string description = "";
if (obj1 != null)
{
description = ((TipoAttribute)obj1).get_Description();
}
string str = "";
System.Windows.Style item = (System.Windows.Style)System.Windows.Application.Current.Resources["VerticalCenterStyle3"];
System.Windows.Style style = (System.Windows.Style)System.Windows.Application.Current.Resources["MaterialDesignDataGridColumnHeader"];
if (description == "DATA" || description == "DATA?")
{
str = "d";
item = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalCenterStyle2"];
style = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalCenterHeaderStyle"];
}
else if (description == "PERCENTUAL")
{
str = "{0:0.00}%";
item = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalRightStyle"];
style = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalRightHeaderStyle"];
}
else if (description == "VALOR" || description == "VALOR?")
{
str = "c";
item = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalRightStyle"];
style = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalRightHeaderStyle"];
}
else if (description == "QUANTIDADE")
{
item = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalCenterStyle2"];
style = (System.Windows.Style)System.Windows.Application.Current.Resources["HorizontalCenterHeaderStyle"];
}
this.Grid.Columns.Add(new MaterialDataGridTextColumn()
{
IsReadOnly = true,
Header = upper,
Binding = new Binding()
{
Path = new PropertyPath(propertyInfo.Name, Array.Empty<object>()),
StringFormat = str,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
},
ElementStyle = item,
HeaderStyle = style
});
});
this.Grid.ItemsSource = this.Lista;
this.Totalizar();
this.ViewModel.Loading(false);
}
private async void Email_OnClick(object sender, RoutedEventArgs e)
{
List<Analitico> lista = this.Lista;
if (lista.Any<Analitico>((Analitico x) => x.get_Selecionado()))
{
if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL"))
{
Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL");
}
List<Analitico> analiticos = this.Lista;
(new HosterWindow(new MalaDiretaView((
from x in analiticos
where x.get_Selecionado()
select x).Select<Analitico, MalaDireta>((Analitico x) => {
MalaDireta malaDiretum = new MalaDireta();
Cliente cliente = new Cliente();
cliente.set_Id(x.get_Cliente().get_Id());
cliente.set_Nome(x.get_Cliente().get_Nome());
cliente.set_Nascimento(x.get_Cliente().get_Nascimento());
cliente.set_VencimentoHabilitacao(x.get_Cliente().get_VencimentoCnh());
malaDiretum.set_Cliente(cliente);
malaDiretum.set_Apolice(x.get_Documento());
malaDiretum.set_Parcela(x.get_Parcela());
malaDiretum.set_Tela(this.ViewModel.Tela);
return malaDiretum;
}).ToList<MalaDireta>(), null, null, null), "ENVIO DE E-MAIL", new double?((double)1200), new double?((double)600), true)).Show();
}
else
{
await this.ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR", "OK", "", false);
}
}
private async void Grid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
double? nullable;
if (this.Grid.SelectedItem != null && (!(this.ViewModel.Tipo == "PARCELAS") || !(this.ViewModel.Tipo == "APOLICES")))
{
if (this.ViewModel.Tipo != "CLIENTES")
{
Analitico selectedItem = (Analitico)this.Grid.SelectedItem;
nullable = null;
double? nullable1 = nullable;
nullable = null;
(new HosterWindow(new ApoliceView(selectedItem.get_Documento(), true, false, 0, (long)0, false), string.Concat("CADASTRO DE APÓLICES - ", selectedItem.get_Cliente().get_Nome()), nullable1, nullable, false)).Show();
}
else
{
Analitico analitico = (Analitico)this.Grid.SelectedItem;
Cliente cliente = await this.ViewModel.CarregaCliente(analitico.get_Cliente().get_Id());
nullable = null;
double? nullable2 = nullable;
nullable = null;
(new HosterWindow(new ClienteView(cliente, true, null), string.Concat("CADASTRO DE CLIENTE - ", cliente.get_Nome()), nullable2, nullable, false)).Show();
}
}
}
[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/componentes/dialoganaliticobi.xaml", UriKind.Relative));
}
private async void Open_OnClick(object sender, RoutedEventArgs e)
{
double? nullable;
if (this.Grid.SelectedItem != null && (!(this.ViewModel.Tipo == "PARCELAS") || !(this.ViewModel.Tipo == "APOLICES")))
{
if (this.ViewModel.Tipo != "CLIENTES")
{
Analitico selectedItem = (Analitico)this.Grid.SelectedItem;
nullable = null;
double? nullable1 = nullable;
nullable = null;
(new HosterWindow(new ApoliceView(selectedItem.get_Documento(), true, false, 0, (long)0, false), string.Concat("CADASTRO DE APÓLICES - ", selectedItem.get_Cliente().get_Nome()), nullable1, nullable, false)).Show();
}
else
{
Analitico analitico = (Analitico)this.Grid.SelectedItem;
Cliente cliente = await this.ViewModel.CarregaCliente(analitico.get_Cliente().get_Id());
nullable = null;
double? nullable2 = nullable;
nullable = null;
(new HosterWindow(new ClienteView(cliente, true, null), string.Concat("CADASTRO DE CLIENTE - ", cliente.get_Nome()), nullable2, nullable, false)).Show();
}
}
}
private async void Print_OnClick(object sender, RoutedEventArgs e)
{
this.ViewModel.Loading(true);
await this.ViewModel.Print(this.Grid);
this.ViewModel.Loading(false);
}
[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.MainGrid = (System.Windows.Controls.Grid)target;
return;
}
case 2:
{
this.Grid = (DataGrid)target;
this.Grid.MouseDoubleClick += new MouseButtonEventHandler(this.Grid_OnMouseDoubleClick);
return;
}
case 3:
case 5:
{
this._contentLoaded = true;
return;
}
case 4:
{
this.InfoButton = (DataGridTemplateColumn)target;
return;
}
case 6:
{
this.Totalizacao = (TextBlock)target;
return;
}
case 7:
{
((MenuItem)target).Click += new RoutedEventHandler(this.Tarefas_OnClick);
return;
}
case 8:
{
((MenuItem)target).Click += new RoutedEventHandler(this.Email_OnClick);
return;
}
case 9:
{
((MenuItem)target).Click += new RoutedEventHandler(this.Print_OnClick);
return;
}
default:
{
this._contentLoaded = true;
return;
}
}
}
[DebuggerNonUserCode]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target)
{
if (connectionId != 3)
{
if (connectionId != 5)
{
return;
}
((Button)target).Click += new RoutedEventHandler(this.Open_OnClick);
return;
}
((CheckBox)target).Checked += new RoutedEventHandler(this.CheckBox_Checked);
((CheckBox)target).Unchecked += new RoutedEventHandler(this.CheckBox_Checked);
}
private async void Tarefas_OnClick(object sender, RoutedEventArgs e)
{
Tarefa tarefa = new Tarefa();
tarefa.set_Entidade(1);
tarefa.set_Titulo(this.ViewModel.Head);
tarefa.set_Usuario(Recursos.Usuario);
tarefa.set_Agendamento(Funcoes.GetNetworkTime());
await this.AbrirTarefa(tarefa);
List<Analitico> lista = this.Lista;
List<Analitico> list = (
from x in lista
where x.get_Selecionado()
select x).ToList<Analitico>();
this.Lista = this.Lista.Except<Analitico>(list).ToList<Analitico>();
this.Grid.ItemsSource = null;
this.Grid.ItemsSource = this.Lista;
this.Totalizar();
}
private void Totalizar()
{
string tipo = this.ViewModel.Tipo;
if (tipo == "CLIENTES")
{
this.Totalizacao.Text = string.Format("TOTAL DE {0} CLIENTES", this.Lista.Count);
return;
}
if (tipo == "PARCELAS")
{
this.Totalizacao.Text = string.Format("TOTAL DE {0} SEGUROS SOMANDO O VALOR DE {1:c}", this.Lista.Count, this.Lista.Sum<Analitico>((Analitico x) => x.get_Valor()));
return;
}
if (tipo == "COMISSÃO")
{
this.Totalizacao.Text = string.Format("TOTAL DE {0} SEGUROS SOMANDO O VALOR DE COMISSÃO RECEBIDA DE {1:c}", this.Lista.Count, this.Lista.Sum<Analitico>((Analitico x) => x.get_ValorComissao()));
return;
}
this.Totalizacao.Text = string.Format("TOTAL DE {0} SEGUROS SOMANDO O VALOR DE {1:c}", this.Lista.Count, this.Lista.Sum<Analitico>((Analitico x) => x.get_PremioLiquido()));
}
}
}
|