Created
January 8, 2019 03:51
-
-
Save jaycdave88/dd8247b322fc6eae45b6afbd086ea765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void EnterBtnActionPerformed(java.awt.event.ActionEvent evt) { | |
try{ | |
//set ID | |
rep.setSalesRepID(Integer.parseInt(IDTF.getText().trim())); | |
//set first name | |
rep.setFirstName(FirstNameTF.getText().trim()); | |
//set last name | |
rep.setLastname(LastNameTF.getText().trim()); | |
//set supplies | |
rep.setOfficeSupplies(Double.parseDouble(OfficeSuppliesTF.getText().trim())); | |
//set books | |
rep.setBooks(Double.parseDouble(BooksTF.getText().trim())); | |
//set papers | |
rep.setPaper(Double.parseDouble(PapersTF.getText().trim())); | |
//set district | |
if (NorthRadioBtn.isSelected()) { | |
rep.setDistrict("North"); | |
} | |
if (SouthRadioBtn.isSelected()) { | |
rep.setDistrict("South"); | |
} | |
if (EastRadioBtn.isSelected()) { | |
rep.setDistrict("East"); | |
} | |
if (WestRadioBtn.isSelected()) { | |
rep.setDistrict("West"); | |
} | |
//set contact | |
if (EmailRadioBtn.isSelected()) { | |
rep.setContact("Email"); | |
} | |
if (PhoneRadioBtn.isSelected()) { | |
rep.setContact("Phone"); | |
} | |
if (VisitRadioBtn.isSelected()) { | |
rep.setContact("Visit"); | |
} | |
// create a new sales rep file writer obj. | |
SalesRepresentativeFileWriter repWriter = new SalesRepresentativeFileWriter(); | |
//write to file. | |
repWriter.writeSalesRepDataToFile(rep); | |
//success message | |
int resetChoice = JOptionPane.showConfirmDialog(null, "Success! Data written to salesrep.txt\n Would you like to reset previous fields? ", "Choose", JOptionPane.YES_NO_OPTION ); | |
//user choice. | |
if(resetChoice == JOptionPane.YES_OPTION){ | |
ResetAllFields(); | |
} | |
}catch (Exception e){ | |
JOptionPane.showMessageDialog(null, "Uh-oh!", "Error", JOptionPane.ERROR_MESSAGE ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment