Database Reference
In-Depth Information
Create a New Employee
We can create new employees from the Add/Modify User functional screen. In that case, a new
employee ID will be assigned. Until the employee has been created, we do not permit the application
user to enter a user ID. In this way it is a two-step process. Once the employee is created, we can then
select him from existingEmpComboBox and enter user and mobile number data for him.
Save Data for the Employee
Once the application user has entered data that she would like to save for the selected or new employee,
she will select the Save button. That action calls the saveButton_actionPerformed() method. We show
the structure of that method in Listing 12-23. In that listing, we have left out the bulk of the delayed
thread run() method, which will be presented later. We test the values entered on the AddUser form to
assure that values have been entered for all required fields. After we test them, we once again make the
modal sayWaitDialog visible. In the meantime, we define another delayed Thread to do our work. At the
end of the delayed thread run() method, we set the sayWaitDialog invisible. As I have described the use
of the delayed Thread and the sayWaitDialog several times now, I will stop mentioning them; although,
we will continue to use those features throughout this application.
Listing 12-23. Save Employee and User Data
private void saveButton_actionPerformed(ActionEvent e) {
if (lastNameTextField.getText().equals("") ||
jobIDComboBox.getSelectedIndex() == 0 ||
eMailNameTextField.getText().equals("") ||
managerIDComboBox.getSelectedIndex() == 0 ||
deptIDComboBox.getSelectedIndex() == 0) {
JOptionPane.showMessageDialog(thisComponent,
" Must have values for Last Name, Job ID, E-Mail, Dept ID and Mgr ID!");
return;
}
if (existingEmpComboBox.getSelectedIndex() > 0 &&
osUserIDTextField.getText().equals("") &&
(!(pagerNumberTextField.getText().equals("") &&
smsPhoneNumberTextField.getText().equals("")))) {
JOptionPane.showMessageDialog(thisComponent,
" Must have value for User ID, else blank mobile nos!");
return;
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
...
Login.sayWaitDialog.setVisible(false) ;
}
});
// Ask the user to be patient while working
Login.sayWaitDialog.setVisible(true) ;
}
The delayed Thread that is defined in the saveButton_actionPerformed() method does our Oracle
update processing. In this case, the real processing occurs in two update Oracle stored procedures. The
 
Search WWH ::




Custom Search