Files
MBS/PROYECTOS/irdir/irprmt010.4gl
T

397 lines
13 KiB
Plaintext

{
------------------------------------------------------------------
PROGRAMA : IRPRMT010
OBJETIVO : Capturar, Modificar, Eliminar registros de la
Relacion Repuestos - Maquinarias.
PROGRAMADOR : Ing. Juan Fco. Soto.
FECHA REALIZACION : Marzo 2, 1993.
------------------------------------------------------------------
}
GLOBALS "irprgb000.4gl"
MAIN
DEFER INTERRUPT
CALL arg_val(1) RETURNING usuarios
CALL arg_val(2) RETURNING clave
CALL arg_val(3) RETURNING impresor
CONNECT TO "smarmotech" USER usuarios USING clave
SELECT * INTO p_companias.* FROM companias
CALL irprmt010()
END MAIN
FUNCTION irprmt010()
CLEAR SCREEN
OPTIONS
FORM LINE 9,
ERROR LINE 23,
COMMENT LINE 21
OPEN FORM irfmmt010 FROM "irfmmt010"
DISPLAY FORM irfmmt010
DISPLAY "irprmt010" AT 4,3
DISPLAY "Repuestos - Maquinas" AT 6,29
MENU
COMMAND "Adicionar"
"<Esc> Adiciona Registro <Ctrl-C> Cancela Operacion"
let int_flag = false
CLEAR FORM
CALL irpcad010()
COMMAND "Buscar"
"<Esc> Realiza Busqueda <Ctrl-C> Cancela Operacion"
let int_flag = false
CALL irpcmf010()
COMMAND "Salir" "Retorna Menu Anterior"
EXIT MENU
END MENU
END FUNCTION
FUNCTION irpcad010()
# WHENEVER ERROR CONTINUE
## Captura los datos que va a contener el registro
INITIALIZE mq_rep.* TO NULL
INPUT BY NAME mq_rep.* WITHOUT DEFAULTS
## Verifica que el cod_maq no exista en el catalogo de maquinas. Si existe,
## entonces despliega los datos del registro existente.
AFTER FIELD cod_maq
IF mq_rep.cod_maq is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_maq
ELSE
SELECT nombre INTO maquinaria.nombre FROM irtb00009
WHERE codigo = mq_rep.cod_maq
IF status >= 0 THEN
IF status = NOTFOUND THEN
DISPLAY BY NAME mq_rep.*
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_maq
END IF
END IF
END IF
DISPLAY BY NAME maquinaria.nombre
# Verifica que el repuesto no este previamente en la maquina
SELECT *FROM irtb00008 WHERE cod_n = mq_rep.cod_n and
cod_grupo = mq_rep.cod_grupo and
cod_tipo = mq_rep.cod_tipo and
cod_sec = mq_rep.cod_sec and
cod_maq = mq_rep.cod_maq
IF status != notfound THEN
LET numero_msg = 117
CALL msg(numero_msg)
NEXT FIELD cod_maq
END IF
AFTER FIELD cod_n
IF mq_rep.cod_n IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
AFTER FIELD cod_grupo
IF mq_rep.cod_grupo IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_grupo
END IF
AFTER FIELD cod_tipo
IF mq_rep.cod_tipo IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_tipo
END IF
AFTER FIELD cod_sec
IF mq_rep.cod_sec IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_sec
END IF
SELECT a.descrip_esp,a.unidad_med INTO articulos.descrip_esp,
articulos.unidad_med
FROM irtb00002 a
WHERE a.cod_n = mq_rep.cod_n and
a.cod_grupo = mq_rep.cod_grupo and
a.cod_tipo = mq_rep.cod_tipo and
a.cod_sec = mq_rep.cod_sec
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_n
END IF
DISPLAY BY NAME articulos.descrip_esp,articulos.unidad_med
AFTER FIELD serie
IF mq_rep.serie IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD serie
END IF
AFTER FIELD motor_elec
IF mq_rep.motor_elec is not null THEN
SELECT * FROM irtb00007 WHERE codigo_m = mq_rep.motor_elec and
status_t is null
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD motor_elec
END IF
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
IF mq_rep.serie IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD serie
END IF
INSERT INTO irtb00008
VALUES
(mq_rep.cod_n,mq_rep.cod_grupo,mq_rep.cod_tipo,mq_rep.cod_sec,
mq_rep.cod_maq,mq_rep.numero,mq_rep.serie,mq_rep.distribuidor,
mq_rep.fabricante,
mq_rep.localizacion,mq_rep.material,mq_rep.dureza,
mq_rep.motor_elec, null, usuarios, getdate(), null, null)
LET numero_msg = 1
CALL msg(numero_msg)
CLEAR FORM
LET mq_rep.cod_maq = NULL
NEXT FIELD cod_n
AFTER FIELD fech_mod
EXIT INPUT
END INPUT
END FUNCTION
FUNCTION irpcmf010()
## Aqui se prepara para la captura del criterio de seleccion
WHENEVER ERROR CONTINUE
CONSTRUCT BY NAME criterio ON cod_n,cod_grupo,cod_tipo,cod_sec,cod_maq
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
LET SELEC = " SELECT UNIQUE * FROM irtb00008 where ",
" status_t is null and ",
criterio clipped,
" ORDER BY 1"
PREPARE busca FROM selec
DECLARE datos SCROLL CURSOR FOR busca
OPEN datos
FETCH FIRST datos INTO mq_rep.*
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
RETURN
END IF
SELECT a.descrip_esp,a.unidad_med INTO articulos.descrip_esp,
articulos.unidad_med
FROM irtb00002 a
WHERE a.cod_n = mq_rep.cod_n and
a.cod_grupo = mq_rep.cod_grupo and
a.cod_tipo = mq_rep.cod_tipo and
a.cod_sec = mq_rep.cod_sec
SELECT nombre INTO maquinaria.nombre FROM irtb00009
WHERE codigo = mq_rep.cod_maq
DISPLAY BY NAME mq_rep.*,maquinaria.nombre,
articulos.descrip_esp,articulos.unidad_med
MENU "OPCIONES "
COMMAND "Siguiente"
"Presenta en pantalla el proximo registro encontrado"
FETCH NEXT datos INTO mq_rep.*
IF STATUS = NOTFOUND THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
SELECT a.descrip_esp,a.unidad_med INTO articulos.descrip_esp,
articulos.unidad_med
FROM irtb00002 a
WHERE a.cod_n = mq_rep.cod_n and
a.cod_grupo = mq_rep.cod_grupo and
a.cod_tipo = mq_rep.cod_tipo and
a.cod_sec = mq_rep.cod_sec
SELECT nombre INTO maquinaria.nombre FROM irtb00009
WHERE codigo = mq_rep.cod_maq
DISPLAY BY NAME mq_rep.*,maquinaria.nombre,
articulos.descrip_esp,articulos.unidad_med
COMMAND "Anterior"
"Presenta en pantalla el registro anterior encontrado"
FETCH PREVIOUS datos INTO mq_rep.*
IF STATUS = NOTFOUND THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
SELECT a.descrip_esp,a.unidad_med INTO articulos.descrip_esp,
articulos.unidad_med
FROM irtb00002 a
WHERE a.cod_n = mq_rep.cod_n and
a.cod_grupo = mq_rep.cod_grupo and
a.cod_tipo = mq_rep.cod_tipo and
a.cod_sec = mq_rep.cod_sec
SELECT nombre INTO maquinaria.nombre FROM irtb00009
WHERE codigo = mq_rep.cod_maq
DISPLAY BY NAME mq_rep.*,maquinaria.nombre,
articulos.descrip_esp,articulos.unidad_med
COMMAND "Primero"
"Presenta en pantalla el primer registro encontrado"
FETCH FIRST datos INTO mq_rep.*
SELECT a.descrip_esp,a.unidad_med INTO articulos.descrip_esp,
articulos.unidad_med
FROM irtb00002 a
WHERE a.cod_n = mq_rep.cod_n and
a.cod_grupo = mq_rep.cod_grupo and
a.cod_tipo = mq_rep.cod_tipo and
a.cod_sec = mq_rep.cod_sec
SELECT nombre INTO maquinaria.nombre FROM irtb00009
WHERE codigo = mq_rep.cod_maq
DISPLAY BY NAME mq_rep.*,maquinaria.nombre,
articulos.descrip_esp,articulos.unidad_med
LET numero_msg = 5
CALL msg(numero_msg)
COMMAND "Ultimo"
"Presenta en pantalla el ultimo registro encontrado"
FETCH LAST datos INTO mq_rep.*
SELECT a.descrip_esp,a.unidad_med INTO articulos.descrip_esp,
articulos.unidad_med
FROM irtb00002 a
WHERE a.cod_n = mq_rep.cod_n and
a.cod_grupo = mq_rep.cod_grupo and
a.cod_tipo = mq_rep.cod_tipo and
a.cod_sec = mq_rep.cod_sec
SELECT nombre INTO maquinaria.nombre FROM irtb00009
WHERE codigo = mq_rep.cod_maq
DISPLAY BY NAME mq_rep.*,maquinaria.nombre,
articulos.descrip_esp,articulos.unidad_med
LET numero_msg = 4
CALL msg(numero_msg)
COMMAND "Escoger"
"<Esc> Actualiza Registro <Ctrl-C> Cancela Operacion"
IF mq_rep.status_t = "E" THEN
LET numero_msg = 39
CALL msg(numero_msg)
RETURN
END IF
INPUT BY NAME mq_rep.numero THRU mq_rep.fech_mod
WITHOUT DEFAULTS
AFTER FIELD serie
IF mq_rep.serie IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD serie
END IF
AFTER FIELD motor_elec
IF mq_rep.motor_elec is not null THEN
SELECT * FROM irtb00007 WHERE codigo_m = mq_rep.motor_elec and
status_t is null
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD motor_elec
END IF
END IF
#### Verifica si el usuario presiono la tecla <Ctrl-C>
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
CLEAR FORM
RETURN
END IF
UPDATE irtb00008 SET numero = mq_rep.numero,
serie = mq_rep.serie,
distribuidor = mq_rep.distribuidor,
fabricante = mq_rep.fabricante,
localizacion = mq_rep.localizacion,
material = mq_rep.material,
dureza = mq_rep.dureza,
motor_elec = mq_rep.motor_elec,
us_mod = usuarios,
fech_mod = getdate()
WHERE cod_n = mq_rep.cod_n and
cod_grupo = mq_rep.cod_grupo and
cod_tipo = mq_rep.cod_tipo and
cod_sec = mq_rep.cod_sec
LET numero_msg = 13
CALL msg(numero_msg)
EXIT INPUT
END INPUT
COMMAND KEY ("L") "eLiminar"
UPDATE irtb00008 SET status_t = "E",
us_mod = usuarios,
fech_mod = getdate()
WHERE cod_n = mq_rep.cod_n and
cod_grupo = mq_rep.cod_grupo and
cod_tipo = mq_rep.cod_tipo and
cod_sec = mq_rep.cod_sec
LET numero_msg = 39
CALL msg(numero_msg)
COMMAND "Retornar"
"Retorna al menu anterior"
CLEAR FORM
EXIT MENU
END MENU
END FUNCTION