Files
MBS/PROYECTO/ctdir/ctprmt011.4gl
T

223 lines
6.8 KiB
Plaintext

{
==============================================================================
PROGRAMAS :CTPRMT011
DESCRIPCION: PRECIOS REALES SEMI-ELABORADOS
OBJETIVO : MANTENER ACTUALIZADA LA TABLA -PRECIOS REALES DE LOS
SEMI-ELABORADOS
FECHA : ENERO 16, 1996.
PROGRAMADOR: JUAN F. SOTO
==============================================================================
}
GLOBALS
"ctprgb000.4gl"
DEFINE p_real RECORD LIKE cttb00037.*,
p_descrip CHAR(30),
selec1 CHAR(100),
opt10 CHAR(1),
hoy DATE
FUNCTION ctprmt011()
OPTIONS
PROMPT LINE 20,
FORM LINE 8,
ERROR LINE 24
OPEN FORM ctfmmt011 FROM "ctfmmt011"
DISPLAY FORM ctfmmt011
CALL pantalla()
DISPLAY "ctprmt011" AT 4,3
DISPLAY "Precios Reales Semi-elaborados" AT 6,25
MENU "OPCION"
COMMAND "Adionar" "<Esc> Adiciona Registro <Ctrl-C> Cancela Operacion"
LET int_flag = false
CALL ctpcad011()
COMMAND "Consultar-modificar"
"<Esc> Actualiza Busca Registro <Ctrl-C> Cancela Operacion"
LET int_flag = false
CALL ctpcmf011()
COMMAND "Salir" "Sale Al Menu Anterior"
EXIT MENU
END MENU
END FUNCTION
# FUNCTION PARA ADICIONAR REGISTRO A LA TABLA
FUNCTION ctpcad011()
CLEAR FORM
LET hoy = today
WHILE int_flag = false
INPUT BY NAME p_real.*
BEFORE FIELD fecha
LET p_real.fecha = hoy
AFTER FIELD fecha
IF p_real.fecha is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha
END IF
LET hoy = p_real.fecha
AFTER FIELD cod_prod
IF p_real.cod_prod is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_prod
END IF
SELECT a.descripcion INTO p_descrip
FROM cttb00001 a
WHERE a.cod_prod = p_real.cod_prod
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
DISPLAY BY NAME p_descrip
NEXT FIELD cod_prod
END IF
DISPLAY BY NAME p_descrip
SELECT * FROM cttb00037
WHERE cod_prod = p_real.cod_prod
IF status != notfound THEN
LET numero_msg = 353
CALL msg(numero_msg)
DISPLAY BY NAME p_real.*
NEXT FIELD cod_prod
END IF
AFTER FIELD precio
IF p_real.precio is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD precio
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
EXIT INPUT
END IF
INSERT INTO cttb00037 VALUES (p_real.*)
UPDATE cttb00037 set us_crea = user,
fech_crea = current
WHERE cod_prod = p_real.cod_prod and
fecha = p_real.fecha
LET numero_msg = 1
CALL msg(numero_msg)
CLEAR FORM
END INPUT
IF int_flag THEN
LET int_flag = false
EXIT WHILE
END IF
CONTINUE WHILE
END WHILE
END FUNCTION
FUNCTION ctpcmf011()
CLEAR FORM
CONSTRUCT BY NAME criterio ON a.cod_prod
IF int_flag THEN
LET numero_msg = 16
CALL msg(numero_msg)
LET int_flag = false
RETURN
END IF
LET selec1 =
"SELECT a.* FROM cttb00037 a ",
"WHERE ",criterio clipped," AND a.status_t is null ",
" ORDER BY 1"
PREPARE comando FROM selec1
DECLARE busca SCROLL CURSOR FOR comando
OPEN busca
FETCH FIRST busca INTO p_real.*
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
RETURN
END IF
CALL busca_p()
DISPLAY BY NAME p_real.*,p_descrip
MENU "OPCION"
COMMAND "Siguiente" "Busca siguiente registro cumpla la condicion"
FETCH NEXT busca INTO p_real.*
IF status = notfound THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
CALL busca_p()
DISPLAY BY NAME p_real.*,p_descrip
COMMAND "Anterior" "Busca registro anterior cumpla la condicion"
FETCH PREVIOUS busca INTO p_real.*
IF status = notfound THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
CALL busca_p()
DISPLAY BY NAME p_real.*,p_descrip
COMMAND "Primero" "Busca primer registro cumpla la condicion"
FETCH FIRST busca INTO p_real.*
IF status = notfound THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
LET numero_msg = 4
CALL msg(numero_msg)
CALL busca_p()
DISPLAY BY NAME p_real.*,p_descrip
COMMAND "Ultimo" "Busca ultimo registro cumpla la condicion"
FETCH FIRST busca INTO p_real.*
LET numero_msg = 5
CALL msg(numero_msg)
CALL busca_p()
DISPLAY BY NAME p_real.*,p_descrip
COMMAND "Escoger"
"<Esc> Actualiza Registro <Ctrl-C> Cancela Operacion"
INPUT BY NAME p_real.precio WITHOUT DEFAULTS
AFTER FIELD precio
IF p_real.precio is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD precio
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
EXIT INPUT
END IF
END INPUT
UPDATE cttb00037 set precio = p_real.precio,
us_mod = user,
fech_mod = current
WHERE cod_prod = p_real.cod_prod and
fecha = p_real.fecha
LET numero_msg = 13
CALL msg(numero_msg)
COMMAND KEY ("L") "eLiminar"
PROMPT
"Esta Seguro de Eliminar Este Registro? (S/N)" FOR CHAR opt10
LET opt10 = upshift(opt10)
IF opt10 = "S" THEN
UPDATE cttb00037 set status_t = "E",
us_mod = user,
fech_mod = current
WHERE cod_prod = p_real.cod_prod and
fecha = p_real.fecha
END IF
COMMAND "Retornar"
CLEAR FORM
EXIT MENU
END MENU
END FUNCTION
FUNCTION busca_p()
SELECT descripcion INTO p_descrip
FROM cttb00001
WHERE cod_prod = p_real.cod_prod
END FUNCTION