Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
all working
  • Loading branch information
“craciun2” committed Feb 27, 2018
1 parent 462662e commit b851c308a2c7db441a0b6d6ad13b7a495be37c13
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 113 deletions.
BIN +0 Bytes (100%) MAIN 100644 → 100755
Binary file not shown.
167 Menu.cpp
@@ -13,39 +13,15 @@ using namespace std;
int createTeam(int Player_ID, string teamName)
{

cout << Player_ID<<endl;
cout << "team name ";
cout<< teamName<<endl;

sqlite::sqlite db( "ball.sqlite" );
auto cur = db.get_statement();

// create the team in MyTeam table
//try
//{
//

cur->set_sql( "INSERT INTO MyTeam (Player_ID, TeamName) VALUES (?,?);" );

cur->set_sql( "INSERT INTO MyTeam (Player_ID, TeamName) VALUES (?,?);" );
cur->prepare();
cur->bind( 1, Player_ID );
cur->bind( 2, teamName );
int insertt =cur->step();
if(insertt=true)
{
cout<<"insert true, "<<endl;
}


//}
//catch( sqlite::exception e )
//{
//cerr << e.what() << endl;
//return 1;
//} // end if registatin fails i dk


return 0;

cur->step();
return 0;
}

// First menu, this will be showed when u start
@@ -85,13 +61,10 @@ char menuu()
cout << "Checking Data..." << endl ;

// cheking on the data base

sqlite::sqlite db( "ball.sqlite" );
auto cur = db.get_statement();

try
{

try
{
sqlite::sqlite db( "ball.sqlite" );
auto cur = db.get_statement();
cur->set_sql( "SELECT Player_ID FROM Player "
"WHERE UserName = ? AND Password = ?;" );
cur->prepare();
@@ -143,99 +116,73 @@ char menuu()
cout << ""<< endl;

//check if already with same user name
try
{
sqlite::sqlite db( "ball.sqlite" );
auto cur = db.get_statement();

try
{

cur->set_sql( "SELECT * FROM Player "
"WHERE UserName = ? OR Email = ?;" );
cur->prepare();

cur->bind( 1, username );
cur->bind( 2, email );
int result= cur->step();
if (result == true){

int result= cur->step();
if (result == true)
{
cout<<"The username or email are already in use!"<<endl;
goto regist;
}
else{

//registin part

// sqlite::sqlite db( "ball.sqlite" );
cur = db.get_statement();

try
{
cur->set_sql( "INSERT INTO Player (UserName, Email,Password) "
}//end of if case
else
{
//registin part
cur = db.get_statement();
cur->set_sql( "INSERT INTO Player (UserName, Email,Password) "
"VALUES (?, ?,?);" );
cur->prepare();

cur->bind( 1, username );
cur->bind( 2, email );
cur->bind( 3, password );
cur->step();
cout<<"Registed Sucessful"<<endl;
cout<<endl<<endl;


}
catch( sqlite::exception e )
{
cerr << e.what() << endl;
return 1;
} // if registatin fails
cur->prepare();
cur->bind( 1, username );
cur->bind( 2, email );
cur->bind( 3, password );
cur->step();
cout<<"Registed Sucessful"<<endl;
cout<<endl<<endl;

// // to get the playerID (unique identification on DB)
cur = db.get_statement();
cur->set_sql( "SELECT Player_ID FROM Player "
"WHERE UserName = ? AND Password = ?;" );
cur->prepare();
cur->bind( 1, username );
cur->bind( 2, password );
int result= cur->step();
int Player_ID = cur->get_int(0);
//sqlite::sqlite3_close(db);
cout<<teamName<<endl;
cout<<Player_ID<<endl;
cur = NULL;
createTeam(Player_ID,teamName); // caling to create a team
// end of getting the ID

// // to get the playerID (unique identification on DB)


// sqlite::sqlite db( "ball.sqlite" );
cur = db.get_statement();

try
{
cur->set_sql( "SELECT Player_ID FROM Player "
"WHERE UserName = ? AND Password = ?;" );
cur->prepare();

cur->bind( 1, username );
cur->bind( 2, password );
int result= cur->step();
int Player_ID = cur->get_int(0);
//sqlite::sqlite3_close(db);
cout<<teamName<<endl;
cout<<Player_ID<<endl;

cur = NULL;
createTeam(Player_ID,teamName); // caling to create a team

}
catch( sqlite::exception e )
{
cerr << e.what() << endl;
return 1;
}// end of getting the ID

}


}
catch( sqlite::exception e )
{
cerr << e.what() << endl;
return 1;
} // if checking if the user already exists fails



goto MainMenu;
}//end of else
}// end of try block


catch( sqlite::exception e )
{
cerr << e.what() << endl;
return 1;
} // if registatin fails


// if checking if the user already exists fails

break;
}

case '3':
cout << "Group E7"<< endl;
cout << "Gheorghe Craciun"<< endl;
break;
case '4':
cout << "End of Program."<< endl;
@@ -14,14 +14,14 @@ Mysql password root user password is 'codio'
git config --global user.name "craciun2"


git status endl
git status

git add . endl
git add .

git commit -m "Messagem"


git push origin master endl
git push origin master

git checkout - to check if its up to date

BIN +0 Bytes (100%) ball.sqlite
Binary file not shown.

0 comments on commit b851c30

Please sign in to comment.