Files
2026-09-22 20:38:51 -04:00

587 lines
18 KiB
Plaintext

{
------------------------------------------------------------------
PROGRAMA : ACPRMT001
OBJETIVO : Capturar, Modificar, Elimacar registros de la
Tabla Catalogo de Bienes y Servicios
PROGRAMADOR : TAdeo A. Ferreras.
FECHA REALIZACION : Sept. 27, 1993.
------------------------------------------------------------------
}
GLOBALS "acprgb000.4gl"
DEFINE fecha6 DATE
DEFINE descripcion1,descripcion2,descripcion3,descripcion4,
descripcion5 CHAR(30)
MAIN
DEFER INTERRUPT
CALL ARG_VAL(1) RETURNING usuarios
CALL ARG_VAL(2) RETURNING clave
CONNECT to "decomarmol" user usuarios USING clave
SELECT a.* INTO p_companias.* FROM companias a
CALL acprmt001()
END MAIN
FUNCTION acprmt001()
# WHENEVER ERROR CONTINUE
CLEAR SCREEN
OPTIONS
FORM LINE 9,
ERROR LINE 23,
COMMENT LINE 21
OPEN FORM acfmmt001 FROM "acfmmt001"
DISPLAY FORM acfmmt001
# CALL pantalla()
DISPLAY "acprmt001" AT 4,3
DISPLAY "Maestra de Activos Fijos" AT 6,28
MENU "OPCIONES"
COMMAND "Adicionar"
"<Esc> Adiciona Registro <Supr> Cancela Operacion"
LET int_flag = FALSE
CLEAR FORM
CALL acpcad001()
COMMAND "Consultar-modificar"
"<Esc> Realiza Busqueda <Supr> Cancela Operacion"
LET INT_FLAG = FALSE
CLEAR FORM
CALL acpcmf001()
COMMAND "Salir" "Retorna Menu Anterior"
EXIT MENU
CLEAR FORM
END MENU
END FUNCTION
FUNCTION acpcad001()
#WHENEVER ERROR CONTINUE
## Captura los datos que va a contener el registro
LET int_flag = false
LABEL volver:
INPUT BY NAME activ.* WITHOUT DEFAULTS
ON KEY (control-w)
CASE
WHEN INFIELD(departamento)
CALL busca_dpto1()
LET activ.departamento = busca_dpto[curr].departamento
LET descripcion4 = busca_dpto[curr].nom_dpto
DISPLAY BY NAME activ.departamento,descripcion4
NEXT FIELD tasa_cambio
END CASE
## Verifica que el codigo no exista en el catalogo de activ. Si existe,
## entonces despliega los datos del registro existente.
BEFORE FIELD codigo
LET activ.codigo = 0
SELECT MAX(a.codigo) INTO activ.codigo FROM actb00001 a
WHERE a.codigo >= 0
IF activ.codigo IS NULL THEN
LET activ.codigo = 0
END IF
LET activ.codigo = activ.codigo + 1
DISPLAY BY NAME activ.codigo
AFTER FIELD codigo
IF activ.codigo is null then
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD codigo
END IF
#### Verifica que el el codigo asignado al activ no exista
SELECT a.* FROM actb00001 a
WHERE a.codigo = activ.codigo AND a.status_t IS NULL
IF status != NOTFOUND THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD codigo
END IF
AFTER FIELD cuenta_no
IF activ.cuenta_no IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
##### Chequea que el numero de cuenta a digitar exista en el catalogo
SELECT a.descripcion INTO descripcion1
FROM cgtb00001 a
WHERE a.cuenta_no = activ.cuenta_no AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
DISPLAY BY NAME descripcion1
AFTER FIELD cta_depr
IF activ.cta_depr IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cta_depr
END IF
##### Chequea que el numero de cuenta a digitar exista en el catalogo
SELECT a.descripcion INTO descripcion2
FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_depr AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cta_depr
END IF
DISPLAY BY NAME descripcion2
AFTER FIELD cta_gasto
IF activ.cta_gasto IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cta_gasto
END IF
##### Chequea que el numero de cuenta a digitar exista en el catalogo
SELECT a.descripcion INTO descripcion3
FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_gasto AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cta_gasto
END IF
DISPLAY BY NAME descripcion3
AFTER FIELD departamento
IF activ.departamento IS NOT NULL THEN
SELECT a.nom_dpto INTO descripcion4 FROM adtb00001 a
WHERE a.departamento = activ.departamento
AND a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
DISPLAY BY NAME descripcion4
END IF
AFTER FIELD duracion
IF activ.duracion IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD duracion
END IF
AFTER FIELD descripcion
IF activ.descripcion IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD descripcion
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
END INPUT
#### Proceso para insertar la informacion en las tablas necesarias
#LET activ.fech_compra = null
LET activ.fech_elim = null
INSERT INTO actb00001 VALUES (activ.*)
UPDATE actb00001 set (us_crea,fech_crea) = (usuarios,getdate())
WHERE @codigo = activ.codigo
INSERT INTO actb00005 (codigo,descripcion,cuenta_no,cta_depr,cta_gasto,departamento,fech_compra
,duracion,fech_elim,status_t,us_crea,fech_crea,codigo_n)
VALUES (activ.codigo,activ.descripcion,activ.cuenta_no,activ.cta_depr,activ.cta_gasto,
activ.departamento,activ.fech_compra,activ.duracion,activ.fech_elim,activ.status_t,
usuarios,getdate(),null )
LET numero_msg = 1
CALL msg(numero_msg)
CLEAR FORM
END FUNCTION
###### Funcion de modificacion
FUNCTION acpcmf001()
#WHENEVER ERROR CONTINUE
LET int_flag = false
## Aqui se prepara para la captura del criterio de seleccion
CONSTRUCT criterio ON a.codigo,a.descripcion,a.cuenta_no,a.departamento
FROM codigo,descripcion,cuenta_no,departamento
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
LET SELEC =
"SELECT a.codigo
,a.descripcion
,a.cuenta_no
,a.cta_depr
,a.cta_gasto
,a.departamento
,CONVERT(VARCHAR(10),fech_compra,103)
,a.duracion
,CONVERT(VARCHAR(10),fech_elim,103)
,a.referencia
,a.fabricante
,a.status_t
,a.us_crea
,a.fech_crea
,a.us_mod
,a.fech_mod
FROM actb00001 a
WHERE a.status_t IS NULL AND ",criterio CLIPPED, " ORDER BY a.codigo "
PREPARE busca FROM selec
DECLARE datos SCROLL CURSOR FOR busca
OPEN datos
FETCH FIRST datos INTO activ.*
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
RETURN
END IF
SELECT a.descripcion INTO descripcion1 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cuenta_no
SELECT a.descripcion INTO descripcion2 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_depr
SELECT a.descripcion INTO descripcion3 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_gasto
SELECT a.nom_dpto INTO descripcion4 FROM adtb00001 a
WHERE a.departamento = activ.departamento
DISPLAY BY NAME activ.*,descripcion1,descripcion2,descripcion3,
descripcion4
MENU "OPCIONES "
COMMAND "Siguiente"
"Presenta en pantalla el proximo registro encontrado"
FETCH NEXT datos INTO activ.*,fecha6,estado.*
IF STATUS = NOTFOUND THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
SELECT a.descripcion INTO descripcion1 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cuenta_no
SELECT a.descripcion INTO descripcion2 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_depr
SELECT a.descripcion INTO descripcion3 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_gasto
SELECT a.nom_dpto INTO descripcion4 FROM adtb00001 a
WHERE a.departamento = activ.departamento
DISPLAY BY NAME activ.*,descripcion1,descripcion2,descripcion3,
descripcion4
COMMAND "Anterior"
"Presenta en pantalla el registro anterior encontrado"
FETCH PREVIOUS datos INTO activ.*,fecha6,estado.*
IF STATUS = NOTFOUND THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
SELECT a.descripcion INTO descripcion1 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cuenta_no
SELECT a.descripcion INTO descripcion2 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_depr
SELECT a.descripcion INTO descripcion3 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_gasto
SELECT a.nom_dpto INTO descripcion4 FROM adtb00001 a
WHERE a.departamento = activ.departamento
DISPLAY BY NAME activ.*,descripcion1,descripcion2,descripcion3,
descripcion4
COMMAND "Primero"
"Presenta en pantalla el primer registro encontrado"
FETCH FIRST datos INTO activ.*,fecha6,estado.*
SELECT a.descripcion INTO descripcion1 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cuenta_no
SELECT a.descripcion INTO descripcion2 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_depr
SELECT a.descripcion INTO descripcion3 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_gasto
SELECT a.nom_dpto INTO descripcion4 FROM adtb00001 a
WHERE a.departamento = activ.departamento
DISPLAY BY NAME activ.*,descripcion1,descripcion2,descripcion3,
descripcion4
LET numero_msg = 5
CALL msg(numero_msg)
COMMAND "Ultimo"
"Presenta en pantalla el ultimo registro encontrado"
FETCH LAST datos INTO activ.*,fecha6,estado.*
SELECT a.descripcion INTO descripcion1 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cuenta_no
SELECT a.descripcion INTO descripcion2 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_depr
SELECT a.descripcion INTO descripcion3 FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_gasto
SELECT a.nom_dpto INTO descripcion4 FROM adtb00001 a
WHERE a.departamento = activ.departamento
DISPLAY BY NAME activ.*,descripcion1,descripcion2,descripcion3,
descripcion4
LET numero_msg = 4
CALL msg(numero_msg)
COMMAND "Escoger"
"<Esc> Actualiza Registro <Supr> Cancela Operacion"
IF estado.status_t="E" THEN
LET numero_msg= 36
CALL msg(numero_msg)
RETURN
END IF
IF activ.status_t IS NOT NULL THEN
RETURN
END IF
INPUT BY NAME activ.descripcion THRU activ.fech_mod
WITHOUT DEFAULTS
ON KEY (control-w)
CASE
WHEN INFIELD(departamento)
CALL busca_dpto1()
LET activ.departamento = busca_dpto[curr].departamento
LET descripcion4 = busca_dpto[curr].nom_dpto
DISPLAY BY NAME activ.departamento,descripcion4
NEXT FIELD tasa_cambio
END CASE
AFTER FIELD cuenta_no
IF activ.cuenta_no IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
##### Chequea que el numero de cuenta a digitar exista en el catalogo
SELECT a.descripcion INTO descripcion1
FROM cgtb00001 a
WHERE a.cuenta_no = activ.cuenta_no AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
DISPLAY BY NAME descripcion1
AFTER FIELD cta_depr
IF activ.cta_depr IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cta_depr
END IF
##### Chequea que el numero de cuenta a digitar exista en el catalogo
SELECT a.descripcion INTO descripcion2
FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_depr AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cta_depr
END IF
DISPLAY BY NAME descripcion2
AFTER FIELD cta_gasto
IF activ.cta_gasto IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cta_gasto
END IF
##### Chequea que el numero de cuenta a digitar exista en el catalogo
SELECT a.descripcion INTO descripcion3
FROM cgtb00001 a
WHERE a.cuenta_no = activ.cta_gasto AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cta_gasto
END IF
DISPLAY BY NAME descripcion3
AFTER FIELD departamento
IF activ.departamento IS NOT NULL THEN
SELECT a.nom_dpto INTO descripcion4 FROM adtb00001 a
WHERE a.departamento = activ.departamento
AND a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
DISPLAY BY NAME descripcion4
END IF
AFTER FIELD duracion
IF activ.duracion IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD duracion
END IF
AFTER FIELD descripcion
IF activ.descripcion IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD descripcion
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
RETURN
END IF
END INPUT
###### Proceso de Actualizacion
UPDATE actb00001 SET descripcion = activ.descripcion,
cuenta_no = activ.cuenta_no,
cta_depr = activ.cta_depr,
cta_gasto = activ.cta_gasto,
duracion = activ.duracion,
fech_compra = activ.fech_compra,
departamento = activ.departamento,
referencia = activ.referencia,
fabricante = activ.fabricante,
us_mod = usuarios,
fech_mod = getdate()
WHERE codigo = activ.codigo
UPDATE actb00005 SET descripcion = activ.descripcion,
cuenta_no = activ.cuenta_no,
cta_depr = activ.cta_depr,
cta_gasto = activ.cta_gasto,
duracion = activ.duracion,
fech_compra = activ.fech_compra,
departamento = activ.departamento,
us_mod = usuarios,
fech_mod = getdate()
WHERE codigo = activ.codigo
LET numero_msg = 13
CALL msg(numero_msg)
#### Proceso para eliminar un registro logicamente
COMMAND KEY ("L") "eLiminar"
UPDATE actb00001 SET (status_t,us_mod,fech_mod) =
("E",usuarios,getdate())
WHERE @codigo = activ.codigo
UPDATE actb00005 SET (status_t,us_mod,fech_mod) =
("E",usuarios,getdate())
WHERE @codigo = activ.codigo
LET numero_msg = 39
CALL msg(numero_msg)
COMMAND "Retornar"
"Retorna al menu anterior"
EXIT MENU
CLEAR FORM
END MENU
END FUNCTION
FUNCTION busca_dpto1()
OPEN WINDOW busqueda AT 10,10 WITH FORM "acfmwd01"
ATTRIBUTE (BORDER,FORM LINE FIRST + 2, comment line last)
CONSTRUCT criterio ON adtb00001.nom_dpto FROM adtb00001.nom_dpto
LET selec = "SELECT departamento,nom_dpto FROM adtb00001 ",
" WHERE status_t is null AND ",criterio clipped,
"ORDER BY 1 "
PREPARE busco FROM selec
DECLARE local CURSOR FOR busco
LET idx = 1
FOREACH local INTO busca_dpto[idx].*
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
EXIT FOREACH
END IF
LET idx = idx + 1
END FOREACH
CALL set_count(idx-1)
DISPLAY ARRAY busca_dpto TO dpto1.*
LET curr = arr_curr()
LET activ.departamento = busca_dpto[curr].departamento
LET descripcion4 = busca_dpto[curr].nom_dpto
CLOSE WINDOW busqueda
END FUNCTION