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

225 lines
6.5 KiB
Plaintext

{
=========================================================================
PROGRAMA : CTPRMT024
OBJETIVO : CAPTURA LOS COSTOS PARA EL INVENTARIO DE PRODUCTOS EN
PROCESO.
PROGRAMADOR : JUAN F. SOTO
FECHA :FEBRERO 7, 1994.
==========================================================================
}
GLOBALS
"ctprgb000.4gl"
DEFINE cttb34 RECORD LIKE cttb00034.*
DEFINE select1 CHAR(1000)
DEFINE descrip CHAR(30)
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 a.* INTO p_compania.* FROM companias a
CALL ctprmt024()
END MAIN
FUNCTION ctprmt024()
OPTIONS
FORM LINE 8,
ERROR LINE 24
OPEN FORM ctfmmt024 FROM "ctfmmt024"
DISPLAY FORM ctfmmt024
DISPLAY "ctprmt024" AT 4,3
DISPLAY "Costos Productos Semi-elaborados" AT 6,24
MENU "OPCION"
COMMAND "Adicionar" "<ESC> Adiciona Registro <CTRL-C> Cancela Operacion"
LET int_flag = false
CALL ctad024()
COMMAND "Consultar-modificar"
"<ESC> Consulta/Modifica <CTRL-C> Cancela Operacion"
LET int_flag = false
CALL ctmf024()
COMMAND "Salir"
EXIT MENU
END MENU
END FUNCTION
FUNCTION ctad024()
LABEL vuelve:
CLEAR FORM
INPUT BY NAME cttb34.*
AFTER FIELD fecha
IF cttb34.fecha IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha
END IF
AFTER FIELD cod_prod
IF cttb34.cod_prod IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_prod
END IF
SELECT descripcion INTO descrip FROM cttb00001
WHERE @cod_prod = cttb34.cod_prod and status_t is null
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_prod
END IF
DISPLAY BY NAME descrip
SELECT DISTINCT a.cod_prod FROM cttb00034 a
WHERE a.cod_prod = cttb34.cod_prod and a.fecha = cttb34.fecha
IF STATUS != NOTFOUND THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD cod_prod
END IF
AFTER INPUT
EXIT INPUT
END INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
IF cttb34.costo_lab IS NULL THEN
LET cttb34.costo_lab = 0
END IF
IF cttb34.costo_lab IS NULL THEN
LET cttb34.costo_lab = 0
END IF
INSERT INTO cttb00034 VALUES (cttb34.*)
UPDATE cttb00034 SET (us_crea,fech_crea) = (SUSER_SNAME(),GETDATE())
WHERE fecha = cttb34.fecha AND cod_prod = cttb34.cod_prod
LET numero_msg = 1
CALL msg(numero_msg)
GOTO vuelve
END FUNCTION
FUNCTION ctmf024()
CONSTRUCT criterio ON a.fecha,a.cod_prod FROM fecha,cod_prod
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
LET select1 = "SELECT CONVERT(CHAR(10),a.fecha,103) AS fecha,a.cod_prod,a.costo_lab,a.costo_ga,a.status_t,a.us_crea,",
" a.fech_crea,a.us_mod,a.fech_mod,b.descripcion FROM cttb00034 a,cttb00001 b ",
"WHERE a.cod_prod = b.cod_prod AND ",criterio clipped,
" ORDER BY fecha,a.cod_prod"
PREPARE comando FROM select1
DECLARE busca SCROLL CURSOR FOR comando
OPEN busca
FETCH busca INTO cttb34.*,descrip
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
CLEAR FORM
RETURN
END IF
DISPLAY BY NAME cttb34.*,descrip
MENU "OPCION"
COMMAND "Siguiente" "Busca siguiente registro cumpla condicion"
FETCH NEXT busca INTO cttb34.*,descrip
IF status = notfound THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
DISPLAY BY NAME cttb34.*,descrip
COMMAND "Anterior" "Busca el registro anterior cumpla condicion"
FETCH PREVIOUS busca INTO cttb34.*,descrip
IF status = notfound THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
DISPLAY BY NAME cttb34.*,descrip
COMMAND "Primero" "Busca primer registro cumpla condicion"
FETCH FIRST busca INTO cttb34.*,descrip
IF status = notfound THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
DISPLAY BY NAME cttb34.*,descrip
COMMAND "Ultimo" "Busca ultimo registro cumpla condicion"
FETCH LAST busca INTO cttb34.*,descrip
IF status = notfound THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
DISPLAY BY NAME cttb34.*,descrip
COMMAND "Escoger"
"<Esc> Actualiza Registro <Ctrl-C> Cancela Operacion"
INPUT BY NAME cttb34.costo_lab THRU cttb34.fech_mod
WITHOUT DEFAULTS
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
IF cttb34.costo_lab IS NULL THEN
LET cttb34.costo_lab = 0
END IF
IF cttb34.costo_lab IS NULL THEN
LET cttb34.costo_lab = 0
END IF
UPDATE cttb00034 SET (costo_lab,costo_ga,us_mod,fech_mod) =
(cttb34.costo_lab,cttb34.costo_ga,
SUSER_SNAME(),GETDATE())
WHERE fecha = cttb34.fecha AND cod_prod = cttb34.cod_prod
LET numero_msg = 13
CALL msg(numero_msg)
COMMAND KEY("L") "eLiminar"
UPDATE cttb00034 SET (status_t,us_mod,fech_mod) =
("E",SUSER_SNAME(),GETDATE())
WHERE fecha = cttb34.fecha AND cod_prod = cttb34.cod_prod
LET numero_msg = 39
CALL msg(numero_msg)
CLEAR FORM
COMMAND "Retornar"
CLEAR FORM
EXIT MENU
END MENU
END FUNCTION
FUNCTION busca()
SELECT descripcion INTO descrip FROM cttb00001
WHERE @cod_prod = cttb34.cod_prod and status_t is null
DISPLAY BY NAME descrip
END FUNCTION