diff --git a/WebContent/html/webpages/shoppingCart.jsp b/WebContent/html/webpages/shoppingCart.jsp index 576b60b..0ad0db4 100644 --- a/WebContent/html/webpages/shoppingCart.jsp +++ b/WebContent/html/webpages/shoppingCart.jsp @@ -231,15 +231,15 @@ function autoFillFields() { <% MySQLAccess access = new MySQLAccess(); User employee = access.getEmployeeByID(9); //replace with real ID - int location = employee.getLocation(); + String location = employee.getLocationName(); String name = employee.getName(); - int phone = employee.getPhone(); + String phone = employee.getPhone(); %> - employee.location = "<%=location%>"; + employee.locationName = "<%=location%>"; employee.name = "<%=name%>"; employee.phone = "<%=phone%>"; document.orderForm.name.value=employee.name; - document.orderForm.location.value=employee.location; + document.orderForm.location.value=employee.locationName; document.orderForm.phone.value=employee.phone; } diff --git a/src/database/MySQLAccess.java b/src/database/MySQLAccess.java index 583f56f..1666661 100644 --- a/src/database/MySQLAccess.java +++ b/src/database/MySQLAccess.java @@ -21,7 +21,7 @@ public void connectDB() throws SQLException, ClassNotFoundException { while(resultSet.next()){ String deviceName = resultSet.getString("Device_Name"); String deviceDescription = resultSet.getString("Device_Description"); - String hardwareType = resultSet.getString("Hardware_Type"); + String hardwareType = resultSet.getString("Hardware_Model"); for(int i = 0; i<1; i++){ result[i][0] = deviceName; @@ -44,7 +44,7 @@ public void initializeEmployee(int id) throws ClassNotFoundException, SQLExcepti statement.executeQuery("INSERT INTO employee (Employee_ID) VALUES ("+id+");"); } - public void updateEmployee(int id, String name, int phone, int location) throws ClassNotFoundException, SQLException + public void updateEmployee(int id, String name, String phone, int location) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Connection connect = DriverManager.getConnection(database,user,password); @@ -69,9 +69,11 @@ public User getEmployeeByID(int id) throws ClassNotFoundException, SQLException id, resultSet.getInt("Location_ID"), resultSet.getString("Name"), - resultSet.getInt("Phone_Number") + resultSet.getString("Phone_Number") ); - + resultSet = statement.executeQuery("SELECT Address FROM location WHERE Location_ID = "+employee.getLocation()); + resultSet.next(); + employee.setLocationName(resultSet.getString("Address")); return employee; } diff --git a/src/entities/Admin.java b/src/entities/Admin.java index e3038c5..d6fe586 100644 --- a/src/entities/Admin.java +++ b/src/entities/Admin.java @@ -6,7 +6,7 @@ */ public class Admin extends User { - public Admin(int id, int location, String name, int phone) { + public Admin(int id, int location, String name, String phone) { super(id, location, name, phone); } diff --git a/src/entities/User.java b/src/entities/User.java index 3b1de9e..5545d91 100644 --- a/src/entities/User.java +++ b/src/entities/User.java @@ -3,10 +3,11 @@ public class User { private int id; private int location; +private String locationName; private String name; -private int phone; +private String phone; - public User(int id, int location, String name, int phone){ + public User(int id, int location, String name, String phone){ this.id = id; this.location = location; this.name = name; //later will do table lookup to determine by id @@ -16,16 +17,40 @@ public int getID() { return id; } + public void setID(int id) + { + this.id=id; + } public int getLocation() { return location; } + public void setLocation(int location) + { + this.location=location; + } public String getName() { return name; } - public int getPhone() + public void setName(String name) + { + this.name=name; + } + public String getPhone() { return phone; } + public void setPhone(String phone) + { + this.phone=phone; + } + public String getLocationName() + { + return locationName; + } + public void setLocationName(String locationName) + { + this.locationName=locationName; + } }