Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
mvahes
/
Lennubroneerimis_tarkvara
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e0fd525a
authored
Mar 29, 2023
by
krmaet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update main.c
parent
773a1a9e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
45 deletions
main.c
main.c
View file @
e0fd525a
...
...
@@ -19,7 +19,8 @@ int main()
keypad
(
stdscr
,
TRUE
);
refresh
();
int
row
,
col
,
ch
,
option
,
position
;
int
row
,
col
,
ch
,
option
;
int
position
=
2
;
int
menuOption
=
-
1
;
int
seatmap
[
ROWS
][
COLUMNS
]
=
{
0
};
int
ticketCount
=
0
;
...
...
@@ -57,123 +58,163 @@ int main()
//Ask for password
mvwprintw
(
my_win
,
2
,
1
,
"Password:"
);
wscanw
(
my_win
,
"%s"
,
password
);
wrefresh
(
my_win
);
//~ delwin(my_win);
// SIIA LÄHEB SQL KASUTAJA KONTROLL
position
=
CheckUser
(
con
,
username
,
password
);
//~ mvwprintw(my_win, 3, 1, "Wrong username or password!");
//~ if (strcmp(username, "admin") == 0)
if
(
position
==
-
1
)
{
refresh
();
my_win
=
create_newwin
(
5
,
40
,
1
,
col
/
2
-
40
/
2
);
mvwprintw
(
my_win
,
1
,
1
,
"Wrong username or password!"
);
mvwprintw
(
my_win
,
2
,
1
,
"Press any key to start again!"
);
wgetch
(
my_win
);
goto
start
;
}
if
(
position
==
ADMIN
)
{
snprintf
(
buffer
,
STR_MAX
,
"Logged in as admin"
);
while
(
1
)
{
admin_menu:
;
option
=
NONE
;
option
=
optionMenu
(
adminOptions
,
ADMIN_OPTIONS_CNT
,
buffer
,
&
row
,
&
col
);
//Choose the correct option
switch
(
option
)
{
case
FLIGHT_INFO
:
break
;
case
CLIENT_INFO
:
CheckBooking
(
bookingNumber
,
&
row
,
&
col
);
menuOption
=
optionMenu
(
userOptions
,
USER_OPTIONS_CNT
,
buffer
,
&
row
,
&
col
);
if
(
CheckBooking
(
con
,
bookingNumber
,
&
row
,
&
col
))
{
checked:
;
menuOption
=
NONE
;
menuOption
=
optionMenu
(
userOptions
,
USER_OPTIONS_CNT
,
buffer
,
&
row
,
&
col
);
}
break
;
case
EXIT
:
goto
start
;
default:
break
;
}
option
=
NONE
;
}
//Choose the correct option to change user info
switch
(
menuOption
)
{
case
NAME
:
ChangeName
(
bookingNumber
,
&
row
,
&
col
);
ChangeName
(
con
,
bookingNumber
,
&
row
,
&
col
);
goto
checked
;
break
;
case
DOCUMENT
:
ChangeDocument
(
bookingNumber
,
&
row
,
&
col
);
ChangeDocument
(
con
,
bookingNumber
,
&
row
,
&
col
);
goto
checked
;
break
;
case
SEAT
:
goto
checked
;
break
;
case
BAGGAGE
:
ChangeBaggage
(
bookingNumber
,
&
row
,
&
col
);
ChangeBaggage
(
con
,
bookingNumber
,
&
row
,
&
col
);
goto
checked
;
break
;
case
BACK
:
goto
admin_menu
;
break
;
default:
break
;
}
menuOption
=
NONE
;
}
}
}
//~ else if (strcmp(username, "assistant") == 0)
else
if
(
position
==
ASSISTANT
)
{
snprintf
(
buffer
,
STR_MAX
,
"Logged in as assistant"
);
while
(
1
)
{
assistant_menu:
;
menuOption
=
NONE
;
option
=
NONE
;
option
=
optionMenu
(
assistantOptions
,
ASSISTANT_OPTIONS_CNT
,
buffer
,
&
row
,
&
col
);
switch
(
option
)
{
case
USER_INFO
:
CheckBooking
(
bookingNumber
,
&
row
,
&
col
);
menuOption
=
optionMenu
(
userOptions
,
USER_OPTIONS_CNT
,
buffer
,
&
row
,
&
col
);
if
(
CheckBooking
(
con
,
bookingNumber
,
&
row
,
&
col
))
{
checked1:
;
menuOption
=
optionMenu
(
userOptions
,
USER_OPTIONS_CNT
,
buffer
,
&
row
,
&
col
);
}
break
;
case
CHECK_IN
:
CheckIn
(
&
row
,
&
col
);
CheckIn
(
con
,
&
row
,
&
col
);
break
;
case
EXIT
:
goto
start
;
break
;
default:
break
;
goto
assistant_menu
;
}
option
=
NONE
;
switch
(
menuOption
)
{
case
NAME
:
ChangeName
(
bookingNumber
,
&
row
,
&
col
);
ChangeName
(
con
,
bookingNumber
,
&
row
,
&
col
);
goto
checked1
;
break
;
case
DOCUMENT
:
ChangeDocument
(
bookingNumber
,
&
row
,
&
col
);
ChangeDocument
(
con
,
bookingNumber
,
&
row
,
&
col
);
goto
checked1
;
break
;
case
SEAT
:
goto
checked1
;
break
;
case
BAGGAGE
:
ChangeBaggage
(
bookingNumber
,
&
row
,
&
col
);
ChangeBaggage
(
con
,
bookingNumber
,
&
row
,
&
col
);
goto
checked1
;
break
;
case
BACK
:
goto
assistant_menu
;
break
;
default:
goto
assistant_menu
;
break
;
}
menuOption
=
NONE
;
menuOption
=
NONE
;
}
}
//~ wgetch(my_win);
break
;
case
'2'
:
my_win
=
create_newwin
(
6
,
40
,
1
,
col
/
2
-
40
/
2
);
echo
();
wrefresh
(
my_win
);
mvwprintw
(
my_win
,
1
,
1
,
"Enter booking number:"
);
mvwscanw
(
my_win
,
2
,
1
,
"%s"
,
bookingNumber
);
mvwprintw
(
my_win
,
3
,
1
,
"Enter document number:"
);
mvwscanw
(
my_win
,
4
,
1
,
"%s"
,
documentNumber
);
//SIIA LÄHEB SQL KONTROLL
snprintf
(
buffer
,
STR_MAX
,
"Booking number found!"
);
optionMenu
(
userOptions
,
USER_OPTIONS_CNT
,
buffer
,
&
row
,
&
col
);
//Check if booking and document number match
if
(
CheckBookingDocument
(
con
,
bookingNumber
,
documentNumber
,
&
row
,
&
col
))
{
strcpy
(
buffer
,
" "
);
//Empty printed buffer
menuOption
=
NONE
;
//For safety, menuOption to NONE
checked2:
;
//Goto to pass checking booking and document number
//Display menu options
menuOption
=
optionMenu
(
userOptions
,
USER_OPTIONS_CNT
,
buffer
,
&
row
,
&
col
);
}
switch
(
menuOption
)
{
case
NAME
:
ChangeName
(
con
,
bookingNumber
,
&
row
,
&
col
);
goto
checked2
;
break
;
case
DOCUMENT
:
ChangeDocument
(
con
,
bookingNumber
,
&
row
,
&
col
);
goto
checked2
;
break
;
case
SEAT
:
goto
checked2
;
break
;
case
BAGGAGE
:
ChangeBaggage
(
con
,
bookingNumber
,
&
row
,
&
col
);
goto
checked2
;
break
;
case
BACK
:
goto
start
;
break
;
default:
goto
start
;
break
;
}
wgetch
(
my_win
);
break
;
case
'3'
:
...
...
@@ -185,7 +226,8 @@ int main()
goto
start
;
break
;
default:
return
1
;
echo
();
return
1
;
//Exit program if any other key pressed
}
}
echo
();
...
...
@@ -211,7 +253,8 @@ void printIntro(int *row, int *col)
char
action
[]
=
"Choose action:"
;
char
logIn
[]
=
"Press 1 to log in"
;
char
bookingNum
[]
=
"Press 2 to enter booking number"
;
char
newFlight
[]
=
"Press 3 to enter new flight"
;
char
newFlight
[]
=
"Press 3 to book new flight"
;
char
exit
[]
=
"Press any key to exit"
;
getmaxyx
(
stdscr
,
*
row
,
*
col
);
/* get the number of rows and columns */
...
...
@@ -219,7 +262,8 @@ void printIntro(int *row, int *col)
mvprintw
(
*
row
/
7
+
3
,(
*
col
-
strlen
(
action
))
/
2
,
"%s"
,
action
);
mvprintw
(
*
row
/
7
+
4
,(
*
col
-
strlen
(
logIn
))
/
2
,
"%s"
,
logIn
);
mvprintw
(
*
row
/
7
+
5
,(
*
col
-
strlen
(
bookingNum
))
/
2
,
"%s"
,
bookingNum
);
mvprintw
(
*
row
/
7
+
6
,(
*
col
-
strlen
(
newFlight
))
/
2
,
"%s"
,
newFlight
);
mvprintw
(
*
row
/
7
+
6
,(
*
col
-
strlen
(
newFlight
))
/
2
,
"%s"
,
newFlight
);
mvprintw
(
*
row
/
7
+
7
,(
*
col
-
strlen
(
exit
))
/
2
,
"%s"
,
exit
);
}
int
printIntroMenu
(
int
*
row
,
int
*
col
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment