home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-02-21 | 14.4 KB | 389 lines |
- /**************************************************************************************************
- * *
- * Class name: expenseView *
- * *
- * Purpose: Extends Panel to allow users to view expense report stored in the database. *
- * *
- * Imports: java.awt.* *
- * java.applet.* *
- * symjava.sql.* *
- * java.net.* *
- * java.lang.* *
- * java.util.* *
- * *
- * Methods include: public boolean handleEvent(Event event) *
- * public class expenseView extends Panel *
- * public expenseView(Applet parent, String empID) *
- * public synchronized void show() *
- * public void clearAllControls () *
- * public void clickedMainMenubutton() *
- * public void disableControls () *
- * public void getEmployeeInfo(String empID) *
- * public void selectedFind() *
- * public void setIDFunct (String empID) *
- * *
- * Additional Notes: *
- * THIS SOFTWARE HAS BEEN COMPILED AND EXECUTED SUCCESSFULLY IN SPECIFIC SYMANTEC *
- * ENVIRONMENTS, AND IS BEING PROVIDED ONLY AS SAMPLE CODE. *
- * *
- * SYMANTEC MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, *
- * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SYMANTEC SHALL NOT *
- * BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING *
- * THIS SOFTWARE OR ITS DERIVATIVES. *
- * *
- * Please see the Sample Code Configuration item in the Read Me file for additional *
- * information about the sample database used in this applet. *
- * *
- * Copyright (c) 1996 Symantec. All Rights Reserved. *
- * *
- **************************************************************************************************/
-
- import java.applet.*;
- import java.net.*;
- import java.awt.*;
- import symjava.sql.*;
- import java.lang.*;
- import java.util.*;
-
- public class expenseView extends Panel {
-
- expenseApplet exp;
- public expenseView(Applet parent, String empID) {
-
- exp = (expenseApplet)parent;
-
- //{{INIT_CONTROLS
- setLayout(null);
- resize(insets().left + insets().right + 741, insets().top + insets().bottom + 494);
-
- label9=new Label("Employee #");
- add(label9);
- label9.reshape(insets().left + 16,insets().top + 43,100,15);
-
- employeenum=new TextField(14);
- add(employeenum);
- employeenum.reshape(insets().left + 119,insets().top + 43,189,25);
-
- find=new Button("Find");
- add(find);
- find.reshape(insets().left + 308,insets().top + 43,35,25);
-
- firstname=new TextField(22);
- add(firstname);
- firstname.reshape(insets().left + 119,insets().top + 84,224,25);
-
- label2=new Label("First Name");
- add(label2);
- label2.reshape(insets().left + 16,insets().top + 84,100,15);
-
- label3=new Label("Last Name");
- add(label3);
- label3.reshape(insets().left + 395,insets().top + 84,100,15);
-
- lastname=new TextField(22);
- add(lastname);
- lastname.reshape(insets().left + 497,insets().top + 84,224,25);
-
- label4=new Label("Address");
- add(label4);
- label4.reshape(insets().left + 16,insets().top + 124,70,15);
-
- address=new TextField(31);
- add(address);
- address.reshape(insets().left + 119,insets().top + 124,224,25);
-
- city=new TextField(22);
- add(city);
- city.reshape(insets().left + 119,insets().top + 159,224,25);
-
- label5=new Label("City");
- add(label5);
- label5.reshape(insets().left + 16,insets().top + 159,70,15);
-
- label6=new Label("State");
- add(label6);
- label6.reshape(insets().left + 16,insets().top + 199,100,15);
-
- state=new TextField(9);
- add(state);
- state.reshape(insets().left + 119,insets().top + 199,224,25);
-
- label7=new Label("Postal Code");
- add(label7);
- label7.reshape(insets().left + 16,insets().top + 234,100,15);
-
- postalcode=new TextField(9);
- add(postalcode);
- postalcode.reshape(insets().left + 119,insets().top + 234,224,25);
-
- title=new TextField(21);
- add(title);
- title.reshape(insets().left + 497,insets().top + 43,224,26);
-
- label8=new Label("Title");
- add(label8);
- label8.reshape(insets().left + 395,insets().top + 43,70,15);
-
- label10=new Label("Social Security #");
- add(label10);
- label10.reshape(insets().left + 395,insets().top + 124,94,15);
-
- socialsecurity=new TextField(13);
- add(socialsecurity);
- socialsecurity.reshape(insets().left + 497,insets().top + 124,224,26);
-
- email=new TextField(20);
- add(email);
- email.reshape(insets().left + 497,insets().top + 159,224,26);
-
- label11=new Label("Email");
- add(label11);
- label11.reshape(insets().left + 395,insets().top + 159,70,15);
-
- label12=new Label("Dept Name");
- add(label12);
- label12.reshape(insets().left + 395,insets().top + 199,100,15);
-
- deptname=new TextField(20);
- add(deptname);
- deptname.reshape(insets().left + 497,insets().top + 199,224,26);
-
- label13=new Label("Home Phone");
- add(label13);
- label13.reshape(insets().left + 395,insets().top + 234,100,15);
-
- homephone=new TextField(13);
- add(homephone);
- homephone.reshape(insets().left + 497,insets().top + 234,224,25);
-
- label14=new Label("Country");
- add(label14);
- label14.reshape(insets().left + 16,insets().top + 274,70,15);
-
- country=new TextField(21);
- add(country);
- country.reshape(insets().left + 119,insets().top + 274,224,25);
-
- label15=new Label("Work Phone");
- add(label15);
- label15.reshape(insets().left + 395,insets().top + 274,100,15);
-
- workphone=new TextField(13);
- add(workphone);
- workphone.reshape(insets().left + 497,insets().top + 274,224,25);
-
- //list1=new List();
- //list1.setFont(new Font("Courier",Font.PLAIN,8));
- //add(list1);
- //list1.reshape(insets().left + 48,insets().top + 353,681,75);
-
- exprptbutton=new Button("Expense Report Name");
- add(exprptbutton);
- exprptbutton.reshape(insets().left + 46,insets().top + 317,156,30);
-
- datebutton=new Button("Date Submitted");
- add(datebutton);
- datebutton.reshape(insets().left + 202,insets().top + 317,105,30);
-
- advancebutton=new Button("Advance");
- add(advancebutton);
- advancebutton.reshape(insets().left + 305,insets().top + 317,108,30);
-
- totalepensebutton=new Button("Total Expenses");
- add(totalepensebutton);
- totalepensebutton.reshape(insets().left + 410,insets().top + 317,140,30);
-
- amountbutton=new Button("Amount due");
- add(amountbutton);
- amountbutton.reshape(insets().left + 546,insets().top + 317,125,30);
-
- paidbutton=new Button("Paid");
- add(paidbutton);
- paidbutton.reshape(insets().left + 670,insets().top + 317,61,30);
-
- MainMenubutton=new Button("Main Menu");
- add(MainMenubutton);
- MainMenubutton.reshape(insets().left + 370,insets().top + 430,70,30);
-
- titlelabel=new Label("Employee Expense View");
- titlelabel.setFont(new Font("Dialog",Font.BOLD,14));
- add(titlelabel);
- titlelabel.reshape(insets().left + 307,insets().top + 10,210,15);
- //}}
-
- disableControls ();
- if (empID != null) setIDFunct (empID);
-
- }
-
- public synchronized void show() {
- super.show();
- }
-
- public boolean handleEvent(Event event) {
- if (event.id == Event.ACTION_EVENT && event.target == find) {
- clearAllControls ();
- selectedFind();
- return true;
- }
- else
- if (event.id == Event.ACTION_EVENT && event.target == employeenum) {
- clearAllControls ();
- getEmployeeInfo(employeenum.getText());
- exp.getExpenseInfo(employeenum.getText());
- return true;
- }
- else
- if (event.id == Event.ACTION_EVENT && event.target == MainMenubutton) {
- clearAllControls ();
- clickedMainMenubutton();
- return true;
- }
-
- return super.handleEvent(event);
- }
-
-
- //{{DECLARE_CONTROLS
- TextField firstname;
- Label label2;
- Label label3;
- TextField lastname;
- Label label4;
- TextField address;
- TextField city;
- Label label5;
- Label label6;
- TextField state;
- Label label7;
- TextField postalcode;
- TextField title;
- Label label8;
- Label label9;
- TextField employeenum;
- Label label10;
- TextField socialsecurity;
- TextField email;
- Label label11;
- Label label12;
- TextField deptname;
- Label label13;
- TextField homephone;
- Label label14;
- TextField country;
- Label label15;
- TextField workphone;
- List list1;
- Button exprptbutton;
- Button datebutton;
- Button advancebutton;
- Button totalepensebutton;
- Button amountbutton;
- Button paidbutton;
- Button find;
- Button MainMenubutton;
- Label titlelabel;
- //}}
-
- public void selectedFind() {
- this.hide();
- exp.clickedFind();
- }
-
- public void disableControls () {
- firstname.setEditable(false);
- lastname.setEditable(false);
- address.setEditable(false);
- city.setEditable(false);
- state.setEditable(false);
- postalcode.setEditable(false);
- title.setEditable(false);
- socialsecurity.setEditable(false);
- email.setEditable(false);
- deptname.setEditable(false);
- homephone.setEditable(false);
- country.setEditable(false);
- workphone.setEditable(false);
- }
-
-
- public void clickedMainMenubutton() {
- hide();
-
- }
-
-
- //**** get employee information from database *******
-
- public void getEmployeeInfo(String empID) {
- Statement s;
- ResultSet rs;
-
- /********************** Query the Employees Table ******************************/
- try
- {
- s = (Statement)exp.connection.createStatement();
- rs = (ResultSet)s.executeQuery("select DepartmentName, SocialSecurityNumber, FirstName, LastName, Title, EmailName, Address, City, StateOrProvince, PostalCode, Country, HomePhone, WorkPhone from Employees where EmployeeID = '" + employeenum.getText() + "'");
-
- deptname.setText(rs.getString(1));
- socialsecurity.setText(rs.getString(2));
- firstname.setText(rs.getString(3));
- lastname.setText(rs.getString(4));
- title.setText(rs.getString(5));
- email.setText(rs.getString(6));
- address.setText(rs.getString(7));
- city.setText(rs.getString(8));
- state.setText(rs.getString(9));
- postalcode.setText(rs.getString(10));
- country.setText(rs.getString(11));
- homephone.setText(rs.getString(12));
- workphone.setText(rs.getString(13));
-
- s.close();
- }
- catch (SQLException e)
- {
- System.out.println(e.getMessage());
- clearAllControls();
- return;
- }
- /**********************************************************************************/
- }
-
- //**** clear control fields ******
-
- public void clearAllControls () {
- firstname.setText(null);
- lastname.setText(null);
- address.setText(null);
- city.setText(null);
- state.setText(null);
- postalcode.setText(null);
- title.setText(null);
- socialsecurity.setText(null);
- email.setText(null);
- deptname.setText(null);
- homephone.setText(null);
- country.setText(null);
- workphone.setText(null);
- /* if (list1.countItems() > 0)
- list1.delItems(0, list1.countItems()-1);*/
- }
-
-
-
-
- public void setIDFunct (String empID) {
- employeenum.setText(empID);
- getEmployeeInfo(empID);
- exp.getExpenseInfo(empID);
- }
- }
-
-
-
-
-
-
-