Você está na página 1de 18

Formulario de ingreso

Programacin del formulario en evento load

SET DEFAULT TO ("c:\infa")


CLOSE DATABASES
OPEN DATABASE escuela
SELECT 1
USE usuarios order tag usuario
SET EXACT ON

Programacin del txtusuario en evento interactivechange

IF EMPTY(ALLTRIM(thisform.txtusuario.Value)) then
thisform.txtcontrasea.Enabled= .F.
ELSE
thisform.txtcontrasea.Enabled= .T.
ENDIF

Programacin del txtcontrasea en evento interactivechange


IF EMPTY(ALLTRIM(thisform.txtcontrasea.Value)) then
thisform.cmdaceptar.Enabled= .F.
ELSE
thisform.cmdaceptar.Enabled= .T.
ENDIF

Programacin del cmdsalir en evento click


thisform.Release

Programacin del cmdaceptar en evento click


SELECT 1
SEEK(UPPER(ALLTRIM(thisform.txtusuario.Value)))
IF UPPER(ALLTRIM(thisform.txtusuario.Value))= usuario THEN
IF ALLTRIM(thisform.txtcontrasea.Value)= contrasea THEN
MESSAGEBOX('BIENVENIDO AL SISTEMA')
ELSE
MESSAGEBOX('CLAVE INCORRECTA')
thisform.txtcontrasea.Value=""
thisform.txtcontrasea.SetFocus
ENDIF
ELSE
MESSAGEBOX('ID NO EXISTE')
thisform.txtusuario.Value=""
thisform.txtusuario.SetFocus
ENDIF

Formulario de registro

Programacin del formulario en evento load


SET DEFAULT TO ("c:\infa")
CLOSE DATABASES
OPEN DATABASE escuela
SELECT 1
USE rep order tag cirep
SELECT 2
USE alu ORDER tag cialu
SET EXACT ON

Programacin del cmdagregar en evento click


thisform.txtcirep.Enabled= .T.
thisform.txtcirep.SetFocus

Programacin del txtcirep en evento interactivechange


IF EMPTY(ALLTRIM(thisform.txtcirep.Value)) then
thisform.txtnomrep.Enabled= .F.
thisform.txtaperep.Enabled= .F.
thisform.txtcialu.Enabled= .F.
thisform.txtnomalu.Enabled= .F.
thisform.txtapealu.Enabled= .F.
ELSE
thisform.txtnomrep.Enabled= .T.
thisform.txtaperep.Enabled= .T.
thisform.txtcialu.Enabled= .T.
thisform.txtnomalu.Enabled= .T.
thisform.txtapealu.Enabled= .T.
thisform.cmdguardar.Enabled= .T.
ENDIF

Programacin del cmdcancelar en evento click


thisform.txtcirep.Value=""
thisform.txtnomrep.Value=""
thisform.txtaperep.Value=""
thisform.txtcialu.Value=""
thisform.txtnomalu.Value=""
thisform.txtapealu.Value=""
thisform.txtcirep.Enabled= .F.
thisform.txtnomrep.Enabled= .F.
thisform.txtaperep.Enabled= .F.
thisform.txtcialu.Enabled= .F.
thisform.txtnomalu.Enabled= .F.
thisform.txtapealu.Enabled= .F.
thisform.cmdguardar.Enabled= .F.

Programacin del cmdguardar en evento click


IF EMPTY(ALLTRIM(thisform.txtcialu.Value)) then
MESSAGEBOX('ingrese cedula del alumno')
thisform.txtcialu.SetFocus
ELSE
SELECT 1
xrep=UPPER(ALLTRIM(thisform.txtcirep.Value))
SEEK(xrep)
IF FOUND() then
MESSAGEBOX('registro ya existe')
ELSE
APPEND BLANK
replace cirep WITH xrep
replace nomrep WITH UPPER(ALLTRIM(thisform.txtnomrep.Value))
replace aperep WITH UPPER(ALLTRIM(thisform.txtaperep.Value))
thisform.txtcirep.Value=""
thisform.txtnomrep.Value=""
thisform.txtaperep.Value=""
thisform.txtnomrep.Enabled= .F.
thisform.txtaperep.Enabled= .F.
ENDIF
SELECT 2
SEEK(UPPER(ALLTRIM(thisform.txtcialu.Value)))
IF FOUND() then
MESSAGEBOX('ya existe')
ELSE
APPEND BLANK
replace cirep WITH xrep
replace cialu WITH UPPER(ALLTRIM(thisform.txtcialu.Value))
replace nomalu WITH UPPER(ALLTRIM(thisform.txtnomalu.Value))
replace apealu WITH UPPER(ALLTRIM(thisform.txtapealu.Value))
thisform.txtcialu.Value=""
thisform.txtnomalu.Value=""
thisform.txtapealu.Value=""
thisform.txtcialu.enabled= .F.
thisform.txtnomalu.Enabled= .F.
thisform.txtapealu.Enabled= .F.
ENDIF
ENDIF

Formulario de consulta 1 a 1

Programacin del formulario en evento load


SET DEFAULT TO ("c:\infa")
CLOSE DATABASES
OPEN DATABASE escuela
SELECT 1
USE rep order tag cirep
SELECT 2
USE alu ORDER tag cialu
SET EXACT ON

Programacin del txtcialu en evento interactivechange


IF EMPTY(ALLTRIM(thisform.txtcialu.Value)) then
thisform.cmdconsultar.Enabled= .F.
ELSE
thisform.cmdconsultar.Enabled= .T.
ENDIF

Programacin del cmdcancelar en evento click


thisform.txtcirep.Value=""
thisform.txtnomrep.Value=""
thisform.txtaperep.Value=""
thisform.txtcialu.Value=""
thisform.txtnomalu.Value=""
thisform.txtapealu.Value=""
thisform.txtcialu.SetFocus
thisform.txtcirep.Enabled= .F.
thisform.txtnomrep.Enabled= .F.
thisform.txtaperep.Enabled= .F.
thisform.txtnomalu.Enabled= .F.
thisform.txtapealu.Enabled= .F.
thisform.cmdconsultar.Enabled= .F.

Programacin del cmdconsultar en evento click


SELECT 2
SEEK(UPPER(ALLTRIM(thisform.txtcialu.Value)))
IF FOUND() then
thisform.txtnomalu.Value= nomalu
thisform.txtapealu.Value= apealu
xcirep= cirep
SELECT 1
SEEK(xcirep)
IF FOUND() then
thisform.txtcirep.Value= xcirep
thisform.txtnomrep.Value= nomrep
thisform.txtaperep.Value= aperep
ENDIF
ELSE
MESSAGEBOX('alumno no registrado')
thisform.txtcialu.Value=""
thisform.txtcialu.SetFocus
ENDIF

Formulario de consulta 1 a muchos

Programacin del formulario en evento load


SET DEFAULT TO ("c:\infa")
CLOSE DATABASES
OPEN DATABASE escuela
SELECT 1
USE rep order tag cirep
SELECT 2
USE alu ORDER tag cialu
SET EXACT ON

Programacin del formulario en evento dibujargrid

thisform.grdalu.columncount=3
thisform.grdalu.column1.Width=100
thisform.grdalu.column1.header1.Caption="cedula"
thisform.grdalu.column1.header1.Alignment= 2
thisform.grdalu.column1.header1.FontBold= .T.
thisform.grdalu.column2.Width=100
thisform.grdalu.column2.header1.Caption="nombre"
thisform.grdalu.column2.header1.Alignment= 2
thisform.grdalu.column2.header1.FontBold= .T.
thisform.grdalu.column3.Width=100
thisform.grdalu.column3.header1.Caption="apellido"

thisform.grdalu.column3.header1.Alignment= 2
thisform.grdalu.column3.header1.FontBold= .T.

Programacin del formulario en evento init

thisform.dibujargrid
thisform.grdalu.readonly=.t.
thisform.grdalu.recordsource=""

Programacin del cmdcancelar en evento click


thisform.txtcirep.Value=""
thisform.txtnomrep.Value=""
thisform.txtaperep.Value=""
thisform.txtcirep.setfocus
thisform.txtnomrep.Enabled= .F.
thisform.txtaperep.Enabled= .F.
thisform.cmdconsultar.Enabled= .F.
thisform.grdalu.RecordSource=""
thisform.dibujargrid

Programacin del txtcirep en evento interactivechange


IF EMPTY(ALLTRIM(thisform.txtcirep.Value)) then
thisform.cmdconsultar.Enabled= .F.
ELSE
thisform.cmdconsultar.Enabled= .T.
ENDIF

Programacin del cmdconsultar en evento click


SELECT 1
xcirep=UPPER(ALLTRIM(thisform.txtcirep.Value))
SEEK(xcirep)
IF FOUND() then
thisform.txtcirep.Value= xcirep
thisform.txtnomrep.Value= nomrep
thisform.txtaperep.Value= aperep
SELECT 2
SELECT cialu,nomalu,apealu FROM alu into cursor curalu WHERE cirep= xcirep
thisform.grdalu.RecordSourceType= 1
thisform.grdalu.RecordSource='curalu'
ENDIF

Formulario Eliminar

Programacin del formulario en evento load


SET DEFAULT TO ("c:\infa")
CLOSE DATABASES
OPEN DATABASE escuela
SELECT 1
USE rep order tag cirep

Programacin del txtci en evento interactivechange


IF EMPTY(ALLTRIM(thisform.txtci.Value)) then
thisform.cmdeliminar.Enabled= .F.
ELSE
thisform.cmdeliminar.Enabled= .T.
ENDIF

Programacin del cmdcancelar en evento click


thisform.txtci.Value=""
thisform.txtnom.Value=""
thisform.txtape.Value=""
thisform.txtci.setfocus
thisform.txtnom.Enabled= .F.
thisform.txtape.Enabled= .F.
thisform.cmdeliminar.Enabled= .F.

Programacin del cmdeliminar en evento click


SELECT 1
xci=UPPER(ALLTRIM(thisform.txtci.Value))
SEEK(xci)
IF FOUND() then
thisform.txtnom.Value= nomrep
thisform.txtape.Value= aperep
x=MESSAGEBOX('DESEA ELIMINAR EL REGISTRO?',4+16+256)
IF x=6 THEN
DELETE
y=MESSAGEBOX('CONFIRMA LA ELIMINACION DEL REGISTRO?',4+32+256)
IF y=6 then
PACK
thisform.txtci.Value=""
thisform.txtnom.Value=""
thisform.txtape.Value=""
thisform.cmdeliminar.Enabled= .F.
thisform.txtci.SetFocus
ELSE
RECALL
thisform.txtci.Value=""
thisform.txtnom.Value=""
thisform.txtape.Value=""
thisform.cmdeliminar.Enabled= .F.
thisform.txtci.SetFocus
ENDIF
ENDIF
ENDIF

Barra de Men

Ir al administrador de proyecto en la pestaa otros, en la opcin


men seleccionar crear nuevo men.
En el diseador de men colocar el nombre de indicador (nombre
del formulario)
En el cuadro accin seleccionar comando si es un solo formulario,
sub-men de 2 formularios en adelante.

Seleccionada la opcin comando colocar al lado en la casilla


blanca el comando do form para llamar un formulario seguido del
name del formulario como se ve en la imagen.
Para finalizar cerrar el diseador de mens y guardar los cambios
en nuestra carpeta de trabajo con el nombre barrademenu sin las
comillas.

Programa Principal o Cdigo


Para crear un cdigo vamos a la pestaa cdigo y seleccionamos la
opcion programas y crear nuevo.
Luego se desplegada una pantalla blanca en la que se colocara el
siguiente cdigo.

SET DEFAULT TO ("c:\infa")


CLOSE ALL
SET SYSMENU off
SET EXACT ON
SET ECHO OFF
SET TALK OFF
SET CENTURY ON
SET CLOCK STATUS
SET DATE TO DMY
SET DELETE ON
SET SAFETY OFF
_screen.BackColor= RGB(255,255,255)
_screen.windowstate= 2
_screen.closable=.F.
_screen.caption='mi sistema'
DO barrademenu.mpr
DO frmingreso
READ EVENTS
CLEAR ALL

Echo el proceso debe quedar as. Para terminar cerrar la pantalla


y guardar con el nombre pantalla principal sin comillas.
Luego ir al administrador de proyecto hacer click en el cdigo
creado y seleccionar la opcin generar como aparece en la imagen.

Y se desplegara una ventara don seleccionaremos ejecutable win32


o servidor com(exe), volver a compilar todos los archivos y
mostrar errores. Como se ve en la imagen.

Por ultimo hacer click en aceptar y guardar el exe con el nombre


misistema.

Hacer click derecho sobre el programa en la pestaa cdigo y


seleccionar la opcin establecer como principal y listo. Correr
el programa desde el ejecutable creado has terminado un sistema.

Para crear un sistema lo primero es crear la carpeta del proyecto en nuestro caso se
llamara infa y guardarla en el disco local c.
Luego iniciamos en compilador visualfoxpro y hacemos click en el icono que tiene forma
de hoja blanca y damos en la opcin nuevo proyecto, colocamos nombre a nuestro
proyecto en nuestro caso salinasur. Luego verificamos que estemos ubicados en nuestra
carpeta infb y sino nos ubicamos en ella para poder guardar el proyecto.
Ya creado nuestro proyecto se desplegara el administrador de proyecto donde crearemos
todos nuestros formulario y cosas tiles.
Lo primero en crear ser nuestra base de datos para esto nos vamos a la pestaa datos
hacemos click en databases y seleccionamos la opcin nuevo el nombre de nuestra base
de datos ser escuela, ya dentro de la base de datos necesitamos crear 3 tablas, con el
diseador de base de datos buscamos la opcin nueva tabla e insertamos 1 por 1.
La primera tabla se llamara alu.
Debe contener 4 campos de tipo carcter:
cirep, cialu, nomalu, apealu.
su ndice principal ser cialu y debe tener cirep como ndice normal.
La segunda tabla se llamara rep.
Debe contener 3 campos de tipo carcter:
cirep, nomrep, aperep.
su ndice principal ser cirep.
La tercera tabla se llama usuarios.
Debe contener 2 campos de tipo carcter:
usuario, contrasea.
Su ndice principal ser usuario.

Ya creadas las tablas insertar datos a todas ellas.


Importante: los datos dentro de las tablas se guardan en maysculas.
Echo todo esto ya podemos empezar a crear nuestros formularios.
Recordemos que en foxpro se trabaja con 2 propiedades bsicas:
Caption que es el nombre visible al usuario.
Name el nombre para el proceso de programacin.
Dentro del formulario todos los objetos deben llevar estas propiedades con exencin de
los cuadros de texto y los grid que solo usan la propiedad name.
Los prefijos que usaremos en la propiedad name sern:
Frm para los formularios luego el nombre
Lbl para la etiquetas
Txt para los cuadros de texto
Grd para las cuadriculas
Cmd para los botones.
Otra propiedad que usaremos ser enabled que tiene 2 valores .F. y .T. esta se usa para
habilitar y deshabilitar un objeto antes o durante su ejecucin.

Formulario Modificar

Programacin del formulario en evento load


SET DEFAULT TO ("c:\infa")
CLOSE DATABASES
OPEN DATABASE escuela
SELECT 1
USE rep order tag cirep
SELECT 2
USE alu ORDER tag cialu
SET EXACT ON

Programacin del cmdcancelar en evento click


thisform.txtcirep.Value=""
thisform.txtnomrep.Value=""
thisform.txtaperep.Value=""
thisform.txtcialu.Value=""
thisform.txtnomalu.Value=""
thisform.txtapealu.Value=""
thisform.txtcialu.SetFocus

Programacin del cmdconsultar en evento click


SELECT 2
SEEK(UPPER(ALLTRIM(thisform.txtcialu.Value)))
IF FOUND() then
thisform.txtnomalu.Value= nomalu
thisform.txtapealu.Value= apealu
thisform.txtnomalu.Enabled= .T.
thisform.txtapealu.Enabled= .T.
xcirep= cirep
SELECT 1
SEEK(xcirep)
IF FOUND() then
thisform.txtcirep.Value= xcirep
thisform.txtnomrep.Value= nomrep
thisform.txtaperep.Value= aperep
thisform.txtcirep.Enabled= .T.
thisform.txtnomrep.Enabled= .T.
thisform.txtaperep.Enabled= .T.
ENDIF
ELSE
MESSAGEBOX('alumno no registrado')
thisform.txtcialu.Value=""
thisform.txtcialu.SetFocus
ENDIF

Programacin del cmdmodificar en evento click


SELECT 1
replace cirep WITH UPPER(ALLTRIM(thisform.txtcirep.Value))
replace nomrep WITH UPPER(ALLTRIM(thisform.txtnomrep.Value))
replace aperep WITH UPPER(ALLTRIM(thisform.txtaperep.Value))
thisform.txtcirep.Value=""
thisform.txtnomrep.Value=""
thisform.txtaperep.Value=""
thisform.txtcirep.enabled= .F.
thisform.txtnomrep.Enabled= .F.
thisform.txtaperep.Enabled= .F.
SELECT 2
replace cialu WITH UPPER(ALLTRIM(thisform.txtcialu.Value))
replace nomalu WITH UPPER(ALLTRIM(thisform.txtnomalu.Value))
replace apealu WITH UPPER(ALLTRIM(thisform.txtapealu.Value))
thisform.txtcialu.Value=""
thisform.txtnomalu.Value=""
thisform.txtapealu.Value=""
thisform.txtcialu.setfocus
thisform.txtnomalu.Enabled= .F.
thisform.txtapealu.Enabled= .F.

Você também pode gostar