Commit 8919500f authored by sam.pople's avatar sam.pople

tryagain

parent 879ccd6a
......@@ -11,9 +11,9 @@ import java.util.ArrayList;
import java.util.List;
public class Database extends SQLiteOpenHelper {
public static final String databasename = "playsrusdata3.db";
public static final String databasename = "totestthedatabase2.db";
public Database(@Nullable Context cont) {
super(cont, "playsrusdata3.db", null, 1);
super(cont, "totestthedatabase2.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase data) {
......@@ -35,7 +35,8 @@ public class Database extends SQLiteOpenHelper {
cv.put("username", username);
cv.put("password", password);
long conclusion = MyDatabase.insert("user", null, cv);
if (conclusion == -1) {
if (conclusion == -1)
{
return false;
} else
{
......@@ -45,7 +46,8 @@ public class Database extends SQLiteOpenHelper {
public Boolean usercheck(String username){
SQLiteDatabase MyDatabase = this.getWritableDatabase();
Cursor record = MyDatabase.rawQuery("SELECT * FROM user WHERE username = ?", new String[]{username});
if (record.getCount() > 0) {
if (record.getCount() > 0)
{
return true;
} else
{
......@@ -55,7 +57,8 @@ public class Database extends SQLiteOpenHelper {
public Boolean userpass(String username, String password){
SQLiteDatabase MyDatabase = this.getWritableDatabase();
Cursor record = MyDatabase.rawQuery("SELECT * FROM user WHERE username = ? AND password = ?", new String[]{username, password});
if (record.getCount() > 0) {
if (record.getCount() > 0)
{
return true;
} else
{
......@@ -68,7 +71,8 @@ public class Database extends SQLiteOpenHelper {
cv.put("playName", playName);
cv.put("noticket", noticket);
long conclusion = MyDatabase.insert("booking", null, cv);
if (conclusion == -1) {
if (conclusion == -1)
{
return false;
} else
{
......@@ -83,13 +87,7 @@ public class Database extends SQLiteOpenHelper {
long conclusion = data.insert("play", null, cv);
return conclusion != -1;
}
public boolean ticketsupdate(String playName, int newtickets){
SQLiteDatabase data = this.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put("tickets", newtickets);
int rows = data.update("play", cv, "playName=?", new String[]{playName});
return rows > 0;
}
public List<String> currentbookings() {
List<String> findbookings = new ArrayList<>();
SQLiteDatabase data = this.getReadableDatabase();
......@@ -114,6 +112,13 @@ public class Database extends SQLiteOpenHelper {
record.close();
return 0;
}
public boolean ticketsupdate(String playName, int newtickets){
SQLiteDatabase data = this.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put("tickets", newtickets);
int rows = data.update("play", cv, "playName=?", new String[]{playName});
return rows > 0;
}
}
......
......@@ -109,12 +109,6 @@ public class seating extends AppCompatActivity implements AdapterView.OnItemSele
}
private boolean bookingdone(String playName, int noticket) {
boolean storebooking = database.bookinginput(playName, Integer.parseInt(String.valueOf(noticket)));
return storebooking;
}
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment