martes, 26 de marzo de 2024

Formateando una tabla (browse)

 

//Desplegando un renglón

IF COL_Estatus = 20 THEN

TABLE_DB_Inv_Inversion[TABLE_DB_Inv_Inversion]..Color = DarkGreen

TABLE_DB_Inv_Inversion[TABLE_DB_Inv_Inversion]..FontBold = True

TABLE_DB_Inv_Inversion[TABLE_DB_Inv_Inversion]..FontSize = 9

ELSE IF COL_Estatus = 15 THEN

TABLE_DB_Inv_Inversion[TABLE_DB_Inv_Inversion]..Color = LightRed

TABLE_DB_Inv_Inversion[TABLE_DB_Inv_Inversion]..FontBold = True

TABLE_DB_Inv_Inversion[TABLE_DB_Inv_Inversion]..FontSize = 9

END


jueves, 8 de febrero de 2024

SINCRONIZAR HORARIO CON HORA DEL SERVIDOR

 //SINCRONIZA HORARIO COM A HORA DO SERVIDOR  //ADRIANO BOLLER


PathFile is string = fCurrentDir ( fCurrentDrive() ) +"\config.ini"

IF CBOX_Sincronizar..Value = True THEN
Sincronizar = "S"
ok is boolean = INIWrite("Nagyro", "Sincronizar", Sincronizar , PathFile)
IF ErrorOccurred = True AND Sincronizar = "" THEN
Error()
END
ELSE
Sincronizar = "N"
ok is boolean = INIWrite("Nagyro", "Sincronizar", Sincronizar , PathFile)
IF ErrorOccurred = True AND Sincronizar = "" THEN
Error()
END
END

IF Sincronizar = "S" THEN
ExeRun("NET TIME \\192.168.1.180 /SET /YES",exeIconize,exeDontWait)
END

miércoles, 26 de julio de 2023

Número a letras 2


PROCEDURE entero_a_letras(numero)
nEntero is int
nTemporal is int
sLetras is string
nEntero = numero
SWITCH nEntero
    CASE 0 : sLetras = "CERO"
    CASE 1 : sLetras = "UN"
    CASE 2 : sLetras = "DOS"
    CASE 3 : sLetras = "TRES"
    CASE 4 : sLetras = "CUATRO"
    CASE 5 : sLetras = "CINCO"
    CASE 6 : sLetras = "SEIS"
    CASE 7 : sLetras = "SIETE"
    CASE 8 : sLetras = "OCHO"
    CASE 9 : sLetras = "NUEVE"
    CASE 10 : sLetras = "DIEZ"
    CASE 11 : sLetras = "ONCE"
    CASE 12 : sLetras = "DOCE"
    CASE 13 : sLetras = "TRECE"
    CASE 14 : sLetras = "CATORCE"
    CASE 15 : sLetras = "QUINCE"
    CASE < 20 : sLetras = "DIECI" + entero_a_letras(nEntero - 10)
    CASE 20 : sLetras = "VEINTE"
    CASE < 30 : sLetras = "VEINTI" + entero_a_letras(nEntero - 20)
    CASE 30 : sLetras = "TREINTA"
    CASE 40 : sLetras = "CUARENTA"
    CASE 50 : sLetras = "CINCUENTA"
    CASE 60 : sLetras = "SESENTA"
    CASE 70 : sLetras = "SETENTA"
    CASE 80 : sLetras = "OCHENTA"
    CASE 90 : sLetras = "NOVENTA"
    CASE < 100 :
        nTemporal = nEntero / 10
        nTemporal = nTemporal * 10
        sLetras = entero_a_letras(nTemporal) + "  Y  " + entero_a_letras(nEntero-nTemporal)
    CASE 100 : sLetras = "CIEN"
    CASE < 200 : sLetras = "CIENTO " + entero_a_letras(nEntero - 100)
    CASE 200, 300, 400, 600, 800 : sLetras = entero_a_letras(nEntero/100) + "CIENTOS"
    CASE 500 : sLetras = "QUINIENTOS"
    CASE 700 : sLetras = "SETECIENTOS"
    CASE 900 : sLetras = "NOVECIENTOS"
    CASE < 1000 :
        nTemporal = nEntero / 100
        nTemporal = nTemporal * 100
        sLetras = entero_a_letras(nTemporal) + " " + entero_a_letras(nEntero-nTemporal)
    CASE 1000 : sLetras = "MIL"
    CASE < 2000 : sLetras = "MIL " + entero_a_letras(nEntero-1000)
    CASE < 1000000 :
        sLetras = entero_a_letras(nEntero/1000) + " MIL"
        nTemporal = nEntero / 1000
        nTemporal = nTemporal * 1000
        nTemporal = nEntero - nTemporal
        IF nTemporal < 1000 AND nTemporal > 0 THEN
            sLetras = sLetras + "  " + entero_a_letras(nTemporal)
        END
    CASE 1000000 : sLetras = "UN MILLON"
    CASE < 2000000 : sLetras = "UN MILLON " + entero_a_letras(nEntero - 1000000)
    CASE < 1000000000000 :
        sLetras = entero_a_letras(nEntero/1000000) + " MILLONES"
        nTemporal = nEntero / 1000000
        nTemporal = nTemporal * 1000000
        nTemporal = nEntero - nTemporal
        IF nTemporal < 1000000 AND nTemporal > 0 THEN
            sLetras = sLetras + "  " + entero_a_letras(nTemporal)          
        END
END
RESULT sLetras

PROCEDURE centavos_a_letras(numero)
sCentavos is string
xDecimales is numeric
 
 
xDecimales = DecimalPart(numero)
xDecimales = xDecimales * 100
 
 
IF xDecimales = 0 THEN
    sCentavos = " PESOS 00/100 M.N."
ELSE
    IF xDecimales < 10 THEN
        sCentavos = " PESOS 0" + xDecimales + "/100 M.N."
    ELSE
        sCentavos = " PESOS " + xDecimales + "/100 M.N."
    END
END
RESULT sCentavos

Conexión BD MySQL

Instalar

wd240msql64.DLL
libmysql.dll
en
C:\PC SOFT\WINDEV 24\Programs\Framework\Win64x86
y también en el ejecutable


 IF InTestMode() = True THEN
////*******************************************************************
MiConTest is Connection   //conexión de pruebas
MiConTest..User = "supervisor"
MiConTest..Password = "supervisor"
MiConTest..Server = "localhost"
MiConTest..Database = "FarmaWD"
MiConTest..Provider = hNativeAccessMySQL
MiConTest..Access = hOReadWrite
MiConTest..ExtendedInfo = "Extended information"
MiConTest..CursorOptions = hClientCursor
MiConTest..Caption               = "AMBIENTE DE PRUEBAS"
HOpenConnection(MiConTest)   // Open the connection
HChangeConnection("*", MiConTest) // Assign the connection to all data files
ELSE
MiConFarma is Connection   //conexión de produccion
MiConFarma..User = "supervisor"
MiConFarma..Password = "supervisor"
MiConFarma..Server = "localhost"
MiConFarma..Database = "FarmaWD"
MiConFarma..Provider = hNativeAccessMySQL
MiConFarma..Access = hOReadWrite
MiConFarma..ExtendedInfo = "Extended information"
MiConFarma..CursorOptions = hClientCursor
MiConFarma..Caption        = "AMBIENTE DE PRODUCCION"
HOpenConnection(MiConFarma)   // Open the connection
HChangeConnection("*", MiConFarma) // Assign the connection to all data files
END

viernes, 30 de junio de 2023

Crear Excel

 MyWorksheet is xlsDocument

xlsAddWorksheet(MyWorksheet, "R04_C-0451")

//MyWorksheet = xlsOpen(sNombreArchivoXLS, xlsWrite)

xlsCurrentWorksheet(MyWorksheet, 1)

nColumna is int 

nRenglon is int = 1


FOR nColumna = 1 TO 15

MyWorksheet[nRenglon,nColumna]..BackgroundColor = LightYellow

MyWorksheet[nRenglon,nColumna]..Border..LineTop..Thickness = 3

MyWorksheet[nRenglon,nColumna]..Border..LineBottom..Thickness = 3

MyWorksheet[nRenglon,nColumna]..Font..Bold = True

MyWorksheet[nRenglon,nColumna]..AlignmentH = haCenter

MyWorksheet[nRenglon,nColumna]..AlignmentV = vaMiddle

MyWorksheet[nRenglon,nColumna] = nColumna

END


nRenglon++


MyWorksheet[nRenglon,03] = "NUMERO DE REPORTE"

MyWorksheet[nRenglon,04] = "NUMERO DE SOCIO"

MyWorksheet[nRenglon,05] = "TIPO DE SOCIO"

MyWorksheet[nRenglon,06] = "NOMBRE O DENOMINACION SOCIAL DEL ACREDITADO"

MyWorksheet[nRenglon,07] = "APELLIDO PATERNO DEL ACREDITADO"

MyWorksheet[nRenglon,08] = "APELLIDO MATERNO DEL ACREDITADO"

MyWorksheet[nRenglon,09] = "PERSONALIDAD JURIDICA DEL ACREDITADO"

MyWorksheet[nRenglon,10] = "GRUPO DE RIESGO"

MyWorksheet[nRenglon,11] = "ACTIVIDAD ECONÓMICA DEL ACREDITADO"

MyWorksheet[nRenglon,12] = "FECHA DE NACIMIENTO / CONSTITUCION DEL ACREDITADO"

MyWorksheet[nRenglon,13] = "RFC DEL ACREDITADO"

MyWorksheet[nRenglon,14] = "CURP DEL ACREDITADO"

MyWorksheet[nRenglon,15] = "EDAD DEL ACREDITADO"


nRenglon++

MyWorksheet[nRenglon,03] = sC03_Reporte

MyWorksheet[nRenglon,04] = nC04_NoSocio

MyWorksheet[nRenglon,05] = nC05_TipoSocio

MyWorksheet[nRenglon,06] = sC06_NombreSocio

MyWorksheet[nRenglon,07] = sC07_PaternoSocio

MyWorksheet[nRenglon,08] = sC08_MaternoSocio

MyWorksheet[nRenglon,09] = nC09_Personalidad

MyWorksheet[nRenglon,10] = sC10_GrupoRiesgo

MyWorksheet[nRenglon,11] = sC11_Actividad

MyWorksheet[nRenglon,12] = sC12_FNacimiento

MyWorksheet[nRenglon,13] = sC13_RFC

MyWorksheet[nRenglon,14] = sC14_CURP

MyWorksheet[nRenglon,15] = nC15_EdadSocio

fSaveText (sNombreArchivoCSV, sFileContent)

xlsSave(MyWorksheet, sNombreArchivoXLS)


Info("Proceso concluido", sNombreArchivoCSV,sNombreArchivoXLS )




lunes, 3 de octubre de 2022

Operaciones sobre tablas

//Agregar un registro
nRenglon = TableCount(TABLE_Detalle)
nRenglon++
TableAdd(TABLE_Detalle)
TABLE_Detalle[nRenglon].COL_IdDB_Articulo = DB_Articulo.IdDB_Articulo
TABLE_Detalle[nRenglon].COL_CodBarras = DB_Articulo.CodigoBarra
TABLE_Detalle[nRenglon].COL_Descripcion = DB_Articulo.Descripcion
TABLE_Detalle[nRenglon].COL_Caducidad = EDT_Caducidad
TABLE_Detalle[nRenglon].COL_Lote = EDT_Lote
TABLE_Detalle[nRenglon].COL_PrecMaxPub = EDT_PrecioMaxPublico
TABLE_Detalle[nRenglon].COL_Cantidad = EDT_Cantidad
TABLE_Detalle[nRenglon].COL_ValorUnitario = EDT_ValorUnitario
TABLE_Detalle[nRenglon].COL_Importe = EDT_Importe
TABLE_Detalle[nRenglon].COL_Descuento = EDT_Descuento
TABLE_Detalle[nRenglon].COL_IVAMonto = EDT_IVA
TABLE_Detalle[nRenglon].COL_IVATasa = EDT_IVATasa
TABLE_Detalle[nRenglon].COL_IEPSMonto = EDT_IEPS
TABLE_Detalle[nRenglon].COL_IEPSTasa = EDT_IEPSTasa
TABLE_Detalle[nRenglon].COL_Total = EDT_Total


//Modificar una cantidad 

IF TableSelect(TABLE_Articulos) = -1 RETURN
nPosicion is int
nTotalRenglones is int
cyCantidad is currency
TableSetFocus(TABLE_Articulos)
// Number of rows found in the "TABLE_Product" control
nTotalRenglones = TableCount(TABLE_Articulos)
// Subscript of selected row in the "TABLE_Product" control
nPosicion     = TableSelect(TABLE_Articulos)
cyCantidad    = Open(WIN_Cantidad)
IF cyCantidad > 0 THEN
    TableSelectPlus(TABLE_Articulos, nPosicion)
    //TableDeleteSelect(TABLE_Articulos)
    TABLE_Articulos.COL_Cantidad = cyCantidad
    TABLE_Articulos.COL_Total = cyCantidad * TABLE_Articulos.COL_PU
    LP_Actualiza()
END

//Borrar

IF TableSelect(TABLE_Articulos) = -1 RETURN
nPosicion is int
nTotalRenglones is int
TableSetFocus(TABLE_Articulos)
// Number of rows found in the "TABLE_Product" control
nTotalRenglones = TableCount(TABLE_Articulos)
// Subscript of selected row in the "TABLE_Product" control
nPosicion = TableSelect(TABLE_Articulos)
TableSelectPlus(TABLE_Articulos, nPosicion)
TableDeleteSelect(TABLE_Articulos)
LP_Actualiza()



////moverse hacia abajo
IF TableSelect(TABLE_Articulos) = -1 RETURN
nPosicion is int
nTotalRenglones is int
TableSetFocus(TABLE_Articulos)
// Number of rows found in the "TABLE_Product" control
nTotalRenglones = TableCount(TABLE_Articulos)
// Subscript of selected row in the "TABLE_Product" control
nPosicion = TableSelect(TABLE_Articulos)
IF nPosicion < nTotalRenglones THEN nPosicion++
TableSelectPlus(TABLE_Articulos, nPosicion)



//Moverse hacia arriba

IF TableSelect(TABLE_Articulos) = -1 RETURN
nPosicion is int
nTotalRenglones is int
TableSetFocus(TABLE_Articulos)
// Number of rows found in the "TABLE_Product" control
nTotalRenglones = TableCount(TABLE_Articulos)
// Subscript of selected row in the "TABLE_Product" control
nPosicion = TableSelect(TABLE_Articulos)
IF nPosicion > 1 THEN nPosicion--
TableSelectPlus(TABLE_Articulos, nPosicion)

Imprimir código de barras

 IF iConfigure(COMBO_ListaImpresoras..DisplayedValue) = True THEN
//IF iConfigure("GTP801 Printer") = True THEN
Info("Entré a imprimir")
iCreateFont(1,8,iBold+iItalic,iRoman)
iCreateFont(2,8,iBold,iRoman)
iCreateFont(3,7,iBold,iRoman)
FOR i=1 TO 2// numero de copias a imprimir
//iPreview(i100)
//IFHReadSeek(Factura,Factura,nFactura)THEN

// IMPRIMIMOS LA CABECERA DE LA FACTURA
iPrint(iFont(1)+"FACTURA ")
iPrint(iFont(1)+"FECHA: " + DateSys())
iPrintWord(iFont(1)+"CLIENTE:")
iPrint(" ")
iPrint(iFont(1) + "Domicilio")
iPrint(RepeatString("-",90))
iPrint()

//HExecuteQuery(QRY_Factura,hQueryDefault,nFactura)
//HReadFirst(QRY_Factura)
iPrint(iFont(1)+"Cantidad Articulo Descripción Precio Total")

//WHILENOTHOut(QRY_Factura)
iPrintWord(iFont(1)+ "Cantidad" )
iXPos(7)
iPrintWord(iFont(1)+iXPos(iXPos()+20)+ "Articulo")

iPrintWord(iFont(1)+iXPos(iXPos()+13)+"Descripcion")

iPrintWord(iFont(1)+iXPos(iXPos()+45)+ "Precio")

iPrint(iFont(1)+iXPos(iXPos()+25)+ "Total")
//HReadNext(QRY_Factura)
//END

Valida RFC

 // Summary: <specify the procedure action> // Syntax: //[ <Result> = ] GP_ValidaRFC (<nTipoPersona>, <sParamRFC>) /...