{ ------------------------------------------------------------------------------- PROGRAMA : COPRMT011 OBJETIVO : Capturar, Modificar, Eliminar registros de la Tabla Puertos PROGRAMADOR : JUAN SOTO FECHA REALIZACION : AGOSTO 1997 DIRECTOR PROYECTO : JOSE ALFREDO PAULINO ALEJO ------------------------------------------------------------------------------- } GLOBALS "coprgb000.4gl" MAIN DEFER INTERRUPT CALL STARTLOG("COPRMT11.TXT") CALL ARG_VAL(1) RETURNING usuarios CALL ARG_VAL(2) RETURNING clave # CONNECT TO "exterior" AS "IFMX" CONNECT to "smarmotech" AS "MSSQL" USER usuarios USING clave SELECT a.* INTO p_companias.* FROM companias a CALL coprmt011() END MAIN FUNCTION coprmt011() OPTIONS FORM LINE 9, ERROR LINE 23, COMMENT LINE 21 OPEN FORM cofmmt011 FROM "cofmmt011" DISPLAY FORM cofmmt011 MENU "OPCIONES" COMMAND "Adicionar" " Adiciona Registro Cancela Operacion" CLEAR FORM CALL copcad011() COMMAND "Consultar-modificar" " Realiza Busqueda Cancela Operacion" CALL copcmf011() COMMAND "Salir" "Retorna Menu Anterior" EXIT MENU END MENU END FUNCTION FUNCTION copcad011() DEFINE ultimo INT #WHENEVER ERROR CONTINUE ## Captura los datos que va a contener el registro INPUT BY NAME puertos.* ## Verifica que el puerto no exista en el catalogo de puertos. Si existe, ## entonces despliega los datos del registro existente. BEFORE INPUT NEXT FIELD nom_pt AFTER FIELD nom_pt IF puertos.nom_pt IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD nom_pt END IF AFTER FIELD cod_pais IF puertos.cod_pais IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_pais ELSE SELECT * INTO paises.* FROM cotb00018 WHERE cod_pais = puertos.cod_pais AND status_t is null IF status >= 0 THEN IF status = NOTFOUND THEN LET numero_msg = 41 CALL msg(numero_msg) NEXT FIELD cod_pais END IF END IF END IF CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF DISPLAY BY NAME paises.nom_pais SELECT * INTO puertos.* FROM cotb00019 WHERE cod_pt = puertos.cod_pt AND cod_pais = puertos.cod_pais IF STATUS != NOTFOUND THEN IF puertos.status_t = "E" THEN LET numero_msg = 36 CALL msg(numero_msg) NEXT FIELD cod_pt END IF DISPLAY BY NAME puertos.* LET numero_msg = 12 CALL msg(numero_msg) NEXT FIELD cod_pt END IF CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF AFTER FIELD ciudad IF puertos.ciudad IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD ciudad END IF AFTER FIELD duracion IF puertos.duracion IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD duracion END IF AFTER INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN END IF IF puertos.ciudad IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD ciudad END IF IF puertos.duracion IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD duracion ELSE SELECT MAX(a.cod_pt) INTO ultimo FROM cotb00019 a IF ultimo IS NULL THEN LET ultimo = 0 END IF LET ultimo = ultimo +1 LET puertos.cod_pt = ultimo INSERT INTO cotb00019 VALUES (puertos.cod_pt,puertos.nom_pt, puertos.cod_pais,puertos.ciudad,puertos.duracion,null, usuarios,getdate(),null,null) DISPLAY BY NAME puertos.cod_pt LET numero_msg = 1 CALL msg(numero_msg) CLEAR FORM INITIALIZE puertos TO NULL NEXT FIELD cod_pt END IF END INPUT END FUNCTION FUNCTION copcmf011() # WHENEVER ERROR CONTINUE ## Aqui se prepara para la captura del criterio de seleccion CONSTRUCT criterio ON cotb00019.* FROM cotb00019.* IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET numero_msg = FALSE RETURN END IF LET SELEC = "SELECT UNIQUE * FROM cotb00019 where ", " status_t is null AND ", criterio clipped, " ORDER BY cod_pt" PREPARE busca FROM selec CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF DECLARE datos SCROLL CURSOR FOR busca OPEN datos CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF FETCH FIRST datos INTO puertos.* IF status >= 0 THEN IF STATUS = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) RETURN END IF END IF CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF SELECT * INTO paises.* FROM cotb00018 WHERE cod_pais = puertos.cod_pais AND status_t is null DISPLAY BY NAME puertos.*,paises.nom_pais MENU "OPCIONES" COMMAND "Siguiente" "Presenta en pantalla el proximo registro encontrado" FETCH NEXT datos INTO puertos.* IF STATUS = NOTFOUND THEN LET numero_msg = 4 CALL msg(numero_msg) END IF SELECT * INTO paises.* FROM cotb00018 WHERE cod_pais = puertos.cod_pais DISPLAY BY NAME puertos.*,paises.nom_pais COMMAND "Anterior" "Presenta en pantalla el registro anterior encontrado" FETCH PREVIOUS datos INTO puertos.* IF STATUS = NOTFOUND THEN LET numero_msg = 5 CALL msg(numero_msg) END IF SELECT * INTO paises.* FROM cotb00018 WHERE cod_pais = puertos.cod_pais DISPLAY BY NAME puertos.*,paises.nom_pais COMMAND "Primero" "Presenta en pantalla el primer registro encontrado" FETCH FIRST datos INTO puertos.* SELECT * INTO paises.* FROM cotb00018 WHERE cod_pais = puertos.cod_pais DISPLAY BY NAME puertos.*,paises.nom_pais LET numero_msg = 5 CALL msg(numero_msg) COMMAND "Ultimo" "Presenta en pantalla el ultimo registro encontrado" FETCH LAST datos INTO puertos.* SELECT * INTO paises.* FROM cotb00018 WHERE cod_pais = puertos.cod_pais DISPLAY BY NAME puertos.*,paises.nom_pais LET numero_msg = 4 CALL msg(numero_msg) COMMAND "Escoger" " Actualiza Registro Cancela Operacion" INPUT BY NAME puertos.nom_pt,puertos.cod_pais,puertos.ciudad, puertos.duracion,puertos.us_crea,puertos.fech_crea, puertos.us_mod,puertos.fech_mod WITHOUT DEFAULTS AFTER FIELD cod_pais IF puertos.cod_pais IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_pais ELSE SELECT * INTO paises.* FROM cotb00018 WHERE cod_pais = puertos.cod_pais AND status_t is null IF status >= 0 THEN IF status = NOTFOUND THEN LET numero_msg = 41 CALL msg(numero_msg) NEXT FIELD cod_pais END IF END IF END IF CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF DISPLAY BY NAME paises.nom_pais AFTER FIELD ciudad IF puertos.ciudad IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD ciudad END IF AFTER FIELD duracion IF puertos.duracion IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD duracion END IF AFTER INPUT ## Verifica si el usuario presiono la tecla IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN END IF UPDATE cotb00019 SET nom_pt = puertos.nom_pt, cod_pais = puertos.cod_pais, ciudad = puertos.ciudad, duracion = puertos.duracion, us_mod = SUSER_SNAME(), fech_mod = getdate() WHERE cod_pt = puertos.cod_pt LET numero_msg = 13 CALL msg(numero_msg) EXIT INPUT END INPUT COMMAND KEY ("L") "eLiminar" UPDATE cotb00019 SET status_t = "E" WHERE cod_pt = puertos.cod_pt AND cod_pais = puertos.cod_pais LET numero_msg = 39 CALL msg(numero_msg) COMMAND "Retornar" "Retorna al menu anterior" CLEAR FORM EXIT MENU END MENU END FUNCTION