Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Uni_TimeTable/header.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
149 lines (92 sloc)
2.6 KB
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
#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; | |
} | |
} |