1049 lines
57 KiB
C#
1049 lines
57 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Security;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.VisualBasic;
|
|
using System.Drawing.Printing;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using ADSUtileriasWF.Helpers;
|
|
|
|
namespace ADSUtileriasWF.Data.Externa.PV
|
|
{
|
|
public class ClsImpresion : CLSExternoBase
|
|
{
|
|
|
|
// Atributos de la clase
|
|
private bool disposedValue = false; // Para detectar llamadas redundantes
|
|
public DataTable dtVentasDetalles;
|
|
|
|
private PrintDocument printDoc = new PrintDocument();
|
|
private int CveVentaTerminal;
|
|
private int CveCategoriaParaComanda;
|
|
private int CveMovimientoTerminal;
|
|
private int CveCorteTerminal;
|
|
public bool ImpresionCortePrevio { get; set; } = false;
|
|
|
|
private TipoImpresion TipoImp;
|
|
private int xPos = 1;
|
|
private int yPos;
|
|
private int yPosPendiente = 0;
|
|
|
|
private Font FontGrande = new Font("Lucida Console", ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal ? 14 : 12, FontStyle.Bold);
|
|
private Font FontMediana = new Font("Lucida Console", ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal ? 11 : 8, FontStyle.Bold);
|
|
private Font FontChica = new Font("Lucida Console", ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal ? 7 : 6, FontStyle.Regular);
|
|
|
|
private WCF_PV.Usuario UsuarioActual;
|
|
|
|
public ClsImpresion(WCF_PV.Usuario usuarioActual)
|
|
{
|
|
printDoc.PrintPage += printDoc_PrintPage;
|
|
UsuarioActual = usuarioActual;
|
|
}
|
|
|
|
private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
|
|
{
|
|
switch (TipoImp)
|
|
{
|
|
case TipoImpresion.Venta:
|
|
{
|
|
ImprimirVenta(e);
|
|
break;
|
|
}
|
|
|
|
case TipoImpresion.MovimientoCaja:
|
|
{
|
|
ImprimirMovimientoCaja(e);
|
|
break;
|
|
}
|
|
|
|
case TipoImpresion.Comanda:
|
|
{
|
|
if (ModVarsPV.ImprimirComandas == true)
|
|
ImprimirComanda(e);
|
|
break;
|
|
}
|
|
|
|
case TipoImpresion.Corte:
|
|
{
|
|
ImprimirCorte(e);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ImprimirVenta(PrintPageEventArgs e)
|
|
{
|
|
ClsVentas objVenta = new ClsVentas();
|
|
|
|
if (objVenta.GetVentas(CveVentaTerminal, -1, -1, "-1", -1, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
yPos = 10;
|
|
ImprimirLogo(e);
|
|
|
|
xPos = 1; // e.MarginBounds.Left
|
|
int EspacioCantidad = ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal ? 10 : 6;
|
|
int EspacioPrecio = ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal ? 11 : 9;
|
|
int EspacioOferta = ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal ? 11 : 9;
|
|
int EspacioImporte = ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal ? 14 : 11;
|
|
|
|
// la posición superior
|
|
// yPos = yPos + FontGrande.GetHeight(e.Graphics)
|
|
|
|
// imprimimos la cadena
|
|
// e.Graphics.DrawString("Hola, Mundo", FontGrande, Brushes.Black, xPos, yPos)
|
|
|
|
ImprimirLinea(Centrar(UsuarioActual.Sucursal, (int)ModVarsPV.TamanoTicketConfigurado, FontGrande), FontGrande, Brushes.Black, e);
|
|
ImprimirLinea(Izquierda(UsuarioActual.NombreEmpresa, (int)ModVarsPV.TamanoTicketConfigurado, FontChica), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0} {1}", UsuarioActual.Empresa.direccionField, UsuarioActual.Empresa.noExtField), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Col. {0}, Telefono: {1}", UsuarioActual.Empresa.coloniaField, UsuarioActual.Empresa.telefonoField), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}, {1}, C.P. {2}", UsuarioActual.Empresa.ciudadField, UsuarioActual.Empresa.estadoField, UsuarioActual.Empresa.cpField), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("R.F.C.: {0}", UsuarioActual.Empresa.rFCField), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}", UsuarioActual.Sucursal), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(Derecha(string.Format("Abre:{0} Imp:{1}", objVenta.FechaApertura.ToString("HH:mm"), DateTime.Now.ToString("HH:mm")), (int)ModVarsPV.TamanoTicketConfigurado, FontChica), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(Derecha(string.Format("{0}", objVenta.Mesa), (int)ModVarsPV.TamanoTicketConfigurado, FontMediana), FontMediana, Brushes.Black, e);
|
|
if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
ImprimirLinea(string.Format("{0} {1} Fecha: {2}", objVenta.CveVendedor, objVenta.Vendedor, objVenta.FechaApertura.ToString("dd/MMM/yyyy").ToUpper()), FontChica, Brushes.Black, e);
|
|
else
|
|
{
|
|
ImprimirLinea(string.Format("{0} {1}", objVenta.CveVendedor, objVenta.Vendedor), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Fecha: {0}", objVenta.FechaApertura.ToString("dd/MMM/yyyy").ToUpper()), FontChica, Brushes.Black, e);
|
|
}
|
|
ImprimirLinea(string.Format("Numero de Personas: {0}", objVenta.NumeroPersonas), FontChica, Brushes.Black, e);
|
|
|
|
ImprimirLinea("".PadLeft((int)ModVarsPV.TamanoTicketConfigurado, '_'), FontChica, Brushes.Black, e);
|
|
ImprimirLinea("Codigo Descripción ", FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}{1}{2}{3}", "Cant.".PadLeft(EspacioCantidad, ' '), "Precio".PadLeft(EspacioPrecio, ' '), "Oferta".PadLeft(EspacioOferta, ' '), "Importe".PadLeft(EspacioImporte, ' ')), FontChica, Brushes.Black, e, true);
|
|
// "999,999.00$999,999.00$999,999.00$9,999,999.00 "
|
|
|
|
if (objVenta.GetVentasDetalle(objVenta.CveVentaTerminal))
|
|
{
|
|
foreach (DataRow Row in objVenta.DtResultados.Tabla.Rows)
|
|
{
|
|
if (IsDBNull(Row["CveVentaDetalleTerminalPadre"]))
|
|
{
|
|
ImprimirLinea(string.Format("{0} {1}", Row["Codigo"].ToString().ToUpper().PadRight(10, ' '), Row["PS"].ToString().ToUpper()), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("{0}{1}{2}{3}", Row["Cantidad"].ToString().PadLeft(EspacioCantidad, ' '), FormatCurrency(!IsDBNull(Row("PrecioNeto")) ? Row("PrecioNeto") : 0).PadLeft(EspacioPrecio, ' '), FormatCurrency(!IsDBNull(Row("PUOfertaNeto")) ? Row("PUOfertaNeto") : 0).PadLeft(EspacioOferta, ' '), FormatCurrency(Row("Importe").ToString().ToDouble + Row("ImporteIVA").ToString().ToDouble - Row("Descuento").ToString().ToDouble).PadLeft(EspacioImporte)), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}{1}{2}{3}", Row["Cantidad"].ToString().PadLeft(EspacioCantidad, ' '), Convert.ToDecimal(!IsDBNull(Row["PrecioNeto"]) ? Row["PrecioNeto"] : 0).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(EspacioPrecio, ' '), Convert.ToDecimal(!IsDBNull(Row["PUOfertaNeto"]) ? Row["PUOfertaNeto"] : 0).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(EspacioOferta, ' '), (Convert.ToDouble(Row["Importe"].ToString()) + Convert.ToDouble(Row["ImporteIVA"].ToString()) - Convert.ToDouble(Row["Descuento"].ToString())).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(EspacioImporte)), FontChica, Brushes.Black, e);
|
|
|
|
}
|
|
else
|
|
// Los Productos del Combo
|
|
ImprimirLinea(string.Format("{0} {1}", Row["Cantidad"].ToString().PadLeft(EspacioCantidad, ' '), Row["PS"].ToString().ToUpper()), FontChica, Brushes.Black, e);
|
|
}
|
|
}
|
|
ImprimirLinea("".PadLeft((int)ModVarsPV.TamanoTicketConfigurado, '_'), FontChica, Brushes.Black, e);
|
|
// " Sub-Total $9,999,999.00 "
|
|
//ImprimirLinea(string.Format("Sub-Total {0} ", FormatCurrency(objVenta.SubTotal).PadLeft(13, ' ')).PadLeft((int)ModVarsPV.TamanoTicketConfigurado, ' '), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("Descuento {0} ", FormatCurrency(objVenta.Descuento).PadLeft(13, ' ')).PadLeft((int)ModVarsPV.TamanoTicketConfigurado, ' '), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("IVA {0} ", FormatCurrency(objVenta.IVA).PadLeft(13, ' ')).PadLeft((int)ModVarsPV.TamanoTicketConfigurado, ' '), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("TOTAL= {0} ", FormatCurrency(objVenta.Total).PadLeft(10, ' ')), FontGrande, Brushes.Black, e);
|
|
|
|
ImprimirLinea(string.Format("Sub-Total {0} ", objVenta.SubTotal.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(13, ' ')).PadLeft((int)ModVarsPV.TamanoTicketConfigurado, ' '), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Descuento {0} ", objVenta.Descuento.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(13, ' ')).PadLeft((int)ModVarsPV.TamanoTicketConfigurado, ' '), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("IVA {0} ", objVenta.IVA.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(13, ' ')).PadLeft((int)ModVarsPV.TamanoTicketConfigurado, ' '), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("TOTAL= {0} ", objVenta.Total.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(10, ' ')), FontGrande, Brushes.Black, e);
|
|
|
|
|
|
ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0} M.N.", EnLetras(objVenta.Total).ToUpper()), FontChica, Brushes.Black, e);
|
|
|
|
ImprimirLinea(objVenta.DescuentoPorcentaje > 0 ? string.Format("Se aplico un {0}% de descuento en su consumo", objVenta.DescuentoPorcentaje) : "", FontChica, Brushes.Black, e);
|
|
ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
ImprimirLinea(Centrar("PAGO EN UNA SOLA EXHIBICION", (int)ModVarsPV.TamanoTicketConfigurado, FontMediana), FontMediana, Brushes.Black, e);
|
|
ImprimirLinea(Centrar("* GRACIAS POR SU PREFERENCIA *", (int)ModVarsPV.TamanoTicketConfigurado, FontChica), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(Centrar("ESTE NO ES UN COMPROBANTE FISCAL", (int)ModVarsPV.TamanoTicketConfigurado, FontChica), FontChica, Brushes.Black, e);
|
|
ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
ImprimirLinea(".", FontChica, Brushes.Black, e);
|
|
|
|
e.HasMorePages = false;
|
|
}
|
|
|
|
objVenta.Dispose();
|
|
}
|
|
|
|
private void ImprimirComanda(PrintPageEventArgs e)
|
|
{
|
|
//DataTable tmpDT = dtVentasDetalles.FiltraParametros(string.Format("CveCategoria = {0}", CveCategoriaParaComanda.ToString()));
|
|
|
|
//if (tmpDT.Rows.Count > 0)
|
|
//{
|
|
// xPos = 1; // e.MarginBounds.Left
|
|
// // La fuente a usar
|
|
// int ComandaOrden;
|
|
// ClsVentas objVenta = new ClsVentas();
|
|
// // la posición superior
|
|
// float yPos = FontGrande.GetHeight(e.Graphics);
|
|
|
|
// objVenta.GetVentas(dtVentasDetalles.Rows(0)("CveVentaTerminal"), -1, -1, "-1", -1, -1, ModVars.UsuarioActual.CveEmpresa);
|
|
// // e.Graphics.DrawString("Hola, Mundo", FontGrande, Brushes.Black, xPos, yPos)
|
|
// ImprimirLinea(Centrar("- COMANDA -", ModVarsPV.TamanoTicketConfigurado, FontChica), FontChica, Brushes.Black, e);
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
|
|
// ImprimirLinea(ModVars.UsuarioActual.NombreEmpresa, FontGrande, Brushes.Black, e);
|
|
// ImprimirLinea("".PadLeft(ModVarsPV.TamanoTicketConfigurado, "_"), FontChica, Brushes.Black, e);
|
|
|
|
// ImprimirLinea("Cantidad Descripción ", FontChica, Brushes.Black, e);
|
|
|
|
// foreach (DataRow Row in tmpDT.Rows)
|
|
// {
|
|
// ImprimirLinea(string.Format("{0} {1}", Row("Cantidad").ToString().PadLeft(3, ' '), Row("PS")), FontChica, Brushes.Black, e, Row("EsPaquete"), Row("EsPaquete"));
|
|
// ComandaOrden = Row("ComandaOrden");
|
|
// // Buscar si hay alguna caracteristica especial para ese producto
|
|
// if (objVenta.GetVentasDetallesCaracteristicas(Row("CveVentaDetalleTerminal")))
|
|
// {
|
|
// foreach (DataRow RowC in objVenta.DtResultados.Tabla.Rows)
|
|
// ImprimirLinea(string.Format(" {0}", RowC("Opcion").ToString()), FontChica, Brushes.Black, e);
|
|
// }
|
|
// }
|
|
|
|
// // poner como impreso las comandas
|
|
// if (objVenta.UpdateImpresoComanda(objVenta.CveVentaTerminal, ComandaOrden))
|
|
// {
|
|
// }
|
|
|
|
// ImprimirLinea("".PadLeft(ModVarsPV.TamanoTicketConfigurado, "_"), FontChica, Brushes.Black, e);
|
|
|
|
// // Mesero y Mesa
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("Cuenta: {0}", objVenta.Cuenta), FontMediana, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("Orden: {0}", ComandaOrden), FontMediana, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("Mesa: {0}", objVenta.Mesa), FontMediana, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("Mesero: {0}", objVenta.Vendedor), FontMediana, Brushes.Black, e);
|
|
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("Fecha: {0} ", DateTime.Now), FontChica, Brushes.Black, e);
|
|
// ImprimirLinea(Centrar("_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _", ModVarsPV.TamanoTicketConfigurado, FontChica), FontChica, Brushes.Black, e);
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
|
|
// objVenta.Dispose();
|
|
// e.HasMorePages = false;
|
|
//}
|
|
}
|
|
private void ImprimirCorte(PrintPageEventArgs e)
|
|
{
|
|
ClsVta_Cortes objCortes = new ClsVta_Cortes();
|
|
ClsVentas objVentas = new ClsVentas();
|
|
double TotMP = 0;
|
|
double TotCxC = 0;
|
|
|
|
if (objCortes.GetVta_Cortes(CveCorteTerminal, "-1", "-1", -1, -1))
|
|
{
|
|
xPos = 1; // e.MarginBounds.Left
|
|
// la posición superior
|
|
float yPos = FontGrande.GetHeight(e.Graphics);
|
|
|
|
ImprimirLinea(Centrar(ImpresionCortePrevio == false ? "- CORTE DE TURNO -" : "- REPORTE DE TURNO -", (int)ModVarsPV.TamanoTicketConfigurado, FontChica), FontChica, Brushes.Black, e);
|
|
ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
|
|
ImprimirLinea(string.Format("{0}", UsuarioActual.Sucursal), FontGrande, Brushes.Black, e);
|
|
ImprimirLinea(Izquierda(UsuarioActual.NombreEmpresa, (int) ModVarsPV.TamanoTicketConfigurado, FontChica), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0} {1}", UsuarioActual.Empresa.direccionField, UsuarioActual.Empresa.noExtField), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Col. {0}, Telefono: {1}", UsuarioActual.Empresa.coloniaField, UsuarioActual.Empresa.telefonoField), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}, {1}, C.P. {2}", UsuarioActual.Empresa.ciudadField, UsuarioActual.Empresa.estadoField, UsuarioActual.Empresa.cpField), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("R.F.C.: {0}", UsuarioActual.Empresa.rFCField), FontChica, Brushes.Black, e);
|
|
|
|
|
|
//ImprimirLinea(string.Format("Descripcion : {0}", objCortes.Descripcion), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("Importe Inicial: {0}", FormatCurrency(objCortes.ImporteInicial).ToString().PadLeft(13, ' ')), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("Importe Final : {0}", ImpresionCortePrevio == false ? FormatCurrency(objCortes.ImporteFinal).ToString().PadLeft(13, ' ') : ""), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("Diferencia : {0}", ImpresionCortePrevio == false ? FormatCurrency(objCortes.Diferencia).ToString().PadLeft(13, ' ') : ""), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("Inicio : {0}", objCortes.FechaInicial), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("Termino: {0}", objCortes.FechaFinal.Year > 1 ? objCortes.FechaFinal : ""), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("Usuario: {0}", objCortes.UsuarioNombre), FontChica, Brushes.Black, e);
|
|
|
|
//ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("{0}: {1}", "Importe Inicial".PadRight(20, ' '), FormatCurrency(objCortes.ImporteInicial).ToString().PadLeft(12, ' ')), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("{0}:+ {1}", "Efectivo".PadRight(20, ' '), FormatCurrency(objCortes.VendidoEfectivo).ToString().PadLeft(12, ' ')), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("{0}:+ {1}", "Entradas".PadRight(20, ' '), FormatCurrency(objCortes.Ingresado).ToString().PadLeft(12, ' ')), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("{0}:- {1}", "Salidas".PadRight(20, ' '), FormatCurrency(objCortes.Retirado).ToString().PadLeft(12, ' ')), FontChica, Brushes.Black, e);
|
|
//ImprimirLinea(string.Format("{0}:- {1}", "Propinas".PadRight(20, ' '), FormatCurrency(objCortes.Propinas).ToString().PadLeft(12, ' ')), FontChica, Brushes.Black, e, true);
|
|
//ImprimirLinea(string.Format("{0}: {1}", "NETO DE EFECTIVO".PadRight(20, ' '), FormatCurrency(objCortes.ImporteInicial + objCortes.VendidoEfectivo + objCortes.Ingresado - objCortes.Retirado - objCortes.Propinas).ToString().PadLeft(12, ' ')), FontChica, Brushes.Black, e);
|
|
|
|
ImprimirLinea(string.Format("Descripcion : {0}", objCortes.Descripcion), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Importe Inicial: {0}", objCortes.ImporteInicial.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(13, ' ')), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Importe Final : {0}", !ImpresionCortePrevio ? objCortes.ImporteFinal.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(13, ' ') : ""), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Diferencia : {0}", !ImpresionCortePrevio ? objCortes.Diferencia.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(13, ' ') : ""), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Inicio : {0}", objCortes.FechaInicial), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Termino: {0}", objCortes.FechaFinal.Year > 1 ? objCortes.FechaFinal.ToString() : ""), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Usuario: {0}", objCortes.UsuarioNombre), FontChica, Brushes.Black, e);
|
|
|
|
ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}: {1}", "Importe Inicial".PadRight(20, ' '), objCortes.ImporteInicial.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(12, ' ')), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}:+ {1}", "Efectivo".PadRight(20, ' '), objCortes.VendidoEfectivo.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(12, ' ')), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}:+ {1}", "Entradas".PadRight(20, ' '), objCortes.Ingresado.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(12, ' ')), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}:- {1}", "Salidas".PadRight(20, ' '), objCortes.Retirado.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(12, ' ')), FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}:- {1}", "Propinas".PadRight(20, ' '), objCortes.Propinas.ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(12, ' ')), FontChica, Brushes.Black, e, true);
|
|
ImprimirLinea(string.Format("{0}: {1}", "NETO DE EFECTIVO".PadRight(20, ' '), (objCortes.ImporteInicial + objCortes.VendidoEfectivo + objCortes.Ingresado - objCortes.Retirado - objCortes.Propinas).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(12, ' ')), FontChica, Brushes.Black, e);
|
|
|
|
|
|
|
|
|
|
ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
ImprimirLinea("Detalle de Pagos", FontMediana, Brushes.Black, e, true);
|
|
int s = 1;
|
|
if (ImpresionCortePrevio == false)
|
|
{
|
|
if (objCortes.GetVta_CortesDetalles(CveCorteTerminal))
|
|
{
|
|
foreach (DataRow Row in objCortes.DtResultados.Tabla.Rows)
|
|
{
|
|
//ImprimirLinea(string.Format("{0}: {1}", Row["MetodoPago"].ToString(), 20).PadRight(20, ' '), Row["CveMetodoPago"].ToString().ToEntero() == 1 ? (Row["Importe"].ToString().ToDouble() - objCortes.Propinas).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).Substring(1).PadLeft(13, ' ') : Convert.ToDecimal(Row["Importe"]).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).Substring(1).PadLeft(13, ' '))), FontChica, Brushes.Black, e, s == objCortes.DtResultados.Tabla.Rows.Count ? true : false);
|
|
ImprimirLinea(string.Format("{0}: {1}", Row["MetodoPago"].ToString().PadRight(20, ' '), Row["CveMetodoPago"].ToString().ToEntero() == 1 ? (Row["Importe"].ToString().ToDouble() - objCortes.Propinas).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).Substring(1).PadLeft(13, ' ') : Convert.ToDecimal(Row["Importe"]).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).Substring(1).PadLeft(13, ' ')), FontChica, Brushes.Black, e, s == objCortes.DtResultados.Tabla.Rows.Count ? true : false);
|
|
|
|
|
|
TotMP = TotMP + Row["CveMetodoPago"].ToString().ToEntero() == 1 ? Row["Importe"].ToString().ToDouble() - objCortes.Propinas : Row["Importe"].ToString().ToDouble();
|
|
s = s + 1;
|
|
}
|
|
ImprimirLinea(string.Format("{0}: {1}", "Total Metodo Pago".PadRight(20, ' '), Strings.FormatCurrency(TotMP).ToString().PadLeft(13, ' ')), FontChica, Brushes.Black, e);
|
|
}
|
|
}
|
|
else if (objVentas.GetVta_VentasPago(CveCorteTerminal, UsuarioActual.CveEmpresa))
|
|
{
|
|
foreach (DataRow Row in objVentas.DtResultados.Tabla.Rows)
|
|
{
|
|
//ImprimirLinea(string.Format("{0}: {1}", Left(Row("MetodoPago"), 20).PadRight(20, ' '), Row("CveMetodoPago").ToString().ToEntero == 1 ? FormatCurrency(Row("Importe").ToString().ToDouble - objCortes.Propinas).ToString().PadLeft(13, ' ') : FormatCurrency(Row("Importe")).ToString().PadLeft(13, ' ')), FontChica, Brushes.Black, e, s == objVentas.DtResultados.Tabla.Rows.Count ? true : false);
|
|
ImprimirLinea(string.Format("{0}: {1}", Row["MetodoPago"].ToString().PadLeft(20).PadRight(20, ' '), Row["CveMetodoPago"].ToString().ToEntero() == 1 ? (Row["Importe"].ToString().ToDouble() - objCortes.Propinas).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).Substring(1).PadLeft(13, ' ') : Convert.ToDecimal(Row["Importe"]).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).Substring(1).PadLeft(13, ' ')), FontChica, Brushes.Black, e, s == objVentas.DtResultados.Tabla.Rows.Count ? true : false);
|
|
TotMP = TotMP + Row["CveMetodoPago"].ToString().ToEntero() == 1 ? Row["Importe"].ToString().ToDouble() - objCortes.Propinas : Row["Importe"].ToString().ToDouble();
|
|
s = s + 1;
|
|
}
|
|
ImprimirLinea(string.Format("{0}: {1}", "Total Metodo Pago".PadRight(20, ' '), Strings.FormatCurrency(TotMP).ToString().PadLeft(13, ' ')), FontChica, Brushes.Black, e);
|
|
}
|
|
|
|
if (objVentas.GetVentas(-1, -1, -1, "-1", CveCorteTerminal, -1, UsuarioActual.CveEmpresa))
|
|
{
|
|
if (objVentas.DtResultados.Tabla.FiltraParametros("Pagado < Total ").Rows.Count > 0)
|
|
{
|
|
s = 1;
|
|
ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
ImprimirLinea("Cuentas X Cobrar", FontMediana, Brushes.Black, e, true);
|
|
int numRows = objVentas.DtResultados.Tabla.FiltraParametros("Pagado < Total ").Rows.Count;
|
|
foreach (DataRow Row in objVentas.DtResultados.Tabla.FiltraParametros("Pagado < Total ").Rows)
|
|
{
|
|
//ImprimirLinea(string.Format("{0}: {1}", Left(Row("Nombre"), 20).PadRight(20, ' '), FormatCurrency(Row("Adeudo")).ToString().PadLeft(13, ' ')), FontChica, Brushes.Black, e, s == numRows ? true : false);
|
|
ImprimirLinea(string.Format("{0}: {1}", Row["Nombre"].ToString().PadLeft(20).PadRight(20, ' '), Convert.ToDecimal(Row["Adeudo"]).ToString("C", CultureInfo.CreateSpecificCulture("es-MX")).PadLeft(13, ' ')), FontChica, Brushes.Black, e, s == numRows ? true : false);
|
|
|
|
TotCxC = TotCxC + Row["Adeudo"].ToString().ToDouble();
|
|
s = s + 1;
|
|
}
|
|
|
|
ImprimirLinea(string.Format("{0}: {1}", "Total".PadRight(20, ' '), Strings.FormatCurrency(TotCxC).ToString().PadLeft(13, ' ')), FontChica, Brushes.Black, e);
|
|
}
|
|
}
|
|
|
|
|
|
ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("{0}: {1}", "TOTAL VENTA".PadRight(20, ' '), Strings.FormatCurrency(TotCxC + TotMP).ToString().PadLeft(13, ' ')), FontChica, Brushes.Black, e);
|
|
|
|
|
|
|
|
|
|
ImprimirLinea("".PadLeft((int)ModVarsPV.TamanoTicketConfigurado, '_'), FontChica, Brushes.Black, e);
|
|
|
|
ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
ImprimirLinea(string.Format("Fecha: {0} ", DateTime.Now), FontChica, Brushes.Black, e);
|
|
e.HasMorePages = false;
|
|
}
|
|
|
|
objVentas.Dispose();
|
|
objCortes.Dispose();
|
|
}
|
|
private void ImprimirMovimientoCaja(PrintPageEventArgs e)
|
|
{
|
|
//ClsVta_MovimientosCaja objMovimientoCaja = new ClsVta_MovimientosCaja();
|
|
|
|
//if (objMovimientoCaja.GetVta_MovimientosCaja(CveMovimientoTerminal, -1, -1))
|
|
//{
|
|
// xPos = 1; // e.MarginBounds.Left
|
|
// // la posición superior
|
|
// float yPos = FontGrande.GetHeight(e.Graphics);
|
|
|
|
// // imprimimos la cadena
|
|
// // e.Graphics.DrawString("Hola, Mundo", FontGrande, Brushes.Black, xPos, yPos)
|
|
// ImprimirLinea(ModVars.UsuarioActual.NombreEmpresa, FontGrande, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("{0} {1}", ModVars.UsuarioActual.Empresa.direccionField, ModVars.UsuarioActual.Empresa.noExtField), FontChica, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("Col. {0}, Telefono: {1}", ModVars.UsuarioActual.Empresa.coloniaField, ModVars.UsuarioActual.Empresa.telefonoField), FontChica, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("{0}, {1}, C.P. {2}", ModVars.UsuarioActual.Empresa.ciudadField, ModVars.UsuarioActual.Empresa.estadoField, ModVars.UsuarioActual.Empresa.cpField), FontChica, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("R.F.C.: {0}", ModVars.UsuarioActual.Empresa.rFCField), FontChica, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("{0}", ModVars.UsuarioActual.Sucursal), FontChica, Brushes.Black, e);
|
|
|
|
// ImprimirLinea("".PadLeft(ModVarsPV.TamanoTicketConfigurado, "_"), FontChica, Brushes.Black, e);
|
|
// ImprimirLinea(objMovimientoCaja.TipoMovimiento == 1 ? "INGRESO DE DINERO" : "RETIRO DE DINERO", FontMediana, Brushes.Black, e);
|
|
|
|
// ImprimirLinea(string.Format("Usuario: {0}", objMovimientoCaja.Usuario), FontMediana, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("Cantidad: {0}", FormatCurrency(objMovimientoCaja.Importe)), FontMediana, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("Descripcion: {0}", objMovimientoCaja.Descripcion), FontMediana, Brushes.Black, e);
|
|
|
|
// ImprimirLinea("".PadLeft(ModVarsPV.TamanoTicketConfigurado, "_"), FontChica, Brushes.Black, e);
|
|
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
|
|
// ImprimirLinea(Centrar("_____________________", ModVarsPV.TamanoTicketConfigurado, FontChica), FontChica, Brushes.Black, e);
|
|
// ImprimirLinea(Centrar("FIRMA", ModVarsPV.TamanoTicketConfigurado, FontChica), FontChica, Brushes.Black, e);
|
|
|
|
// ImprimirLinea("", FontChica, Brushes.Black, e);
|
|
// ImprimirLinea(string.Format("Fecha: {0} Folio: {1}", objMovimientoCaja.Fecha.ToString("dd/MM/yyyy"), objMovimientoCaja.CveMovimientoTerminal), FontChica, Brushes.Black, e);
|
|
// e.HasMorePages = false;
|
|
//}
|
|
|
|
//objMovimientoCaja.Dispose();
|
|
}
|
|
|
|
public string Centrar(string Cadena, int Tamaño, Font Font, bool AfectarTamaño = true)
|
|
{
|
|
string CadenaCentrada = "";
|
|
//if (AfectarTamaño)
|
|
//{
|
|
// switch (Font.Size)
|
|
// {
|
|
// case 8:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño;
|
|
// else
|
|
// Tamaño = Tamaño - 10;
|
|
// break;
|
|
// }
|
|
|
|
// case 11:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño - 18;
|
|
// break;
|
|
// }
|
|
|
|
// case 12:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño;
|
|
// else
|
|
// Tamaño = Tamaño - 18;
|
|
// break;
|
|
// }
|
|
|
|
// case 14:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño - 25;
|
|
// break;
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
|
|
//int TamañoCadena = Cadena.Length;
|
|
//var SaltoLinea = Constants.vbNewLine;
|
|
|
|
//if (TamañoCadena > Tamaño)
|
|
//{
|
|
// CadenaCentrada = Cadena.Substring(0, Tamaño);
|
|
// TamañoCadena = TamañoCadena - Tamaño;
|
|
// yPosPendiente = yPosPendiente + Font.GetHeight;
|
|
// return Centrar(CadenaCentrada, Tamaño, Font, false) + SaltoLinea + Centrar(Cadena.Substring(Tamaño, TamañoCadena), Tamaño, Font, false);
|
|
//}
|
|
|
|
//int EspacioIzquierda = (Tamaño - TamañoCadena) / (double)2;
|
|
|
|
//CadenaCentrada = Cadena.PadLeft(EspacioIzquierda + TamañoCadena, ' ');
|
|
|
|
return CadenaCentrada;
|
|
}
|
|
|
|
public string Derecha(string Cadena, int Tamaño, Font Font)
|
|
{
|
|
string CadenaDerecha = "";
|
|
//switch (Font.Size)
|
|
//{
|
|
// case 8:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño;
|
|
// else
|
|
// Tamaño = Tamaño - 10;
|
|
// break;
|
|
// }
|
|
|
|
// case 11:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño - 18;
|
|
// break;
|
|
// }
|
|
|
|
// case 12:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño;
|
|
// else
|
|
// Tamaño = Tamaño;
|
|
// break;
|
|
// }
|
|
|
|
// case 14:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño - 25;
|
|
// break;
|
|
// }
|
|
//}
|
|
|
|
//int TamañoCadena = Cadena.Length;
|
|
//var SaltoLinea = Constants.vbNewLine;
|
|
|
|
//if (TamañoCadena > Tamaño)
|
|
//{
|
|
// CadenaDerecha = Cadena.Substring(0, Tamaño);
|
|
// TamañoCadena = TamañoCadena - Tamaño;
|
|
// yPosPendiente = yPosPendiente + Font.GetHeight;
|
|
// return Derecha(CadenaDerecha, Tamaño, Font) + SaltoLinea + Derecha(Cadena.Substring(Tamaño, TamañoCadena), Tamaño, Font);
|
|
//}
|
|
|
|
//int EspacioIzquierda = Tamaño - TamañoCadena;
|
|
|
|
//CadenaDerecha = Cadena.PadLeft(EspacioIzquierda + TamañoCadena, ' ');
|
|
|
|
return CadenaDerecha;
|
|
}
|
|
|
|
public string Izquierda(string Cadena, int Tamaño, Font Font)
|
|
{
|
|
string CadenaIzquierda = "";
|
|
//switch (Font.Size)
|
|
//{
|
|
// case 8:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño;
|
|
// else
|
|
// Tamaño = Tamaño - 10;
|
|
// break;
|
|
// }
|
|
|
|
// case 11:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño - 18;
|
|
// break;
|
|
// }
|
|
|
|
// case 12:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño;
|
|
// else
|
|
// Tamaño = Tamaño;
|
|
// break;
|
|
// }
|
|
|
|
// case 14:
|
|
// {
|
|
// if (ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal)
|
|
// Tamaño = Tamaño - 25;
|
|
// break;
|
|
// }
|
|
//}
|
|
|
|
//int TamañoCadena = Cadena.Length;
|
|
//var SaltoLinea = Constants.vbNewLine;
|
|
|
|
//if (TamañoCadena > Tamaño)
|
|
//{
|
|
// CadenaIzquierda = Cadena.Substring(0, Tamaño);
|
|
// TamañoCadena = TamañoCadena - Tamaño;
|
|
// yPosPendiente = yPosPendiente + Font.GetHeight;
|
|
// return Izquierda(CadenaIzquierda, Tamaño, Font) + SaltoLinea + Izquierda(Cadena.Substring(Tamaño, TamañoCadena).Trim(), Tamaño, Font);
|
|
//}
|
|
|
|
//int EspacioIzquierda = Tamaño - TamañoCadena;
|
|
|
|
//CadenaIzquierda = Cadena.PadRight(EspacioIzquierda + TamañoCadena, ' ');
|
|
|
|
return CadenaIzquierda;
|
|
}
|
|
public void Imprimir(int Cve_, TipoImpresion TipoImp_, TamanoTicket Tamano_)
|
|
{
|
|
switch (TipoImp_)
|
|
{
|
|
case TipoImpresion.Venta:
|
|
{
|
|
CveVentaTerminal = Cve_;
|
|
break;
|
|
}
|
|
|
|
case TipoImpresion.Comanda:
|
|
{
|
|
CveCategoriaParaComanda = Cve_;
|
|
break;
|
|
}
|
|
|
|
case TipoImpresion.MovimientoCaja:
|
|
{
|
|
CveMovimientoTerminal = Cve_;
|
|
break;
|
|
}
|
|
|
|
case TipoImpresion.Corte:
|
|
{
|
|
CveCorteTerminal = Cve_;
|
|
break;
|
|
}
|
|
}
|
|
TipoImp = TipoImp_;
|
|
|
|
printDoc.Print();
|
|
}
|
|
private void ImprimirLogo(PrintPageEventArgs e)
|
|
{
|
|
//string Ruta = string.Format(@"{0}\{1}.jpg", System.IO.Directory.GetCurrentDirectory(), ModVars.UsuarioActual.CveSucursal);
|
|
//if (System.IO.File.Exists(Ruta))
|
|
//{
|
|
// Bitmap imagen = new Bitmap(Ruta);
|
|
// int HeightImagen = ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal ? 100 : 50; // Inicialmente el alto sera de 100 para Normal y 50 para Chico
|
|
// int WidthImagen = HeightImagen * imagen.Width / (double)imagen.Height;
|
|
// int TamanoPixelesTicket = ModVarsPV.TamanoTicketConfigurado == TamanoTicket.Normal ? 280 : 180;
|
|
// int MargenPorLado = 20;
|
|
|
|
// if (WidthImagen + (MargenPorLado * 2) > TamanoPixelesTicket)
|
|
// {
|
|
// // si se supera el ancho ajustar el alto
|
|
// WidthImagen = TamanoPixelesTicket - (MargenPorLado * 2);
|
|
// HeightImagen = WidthImagen * imagen.Height / (double)imagen.Width;
|
|
// }
|
|
|
|
// xPos = (TamanoPixelesTicket - WidthImagen) / (double)2;
|
|
|
|
// e.Graphics.DrawImage(imagen, xPos, yPos, WidthImagen, HeightImagen);
|
|
// yPos = yPos + HeightImagen + 10;
|
|
//}
|
|
}
|
|
|
|
public Bitmap ResizeBitmap(Bitmap b, int nWidth, int nHeight)
|
|
{
|
|
Bitmap result = new Bitmap(nWidth, nHeight);
|
|
using (Graphics g = Graphics.FromImage((Image)result))
|
|
{
|
|
g.DrawImage(b, 0, 0, nWidth, nHeight);
|
|
}
|
|
return result;
|
|
}
|
|
private void ImprimirLinea(string Texto, Font Font, Brush Color, PrintPageEventArgs e, bool Subrayado = false, bool Negrita = false)
|
|
{
|
|
|
|
if (Subrayado == true & Negrita == true)
|
|
Font = new Font(Font.Name, Font.Size, FontStyle.Bold ^ FontStyle.Underline);
|
|
else
|
|
{
|
|
Font = Subrayado == true ? new Font(Font.Name, Font.Size, FontStyle.Underline) : new Font(Font.Name, Font.Size, Font.Style);
|
|
Font = Negrita == true ? new Font(Font.Name, Font.Size, FontStyle.Bold) : new Font(Font.Name, Font.Size, Font.Style);
|
|
}
|
|
|
|
e.Graphics.DrawString(Texto, Font, Color, xPos, yPos);
|
|
yPos = yPos + yPosPendiente + (int)Font.GetHeight(e.Graphics);
|
|
yPosPendiente = 0;
|
|
}
|
|
|
|
public string EnLetras(double Valor)
|
|
{
|
|
int b, paso;
|
|
string expresion, entero, deci, flag, EnLetras = "";
|
|
expresion = string.Empty;
|
|
entero = string.Empty; deci = string.Empty;
|
|
|
|
string Numero = Valor.ToString();
|
|
|
|
Numero = Strings.Trim(Numero);
|
|
flag = "N";
|
|
for (paso = 1; paso <= Strings.Len(Numero); paso++)
|
|
{
|
|
if (Strings.Mid(Numero, paso, 1) == ".")
|
|
flag = "S";
|
|
else if (flag == "N")
|
|
entero = entero + Strings.Mid(Numero, paso, 1); // Extae la parte entera del numero
|
|
else
|
|
deci = deci + Strings.Mid(Numero, paso, 1);// Extrae la parte decimal del numero
|
|
}
|
|
|
|
if (Strings.Len(deci) == 1)
|
|
deci = deci + "0";
|
|
|
|
flag = "N";
|
|
if (Conversion.Val(Numero) >= -999999999 & Conversion.Val(Numero) <= 999999999)
|
|
{
|
|
for (paso = Strings.Len(entero); paso >= 1; paso += -1)
|
|
{
|
|
b = Strings.Len(entero) - (paso - 1);
|
|
switch (paso)
|
|
{
|
|
case 3:
|
|
case 6:
|
|
case 9:
|
|
{
|
|
switch (Strings.Mid(entero, b, 1))
|
|
{
|
|
case "1":
|
|
{
|
|
if (Strings.Mid(entero, b + 1, 1) == "0" & Strings.Mid(entero, b + 2, 1) == "0")
|
|
expresion = expresion + "cien ";
|
|
else
|
|
expresion = expresion + "ciento ";
|
|
break;
|
|
}
|
|
|
|
case "2":
|
|
{
|
|
expresion = expresion + "doscientos ";
|
|
break;
|
|
}
|
|
|
|
case "3":
|
|
{
|
|
expresion = expresion + "trescientos ";
|
|
break;
|
|
}
|
|
|
|
case "4":
|
|
{
|
|
expresion = expresion + "cuatrocientos ";
|
|
break;
|
|
}
|
|
|
|
case "5":
|
|
{
|
|
expresion = expresion + "quinientos ";
|
|
break;
|
|
}
|
|
|
|
case "6":
|
|
{
|
|
expresion = expresion + "seiscientos ";
|
|
break;
|
|
}
|
|
|
|
case "7":
|
|
{
|
|
expresion = expresion + "setecientos ";
|
|
break;
|
|
}
|
|
|
|
case "8":
|
|
{
|
|
expresion = expresion + "ochocientos ";
|
|
break;
|
|
}
|
|
|
|
case "9":
|
|
{
|
|
expresion = expresion + "novecientos ";
|
|
break;
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case 2:
|
|
case 5:
|
|
case 8:
|
|
{
|
|
switch (Strings.Mid(entero, b, 1))
|
|
{
|
|
case "1":
|
|
{
|
|
if (Strings.Mid(entero, b + 1, 1) == "0")
|
|
{
|
|
flag = "S";
|
|
expresion = expresion + "diez ";
|
|
}
|
|
if (Strings.Mid(entero, b + 1, 1) == "1")
|
|
{
|
|
flag = "S";
|
|
expresion = expresion + "once ";
|
|
}
|
|
if (Strings.Mid(entero, b + 1, 1) == "2")
|
|
{
|
|
flag = "S";
|
|
expresion = expresion + "doce ";
|
|
}
|
|
if (Strings.Mid(entero, b + 1, 1) == "3")
|
|
{
|
|
flag = "S";
|
|
expresion = expresion + "trece ";
|
|
}
|
|
if (Strings.Mid(entero, b + 1, 1) == "4")
|
|
{
|
|
flag = "S";
|
|
expresion = expresion + "catorce ";
|
|
}
|
|
if (Strings.Mid(entero, b + 1, 1) == "5")
|
|
{
|
|
flag = "S";
|
|
expresion = expresion + "quince ";
|
|
}
|
|
if (ModExtensiones.Mid(entero, b + 1, 1).ToEntero() > 5)
|
|
{
|
|
flag = "N";
|
|
expresion = expresion + "dieci";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case "2":
|
|
{
|
|
if (Strings.Mid(entero, b + 1, 1) == "0")
|
|
{
|
|
expresion = expresion + "veinte ";
|
|
flag = "S";
|
|
}
|
|
else
|
|
{
|
|
expresion = expresion + "veinti";
|
|
flag = "N";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case "3":
|
|
{
|
|
if (Strings.Mid(entero, b + 1, 1) == "0")
|
|
{
|
|
expresion = expresion + "treinta ";
|
|
flag = "S";
|
|
}
|
|
else
|
|
{
|
|
expresion = expresion + "treinta y ";
|
|
flag = "N";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case "4":
|
|
{
|
|
if (Strings.Mid(entero, b + 1, 1) == "0")
|
|
{
|
|
expresion = expresion + "cuarenta ";
|
|
flag = "S";
|
|
}
|
|
else
|
|
{
|
|
expresion = expresion + "cuarenta y ";
|
|
flag = "N";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case "5":
|
|
{
|
|
if (Strings.Mid(entero, b + 1, 1) == "0")
|
|
{
|
|
expresion = expresion + "cincuenta ";
|
|
flag = "S";
|
|
}
|
|
else
|
|
{
|
|
expresion = expresion + "cincuenta y ";
|
|
flag = "N";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case "6":
|
|
{
|
|
if (Strings.Mid(entero, b + 1, 1) == "0")
|
|
{
|
|
expresion = expresion + "sesenta ";
|
|
flag = "S";
|
|
}
|
|
else
|
|
{
|
|
expresion = expresion + "sesenta y ";
|
|
flag = "N";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case "7":
|
|
{
|
|
if (Strings.Mid(entero, b + 1, 1) == "0")
|
|
{
|
|
expresion = expresion + "setenta ";
|
|
flag = "S";
|
|
}
|
|
else
|
|
{
|
|
expresion = expresion + "setenta y ";
|
|
flag = "N";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case "8":
|
|
{
|
|
if (Strings.Mid(entero, b + 1, 1) == "0")
|
|
{
|
|
expresion = expresion + "ochenta ";
|
|
flag = "S";
|
|
}
|
|
else
|
|
{
|
|
expresion = expresion + "ochenta y ";
|
|
flag = "N";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case "9":
|
|
{
|
|
if (Strings.Mid(entero, b + 1, 1) == "0")
|
|
{
|
|
expresion = expresion + "noventa ";
|
|
flag = "S";
|
|
}
|
|
else
|
|
{
|
|
expresion = expresion + "noventa y ";
|
|
flag = "N";
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case 1:
|
|
case 4:
|
|
case 7:
|
|
{
|
|
switch (Strings.Mid(entero, b, 1))
|
|
{
|
|
case "1":
|
|
{
|
|
if (flag == "N")
|
|
{
|
|
if (paso == 1)
|
|
expresion = expresion + "uno ";
|
|
else
|
|
expresion = expresion + "un ";
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case "2":
|
|
{
|
|
if (flag == "N")
|
|
expresion = expresion + "dos ";
|
|
break;
|
|
}
|
|
|
|
case "3":
|
|
{
|
|
if (flag == "N")
|
|
expresion = expresion + "tres ";
|
|
break;
|
|
}
|
|
|
|
case "4":
|
|
{
|
|
if (flag == "N")
|
|
expresion = expresion + "cuatro ";
|
|
break;
|
|
}
|
|
|
|
case "5":
|
|
{
|
|
if (flag == "N")
|
|
expresion = expresion + "cinco ";
|
|
break;
|
|
}
|
|
|
|
case "6":
|
|
{
|
|
if (flag == "N")
|
|
expresion = expresion + "seis ";
|
|
break;
|
|
}
|
|
|
|
case "7":
|
|
{
|
|
if (flag == "N")
|
|
expresion = expresion + "siete ";
|
|
break;
|
|
}
|
|
|
|
case "8":
|
|
{
|
|
if (flag == "N")
|
|
expresion = expresion + "ocho ";
|
|
break;
|
|
}
|
|
|
|
case "9":
|
|
{
|
|
if (flag == "N")
|
|
expresion = expresion + "nueve ";
|
|
break;
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
if (paso == 4)
|
|
{
|
|
if (Strings.Mid(entero, 6, 1) != "0" | Strings.Mid(entero, 5, 1) != "0" | Strings.Mid(entero, 4, 1) != "0" | (Strings.Mid(entero, 6, 1) == "0" & Strings.Mid(entero, 5, 1) == "0" & Strings.Mid(entero, 4, 1) == "0" & Strings.Len(entero) <= 6))
|
|
expresion = expresion + "mil ";
|
|
}
|
|
if (paso == 7)
|
|
{
|
|
if (Strings.Len(entero) == 7 & Strings.Mid(entero, 1, 1) == "1")
|
|
expresion = expresion + "millón ";
|
|
else
|
|
expresion = expresion + "millones ";
|
|
}
|
|
}
|
|
|
|
if (deci != "")
|
|
{
|
|
if (Strings.Mid(entero, 1, 1) == "-")
|
|
{ EnLetras = "menos " + expresion + "con " + deci + "/100 M.N."; }
|
|
else
|
|
{ EnLetras = expresion + "con " + deci + "/100 M.N."; }
|
|
}
|
|
else if (Strings.Mid(entero, 1, 1) == "-")
|
|
{ EnLetras = "menos " + expresion; }
|
|
else
|
|
{ EnLetras = Strings.UCase(expresion); }
|
|
}
|
|
else
|
|
{ EnLetras = ""; }
|
|
|
|
return EnLetras;
|
|
}
|
|
|
|
}
|
|
}
|