Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stephen
IF3230-Tugas-Besar-Sister-2015
Commits
c3fbb772
Commit
c3fbb772
authored
Apr 23, 2015
by
melvinfonda
Browse files
accept fixed
parent
1ce989a2
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/client/build/classes/tcpclient/TCPClient.class
View file @
c3fbb772
No preview for this file type
src/client/nbproject/private/private.properties
View file @
c3fbb772
compile.on.save
=
true
user.properties.file
=
C:
\\
Users
\\
Stephen
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0.2
\\
build.properties
\ No newline at end of file
user.properties.file
=
C:
\\
Users
\\
user
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
\\
build.properties
src/client/src/tcpclient/TCPClient.java
View file @
c3fbb772
...
...
@@ -800,7 +800,10 @@ public class TCPClient {
response
=
client
.
offer
(
client
.
token
,
0
,
1
,
7
,
3
);
System
.
out
.
println
(
response
.
toString
());
response
=
client
.
sendFind
(
client
.
token
,
2
);
// response = client.sendFind(client.token, 2);
// System.out.println(response.toString());
response
=
client
.
accept
(
client
.
token
,
"a"
);
System
.
out
.
println
(
response
.
toString
());
}
...
...
src/server/build/classes/tcpserver/MySQLAccess.class
View file @
c3fbb772
No preview for this file type
src/server/nbproject/private/private.properties
View file @
c3fbb772
compile.on.save
=
true
user.properties.file
=
C:
\\
Users
\\
Stephen
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
.2
\\
build.properties
user.properties.file
=
C:
\\
Users
\\
user
\\
AppData
\\
Roaming
\\
NetBeans
\\
8.0
\\
build.properties
src/server/src/tcpserver/MySQLAccess.java
View file @
c3fbb772
...
...
@@ -429,7 +429,7 @@ public class MySQLAccess {
return
response
;
}
public
JSONObject
a
ccept
(
int
userID
,
String
offer_token
)
throws
JSONException
public
JSONObject
sendA
ccept
(
int
userID
,
String
offer_token
)
throws
JSONException
{
open
();
JSONObject
response
=
new
JSONObject
();
...
...
@@ -522,6 +522,43 @@ public class MySQLAccess {
return
response
;
}
public
JSONObject
accept
(
int
userID
,
String
offer_token
)
throws
JSONException
{
open
();
JSONObject
response
=
new
JSONObject
();
try
{
//cek offer dengan offer token yang sesuai
preparedStatement
=
connect
.
prepareStatement
(
"SELECT * FROM offer WHERE "
+
"offer_token=\""
+
offer_token
+
"\";"
);
resultSet
=
preparedStatement
.
executeQuery
();
if
(
resultSet
.
first
())
{
boolean
available
=
resultSet
.
getBoolean
(
"available"
);
//cek apakah offer tersedia
if
(
available
)
{
preparedStatement
=
connect
.
prepareStatement
(
"UPDATE offer SET available = 0"
+
" WHERE "
+
"offer_token=\""
+
offer_token
+
"\";"
);
preparedStatement
.
executeUpdate
();
response
.
put
(
"status"
,
"ok"
);
}
else
//offer tidak tersedia
{
response
.
put
(
"status"
,
"fail"
);
response
.
put
(
"description"
,
"offer is not available"
);
}
}
}
catch
(
SQLException
e
)
{
response
.
put
(
"status"
,
"error"
);
e
.
printStackTrace
();
}
close
();
return
response
;
}
public
JSONObject
fetchitem
(
int
userID
,
String
offer_token
)
throws
JSONException
{
open
();
...
...
Write
Preview
Supports
Markdown
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