public static string insertar(string nombre, int codigoFormaPago) { DatosTarjeta tarjeta = new DatosTarjeta(nombre, codigoFormaPago); return(tarjeta.agregarTarjeta(tarjeta)); }
public static IDatosTarjeta GetDatosTarjeta() { return(DatosTarjeta.GetInstancia()); }
private MemoryStream DrawDataInCard(string emeci) { var memory = new MemoryStream(); var doc = new Document(); var pdf = PdfWriter.GetInstance(doc, memory); doc.Open(); var bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false); var fBold = new Font(bfTimes, 8, Font.NORMAL, BaseColor.BLACK); var pdfTable = new PdfPTable(2) { TotalWidth = 500f, LockedWidth = true, HorizontalAlignment = 1 }; var widths = new float[] { 2.8f, 2.1f }; pdfTable.SetWidths(widths); pdfTable.DefaultCell.Border = Rectangle.NO_BORDER; var file = $"{AppDomain.CurrentDomain.BaseDirectory}imgAccess.jpg"; var image = Image.GetInstance(ConvertImageToBytes(file, emeci)); image.ScaleAbsolute(258f, 153f); var cell = new PdfPCell(image) { HorizontalAlignment = Element.ALIGN_MIDDLE, Border = Rectangle.NO_BORDER }; pdfTable.AddCell(cell); var position = new PdfPTable(11) { HorizontalAlignment = 1, TotalWidth = 265f, LockedWidth = true }; var cellPosition = new PdfPCell(new Phrase("Posiciones de Acceso Seguro")) { BackgroundColor = new BaseColor(162, 212, 255), HorizontalAlignment = 1, Colspan = 11, Border = Rectangle.NO_BORDER }; position.AddCell(cellPosition); string[] arrABC = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }; for (var i = 0; i <= 10; i++) { position.DefaultCell.BackgroundColor = new BaseColor(255, 255, 255); position.DefaultCell.Padding = 2f; position.DefaultCell.Border = Rectangle.NO_BORDER; if (i == 0) { position.AddCell(""); } else { position.AddCell(new Phrase(arrABC[i - 1], fBold)); } } bool color = true; DatosTarjeta dt; for (int i = 1; i <= 10; i++) { if (color) { position.DefaultCell.BackgroundColor = new BaseColor(162, 212, 255); } else { position.DefaultCell.BackgroundColor = new BaseColor(255, 255, 255); } color = !color; position.AddCell(new Phrase(i.ToString(), fBold)); string letter; for (var j = 0; j <= 9; j++) { letter = arrABC[j]; dt = new DatosTarjeta { noTarjeta = emeci, Dato = new Random().Next(0, 999).ToString("00#"), Coordenada = $"{letter}{i}" }; position.AddCell(new Phrase(dt.Dato, fBold)); Context.DatosTarjeta.Add(dt); } } pdfTable.AddCell(position); doc.Add(pdfTable); pdf.CloseStream = false; doc.Close(); memory.Position = 0; Context.SaveChanges(); return(memory); }