private void TipoNominaMantenimiento_Load(object sender, EventArgs e) { lbTitulo.Text = "MANTENIMIENTO DE TIPO DE NOMINA"; lbTitulo.ForeColor = Color.White; cbEstatus.Checked = true; VariablesGlobales.NombreSistema = InformacionEmpresa.SacarNombreEmpresa(); if (VariablesGlobales.Accion != "INSERT") { var SacarInformacion = ObjDataEmpresa.Value.BuscaTipoNomina( VariablesGlobales.IdMantenimeinto, null, 1, 1); foreach (var n in SacarInformacion) { txtTipoNomina.Text = n.TipoNomina; cbEstatus.Checked = (n.Estatus0.HasValue ? n.Estatus0.Value : false); } } }
public static void ImprimirCuenta(int CodigoOrden) { try { int LINE_MAX_LENGHT = Properties.Settings.Default.MaximoCaracteresBarra; var center = new StringFormat() { Alignment = StringAlignment.Center }; Usuarios usuario = null; string AtendidoPor = string.Empty; InformacionEmpresa info = null; System.Drawing.Font Normal = null; System.Drawing.Font Bold = null; List <SPC_GET_ORDENDETALLE_Result> OrdenDetalle = null; var Mesa = string.Empty; decimal TotalFactura = 0; int comensales = 0; using (var DB = new TPVDBEntities()) { info = DB.InformacionEmpresa.First(); Normal = new System.Drawing.Font(info.TipoLetraBarra, (int)info.TamanoLetraBarra, System.Drawing.FontStyle.Regular); Bold = new System.Drawing.Font(info.TipoLetraBarra, (int)info.TamanoLetraBarra, System.Drawing.FontStyle.Bold); if (!string.IsNullOrEmpty(info.TipoLetraBarra)) { Normal = new System.Drawing.Font(new System.Drawing.FontFamily(info.TipoLetraBarra), (float)info.TamanoLetraBarra.Value, System.Drawing.FontStyle.Regular); Bold = new System.Drawing.Font(new System.Drawing.FontFamily(info.TipoLetraBarra), (float)info.TamanoLetraBarra, System.Drawing.FontStyle.Bold); } var orden = DB.Ordenes.Where(w => w.Codigo_Orden == CodigoOrden).First(); usuario = orden.OrdenesDetalles.First().Usuarios; AtendidoPor = usuario.Nombre_Usuario + " " + usuario.Apellido_Usuario; comensales = orden.Comensales; if (orden.Codigo_Estado_Orden == 1) { orden.Codigo_Estado_Orden = 2; orden.Hora_Pago = DateTime.Now; DB.SaveChanges(); } OrdenDetalle = DB.SPC_GET_ORDENDETALLE(CodigoOrden, null, null, null, null, null, null, null, true) .OrderBy(o => o.OrdenFactura).ToList(); } ///-- Mesa y Nº factura var ordenDetalle = OrdenDetalle.First(); Mesa = ordenDetalle.Mesa; var NumeroFactura = string.Format("{0}-{1}", ordenDetalle.Hora_Pago.Value.Year, ordenDetalle.NumeroFactura.Value.ToString().PadLeft(6, '0')); int Index = 0; var LineasImpresion = new List <LineaPedido>(); LineasImpresion.Add(new LineaPedido(Index++, info.NombreEmpresa.ToUpper(), Bold, center)); LineasImpresion.Add(new LineaPedido(Index++, info.Direccion, Normal, center)); LineasImpresion.Add(new LineaPedido(Index++, string.Format("{0} {1}, {2}", info.CodigoPostal, info.Ciudad, info.Provincia), Normal, center)); if (!string.IsNullOrEmpty(info.Telefono)) { LineasImpresion.Add(new LineaPedido(Index++, "Tel. " + info.Telefono, Normal, center)); } if (!string.IsNullOrEmpty(info.Movil) && info.Telefono != info.Movil) { LineasImpresion.Add(new LineaPedido(Index++, "Móvil " + info.Movil, Normal, center)); } if (!string.IsNullOrEmpty(info.NIF)) { LineasImpresion.Add(new LineaPedido(Index++, "N.I.F: " + info.NIF, Normal, center)); } if (!string.IsNullOrEmpty(info.CIF)) { LineasImpresion.Add(new LineaPedido(Index++, "C.I.F: " + info.CIF, Normal, center)); } Index++; LineasImpresion.Add(new LineaPedido(Index++, string.Format("Factura Simplificada: {0}", NumeroFactura.PadLeft(LINE_MAX_LENGHT - 22, ' ')), Normal)); LineasImpresion.Add(new LineaPedido(Index++, new string('-', LINE_MAX_LENGHT), Normal)); var grpProductos = OrdenDetalle.GroupBy(g => new { g.NombreProducto }).ToList(); foreach (var Producto in grpProductos) { var grpUnidadMedida = Producto.GroupBy(g => g.Codigo_Producto_Unidad_Medida); foreach (var UnidadMedida in grpUnidadMedida) { var grpNota = UnidadMedida.GroupBy(g => g.Nota_Producto).ToList(); foreach (var Pedidos in grpNota) { var Linea = new SPC_GET_ORDENDETALLE_Result(); foreach (var Pedido in Pedidos) { Linea.Cantidad_Producto += Pedido.Cantidad_Producto; Linea.NombreProducto = Pedido.NombreProducto; Linea.Nota_Producto = Pedido.Nota_Producto; Linea.Sub_Total_Precio_Producto += Pedido.Sub_Total_Precio_Producto; } string cantidad = string.Format("{0}x{1:F}", Linea.Cantidad_Producto.ToString().PadLeft(2, ' '), Linea.Sub_Total_Precio_Producto / Linea.Cantidad_Producto); string Descripcion = string.Empty; string total = Linea.Sub_Total_Precio_Producto.ToString("F"); int EspacioTotal = 0; int intFiller = 0; EspacioTotal = (LINE_MAX_LENGHT - 3) - cantidad.Length - total.Length; if (!string.IsNullOrEmpty(Linea.Nota_Producto)) { EspacioTotal -= Linea.Nota_Producto.Length + 2; if (EspacioTotal < 0) { EspacioTotal = 0; } Descripcion = Linea.NombreProducto.Truncate(EspacioTotal); Descripcion += " " + Linea.Nota_Producto; } else { Descripcion = Linea.NombreProducto.Truncate(EspacioTotal); } intFiller = (LINE_MAX_LENGHT - 2) - (cantidad.Length + Descripcion.Length + total.Length); if (intFiller == 0) { LineasImpresion.Add(new LineaPedido(Index++, string.Format("{0} {1} {2}", cantidad, Descripcion, total), Normal)); } else if (intFiller > 0) { LineasImpresion.Add(new LineaPedido(Index++, string.Format("{0} {1}{2} {3}", cantidad, Descripcion, new string('.', intFiller), total), Normal)); } TotalFactura += Linea.Sub_Total_Precio_Producto; } } } LineasImpresion.Add(new LineaPedido(Index++, new string('-', LINE_MAX_LENGHT), Normal)); LineasImpresion.Add(new LineaPedido(Index++, string.Format("TOTAL: {0}", TotalFactura.ToString("F").PadLeft(LINE_MAX_LENGHT - 7, '.')), Bold)); if (comensales > 1) { Index++; LineasImpresion.Add(new LineaPedido(Index++, string.Format("{0} por persona", (TotalFactura / comensales).ToString("F")), Normal, center)); Index++; } Index++; LineasImpresion.Add(new LineaPedido(Index++, "TIPO BASE IVA TOTAL", Normal)); var Impuestos = TotalFactura / (1 + info.PorcientoIVA.Value); LineasImpresion.Add(new LineaPedido(Index++, string.Format("{0} {1} {2} {3}", info.PorcientoIVA.Value.ToString("F").PadRight(7, ' '), (TotalFactura - Impuestos).ToString("F").PadRight(7, ' '), Impuestos.ToString("F").PadRight(7, ' '), TotalFactura.ToString("F")), Normal)); Index++; LineasImpresion.Add(new LineaPedido(Index++, "PRECIOS CON IVA INCLUIDO", Normal)); LineasImpresion.Add(new LineaPedido(Index++, "ATENDIDO POR: " + AtendidoPor, Normal)); LineasImpresion.Add(new LineaPedido(Index++, "MESA: " + Mesa.ToUpper(), Bold)); LineasImpresion.Add(new LineaPedido(Index++, "FECHA: " + DateTime.Now.ToString("dd MMM HH:mm:ss"), Normal)); Index++; if (!string.IsNullOrEmpty(info.Facebook)) { LineasImpresion.Add(new LineaPedido(Index++, "Síguenos en FB", Bold, center)); LineasImpresion.Add(new LineaPedido(Index++, info.Facebook, Normal, center)); } LineasImpresion.Add(new LineaPedido(Index++, "Gracias por su visita", Normal, center)); HttpContext.Current.Session.Add(C_SV_IMPRESION, LineasImpresion); var pd = new System.Drawing.Printing.PrintDocument(); pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage); pd.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("3 1/8 inc x 220 mm", 313, (Index + 2) * Normal.Height); pd.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0); if (!string.IsNullOrEmpty(info.NombreImpresoraBarra)) { pd.PrinterSettings.PrinterName = info.NombreImpresoraBarra; } pd.Print(); } catch (Exception ex) { (LogManager.GetCurrentClassLogger()).Error(ex, "ha ocurrido un error al intentar Imprimir Cuenta"); throw new Exception(ex.Message); } }