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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
|
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Threading;
using Assinador.Infrastructure.Helpers;
using ClosedXML.Excel;
using Gestor.Application.Actions;
using Gestor.Application.Helpers;
using Gestor.Application.Model;
using Gestor.Application.Servicos;
using Gestor.Application.Servicos.Ferramentas;
using Gestor.Application.Servicos.Generic;
using Gestor.Application.Servicos.Seguros;
using Gestor.Application.Servicos.Seguros.Itens;
using Gestor.Application.ViewModels.Generic;
using Gestor.Model.API;
using Gestor.Model.Common;
using Gestor.Model.Domain.Common;
using Gestor.Model.Domain.Configuracoes;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;
namespace Gestor.Application.ViewModels.Seguros;
public class ConsultaViewModel : BaseSegurosViewModel
{
private readonly ApoliceServico _apoliceServico;
private readonly ParcelaServico _parcelaServico;
private readonly ItemServico _itemServico;
private readonly VendedorServico _vendedorServico;
public bool UpdatingScroll;
public static Parcela ParcelaSelecionada;
public static Item ItemSelecionado;
private static Documento _documentoSelecionado;
private bool _apelido;
private Visibility _semDocumentos = (Visibility)2;
private Cliente _selectedCliente = new Cliente();
private bool _carregando;
private bool _isLoading;
private Visibility _visibilityParcelasVendedores;
private ObservableCollection<Documento> _apolices = new ObservableCollection<Documento>();
private ObservableCollection<Documento> _endossos = new ObservableCollection<Documento>();
private Documento _selectedEndosso = new Documento();
private string _parcelasLabel = "PARCELAS";
private Documento _selectedControle = new Documento();
private bool _isFatura;
private bool _isEnabledParcelaItem = true;
private Item _selectedItem = new Item();
private ObservableCollection<Item> _itens = new ObservableCollection<Item>();
private Parcela _selectedParcela = new Parcela();
private ObservableCollection<Parcela> _parcelas = new ObservableCollection<Parcela>();
private Visibility _isVisibleRadioEndosso = (Visibility)2;
private Visibility _isVisibleEndosso = (Visibility)2;
private Visibility _isVisibleApolice;
private string _pendenciaApolice = "";
private Visibility _isVisiblePendenciaApolice = (Visibility)2;
private decimal _gerada;
private decimal _recebida;
private decimal _pendente;
private bool _isLoadingParcelas = true;
private bool _isLoadingItens = true;
private int _filterItens;
private int _filterDocumento;
private Visibility _manutencaoItemVisibility;
private Visibility _recusaVisibility;
private Visibility _renovarVisibility;
private Visibility _endossarVisibility;
private Visibility _trocarClienteVisibility;
private Visibility _tarefasVisibility;
private Visibility _comissaoVisibility;
private Visibility _comissaoValorVisibility;
private Visibility _mostrarItensVisibility = (Visibility)2;
private Visibility _mostrarSinistroVisibility;
private ObservableCollection<ClienteTelefone> _telefones = new ObservableCollection<ClienteTelefone>();
public static Documento DocumentoSelecionado
{
get
{
return _documentoSelecionado;
}
set
{
_documentoSelecionado = value;
Gestor.Application.Actions.Actions.EnableItens?.Invoke(value != null && ((DomainBase)value).Id > 0);
Gestor.Application.Actions.Actions.EnableDocumento?.Invoke(value != null && ((DomainBase)value).Id > 0);
}
}
public static Documento DocumentoRenovado { get; set; }
public bool Apelido
{
get
{
return _apelido;
}
set
{
_apelido = value;
OnPropertyChanged("Apelido");
}
}
public bool Pesquisando { get; set; }
public Visibility SemDocumentos
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _semDocumentos;
}
set
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
_semDocumentos = value;
OnPropertyChanged("SemDocumentos");
}
}
public Cliente SelectedCliente
{
get
{
return _selectedCliente;
}
set
{
_selectedCliente = value;
OnPropertyChanged("SelectedCliente");
}
}
public bool Carregando
{
get
{
return _carregando;
}
set
{
_carregando = value;
SemDocumentos = (Visibility)((value || (Apolices != null && Apolices.Count != 0)) ? 2 : 0);
}
}
public bool IsLoading
{
get
{
return _isLoading;
}
set
{
_isLoading = value;
OnPropertyChanged("IsLoading");
}
}
public Visibility VisibilityParcelasVendedores
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _visibilityParcelasVendedores;
}
set
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
_visibilityParcelasVendedores = value;
OnPropertyChanged("VisibilityParcelasVendedores");
}
}
public ObservableCollection<Documento> Apolices
{
get
{
return _apolices;
}
set
{
_apolices = value;
OnPropertyChanged("Apolices");
}
}
public ObservableCollection<Documento> Endossos
{
get
{
return _endossos;
}
set
{
_endossos = value;
OnPropertyChanged("Endossos");
}
}
public Documento SelectedEndosso
{
get
{
return _selectedEndosso;
}
set
{
_selectedEndosso = value;
WorkOnSelectedDocumento(value);
OnPropertyChanged("SelectedEndosso");
}
}
public string ParcelasLabel
{
get
{
return _parcelasLabel;
}
set
{
_parcelasLabel = value;
OnPropertyChanged("ParcelasLabel");
}
}
public Documento SelectedControle
{
get
{
return _selectedControle;
}
set
{
_selectedControle = value;
int enableButtons;
if (value != null && ((DomainBase)value).Id > 0)
{
Usuario usuario = Recursos.Usuario;
enableButtons = ((usuario != null && ((DomainBase)usuario).Id > 0) ? 1 : 0);
}
else
{
enableButtons = 0;
}
base.EnableButtons = (byte)enableButtons != 0;
bool flag = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 13);
base.EnableEndossar = value != null && ((DomainBase)value).Id > 0 && (flag || (!string.IsNullOrWhiteSpace(value.Apolice) && !string.IsNullOrWhiteSpace(value.Proposta) && value.Emissao.HasValue));
base.EnableRenovar = value != null && ((DomainBase)value).Id > 0 && value.Vigencia2.HasValue && !string.IsNullOrWhiteSpace(value.Apolice);
WorkOnSelectedDocumento(value);
RecusaVisibility = (Visibility)((Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 19) && !string.IsNullOrWhiteSpace((value != null) ? value.Apolice : null) && value.Emissao.HasValue) ? 2 : 0);
ItensRevelados = false;
MostrarItensVisibility = (Visibility)2;
MostrarSinistroVisibility = (Visibility)0;
OnPropertyChanged("SelectedControle");
}
}
public bool IsFatura
{
get
{
return _isFatura;
}
set
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
if (!value)
{
value = (int)ComissaoValorVisibility == 2;
}
_isFatura = value;
OnPropertyChanged("IsFatura");
}
}
public bool Recarregando { get; set; }
public bool IsEnabledParcelaItem
{
get
{
return _isEnabledParcelaItem;
}
set
{
_isEnabledParcelaItem = value;
OnPropertyChanged("IsEnabledParcelaItem");
}
}
public Item SelectedItem
{
get
{
return _selectedItem;
}
set
{
_selectedItem = value;
WorkOnSelectedItem(value);
OnPropertyChanged("SelectedItem");
}
}
public ObservableCollection<Item> Itens
{
get
{
return _itens;
}
set
{
_itens = value;
OnPropertyChanged("Itens");
}
}
public Parcela SelectedParcela
{
get
{
return _selectedParcela;
}
set
{
_selectedParcela = value;
OnPropertyChanged("SelectedParcela");
}
}
public ObservableCollection<Parcela> Parcelas
{
get
{
return _parcelas;
}
set
{
_parcelas = value;
OnPropertyChanged("Parcelas");
}
}
public Visibility IsVisibleRadioEndosso
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _isVisibleRadioEndosso;
}
set
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
_isVisibleRadioEndosso = value;
OnPropertyChanged("IsVisibleRadioEndosso");
}
}
public Visibility IsVisibleEndosso
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _isVisibleEndosso;
}
set
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
_isVisibleEndosso = value;
OnPropertyChanged("IsVisibleEndosso");
}
}
public Visibility IsVisibleApolice
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _isVisibleApolice;
}
set
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
_isVisibleApolice = value;
OnPropertyChanged("IsVisibleApolice");
}
}
public string PendenciaApolice
{
get
{
return _pendenciaApolice;
}
set
{
_pendenciaApolice = value;
IsVisiblePendenciaApolice = (Visibility)(string.IsNullOrEmpty(_pendenciaApolice) ? 2 : 0);
OnPropertyChanged("PendenciaApolice");
}
}
public Visibility IsVisiblePendenciaApolice
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _isVisiblePendenciaApolice;
}
set
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
_isVisiblePendenciaApolice = value;
OnPropertyChanged("IsVisiblePendenciaApolice");
}
}
public decimal Gerada
{
get
{
return _gerada;
}
set
{
_gerada = value;
OnPropertyChanged("Gerada");
}
}
public decimal Recebida
{
get
{
return _recebida;
}
set
{
_recebida = value;
OnPropertyChanged("Recebida");
}
}
public decimal Pendente
{
get
{
return _pendente;
}
set
{
_pendente = value;
OnPropertyChanged("Pendente");
}
}
public bool IsLoadingParcelas
{
get
{
return _isLoadingParcelas;
}
set
{
_isLoadingParcelas = value;
OnPropertyChanged("IsLoadingParcelas");
}
}
public bool IsLoadingItens
{
get
{
return _isLoadingItens;
}
set
{
_isLoadingItens = value;
OnPropertyChanged("IsLoadingItens");
}
}
public static int FiltrarItens { get; set; }
public int FilterItens
{
get
{
return _filterItens;
}
set
{
_filterItens = value;
FiltrarItens = value;
OnPropertyChanged("FilterItens");
}
}
public int FilterDocumento
{
get
{
return _filterDocumento;
}
set
{
_filterDocumento = value;
Gestor.Application.Actions.Actions.UpdateRadioApolice?.Invoke(_filterDocumento);
OnPropertyChanged("FilterDocumento");
}
}
public Visibility ManutencaoItemVisibility
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _manutencaoItemVisibility;
}
set
{
//IL_000e: 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)
_manutencaoItemVisibility = (Visibility)(Restricao((TipoRestricao)22) ? 2 : ((int)value));
OnPropertyChanged("ManutencaoItemVisibility");
}
}
public Visibility RecusaVisibility
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _recusaVisibility;
}
set
{
//IL_000e: 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)
_recusaVisibility = (Visibility)(Restricao((TipoRestricao)18) ? 2 : ((int)value));
OnPropertyChanged("RecusaVisibility");
}
}
public Visibility RenovarVisibility
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _renovarVisibility;
}
set
{
//IL_000e: 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)
_renovarVisibility = (Visibility)(Restricao((TipoRestricao)17) ? 2 : ((int)value));
OnPropertyChanged("RenovarVisibility");
}
}
public Visibility EndossarVisibility
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _endossarVisibility;
}
set
{
//IL_000e: 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)
_endossarVisibility = (Visibility)(Restricao((TipoRestricao)33) ? 2 : ((int)value));
OnPropertyChanged("EndossarVisibility");
}
}
public Visibility TrocarClienteVisibility
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _trocarClienteVisibility;
}
set
{
//IL_000e: 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)
_trocarClienteVisibility = (Visibility)(Restricao((TipoRestricao)21) ? 2 : ((int)value));
OnPropertyChanged("TrocarClienteVisibility");
}
}
public Visibility TarefasVisibility
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _tarefasVisibility;
}
set
{
//IL_000e: 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)
_tarefasVisibility = (Visibility)((!Permissao((TipoTela)38)) ? 2 : ((int)value));
OnPropertyChanged("TarefasVisibility");
}
}
public Visibility ComissaoVisibility
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _comissaoVisibility;
}
set
{
//IL_000e: 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)
_comissaoVisibility = (Visibility)(Restricao((TipoRestricao)95) ? 2 : ((int)value));
OnPropertyChanged("ComissaoVisibility");
}
}
public Visibility ComissaoValorVisibility
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _comissaoValorVisibility;
}
set
{
//IL_000e: 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)
_comissaoValorVisibility = (Visibility)(Restricao((TipoRestricao)14) ? 2 : ((int)value));
OnPropertyChanged("ComissaoValorVisibility");
}
}
public Visibility MostrarItensVisibility
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _mostrarItensVisibility;
}
set
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
_mostrarItensVisibility = value;
OnPropertyChanged("MostrarItensVisibility");
}
}
public Visibility MostrarSinistroVisibility
{
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return _mostrarSinistroVisibility;
}
set
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
_mostrarSinistroVisibility = value;
OnPropertyChanged("MostrarSinistroVisibility");
}
}
public bool ItensRevelados { get; set; }
public ObservableCollection<ClienteTelefone> Telefones
{
get
{
return _telefones;
}
set
{
_telefones = value;
OnPropertyChanged("Telefones");
}
}
public ConsultaViewModel()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
_apoliceServico = new ApoliceServico();
_parcelaServico = new ParcelaServico();
_vendedorServico = new VendedorServico();
_itemServico = new ItemServico();
Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 6);
SemDocumentos = (Visibility)0;
base.EnableButtons = false;
if (MainViewModel.ClienteSelecionado != null && ((DomainBase)MainViewModel.ClienteSelecionado).Id > 0)
{
SelecionarCliente(MainViewModel.ClienteSelecionado);
}
}
public async Task Pesquisar(PesquisaAvancada pesquisa)
{
MainViewModel.StatusSelecionado = pesquisa.Status;
if (pesquisa.IdDocumento == 0L)
{
await SelecionarCliente(pesquisa.IdCliente, selecionar: true);
return;
}
Pesquisando = true;
await SelecionarCliente(pesquisa.IdCliente, selecionar: false);
Loading(isLoading: true);
Documento documento = await _apoliceServico.BuscarApoliceAsync(pesquisa.IdDocumento);
if (documento == null || Apolices.Count == 0 || Apolices == null)
{
Pesquisando = false;
Loading(isLoading: false);
return;
}
Documento val = ((IEnumerable<Documento>)Apolices).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x.Controle).Id == ((DomainBase)documento.Controle).Id));
if (val == null && documento.Tipo == 1)
{
val = documento;
val.TemEndosso = true;
if (val == null)
{
Pesquisando = false;
Loading(isLoading: false);
return;
}
}
SelectedControle = val;
IsVisibleApolice = (Visibility)0;
VisibilityParcelasVendedores = (Visibility)2;
DateTime date = Funcoes.GetNetworkTime().Date;
PendenciaApolice = (string.IsNullOrEmpty(val.Apolice) ? $"{(date - val.Vigencia1).TotalDays} DIAS DE PENDÊNCIA" : "");
IsVisibleRadioEndosso = (Visibility)((!val.TemEndosso) ? 2 : 0);
if (val.TemEndosso)
{
IsVisibleRadioEndosso = (Visibility)0;
Endossos = new ObservableCollection<Documento>(val.Controle.Documentos.Where((Documento x) => x.Tipo == 1 && !x.Excluido));
}
if (documento.Tipo == 1)
{
documento = Endossos.First((Documento x) => ((DomainBase)x).Id == ((DomainBase)documento).Id);
FilterDocumento = 1;
IsVisibleEndosso = (Visibility)0;
SelectedEndosso = documento;
PendenciaApolice = (string.IsNullOrEmpty(documento.Endosso) ? $"{(date - documento.Vigencia1).TotalDays} DIAS DE PENDÊNCIA" : "");
}
CarregaDocumentos(documento.Tipo);
await SelecionaParcelas(documento);
VisibilityParcelasVendedores = (Visibility)0;
Pesquisando = false;
if (pesquisa.IdItem == 0L)
{
await SelecionaItens((documento.Tipo == 0) ? 1 : 2, documento, 0L);
Loading(isLoading: false);
return;
}
await SelecionaItens((documento.Tipo == 0) ? 1 : 2, documento, pesquisa.IdItem, pesquisaAvancada: true);
SelecionaItem(((IEnumerable<Item>)Itens).FirstOrDefault((Func<Item, bool>)((Item x) => ((DomainBase)x).Id == pesquisa.IdItem)));
Loading(isLoading: false);
if (pesquisa.IdSinistro != 0L)
{
Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)7, "");
}
}
public async void SelecionarCliente(Cliente cliente)
{
await SelecionaCliente(cliente);
ScrollDocumento();
}
public void ScrollDocumento()
{
if (UpdatingScroll)
{
return;
}
UpdatingScroll = true;
Task.Run(async delegate
{
await Task.Delay(300);
((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate
{
Gestor.Application.Actions.Actions.ScrollDocumento?.Invoke();
});
});
}
public async Task SelecionarCliente(long id, bool selecionar)
{
await SelecionaCliente(await new ClienteServico().BuscarCliente(id), selecionar);
}
public async Task SelecionaCliente(Cliente value, bool selecionar = true)
{
Clear();
if (value == null || ((DomainBase)value).Id == 0L)
{
base.IsVisible = (Visibility)2;
return;
}
try
{
Carregando = true;
Loading(isLoading: true);
SelectedCliente = value;
ApoliceServico apoliceServico = _apoliceServico;
long id = ((DomainBase)value).Id;
FiltroStatusDocumento statusSelecionado = MainViewModel.StatusSelecionado;
List<VendedorUsuario> vendedorVinculado = ((Recursos.Usuario != null) ? (await VerificaVinculoVendedor(Recursos.Usuario)) : new List<VendedorUsuario>());
Apolices = await apoliceServico.BuscarApolicesAsync(id, statusSelecionado, vendedorVinculado);
ConsultaViewModel consultaViewModel = this;
string descricao = "CONSULTOU " + (((int)MainViewModel.StatusSelecionado != 4) ? ("OS " + Functions.GetDescription((Enum)(object)MainViewModel.StatusSelecionado)) : "TODOS OS DOCUMENTOS") + " DO CLIENTE \"" + SelectedCliente.Nome + "\"";
long id2 = ((DomainBase)SelectedCliente).Id;
TipoTela? tela = (TipoTela)21;
Cliente selectedCliente = SelectedCliente;
consultaViewModel.RegistrarAcao(descricao, id2, tela, $"ID CLIENTE: {((selectedCliente != null) ? new long?(((DomainBase)selectedCliente).Id) : null)}");
if (Apolices != null && Apolices.Count > 0)
{
if (!selecionar)
{
Loading(isLoading: false);
Carregando = false;
return;
}
if (DocumentoSelecionado != null && DocumentoSelecionado.Tipo != 0)
{
Controle controle = DocumentoSelecionado.Controle;
long? obj;
if (controle == null)
{
obj = null;
}
else
{
Cliente cliente = controle.Cliente;
obj = ((cliente != null) ? new long?(((DomainBase)cliente).Id) : null);
}
if (obj == ((DomainBase)value).Id)
{
Controle controle2 = DocumentoSelecionado.Controle;
long? obj2;
if (controle2 == null)
{
obj2 = null;
}
else
{
IList<Documento> documentos = controle2.Documentos;
if (documentos == null)
{
obj2 = null;
}
else
{
Documento? obj3 = ((IEnumerable<Documento>)documentos).FirstOrDefault((Func<Documento, bool>)((Documento x) => x.Tipo == 0));
obj2 = ((obj3 != null) ? new long?(((DomainBase)obj3).Id) : null);
}
}
long? num = obj2;
long documentId = num.GetValueOrDefault();
Documento documentoSelecionado = DocumentoSelecionado;
long? endossoId = ((documentoSelecionado != null) ? new long?(((DomainBase)documentoSelecionado).Id) : null);
if (((documentId > 0) ? ((IEnumerable<Documento>)Apolices).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == documentId)) : null) != null)
{
await SelecionaDocumento(0, ((IEnumerable<Documento>)Apolices).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == documentId)));
FilterDocumento = 1;
IsVisibleEndosso = (Visibility)0;
SelectedEndosso = ((IEnumerable<Documento>)Endossos).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == endossoId)) ?? Endossos[0];
IsLoading = false;
await WorkOnSelectedEndosso(SelectedEndosso);
CarregaDocumentos(1);
}
else
{
await SelecionaDocumento(0, (DocumentoSelecionado != null) ? (((IEnumerable<Documento>)Apolices).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == ((DomainBase)DocumentoSelecionado).Id)) ?? Apolices.FirstOrDefault()) : Apolices.FirstOrDefault());
CarregaDocumentos(0);
}
goto IL_06af;
}
}
await SelecionaDocumento(0, (DocumentoSelecionado != null) ? (((IEnumerable<Documento>)Apolices).FirstOrDefault((Func<Documento, bool>)((Documento x) => ((DomainBase)x).Id == ((DomainBase)DocumentoSelecionado).Id)) ?? Apolices.FirstOrDefault()) : Apolices.FirstOrDefault());
CarregaDocumentos(0);
}
else
{
SelectedControle = null;
SelectedEndosso = null;
SelectedItem = null;
SelectedParcela = null;
DocumentoSelecionado = null;
ItemSelecionado = null;
FilterDocumento = 0;
IsVisibleRadioEndosso = (Visibility)2;
Gestor.Application.Actions.Actions.UpdateDocumento?.Invoke(null);
}
goto IL_06af;
IL_06af:
ManutencaoItemVisibility = (Visibility)0;
RenovarVisibility = (Visibility)0;
TrocarClienteVisibility = (Visibility)0;
TarefasVisibility = (Visibility)0;
EndossarVisibility = (Visibility)0;
ComissaoVisibility = (Visibility)0;
Loading(isLoading: false);
}
catch (Exception e)
{
Clear();
SelectedControle = null;
SelectedEndosso = null;
SelectedItem = null;
SelectedParcela = null;
DocumentoSelecionado = null;
ItemSelecionado = null;
FilterDocumento = 0;
IsVisibleRadioEndosso = (Visibility)2;
Gestor.Application.Actions.Actions.UpdateDocumento?.Invoke(null);
new BaseServico().Registrar(e, (TipoErro)1, 3, new { value, selecionar });
}
Carregando = false;
}
private void Clear()
{
Apolices = null;
Parcelas = null;
Itens = null;
}
private async Task WorkOnSelectedEndosso(Documento value)
{
if (value == null || ((DomainBase)value).Id == 0L || IsLoading)
{
return;
}
DocumentoSelecionado = value;
base.IsEnabled = false;
IsLoading = true;
VisibilityParcelasVendedores = (Visibility)2;
PendenciaApolice = (string.IsNullOrEmpty(value.Endosso) ? $"{(Funcoes.GetNetworkTime().Date - value.Vigencia1).TotalDays} DIAS DE PENDÊNCIA" : "");
await SelecionaParcelas(value);
Item itemSelecionado = ItemSelecionado;
long item = ((itemSelecionado != null) ? ((DomainBase)itemSelecionado).Id : 0);
await SelecionaItens(FilterItens, null, 0L);
if (item > 0 && Itens != null && Itens.Any((Item x) => ((DomainBase)x).Id == item))
{
ItemSelecionado = Itens.First((Item x) => ((DomainBase)x).Id == item);
SelecionaItem(ItemSelecionado);
Gestor.Application.Actions.Actions.ScrollToItem?.Invoke();
}
VisibilityParcelasVendedores = (Visibility)0;
ConsultaViewModel consultaViewModel = this;
int num;
if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 19))
{
if (!string.IsNullOrWhiteSpace((value != null) ? value.Apolice : null) && value.Emissao.HasValue)
{
num = 2;
goto IL_027b;
}
}
num = 0;
goto IL_027b;
IL_027b:
consultaViewModel.RecusaVisibility = (Visibility)num;
base.IsEnabled = true;
IsLoading = false;
}
private void WorkOnSelectedDocumento(Documento value)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
if (value != null && ((DomainBase)value).Id != 0L && !Recarregando)
{
DocumentoSelecionado = value;
ParcelasLabel = (((int)DocumentoSelecionado.TipoRecebimento.GetValueOrDefault() == 2) ? "FATURAS" : "PARCELAS");
IsFatura = (int)DocumentoSelecionado.TipoRecebimento.GetValueOrDefault() == 2;
Gestor.Application.Actions.Actions.UpdateDocumento?.Invoke(value);
}
}
private async Task WorkOnSelectedControle(Documento value)
{
if (value == null || ((DomainBase)value).Id == 0L || IsLoading)
{
return;
}
DocumentoSelecionado = value;
IsEnabledParcelaItem = false;
IsLoading = true;
VisibilityParcelasVendedores = (Visibility)2;
PendenciaApolice = (string.IsNullOrEmpty(value.Apolice) ? $"{(Funcoes.GetNetworkTime().Date - value.Vigencia1).TotalDays} DIAS DE PENDÊNCIA" : "");
IsVisibleRadioEndosso = (Visibility)((!value.TemEndosso) ? 2 : 0);
await SelecionaParcelas(value);
VisibilityParcelasVendedores = (Visibility)0;
FilterItens = 0;
Item itemSelecionado = ItemSelecionado;
long item = ((itemSelecionado != null) ? ((DomainBase)itemSelecionado).Id : 0);
await SelecionaItens(FilterItens, value, 0L);
if (item > 0 && Itens != null && Itens.Any((Item x) => ((DomainBase)x).Id == item))
{
ItemSelecionado = Itens.First((Item x) => ((DomainBase)x).Id == item);
SelecionaItem(ItemSelecionado);
Gestor.Application.Actions.Actions.ScrollToItem?.Invoke();
}
IsLoading = false;
IsEnabledParcelaItem = true;
}
private void CalculaComissao(Documento documento, ObservableCollection<Parcela> parcelas)
{
decimal num = (documento.AdicionalComiss ? (documento.PremioLiquido + documento.PremioAdicional) : documento.PremioLiquido);
decimal num2 = documento.Comissao * 0.01m;
Gerada = num * num2;
Recebida = (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 32) ? parcelas.Where((Parcela x) => (int)x.SubTipo == 1 || (int)x.SubTipo == 6).Sum((Parcela x) => x.ValorComissao) : parcelas.Where((Parcela x) => (int)x.SubTipo == 1).Sum((Parcela x) => x.ValorComissao));
Pendente = Gerada - Recebida;
Pendente = ((Pendente < 0.01m) ? 0.00m : Pendente);
}
public async Task SelecionaParcelas(Documento documento = null)
{
if (documento == null)
{
documento = SelectedControle;
}
ObservableCollection<Parcela> observableCollection = await _parcelaServico.BuscarParcelasPorDocumento(documento);
Parcelas = (((int)documento.TipoRecebimento.GetValueOrDefault() == 2) ? new ObservableCollection<Parcela>(observableCollection.OrderByDescending((Parcela x) => x.NumeroParcela)) : observableCollection);
SelectedParcela = ((Parcelas != null && Parcelas.Count > 0) ? Parcelas[0] : null);
CalculaComissao(documento, Parcelas);
IsLoadingParcelas = true;
}
public async Task SelecionaItens(int type, Documento documento = null, long iditem = 0L, bool pesquisaAvancada = false)
{
if (documento == null)
{
documento = SelectedControle;
}
if (documento == null)
{
return;
}
IsLoadingItens = false;
bool flag = !pesquisaAvancada;
if (flag)
{
flag = await VerificaItens(documento);
}
if (flag)
{
return;
}
await CarregaItens(type, documento);
int filterItens = FilterItens;
if (iditem == 0L && filterItens != 2)
{
Item val = Itens?.FirstOrDefault((Func<Item, bool>)delegate(Item i)
{
long id3 = ((DomainBase)i).Id;
Item selectedItem5 = SelectedItem;
return id3 == ((selectedItem5 != null) ? new long?(((DomainBase)selectedItem5).Id) : null);
});
if (val != null || filterItens == 0)
{
SelectedItem = (Item)((val != null) ? ((object)val) : ((object)Itens?.FirstOrDefault()));
}
else if (val == null && filterItens == 1)
{
Item selectedItem = SelectedItem;
if (selectedItem != null && selectedItem.Substituicao > 0)
{
val = Itens?.FirstOrDefault((Func<Item, bool>)delegate(Item i)
{
long id2 = ((DomainBase)i).Id;
Item selectedItem4 = SelectedItem;
return id2 == ((selectedItem4 != null) ? selectedItem4.Substituicao : null);
});
}
SelectedItem = (Item)((val != null) ? ((object)val) : ((object)Itens?.FirstOrDefault()));
}
Item selectedItem2 = SelectedItem;
if (selectedItem2 != null && selectedItem2.Substituido > 0 && filterItens != 1)
{
FilterItens = 3;
Itens = await _itemServico.BuscarItens(((DomainBase)documento.Controle).Id, (StatusItem)1);
val = Itens?.FirstOrDefault((Func<Item, bool>)delegate(Item i)
{
long id = ((DomainBase)i).Id;
Item selectedItem3 = SelectedItem;
return id == ((selectedItem3 != null) ? new long?(((DomainBase)selectedItem3).Id) : null);
});
SelectedItem = (Item)((val != null) ? ((object)val) : ((object)Itens?.FirstOrDefault()));
}
}
IsLoadingItens = true;
}
public async Task<bool> VerificaItens(Documento documento)
{
if (!ItensRevelados && await _itemServico.ChecarQuantidade(((DomainBase)documento).Id) > 2)
{
Itens = new ObservableCollection<Item>();
Itens.Add(new Item
{
Id = 0L,
Descricao = "Item - Apólice Coletiva"
});
MostrarItensVisibility = (Visibility)0;
MostrarSinistroVisibility = (Visibility)2;
return true;
}
return false;
}
public async Task MostrarItens(int type = 0)
{
IsLoadingItens = false;
MostrarItensVisibility = (Visibility)2;
MostrarSinistroVisibility = (Visibility)0;
ItensRevelados = true;
Documento documento = DocumentoSelecionado;
if (type == 1 && DocumentoSelecionado.Tipo == 1)
{
documento = SelectedControle;
}
await CarregaItens(type, documento);
ObservableCollection<Item> itens = Itens;
if (itens != null && itens.Count > 1)
{
SelectedItem = Itens?.FirstOrDefault();
}
IsLoadingItens = true;
}
public async Task CarregaItens(int type, Documento documento)
{
FilterItens = 0;
switch (type)
{
case 0:
Itens = await _itemServico.BuscarItens(((DomainBase)documento.Controle).Id, (StatusItem)0);
break;
case 1:
FilterItens = 1;
Itens = await _itemServico.BuscarItens(((DomainBase)documento).Id, (StatusItem)2);
break;
case 2:
FilterItens = 2;
documento = SelectedEndosso ?? documento;
Itens = await _itemServico.BuscarItens(((DomainBase)documento).Id, (StatusItem)2);
break;
case 3:
FilterItens = 3;
Itens = await _itemServico.BuscarItens(((DomainBase)documento.Controle).Id, (StatusItem)1);
break;
}
}
public async Task SelecionaDocumento(int type, Documento documento)
{
if (Pesquisando)
{
return;
}
if (documento == null)
{
FilterDocumento = 0;
IsVisibleRadioEndosso = (Visibility)2;
IsVisibleApolice = (Visibility)0;
return;
}
documento.Controle.Cliente.Nome = SelectedCliente.Nome;
if (type != 1)
{
FilterDocumento = 0;
IsVisibleRadioEndosso = (Visibility)2;
IsVisibleApolice = (Visibility)0;
SelectedControle = documento;
await WorkOnSelectedControle(documento);
if (documento.TemEndosso)
{
IsVisibleRadioEndosso = (Visibility)0;
Endossos = new ObservableCollection<Documento>(documento.Controle.Documentos.Where((Documento x) => x.Tipo == 1 && (((DomainBase)Recursos.Usuario).Id == 0L || !x.Excluido)));
}
}
else
{
FilterDocumento = 1;
IsVisibleEndosso = (Visibility)0;
SelectedEndosso = documento;
await WorkOnSelectedEndosso(documento);
}
}
public void CarregaDocumentos(int type)
{
IsVisibleApolice = (Visibility)2;
IsVisibleEndosso = (Visibility)2;
if (type != 1)
{
IsVisibleApolice = (Visibility)0;
}
else
{
IsVisibleEndosso = (Visibility)0;
}
}
public void SelecionaItem(Item item)
{
if (item != null && ((DomainBase)item).Id != 0L)
{
FilterItens = ((item != null && item.Substituido > 0) ? 3 : 0);
SelectedItem = item;
}
}
private static void WorkOnSelectedItem(Item value)
{
if (value != null)
{
Item itemSelecionado = ItemSelecionado;
if (((itemSelecionado != null) ? new long?(((DomainBase)itemSelecionado).Id) : null) == ((DomainBase)value).Id)
{
return;
}
}
ItemSelecionado = value;
Gestor.Application.Actions.Actions.UpdateItem?.Invoke(value);
}
public async Task<Documento> AbrirDetalhes()
{
Documento documento = SelectedControle;
if (FilterDocumento == 1)
{
documento = SelectedEndosso ?? SelectedControle;
}
Documento val = documento;
val.Pagamentos = await _vendedorServico.BuscaRepasse(((DomainBase)documento).Id);
val = documento;
val.Parcelas = await _parcelaServico.BuscarParcelasAsync(((DomainBase)documento).Id);
return documento;
}
public async Task EditarParcelas()
{
await ShowEditarParcelasDialog(DocumentoSelecionado);
await SelecionaParcelas(DocumentoSelecionado);
}
public async Task RecusarDocumento()
{
if (DocumentoSelecionado == null)
{
return;
}
bool[] array = await Funcoes.VerificarPagamento(((DomainBase)DocumentoSelecionado).Id);
if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 23) && array.Any((bool x) => x))
{
await ShowMessage("NÃO É POSSÍVEL RECUSAR UMA APÓLICE ENQUANTO HOUVER RECEBIMENTO DE COMISSÃO OU PAGAMENTO DE VENDEDORES");
return;
}
bool flag = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 23) && array[1];
if (flag)
{
flag = await ShowMessage("EXISTEM PAGAMENTOS PARA OS VENDEDORES DO CONTRATO, DESEJA CRIAR ESTORNOS PARA ESSES PAGAMENTOS?", "SIM", "NÃO");
}
bool estorno = flag;
Documento documento = await _apoliceServico.BuscarApoliceAsync(((DomainBase)DocumentoSelecionado).Id);
IList<Documento> list;
if (documento.Controle.Documentos.Count <= 1)
{
list = documento.Controle.Documentos;
}
else
{
IList<Documento> list2 = (from x in documento.Controle.Documentos
where !x.Excluido
orderby x.Ordem
select x).ToList();
list = list2;
}
IList<Documento> list3 = list;
if (list3.Count > 1 && ((DomainBase)list3.Last((Documento x) => (int)x.Situacao != 7)).Id != ((DomainBase)DocumentoSelecionado).Id)
{
await ShowMessage("NÃO É POSSÍVEL RECUSAR UM DOCUMENTO ENQUANTO HOUVER ENDOSSOS EM CIMA DO MESMO.");
return;
}
if ((int)documento.Situacao == 7)
{
await ShowMessage("NÃO É POSSÍVEL RECUSAR UM DOCUMENTO JÁ RECUSADO.");
return;
}
string text = ((documento.Tipo == 0 && string.IsNullOrEmpty(documento.Apolice)) ? "A PROPOSTA SELECIONADA" : ((documento.Tipo == 0 && !string.IsNullOrEmpty(documento.Apolice)) ? "A APÓLICE SELECIONADA" : "O ENDOSSO SELECIONADO"));
if (await ShowMessage("DESEJA REALMENTE RECUSAR " + text + "?", "SIM", "NÃO"))
{
string text2 = await ShowObservacaoDialog();
if (text2 != null)
{
Loading(isLoading: true);
await Funcoes.RecusarApolice(documento, text2, estorno);
DocumentoSelecionado = null;
await SelecionaCliente(SelectedCliente);
Loading(isLoading: false);
}
}
}
public async Task<Parcela> AbrirDetalhesParcela()
{
Parcela parcela = SelectedParcela;
parcela.Vendedores = new ObservableCollection<VendedorParcela>(await _vendedorServico.BuscaRepasseParcela(((DomainBase)parcela).Id));
return parcela;
}
public void ManutecaoItens()
{
Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)3, "Manutencao");
}
public async Task GerarExcel(int type)
{
if (SelectedControle == null)
{
return;
}
Loading(isLoading: true);
bool iniciar = Type.GetTypeFromProgID("Excel.Application") != null;
string descricao = "ATIVOS";
ObservableCollection<Item> observableCollection;
switch (type)
{
default:
observableCollection = await _itemServico.BuscarItems(((DomainBase)SelectedControle.Controle).Id, (StatusItem)0, sinsitroCompleto: true);
break;
case 1:
descricao = "DA APÓLICE";
observableCollection = await _itemServico.BuscarItems(((DomainBase)SelectedControle).Id, (StatusItem)2, sinsitroCompleto: true);
break;
case 2:
{
Documento val = SelectedEndosso ?? SelectedControle;
descricao = ((SelectedEndosso == null) ? "DA APÓLICE" : "DO ENDOSSO");
observableCollection = await _itemServico.BuscarItems(((DomainBase)val).Id, (StatusItem)2, sinsitroCompleto: true);
break;
}
case 3:
descricao = "INATIVOS";
observableCollection = await _itemServico.BuscarItems(((DomainBase)SelectedControle.Controle).Id, (StatusItem)1, sinsitroCompleto: true);
break;
}
if (observableCollection == null || observableCollection.Count == 0)
{
Loading(isLoading: false);
await ShowMessage("NÃO HÁ ITENS PARA EXIBIR A RELAÇÃO");
return;
}
List<RelacaoItens> itensList = new List<RelacaoItens>();
observableCollection.ToList().ForEach(delegate(Item x)
{
string Coberturas = "";
if (x.Coberturas.Count() > 0)
{
x.Coberturas.ToList().ForEach(delegate(Cobertura c)
{
Coberturas += $"Cobertura: {c.Observacao} | Premio: {c.Premio} | Franquia: {c.Franquia} | LMI: {c.Lmi}\n";
});
}
RelacaoItens obj = new RelacaoItens
{
Nome = SelectedCliente.Nome,
Documento = SelectedCliente.Documento,
Apolice = SelectedControle.Apolice,
VigenciaInicial = SelectedControle.Vigencia1,
VigenciaFinal = SelectedControle.Vigencia2,
Ordem = x.Ordem,
Sinistrado = (x.Sinistrado ? "SIM" : "NÃO")
};
ControleSinistro? obj2 = x.Sinistros.FirstOrDefault();
obj.DataSinistro = ((obj2 != null) ? obj2.DataSinistro : null);
ControleSinistro? obj3 = x.Sinistros.FirstOrDefault();
object numSinistro;
if (obj3 == null)
{
numSinistro = null;
}
else
{
Sinistro? obj4 = obj3.Sinistros.FirstOrDefault();
numSinistro = ((obj4 != null) ? obj4.Numero : null);
}
obj.NumSinistro = (string)numSinistro;
ControleSinistro? obj5 = x.Sinistros.FirstOrDefault();
StatusSinistro? statusSinistro;
if (obj5 == null)
{
statusSinistro = null;
}
else
{
Sinistro? obj6 = obj5.Sinistros.FirstOrDefault();
statusSinistro = ((obj6 != null) ? obj6.StatusSinistro : null);
}
obj.StatusSinistro = statusSinistro;
ControleSinistro? obj7 = x.Sinistros.FirstOrDefault();
object itemSinistrado;
if (obj7 == null)
{
itemSinistrado = null;
}
else
{
Sinistro? obj8 = obj7.Sinistros.FirstOrDefault();
itemSinistrado = ((obj8 != null) ? obj8.ItemSinistrado : null);
}
obj.ItemSinistrado = (string)itemSinistrado;
ControleSinistro? obj9 = x.Sinistros.FirstOrDefault();
decimal? valor;
if (obj9 == null)
{
valor = null;
}
else
{
Sinistro? obj10 = obj9.Sinistros.FirstOrDefault();
valor = ((obj10 != null) ? new decimal?(obj10.Valor) : null);
}
obj.Valor = valor;
ControleSinistro? obj11 = x.Sinistros.FirstOrDefault();
DateTime? dataLiq;
if (obj11 == null)
{
dataLiq = null;
}
else
{
Sinistro? obj12 = obj11.Sinistros.FirstOrDefault();
dataLiq = ((obj12 != null) ? obj12.DataLiquidacao : null);
}
obj.DataLiq = dataLiq;
ControleSinistro? obj13 = x.Sinistros.FirstOrDefault();
DateTime? dataRec;
if (obj13 == null)
{
dataRec = null;
}
else
{
Sinistro? obj14 = obj13.Sinistros.FirstOrDefault();
dataRec = ((obj14 != null) ? obj14.DataReclamacao : null);
}
obj.DataRec = dataRec;
ControleSinistro? obj15 = x.Sinistros.FirstOrDefault();
object motivo;
if (obj15 == null)
{
motivo = null;
}
else
{
Sinistro? obj16 = obj15.Sinistros.FirstOrDefault();
motivo = ((obj16 != null) ? obj16.Motivo : null);
}
obj.Motivo = (string)motivo;
obj.Status = (string.IsNullOrEmpty(x.Status) ? x.StatusInclusao : x.Status);
obj.Cobertura = ((Coberturas.Length > 4000) ? Coberturas.Substring(0, 4000) : Coberturas);
RelacaoItens relacaoItens = obj;
switch (((DomainBase)SelectedControle.Controle.Ramo).Id)
{
case 1L:
case 2L:
case 3L:
case 18L:
relacaoItens.Endereco = ((EnderecoBase)x.Patrimonial).Endereco;
relacaoItens.Numero = ((EnderecoBase)x.Patrimonial).Numero;
relacaoItens.Bairro = ((EnderecoBase)x.Patrimonial).Bairro;
relacaoItens.Cidade = ((EnderecoBase)x.Patrimonial).Cidade;
relacaoItens.Estado = ((EnderecoBase)x.Patrimonial).Estado;
relacaoItens.Cep = ((EnderecoBase)x.Patrimonial).Cep;
relacaoItens.Complemento = ((EnderecoBase)x.Patrimonial).Complemento;
relacaoItens.Bens = x.Patrimonial.Bens;
relacaoItens.Descricao = x.Descricao;
break;
case 5L:
case 37L:
{
relacaoItens.Fipe = x.Auto.Fipe;
Fabricante fabricante = x.Auto.Fabricante;
relacaoItens.Fabricante = ((fabricante != null) ? fabricante.Descricao : null);
relacaoItens.Modelo = x.Auto.Modelo;
relacaoItens.AnoFab = x.Auto.AnoFabricacao;
relacaoItens.AnoMod = x.Auto.AnoModelo;
relacaoItens.Chassi = x.Auto.Chassi;
relacaoItens.Placa = x.Auto.Placa;
relacaoItens.RegiaoCirculacao = x.Auto.RegiaoCirculacao;
relacaoItens.Bonus = x.Auto.Bonus;
relacaoItens.Descricao = x.Descricao;
break;
}
default:
relacaoItens.Descricao = x.Descricao;
break;
}
itensList.Add(relacaoItens);
});
string text = "";
string fileName;
if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 41))
{
FolderBrowserDialog val2 = new FolderBrowserDialog();
try
{
if (1 != (int)((CommonDialog)val2).ShowDialog())
{
return;
}
text = val2.SelectedPath + "\\";
Directory.CreateDirectory(text);
}
finally
{
((IDisposable)val2)?.Dispose();
}
fileName = string.Format("{0}ITENS - {1} {2} {3}.xlsx", text, descricao, SelectedControle.Apolice.Replace("/", ""), Guid.NewGuid());
}
else
{
text = Path.GetTempPath();
fileName = $"{text}{Guid.NewGuid()}.xlsx";
}
(await Funcoes.GerarXls(new XLWorkbook(), "ITENS - " + SelectedControle.Apolice?.Replace("/", ""), itensList)).SaveAs(fileName);
if (!iniciar)
{
await ShowMessage("ARQUIVO SALVO NO CAMINHO " + fileName);
}
else
{
Process.Start(fileName);
}
RegistrarAcao($"GEROU A RELAÇÃO DOS ITENS DO DOCUMENTO DE ID {((DomainBase)SelectedControle).Id}", ((DomainBase)SelectedControle).Id, (TipoTela)21);
Loading(isLoading: false);
}
public async void SalvarOrdem(ObservableCollection<Item> itens)
{
if (itens == null)
{
return;
}
if (itens.Any((Item x) => x.Ordem == 0))
{
await ShowMessage("O CAMPO ORDEM DEVE SER MAIOR QUE ZERO.");
return;
}
if ((from item in itens
group item by item.Ordem).Any((IGrouping<int?, Item> x) => x.Count() > 1))
{
await ShowMessage("EXISTEM ITENS COM ORDEM REPETIDA. \nDEFINA UMA SEQUÊNCIA DIFERENTE PARA CADA ITEM.");
return;
}
Loading(isLoading: true);
foreach (Item iten in itens)
{
await _itemServico.Save(iten);
}
await SelecionaItens(FilterItens, null, 0L);
Loading(isLoading: false);
}
public async Task<string> CreateLink(Documento documento)
{
if (documento == null || SelectedCliente == null)
{
return "";
}
Telefones = new ObservableCollection<ClienteTelefone>(await new ClienteServico().BuscarTelefonesAsync(((DomainBase)SelectedCliente).Id));
object obj2;
if (Itens != null)
{
if (Itens.Count <= 1)
{
Item? obj = Itens.FirstOrDefault();
obj2 = ((obj != null) ? obj.Descricao : null);
}
else
{
obj2 = "APÓLICE COLETIVA";
}
}
else
{
obj2 = "";
}
string item = (string)obj2;
return await CreateLinkAssistencia(documento, item);
}
}
|