lunes, 3 de diciembre de 2007

LENGUAJE DE PROGRAMACION IV EJEMPLO DE SQL

EJEMPLO APLICATIVO SQL

El siguiente problema esu una aplicación de las instrucciones SQL

PASO 1 .- CREAR PROYECTO CON EL GENERADOR DE PROYECTOS

CARPETA :D:\SQLFOX
PROYECTO :proy1
BSE DE DATOS :datos1
TABLAS Y RELACIONAMIENTO
PASO 2 .- CREACION DE FORMULARIOS.
* FORMULARIO DE ADMINISTRACION DE CATEGORIAS
PASO 3 .-CODIFICACION.
- 2 CLICK EN FORMULARIO (ativate):
close database
open database("D:\sqlfox\datos1")
- 2 CLICK EN MOSTRAR DATOS (click)
select categoria.categoria,prehora from categoria
- 2 CLICK EN GRABAR (click)
with thisform
close table all
use categoria
insert into categoria (categoria,prehora) values;
(.text1.value,val(.text2.value))
=messagebox("este registro fue grabado")
-2 CLICK EN TEXT1 (interactivechange)
with thisform
titulo="resultado de registro"
texto="este registro ["+.text1.value+"] ya existe ...desea eliminar?"
tipo=4+32+256
use categoria
go top
flag=0
do while !eof()
if rtrim(ltrim(.text1.value))=ltrim(rtrim(categoria))
.text2.value=prehora
flag=1
endif
skip
enddo
if flag=1
opcion=messagebox(texto,tipo,titulo)
do case
case opcion=6
delete from categoria where categoria=thisform.text1.value
wait windows "eligio si... el registro ["+.text1.value+"] fue eliminado"
pack
.text1.value=""
.text2.value=""
.text1.setfocus
endcase
endif
endwith
- 2 CLICK EN SALIR (click)
thisform.release
* CREACION DEL FORMULARIO ADMINISTRACION DE EMPLEADOS


CODIFICACION.
- 2 CLICK EN FORMULARIO (ativate):
close database
open database("D:\sqlfox\datos1")

- 2 CLICK EN TEXT1 (interactivechange)
with thisform
close table all
titulo="resultado de registro"
texto="este registro ["+.text1.value+"] ya existe ...desea eliminar?"
tipo=4+32+256
use empleados
go top
flag=0
do while !eof()
if .text1.value=dni
.text2.value=nombre
.text3.value=direccion
.text4.value=sexo
.text5.value=categoria
flag=1
endif
skip
enddo
if flag=1
opcion=messagebox(texto,tipo,titulo)
do case
case opcion=6
delete from empleados where dni=thisform.text1.value
wait windows "eligio si... el registro ["+.text1.value+"] fue eliminado"
pack
.text1.value=""
.text2.value=""
.text3.value=""
.text4.value=""
.text5.value=""
.text1.setfocus
endcase
endif
endwith
- 2 CLICK EN MOSTRAR DATOS (click)
select empleados.dni,nombre,direccion,sexo,categoria from empleados
- 2 CLICK EN GRABAR (click)
with thisform
close table all
use empleados
append blank
replace dni with .text1.value
repla nombre with .text2.value
repla direccion with .text3.value
repla sexo with .text4.value
repla categoria with .text5.value
=messagebox("los registro fueron grabados ")
Endwith

- 2 CLICK EN SALIR (click)
thisform.release
* CREAR EL FORMULARIO SUELDOS:

CODIFICACION.
- 2 CLICK EN FORMULARIO (ativate):
close database
open database("D:\sqlfox\datos1")
- 2 CLICK EN TEXT1 (interactivechange)
with thisform
close table all
titulo="resultado de registro"
texto="este registro ["+.text1.value+"] ya existe ...desea eliminar?"
tipo=4+32+256
use sueldo
go top
flag=0
do while !eof()
if val(.text1.value)=(contador)
.text2.value=dni
.text3.value=htrab
.text4.value=sbruto
.text5.value=fonavi
.text6.value=essalud
.text7.value=neto
flag=1
endif
skip
enddo
if flag=1
opcion=messagebox(texto,tipo,titulo)
do case
case opcion=6
delete from sueldo where contador=thisform.text1.value
wait windows "eligio si... el registro ["+.text1.value+"] fue eliminado"
pack
.text1.value=""
.text2.value=""
.text3.value=""
.text4.value=""
.text5.value=""
.text6.value=""
.text7.value=""
.text1.setfocus
endcase
endif
endwith
- 2 CLICK EN MOSTRAR DATOS (click)
select sueldos.contador,dni,htrab,sbruto,fonavi,essalud,neto from sueldos
- 2 CLICK EN GRABAR (click)
with thisform
close table all
use sueldo
append blank
repla contador with val(.text1.value)
repla dni with .text2.value
repla htrab with val(.text3.value)
repla sbruto with val(.text4.value)
repla fonavi with val(.text5.value)
repla essalud with val(.text6.value)
repla neto with .text7.value
=messagebox("los registro fueron guardados")
endwith
- 2 CLICK EN SALIR (click)
thisform.release

No hay comentarios: