Skip to content

Commit

Permalink
Send Payment Info to Server
Browse files Browse the repository at this point in the history
  • Loading branch information
tanvir10029 committed Apr 16, 2021
1 parent cae3a88 commit 93e996d
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 79 deletions.
165 changes: 87 additions & 78 deletions Expedia/src/application/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,83 +105,7 @@ public void start(Stage primaryStage)
RB2.setToggleGroup(Payment);


Button submitButton = new Button("SUBMIT");
submitButton.setOnAction(new EventHandler<ActionEvent>()
{
@Override public void handle(ActionEvent e)
{
Platform.runLater(new Runnable()
{
public void run()
{
String rs=null;
socketUtils su = new socketUtils();

if (su.socketConnect() == true) //this always seems to be false for whatever reason
{
String strDouble = String.format("%.2f", total);
String msg = "Transaction>kiosk#001" + "," + numOfItems + "," + strDouble;
su.sendMessage(msg);
String ackOrNack = su.recvMessage();


msg = "quit";
su.sendMessage(msg);
rs = su.recvMessage();


//
// close the socket connection
//
su.closeSocket();

//
// write to transaction log
//
msg = "CLIENT : Transaction>kiosk#001" + "," + numOfItems + "," + strDouble;
fileIO trans = new fileIO();
trans.wrTransactionData(msg);


// initialize variables back to zero
total=0.0;
numOfItems=0;

ta.setText("");
ta2.setText("");

if (ackOrNack.startsWith("ACK") == true)
{
ta2.setText("Success! Message was received and processed by the Socket Server!");
}
else
{
ta2.setText("RECV : " + ackOrNack);
ta2.appendText(rs);
}
}
else
{
//
// write to transaction log
//
String strDouble = String.format("%.2f", total);
String msg = "CLIENT NETWORK ERROR : Transaction>kiosk#001" + "," + numOfItems + "," + strDouble;

fileIO trans = new fileIO();
trans.wrTransactionData(msg);


Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("--- Network Communications Error ---");
alert.setHeaderText("Unable to talk to Socket Server!");

alert.showAndWait();
}
}
});
}
});


//Image Buttons (Just going to be lying around for now)
Text reccLabel = new Text(" Recommendations: ");
Expand Down Expand Up @@ -304,7 +228,92 @@ public void run()
contact.add(pay, 2, 3, 1, 1);
contact.add(Card, 0, 4, 1, 1);
contact.add(CardF, 1, 4, 1, 1);


Button submitButton = new Button("SUBMIT");
submitButton.setOnAction(new EventHandler<ActionEvent>()
{
@Override public void handle(ActionEvent e)
{
Platform.runLater(new Runnable()
{
public void run()
{
String rs=null;
socketUtils su = new socketUtils();

if (su.socketConnect() == true) //this always seems to be false for whatever reason
{
String strDouble = String.format("%.2f", total);
String msg = "Transaction>kiosk#001" + "," + numOfItems + "," + strDouble;
su.sendMessage(msg);
String ackOrNack = su.recvMessage();

String msg1 = "Name: " + nameF.getText();
su.sendMessage(msg1);
msg1 = "Email: " + emailF.getText();
su.sendMessage(msg1);
msg1 = "Card #: "+ CardF.getText();
su.sendMessage(msg1);


msg = "quit";
su.sendMessage(msg);
rs = su.recvMessage();


//
// close the socket connection
//
su.closeSocket();

//
// write to transaction log
//
msg = "CLIENT : Transaction>kiosk#001" + "," + numOfItems + "," + strDouble;
fileIO trans = new fileIO();
trans.wrTransactionData(msg);


// initialize variables back to zero
total=0.0;
numOfItems=0;

ta.setText("");
ta2.setText("");

if (ackOrNack.startsWith("ACK") == true)
{
ta2.setText("Success! Message was received and processed by the Socket Server!");
}
else
{
ta2.setText("RECV : " + ackOrNack);
ta2.appendText(rs);
}
}
else
{
//
// write to transaction log
//
String strDouble = String.format("%.2f", total);
String msg = "CLIENT NETWORK ERROR : Transaction>kiosk#001" + "," + numOfItems + "," + strDouble;

fileIO trans = new fileIO();
trans.wrTransactionData(msg);


Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("--- Network Communications Error ---");
alert.setHeaderText("Unable to talk to Socket Server!");

alert.showAndWait();
}
}
});
}
});

//Gridpane for payment
GridPane payGrid = new GridPane();
gridPane.add(payGrid, 3, 3, 1, 1);
Expand Down
2 changes: 1 addition & 1 deletion Expedia/src/application/sockServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public void run()


// update the status text area to show progress of program
expediaServer.textArea.appendText("RECV : " + clientString + newline);
expediaServer.textArea_3.appendText("RECV : " + clientString + newline);

// update the status text area to show progress of program
expediaServer.textArea.appendText("RLEN : " + clientString.length() + newline);
Expand Down
36 changes: 36 additions & 0 deletions Expedia/transactionLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,39 @@
04-08-2021 23.54.32 : SERVER : Transaction>kiosk#001,0,0.00
04-08-2021 23.54.33 : SERVER : quit
04-08-2021 23.54.33 : CLIENT : Transaction>kiosk#001,0,0.00
04-16-2021 12.06.58 : SERVER : Transaction>kiosk#001,0,0.00
04-16-2021 12.06.59 : SERVER : quit
04-16-2021 12.06.59 : CLIENT : Transaction>kiosk#001,0,0.00
04-16-2021 12.08.08 : SERVER : Transaction>kiosk#001,0,0.00
04-16-2021 12.08.09 : SERVER : quit
04-16-2021 12.08.09 : CLIENT : Transaction>kiosk#001,0,0.00
04-16-2021 12.10.18 : SERVER : Transaction>kiosk#001,0,0.00
04-16-2021 12.10.19 : SERVER : quit
04-16-2021 12.10.19 : CLIENT : Transaction>kiosk#001,0,0.00
04-16-2021 12.34.56 : SERVER : Transaction>kiosk#001,0,0.00
04-16-2021 12.34.56 : SERVER : hibyechai
04-16-2021 12.34.56 : CLIENT : Transaction>kiosk#001,0,0.00
04-16-2021 12.34.57 : SERVER : quit
04-16-2021 12.40.54 : SERVER : Transaction>kiosk#001,0,0.00
04-16-2021 12.40.54 : SERVER : ya yeetyoot
04-16-2021 12.40.54 : CLIENT : Transaction>kiosk#001,0,0.00
04-16-2021 12.40.55 : SERVER : quit
04-16-2021 12.43.59 : SERVER : Transaction>kiosk#001,0,0.00
04-16-2021 12.43.59 : SERVER :
04-16-2021 12.43.59 : CLIENT : Transaction>kiosk#001,0,0.00
04-16-2021 12.44.00 : SERVER : Name: bill
04-16-2021 12.44.00 : SERVER : Phone #:
04-16-2021 12.44.01 : SERVER : Email:nye/n Card #: 133
04-16-2021 12.44.01 : SERVER : quit
04-16-2021 12.46.45 : SERVER : Transaction>kiosk#001,0,0.00
04-16-2021 12.46.46 : SERVER :
04-16-2021 12.46.46 : CLIENT : Transaction>kiosk#001,0,0.00
04-16-2021 12.46.46 : SERVER : Name: Fed
04-16-2021 12.46.47 : SERVER : Email: [email protected]/nCard #: 1111
04-16-2021 12.46.47 : SERVER : quit
04-16-2021 12.51.28 : SERVER : Transaction>kiosk#001,0,0.00
04-16-2021 12.51.28 : SERVER : Name: Mom
04-16-2021 12.51.28 : CLIENT : Transaction>kiosk#001,0,0.00
04-16-2021 12.51.29 : SERVER : Email: Ya
04-16-2021 12.51.29 : SERVER : Card #: Juice
04-16-2021 12.51.30 : SERVER : quit

0 comments on commit 93e996d

Please sign in to comment.