449 lines
13 KiB
Plaintext
449 lines
13 KiB
Plaintext
{
|
|
------------------------------------------------------------------
|
|
PROGRAMA : TEPRMT001
|
|
OBJETIVO : Capturar, Modificar, Eliminar registros de la
|
|
Tabla de Depositos.
|
|
PROGRAMADOR : Tadeo A. Ferreras
|
|
FECHA REALIZACION : Diciembre 2, 1992.
|
|
------------------------------------------------------------------
|
|
}
|
|
GLOBALS "teprgb000.4gl"
|
|
DEFINE proced INTEGER
|
|
|
|
FUNCTION teprmt001()
|
|
CLEAR SCREEN
|
|
OPTIONS
|
|
FORM LINE 9,
|
|
ERROR LINE 23,
|
|
MESSAGE LINE 24,
|
|
COMMENT LINE 21
|
|
|
|
OPEN FORM tefmmt001 FROM "tefmmt001"
|
|
DISPLAY FORM tefmmt001
|
|
CALL pantalla()
|
|
# CALL ayuda()
|
|
DISPLAY "teprmt001" AT 4,3 ATTRIBUTE(RED)
|
|
DISPLAY "Mantenimiento de Depositos" at 6,27 ATTRIBUTE(BLACK)
|
|
|
|
MENU "OPCIONES"
|
|
COMMAND "Adicionar"
|
|
"<Esc> Adiciona Registro <Supr> Cancela Operacion"
|
|
HELP 5
|
|
LET INT_FLAG = FALSE
|
|
CLEAR FORM
|
|
LET INT_FLAG = FALSE
|
|
CALL tepcad001()
|
|
COMMAND "Consultar-modificar"
|
|
"<Esc> Realiza Busqueda <Supr> Cancela Operacion"
|
|
HELP 6
|
|
LET int_flag = FALSE
|
|
CALL tepcmf001()
|
|
COMMAND "Salir" "Retorna Menu Anterior"
|
|
EXIT MENU
|
|
END MENU
|
|
END FUNCTION
|
|
|
|
FUNCTION tepcad001()
|
|
# WHENEVER ERROR CONTINUE
|
|
## Captura los datos que va a contener el registro
|
|
|
|
INITIALIZE deposito.* TO NULL
|
|
LET descrip1 = NULL
|
|
LET descrip2 = NULL
|
|
INPUT BY NAME deposito.*
|
|
ON KEY (CONTROL-W)
|
|
CASE
|
|
WHEN INFIELD(procedencia)
|
|
CALL busca_procedencia()
|
|
LET deposito.procedencia = proced
|
|
DISPLAY BY NAME deposito.procedencia,descrip2
|
|
NEXT FIELD fecha
|
|
END CASE
|
|
|
|
BEFORE FIELD num_doc
|
|
SELECT MAX(num_doc) INTO deposito.num_doc
|
|
FROM tetb00001
|
|
|
|
IF deposito.num_doc IS NULL THEN
|
|
LET deposito.num_doc = 0
|
|
END IF
|
|
|
|
LET deposito.num_doc = deposito.num_doc + 1
|
|
DISPLAY BY NAME deposito.num_doc
|
|
|
|
AFTER FIELD cuenta_no
|
|
IF deposito.cuenta_no = " " OR
|
|
deposito.cuenta_no is null THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cuenta_no
|
|
END IF
|
|
|
|
LET descrip1 = NULL
|
|
SELECT i.descripcion INTO descrip1
|
|
FROM cgtb00001 i,cgtb00012 b
|
|
WHERE i.cuenta_no = b.cuenta_no AND
|
|
i.cuenta_no= deposito.cuenta_no AND
|
|
i.status_t is null
|
|
|
|
IF descrip1 IS NULL THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cuenta_no
|
|
END IF
|
|
DISPLAY BY NAME descrip1
|
|
|
|
AFTER FIELD procedencia
|
|
IF deposito.cta_banco IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cta_banco
|
|
END IF
|
|
|
|
LET descrip2 = NULL
|
|
IF deposito.procedencia IS NOT NULL THEN
|
|
SELECT unique a.descripcion INTO descrip2 FROM tetb00002 a
|
|
WHERE a.status_t IS NULL AND a.procedencia=deposito.procedencia
|
|
|
|
IF descrip2 IS NULL THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD procedencia
|
|
END IF
|
|
|
|
DISPLAY BY NAME descrip2
|
|
END IF
|
|
|
|
AFTER FIELD fecha
|
|
IF deposito.procedencia IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD procedencia
|
|
END IF
|
|
|
|
IF deposito.fecha IS NOT NULL THEN
|
|
IF deposito.fecha > today THEN
|
|
LET numero_msg = 189
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD fecha
|
|
END IF
|
|
|
|
LET p_fechas = deposito.fecha
|
|
CALL prd()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
NEXT FIELD fecha
|
|
END IF
|
|
END IF
|
|
|
|
AFTER FIELD monto
|
|
IF deposito.fecha IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD fecha
|
|
END IF
|
|
|
|
IF deposito.monto IS NULL OR
|
|
deposito.monto = 0 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD monto
|
|
END IF
|
|
|
|
END INPUT
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET numero_msg = FALSE
|
|
RETURN
|
|
END IF
|
|
|
|
INSERT INTO tetb00001 VALUES (deposito.*)
|
|
UPDATE tetb00001 SET (us_crea,fech_crea) = (USER,CURRENT)
|
|
WHERE @num_doc = deposito.num_doc
|
|
|
|
LET numero_msg = 1
|
|
CALL msg(numero_msg)
|
|
END FUNCTION
|
|
|
|
FUNCTION tepcmf001()
|
|
LET int_flag = FALSE
|
|
## Aqui se prepara para la captura del criterio de seleccion
|
|
MESSAGE ""
|
|
CLEAR FORM
|
|
CONSTRUCT criterio ON a.num_doc,a.cuenta_no FROM num_doc,cuenta_no
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
|
|
LET SELEC = " SELECT UNIQUE a.*,b.descripcion,c.descripcion ",
|
|
" FROM tetb00001 a,cgtb00001 b,tetb00002 c ",
|
|
" WHERE a.cuenta_no = b.cuenta_no AND a.status_t is null AND ",
|
|
" a.procedencia = c.procedencia AND ",
|
|
criterio clipped," ORDER BY a.num_doc "
|
|
|
|
PREPARE busca FROM selec
|
|
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
|
|
DECLARE datos SCROLL CURSOR FOR busca
|
|
OPEN datos
|
|
|
|
FETCH FIRST datos INTO deposito.*,descrip1,descrip2
|
|
IF status >= 0 THEN
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
RETURN
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
|
|
DISPLAY BY NAME deposito.*,descrip1,descrip2
|
|
#CALL busca_cuenta()
|
|
|
|
MENU "OPCIONES "
|
|
COMMAND "Siguiente"
|
|
"Presenta en pantalla el proximo registro encontrado"
|
|
FETCH NEXT datos INTO deposito.*,descrip1,descrip2
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 4
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
#CALL busca_cuenta()
|
|
|
|
DISPLAY BY NAME deposito.*,descrip1,descrip2
|
|
|
|
COMMAND "Anterior"
|
|
"Presenta en pantalla el registro anterior encontrado"
|
|
FETCH PREVIOUS datos INTO deposito.*,descrip1,descrip2
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 5
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
|
|
#CALL busca_cuenta()
|
|
DISPLAY BY NAME deposito.*,descrip1,descrip2
|
|
|
|
COMMAND "Primero"
|
|
"Presenta en pantalla el primer registro encontrado"
|
|
FETCH FIRST datos INTO deposito.*,descrip1,descrip2
|
|
|
|
#CALL busca_cuenta()
|
|
DISPLAY BY NAME deposito.*,descrip1,descrip2
|
|
|
|
LET numero_msg = 5
|
|
CALL msg(numero_msg)
|
|
|
|
COMMAND "Ultimo"
|
|
"Presenta en pantalla el ultimo registro encontrado"
|
|
FETCH LAST datos INTO deposito.*,descrip1,descrip2
|
|
|
|
# CALL busca_cuenta()
|
|
DISPLAY BY NAME deposito.*,descrip1
|
|
|
|
LET numero_msg = 4
|
|
CALL msg(numero_msg)
|
|
|
|
COMMAND "Escoger"
|
|
"<Esc> Actualiza Registro <Supr> Cancela Operacion"
|
|
|
|
LET p_fechas = deposito.fecha
|
|
CALL prd()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
|
|
INPUT BY NAME deposito.cuenta_no THRU deposito.fech_mod WITHOUT DEFAULTS
|
|
ON KEY (CONTROL-W)
|
|
CASE
|
|
WHEN INFIELD(procedencia)
|
|
CALL busca_procedencia()
|
|
LET deposito.procedencia = proced
|
|
DISPLAY BY NAME deposito.procedencia,descrip2
|
|
NEXT FIELD fecha
|
|
END CASE
|
|
|
|
AFTER FIELD cuenta_no
|
|
IF deposito.cuenta_no = " " OR
|
|
deposito.cuenta_no is null THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cuenta_no
|
|
END IF
|
|
|
|
LET descrip1 = NULL
|
|
SELECT i.descripcion INTO descrip1
|
|
FROM cgtb00001 i,cgtb00012 b
|
|
WHERE i.cuenta_no = b.cuenta_no AND
|
|
i.cuenta_no= deposito.cuenta_no AND
|
|
i.status_t is null
|
|
|
|
IF descrip1 IS NULL THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cuenta_no
|
|
END IF
|
|
DISPLAY BY NAME descrip1
|
|
|
|
AFTER FIELD procedencia
|
|
IF deposito.cta_banco IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cta_banco
|
|
END IF
|
|
|
|
LET descrip2 = NULL
|
|
IF deposito.procedencia IS NOT NULL THEN
|
|
SELECT unique a.descripcion INTO descrip2 FROM tetb00002 a
|
|
WHERE a.status_t IS NULL AND a.procedencia=deposito.procedencia
|
|
|
|
IF descrip2 IS NULL THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD procedencia
|
|
END IF
|
|
|
|
DISPLAY BY NAME descrip2
|
|
END IF
|
|
|
|
AFTER FIELD fecha
|
|
IF deposito.procedencia IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD procedencia
|
|
END IF
|
|
|
|
IF deposito.fecha IS NOT NULL THEN
|
|
IF deposito.fecha > today THEN
|
|
LET numero_msg = 189
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD fecha
|
|
END IF
|
|
|
|
LET p_fechas = deposito.fecha
|
|
CALL prd()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
NEXT FIELD fecha
|
|
END IF
|
|
END IF
|
|
|
|
AFTER FIELD monto
|
|
IF deposito.monto IS NULL OR
|
|
deposito.monto = 0 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD monto
|
|
END IF
|
|
END INPUT
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
|
|
UPDATE tetb00001 SET (cuenta_no,cta_banco,procedencia,
|
|
fecha,monto,us_mod,fech_mod)
|
|
= (deposito.cuenta_no,deposito.cta_banco,
|
|
deposito.procedencia,deposito.fecha,
|
|
deposito.monto,USER,CURRENT)
|
|
WHERE @num_doc = deposito.num_doc
|
|
|
|
LET numero_msg = 13
|
|
CALL msg(numero_msg)
|
|
|
|
COMMAND KEY ("L") "eLiminar"
|
|
"Elimina registro que esta en la pantalla"
|
|
|
|
DELETE FROM tetb00001
|
|
WHERE @num_doc = deposito.num_doc
|
|
|
|
LET numero_msg = 39
|
|
CALL msg(numero_msg)
|
|
|
|
COMMAND "Retornar"
|
|
"Retorna al menu anterior"
|
|
CLEAR FORM
|
|
# CALL ayuda()
|
|
EXIT MENU
|
|
END MENU
|
|
END FUNCTION
|
|
|
|
FUNCTION busca_cuenta()
|
|
# Esta funcion busca el nombre del cuenta y lo despliega en pantalla
|
|
# Esta funcion es valida solamente para la consulta-modificacion.
|
|
|
|
SELECT i.descripcion INTO descrip1 FROM cgtb00001 i
|
|
WHERE i.cuenta_no = deposito.cuenta_no and
|
|
i.status_t is null
|
|
|
|
IF status >= 0 THEN
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 68
|
|
CALL msg(numero_msg)
|
|
ELSE
|
|
IF status_reg = "E" THEN
|
|
LET numero_msg = 67
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION busca_procedencia()
|
|
# Esta funcion busca el nombre de la Procedencia
|
|
|
|
OPEN WINDOW busqueda1 AT 10,10 WITH FORM "tefmwd002"
|
|
ATTRIBUTE (BORDER,FORM LINE FIRST + 1, comment line last)
|
|
|
|
DECLARE buscador CURSOR FOR
|
|
SELECT i.procedencia,i.descripcion FROM tetb00002 i
|
|
WHERE i.status_t IS NULL ORDER BY 1
|
|
|
|
IF status >= 0 THEN
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 68
|
|
CALL msg(numero_msg)
|
|
CLOSE WINDOW busqueda1
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
|
|
LET idx = 1
|
|
FOREACH buscador INTO arr_procedencia[idx].*
|
|
LET idx = idx + 1
|
|
END FOREACH
|
|
CALL SET_COUNT(idx - 1)
|
|
|
|
DISPLAY ARRAY arr_procedencia TO s_procedencia.*
|
|
LET curr = ARR_CURR()
|
|
|
|
LET proced = arr_procedencia[curr].procedencia
|
|
LET descrip2 = arr_procedencia[curr].descripcion
|
|
CLOSE WINDOW busqueda1
|
|
END FUNCTION
|