Files

393 lines
13 KiB
Plaintext

{
------------------------------------------------------------------
PROGRAMA : noprmt023
OBJETIVO : Capturar, Modificar, Eliminar registros de la
Tabla Numeros de Periodos de Nomina.
PROGRAMADOR : Oscar Castillo
FECHA REALIZACION : Friday, 15 December, 2000
------------------------------------------------------------------
}
GLOBALS "noprgb000.4gl"
DEFINE relacion RECORD LIKE notb00023.*
MAIN
DEFER INTERRUPT
CALL ARG_VAL(1) RETURNING usuarios
CALL ARG_VAL(2) RETURNING clave
CONNECT to "smarmotech" USER usuarios USING clave
SELECT a.* INTO p_companias.* FROM companias a
CALL noprmt025()
END MAIN
FUNCTION noprmt025()
CLEAR SCREEN
OPTIONS
FORM LINE 9,
ERROR LINE 23,
COMMENT LINE 21
OPEN FORM nofmmt025 FROM "nofmmt025"
DISPLAY FORM nofmmt025
MENU
ON ACTION nuevo
let int_flag = false
CLEAR FORM
CALL nopcad023()
ON ACTION buscar
let int_flag = false
CALL nopcmf023()
ON ACTION Salir
EXIT MENU
END MENU
END FUNCTION
FUNCTION nopcad023()
#WHENEVER ERROR CONTINUE
## Captura los datos que va a contener el registro
INPUT BY NAME relacion.*
## Verifica que el codigo no exista en el catalogo de unidades. Si existe,
## entonces despliega los datos del registro existente.
AFTER FIELD numero_nomina
IF relacion.numero_nomina IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD numero_nomina
END IF
SELECT *
FROM notb00023 a
WHERE a.numero_nomina = relacion.numero_nomina
IF STATUS != NOTFOUND THEN
LET numero_msg = 2
CALL msg(numero_msg)
NEXT FIELD numero_nomina
END IF
AFTER FIELD tipo_emp
IF relacion.tipo_emp IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD tipo_emp
END IF
SELECT a.*
FROM notb00010 a
WHERE a.tipo_emp = relacion.tipo_emp
AND a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 2
CALL msg(numero_msg)
NEXT FIELD tipo_emp
END IF
IF relacion.tipo_emp = "Q" AND
relacion.numero_nomina <= 24 THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD numero_nomina
END IF
IF relacion.tipo_emp = "S" AND
relacion.numero_nomina <= 52 THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD numero_nomina
END IF
AFTER FIELD fecha
IF relacion.fecha IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha
END IF
SELECT a.*
FROM notb00023 a
WHERE a.tipo_emp = relacion.tipo_emp
AND a.fecha = relacion.fecha
AND a.status_t IS NULL
IF STATUS != NOTFOUND THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD tipo_emp
END IF
AFTER FIELD monto_excento
IF relacion.monto_excento IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD monto_excento
END IF
AFTER FIELD porc_15
IF relacion.porc_15 IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD porc_15
END IF
AFTER FIELD porc_20
IF relacion.porc_20 IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD porc_20
END IF
AFTER FIELD porc_25
IF relacion.porc_25 IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD porc_25
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
IF relacion.numero_nomina IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD numero_nomina
ELSE
INSERT INTO notb00023 VALUES (relacion.numero_nomina,
relacion.tipo_emp,relacion.fecha,relacion.monto_excento,
relacion.porc_15,relacion.porc_20,relacion.porc_25,
null, SUSER_SNAME(), GETDATE(), null, null,relacion.monto_ars,relacion.monto_afp)
LET numero_msg = 1
CALL msg(numero_msg)
CLEAR FORM
END IF
END INPUT
END FUNCTION
FUNCTION nopcmf023()
DEFINE chfecha char(25)
## Aqui se prepara para la captura del criterio de seleccion
CONSTRUCT BY NAME criterio ON a.numero_nomina,a.tipo_emp #,a.fecha
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
LET SELEC = "SELECT a.numero_nomina,a.tipo_emp,convert(varchar(10),a.fecha,101),a.monto_excento,",
"a.porc_15,a.porc_20,a.porc_25,a.monto_ars,a.monto_afp FROM notb00023 a where ",
" a.status_t is null and ",
criterio clipped
PREPARE busca FROM selec
DECLARE datos SCROLL CURSOR FOR busca
OPEN datos
FETCH FIRST datos INTO relacion.numero_nomina,
relacion.tipo_emp,
relacion.fecha,
relacion.monto_excento,
relacion.porc_15,
relacion.porc_20,
relacion.porc_25,
relacion.monto_ars,
relacion.monto_afp
#LET relacion.fecha = chfecha
# DISPLAY chfecha TO fecha
DISPLAY BY NAME relacion.*
MENU "OPCIONES "
COMMAND "Siguiente"
"Presenta en pantalla el proximo registro encontrado"
FETCH NEXT datos INTO relacion.numero_nomina,
relacion.tipo_emp,
relacion.fecha,
relacion.monto_excento,
relacion.porc_15,
relacion.porc_20,
relacion.porc_25,
relacion.monto_ars,
relacion.monto_afp
IF STATUS = NOTFOUND THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
DISPLAY BY NAME relacion.*
COMMAND "Anterior"
"Presenta en pantalla el registro anterior encontrado"
FETCH PREVIOUS datos INTO relacion.numero_nomina,
relacion.tipo_emp,
relacion.fecha,
relacion.monto_excento,
relacion.porc_15,
relacion.porc_20,
relacion.porc_25,
relacion.monto_ars,
relacion.monto_afp
IF STATUS = NOTFOUND THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
DISPLAY BY NAME relacion.*
COMMAND "Primero"
"Presenta en pantalla el primer registro encontrado"
FETCH FIRST datos INTO relacion.numero_nomina,
relacion.tipo_emp,
relacion.fecha,
relacion.monto_excento,
relacion.porc_15,
relacion.porc_20,
relacion.porc_25,
relacion.monto_ars,
relacion.monto_afp
DISPLAY BY NAME relacion.*
LET numero_msg = 5
CALL msg(numero_msg)
COMMAND "Ultimo"
"Presenta en pantalla el ultimo registro encontrado"
FETCH LAST datos INTO relacion.numero_nomina,
relacion.tipo_emp,
relacion.fecha,
relacion.monto_excento,
relacion.porc_15,
relacion.porc_20,
relacion.porc_25,
relacion.monto_ars,
relacion.monto_afp
DISPLAY BY NAME relacion.*
LET numero_msg = 4
CALL msg(numero_msg)
COMMAND "Escoger"
"<Esc> Actualiza Registro <Ctrl-C> Cancela Operacion"
INPUT BY NAME relacion.* WITHOUT DEFAULTS
AFTER FIELD numero_nomina
IF relacion.numero_nomina IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD numero_nomina
END IF
{
SELECT *
FROM notb00023 a
WHERE a.numero_nomina = relacion.numero_nomina
IF STATUS != NOTFOUND THEN
LET numero_msg = 2
CALL msg(numero_msg)
NEXT FIELD numero_nomina
END IF
IF relacion.tipo_emp = "Q" AND
relacion.numero_nomina <= 24 THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD numero_nomina
END IF
IF relacion.tipo_emp = "S" AND
relacion.numero_nomina <= 52 THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD numero_nomina
END IF
}
AFTER FIELD monto_excento
IF relacion.monto_excento IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD monto_excento
END IF
AFTER FIELD porc_15
IF relacion.porc_15 IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD porc_15
END IF
AFTER FIELD porc_20
IF relacion.porc_20 IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD porc_20
END IF
AFTER FIELD porc_25
IF relacion.porc_25 IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD porc_25
END IF
#### Verifica si el usuario presiono la tecla <Ctrl-C>
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
CLEAR FORM
RETURN
END IF
#DISPLAY "PASO ", relacion.numero_nomina," ",relacion.porc_15
UPDATE notb00023 SET numero_nomina = relacion.numero_nomina,
monto_excento = relacion.monto_excento,
porc_15 = relacion.porc_15,
porc_20 = relacion.porc_20,
porc_25 = relacion.porc_25,
us_mod = SUSER_SNAME(),
fecha_mod = GETDATE(),
monto_ars = relacion.monto_ars,
monto_afp = relacion.monto_afp
WHERE fecha = relacion.fecha
LET numero_msg = 13
CALL msg(numero_msg)
EXIT INPUT
END INPUT
COMMAND KEY ("L") "eLiminar"
UPDATE notb00023 SET status_t = "E",
us_mod = SUSER_SNAME(),
fecha_mod = GETDATE()
WHERE fecha = relacion.fecha
LET numero_msg = 39
CALL msg(numero_msg)
COMMAND "Retornar"
"Retorna al menu anterior"
CLEAR FORM
EXIT MENU
END MENU
END FUNCTION