Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Booking App COM5007
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
austin.blanke
Booking App COM5007
Commits
82801d87
Commit
82801d87
authored
May 29, 2023
by
austin.blanke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Almost Done
parent
916890f0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
6 deletions
+95
-6
DatabaseConnector.java
...om/example/bookingapp_austinblanke/DatabaseConnector.java
+22
-0
MoreInfoActivity.java
...com/example/bookingapp_austinblanke/MoreInfoActivity.java
+11
-6
SingleBookingActivity.java
...xample/bookingapp_austinblanke/SingleBookingActivity.java
+11
-0
singlebooking.xml
app/src/main/res/layout/singlebooking.xml
+51
-0
No files found.
app/src/main/java/com/example/bookingapp_austinblanke/DatabaseConnector.java
View file @
82801d87
...
...
@@ -342,6 +342,28 @@ public class DatabaseConnector extends SQLiteOpenHelper {
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
(){
ArrayList
<
String
>
bookings
=
new
ArrayList
<>();
String
query
=
"SELECT * FROM "
+
TABLE_BOOKINGS
;
...
...
app/src/main/java/com/example/bookingapp_austinblanke/MoreInfoActivity.java
View file @
82801d87
...
...
@@ -115,8 +115,6 @@ public class MoreInfoActivity extends AppCompatActivity {
EditText
Tic1Cnt
=
findViewById
(
R
.
id
.
bookTicket1Cnt
);
EditText
Tic2Cnt
=
findViewById
(
R
.
id
.
bookTicket2Cnt
);
EditText
Tic3Cnt
=
findViewById
(
R
.
id
.
bookTicket3Cnt
);
TIC1
=
Tic1Cnt
.
getText
().
toString
();
TIC2
=
Tic2Cnt
.
getText
().
toString
();
TIC3
=
Tic3Cnt
.
getText
().
toString
();
...
...
@@ -125,10 +123,17 @@ public class MoreInfoActivity extends AppCompatActivity {
if
(
TIC2
==
""
){
TIC2
=
"0"
;}
if
(
TIC3
==
""
){
TIC3
=
"0"
;}
connector
.
addBooking
(
PID
,
Integer
.
parseInt
(
TIC1
),
Integer
.
parseInt
(
TIC2
),
Integer
.
parseInt
(
TIC3
));
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
startActivity
(
intent
);
if
(
Integer
.
parseInt
(
TIC1
)
==
0
&&
Integer
.
parseInt
(
TIC2
)
==
0
&&
Integer
.
parseInt
(
TIC3
)
==
0
){
Toast
.
makeText
(
this
,
"No booking information given"
,
Toast
.
LENGTH_SHORT
).
show
();}
else
{
if
(
Integer
.
parseInt
(
TIC1
)
>
20
||
Integer
.
parseInt
(
TIC2
)
>
20
||
Integer
.
parseInt
(
TIC3
)
>
20
){
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
);
}
}
}
}
app/src/main/java/com/example/bookingapp_austinblanke/SingleBookingActivity.java
View file @
82801d87
...
...
@@ -6,10 +6,14 @@ import android.view.View;
import
androidx.appcompat.app.AppCompatActivity
;
public
class
SingleBookingActivity
extends
AppCompatActivity
{
String
BID
;
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
singlebooking
);
Bundle
loginBundle
=
getIntent
().
getExtras
();
BID
=
loginBundle
.
getString
(
"BID"
);
}
public
void
myBookings
(
View
view
){
...
...
@@ -17,4 +21,11 @@ public class SingleBookingActivity extends AppCompatActivity {
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
);
}
}
app/src/main/res/layout/singlebooking.xml
View file @
82801d87
...
...
@@ -16,4 +16,55 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
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>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment