import GUI
%-----
var window : int := Window.Open ("position: middle;middle, title: Marks Manager Deluxe")
var ans : int
var pic : int
var key : string (1)
var NewUserButton, SortButton, DisplayButton, EditButton, SearchButton, ExitButton : int
var font1, font2, font3, font4 : int
var ser, review : string
var names : flexible array 1 .. 0 of string
%------------Declaring the fonts
font1 := Font.New ("Times New Roman:16")
font2 := Font.New ("comic sans ms:12")
font3 := Font.New ("times new roman:12")
font4 := Font.New ("Comic Sans ms:16")
%---Setting the records--------
type name :
record
first_name : string
last_name : string
age : string
male_female : string (1)
mark1 : string
mark2 : string
mark3 : string
mark4 : string
mark5 : string
markavg : string
end record
%---Opening screen--------------------------------
setscreen ("graphics:600;550")
pic := Pic.FileNew ("h:/introscreen.jpg")
Pic.Draw (pic, 1, 1, picCopy)
Font.Draw ("Press any key to continue", 200, 105, font2, black)
getch (key)
cls
%---Registering And login screen---------------------------
var num : int
var count : int := 1
setscreen ("graphics:685;550")
var file : int
open : file, "markssummative.txt", get
setscreen ("graphics:500;380")
pic := Pic.FileNew ("h:/choice.jpg")
Pic.Draw (pic, 1, 1, picCopy)
get : file, num
var clas : array 1 .. 35 of name
loop
get : file, clas (count).first_name
get : file, clas (count).last_name
get : file, clas (count).age
get : file, clas (count).male_female
get : file, clas (count).mark1
get : file, clas (count).mark2
get : file, clas (count).mark3
get : file, clas (count).mark4
get : file, clas (count).mark5
exit when count = num
count := count + 1
end loop
close : file
%-------
proc EnterNewUser (id : int)
var window1 : int := Window.Open ("position: middle;middle, title: Enter new user")
setscreen ("graphics:685;550")
pic := Pic.FileNew ("h:/markspage.jpg")
Pic.Draw (pic, 1, 1, picCopy)
drawfillbox (168, 95, 342, 120, white)
Font.Draw ("Average:", 9, 105, font1, black)
locate (9, 25)
get clas (id).first_name : *
locate (11, 25)
get clas (id).last_name : *
locate (13, 25)
get clas (id).age : *
locate (15, 25)
get clas (id).male_female : *
locate (17, 25)
get clas (id).mark1 : *
locate (19, 25)
get clas (id).mark2 : *
locate (21, 25)
get clas (id).mark3 : *
locate (24, 25)
get clas (id).mark4 : *
locate (26, 25)
get clas (id).mark5 : *
locate (28, 25)
% clas (id).markavg := (clas (id).mark1 + clas (id).mark2 + clas (id).mark3 + clas (id).mark4 + clas (id).mark5) / 5
% Font.Draw (clas (id).markavg, 100, 255, font3, black)
GUI.Quit
Window.Close (window1)
end EnterNewUser
proc NewUser
num := num + 1
EnterNewUser (num)
end NewUser
proc swap (var list : array 1 .. * of string, z, x : int)
const temp := list (z)
list (z) := list (x)
list (x) := temp
end swap
proc bubsort (var list : array 1 .. * of string)
for x : 1 .. upper (list) - 1
const last := upper (list) - x + 1
for q : 1 .. last - 1
if list (q) > list (q + 1) then
swap (list, q, q + 1)
end if
end for
end for
end bubsort
proc sorting
count := 0
new names, 0 % purge names
loop
exit when count = num
count += 1
new names, count
names (count) := clas (count).last_name + ", " + clas (count).first_name + ", " + clas (count).male_female + ", " + clas (count).age
end loop
bubsort (names)
drawfillbox (127, 0, 1000, 1000, black)
colourback (black)
colour (white)
Font.Draw (" Names are sorted by last name.", 110, 350, font3, white)
Font.Draw (" (Last name, first name, sex, age)", 110, 330, font3, white)
for a : 1 .. upper (names)
locate (7 + a, 18)
put names (a)
end for
Font.Draw ("Select a option from the list", 150, 15, font2, white)
end sorting
proc displaying
var window2 : int := Window.Open ("position: middle;middle, title: Enter new user")
var number : int := 1
var row : int := 3
setscreen ("graphics:600;400")
drawfillbox (0, 370, 1000, 400, green)
drawfillbox (0, 370, 1000, 100, blue)
colourback (blue)
colour (white)
Font.Draw ("Press any key to continue", 185, 25, font2, red)
Font.Draw ("Name Age Sex Mark1 Mark2 Mark3 Mark4 Mark5 Average ", 5, 380, font3, black)
for c : 1 .. num
locate (row, 1)
put number, " ", clas (c).first_name, " ", clas (c).last_name ..
locate (row, 20)
put " ", clas (c).age : 6, clas (c).male_female : 6, clas (c).mark1 : 6, clas (c).mark2 : 7, clas (c).mark3 : 7, clas (c).mark4 : 7, clas (c).mark5 : 4
if c > 0 then
row += 1
end if
if c > 0 then
number += 1
end if
end for
getch (key)
Window.Close (window2)
end displaying
proc editing
displaying
drawfillbox (127, 0, 1000, 1000, black)
Font.Draw ("Which number would you like to edit?", 132, 190, font4, white)
Font.Draw ("Enter 0 for not editing anybody", 142, 160, font4, white)
locate (16, 33)
get ans
if ans = 0 then
Font.Draw ("Select a option from the list", 150, 75, font2, white)
else
EnterNewUser (ans)
end if
end editing
proc searching
var window3 : int := Window.Open ("position: middle;middle, title: Enter new user")
setscreen ("graphics:600;400")
pic := Pic.FileNew ("h:/qwerty.jpg")
Pic.Draw (pic, 1, 1, picCopy)
Font.Draw ("Enter the Last name you are searching for:", 5, 305, font4, blue)
Font.Draw ("(case sensative)", 115, 290, font2, blue)
locate (6, 55)
get ser
colourback (14)
colour (2)
drawfillbox (0, 100, 1000, 270, 14)
for g : 1 .. num
if ser = clas (g).last_name then
locate (10, 1)
put "Last name: ", clas (g).last_name
put "First name: ", clas (g).first_name
put "Sex: ", clas (g).male_female
put "Mark1: ", clas (g).mark1
put "Mark2: ", clas (g).mark2
put "Mark3: ", clas (g).mark3
put "Mark4: ", clas (g).mark4
put "Mark5: ", clas (g).mark5
end if
end for
Font.Draw ("Press any key to continue", 130, 10, font3, black)
Font.Draw ("If nothing shows up, no data entry was found", 100, 30, font3, black)
getch (key)
Window.Close (window3)
end searching
proc exiting
setscreen ("graphics:600;500")
pic := Pic.FileNew ("h:/closing.jpg")
Pic.Draw (pic, 1, 1, picCopy)
getch (key)
Window.Close (window)
end exiting
setscreen ("graphics:500;380")
pic := Pic.FileNew ("h:/choice.jpg")
Pic.Draw (pic, 1, 1, picCopy)
NewUserButton := GUI.CreateButton (10, 260, 20, "Enter New User", NewUser)
SortButton := GUI.CreateButton (10, 220, 20, "Sort Data", sorting)
DisplayButton := GUI.CreateButton (10, 180, 20, "Display Data", displaying)
EditButton := GUI.CreateButton (10, 140, 20, "Edit a User", editing)
SearchButton := GUI.CreateButton (10, 100, 20, "Search", searching)
ExitButton := GUI.CreateButton (10, 30, 20, "Exit", exiting)
loop
exit when GUI.ProcessEvent
end loop
open : file, "markssummative.txt", put
put : file, num
for c : 1 .. num
put : file, clas (c).first_name
put : file, clas (c).last_name
put : file, clas (c).age
put : file, clas (c).male_female
put : file, clas (c).mark1
put : file, clas (c).mark2
put : file, clas (c).mark3
put : file, clas (c).mark4
put : file, clas (c).mark5
end for
close : file
getch (key)
Window.Close (window)
|