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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
|
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
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;
using Gestor.Application.Helpers;
using Gestor.Application.ViewModels;
using Gestor.Application.Views.Ferramentas;
using Gestor.Application.Views.Generic;
using Gestor.Application.Views.Seguros;
using Gestor.Model.Attributes;
using Gestor.Model.Common;
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.Seguros;
using MaterialDesignThemes.Wpf;
namespace Gestor.Application.Componentes;
public class DialogAnaliticoBi : BaseUserControl, IComponentConnector, IStyleConnector
{
internal AnaliticoViewModel ViewModel;
internal Grid MainGrid;
internal DataGrid Grid;
internal DataGridTemplateColumn InfoButton;
internal TextBlock Totalizacao;
private bool _contentLoaded;
public List<Analitico> Lista { get; set; }
public List<string> Campos { get; set; }
public DialogAnaliticoBi(string titulo, List<Analitico> analitico, string tipo, List<string> campos)
{
ViewModel = new AnaliticoViewModel(tipo);
((FrameworkElement)this).DataContext = ViewModel;
InitializeComponent();
ViewModel.Head = titulo;
Lista = analitico;
Campos = campos;
ConstruirLista();
}
private void ConstruirLista()
{
ViewModel.Loading(isLoading: true);
PropertyInfo[] properties = ((object)Lista.First()).GetType().GetProperties();
Campos.ForEach(delegate(string x)
{
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Expected O, but got Unknown
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Expected O, but got Unknown
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Expected O, but got Unknown
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Expected O, but got Unknown
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Expected O, but got Unknown
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Expected O, but got Unknown
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Expected O, but got Unknown
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Expected O, but got Unknown
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Expected O, but got Unknown
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Expected O, but got Unknown
PropertyInfo propertyInfo = properties.FirstOrDefault((PropertyInfo p) => p.Name == x);
if (!(propertyInfo == null))
{
object obj = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), inherit: true).FirstOrDefault();
string header = propertyInfo.Name.ToUpper();
if (obj != null)
{
header = ((DescriptionAttribute)obj).Description;
}
object obj2 = propertyInfo.GetCustomAttributes(typeof(TipoAttribute), inherit: true).FirstOrDefault();
string text = "";
if (obj2 != null)
{
text = ((TipoAttribute)obj2).Description;
}
string stringFormat = "";
Style elementStyle = (Style)Application.Current.Resources[(object)"VerticalCenterStyle3"];
Style headerStyle = (Style)Application.Current.Resources[(object)"MaterialDesignDataGridColumnHeader"];
switch (text)
{
case "DATA":
case "DATA?":
stringFormat = "d";
elementStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterStyle2"];
headerStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterHeaderStyle"];
break;
case "PERCENTUAL":
stringFormat = "{0:0.00}%";
elementStyle = (Style)Application.Current.Resources[(object)"HorizontalRightStyle"];
headerStyle = (Style)Application.Current.Resources[(object)"HorizontalRightHeaderStyle"];
break;
case "VALOR":
case "VALOR?":
stringFormat = "c";
elementStyle = (Style)Application.Current.Resources[(object)"HorizontalRightStyle"];
headerStyle = (Style)Application.Current.Resources[(object)"HorizontalRightHeaderStyle"];
break;
case "QUANTIDADE":
elementStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterStyle2"];
headerStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterHeaderStyle"];
break;
}
Grid.Columns.Add((DataGridColumn)new MaterialDataGridTextColumn
{
IsReadOnly = true,
Header = header,
Binding = (BindingBase)new Binding
{
Path = new PropertyPath(propertyInfo.Name, Array.Empty<object>()),
StringFormat = stringFormat,
UpdateSourceTrigger = (UpdateSourceTrigger)1
},
ElementStyle = elementStyle,
HeaderStyle = headerStyle
});
}
});
((ItemsControl)Grid).ItemsSource = Lista;
Totalizar();
ViewModel.Loading(isLoading: false);
}
private void Totalizar()
{
switch (ViewModel.Tipo)
{
case "CLIENTES":
Totalizacao.Text = $"TOTAL DE {Lista.Count} CLIENTES";
break;
default:
Totalizacao.Text = $"TOTAL DE {Lista.Count} SEGUROS SOMANDO O VALOR DE {Lista.Sum((Analitico x) => x.PremioLiquido):c}";
break;
case "PARCELAS":
Totalizacao.Text = $"TOTAL DE {Lista.Count} SEGUROS SOMANDO O VALOR DE {Lista.Sum((Analitico x) => x.Valor):c}";
break;
case "COMISSÃO":
Totalizacao.Text = $"TOTAL DE {Lista.Count} SEGUROS SOMANDO O VALOR DE COMISSÃO RECEBIDA DE {Lista.Sum((Analitico x) => x.ValorComissao):c}";
break;
}
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
Lista.ForEach(delegate(Analitico x)
{
x.Selecionado = !x.Selecionado;
});
((ItemsControl)Grid).ItemsSource = null;
((ItemsControl)Grid).ItemsSource = Lista;
}
private async void Tarefas_OnClick(object sender, RoutedEventArgs e)
{
Tarefa data = new Tarefa
{
Entidade = (TipoTarefa)1,
Titulo = ViewModel.Head,
Usuario = Recursos.Usuario,
Agendamento = Funcoes.GetNetworkTime()
};
await AbrirTarefa(data);
List<Analitico> second = Lista.Where((Analitico x) => x.Selecionado).ToList();
Lista = Lista.Except(second).ToList();
((ItemsControl)Grid).ItemsSource = null;
((ItemsControl)Grid).ItemsSource = Lista;
Totalizar();
}
private async Task AbrirTarefa(Tarefa data)
{
ViewModel.Loading(isLoading: true);
Tarefa tarefa;
while (true)
{
tarefa = await ViewModel.ShowTarefaDialog(data, nota: true);
List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
if (tarefa == null)
{
ViewModel.Loading(isLoading: false);
return;
}
tarefa.AgendamentoRetroativo = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 45);
List<KeyValuePair<string, string>> list2 = tarefa.Validate();
if (list2 == null || list2.Count == 0)
{
break;
}
if (list2.Count > 0)
{
list.AddRange(list2);
}
await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK");
}
if (tarefa.Usuario == null)
{
tarefa.Usuario = tarefa.UsuariosVinculados.FirstOrDefault();
}
List<ResponsavelTarefa> responsaveis = ((IEnumerable<Usuario>)tarefa.UsuariosVinculados).Select((Func<Usuario, ResponsavelTarefa>)((Usuario x) => new ResponsavelTarefa
{
IdTarefa = ((DomainBase)tarefa).Id,
Usuario = x
})).ToList();
List<Analitico> source = Lista.Where((Analitico x) => x.Selecionado).ToList();
List<Tarefa> list3;
switch (ViewModel.Tipo)
{
case "CLIENTES":
list3 = ((IEnumerable<Analitico>)source).Select((Func<Analitico, Tarefa>)((Analitico x) => new Tarefa
{
Entidade = (TipoTarefa)2,
IdEntidade = x.Cliente.Id,
Agendamento = tarefa.Agendamento,
Titulo = tarefa.Titulo,
Descricao = tarefa.Anotacoes,
Usuario = tarefa.Usuario,
UsuarioCadastro = Recursos.Usuario,
Cliente = x.Nome,
IdCliente = x.Cliente.Id,
Responsaveis = responsaveis
})).ToList();
break;
default:
list3 = ((IEnumerable<Analitico>)source).Select((Func<Analitico, Tarefa>)((Analitico x) => new Tarefa
{
Entidade = (TipoTarefa)0,
IdEntidade = ((DomainBase)x.Documento).Id,
Agendamento = tarefa.Agendamento,
Titulo = tarefa.Titulo,
Descricao = tarefa.Anotacoes,
Usuario = tarefa.Usuario,
UsuarioCadastro = Recursos.Usuario,
Cliente = x.Nome,
IdCliente = ((DomainBase)x.Documento.Controle.Cliente).Id,
Referencia = ((x.Documento.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Documento.Apolice)) ? ("APÓLICE NÚMERO " + x.Documento.Apolice) : ((x.Documento.Tipo > 0) ? ("APÓLICE NÚMERO " + x.Documento.Apolice + " ENDOSSO " + x.Documento.Endosso) : ("PROPOSTA NÚMERO " + x.Documento.Proposta))),
Responsaveis = responsaveis
})).ToList();
break;
case "PARCELAS":
case "COMISSÃO":
list3 = ((IEnumerable<Analitico>)source).Select((Func<Analitico, Tarefa>)((Analitico x) => new Tarefa
{
Entidade = (TipoTarefa)3,
IdEntidade = ((DomainBase)x.Parcela).Id,
Agendamento = tarefa.Agendamento,
Titulo = tarefa.Titulo,
Descricao = tarefa.Anotacoes,
Usuario = tarefa.Usuario,
UsuarioCadastro = Recursos.Usuario,
Cliente = x.Nome,
IdCliente = ((DomainBase)x.Parcela.Documento.Controle.Cliente).Id,
Referencia = ((x.Parcela.Documento.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Parcela.Documento.Apolice)) ? $"PARCELA {x.NumeroParcela} DA APÓLICE {x.Parcela.Documento.Apolice}" : ((x.Documento.Tipo > 0) ? $"PARCELA {x.NumeroParcela} DA APÓLICE {x.Parcela.Documento.Apolice} ENDOSSO {x.Parcela.Documento.Endosso}" : $"PARCELA {x.NumeroParcela} DA PROPOSTA {x.Parcela.Documento.Proposta}")),
Responsaveis = responsaveis
})).ToList();
break;
}
if (list3.Count == 0)
{
ViewModel.Loading(isLoading: false);
await ViewModel.ShowMessage("FALHA AO CRIAR TAREFA.");
return;
}
await ViewModel.Save(list3);
ViewModel.ToggleSnackBar("TAREFA SALVA COM SUCESSO.");
ViewModel.Alterar(alterar: false);
ViewModel.Loading(isLoading: false);
}
private async void Email_OnClick(object sender, RoutedEventArgs e)
{
if (!Lista.Any((Analitico x) => x.Selecionado))
{
await ViewModel.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM CLIENTE PARA PROSSEGUIR");
return;
}
if (Funcoes.IsWindowOpen<HosterWindow>("ENVIO DE E-MAIL"))
{
Funcoes.Destroy<HosterWindow>("ENVIO DE E-MAIL");
}
((Window)new HosterWindow((ContentControl)(object)new MalaDiretaView(Lista.Where((Analitico x) => x.Selecionado).Select((Func<Analitico, MalaDireta>)((Analitico x) => new MalaDireta
{
Cliente = new Cliente
{
Id = x.Cliente.Id,
Nome = x.Cliente.Nome,
Nascimento = x.Cliente.Nascimento,
VencimentoHabilitacao = x.Cliente.VencimentoCnh
},
Apolice = x.Documento,
Parcela = x.Parcela,
Tela = ViewModel.Tela
})).ToList()), "ENVIO DE E-MAIL", 1200.0, 600.0, canMaximize: true)).Show();
}
private async void Grid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (((Selector)Grid).SelectedItem != null && (!(ViewModel.Tipo == "PARCELAS") || !(ViewModel.Tipo == "APOLICES")))
{
if (ViewModel.Tipo == "CLIENTES")
{
Analitico val = (Analitico)((Selector)Grid).SelectedItem;
Cliente val2 = await ViewModel.CarregaCliente(val.Cliente.Id);
((Window)new HosterWindow((ContentControl)(object)new ClienteView(val2, lockInsert: true), "CADASTRO DE CLIENTE - " + val2.Nome)).Show();
}
else
{
Analitico val3 = (Analitico)((Selector)Grid).SelectedItem;
((Window)new HosterWindow((ContentControl)(object)new ApoliceView(val3.Documento, lockInsert: true, invoke: false, (AcessoApolice)0, 0L), "CADASTRO DE APÓLICES - " + val3.Cliente.Nome)).Show();
}
}
}
private async void Print_OnClick(object sender, RoutedEventArgs e)
{
ViewModel.Loading(isLoading: true);
await ViewModel.Print(Grid);
ViewModel.Loading(isLoading: false);
}
private async void Open_OnClick(object sender, RoutedEventArgs e)
{
if (((Selector)Grid).SelectedItem != null && (!(ViewModel.Tipo == "PARCELAS") || !(ViewModel.Tipo == "APOLICES")))
{
if (ViewModel.Tipo == "CLIENTES")
{
Analitico val = (Analitico)((Selector)Grid).SelectedItem;
Cliente val2 = await ViewModel.CarregaCliente(val.Cliente.Id);
((Window)new HosterWindow((ContentControl)(object)new ClienteView(val2, lockInsert: true), "CADASTRO DE CLIENTE - " + val2.Nome)).Show();
}
else
{
Analitico val3 = (Analitico)((Selector)Grid).SelectedItem;
((Window)new HosterWindow((ContentControl)(object)new ApoliceView(val3.Documento, lockInsert: true, invoke: false, (AcessoApolice)0, 0L), "CADASTRO DE APÓLICES - " + val3.Cliente.Nome)).Show();
}
}
}
[DebuggerNonUserCode]
[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent()
{
if (!_contentLoaded)
{
_contentLoaded = true;
Uri uri = new Uri("/Gestor.Application;component/componentes/dialoganaliticobi.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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Expected O, but got Unknown
switch (connectionId)
{
case 1:
MainGrid = (Grid)target;
break;
case 2:
Grid = (DataGrid)target;
((Control)Grid).MouseDoubleClick += new MouseButtonEventHandler(Grid_OnMouseDoubleClick);
break;
case 4:
InfoButton = (DataGridTemplateColumn)target;
break;
case 6:
Totalizacao = (TextBlock)target;
break;
case 7:
((MenuItem)target).Click += new RoutedEventHandler(Tarefas_OnClick);
break;
case 8:
((MenuItem)target).Click += new RoutedEventHandler(Email_OnClick);
break;
case 9:
((MenuItem)target).Click += new RoutedEventHandler(Print_OnClick);
break;
default:
_contentLoaded = true;
break;
}
}
[DebuggerNonUserCode]
[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
[EditorBrowsable(EditorBrowsableState.Never)]
void IStyleConnector.Connect(int connectionId, object target)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
switch (connectionId)
{
case 3:
((ToggleButton)(CheckBox)target).Checked += new RoutedEventHandler(CheckBox_Checked);
((ToggleButton)(CheckBox)target).Unchecked += new RoutedEventHandler(CheckBox_Checked);
break;
case 5:
((ButtonBase)(Button)target).Click += new RoutedEventHandler(Open_OnClick);
break;
}
}
}
|