Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
475 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#include <iostream> | ||
#include <array> | ||
#include <string> | ||
#include "libsqlite.hpp" | ||
|
||
using namespace std; | ||
|
||
void SearchLect(int module_code){ | ||
|
||
try | ||
{ | ||
sqlite::sqlite db( "uni_TimeTable.db" ); //open database | ||
auto curs= db.get_statement(); //create cursor | ||
curs->set_sql( "select lecturers.Name from lecturers,lecturer_module where lecturer_module.lecturer=lecturers.lect_ID and module=(?);" ); | ||
|
||
curs->prepare(); | ||
curs->bind( 1, module_code ); | ||
while( curs->step()){ | ||
|
||
cout <<" "<< curs->get_text(0) << " " <<endl; | ||
|
||
|
||
} | ||
|
||
} | ||
|
||
catch( sqlite::exception e ) | ||
|
||
{ | ||
cerr << e.what() << endl; | ||
|
||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
int NewLecturers(int id, string name, int number){ | ||
try | ||
{ | ||
sqlite::sqlite db( "uni_TimeTable.db" ); //open database | ||
auto curs= db.get_statement();//create cursor | ||
curs->set_sql( "INSERT INTO Lecturers ( Lect_ID, name, number) " | ||
|
||
"VALUES (?, ?, ?);" ); | ||
|
||
curs->prepare(); | ||
curs->bind( 1, id ); | ||
curs->bind( 2, name ); | ||
curs->bind( 3, number ); | ||
curs->step(); | ||
|
||
} | ||
|
||
catch( sqlite::exception e ) | ||
|
||
{ | ||
cerr << e.what() << endl; | ||
return 1; | ||
|
||
} | ||
|
||
} | ||
int NewStudents(int id, string Name, int number){ | ||
try | ||
{ | ||
sqlite::sqlite db( "uni_TimeTable.db" ); //open database | ||
auto curs = db.get_statement();//create cursor | ||
curs->set_sql( "INSERT INTO Students ( ID, name, number) " | ||
|
||
"VALUES (?, ?, ?);" );// insert into DB | ||
|
||
curs->prepare(); | ||
curs->bind( 1, id ); | ||
curs->bind( 2, Name ); | ||
curs->bind( 3,number ); | ||
curs->step(); | ||
|
||
} | ||
|
||
catch( sqlite::exception e ) | ||
|
||
{ | ||
cerr << e.what() << endl; | ||
return 1; | ||
|
||
} | ||
|
||
} | ||
|
||
int displayLecturers(){ | ||
|
||
try | ||
|
||
{ | ||
|
||
sqlite::sqlite db( "uni_TimeTable.db" ); // open database | ||
|
||
auto curs = db.get_statement(); | ||
|
||
curs->set_sql( "SELECT * FROM Lecturers" );// set query | ||
curs->prepare(); | ||
|
||
while( curs->step()){ | ||
|
||
cout <<" "<< curs->get_int(0) << " " << curs->get_text(1) <<endl; | ||
} | ||
|
||
} | ||
|
||
catch( sqlite::exception e ){ | ||
|
||
cerr << e.what() << endl; | ||
|
||
return 1; | ||
|
||
} | ||
|
||
} | ||
int displayStudents(){ | ||
|
||
try | ||
|
||
{ | ||
sqlite::sqlite db( "uni_TimeTable.db" ); // open database | ||
|
||
auto curs = db.get_statement(); | ||
curs->set_sql( "SELECT * FROM Students" );// set query | ||
curs->prepare(); | ||
|
||
while( curs->step()){ | ||
|
||
cout <<" "<< curs->get_int(0) << " " << curs->get_text(1) << " " << curs->get_int(2)<<endl; | ||
|
||
|
||
} | ||
|
||
} | ||
|
||
catch( sqlite::exception e ){ | ||
|
||
cerr << e.what() << endl; | ||
|
||
return 1; | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.