Commit 916890f0 authored by austin.blanke's avatar austin.blanke

Booking List Working

parent 90fff506
......@@ -52,6 +52,14 @@
android:name=".MyBookingsActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".SingleBookingActivity"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
......
......@@ -6,10 +6,6 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.Nullable;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Random;
......@@ -49,7 +45,7 @@ public class DatabaseConnector extends SQLiteOpenHelper {
private static final String COLUMN_TIC1CNT = "ticket1count";
private static final String COLUMN_TIC2CNT = "ticket2count";
private static final String COLUMN_TIC3CNT = "ticket3count";
private static final String COLUMN_BOOKINGTITLE = "booking title";
private static final String COLUMN_BT = "bt";
public DatabaseConnector(Context context, SQLiteDatabase.CursorFactory factory) {
......@@ -92,7 +88,7 @@ public class DatabaseConnector extends SQLiteOpenHelper {
COLUMN_TIC1CNT + " INT, " +
COLUMN_TIC2CNT + " INT, " +
COLUMN_TIC3CNT + " INT, " +
COLUMN_BOOKINGTITLE + "TEXT)";
COLUMN_BT + " TEXT)";
db.execSQL(CREATE_table3);
ContentValues play1 = new ContentValues();
......@@ -218,7 +214,7 @@ public class DatabaseConnector extends SQLiteOpenHelper {
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
cursor.moveToFirst();
String title = cursor.getString(1);
String title = "\'" + cursor.getString(1) + "\'";
CurrentPTicCount1 = cursor.getString(10);
CurrentPTicCount2 = cursor.getString(13);
CurrentPTicCount3 = cursor.getString(16);
......@@ -248,9 +244,9 @@ public class DatabaseConnector extends SQLiteOpenHelper {
values.put(COLUMN_BID, BID);
values.put(COLUMN_PID, PID);
values.put(COLUMN_TIC1CNT, TIC1CNT);
values.put(COLUMN_TIC1CNT, TIC2CNT);
values.put(COLUMN_TIC1CNT, TIC3CNT);
values.put(COLUMN_BOOKINGTITLE, title);
values.put(COLUMN_TIC2CNT, TIC2CNT);
values.put(COLUMN_TIC3CNT, TIC3CNT);
values.put(COLUMN_BT, title);
db.insert(TABLE_BOOKINGS, null, values);
db.close();
}
......@@ -348,14 +344,12 @@ public class DatabaseConnector extends SQLiteOpenHelper {
public ArrayList bookings(){
ArrayList<String> bookings = new ArrayList<>();
String booking = null;
String query = "SELECT * FROM " + TABLE_BOOKINGS;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
cursor.moveToFirst();
for(int i=0;i< cursor.getCount();i++){
bookings.add(cursor.getString(1) + "id: " + cursor.getString(0));
cursor.moveToNext();
bookings.add(cursor.getString(5) + "id: " + cursor.getString(0));
cursor.moveToNext();
}
return bookings;
......
package com.example.bookingapp_austinblanke;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.app.assist.AssistStructure;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class MyBookingsActivity extends AppCompatActivity {
......@@ -27,6 +37,26 @@ public class MyBookingsActivity extends AppCompatActivity {
recyclerObj.setLayoutManager(new LinearLayoutManager(this));
adapterObj = new adapter2(this, bookingList);
recyclerObj.setAdapter(adapterObj);
}
public void performanceBack(View view){
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
public void toBooking(View view){toBooking();}
private void toBooking(){
EditText BID = findViewById(R.id.bookingID);
Intent intent = new Intent(this, SingleBookingActivity.class);
Bundle bundle = new Bundle();
bundle.putString("BID", BID.getText().toString());
intent.putExtras(bundle);
startActivity(intent);
}
}
......
package com.example.bookingapp_austinblanke;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
public class SingleBookingActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.singlebooking);
}
public void myBookings(View view){
Intent intent = new Intent(this, MyBookingsActivity.class);
startActivity(intent);
}
}
......@@ -24,6 +24,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Look at Booking"
android:onClick="toBooking"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.995"
......@@ -33,8 +34,8 @@
<EditText
android:id="@+id/bookingID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="213dp"
android:layout_height="72dp"
android:ems="10"
android:hint="Booking ID"
android:inputType="textPersonName"
......@@ -50,6 +51,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Performances"
android:onClick="performanceBack"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/myBookings"
android:layout_width="229dp"
android:layout_height="54dp"
android:onClick="myBookings"
android:text="My Bookings"
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.134" />
</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