Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PlaysRUs
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
sam.pople
PlaysRUs
Commits
092fc9ea
Commit
092fc9ea
authored
Jun 15, 2023
by
sam.pople
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try6
parent
d3f5f464
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
150 additions
and
91 deletions
+150
-91
Database.java
...RUs2/app/src/main/java/com/example/playsrus/Database.java
+19
-20
MainActivity.java
.../app/src/main/java/com/example/playsrus/MainActivity.java
+2
-2
performancetickets.java
...rc/main/java/com/example/playsrus/performancetickets.java
+13
-15
seating.java
...sRUs2/app/src/main/java/com/example/playsrus/seating.java
+56
-21
seating.xml
PlaysRUs2/app/src/main/res/layout/seating.xml
+60
-33
No files found.
PlaysRUs2/app/src/main/java/com/example/playsrus/Database.java
View file @
092fc9ea
...
...
@@ -19,8 +19,8 @@ public class Database extends SQLiteOpenHelper {
@Override
public
void
onCreate
(
SQLiteDatabase
data
)
{
data
.
execSQL
(
"CREATE TABLE IF NOT EXISTS user (username TEXT PRIMARY KEY, password TEXT)"
);
data
.
execSQL
(
"CREATE TABLE IF NOT EXISTS play (play
n
ame TEXT PRIMARY KEY, tickets INTEGER)"
);
data
.
execSQL
(
"CREATE TABLE IF NOT EXISTS booking (bookingid INTEGER PRIMARY KEY AUTOINCREMENT, play
name TEXT, noticket INTEGER, fullname TEXT, seatingtype Text
)"
);
data
.
execSQL
(
"CREATE TABLE IF NOT EXISTS play (play
N
ame TEXT PRIMARY KEY, tickets INTEGER)"
);
data
.
execSQL
(
"CREATE TABLE IF NOT EXISTS booking (bookingid INTEGER PRIMARY KEY AUTOINCREMENT, play
Name TEXT, noticket INTEGER
)"
);
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
data
,
int
i
,
int
i1
)
{
...
...
@@ -37,7 +37,8 @@ public class Database extends SQLiteOpenHelper {
long
conclusion
=
MyDatabase
.
insert
(
"user"
,
null
,
cv
);
if
(
conclusion
==
-
1
)
{
return
false
;
}
else
{
}
else
{
return
true
;
}
}
...
...
@@ -61,13 +62,11 @@ public class Database extends SQLiteOpenHelper {
return
false
;
}
}
public
Boolean
booking
(
String
playName
,
String
fullname
,
int
notickets
,
String
seatingtype
)
{
public
Boolean
booking
input
(
String
playName
,
int
noticket
)
{
SQLiteDatabase
MyDatabase
=
this
.
getWritableDatabase
();
ContentValues
cv
=
new
ContentValues
();
cv
.
put
(
"playname"
,
playName
);
cv
.
put
(
"noticket"
,
notickets
);
cv
.
put
(
"fullname"
,
fullname
);
cv
.
put
(
"seatingtype"
,
seatingtype
);
cv
.
put
(
"playName"
,
playName
);
cv
.
put
(
"noticket"
,
noticket
);
long
conclusion
=
MyDatabase
.
insert
(
"booking"
,
null
,
cv
);
if
(
conclusion
==
-
1
)
{
return
false
;
...
...
@@ -76,28 +75,28 @@ public class Database extends SQLiteOpenHelper {
return
true
;
}
}
public
boolean
play
(
String
playName
,
int
tickets
){
public
boolean
play
input
(
String
playName
,
int
ticketsavail
){
SQLiteDatabase
data
=
this
.
getWritableDatabase
();
ContentValues
cv
=
new
ContentValues
();
cv
.
put
(
"play
n
ame"
,
playName
);
cv
.
put
(
"tickets"
,
tickets
);
cv
.
put
(
"play
N
ame"
,
playName
);
cv
.
put
(
"tickets"
,
tickets
avail
);
long
conclusion
=
data
.
insert
(
"play"
,
null
,
cv
);
return
conclusion
!=
-
1
;
}
public
boolean
ticketsupdate
(
String
playName
,
int
newtickets
){
public
boolean
ticketsupdate
(
String
playName
,
int
newtickets
){
SQLiteDatabase
data
=
this
.
getWritableDatabase
();
ContentValues
cv
=
new
ContentValues
();
cv
.
put
(
"
noticket
"
,
newtickets
);
int
rows
=
data
.
update
(
"play"
,
cv
,
"play
n
ame=?"
,
new
String
[]{
playName
});
cv
.
put
(
"
tickets
"
,
newtickets
);
int
rows
=
data
.
update
(
"play"
,
cv
,
"play
N
ame=?"
,
new
String
[]{
playName
});
return
rows
>
0
;
}
public
int
tickets
(
String
playName
)
{
public
int
get
tickets
(
String
playName
)
{
SQLiteDatabase
data
=
this
.
getReadableDatabase
();
Cursor
record
=
data
.
query
(
"play"
,
new
String
[]{
"tickets"
},
"play
n
ame=?"
,
new
String
[]{
playName
},
null
,
null
,
null
);
Cursor
record
=
data
.
query
(
"play"
,
new
String
[]{
"tickets"
},
"play
N
ame=?"
,
new
String
[]{
playName
},
null
,
null
,
null
);
if
(
record
.
moveToFirst
())
{
int
notickets
=
record
.
getInt
(
record
.
getColumnIndexOrThrow
(
"tickets"
));
int
ticketsavail
=
record
.
getInt
(
record
.
getColumnIndexOrThrow
(
"tickets"
));
record
.
close
();
return
notickets
;
return
ticketsavail
;
}
record
.
close
();
return
0
;
...
...
@@ -105,10 +104,10 @@ public class Database extends SQLiteOpenHelper {
public
List
<
String
>
currentbookings
()
{
List
<
String
>
findbookings
=
new
ArrayList
<>();
SQLiteDatabase
data
=
this
.
getReadableDatabase
();
Cursor
record
=
data
.
rawQuery
(
"SELECT play
n
ame FROM booking"
,
null
);
Cursor
record
=
data
.
rawQuery
(
"SELECT play
N
ame FROM booking"
,
null
);
if
(
record
.
moveToFirst
())
{
do
{
String
playName
=
record
.
getString
(
record
.
getColumnIndexOrThrow
(
"play
n
ame"
));
String
playName
=
record
.
getString
(
record
.
getColumnIndexOrThrow
(
"play
N
ame"
));
findbookings
.
add
(
playName
);
}
while
(
record
.
moveToNext
());
...
...
PlaysRUs2/app/src/main/java/com/example/playsrus/MainActivity.java
View file @
092fc9ea
...
...
@@ -20,6 +20,8 @@ public class MainActivity extends AppCompatActivity {
plays
=
new
ArrayList
<>();
plays
.
add
(
new
performancetickets
(
"The Merchant of Venice"
,
17
));
Button
performance1
=
(
Button
)
findViewById
(
R
.
id
.
Performance1
);
Button
wheelchair
=
(
Button
)
findViewById
(
R
.
id
.
filtered
);
Button
view
=
(
Button
)
findViewById
(
R
.
id
.
viewall
);
...
...
@@ -53,8 +55,6 @@ public class MainActivity extends AppCompatActivity {
startActivity
(
intent
);
}
});
}
}
PlaysRUs2/app/src/main/java/com/example/playsrus/performancetickets.java
View file @
092fc9ea
...
...
@@ -2,24 +2,22 @@ package com.example.playsrus;
public
class
performancetickets
{
private
int
notickets
;
private
String
playname
;
private
String
playName
;
private
int
ticketsavail
;
public
performancetickets
(
String
playname
,
int
notickets
)
{
this
.
notickets
=
notickets
;
this
.
playname
=
playname
;
public
performancetickets
(
String
playName
,
int
ticketsavail
)
{
this
.
playName
=
playName
;
this
.
ticketsavail
=
ticketsavail
;
}
public
String
findplayn
ame
()
{
return
play
n
ame
;
public
String
getPlayN
ame
()
{
return
play
N
ame
;
}
public
int
findtickets
()
{
return
notickets
;
public
int
getTicketsavail
()
{
return
ticketsavail
;
}
public
void
applytickets
(
int
notickets
)
{
this
.
notickets
=
notickets
;
}
public
void
setTicketsavail
(
int
ticketsavail
)
{
this
.
ticketsavail
=
ticketsavail
;
}
}
PlaysRUs2/app/src/main/java/com/example/playsrus/seating.java
View file @
092fc9ea
...
...
@@ -12,65 +12,100 @@ import android.widget.TextView;
import
android.widget.ArrayAdapter
;
import
android.widget.Button
;
import
com.example.playsrus.databinding.SeatingBinding
;
import
com.example.playsrus.databinding.SignupBinding
;
import
org.w3c.dom.Text
;
public
class
seating
extends
AppCompatActivity
implements
AdapterView
.
OnItemSelectedListener
{
String
[]
seatings
=
{
"Seated"
};
private
EditText
fullName
;
private
EditText
orderedtickets
;
private
TextView
displayplayname
;
private
int
tickets
;
private
Database
database
;
private
TextView
displayorderedtickets
;
private
int
orderedtickets
=
0
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
seating
);
displayorderedtickets
=
findViewById
(
R
.
id
.
orderedtickets
);
fullName
=
(
EditText
)
findViewById
(
R
.
id
.
fullname
);
displayplayname
=
findViewById
(
R
.
id
.
displayplayname
);
orderedtickets
=
(
EditText
)
findViewById
(
R
.
id
.
noticketsseating
);
Button
seatingback
=
(
Button
)
findViewById
(
R
.
id
.
seatingback
);
String
playName
=
getIntent
().
getStringExtra
(
"playName"
);
Spinner
seatingtype
=
(
Spinner
)
findViewById
(
R
.
id
.
seatingtype
);
seatingtype
.
setOnItemSelectedListener
(
this
);
ArrayAdapter
aa
=
new
ArrayAdapter
(
this
,
android
.
R
.
layout
.
simple_spinner_item
,
seatings
);
aa
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
seatingtype
.
setAdapter
(
aa
);
Button
confirm
=
(
Button
)
findViewById
(
R
.
id
.
confirm
);
String
playName
=
getIntent
().
getStringExtra
(
"name"
);
Button
seatingback
=
(
Button
)
findViewById
(
R
.
id
.
seatingback
);
displayorderedtickets
.
setText
(
String
.
valueOf
(
orderedtickets
));
Intent
intent
=
getIntent
();
database
=
new
Database
(
this
);
TextView
displaytickets
=
findViewById
(
R
.
id
.
venicetickets
);
// displaytickets.setText(String.valueOf(notickets));
// int ticketsavail = database.gettickets(playnameforthis);
int
ticketsavail
=
17
;
displaytickets
.
setText
(
String
.
valueOf
(
ticketsavail
));
confirm
.
setOnClickListener
(
v
->
{
String
playname
=
"The Merchant of Venice"
;
int
tickets
=
Integer
.
parseInt
(
orderedtickets
.
getText
().
toString
());
if
(
tickets
>
0
)
{
int
notickets
=
database
.
tickets
(
playname
);
TextView
displayorderedtickets
=
findViewById
(
R
.
id
.
orderedtickets
);
int
orderedtickets
=
Integer
.
parseInt
(
displayorderedtickets
.
getText
().
toString
());
if
(
tickets
<=
notickets
)
{
int
currentickets
=
notickets
-
tickets
;
boolean
bookedupdate
=
database
.
ticketsupdate
(
playname
,
currentickets
);
if
(
orderedtickets
>
0
)
{
String
playnameforthis
=
"The Merchant of Venice"
;
int
ticketsthere
=
database
.
gettickets
(
playnameforthis
);
if
(
orderedtickets
<=
ticketsthere
)
{
int
currentickets
=
ticketsthere
-
orderedtickets
;
boolean
bookedupdate
=
database
.
ticketsupdate
(
playnameforthis
,
currentickets
);
if
(
bookedupdate
)
{
Intent
screenchange
=
new
Intent
(
seating
.
this
,
booked
.
class
);
startActivity
(
screenchange
);
;
}
else
{
Toast
.
makeText
(
seating
.
this
,
"Please try again."
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
else
{
Toast
.
makeText
(
seating
.
this
,
"Please
try again
."
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
seating
.
this
,
"Please
order less tickets
."
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
else
{
Toast
.
makeText
(
seating
.
this
,
"Please order some tickets."
,
Toast
.
LENGTH_SHORT
).
show
();
}
});
seatingback
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Intent
intent
=
new
Intent
(
seating
.
this
,
MainActivity
.
class
);
startActivity
(
intent
);
}
private
boolean
bookingdone
(
String
playName
,
String
fullName
,
int
tickets
,
String
seatingtype
)
{
boolean
storebooking
=
database
.
booking
(
playName
,
fullName
,
Integer
.
parseInt
(
String
.
valueOf
(
tickets
)),
seatingtype
);
});
Button
minusone
=
findViewById
(
R
.
id
.
minusone
);
Button
plusone
=
findViewById
(
R
.
id
.
plusone
);
plusone
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
orderedtickets
++;
displayorderedtickets
.
setText
(
String
.
valueOf
(
orderedtickets
));
}
});
minusone
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
orderedtickets
>
0
)
{
orderedtickets
--;
displayorderedtickets
.
setText
(
String
.
valueOf
(
orderedtickets
));
}
}
});
}
private
boolean
bookingdone
(
String
playName
,
int
noticket
)
{
boolean
storebooking
=
database
.
bookinginput
(
playName
,
Integer
.
parseInt
(
String
.
valueOf
(
noticket
)));
return
storebooking
;
}
...
...
PlaysRUs2/app/src/main/res/layout/seating.xml
View file @
092fc9ea
...
...
@@ -37,20 +37,34 @@
<TextView
android:id=
"@+id/textView17"
android:layout_width=
"
wrap_content
"
android:layout_height=
"
wrap_content
"
android:layout_width=
"
173dp
"
android:layout_height=
"
39dp
"
android:layout_marginTop=
"8dp"
android:text=
"How many"
android:text=
"How many
tickets?
"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textSize=
"20sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.
066
"
app:layout_constraintHorizontal_bias=
"0.
432
"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.
494
"
app:layout_constraintVertical_bias=
"0.
523
"
tools:text=
"How many tickets?"
/>
<TextView
android:id=
"@+id/orderedtickets"
android:layout_width=
"54dp"
android:layout_height=
"38dp"
android:layout_marginTop=
"8dp"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body1"
android:textSize=
"24sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.498"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.616"
/>
<TextView
android:id=
"@+id/textView18"
android:layout_width=
"wrap_content"
...
...
@@ -61,10 +75,10 @@
android:textSize=
"20sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.
075
"
app:layout_constraintHorizontal_bias=
"0.
124
"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.
6
"
app:layout_constraintVertical_bias=
"0.
752
"
tools:text=
"Fullname"
/>
<TextView
...
...
@@ -89,10 +103,10 @@
android:text=
"Confirm"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.
69
4"
app:layout_constraintHorizontal_bias=
"0.
76
4"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.
732
"
/>
app:layout_constraintVertical_bias=
"0.
909
"
/>
<Button
android:id=
"@+id/seatingback"
...
...
@@ -101,10 +115,10 @@
android:text=
"Back"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.
059
"
app:layout_constraintHorizontal_bias=
"0.
152
"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.
732
"
/>
app:layout_constraintVertical_bias=
"0.
909
"
/>
<EditText
android:id=
"@+id/fullname"
...
...
@@ -115,24 +129,10 @@
android:text=
"Input fullname"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.833"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.615"
/>
<EditText
android:id=
"@+id/noticketsseating"
android:layout_width=
"209dp"
android:layout_height=
"48dp"
android:ems=
"10"
android:inputType=
"number"
android:text=
"How many tickets?"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.965"
app:layout_constraintHorizontal_bias=
"0.9"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.
499
"
/>
app:layout_constraintVertical_bias=
"0.
766
"
/>
<Spinner
android:id=
"@+id/seatingtype"
...
...
@@ -154,23 +154,50 @@
android:textSize=
"24sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.
698
"
app:layout_constraintHorizontal_bias=
"0.
712
"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.4
2
4"
/>
app:layout_constraintVertical_bias=
"0.4
1
4"
/>
<TextView
android:id=
"@+id/venicetickets2"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_width=
"260dp"
android:layout_height=
"38dp"
android:text=
"Available Seating Tickets -"
android:textColor=
"#000000"
android:textSize=
"20sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.
067
"
app:layout_constraintHorizontal_bias=
"0.
105
"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.4
23
"
app:layout_constraintVertical_bias=
"0.4
18
"
tools:text=
"Available Seating Tickets -"
/>
<Button
android:id=
"@+id/minusone"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"- 1"
android:textSize=
"34sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.145"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.624"
/>
<Button
android:id=
"@+id/plusone"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"+ 1"
android:textSize=
"34sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.804"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.624"
/>
</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