Sei sulla pagina 1di 16

Material de Apoyo para 3er.

Departamental PSGBD

CREACIÓN DE FORMULARIOS UTILIZANDO ASISTENTE

Estando en el Administrador de Proyectos y en el Elemento Formularios

 Botón Nuevo
 Asistente para formularios (De Uno o De Uno a Varios)
 Selección de Base de Datos (Tabla y campos que integrarán el formulario)
 Elegir el estilo del formulario
 Elegir campo por el que se ordenará y el tipo de ordenamiento
 Escribir un título para el formulario

CREACIÓN DE INFORMES UTILIZANDO ASISTENTE

Estando en el Administrador de Proyectos y en el Elemento Informes

 Botón Nuevo
 Asistente para informes
 Selección de Base de Datos (Tabla y campos que integrarán el formulario)
 Elegir el estilo del informe
 Elegir el diseño del informe y la orientación
 Indicar el ordenamiento para los registros
 Escribir un título para el informe.

1
Material de Apoyo para 3er. Departamental PSGBD

NOTA:
También se pueden diseñar informes en blanco utilizando la barra de herramientas de
controles de informes, mediante el arrastre de los diferentes controles a las secciones
correspondientes.

COMANDOS Y ELEMENTOS BASICOS PARA TRABAJAR CON VFP

VARIABLES PÚBLICAS
Las variables públicas en VFP es un tipo de variables que pueden ser utilizadas en cualquier
formulario, independientemente en cual se haya declarado.
SINTAXIS
Public as [nombre de la variable]
EJEMPLOS:
Public as x Public as y
X=0 y=” “

SINTAXIS PARA ESTABLECER EL VALOR DE UNA PROPIEDAD EN TIEMPO DE EJECUCIÓN

THISFORM.[nombre del objeto].[propiedad]=valor a asignar


EJEMPLO:
thisform.clave.enabled=.f.

SINTAXIS PARA ESTABLECER UNA RUTA DE ACCESO PREDETERMINADA

SET DEFA TO [ruta de acceso]

SINTAXIS PARA ENLAZAR A UN FORMULARIO

do form [nombre del reporte]

EJEMPLO:
do form clientes

SINTAXIS PARA ENLAZAR A UN REPORTE POR IMPRESORA

2
Material de Apoyo para 3er. Departamental PSGBD
report form [nombre del reporte] to printer

EJEMPLO:
report form clientes to printer

SINTAXIS PARA ENLAZAR A UN REPORTE POR PANTALLA

report form [nombre del reporte] preview

EJEMPLO:
report form clientes to preview

SINTAXIS PARA CERRAR UNA BASE DE DATOS

close database

SINTAXIS PARA ABRIR UNA BASE DE DATOS

open database [nombre de la BD]

PRINCIPALES COMANDOS UTILIZADOS PARA MANIPULACIÓN DE TABLAS

UPPER

Convierte a mayúsculas una cadena de caracteres

SINTAXIS:
UPPER(objeto o cadena de caracteres)
LOWER

Convierte a minúsculas una cadena de caracteres

SINTAXIS:
LOWER(objeto o cadena de caracteres)
SELECT

Activa una tabla o área de trabajo específica por medio de un identificador.

SINTAXIS
Select [identificador]

***El identificador puede ser una letra o un número y se usa en combinación del comando
use.

USE

Abre para poner en uso una tabla.


SINTAXIS
3
Material de Apoyo para 3er. Departamental PSGBD
Use [nombre de la tabla]

GO TOP

Permite colocar el puntero de registro en el primer registro de la tabla en uso

SINTAXIS
Go top
GO BOTTOM

Permite colocar el puntero de registro en el último registro de la tabla en uso

SINTAXIS
Go bottom

BOF

Determina si el puntero de registro está colocado al principio (en el primer registro) de una
tabla.

SINTAXIS
BOF( )

EOF

Determina si el puntero de registro está colocado al final (en el último registro) de una tabla.

SINTAXIS
EOF( )

SKIP

Mueve el puntero de registro hacia delante o hacia atrás en una tabla.

SINTAXIS
Skip #

REPLACE

Actualiza los registros de una tabla reemplazando lo contenido en los campos con el contenido de
los objetos del formulario.

SINTAXIS
Replace [campo] with [objeto, variable o valor]

LOCATE

Permite realizar búsquedas de manera secuencial en los archivos de datos (tablas en uso)

SINTAXIS
4
Material de Apoyo para 3er. Departamental PSGBD
LOCATE FOR [EXPRESIONES O CONDICIONES]

FOUND

Determina si encontró un elemento de búsqueda.

SINTAXIS
FOUND()

APPEND BLANK

Crea un registro en blanco para la tabla que esté en uso

SINTAXIS
Append blank

DELETE

Marca registros para que sean eliminados posteriormente

SINTAXIS
DELETE FOR [EXPRESION] O DELETE

PACK

Elimina los registros que se encuentran marcados para eliminarse.

SINTAXIS
PACK

ZAP

Elimina todos los registros que se encuentran a la tabla que esté en uso

SINTAXIS
ZAP

5
Material de Apoyo para 3er. Departamental PSGBD

SISTEMA DE VENTAS
CODIGOS DEL FORMULARIO DE LA CLAVE DE ACCESO

FORMULARIO PROCEDIMIENTO: ACTIVATE (PAG. 2)


***PARA ESTABLECER LA RUTA PREDETERMINADA
SET DEFA TO C:\SISTEMA
***PARA DECLARAR LA VARIABLE CONTAR COMO PUBLICA
PUBLIC AS CONTAR
CONTAR=0

BOTON ACCESAR PROCEDIMIENTO: CLICK


CONTAR = CONTAR + 1
IF UPPER(THISFORM.CLAVE.VALUE) = THISFORM.CLAVE.TAG Then
MESSAGEBOX("BIENVENIDO AL SISTEMA",0+64, "HOLA")
RELEASE THISFORM
DO FORM MENU_PRINCIPAL
Else
If (CONTAR = 1) Then
MESSAGEBOX("TIENES DOS OPORTUNIDADES MAS",0+64, "ERROR")
THISFORM.CLAVE.VALUE = " "
THISFORM.CLAVE.SetFocus
EndIf
If (CONTAR = 2) Then
MESSAGEBOX("SOLAMENTE TIENES UNA OPORTUNIDAD MAS",0+64, "ERROR")
THISFORM.CLAVE.VALUE = " "
THISFORM.CLAVE.SetFocus
EndIf
If (CONTAR = 3) Then
MESSAGEBOX("ACCESO CANCELADO",0+64, "ERROR")
RELEASE THISFORM
EndIf
6
Material de Apoyo para 3er. Departamental PSGBD
EndIf

BOTON SALIR PROCEDIMIENTO: CLIC

RELEASE THISFORM

CODIGOS DEL FORMULARIO MENU PRINCIPAL

FORMULARIO PROCEDIMIENTO: ACTIVATE (PAG. 3)

***PARA ESTABLECER EL FORMATO BRITANICO A LA FECHA DD/MM/AA

SET DATE BRITISH

***CIERRE DE LAS BD ABIERTAS

CLOSE DATABASE

***ABRIR BD VENTAS

OPEN DATABASE VENTAS

***SELECCION DE LA TABLA PRODUCTOS PARA USARLA REFERENCIANDOLA POR LA


LETRA A

SELECT A
USE PRODUCTOS

7
Material de Apoyo para 3er. Departamental PSGBD

***SELECCION DE LA TABLA CLIENTES PARA USARLA REFERENCIANDOLA POR LA LETRA


B
SELECT B
USE CLIENTES

***SELECCION DE LA TABLA NFACTURA PARA USARLA REFERENCIANDOLA POR LA


LETRA C
SELECT C
USE NFACTURA

***SELECCION DE LA TABLA NFACTURA PARA USARLA REFERENCIANDOLA POR LA


LETRA D

SELECT D
USE FACTURA

BOTON PRODUCTOS PROCEDIMIENTO: CLICK

DO FORM PRODUCTOS

BOTON CLIENTES PROCEDIMIENTO: CLICK

DO FORM CLIENTES

BOTON VENTAS_FACTURAS PROCEDIMIENTO: CLICK

DO FORM VENTAS_FACTURAS

BOTON IMPRIME_FACTURA PROCEDIMIENTO: CLICK

DO FORM IMPRIME_FACTURA

BOTON CONSULTAS-REPORTES PROCEDIMIENTO: CLICK

DO FORM CONSULTAS_CLIENTES

BOTON SALIR PROCEDIMIENTO: CLICK

RELEASE THISFORM

8
Material de Apoyo para 3er. Departamental PSGBD
CODIGOS DEL FORMULARIO CLIENTES

CUADRO DE TEXTO: CLAVEC PROCEDIMIENTO: LOSTFOCUS (PAG. 4)

Select B
Locate for thisform.clavec.value=clave
if thisform.clavec.value<>0
if found() then

*Desplegar (ASIGNAR) los contenidos de los campos en los cuadros de texto

thisform.nombrec.value=nombre
thisform.direccionc.value=direccion
thisform.edadc.value=edad
thisform.telefonoc.value=telefono
thisform.ingresosc.value=ingresos
thisform.fechac.value=fecha

*Habilitar los botones para hacer cambios y grabarlos en el registro

thisform.modificar.enabled=.t.
thisform.guardar_cambios.enabled=.t.
thisform.eliminar.enabled=.t.
9
Material de Apoyo para 3er. Departamental PSGBD
thisform.cancelar.enabled=.t.
thisform.nuevo.enabled=.t.
thisform.guardar.enabled=.f.
else
=messagebox("LA CLAVE DEL CLIENTE NO EXISTE")
resp=messagebox("DESEA DAR DE ALTA UN CLIENTE CON LA CLAVE
INTRODUCIDA",4+0+32,"NUEVO CLIENTE")
if resp=6
*Inhabilitar y habilitar objetos
thisform.clavec.enabled=.f.
thisform.nombrec.enabled=.t.
thisform.direccionc.enabled=.t.
thisform.edadc.enabled=.t.
thisform.telefonoc.enabled=.t.
thisform.ingresosc.enabled=.t.
thisform.fechac.enabled=.t.

thisform.guardar.enabled=.t.
thisform.cancelar.enabled=.t.
thisform.modificar.enabled=.f.
thisform.guardar_cambios.enabled=.f.
thisform.eliminar.enabled=.f.
thisform.cancelar.enabled=.t.

*Limpiar objetos
thisform.nombrec.value=" "
thisform.direccionc.value=" "
thisform.edadc.value=0
thisform.telefonoc.value=" "
thisform.ingresosc.value=0
thisform.fechac.value={ / / }
thisform.nuevo.enabled=.f.
thisform.nombrec.Setfocus
else
thisform.guardar.enabled=.f.
thisform.cancelar.enabled=.f.
thisform.nuevo.enabled=.t.
thisform.clavec.value=0
thisform.clavec.Setfocus

endif
endif
endif

10
Material de Apoyo para 3er. Departamental PSGBD
BOTON NUEVO PROCEDIMIENTO: CLICK

*Inhabilitar y habilitar objetos

thisform.clavec.enabled=.t.
thisform.guardar.enabled=.t.
thisform.cancelar.enabled=.t.
thisform.modificar.enabled=.f.
thisform.guardar_cambios.enabled=.f.
thisform.eliminar.enabled=.f.

*Limpiar objetos

thisform.clavec.value=0
thisform.nombrec.value=" "
thisform.direccionc.value=" "
thisform.edadc.value=0
thisform.telefonoc.value=" "
thisform.ingresosc.value=0
thisform.fechac.value={ / / }
thisform.nuevo.enabled=.f.
thisform.clavec.setfocus

BOTON CANCELAR PROCEDIMIENTO: CLICK

thisform.clavec.value=0
thisform.nombrec.value=" "
thisform.direccionc.value=" "
thisform.edadc.value=0
thisform.telefonoc.value=" "
thisform.ingresosc.value=0
thisform.fechac.value={ / / }

thisform.clavec.Setfocus

thisform.nuevo.enabled=.t.
thisform.modificar.enabled=.t.
thisform.guardar_cambios.enabled=.t.
thisform.eliminar.enabled=.t.

BOTON GUARDAR PROCEDIMIENTO: CLICK (PAG. 4 Y 5)

11
Material de Apoyo para 3er. Departamental PSGBD
select B
append blank
replace clave with thisform.clavec.value
replace nombre with thisform.nombrec.value
replace direccion with thisform.direccionc.value
replace edad with thisform.edadc.value
replace telefono with thisform.telefonoc.value
replace ingresos with thisform.ingresosc.value
replace fecha with thisform.fechac.value
=messagebox("EL REGISTRO HA SIDO GUARDADO")

*Habilitar y Deshabilitar objetos

thisform.nuevo.enabled=.t.
thisform.guardar.enabled=.f.
thisform.modificar.enabled=.t.

BOTON ELIMINAR PROCEDIMIENTO: CLICK (PAG. 5)

resp=messagebox("¿Estás Seguro de Borrar el Registro?",4+0+32,"Eliminar Registro")


if resp=6
delete
pack
=messagebox("El Registro se ha Eliminado Satisfactoriamente")
thisform.clavec.value=0
thisform.nombrec.value=" "
thisform.direccionc.value=" "
thisform.edadc.value=0
thisform.telefonoc.value=" "
thisform.ingresosc.value=0
thisform.fechac.value="{ / / }"
thisform.clavec.Setfocus
endif

BOTON MODIFICAR PROCEDIMIENTO: CLICK

thisform.nombrec.enabled=.t.
thisform.direccionc.enabled=.t.
thisform.edadc.enabled=.t.
thisform.telefonoc.enabled=.t.
thisform.ingresosc.enabled=.t.
thisform.fechac.enabled=.t.
thisform.nuevo.enabled=.t.

thisform.clavec.enabled=.f.
thisform.nombrec.setfocus

BOTON GUARDAR CAMBIOS PROCEDIMIENTO: CLICK

12
Material de Apoyo para 3er. Departamental PSGBD
select B
replace clave with thisform.clavec.value
replace nombre with thisform.nombrec.value
replace direccion with thisform.direccionc.value
replace edad with thisform.edadc.value
replace telefono with thisform.telefonoc.value
replace ingresos with thisform.ingresosc.value
replace fecha with thisform.fechac.value
thisform.nombrec.enabled=.f.
thisform.direccionc.enabled=.f.
thisform.edadc.enabled=.f.
thisform.telefonoc.enabled=.f.
thisform.ingresosc.enabled=.f.
thisform.fechac.enabled=.f.

BOTON CERRAR PROCEDIMIENTO: CLICK

RELEASE THISFORM

CODIGOS DEL FORMULARIO CONSULTA DE CLIENTES

BOTON ANTERIOR PROCEDIMIENTO: CLICK (PAG. 3 Y 4)

Select B
13
Material de Apoyo para 3er. Departamental PSGBD
if .not. bof()
skip -1
thisform.clavec.value=clave
thisform.nombrec.value=nombre
thisform.direccionc.value=direccion
thisform.edadc.value=edad
thisform.telefonoc.value=telefono
thisform.ingresosc.value=ingresos
thisform.fechac.value=fecha
thisform.siguiente.enabled=.t.
else
=messagebox("YA ESTAS EN EL PRIMER REGISTRO")
thisform.anterior.enabled=.f.
endif

BOTON PRIMERO PROCEDIMIENTO: CLICK (PAG. 3 Y 4)

SELECT B
GO TOP
thisform.clavec.value=clave
thisform.nombrec.value=nombre
thisform.direccionc.value=direccion
thisform.edadc.value=edad
thisform.telefonoc.value=telefono
thisform.ingresosc.value=ingresos
thisform.fechac.value=fecha

*Deshabilitar Botones

thisform.anterior.enabled=.f.
thisform.siguiente.enabled=.t.

BOTON SIGUIENTE PROCEDIMIENTO: CLICK (PAG. 3 Y 4)

Select B
if .not. eof()
skip
thisform.clavec.value=clave
thisform.nombrec.value=nombre
thisform.direccionc.value=direccion
thisform.edadc.value=edad
thisform.telefonoc.value=telefono
thisform.ingresosc.value=ingresos
thisform.fechac.value=fecha
thisform.anterior.enabled=.t.
else
=messagebox("YA ESTAS EN EL ULTIMO REGISTRO")
thisform.siguiente.enabled=.f.
endif

14
Material de Apoyo para 3er. Departamental PSGBD

BOTON ULTIMO PROCEDIMIENTO: CLICK (PAG. 3 Y 4)

SELECT B
GO BOTTOM
thisform.clavec.value=clave
thisform.nombrec.value=nombre
thisform.direccionc.value=direccion
thisform.edadc.value=edad
thisform.telefonoc.value=telefono
thisform.ingresosc.value=ingresos
thisform.fechac.value=fecha

*Deshabilitar Botones

thisform.siguiente.enabled=.f.
thisform.anterior.enabled=.t.

BOTON CERRAR PROCEDIMIENTO: CLICK

RELEASE THISFORM

BOTON REPORTES PROCEDIMIENTO: CLICK

DO FORM MENU_REPORTES

CODIGOS DEL FORMULARIO REPORTES

BOTON POR_PANTALLA PROCEDIMIENTO: CLICK

15
Material de Apoyo para 3er. Departamental PSGBD
report form reporte_clientes preview

BOTON POR_IMPRESORA PROCEDIMIENTO: CLICK

report form reporte_clientes to printer

BOTON SALIR PROCEDIMIENTO: CLICK

RELEASE THISFORM

PROPIEDADES ADICIONALES A LAS VISTAS

• PasswordChar.- Se utiliza en la clave de acceso para establecer un carácter o símbolo


especial que se muestre en lugar de que se visualice lo que se está tecleando.

• Tag.- Se utiliza en la clave de acceso para establecer en ella la clave o contraseña de acceso
que tendrá el sistema.

• ReadOnly.-Se utiliza para tener acceso a algún control, pero que no se pueda modificar el
contenido de éste.

• WindowState.- Se utiliza para establecer de que manera se visualizará el formulario en


tiempo de ejecución, ya sea en ventana maximizada, normal o minimizada.

16

Potrebbero piacerti anche