public String generateUserInsertQuery(Staff staff) { StringBuffer strQuery = new StringBuffer(INSERT_USER_QUERY); strQuery.append(staff.getF_name()); strQuery.append("', '"); strQuery.append(staff.getL_name()); strQuery.append("', '"); strQuery.append(staff.getPassword()); strQuery.append("', '"); strQuery.append(staff.getEmail()); strQuery.append("', '"); strQuery.append(staff.getAddress()); strQuery.append("', '"); strQuery.append(staff.getCity()); strQuery.append("', '"); strQuery.append(staff.getState()); strQuery.append("', '"); strQuery.append(staff.getZipcode()); strQuery.append("', '"); strQuery.append(utility.convertStringToDate(staff.getDob())); strQuery.append("', '"); strQuery.append(staff.getType()); strQuery.append("')"); System.out.println("Insert User query : " + strQuery.toString()); return strQuery.toString(); }
public StaffMessageBean addStaff(Staff staff) { StaffMessageBean staffMessageBean = new StaffMessageBean(); String insertUserQuery = generateUserInsertQuery(staff); try { // insert into User Table int user_id = dbOperation.executeUpdateQuery(insertUserQuery); System.out.println("User Id of newly added staff:: " + user_id); // insert into Staff Table insertIntoStaffTable(user_id, staff); // Set the return values staffMessageBean.setUser_id(user_id); staffMessageBean.setStaff(staff); staffMessageBean.setMessage( "New Staff " + staff.getF_name() + " " + staff.getL_name() + " Added Successfully"); } catch (Exception e) { // TODO Auto-generated catch block staffMessageBean.setMessage("Error in adding New Staff!! "); e.printStackTrace(); } return staffMessageBean; }