DATABASE ..

 

GLOBALS

DEFINE p_soft RECORD LIKE soft.*,

najdene SMALLINT

END GLOBALS

 

MAIN

OPEN FORM ..

DISPLAY FORM

LET najdene = FALSE

OPTIONS MESSAGE LINE 22,

PROMPT LINE 21,

# HELP KEY F1,

HELP FILE "pomoc.ex"

 

CALL ponuka()

MESSAGE "Koniec programu"

SLEEP 3

CLEAR SCREEN

 

END MAIN

 

FUNCTION ponuka()

DEFINE odp CHAR(1)

 

MESSAGE "Vyber volby - stlac velke pismeno vo volbe",

# "F1 klavesa pre Help"

", CTRL-W vyvolanie HELP-u"

 

MENU "Ponuka"

 

COMMAND "Pridaj" "Pridanie do tab. soft" HELP 1

LET odp = "a"

WHILE

CALL pridaj()

PROMPT "Chces pridat dalsi",

" riadok (a/n) ? "

FOR CHAR odp

END WHILE

 

COMMAND "Hladaj" "Hladanie zaznamov" HELP 2

CALL hladaj()

IF najdene THEN

NEXT OPTION "zMena"

END IF

COMMAND KEY ("M") "zMena" "Zmena udajov v tab. soft" HELP 3

IF najdene THEN

CALL zmena()

ELSE

MESSAGE "Ziadny zaznam vybraty",

"Pouzi volbu Hladaj pre",

"vyber zaznamu"

NEXT OPTION "Hladaj"

END IF

 

COMMAND "Zmaz" "Zmazanie zaznamu" HELP 4

IF najdene THEN

PROMPT "Chces mazat, si si isty (a/n)?"

FOR CHAR odp

IF odp = "a" THEN

CALL zmaz()

LET najdene = FALSE

END IF

 

ELSE

MESSAGE "Ziadny zaznam vybraty",

"pouzi volbu Hladaj",

"pre vyber zaznamu"

NEXT OPTION "Hladaj"

END IF

 

COMMAND "Koniec" "Koniec" HELP 5

EXIT MENU

 

END MENU

END FUNCTION

 

FUNCTION hladaj()

 

DEFINE kod INT

 

MESSAGE ""

CLEAR FORM

PROMPT "Zadaj kod dodavatela: " FOR kod

MESSAGE "Hladam vsetky zaznamy tabulky soft pre dany kod ",kod

SLEEP 3

MESSAGE ""

 

# rolovaci kurzor

 

DECLARE r_kurzor .

SELECT .

LET najdene = FALSE

OPEN .

FETCH FIRST

 

IF status = NOTFOUND THEN

MESSAGE "Zaznam neexistuje"

SLEEP 3

MESSAGE ""

ELSE

LET najdene = TRUE

DISPLAY BY NAME p_soft.*

CALL prezeraj()

END IF

 

CLOSE r_kurzor

 

END FUNCTION

 

FUNCTION prezeraj()

 

MENU "PREZERAJ"

COMMAND "Nasledujuci" "Nasledujuci zaznam"

FETCH

IF

END IF

DISPLAY BY NAME ..

COMMAND KEY ("R") "pRedosly" "Predosly zaznam"

FETCH ..

IF ..

END IF

DISPLAY BY NAME ..

COMMAND "Prvy" "Prvy zaznam"

FETCH

DISPLAY BY NAME

COMMAND KEY ("S") "poSledny" "Posledny zaznam"

FETCH ..

DISPLAY BY NAME .

COMMAND "Koniec" "Koniec prezerania"

EXIT MENU

END MENU

END FUNCTION

 

FUNCTION pridaj()

 

MESSAGE ""

CLEAR FORM

INPUT BY NAME p_soft.*

LET p_soft.por_cislo = 0

INSERT INTO soft VALUES (p_soft.*)

LET p_soft.por_cislo = SQLCA.SQLERRD[2]

DISPLAY p_soft.por_cislo TO por_cislo

MESSAGE "Zaznam pridany"

SLEEP 2

MESSAGE ""

END FUNCTION

 

FUNCTION zmena()

 

INPUT BY NAME p_soft.nazov THRU p_soft.datum

WITHOUT DEFAULTS

 

UPDATE soft

SET soft.* = p_soft.*

WHERE por_cislo = p_soft.por_cislo

MESSAGE "Zaznam zmeneny"

SLEEP 2

MESSAGE ""

 

END FUNCTION

 

FUNCTION zmaz()

 

DELETE FROM soft WHERE por_cislo = p_soft.por_cislo

CLEAR FORM

MESSAGE "Zaznam zmazany"

SLEEP 2

MESSAGE ""

 

END FUNCTION