335 lines
10 KiB
Plaintext
335 lines
10 KiB
Plaintext
{
|
|
-------------------------------------------------------------------------------
|
|
PROGRAMA : CTPRMT009
|
|
OBJETIVO : Capturar, Modificar, Eliminar registros de la
|
|
Tabla de Costos Reales de Liqidacion
|
|
PROGRAMADOR : Ing. Juan F. Soto.
|
|
FECHA REALIZACION : Junio 23, 1993.
|
|
-------------------------------------------------------------------------------
|
|
}
|
|
GLOBALS "ctprgb000.4gl"
|
|
|
|
DEFINE selec1 CHAR(1000)
|
|
DEFINE id_num INTEGER
|
|
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 ctprmt009()
|
|
END MAIN
|
|
|
|
FUNCTION ctprmt009()
|
|
CLEAR SCREEN
|
|
OPTIONS
|
|
FORM LINE 9,
|
|
ERROR LINE 23,
|
|
COMMENT LINE 21
|
|
|
|
OPEN FORM ctfmmt009 FROM "ctfmmt009"
|
|
DISPLAY FORM ctfmmt009
|
|
# CALL pantalla()
|
|
# DISPLAY "ctprmt009" AT 4,3
|
|
# DISPLAY "Costos de Liquidacion" AT 6,29
|
|
|
|
MENU "OPCIONES"
|
|
COMMAND "Adicionar"
|
|
"<Esc> Adiciona Registro <Supr> Cancela Operacion"
|
|
CLEAR FORM
|
|
LET int_flag = false
|
|
CALL ctpcad009()
|
|
COMMAND "Consultar-modificar"
|
|
"<Esc> Realiza Busqueda <Supr> Cancela Operacion"
|
|
LET int_flag = false
|
|
CALL ctpcmf009()
|
|
COMMAND "Salir" "Retorna Menu Anterior"
|
|
EXIT MENU
|
|
END MENU
|
|
END FUNCTION
|
|
|
|
FUNCTION ctpcad009()
|
|
#WHENEVER ERROR CONTINUE
|
|
## Captura los datos que va a contener el registro
|
|
|
|
INPUT BY NAME costos.*
|
|
|
|
AFTER FIELD cod_n
|
|
IF costos.cod_n IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
AFTER FIELD cod_grupo
|
|
IF costos.cod_grupo IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_grupo
|
|
END IF
|
|
AFTER FIELD cod_tipo
|
|
IF costos.cod_tipo IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_tipo
|
|
END IF
|
|
AFTER FIELD cod_sec
|
|
IF costos.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 intb00001 a
|
|
WHERE a.cod_n=costos.cod_n AND a.cod_grupo=costos.cod_grupo AND
|
|
a.cod_tipo=costos.cod_tipo AND a.cod_sec=costos.cod_sec AND
|
|
a.status_t is null
|
|
|
|
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 fecha
|
|
SELECT a.* FROM cttb00013 a WHERE a.fecha = costos.fecha AND
|
|
a.cod_n=costos.cod_n AND a.cod_grupo=costos.cod_grupo AND
|
|
a.cod_tipo=costos.cod_tipo AND a.cod_sec=costos.cod_sec
|
|
AND a.status_t IS NULL
|
|
|
|
IF STATUS != NOTFOUND THEN
|
|
LET numero_msg = 12
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
|
|
SELECT a.* FROM intb00006 a WHERE a.fecha = costos.fecha AND
|
|
a.cod_n=costos.cod_n AND a.cod_grupo=costos.cod_grupo AND
|
|
a.cod_tipo=costos.cod_tipo AND a.cod_sec=costos.cod_sec
|
|
AND a.cod_mov IN (34,35) AND a.status_t IS NULL
|
|
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
|
|
AFTER FIELD costo_lq
|
|
IF costos.costo_lq IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD costo_lq
|
|
END IF
|
|
|
|
AFTER FIELD cantidad
|
|
IF costos.cantidad IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cantidad
|
|
END IF
|
|
|
|
AFTER INPUT
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
|
|
IF costos.costo_lq IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD costo_lq
|
|
END IF
|
|
IF costos.cantidad IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cantidad
|
|
END IF
|
|
|
|
INSERT INTO cttb00013 VALUES (costos.fecha_lq,costos.fecha,
|
|
costos.tipo_lq,costos.num_oc,costos.cod_n,
|
|
costos.cod_grupo,costos.cod_tipo,costos.cod_sec,
|
|
costos.cantidad,costos.costo_lq,NULL,user_sname(),GETDATE(),
|
|
null, null)
|
|
|
|
CALL integridad()
|
|
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
|
|
LET numero_msg = 1
|
|
CALL msg(numero_msg)
|
|
CLEAR FORM
|
|
|
|
EXIT INPUT
|
|
END INPUT
|
|
END FUNCTION
|
|
|
|
FUNCTION ctpcmf009()
|
|
|
|
#WHENEVER ERROR CONTINUE
|
|
## Aqui se prepara para la captura del criterio de seleccion
|
|
|
|
CONSTRUCT BY NAME criterio ON fecha_lq,fecha,cod_n,cod_grupo,cod_tipo,cod_sec
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
|
|
LET selec1 =
|
|
"SELECT *,rowid FROM cttb00013 ",
|
|
"WHERE status_t IS NULL AND fecha IS NOT NULL AND rowid != 0 AND ",
|
|
criterio clipped, " ORDER BY 1,2,3,4,5,6 "
|
|
|
|
PREPARE datos FROM selec1
|
|
DECLARE busca1 SCROLL CURSOR FOR datos
|
|
OPEN busca1
|
|
|
|
FETCH FIRST busca1 INTO costos.*,id_num
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
RETURN
|
|
END IF
|
|
SELECT descrip_esp,unidad_med
|
|
INTO articulos.descrip_esp,articulos.unidad_med
|
|
FROM intb00001 a
|
|
WHERE a.cod_n = costos.cod_n AND
|
|
a.cod_grupo = costos.cod_grupo AND
|
|
a.cod_tipo = costos.cod_tipo AND
|
|
a.cod_sec = costos.cod_sec
|
|
|
|
DISPLAY BY NAME costos.*,articulos.descrip_esp,articulos.unidad_med
|
|
|
|
|
|
MENU "OPCIONES"
|
|
COMMAND "Siguiente"
|
|
"Presenta en pantalla el proximo registro encontrado"
|
|
FETCH NEXT busca1 INTO costos.*,id_num
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 4
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
|
|
SELECT descrip_esp,unidad_med
|
|
INTO articulos.descrip_esp,articulos.unidad_med
|
|
FROM intb00001 a
|
|
WHERE a.cod_n = costos.cod_n AND
|
|
a.cod_grupo = costos.cod_grupo AND
|
|
a.cod_tipo = costos.cod_tipo AND
|
|
a.cod_sec = costos.cod_sec
|
|
|
|
DISPLAY BY NAME costos.*,articulos.descrip_esp,articulos.unidad_med
|
|
|
|
COMMAND "Anterior"
|
|
"Presenta en pantalla el registro anterior encontrado"
|
|
FETCH PREVIOUS busca1 INTO costos.*,id_num
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 5
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
|
|
SELECT descrip_esp,unidad_med
|
|
INTO articulos.descrip_esp,articulos.unidad_med
|
|
FROM intb00001 a
|
|
WHERE a.cod_n = costos.cod_n AND
|
|
a.cod_grupo = costos.cod_grupo AND
|
|
a.cod_tipo = costos.cod_tipo AND
|
|
a.cod_sec = costos.cod_sec
|
|
DISPLAY BY NAME costos.*,articulos.descrip_esp,articulos.unidad_med
|
|
|
|
COMMAND "Primero"
|
|
"Presenta en pantalla el primer registro encontrado"
|
|
FETCH FIRST busca1 INTO costos.*,id_num
|
|
|
|
SELECT descrip_esp,unidad_med
|
|
INTO articulos.descrip_esp,articulos.unidad_med
|
|
FROM intb00001 a
|
|
WHERE a.cod_n = costos.cod_n AND
|
|
a.cod_grupo = costos.cod_grupo AND
|
|
a.cod_tipo = costos.cod_tipo AND
|
|
a.cod_sec = costos.cod_sec
|
|
DISPLAY BY NAME costos.*,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 busca1 INTO costos.*,id_num
|
|
|
|
SELECT descrip_esp,unidad_med
|
|
INTO articulos.descrip_esp,articulos.unidad_med
|
|
FROM intb00001 a
|
|
WHERE a.cod_n = costos.cod_n AND
|
|
a.cod_grupo = costos.cod_grupo AND
|
|
a.cod_tipo = costos.cod_tipo AND
|
|
a.cod_sec = costos.cod_sec
|
|
|
|
DISPLAY BY NAME costos.*,articulos.descrip_esp,articulos.unidad_med
|
|
LET numero_msg = 4
|
|
CALL msg(numero_msg)
|
|
|
|
COMMAND "Escoger"
|
|
"<Esc> Actualiza Registro <Supr> Cancela Operacion"
|
|
|
|
INPUT BY NAME costos.cantidad,costos.costo_lq WITHOUT DEFAULTS
|
|
|
|
AFTER FIELD costo_lq
|
|
IF costos.costo_lq IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD costo_lq
|
|
END IF
|
|
|
|
AFTER FIELD cantidad
|
|
IF costos.cantidad IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cantidad
|
|
END IF
|
|
|
|
## Verifica si el usuario presiono la tecla <Supr>
|
|
AFTER INPUT
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
|
|
UPDATE cttb00013 SET costo_lq = costos.costo_lq,
|
|
cantidad = costos.cantidad,
|
|
us_mod = user_sname(),
|
|
fech_mod = GETDATE()
|
|
WHERE rowid = id_num
|
|
|
|
LET numero_msg = 13
|
|
CALL msg(numero_msg)
|
|
EXIT INPUT
|
|
END INPUT
|
|
|
|
COMMAND KEY ("L") "eLiminar"
|
|
DELETE FROM cttb00013 WHERE rowid = id_num
|
|
|
|
LET numero_msg = 39
|
|
CALL msg(numero_msg)
|
|
|
|
COMMAND "Retornar"
|
|
"Retorna al menu anterior"
|
|
CLEAR FORM
|
|
EXIT MENU
|
|
|
|
END MENU
|
|
END FUNCTION
|