summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Ferramentas/ReciboViewModel.cs
blob: 81e4e8f90c30b75462cd2af6a149ad20b6056deb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Gestor.Application.Helpers;
using Gestor.Application.Servicos.Ferramentas;
using Gestor.Application.ViewModels.Generic;
using Gestor.Common.Validation;
using Gestor.Model.Common;
using Gestor.Model.Domain.Common;
using Gestor.Model.Domain.Ferramentas;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;

namespace Gestor.Application.ViewModels.Ferramentas;

public class ReciboViewModel : BaseSegurosViewModel
{
	private readonly ReciboServico _servico;

	public Recibo CancelRecibo;

	private Recibo _selectedRecibo = new Recibo();

	private DateTime? _horaRecibo;

	private ObservableCollection<Recibo> _recibosFiltrados = new ObservableCollection<Recibo>();

	private bool _isExpanded;

	private Cliente _pagante;

	private Cliente _recebedor;

	public List<Recibo> Recibos { get; set; }

	public Recibo SelectedRecibo
	{
		get
		{
			return _selectedRecibo;
		}
		set
		{
			_selectedRecibo = value;
			WorkOnSelectedRecibo(value);
			VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
			if (!value.DataRecibo.HasValue)
			{
				value.DataRecibo = DateTime.Now;
			}
			if (value != null)
			{
				HoraRecibo = value.DataRecibo;
			}
			OnPropertyChanged("SelectedRecibo");
		}
	}

	public DateTime? HoraRecibo
	{
		get
		{
			return _horaRecibo;
		}
		set
		{
			_horaRecibo = value;
			if (value.HasValue)
			{
				SelectedRecibo.DataRecibo = (SelectedRecibo.DataRecibo.HasValue ? new DateTime?(DateTime.Parse($"{SelectedRecibo.DataRecibo.Value:d} {value:T}")) : null);
				OnPropertyChanged("HoraRecibo");
			}
		}
	}

	public ObservableCollection<Recibo> RecibosFiltrados
	{
		get
		{
			return _recibosFiltrados;
		}
		set
		{
			_recibosFiltrados = value;
			IsExpanded = value != null && value.Count > 0;
			OnPropertyChanged("RecibosFiltrados");
		}
	}

	public bool IsExpanded
	{
		get
		{
			return _isExpanded;
		}
		set
		{
			_isExpanded = value;
			OnPropertyChanged("IsExpanded");
		}
	}

	public Cliente Pagante
	{
		get
		{
			return _pagante;
		}
		set
		{
			_pagante = value;
			WorkOnSelectedPagante(value);
			OnPropertyChanged("Pagante");
		}
	}

	public Cliente Recebedor
	{
		get
		{
			return _recebedor;
		}
		set
		{
			_recebedor = value;
			WorkOnSelectedRecebedor(value);
			OnPropertyChanged("Recebedor");
		}
	}

	public ReciboViewModel()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		_servico = new ReciboServico();
		base.EnableMenu = true;
		Seleciona();
	}

	private void WorkOnSelectedPagante(Cliente value)
	{
		if (value != null)
		{
			SelectedRecibo.Pagante = Regex.Replace(value.NomeSocial, "\\-\\s\\d.*", "").Trim();
			SelectedRecibo.DocumentoPagante = value.Documento;
			SelectedRecibo = SelectedRecibo;
		}
	}

	private void WorkOnSelectedRecebedor(Cliente value)
	{
		if (value != null)
		{
			SelectedRecibo.Recebedor = Regex.Replace(value.NomeSocial, "\\-\\s\\d.*", "").Trim();
			SelectedRecibo.DocumentoRecebedor = value.Documento;
			SelectedRecibo = SelectedRecibo;
		}
	}

	private async void Seleciona()
	{
		Loading(isLoading: true);
		await PermissaoTela((TipoTela)42);
		await SelecionaRecibo();
		Loading(isLoading: false);
	}

	private async Task SelecionaRecibo()
	{
		Loading(isLoading: true);
		Recibos = (await _servico.BuscarRecibos()).ToList();
		RecibosFiltrados = new ObservableCollection<Recibo>(Recibos);
		if (RecibosFiltrados.Count > 0)
		{
			SelectedRecibo = RecibosFiltrados.First();
		}
		else
		{
			SelectedRecibo = new Recibo();
			Alterar(alterar: false);
			base.EnableMenu = false;
		}
		Loading(isLoading: false);
	}

	public void Incluir()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		SelectedRecibo = new Recibo();
		Alterar(alterar: true);
	}

	internal async Task<List<Recibo>> Filtrar(string value)
	{
		return await Task.Run(() => FiltrarRecibo(value));
	}

	public List<Recibo> FiltrarRecibo(string filter)
	{
		RecibosFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection<Recibo>(Recibos) : new ObservableCollection<Recibo>(Recibos.Where((Recibo x) => ValidationHelper.RemoveDiacritics(x.Pagante.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) || ValidationHelper.RemoveDiacritics(x.Recebedor).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)))));
		return RecibosFiltrados.ToList();
	}

	public async Task<List<KeyValuePair<string, string>>> Salvar()
	{
		List<KeyValuePair<string, string>> list = SelectedRecibo.Validate();
		if (list.Count > 0)
		{
			return list;
		}
		string acao = ((((DomainBase)SelectedRecibo).Id == 0L) ? "INCLUIU" : "ALTEROU");
		Recibo value = await _servico.Save(SelectedRecibo);
		if (!_servico.Sucesso)
		{
			return null;
		}
		ReciboViewModel reciboViewModel = this;
		string descricao = $"{acao} RECIBO DE NÚMERO \"{((DomainBase)value).Id}\"";
		long id = ((DomainBase)value).Id;
		TipoTela? tela = (TipoTela)42;
		object[] obj = new object[9]
		{
			value.Tipo.HasValue ? (ValidationHelper.GetDescription((Enum)(object)value.Tipo.Value) ?? "") : "-",
			null,
			null,
			null,
			null,
			null,
			null,
			null,
			null
		};
		TipoPagamento? pagamento = value.Pagamento;
		obj[1] = (pagamento.HasValue ? ValidationHelper.GetDescription((Enum)(object)pagamento.GetValueOrDefault()) : null);
		obj[2] = value.Valor;
		obj[3] = value.DataRecibo;
		obj[4] = value.Pagante;
		obj[5] = value.DocumentoPagante;
		obj[6] = value.Recebedor;
		obj[7] = value.DocumentoRecebedor;
		obj[8] = value.Referente;
		reciboViewModel.RegistrarAcao(descricao, id, tela, string.Format("TIPO: {0}\nPAGAMENTO: {1}\nVALOR: {2:c}\nDATA RECIBO: {3:G}\nPAGANTE: {4}, {5}\nRECEBEDOR: {6}, {7}\nREFERENTE: \"{8}\"", obj));
		if (Recibos.Any((Recibo x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
		{
			DomainBase.Copy<Recibo, Recibo>(Recibos.First((Recibo x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
		}
		else
		{
			Recibos.Add(value);
		}
		if (RecibosFiltrados.Any((Recibo x) => ((DomainBase)x).Id == ((DomainBase)value).Id))
		{
			DomainBase.Copy<Recibo, Recibo>(RecibosFiltrados.First((Recibo x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value);
		}
		else
		{
			RecibosFiltrados.Add(value);
		}
		RecibosFiltrados = new ObservableCollection<Recibo>(RecibosFiltrados);
		WorkOnSelectedRecibo(value, registrar: false);
		Alterar(alterar: false);
		ToggleSnackBar("RECIBO SALVO COM SUCESSO");
		return null;
	}

	public async void Excluir()
	{
		if (SelectedRecibo != null && ((DomainBase)SelectedRecibo).Id != 0L && await ShowMessage("DESEJA REALMENTE EXCLUIR O RECIBO PERMANENTEMENTE?", "SIM", "NÃO"))
		{
			Loading(isLoading: true);
			if (!(await _servico.Delete(SelectedRecibo)))
			{
				Loading(isLoading: false);
				return;
			}
			ReciboViewModel reciboViewModel = this;
			string descricao = $"EXCLUIU RECIBO DE NÚMERO \"{((DomainBase)SelectedRecibo).Id}\"";
			long id = ((DomainBase)SelectedRecibo).Id;
			TipoTela? tela = (TipoTela)42;
			object[] obj = new object[9]
			{
				SelectedRecibo.Tipo.HasValue ? (ValidationHelper.GetDescription((Enum)(object)SelectedRecibo.Tipo.Value) ?? "") : "-",
				null,
				null,
				null,
				null,
				null,
				null,
				null,
				null
			};
			TipoPagamento? pagamento = SelectedRecibo.Pagamento;
			obj[1] = (pagamento.HasValue ? ValidationHelper.GetDescription((Enum)(object)pagamento.GetValueOrDefault()) : null);
			obj[2] = SelectedRecibo.Valor;
			obj[3] = SelectedRecibo.DataRecibo;
			obj[4] = SelectedRecibo.Pagante;
			obj[5] = SelectedRecibo.DocumentoPagante;
			obj[6] = SelectedRecibo.Recebedor;
			obj[7] = SelectedRecibo.DocumentoRecebedor;
			obj[8] = SelectedRecibo.Referente;
			reciboViewModel.RegistrarAcao(descricao, id, tela, string.Format("TIPO: {0}\nPAGAMENTO: {1}\nVALOR: {2:c}\nDATA RECIBO: {3:G}\nPAGANTE: {4}, {5}\nRECEBEDOR: {6}, {7}\nREFERENTE: \"{8}\"", obj));
			await SelecionaRecibo();
			Loading(isLoading: false);
			ToggleSnackBar("RECIBO EXCLUÍDO COM SUCESSO");
		}
	}

	public void CancelarAlteracao()
	{
		if (CancelRecibo != null && Recibos.Any((Recibo x) => ((DomainBase)x).Id == ((DomainBase)CancelRecibo).Id))
		{
			DomainBase.Copy<Recibo, Recibo>(Recibos.First((Recibo x) => ((DomainBase)x).Id == ((DomainBase)CancelRecibo).Id), CancelRecibo);
			if (RecibosFiltrados.Count > 0 && RecibosFiltrados.Any((Recibo x) => ((DomainBase)x).Id == ((DomainBase)CancelRecibo).Id))
			{
				DomainBase.Copy<Recibo, Recibo>(RecibosFiltrados.First((Recibo x) => ((DomainBase)x).Id == ((DomainBase)CancelRecibo).Id), CancelRecibo);
			}
			else
			{
				RecibosFiltrados.Add(CancelRecibo);
			}
			RecibosFiltrados = new ObservableCollection<Recibo>(RecibosFiltrados);
			SelectedRecibo = RecibosFiltrados.First((Recibo x) => ((DomainBase)x).Id == ((DomainBase)CancelRecibo).Id);
		}
		else
		{
			Incluir();
		}
		Alterar(alterar: false);
	}

	private bool IsImage(string extensao)
	{
		if (extensao == null)
		{
			return false;
		}
		if (extensao.ToLower().Contains("jpg"))
		{
			return true;
		}
		if (extensao.ToLower().Contains("jpeg"))
		{
			return true;
		}
		if (extensao.ToLower().Contains("png"))
		{
			return true;
		}
		return false;
	}

	public async void Print()
	{
		Recibo selectedRecibo = SelectedRecibo;
		if (((selectedRecibo != null) ? selectedRecibo.Referente : null) == null || SelectedRecibo.Recebedor == null)
		{
			return;
		}
		ArquivoDigital arquivo = null;
		List<IndiceArquivoDigital> list = await ArquivoDigitalServico.BuscarPorTipo((TipoArquivoDigital)13, ((DomainBase)Recursos.Empresa).Id);
		if (list != null && list.Any((IndiceArquivoDigital x) => x.Descricao == "LOGO"))
		{
			IndiceArquivoDigital? obj = ((IEnumerable<IndiceArquivoDigital>)list).FirstOrDefault((Func<IndiceArquivoDigital, bool>)((IndiceArquivoDigital x) => x.Descricao == "LOGO"));
			long? num = ((obj != null) ? new long?(obj.IdArquivoDigital) : null);
			IndiceArquivoDigital? obj2 = ((IEnumerable<IndiceArquivoDigital>)list).FirstOrDefault((Func<IndiceArquivoDigital, bool>)((IndiceArquivoDigital x) => x.Descricao == "LOGO"));
			string banco = ((obj2 != null) ? obj2.Bd : null);
			if (num.HasValue)
			{
				arquivo = await ArquivoDigitalServico.BuscarPorId(num.Value, banco);
			}
		}
		ArquivoDigital obj3 = arquivo;
		byte[] array = ((obj3 != null) ? obj3.Arquivo : null);
		string image = "";
		if (array != null && array.Length != 0)
		{
			ReciboViewModel reciboViewModel = this;
			ArquivoDigital obj4 = arquivo;
			if (reciboViewModel.IsImage((obj4 != null) ? obj4.Extensao : null))
			{
				ArquivoDigital obj5 = arquivo;
				image = GetImage(array, (obj5 != null) ? obj5.Extensao : null);
			}
		}
		string longDatePattern = new CultureInfo("pt-PT", useUserOverride: false).DateTimeFormat.LongDatePattern;
		string data = SelectedRecibo.DataRecibo?.ToString(longDatePattern, new CultureInfo("pt-PT"));
		int vias = ((!(await ShowMessage("DESEJA IMPRIMIR DUAS VIAS DO RECIBO?", "SIM", "NÃO"))) ? 1 : 2);
		bool flag = !string.IsNullOrEmpty(image);
		if (flag)
		{
			flag = await ShowMessage("DESEJA IMPRIMIR O LOGO DA CORRETORA NO RECIBO?\nPARA ADICIONAR UM LOGO, É NECESSÁRIO COLOCÁ-LO NO ARQUIVO\nDIGITAL NA TELA DE EMPRESA E FILIAIS COM DESCRIÇÃO \"LOGO\"", "SIM", "NÃO");
		}
		bool flag2 = flag;
		string text = "<html><head><style type='text/css'>@page{size: A4; margin: 0cm}</style><title>RECIBO</title><link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css' integrity='sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh' crossorigin='anonymous'></head><body>";
		for (int i = 0; i < vias; i++)
		{
			if (flag2)
			{
				text = text + "<div>" + image + "</div>";
				text += "<div style='margin: 0px 100px 0px 100px; font-size: 20px;'>";
			}
			else
			{
				text += "<div style='margin: 50px 100px 50px 100px; font-size: 20px;'>";
			}
			text += $"<div style='text-align: right'><strong>N° {((DomainBase)SelectedRecibo).Id}</strong></div><br>";
			text += "<strong>R E C I B O</strong><br><br>";
			if ((int)SelectedRecibo.Tipo.GetValueOrDefault() == 1)
			{
				string text2 = ((SelectedRecibo.DocumentoRecebedor == null || SelectedRecibo.DocumentoRecebedor.Clear().Length < 12) ? "EU" : "A");
				string text3 = ((SelectedRecibo.DocumentoRecebedor == null || SelectedRecibo.DocumentoRecebedor.Clear().Length < 12) ? "CPF" : "CNPJ");
				string text4 = ((text2 == "EU") ? "O" : "A");
				string text5 = ((text2 == "EU") ? "RECEBI" : "RECEBEU");
				text += $"PELO PRESENTE, {text2}, <strong>{SelectedRecibo.Recebedor}</strong>, INSCRIT{text4} NO {text3} SOB Nº <strong>{SelectedRecibo.DocumentoRecebedor}</strong>, DECLAR{text4} QUE {text5}, NA DATA DE HOJE, <strong>{SelectedRecibo.DataRecibo:dd/MM/yyyy HH:mm}</strong>, O VALOR DE <strong>R$ {SelectedRecibo.Valor:0.00}</strong> POR MEIO DE <strong>{ValidationHelper.GetDescription((Enum)(object)SelectedRecibo.Pagamento)}</strong>, DE <strong>{SelectedRecibo.Pagante}</strong>, INSCRITO NO CPF/CNPJ SOB Nº <strong>{SelectedRecibo.DocumentoPagante}</strong>, REFERENTE À(AO) <strong>{SelectedRecibo.Referente.ToUpper()}</strong>. DANDO-LHE POR ESTE RECIBO A DEVIDA QUITAÇÃO.<br>";
				text = text + "<strong>" + ((EnderecoBase)Recursos.Empresa).Cidade + ", " + data?.ToUpper() + ".</strong><br><br>";
				text = text + "_________________________________<br><strong>ASSINATURA  </strong>" + SelectedRecibo.Recebedor + "<br>" + SelectedRecibo.DocumentoRecebedor;
			}
			else
			{
				string text6 = ((SelectedRecibo.DocumentoPagante == null || SelectedRecibo.DocumentoPagante.Clear().Length < 12) ? "EU" : "A");
				string text7 = ((SelectedRecibo.DocumentoPagante == null || SelectedRecibo.DocumentoPagante.Clear().Length < 12) ? "CPF" : "CNPJ");
				string text8 = ((text6 == "EU") ? "O" : "A");
				string text9 = ((text6 == "EU") ? "PAGUEI" : "PAGOU");
				text += $"PELO PRESENTE, {text6}, <strong>{SelectedRecibo.Pagante}</strong>, INSCRIT{text8} NO {text7} SOB Nº <strong>{SelectedRecibo.DocumentoPagante}</strong>, DECLAR{text8} QUE {text9}, NA DATA DE HOJE, <strong>{SelectedRecibo.DataRecibo:dd/MM/yyyy HH:mm}</strong>, O VALOR DE <strong>R$ {SelectedRecibo.Valor:0.00}</strong> POR MEIO DE <strong>{ValidationHelper.GetDescription((Enum)(object)SelectedRecibo.Pagamento)}</strong>, PARA <strong>{SelectedRecibo.Recebedor}</strong>, INSCRITO NO CPF/CNPJ SOB Nº <strong>{SelectedRecibo.DocumentoRecebedor}</strong>, REFERENTE À(AO) <strong>{SelectedRecibo.Referente.ToUpper()}</strong>. DANDO-LHE POR ESTE RECIBO A DEVIDA QUITAÇÃO.<br>";
				text = text + "<br><strong>" + ((EnderecoBase)Recursos.Empresa).Cidade + ", " + data?.ToUpper() + ".</strong><br><br>";
				text = text + "_________________________________<br><strong>ASSINATURA  </strong>" + SelectedRecibo.Recebedor + "<br>" + SelectedRecibo.DocumentoRecebedor;
			}
			text += "<hr /></div>";
		}
		text += "<script src='https://code.jquery.com/jquery-3.4.1.slim.min.js' integrity='sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n' crossorigin='anonymous'></script> <script src = 'https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js' integrity = 'sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo' crossorigin = 'anonymous' ></script><script src = 'https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js' integrity = 'sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6' crossorigin = 'anonymous' ></script> </body></html>";
		string tempPath = Path.GetTempPath();
		string text10 = $"{tempPath}_{Funcoes.GetNetworkTime():ddMMyyyyhhmmss}.html";
		StreamWriter streamWriter = new StreamWriter(text10, append: true, Encoding.UTF8);
		streamWriter.Write(text);
		streamWriter.Close();
		Process.Start(text10);
		ReciboViewModel reciboViewModel2 = this;
		string descricao = $"IMPRIMIU O RECIBO DE NÚMERO \"{((DomainBase)SelectedRecibo).Id}\"";
		long id = ((DomainBase)SelectedRecibo).Id;
		TipoTela? tela = (TipoTela)42;
		object[] obj6 = new object[9]
		{
			SelectedRecibo.Tipo.HasValue ? (ValidationHelper.GetDescription((Enum)(object)SelectedRecibo.Tipo.Value) ?? "") : "-",
			null,
			null,
			null,
			null,
			null,
			null,
			null,
			null
		};
		TipoPagamento? pagamento = SelectedRecibo.Pagamento;
		obj6[1] = (pagamento.HasValue ? ValidationHelper.GetDescription((Enum)(object)pagamento.GetValueOrDefault()) : null);
		obj6[2] = SelectedRecibo.Valor;
		obj6[3] = SelectedRecibo.DataRecibo;
		obj6[4] = SelectedRecibo.Pagante;
		obj6[5] = SelectedRecibo.DocumentoPagante;
		obj6[6] = SelectedRecibo.Recebedor;
		obj6[7] = SelectedRecibo.DocumentoRecebedor;
		obj6[8] = SelectedRecibo.Referente;
		reciboViewModel2.RegistrarAcao(descricao, id, tela, string.Format("TIPO: {0}\nPAGAMENTO: {1}\nVALOR: {2:c}\nDATA RECIBO: {3:G}\nPAGANTE: {4}, {5}\nRECEBEDOR: {6}, {7}\nREFERENTE: \"{8}\"", obj6));
	}

	private static string GetImage(byte[] bytes, string extensao)
	{
		try
		{
			Image val = Image.FromStream((Stream)new MemoryStream(bytes));
			string text = (extensao.ToUpper().Contains("JPG") ? ("data:image/jpeg;base64," + Convert.ToBase64String(bytes, Base64FormattingOptions.None)) : ("data:image/png;base64," + Convert.ToBase64String(bytes, Base64FormattingOptions.None)));
			return "<img style=\"WIDTH=" + val.Width + "; HEIGHT=" + val.Height + "; max-height: 250px; max-width: 250px; margin-bottom: 0px; margin-left: 100px; margin-top: 0px;\" src=\"" + text + "\"/>";
		}
		catch (Exception)
		{
			return "";
		}
	}

	private void WorkOnSelectedRecibo(Recibo value, bool registrar = true)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Invalid comparison between Unknown and I4
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		CancelRecibo = (Recibo)((value == null || ((DomainBase)value).Id == 0L) ? ((object)CancelRecibo) : ((object)(Recibo)((DomainBase)value).Clone()));
		if (value == null || ((DomainBase)value).Id == 0L || (LastAccessId == ((DomainBase)value).Id && (int)LastAccessTela == 42))
		{
			return;
		}
		if (registrar)
		{
			string descricao = $"ACESSOU RECIBO DE NÚMERO \"{((DomainBase)value).Id}\"";
			long id = ((DomainBase)value).Id;
			TipoTela? tela = (TipoTela)42;
			object[] obj = new object[9]
			{
				value.Tipo.HasValue ? (ValidationHelper.GetDescription((Enum)(object)value.Tipo.Value) ?? "") : "-",
				null,
				null,
				null,
				null,
				null,
				null,
				null,
				null
			};
			TipoPagamento? pagamento = value.Pagamento;
			obj[1] = (pagamento.HasValue ? ValidationHelper.GetDescription((Enum)(object)pagamento.GetValueOrDefault()) : null);
			obj[2] = value.Valor;
			obj[3] = value.DataRecibo;
			obj[4] = value.Pagante;
			obj[5] = value.DocumentoPagante;
			obj[6] = value.Recebedor;
			obj[7] = value.DocumentoRecebedor;
			obj[8] = value.Referente;
			RegistrarAcao(descricao, id, tela, string.Format("TIPO: {0}\nPAGAMENTO: {1}\nVALOR: {2:c}\nDATA RECIBO: {3:G}\nPAGANTE: {4}, {5}\nRECEBEDOR: {6}, {7}\nREFERENTE: \"{8}\"", obj));
		}
		LastAccessId = ((DomainBase)value).Id;
		LastAccessTela = (TipoTela)42;
		Recibo selectedRecibo = SelectedRecibo;
		if (((selectedRecibo != null) ? new long?(((DomainBase)selectedRecibo).Id) : null) != ((DomainBase)value).Id)
		{
			SelectedRecibo = ((IEnumerable<Recibo>)RecibosFiltrados).FirstOrDefault((Func<Recibo, bool>)((Recibo x) => ((DomainBase)x).Id == ((DomainBase)value).Id));
		}
	}
}