Commit 82801d87 authored by austin.blanke's avatar austin.blanke

Almost Done

parent 916890f0
...@@ -342,6 +342,28 @@ public class DatabaseConnector extends SQLiteOpenHelper { ...@@ -342,6 +342,28 @@ public class DatabaseConnector extends SQLiteOpenHelper {
return result; return result;
} }
public int overBook(String PID, int Cnt){
int result = 0;
String query = "SELECT * FROM " + TABLE_PERFORMANCES + " WHERE " + COLUMN_PERFORMANCEID + " = \"" + PID + "\"";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
cursor.moveToFirst();
if(Cnt == 1){result = Integer.parseInt(cursor.getString(10));}
if(Cnt == 2){result = Integer.parseInt(cursor.getString(13));}
if(Cnt == 3){result = Integer.parseInt(cursor.getString(16));}
cursor.close();
db.close();
return result;
}
public void deleteBooking(int BID){
String query = "SELECT * FROM " + TABLE_BOOKINGS;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
db.delete(TABLE_BOOKINGS, COLUMN_BID + "=" + BID, null);
cursor.close();
db.close();
}
public ArrayList bookings(){ public ArrayList bookings(){
ArrayList<String> bookings = new ArrayList<>(); ArrayList<String> bookings = new ArrayList<>();
String query = "SELECT * FROM " + TABLE_BOOKINGS; String query = "SELECT * FROM " + TABLE_BOOKINGS;
......
...@@ -115,8 +115,6 @@ public class MoreInfoActivity extends AppCompatActivity { ...@@ -115,8 +115,6 @@ public class MoreInfoActivity extends AppCompatActivity {
EditText Tic1Cnt = findViewById(R.id.bookTicket1Cnt); EditText Tic1Cnt = findViewById(R.id.bookTicket1Cnt);
EditText Tic2Cnt = findViewById(R.id.bookTicket2Cnt); EditText Tic2Cnt = findViewById(R.id.bookTicket2Cnt);
EditText Tic3Cnt = findViewById(R.id.bookTicket3Cnt); EditText Tic3Cnt = findViewById(R.id.bookTicket3Cnt);
TIC1 = Tic1Cnt.getText().toString(); TIC1 = Tic1Cnt.getText().toString();
TIC2 = Tic2Cnt.getText().toString(); TIC2 = Tic2Cnt.getText().toString();
TIC3 = Tic3Cnt.getText().toString(); TIC3 = Tic3Cnt.getText().toString();
...@@ -125,10 +123,17 @@ public class MoreInfoActivity extends AppCompatActivity { ...@@ -125,10 +123,17 @@ public class MoreInfoActivity extends AppCompatActivity {
if(TIC2 == ""){TIC2="0";} if(TIC2 == ""){TIC2="0";}
if(TIC3 == ""){TIC3="0";} if(TIC3 == ""){TIC3="0";}
if (Integer.parseInt(TIC1) == 0 && Integer.parseInt(TIC2) == 0 && Integer.parseInt(TIC3) == 0){Toast.makeText(this, "No booking information given", Toast.LENGTH_SHORT).show();}
connector.addBooking(PID, Integer.parseInt(TIC1), Integer.parseInt(TIC2), Integer.parseInt(TIC3)); else{
Intent intent = new Intent(this, MainActivity.class); if(Integer.parseInt(TIC1) > 20 || Integer.parseInt(TIC2) > 20 || Integer.parseInt(TIC3) > 20){
startActivity(intent); Toast.makeText(this, "Not enough tickets available", Toast.LENGTH_SHORT).show();
}
else{
connector.addBooking(PID, Integer.parseInt(TIC1), Integer.parseInt(TIC2), Integer.parseInt(TIC3));
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
}
} }
} }
...@@ -6,10 +6,14 @@ import android.view.View; ...@@ -6,10 +6,14 @@ import android.view.View;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
public class SingleBookingActivity extends AppCompatActivity { public class SingleBookingActivity extends AppCompatActivity {
String BID;
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();
BID = loginBundle.getString("BID");
} }
public void myBookings(View view){ public void myBookings(View view){
...@@ -17,4 +21,11 @@ public class SingleBookingActivity extends AppCompatActivity { ...@@ -17,4 +21,11 @@ public class SingleBookingActivity extends AppCompatActivity {
startActivity(intent); startActivity(intent);
} }
public void deleteBooking(View view){
DatabaseConnector connector = new DatabaseConnector(this, null);
connector.deleteBooking(Integer.valueOf(BID));
Intent intent = new Intent(this, MyBookingsActivity.class);
startActivity(intent);
}
} }
...@@ -16,4 +16,55 @@ ...@@ -16,4 +16,55 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.134" /> app:layout_constraintVertical_bias="0.134" />
<Button
android:id="@+id/deleteBooking"
android:layout_width="205dp"
android:layout_height="49dp"
android:onClick="deleteBooking"
android:text="Delete Booking"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.787" />
<TextView
android:id="@+id/BTitle"
android:layout_width="290dp"
android:layout_height="92dp"
android:text="TextView"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.267" />
<TextView
android:id="@+id/time"
android:layout_width="107dp"
android:layout_height="39dp"
android:text="TextView"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.799"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.417" />
<TextView
android:id="@+id/date"
android:layout_width="190dp"
android:layout_height="55dp"
android:text="TextView"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.18"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.181" />
</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