Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
krmaet
/
Lennubroneerimis_tarkvara
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1f6b3af4
authored
May 01, 2023
by
krmaet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update proccessing.c
parent
f35a76a4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
164 additions
and
1 deletions
proccessing.c
proccessing.c
View file @
1f6b3af4
...
...
@@ -6,7 +6,7 @@
#include <time.h>
#include <ncurses.h>
#include "
readdata
.h"
#include "
proccessing
.h"
#include "main.h"
void
NewTicket
(
int
*
row
,
int
*
col
,
char
*
seat
,
int
flightID
,
MYSQL
*
con
,
int
count
)
...
...
@@ -521,3 +521,166 @@ int CheckLetters(char word[STR_MAX])
}
return
1
;
}
int
CheckUser
(
MYSQL
*
con
,
char
*
username
,
char
*
password
)
{
char
query
[
512
];
int
position
;
//Query for password associated with the username
sprintf
(
query
,
"SELECT password, position FROM profiles WHERE username = '%s';"
,
username
);
if
(
mysql_query
(
con
,
query
))
{
//päring serverile
printf
(
"Error getting data: %s
\n
"
,
mysql_error
(
con
));
exit
(
EXIT_FAILURE
);
}
MYSQL_RES
*
result
=
mysql_store_result
(
con
);
mysql_num_fields
(
result
);
char
tempPassword
[
128
]
=
{
" "
};
char
tempPosition
[
128
]
=
{
" "
};
MYSQL_ROW
row
;
while
((
row
=
mysql_fetch_row
(
result
)))
{
strcpy
(
tempPassword
,
row
[
0
]);
strcpy
(
tempPosition
,
row
[
1
]);
}
position
=
atoi
(
tempPosition
);
//Check if passwords match
if
(
!
strcmp
(
tempPassword
,
password
))
{
if
(
position
==
ADMIN
)
{
return
ADMIN
;
}
else
if
(
position
==
ASSISTANT
)
{
return
ASSISTANT
;
}
else
if
(
position
==
CLIENT
)
{
return
CLIENT
;
}
}
return
-
1
;
}
int
CheckBookingDocument
(
MYSQL
*
con
,
char
*
bookingNumber
,
char
*
documentNumber
,
int
*
row
,
int
*
col
)
{
WINDOW
*
menu_win
;
clear
();
refresh
();
char
booking
[
STR_MAX
];
char
document
[
STR_MAX
];
char
buffer
[
BUFFER_MAX
];
menu_win
=
create_newwin
(
WIN_LENGTH
,
WIN_WIDTH
,
1
,
*
col
/
2
-
WIN_WIDTH
/
2
);
//Ask for booking number
mvwprintw
(
menu_win
,
1
,
1
,
"Enter booking number"
);
mvwprintw
(
menu_win
,
2
,
1
,
"--------------------"
);
echo
();
mvwscanw
(
menu_win
,
3
,
1
,
"%s"
,
booking
);
noecho
();
//Ask for document number
mvwprintw
(
menu_win
,
5
,
1
,
"Enter document number"
);
mvwprintw
(
menu_win
,
6
,
1
,
"--------------------"
);
echo
();
mvwscanw
(
menu_win
,
7
,
1
,
"%s"
,
document
);
noecho
();
//Find document number associated with the booking number
sprintf
(
buffer
,
"SELECT documentNum FROM Users WHERE id IN"
"(SELECT user_id FROM Bookings WHERE bookingNumber = '%s');"
,
booking
);
if
(
mysql_query
(
con
,
buffer
))
{
finish_with_error
(
con
);
}
MYSQL_RES
*
result
=
mysql_store_result
(
con
);
MYSQL_ROW
row1
;
row1
=
mysql_fetch_row
(
result
);
//Check if booking number exists
if
(
row1
==
NULL
)
{
mvwprintw
(
menu_win
,
9
,
1
,
"Booking number not found!"
);
mvwprintw
(
menu_win
,
10
,
1
,
"Press any key to continue!"
);
wgetch
(
menu_win
);
return
0
;
}
mysql_free_result
(
result
);
//Check if documentNumbers match
if
(
!
strcasecmp
(
row1
[
0
],
document
))
{
strcpy
(
bookingNumber
,
booking
);
strcpy
(
documentNumber
,
document
);
wrefresh
(
menu_win
);
delwin
(
menu_win
);
return
1
;
}
else
{
mvwprintw
(
menu_win
,
9
,
1
,
"Document number does not match!"
);
mvwprintw
(
menu_win
,
10
,
1
,
"Press any key to continue!"
);
wgetch
(
menu_win
);
wrefresh
(
menu_win
);
delwin
(
menu_win
);
return
0
;
}
}
int
CheckBooking
(
MYSQL
*
con
,
char
*
bookingNumber
,
int
*
row
,
int
*
col
)
{
WINDOW
*
menu_win
;
clear
();
refresh
();
char
temp
[
STR_MAX
];
char
buffer
[
200
];
menu_win
=
create_newwin
(
WIN_LENGTH
,
WIN_WIDTH
,
1
,
*
col
/
2
-
WIN_WIDTH
/
2
);
//Ask for booking number
mvwprintw
(
menu_win
,
1
,
1
,
"Enter booking number"
);
mvwprintw
(
menu_win
,
2
,
1
,
"--------------------"
);
echo
();
mvwscanw
(
menu_win
,
3
,
1
,
"%s"
,
temp
);
noecho
();
sprintf
(
buffer
,
"SELECT id FROM Bookings WHERE bookingNumber = '%s';"
,
temp
);
if
(
mysql_query
(
con
,
buffer
))
{
finish_with_error
(
con
);
}
MYSQL_RES
*
result
=
mysql_store_result
(
con
);
MYSQL_ROW
row1
;
row1
=
mysql_fetch_row
(
result
);
mysql_free_result
(
result
);
//Check if booking number exists
if
(
row1
!=
NULL
)
{
strcpy
(
bookingNumber
,
temp
);
wrefresh
(
menu_win
);
delwin
(
menu_win
);
return
1
;
}
else
{
mvwprintw
(
menu_win
,
5
,
1
,
"Booking number does not exist!"
);
mvwprintw
(
menu_win
,
6
,
1
,
"Press any key to continue!"
);
wgetch
(
menu_win
);
wrefresh
(
menu_win
);
delwin
(
menu_win
);
return
0
;
}
}
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