Commit ce152119 authored by austin.blanke's avatar austin.blanke

Almost Done3

parent b1b58be6
...@@ -310,7 +310,17 @@ public class DatabaseConnector extends SQLiteOpenHelper { ...@@ -310,7 +310,17 @@ public class DatabaseConnector extends SQLiteOpenHelper {
} }
public String getBookingInfo(String BID, int column) {
String result;
String query = "SELECT * FROM " + TABLE_BOOKINGS + " WHERE " + COLUMN_BID + " = \"" + BID + "\"";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
cursor.moveToFirst();
result = cursor.getString(column).toString();
cursor.close();
db.close();
return result;
}
public String getInfo(String PID, int column) { public String getInfo(String PID, int column) {
String result; String result;
String query = "SELECT * FROM " + TABLE_PERFORMANCES + " WHERE " + COLUMN_PERFORMANCEID + " = \"" + PID + "\""; String query = "SELECT * FROM " + TABLE_PERFORMANCES + " WHERE " + COLUMN_PERFORMANCEID + " = \"" + PID + "\"";
...@@ -357,11 +367,40 @@ public class DatabaseConnector extends SQLiteOpenHelper { ...@@ -357,11 +367,40 @@ public class DatabaseConnector extends SQLiteOpenHelper {
} }
public void deleteBooking(int BID){ public void deleteBooking(int BID){
String query = "SELECT * FROM " + TABLE_BOOKINGS;
String PID = null;
String newTicketCount1 = null;
String newTicketCount2 = null;
String newTicketCount3= null;
String query = "SELECT * FROM " + TABLE_BOOKINGS + " WHERE " + COLUMN_BID + " = \"" + BID + "\"";
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null); Cursor cursor = db.rawQuery(query, null);
db.delete(TABLE_BOOKINGS, COLUMN_BID + "=" + BID, null); PID = cursor.getString(1);
String query2 = "SELECT * FROM " + TABLE_PERFORMANCES + " WHERE " + COLUMN_PERFORMANCEID + " = \"" + PID + "\"";
Cursor cursor2 = db.rawQuery(query2, null);
newTicketCount1 = (Integer.valueOf(cursor2.getString(10)) + Integer.valueOf(cursor.getString(2)).toString());
newTicketCount2 = (Integer.valueOf(cursor2.getString(13)) + Integer.valueOf(cursor.getString(3)).toString());
newTicketCount3 = (Integer.valueOf(cursor2.getString(16)) + Integer.valueOf(cursor.getString(4)).toString());
cursor.close(); cursor.close();
cursor2.close();
ContentValues values2 = new ContentValues();
values2.put(COLUMN_TICKET1CNT, newTicketCount1);
values2.put(COLUMN_TICKET2CNT, newTicketCount2);
values2.put(COLUMN_TICKET3CNT, newTicketCount3);
String whereClause = COLUMN_PERFORMANCEID + " = " + "\"" + PID + "\"";
db.update(TABLE_PERFORMANCES, values2, whereClause, null);
String queryDelete = "SELECT * FROM " + TABLE_BOOKINGS;
Cursor cursor3 = db.rawQuery(queryDelete, null);
db.delete(TABLE_BOOKINGS, COLUMN_BID + "=" + BID, null);
cursor3.close();
db.close(); db.close();
} }
public ArrayList bookings(){ public ArrayList bookings(){
......
...@@ -3,6 +3,9 @@ package com.example.bookingapp_austinblanke; ...@@ -3,6 +3,9 @@ package com.example.bookingapp_austinblanke;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
...@@ -12,8 +15,86 @@ public class SingleBookingActivity extends AppCompatActivity { ...@@ -12,8 +15,86 @@ public class SingleBookingActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.singlebooking); setContentView(R.layout.singlebooking);
Bundle loginBundle = getIntent().getExtras(); Bundle loginBundle = getIntent().getExtras();
BID = loginBundle.getString("BID"); BID = loginBundle.getString("BID");
String PID = null;
String Title = null;
String Date = null;
String Time = null;
String Location = null;
String Flash = null;
String Wheelchair = null;
String Stairs = null;
String Flashdis = null;
String Wheelchairdis = null;
String Stairsdis = null;
String Tickets1Type = null;
String Tickets2Type = null;
String Tickets3Type = null;
String Tickets1 = null;
String Tickets2 = null;
String Tickets3 = null;
String Tickets1Price = null;
String Tickets2Price = null;
String Tickets3Price = null;
DatabaseConnector connector = new DatabaseConnector(this, null);
PID = connector.getBookingInfo(BID, 1);
Title = connector.getInfo(PID, 1);
Date = connector.getInfo(PID, 2);
Time = connector.getInfo(PID, 3);
Location = connector.getInfo(PID, 4);
Flash = connector.getInfo(PID, 5);
Wheelchair = connector.getInfo(PID, 6);
Stairs = connector.getInfo(PID, 7);
if(Flash == "true"){Flashdis = "There are Flashing Lights";}
else{Flashdis = "There are no flashing lights";}
if(Wheelchair == "true"){Wheelchairdis = "There is wheelchair access";}
else{Wheelchairdis = "There is no wheelchair access";}
if(Stairs == "true"){Stairsdis = "There are less than 20 steps";}
else{Stairsdis = "There are more than 20 steps";}
TextView title = (TextView) findViewById(R.id.BTitle);
title.setText(Title);
TextView date = (TextView) findViewById(R.id.date);
date.setText(Date);
TextView time = (TextView) findViewById(R.id.time);
time.setText(Time);
TextView location = (TextView) findViewById(R.id.location);
location.setText(Location);
TextView flash = (TextView) findViewById(R.id.flash);
flash.setText(Flashdis);
TextView wheel = (TextView) findViewById(R.id.wheelchair);
wheel.setText(Wheelchairdis);
TextView stairs = (TextView) findViewById(R.id.stairs);
stairs.setText(Stairsdis);
Tickets1 = connector.getBookingInfo(BID, 2);
Tickets2 = connector.getBookingInfo(BID, 3);
Tickets3 = connector.getBookingInfo(BID, 4);
Tickets1Price = connector.getTicketPrice(PID, 1);
Tickets2Price = connector.getTicketPrice(PID, 2);
Tickets3Price = connector.getTicketPrice(PID, 3);
Tickets1Type = connector.getTicketType(PID, 1);
Tickets2Type = connector.getTicketType(PID, 2);
Tickets3Type = connector.getTicketType(PID, 3);
TextView ticket1 = (TextView) findViewById(R.id.tickets1);
TextView ticket2 = (TextView) findViewById(R.id.tickets2);
TextView ticket3 = (TextView) findViewById(R.id.tickets3);
if(Tickets1 != null){ticket1.setText(Tickets1Type + ": " + Tickets1 + " (£" + Tickets1Price + ")");}
else{ticket1.setText("");}
if(Tickets2 != null){ticket2.setText(Tickets2Type + ": " + Tickets2 + " (£" + Tickets2Price + ")");}
else{ticket2.setText("");}
if(Tickets3 != null){ticket3.setText(Tickets3Type + ": " + Tickets3 + " (£" + Tickets3Price + ")");}
else{ticket3.setText("");}
} }
public void myBookings(View view){ public void myBookings(View view){
......
...@@ -146,5 +146,17 @@ ...@@ -146,5 +146,17 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.699" /> app:layout_constraintVertical_bias="0.699" />
<TextView
android:id="@+id/location"
android:layout_width="166dp"
android:layout_height="44dp"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.124"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.476" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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