990 lines
36 KiB
Plaintext
990 lines
36 KiB
Plaintext
{
|
|
------------------------------------------------------------------
|
|
PROGRAMA : VEPRMT003
|
|
OBJETIVO : Capturar, Modificar, Eliminar registros de la
|
|
Tabla de Descuentos.
|
|
PROGRAMADOR : Lic. Abner Montalvo Z.
|
|
FECHA REALIZACION : Septiembre 14, 1992.
|
|
------------------------------------------------------------------
|
|
}
|
|
GLOBALS "veprgb000.4gl"
|
|
|
|
FUNCTION veprmt003()
|
|
WHENEVER ERROR CONTINUE
|
|
CLEAR SCREEN
|
|
OPTIONS
|
|
FORM LINE 9,
|
|
ERROR LINE 23,
|
|
HELP FILE "vepray000.exe",
|
|
HELP KEY CONTROL-W,
|
|
MESSAGE LINE 24,
|
|
COMMENT LINE 21
|
|
|
|
OPEN FORM vefmmt003 FROM "vefmmt003"
|
|
DISPLAY FORM vefmmt003
|
|
CALL pantalla()
|
|
CALL ayuda()
|
|
DISPLAY "veprmt003" AT 4,3
|
|
DISPLAY "Maestra de Descuentos" AT 6,29
|
|
|
|
MENU "OPCIONES"
|
|
COMMAND "Adicionar"
|
|
"<Esc> Adiciona Registro <Delete> Cancela Operacion"
|
|
HELP 5
|
|
LET int_flag = FALSE
|
|
CLEAR FORM
|
|
CALL vepcad003()
|
|
COMMAND "Consultar-modificar"
|
|
"<Esc> Realiza Busqueda <Delete> Cancela Operacion"
|
|
HELP 6
|
|
LET int_flag = FALSE
|
|
CALL vepcmf003()
|
|
COMMAND "Salir" "Retorna Menu Anterior"
|
|
EXIT MENU
|
|
END MENU
|
|
END FUNCTION
|
|
|
|
FUNCTION vepcad003()
|
|
## Captura los datos que va a contener el registro
|
|
|
|
WHENEVER ERROR CONTINUE
|
|
MESSAGE ""
|
|
LET int_flag = false
|
|
INPUT BY NAME descuento.*
|
|
ON KEY (CONTROL-W)
|
|
CASE
|
|
WHEN INFIELD (cod_n)
|
|
CALL busca_pt()
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
|
|
IF NOT int_flag THEN
|
|
DISPLAY pterminado.cod_n TO cod_n
|
|
DISPLAY pterminado.cod_grupo TO cod_grupo
|
|
DISPLAY pterminado.cod_tipo TO cod_tipo
|
|
DISPLAY pterminado.cod_sec TO cod_sec
|
|
DISPLAY descrip1 TO descrip_esp
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
LET int_flag = FALSE
|
|
|
|
WHEN INFIELD (cod_grupo)
|
|
CALL busca_pt()
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_grupo
|
|
END IF
|
|
|
|
IF NOT int_flag THEN
|
|
DISPLAY pterminado.cod_n TO cod_n
|
|
DISPLAY pterminado.cod_grupo TO cod_grupo
|
|
DISPLAY pterminado.cod_tipo TO cod_tipo
|
|
DISPLAY pterminado.cod_sec TO cod_sec
|
|
DISPLAY descrip1 TO descrip_esp
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
LET int_flag = FALSE
|
|
|
|
WHEN INFIELD (cod_tipo)
|
|
CALL busca_pt()
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_tipo
|
|
END IF
|
|
|
|
IF NOT int_flag THEN
|
|
DISPLAY pterminado.cod_n TO cod_n
|
|
DISPLAY pterminado.cod_grupo TO cod_grupo
|
|
DISPLAY pterminado.cod_tipo TO cod_tipo
|
|
DISPLAY pterminado.cod_sec TO cod_sec
|
|
DISPLAY descrip1 TO descrip_esp
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
LET int_flag = FALSE
|
|
|
|
WHEN INFIELD (cod_sec)
|
|
CALL busca_pt()
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_sec
|
|
END IF
|
|
|
|
IF NOT int_flag THEN
|
|
DISPLAY pterminado.cod_n TO cod_n
|
|
DISPLAY pterminado.cod_grupo TO cod_grupo
|
|
DISPLAY pterminado.cod_tipo TO cod_tipo
|
|
DISPLAY pterminado.cod_sec TO cod_sec
|
|
DISPLAY descrip1 TO descrip_esp
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
LET int_flag = FALSE
|
|
END CASE
|
|
|
|
## Verifica que el codigo no exista en la tabla de descuentos. Si existe,
|
|
## entonces despliega los datos del registro existente.
|
|
AFTER FIELD tipo_desc
|
|
IF descuento.tipo_desc IS NULL OR
|
|
descuento.tipo_desc = 0 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD tipo_desc
|
|
ELSE
|
|
SELECT * INTO descuento.* FROM vetb00013
|
|
WHERE tipo_desc = descuento.tipo_desc
|
|
|
|
IF status >= 0 THEN
|
|
IF status != NOTFOUND THEN
|
|
IF descuento.status_t = "E" THEN
|
|
LET numero_msg = 36
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD tipo_desc
|
|
END IF
|
|
DISPLAY BY NAME descuento.*
|
|
LET numero_msg = 12
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD tipo_desc
|
|
ELSE
|
|
LET descuento.porc_desc = 0
|
|
LET descuento.valor_desc = 0
|
|
LET descuento.cantidad_1 = 0
|
|
LET descuento.cantidad_2 = 0
|
|
LET descuento.cajas_bonif = 0
|
|
INITIALIZE descuento.descrip, descuento.cod_n,
|
|
descuento.cod_grupo, descuento.cod_tipo,
|
|
descuento.cod_sec, descuento.us_crea,
|
|
descuento.fech_crea, descuento.us_mod,
|
|
descuento.fech_mod, descrip1 TO NULL
|
|
DISPLAY descrip1 TO descrip_esp
|
|
DISPLAY BY NAME descuento.descrip, descuento.cod_n,
|
|
descuento.cod_grupo, descuento.cod_tipo,
|
|
descuento.cod_sec, descuento.porc_desc,
|
|
descuento.cantidad_1, descuento.cantidad_2,
|
|
descuento.cajas_bonif, descuento.us_crea,
|
|
descuento.fech_crea, descuento.us_mod,
|
|
descuento.fech_mod
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
END IF
|
|
|
|
AFTER FIELD descrip
|
|
IF descuento.descrip IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD descrip
|
|
END IF
|
|
|
|
AFTER FIELD cod_n
|
|
IF descuento.cod_n IS NOT NULL THEN
|
|
IF descuento.cod_n != 3 and
|
|
descuento.cod_n != 6 and
|
|
descuento.cod_n != 9 THEN
|
|
LET numero_msg = 60
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
END IF
|
|
|
|
AFTER FIELD cod_sec
|
|
IF descuento.cod_n IS NOT NULL AND
|
|
descuento.cod_grupo IS NOT NULL AND
|
|
descuento.cod_tipo IS NOT NULL AND
|
|
descuento.cod_sec IS NOT NULL THEN
|
|
SELECT i.descrip_esp INTO descrip1
|
|
FROM iptb00002 i
|
|
WHERE i.cod_n = descuento.cod_n AND
|
|
i.cod_grupo = descuento.cod_grupo AND
|
|
i.cod_tipo = descuento.cod_tipo AND
|
|
i.cod_sec = descuento.cod_sec and
|
|
i.status_t is null
|
|
|
|
IF status >= 0 THEN
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 61
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
DISPLAY descrip1 TO descrip_esp
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
END IF
|
|
|
|
{ BEFORE FIELD dias_validos
|
|
IF descuento.tipo_desc < 99 THEN
|
|
NEXT FIELD porc_desc
|
|
END IF }
|
|
|
|
|
|
AFTER FIELD cantidad_2
|
|
IF descuento.cantidad_2 is null THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cantidad_2
|
|
END IF
|
|
|
|
AFTER FIELD cajas_bonif
|
|
IF descuento.cajas_bonif = 0 AND descuento.cantidad_2 = 0 AND
|
|
descuento.cantidad_1 = 0 AND descuento.porc_desc = 0 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
|
|
IF descuento.cantidad_2 != 0 AND
|
|
descuento.cantidad_1 != 0 AND
|
|
descuento.porc_desc = 0 AND
|
|
descuento.cajas_bonif = 0 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
|
|
AFTER INPUT
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
CALL ayuda()
|
|
RETURN
|
|
END IF
|
|
|
|
## Verifica que el codigo no exista en la tabla de descuentos. Si existe,
|
|
## entonces despliega los datos del registro existente.
|
|
IF descuento.tipo_desc IS NULL OR
|
|
descuento.tipo_desc = 0 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD tipo_desc
|
|
ELSE
|
|
SELECT * INTO descuento.* FROM vetb00013
|
|
WHERE tipo_desc = descuento.tipo_desc
|
|
|
|
IF status >= 0 THEN
|
|
IF status != NOTFOUND THEN
|
|
IF descuento.status_t = "E" THEN
|
|
LET numero_msg = 36
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD tipo_desc
|
|
END IF
|
|
DISPLAY BY NAME descuento.*
|
|
LET numero_msg = 12
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD tipo_desc
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
END IF
|
|
|
|
IF descuento.descrip IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD descrip
|
|
END IF
|
|
|
|
IF descuento.cod_n IS NULL THEN
|
|
IF descuento.cod_n != 3 and
|
|
descuento.cod_n != 6 and
|
|
descuento.cod_n != 9 THEN
|
|
LET numero_msg = 60
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
END IF
|
|
|
|
IF descuento.cod_n IS NOT NULL AND
|
|
descuento.cod_grupo IS NOT NULL AND
|
|
descuento.cod_tipo IS NOT NULL AND
|
|
descuento.cod_sec IS NOT NULL THEN
|
|
SELECT i.descrip_esp INTO descrip1
|
|
FROM iptb00002 i
|
|
WHERE i.cod_n = descuento.cod_n AND
|
|
i.cod_grupo = descuento.cod_grupo AND
|
|
i.cod_tipo = descuento.cod_tipo AND
|
|
i.cod_sec = descuento.cod_sec and
|
|
i.status_t is null
|
|
|
|
IF status >= 0 THEN
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 61
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
DISPLAY descrip1 TO descrip_esp
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
END IF
|
|
|
|
IF descuento.cantidad_2 is null THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cantidad_2
|
|
END IF
|
|
|
|
{ IF descuento.cajas_bonif = 0 AND descuento.cantidad_2 = 0 AND
|
|
descuento.cantidad_1 = 0 AND descuento.porc_desc = 0 AND
|
|
descuento.valor_desc = 0 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD porc_desc
|
|
END IF}
|
|
|
|
{ IF descuento.cantidad_2 != 0 AND
|
|
descuento.cantidad_1 != 0 AND
|
|
descuento.porc_desc = 0 AND
|
|
descuento.cajas_bonif = 0 AND
|
|
descuento.tipo_desc < 99 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD porc_desc
|
|
END IF }
|
|
# Valida que el codigo del descuento no sea cero. Si no es cero, adiciona el
|
|
# registro en la tabla, de lo contrario, presenta mensaje de error y acepta
|
|
# el codigo de nuevo.
|
|
|
|
INSERT INTO vetb00013 VALUES (descuento.tipo_desc,
|
|
descuento.descrip,
|
|
descuento.cod_n,
|
|
descuento.cod_grupo,
|
|
descuento.cod_tipo,
|
|
descuento.cod_sec,
|
|
descuento.dias_validos,
|
|
descuento.porc_desc,
|
|
descuento.valor_desc,
|
|
descuento.cantidad_1,
|
|
descuento.cantidad_2,
|
|
descuento.cajas_bonif,
|
|
null, USER, CURRENT,
|
|
null, null)
|
|
|
|
# Verifica el Status que retorna luego de insertar el registro en la tabla.
|
|
# Si el Status es diferente de cero quiere decir que hubo problemas durante
|
|
# la creacion del registro, entonces despliega un mensaje.
|
|
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
|
|
LET numero_msg = 1
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD tipo_desc
|
|
|
|
AFTER FIELD fech_mod
|
|
EXIT INPUT
|
|
END INPUT
|
|
END FUNCTION
|
|
|
|
FUNCTION vepcmf003()
|
|
# WHENEVER ERROR CONTINUE
|
|
|
|
IF parametro = "CONSULTA" THEN
|
|
OPEN FORM vefmmt003 FROM "vefmmt003"
|
|
DISPLAY FORM vefmmt003
|
|
CALL pantalla()
|
|
CALL ayuda()
|
|
DISPLAY "veprmt003" AT 4,3
|
|
DISPLAY "Consulta de Descuentos" AT 6,23
|
|
END IF
|
|
|
|
MESSAGE ""
|
|
LET int_flag = false
|
|
## Aqui se prepara para la captura del criterio de seleccion
|
|
|
|
LET descrip1 = NULL
|
|
DISPLAY descrip1 TO descrip_esp
|
|
CONSTRUCT criterio ON vetb00013.* FROM vetb00013.*
|
|
|
|
IF int_flag THEN
|
|
LET parametro = "INT-FLAG"
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
CALL ayuda()
|
|
RETURN
|
|
END IF
|
|
|
|
LET SELEC = " SELECT UNIQUE * FROM vetb00013 where ",
|
|
" status_t is null and ",
|
|
criterio clipped,
|
|
" ORDER BY 1"
|
|
|
|
PREPARE busca FROM selec
|
|
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET parametro = "INT-FLAG"
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
|
|
DECLARE datos SCROLL CURSOR FOR busca
|
|
OPEN datos
|
|
FETCH FIRST datos INTO descuento.*
|
|
IF status >= 0 THEN
|
|
IF STATUS = NOTFOUND THEN
|
|
LET parametro = "INT-FLAG"
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
RETURN
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET parametro = "INT-FLAG"
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
|
|
LET descrip1 = null
|
|
SELECT i.descrip_esp INTO descrip1
|
|
FROM iptb00002 i
|
|
WHERE i.cod_n = descuento.cod_n AND
|
|
i.cod_grupo = descuento.cod_grupo AND
|
|
i.cod_tipo = descuento.cod_tipo AND
|
|
i.cod_sec = descuento.cod_sec and
|
|
i.status_t is null
|
|
|
|
IF status >= 0 THEN
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 61
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET parametro = "INT-FLAG"
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
|
|
DISPLAY descrip1 TO descrip_esp
|
|
DISPLAY BY NAME descuento.*
|
|
LET cliente_des.tipo_desc = descuento.tipo_desc
|
|
|
|
MENU "OPCIONES "
|
|
COMMAND "Siguiente"
|
|
"Presenta en pantalla el proximo registro encontrado"
|
|
FETCH NEXT datos INTO descuento.*
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 4
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
LET descrip1 = null
|
|
SELECT i.descrip_esp INTO descrip1
|
|
FROM iptb00002 i
|
|
WHERE i.cod_n = descuento.cod_n AND
|
|
i.cod_grupo = descuento.cod_grupo AND
|
|
i.cod_tipo = descuento.cod_tipo AND
|
|
i.cod_sec = descuento.cod_sec and
|
|
i.status_t is null
|
|
|
|
IF status >= 0 THEN
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 61
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET parametro = "INT-FLAG"
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
|
|
DISPLAY descrip1 TO descrip_esp
|
|
DISPLAY BY NAME descuento.*
|
|
LET cliente_des.tipo_desc = descuento.tipo_desc
|
|
|
|
COMMAND "Anterior"
|
|
"Presenta en pantalla el registro anterior encontrado"
|
|
FETCH PREVIOUS datos INTO descuento.*
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 5
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
LET descrip1 = null
|
|
SELECT i.descrip_esp INTO descrip1
|
|
FROM iptb00002 i
|
|
WHERE i.cod_n = descuento.cod_n AND
|
|
i.cod_grupo = descuento.cod_grupo AND
|
|
i.cod_tipo = descuento.cod_tipo AND
|
|
i.cod_sec = descuento.cod_sec and
|
|
i.status_t is null
|
|
|
|
IF status >= 0 THEN
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 61
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET parametro = "INT-FLAG"
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
|
|
DISPLAY descrip1 TO descrip_esp
|
|
DISPLAY BY NAME descuento.*
|
|
LET cliente_des.tipo_desc = descuento.tipo_desc
|
|
|
|
COMMAND "Primero"
|
|
"Presenta en pantalla el primer registro encontrado"
|
|
FETCH FIRST datos INTO descuento.*
|
|
LET descrip1 = null
|
|
SELECT i.descrip_esp INTO descrip1
|
|
FROM iptb00002 i
|
|
WHERE i.cod_n = descuento.cod_n AND
|
|
i.cod_grupo = descuento.cod_grupo AND
|
|
i.cod_tipo = descuento.cod_tipo AND
|
|
i.cod_sec = descuento.cod_sec and
|
|
i.status_t is null
|
|
|
|
IF status >= 0 THEN
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 61
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET parametro = "INT-FLAG"
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
|
|
DISPLAY descrip1 TO descrip_esp
|
|
DISPLAY BY NAME descuento.*
|
|
LET numero_msg = 5
|
|
CALL msg(numero_msg)
|
|
LET cliente_des.tipo_desc = descuento.tipo_desc
|
|
|
|
COMMAND "Ultimo"
|
|
"Presenta en pantalla el ultimo registro encontrado"
|
|
FETCH LAST datos INTO descuento.*
|
|
LET descrip1 = null
|
|
SELECT i.descrip_esp INTO descrip1
|
|
FROM iptb00002 i
|
|
WHERE i.cod_n = descuento.cod_n AND
|
|
i.cod_grupo = descuento.cod_grupo AND
|
|
i.cod_tipo = descuento.cod_tipo AND
|
|
i.cod_sec = descuento.cod_sec and
|
|
i.status_t is null
|
|
|
|
IF status >= 0 THEN
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 61
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET parametro = "INT-FLAG"
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
|
|
DISPLAY descrip1 TO descrip_esp
|
|
DISPLAY BY NAME descuento.*
|
|
LET numero_msg = 4
|
|
CALL msg(numero_msg)
|
|
LET cliente_des.tipo_desc = descuento.tipo_desc
|
|
|
|
COMMAND "Escoger"
|
|
"<Esc> Actualiza Registro <Delete> Cancela Operacion"
|
|
IF parametro = "CONSULTA" THEN
|
|
GO TO salir_escoger
|
|
END IF
|
|
|
|
IF descuento.status_t= "E" THEN
|
|
LET parametro = "INT-FLAG"
|
|
LET numero_msg= 36
|
|
CALL msg(numero_msg)
|
|
RETURN
|
|
END IF
|
|
INPUT BY NAME descuento.descrip,
|
|
descuento.cod_n,
|
|
descuento.cod_grupo,
|
|
descuento.cod_tipo,
|
|
descuento.cod_sec,
|
|
descuento.dias_validos,
|
|
descuento.porc_desc,
|
|
descuento.valor_desc,
|
|
descuento.cantidad_1,
|
|
descuento.cantidad_2,
|
|
descuento.cajas_bonif,
|
|
descuento.us_crea,
|
|
descuento.fech_crea,
|
|
descuento.us_mod,
|
|
descuento.fech_mod WITHOUT DEFAULTS
|
|
ON KEY (CONTROL-W)
|
|
CASE
|
|
WHEN INFIELD (cod_n)
|
|
CALL busca_pt()
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
|
|
IF NOT int_flag THEN
|
|
DISPLAY pterminado.cod_n TO cod_n
|
|
DISPLAY pterminado.cod_grupo TO cod_grupo
|
|
DISPLAY pterminado.cod_tipo TO cod_tipo
|
|
DISPLAY pterminado.cod_sec TO cod_sec
|
|
DISPLAY descrip1 TO descrip_esp
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
LET int_flag = FALSE
|
|
|
|
WHEN INFIELD (cod_grupo)
|
|
CALL busca_pt()
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_grupo
|
|
END IF
|
|
|
|
IF NOT int_flag THEN
|
|
DISPLAY pterminado.cod_n TO cod_n
|
|
DISPLAY pterminado.cod_grupo TO cod_grupo
|
|
DISPLAY pterminado.cod_tipo TO cod_tipo
|
|
DISPLAY pterminado.cod_sec TO cod_sec
|
|
DISPLAY descrip1 TO descrip_esp
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
LET int_flag = FALSE
|
|
|
|
WHEN INFIELD (cod_tipo)
|
|
CALL busca_pt()
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_tipo
|
|
END IF
|
|
|
|
IF NOT int_flag THEN
|
|
DISPLAY pterminado.cod_n TO cod_n
|
|
DISPLAY pterminado.cod_grupo TO cod_grupo
|
|
DISPLAY pterminado.cod_tipo TO cod_tipo
|
|
DISPLAY pterminado.cod_sec TO cod_sec
|
|
DISPLAY descrip1 TO descrip_esp
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
LET int_flag = FALSE
|
|
|
|
WHEN INFIELD (cod_sec)
|
|
CALL busca_pt()
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_sec
|
|
END IF
|
|
|
|
IF NOT int_flag THEN
|
|
DISPLAY pterminado.cod_n TO cod_n
|
|
DISPLAY pterminado.cod_grupo TO cod_grupo
|
|
DISPLAY pterminado.cod_tipo TO cod_tipo
|
|
DISPLAY pterminado.cod_sec TO cod_sec
|
|
DISPLAY descrip1 TO descrip_esp
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
LET int_flag = FALSE
|
|
END CASE
|
|
|
|
AFTER FIELD descrip
|
|
IF descuento.descrip IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD descrip
|
|
END IF
|
|
|
|
AFTER FIELD cod_n
|
|
IF descuento.cod_n IS NULL THEN
|
|
IF descuento.cod_n != 3 and
|
|
descuento.cod_n != 6 and
|
|
descuento.cod_n != 9 THEN
|
|
LET numero_msg = 60
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
END IF
|
|
|
|
AFTER FIELD cod_sec
|
|
IF descuento.cod_n IS NOT NULL AND
|
|
descuento.cod_grupo IS NOT NULL AND
|
|
descuento.cod_tipo IS NOT NULL AND
|
|
descuento.cod_sec IS NOT NULL THEN
|
|
SELECT i.descrip_esp INTO descrip1
|
|
FROM iptb00002 i
|
|
WHERE i.cod_n = descuento.cod_n AND
|
|
i.cod_grupo = descuento.cod_grupo AND
|
|
i.cod_tipo = descuento.cod_tipo AND
|
|
i.cod_sec = descuento.cod_sec and
|
|
i.status_t is null
|
|
|
|
IF status >= 0 THEN
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 61
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
DISPLAY descrip1 TO descrip_esp
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
END IF
|
|
|
|
{ BEFORE FIELD dias_validos
|
|
IF descuento.tipo_desc < 99 THEN
|
|
NEXT FIELD porc_desc
|
|
END IF }
|
|
|
|
AFTER FIELD cantidad_2
|
|
IF descuento.cantidad_2 is null THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cantidad_2
|
|
END IF
|
|
|
|
AFTER FIELD cajas_bonif
|
|
IF descuento.cajas_bonif = 0 AND descuento.cantidad_2 = 0 AND
|
|
descuento.cantidad_1 = 0 AND descuento.porc_desc = 0 AND
|
|
descuento.valor_desc = 0 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
|
|
IF descuento.cantidad_2 != 0 AND
|
|
descuento.cantidad_1 != 0 AND
|
|
descuento.porc_desc = 0 AND
|
|
descuento.cajas_bonif = 0 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
|
|
AFTER INPUT
|
|
#### Verifica si el usuario presiono la tecla <Delete>
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
CALL ayuda()
|
|
RETURN
|
|
END IF
|
|
|
|
IF descuento.descrip IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD descrip
|
|
END IF
|
|
|
|
IF descuento.cod_n IS NULL THEN
|
|
IF descuento.cod_n != 3 THEN
|
|
LET numero_msg = 60
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
END IF
|
|
|
|
IF descuento.cod_n IS NOT NULL AND
|
|
descuento.cod_grupo IS NOT NULL AND
|
|
descuento.cod_tipo IS NOT NULL AND
|
|
descuento.cod_sec IS NOT NULL THEN
|
|
SELECT i.descrip_esp INTO descrip1
|
|
FROM iptb00002 i
|
|
WHERE i.cod_n = descuento.cod_n AND
|
|
i.cod_grupo = descuento.cod_grupo AND
|
|
i.cod_tipo = descuento.cod_tipo AND
|
|
i.cod_sec = descuento.cod_sec and
|
|
i.status_t is null
|
|
|
|
IF status >= 0 THEN
|
|
IF status = NOTFOUND THEN
|
|
LET numero_msg = 61
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cod_n
|
|
END IF
|
|
DISPLAY descrip1 TO descrip_esp
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
RETURN
|
|
END IF
|
|
END IF
|
|
END IF
|
|
|
|
IF descuento.cantidad_2 is null THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD cantidad_2
|
|
END IF
|
|
|
|
IF descuento.cajas_bonif = 0 AND descuento.cantidad_2 = 0 AND
|
|
descuento.cantidad_1 = 0 AND descuento.porc_desc = 0 AND
|
|
descuento.valor_desc = 0 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
|
|
IF descuento.cantidad_2 != 0 AND
|
|
descuento.cantidad_1 != 0 AND
|
|
descuento.porc_desc = 0 AND
|
|
descuento.cajas_bonif = 0 AND
|
|
descuento.tipo_desc < 99 THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD porc_desc
|
|
END IF
|
|
|
|
UPDATE vetb00013 SET descrip = descuento.descrip,
|
|
cod_n = descuento.cod_n,
|
|
cod_grupo = descuento.cod_grupo,
|
|
cod_tipo = descuento.cod_tipo,
|
|
cod_sec = descuento.cod_sec,
|
|
dias_validos = descuento.dias_validos,
|
|
porc_desc = descuento.porc_desc,
|
|
valor_desc = descuento.valor_desc,
|
|
cantidad_1 = descuento.cantidad_1,
|
|
cantidad_2 = descuento.cantidad_2,
|
|
cajas_bonif = descuento.cajas_bonif,
|
|
us_mod = USER,
|
|
fech_mod = CURRENT
|
|
WHERE tipo_desc = descuento.tipo_desc
|
|
|
|
LET numero_msg = 13
|
|
CALL msg(numero_msg)
|
|
EXIT INPUT
|
|
END INPUT
|
|
LABEL salir_escoger:
|
|
LET numero_msg = 22
|
|
|
|
COMMAND KEY ("L") "eLiminar"
|
|
"Elimina registro que esta en la pantalla"
|
|
|
|
IF parametro = "CONSULTA" THEN
|
|
GO TO salir_eliminar
|
|
END IF
|
|
|
|
UPDATE vetb00013 SET status_t = "E",
|
|
us_mod = USER,
|
|
fech_mod = CURRENT
|
|
WHERE tipo_desc = descuento.tipo_desc
|
|
|
|
LET numero_msg = 39
|
|
CALL msg(numero_msg)
|
|
|
|
LABEL salir_eliminar:
|
|
LET numero_msg = 22
|
|
|
|
COMMAND "Retornar"
|
|
"Retorna al menu anterior"
|
|
EXIT MENU
|
|
END MENU
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION busca_pt()
|
|
OPEN WINDOW busqueda AT 7,12 WITH FORM "vefmwd003"
|
|
ATTRIBUTE (BORDER,FORM LINE FIRST + 2,COMMENT LINE LAST,MESSAGE LINE LAST)
|
|
LET int_flag = false
|
|
CONSTRUCT criterio ON a.descrip_esp FROM descrip_esp
|
|
|
|
LET selec2 =
|
|
"SELECT a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.descrip_esp ",
|
|
"FROM iptb00002 a ",
|
|
"WHERE a.status_t is null AND ",criterio clipped," ORDER BY 5 "
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
GO TO sale9
|
|
END IF
|
|
|
|
PREPARE busca_pila FROM selec2
|
|
IF status >= 0 THEN
|
|
IF status = notfound THEN
|
|
LET numero_msg = 12
|
|
CALL msg(numero_msg)
|
|
END IF
|
|
ELSE
|
|
CALL integridad()
|
|
IF bandera = 1 THEN
|
|
LET bandera = 0
|
|
END IF
|
|
END IF
|
|
|
|
DECLARE buscar_pila CURSOR FOR busca_pila
|
|
LET idx = 1
|
|
|
|
FOREACH buscar_pila INTO pilas[idx].*
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
EXIT FOREACH
|
|
END IF
|
|
|
|
LET idx = idx + 1
|
|
END FOREACH
|
|
|
|
CALL set_count(idx-1)
|
|
MESSAGE " <Esc> Selecciona Producto Terminado donde esta el cursor"
|
|
DISPLAY ARRAY pilas TO s_pilas.*
|
|
LET curr1 = arr_curr()
|
|
LET pterminado.cod_n = pilas[curr1].cod_n
|
|
LET pterminado.cod_grupo = pilas[curr1].cod_grupo
|
|
LET pterminado.cod_tipo = pilas[curr1].cod_tipo
|
|
LET pterminado.cod_sec = pilas[curr1].cod_sec
|
|
LET descuento.cod_n = pilas[curr1].cod_n
|
|
LET descuento.cod_grupo = pilas[curr1].cod_grupo
|
|
LET descuento.cod_tipo = pilas[curr1].cod_tipo
|
|
LET descuento.cod_sec = pilas[curr1].cod_sec
|
|
LET descrip1 = pilas[curr1].descrip_esp
|
|
|
|
LABEL sale9:
|
|
CLOSE WINDOW busqueda
|
|
|
|
END FUNCTION
|