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

final push, all items working

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