Exemplo n.º 1
0
  public void update(int updateIndex[], Vector updateValue) {

    StringBuffer select = new StringBuffer();
    select.append(columns[0]).append(" = ").append(Integer.toString(employeeID()));

    String updateString =
        getUpdateString(updateIndex, updateValue, table, columns, col_types, select.toString());

    try {

      Application.dbConnection().execute(updateString);
      Application.dbConnection().commit();
    } catch (SQLException e) {
      logger.warn("Update failed " + updateString, e);
    }
  }
Exemplo n.º 2
0
  public void relations() {

    String fetchSpec = null;
    Vector v = null;
    fetchSpec = SubMenu.getByMenuID(menuID());
    v = Application.dbConnection().fetch(new SubMenu(), fetchSpec);
    setSubMenus(v);
  }
Exemplo n.º 3
0
 public void relations() {
   String fetchSpec = PosProfile.getByID(profile());
   Vector v = Application.dbConnection().fetch(new PosProfile(), fetchSpec);
   if (v.size() > 0) {
     posProfile = (PosProfile) v.elementAt(0);
   } else {
     logger.warn("Pos Profile not found for employee " + employeeID());
   }
 }
Exemplo n.º 4
0
  public void add() {

    StringBuffer str = new StringBuffer();

    str.append("insert into ").append(table).append(" values (");
    str.append("null, "); // trigger on ID
    str.append(Integer.toString(logonNo())).append(", ");
    str.append(Integer.toString(logonPass())).append(", ");
    str.append(Integer.toString(profile())).append(", ");
    str.append(quoteString(firstName())).append(", ");
    str.append(quoteString(lastName())).append(", ");
    str.append(quoteString(middleInitial())).append(", ");
    str.append(quoteString(SSN())).append(", ");
    str.append(Integer.toString(salaryGrade())).append(",");
    str.append(Double.toString(hourlyWage())).append(")");

    try {
      Application.dbConnection().execute(str.toString());
      Application.dbConnection().commit();
    } catch (SQLException e) {
      logger.warn("Update failed " + str.toString(), e);
    }
  }
Exemplo n.º 5
0
  public void populate(ResultSet rset) {

    try {
      setMenuID(rset.getInt("menu_id"));
      setConfigNo(rset.getInt("config_no"));
      setMenuXLoc(rset.getInt("xpos"));
      setMenuYLoc(rset.getInt("ypos"));
      setMenuHeight(rset.getInt("height"));
      setMenuWidth(rset.getInt("width"));
      setPixWidth(rset.getInt("pix_width"));
      setPixHeight(rset.getInt("pix_height"));
      setName(rset.getString("name"));
    } catch (java.sql.SQLException e) {
      Application.dbConnection().setException(e);
    }
  }
Exemplo n.º 6
0
  public void populate(ResultSet rset) {

    try {

      setEmployeeID(rset.getInt("employee_id"));
      setLogonNo(rset.getInt("logon_no"));
      setLogonPass(rset.getInt("logon_pass"));
      setProfile(rset.getInt("profile"));
      setFirstName(rset.getString("fname"));
      setLastName(rset.getString("lname"));
      setMiddleInitial(rset.getString("mi"));
      setSSN(rset.getString("ssn"));
      setSalaryGrade(rset.getInt("sal_grade"));
      setHourlyWage((double) rset.getFloat("hourly_wage"));
    } catch (java.sql.SQLException e) {
      Application.dbConnection().setException(e);
    }
  }
Exemplo n.º 7
0
 public void logon() {
   Timestamp stamp = new Timestamp((new Date()).getTime());
   SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
   try {
     Application.dbConnection()
         .execute(
             "INSERT into Employee_Timesheet (employee_id, logon_time, hourly_wage) VALUES ("
                 + employeeID()
                 + ",now(), "
                 + hourlyWage()
                 + ")");
   } catch (SQLException e) {
     logger.fatal(
         "Could not insert logon time for employee:"
             + employeeID()
             + " who logged on at "
             + df.format(stamp),
         e);
   }
 }
Exemplo n.º 8
0
  public Vector parents() {

    String fetchSpec = PosConfig.getByID(configNo());
    Vector v = Application.dbConnection().fetch(new PosConfig(), fetchSpec);
    return v;
  }
Exemplo n.º 9
0
  public void logoff() {
    Timestamp stamp = new Timestamp((new Date()).getTime());
    SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
    try {
      ResultSet rs =
          Application.dbConnection()
              .executeWithResult(
                  "SELECT max(employee_time_sheet_id) from Employee_TimeSheet where employee_id = "
                      + employeeID());

      if (rs.next()) {
        int timesheet_id = rs.getInt(1);

        Application.dbConnection()
            .execute(
                "UPDATE Employee_Timesheet SET logoff_time = now() WHERE employee_time_sheet_id = "
                    + timesheet_id);

        ResultSet rs2 =
            Application.dbConnection()
                .executeWithResult(
                    "SELECT logon_time, logoff_time, hourly_wage from Employee_Timesheet where employee_time_sheet_id = "
                        + timesheet_id);
        rs2.next();

        float hourlyWage = rs2.getFloat("hourly_wage");

        // NOTE  This is hacked to get the logoff time back from the DB.  Some DB's apparently
        // transpose the time, so as long as it's consistent amountOwed will be OK

        Timestamp logon_time = rs2.getTimestamp("logon_time");
        Timestamp logoff_time = rs2.getTimestamp("logoff_time");

        double hoursWorked =
            (logoff_time.getTime() - logon_time.getTime()) / (1000.0d * 60.0d * 60.0d);

        double amountOwed = hourlyWage * hoursWorked;

        Application.dbConnection()
            .execute(
                "UPDATE Employee_Timesheet SET amount_owed = "
                    + amountOwed
                    + " WHERE employee_time_sheet_id = "
                    + timesheet_id);

      } else {
        logger.error(
            "Could not find an appropriate logon entry for employee "
                + employeeID()
                + " who logged off at "
                + df.format(stamp));
      }
    } catch (SQLException e) {
      logger.fatal(
          "Could not insert logoff time for employee:"
              + employeeID()
              + " who logged off at "
              + df.format(stamp),
          e);
    }
  }