martes, 6 de julio de 2021

Ejemplo de campo tipo fórmula

 CONCAT(TO_CHAR(db_con_catalogo.Cta1,'0999'), CHAR(45),
TRIM(TO_CHAR(db_con_catalogo.Cta2,'09')), CHAR(45),
TRIM(TO_CHAR(db_con_catalogo.Cta3,'09')), CHAR(45),
TRIM(TO_CHAR(db_con_catalogo.Cta4,'09')), CHAR(45),
TRIM(TO_CHAR(db_con_catalogo.Cta5,'09')))

sábado, 5 de junio de 2021

on error

En inicialización del projecto

HOnError("*",hErrDuplicates,GP_OnError_Duplicado)

HOnError("*",hErrIntegrity ,GP_OnError_Integridad)

//********************************************
En los procedimientos globales

PROCEDURE GP_OnError_Duplicado()

sItemName is string  = HErrorInfo(hErrItem)

Info("Problema campo duplicado",sItemName)

// ToastDisplay("Ese registro ya existe")

RESULT opEndProcess


PROCEDURE GP_OnError_Integridad()

sItemName is string  = HErrorInfo(hErrItem)

Info("Problema integridad de registro",sItemName)

// ToastDisplay("Ese registro ya existe")

RESULT opEndProcess





jueves, 12 de noviembre de 2020

Imprimir

 //Imprimir sin qry


// Open the preview window
iPreview()
// Print the report while passing parameters
iPrintReport(RPT_DB_Socio,RADIO_Persona..Value, RADIO_Activos..Value)


//imprimir con qry

 

    // Open the preview window
    iPreview()
    
    iInitReportQuery(RPT_Soc_Historico,gsIdSocio,gdFechaInicial, gdFechaFinal)
    // Print the report while passing parameters
    iPrintReport(RPT_Soc_Historico,gsIdSocio,gdFechaInicial, gdFechaFinal)


miércoles, 7 de octubre de 2020

Crear XLS /abrir XLS

 MyXLSDocumentToCreate is a xlsDocument

// Adds a worksheet
xlsAddWorksheet(MyXLSDocumentToCreate, "Customer list")
MyXLSDocumentToCreate..Worksheet = 1

// Adds a "title" row
MyXLSDocumentToCreate..Cell[1,1] = "Name"
MyXLSDocumentToCreate..Cell[1,1]..AlignmentH = haCenter
MyXLSDocumentToCreate..Cell[1,1]..Font..Bold = True
MyXLSDocumentToCreate..Cell[1,2] = "FirstName"
MyXLSDocumentToCreate..Cell[1,2]..AlignmentH = haCenter
MyXLSDocumentToCreate..Cell[1,2]..Font..Bold = True
MyXLSDocumentToCreate..Cell[1,3] = "Phone"
MyXLSDocumentToCreate..Cell[1,3]..AlignmentH = haCenter
MyXLSDocumentToCreate..Cell[1,3]..Font..Bold = True
MyXLSDocumentToCreate..Cell[1,4] = "Nb orders"
MyXLSDocumentToCreate..Cell[1,4]..AlignmentH = haCenter
MyXLSDocumentToCreate..Cell[1,4]..Font..Bold = True

// Adds data
FOR nCounter = 2 TO 50
    
    // Random data
    MyXLSDocumentToCreate..Cell[2,1] = "Name " + (nCounter-1)
    MyXLSDocumentToCreate..Cell[2,2] = "First name " + (nCounter-1)
    MyXLSDocumentToCreate..Cell[2,3] = "xx.xx.xx.xx.xx"
    MyXLSDocumentToCreate..Cell[2,4] = Random(0,50)
    // Applies a color according to the number of orders
    IF MyXLSDocumentToCreate..Cell[2,4] <= 5 THEN
        // Red
        MyXLSDocumentToCreate..Cell[2,4]..Font..Color = RGB(245, 110, 110)
    ELSE
        // Green
        MyXLSDocumentToCreate..Cell[2,4]..Font..Color = RGB(151, 221, 88)
    END
    
END

// Defines the path of the file to create
sNewFile is string = fTempPath()+["\"]+"XLSTest.xls"
// Saves the XLS document
IF xlsSave(MyXLSDocumentToCreate, sNewFile) = False THEN
    Error("Error while saving the document", ErrorInfo(errMessage))
    RETURN
END

// Closes the document (for its next opening)
xlsClose(MyXLSDocumentToCreate)

// Positions the file path in the edit control
EDT_XLSFile = sNewFile

// Runs the opening code
ExecuteProcess(TAB_Example.BTN_Open, trtClick)

 

 

 

////***** Abrir un documento xls  (2)

// Opens the XLS document
gMyXLSDocument = xlsOpen(EDT_XLSFile, xlsWrite)
IF ErrorOccurred THEN
    Error("Unable to open the document", ErrorInfo())
    RETURN
END

martes, 6 de octubre de 2020

Botón Browse

 // Open the vision window
IF Open(WIN_VISION_DB_Socio) = True THEN
    
    // Refresh the content of the DB_Socio combo box
    //    ListDisplay(COMBO_IdDB_Socio, taCurrentFirst)
    COMBO_IdSocio = DB_Socio.IdSocio
    STC_RazonSocial = DB_Socio.RazonSocial
    gdFechaNacimiento     = DB_Socio.FechaNacimiento
    
END

Botón con código para filtrar

 sMiFiltro is string
sFiltroFechas is string
sFiltroSolicitante is string
sFiltroArea is string
dFechaInicio is Date
dFechaFinal is Date

dFechaInicio = EDT_Date1
dFechaFinal  = EDT_Date2

//busco el id de cada parametro
IF COMBO_Solicitante..StoredValue <> "--TODOS--" THEN
    HReadSeekFirst(Solicitante, Solicitante.SolicitanteNombre, COMBO_Solicitante..StoredValue)
    IF HFound() = True
           sFiltroSolicitante =  " AND calendario.SolicitanteID = " + Solicitante.SolicitanteID
       ELSE
           sFiltroSolicitante = ""
    END
ELSE
    sFiltroSolicitante = ""
END

IF COMBO_Area..StoredValue <> "--TODOS--" THEN
    HReadSeekFirst(Area, AreaNombre, COMBO_Area..StoredValue)
    IF HFound() = True
        sFiltroArea = " AND calendario.AreaID = " +     Area.AreaID
    ELSE
        sFiltroArea = ""        
    END
ELSE
    sFiltroArea = ""    
END

sFiltroFechas = "Calendario.FechaProgramada >= " +  dFechaInicio  +  "  and Calendario.FechaProgramada <= " + dFechaFinal

//armo filtro
sMiFiltro = sFiltroFechas + sFiltroArea + sFiltroSolicitante

HFilter(Calendario,sMiFiltro)
HDeactivateFilter(Calendario)
HActivateFilter(Calendario)
TableDisplay(TABLE_Calendario,taStart)

lunes, 28 de septiembre de 2020

Lee Excel

 sNombreArchivoExcel is string
// Opens the file picker
sNombreArchivoExcel = fSelect("", "", "Selecciona el archivo de excel...", "Excel" + TAB + "*.xlsx;*.xls", "*.xlsx;*.xls")
nNumArchivoExcel    is int = xlsOpen(sNombreArchivoExcel)
nLineasArchivoExcel is int = xlsNbRow(nNumArchivoExcel)
nCiclo            is int
nContador         is int = 0

dFecha             is Date
sIdDB_Tasa_Tipo is string
sClave             is string
cyValor         is currency



FOR nCiclo = 1 TO 5
    IF         nCiclo = 1 THEN
        sClave     = "TIIE"
    ELSE IF nCiclo = 2
        sClave     = "CETE"
    ELSE IF nCiclo = 3
        sClave     = "DOLAR"    
    ELSE IF nCiclo = 4
        sClave     = "UDI"
    ELSE
        sClave = "INPC"    
    END
    //EL PRIMER CICLO GRABO LA TIIE, POR TANTO BUSCO LA ID DE TIIE
    HReadSeekFirst(DB_Tasa_Tipo,Clave,sClave)
    IF HFound(DB_Tasa_Tipo) = True THEN
        sIdDB_Tasa_Tipo = DB_Tasa_Tipo.IdDB_Tasa_Tipo
    END
    
    FOR nContador = 2 TO nLineasArchivoExcel  //NO CONSIDERO ENCABEZADOS
        IF nCiclo     =  1 THEN
            cyValor = xlsData(nNumArchivoExcel,nContador,3)
        ELSE IF nCiclo = 2
            cyValor = xlsData(nNumArchivoExcel,nContador,4)
        ELSE IF nCiclo = 3
            cyValor = xlsData(nNumArchivoExcel,nContador,5)    
        ELSE IF nCiclo = 4
            cyValor = xlsData(nNumArchivoExcel,nContador,6)    
        ELSE
            cyValor = xlsData(nNumArchivoExcel,nContador,10)        
        END
        IF cyValor > 0
            dFecha  = StringToDate(xlsData(nNumArchivoExcel,nContador,2),"DD/MM/YYYY")
            HReadSeekFirst(DB_Tasa_Diaria,IdDB_Tasa_TipoFecha,[sIdDB_Tasa_Tipo,dFecha])
            IF HFound(DB_Tasa_Diaria) THEN        
                DB_Tasa_Diaria.Valor = cyValor
            ELSE
                HReset(DB_Tasa_Diaria)
                DB_Tasa_Diaria.IdDB_Tasa_Diaria = GP_DameIdentificador()
                DB_Tasa_Diaria.IdDB_Tasa_Tipo     = sIdDB_Tasa_Tipo
                DB_Tasa_Diaria.Fecha             = dFecha
                DB_Tasa_Diaria.Valor             = cyValor
                DB_Tasa_Diaria.VigenteAl         = dFecha
                
            END    
            HSave(DB_Tasa_Diaria)
        END
    END
END //FOR nCiclo = 1 TO 3

Info("Proceso Terminado")

Valida RFC

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