Commit 6e4c4bf0 authored by a-j.towse's avatar a-j.towse

final push, all items working

parent 5681a163
package com.example.no1theatrecompany; package com.example.no1theatrecompany;
import static androidx.core.content.ContextCompat.startActivity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.telecom.Call; import android.telecom.Call;
...@@ -40,10 +42,7 @@ public class BookingsPageAdapter extends RecyclerView.Adapter<IdleViewHolder2> { ...@@ -40,10 +42,7 @@ public class BookingsPageAdapter extends RecyclerView.Adapter<IdleViewHolder2> {
holder.cancelBookingBtnButton.setOnClickListener(new View.OnClickListener() { holder.cancelBookingBtnButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
context.startActivity(new Intent(view.getContext(),MainActivity.class));
DBConnector connector = new DBConnector(context, null);
System.out.println(mData.get(position).name);
connector.cancelBooking(mData.get(position).name);
} }
}); });
......
...@@ -313,6 +313,8 @@ public class DBConnector extends SQLiteOpenHelper { ...@@ -313,6 +313,8 @@ public class DBConnector extends SQLiteOpenHelper {
db.close(); db.close();
} }
public ArrayList getBookingInfo() { public ArrayList getBookingInfo() {
ArrayList<ArrayList<String>> bookingInfoList = new ArrayList<>(); ArrayList<ArrayList<String>> bookingInfoList = new ArrayList<>();
...@@ -368,14 +370,6 @@ public class DBConnector extends SQLiteOpenHelper { ...@@ -368,14 +370,6 @@ public class DBConnector extends SQLiteOpenHelper {
} }
public void cancelBooking (String playName) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_BOOKINGS, COLUMN_PERFORMANCENAME + "=" + playName, null);
db.close();
}
//Upgrade DB (to satisfy extends f SQLiteOpenHelper) //Upgrade DB (to satisfy extends f SQLiteOpenHelper)
@Override @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
......
...@@ -43,7 +43,8 @@ public class myBookingsActivity extends AppCompatActivity { ...@@ -43,7 +43,8 @@ public class myBookingsActivity extends AppCompatActivity {
tempList.get(2).toString(), tempList.get(0).toString())); tempList.get(2).toString(), tempList.get(0).toString()));
} }
} }
public void cancelBooking (View view) { public void backBtn (View view) {
onBackPressed();
} }
} }
...@@ -149,15 +149,20 @@ public class performanceInfoPage extends AppCompatActivity { ...@@ -149,15 +149,20 @@ public class performanceInfoPage extends AppCompatActivity {
if (ticketNumInt > Integer.parseInt(splitItems[0])) { if (ticketNumInt > Integer.parseInt(splitItems[0])) {
Toast.makeText(this, "Number of selected tickets not available", Toast.makeText(this, "Number of selected tickets not available",
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
break;
}
else if (ticketNumInt == 0){
Toast.makeText(this, "No Tickets Selected",
Toast.LENGTH_SHORT).show();
break;
} }
else else {
splitItems[0] = String.valueOf(Integer.parseInt(splitItems[0]) - ticketNumInt); splitItems[0] = String.valueOf(Integer.parseInt(splitItems[0]) - ticketNumInt);
String unsplitSplit = splitItems[0]+","+splitItems[1]+","+splitItems[2]; String unsplitSplit = splitItems[0] + "," + splitItems[1] + "," + splitItems[2];
for (int x=0;x<currentPerformance.size();x++) { for (int x = 0; x < currentPerformance.size(); x++) {
if (currentPerformance.get(x) == (currentTicket)) { if (currentPerformance.get(x) == (currentTicket)) {
currentPerformance.set(x,unsplitSplit); currentPerformance.set(x, unsplitSplit);
//Connect to DB //Connect to DB
DBConnector connector = new DBConnector(this, null); DBConnector connector = new DBConnector(this, null);
...@@ -166,8 +171,6 @@ public class performanceInfoPage extends AppCompatActivity { ...@@ -166,8 +171,6 @@ public class performanceInfoPage extends AppCompatActivity {
break; break;
} }
} }
}
DBConnector connector = new DBConnector(this, null); DBConnector connector = new DBConnector(this, null);
String bookingID = createBookingID(); String bookingID = createBookingID();
System.out.println(bookingID); System.out.println(bookingID);
...@@ -175,6 +178,9 @@ public class performanceInfoPage extends AppCompatActivity { ...@@ -175,6 +178,9 @@ public class performanceInfoPage extends AppCompatActivity {
Intent intent = new Intent(this, MainActivity.class); Intent intent = new Intent(this, MainActivity.class);
startActivity(intent); startActivity(intent);
} }
}
}
public String createBookingID () { public String createBookingID () {
int upper = 10000; int upper = 10000;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:onClick="backBtn"
android:text="Back" android:text="Back"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
......
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