Exemplo n.º 1
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() instanceof WebComboBox) {

      if (((WebComboBox) e.getSource()).getActionCommand().equals("crewSelectedChanged")) {
        if (cmbCrew.getSelectedItem() instanceof Crew) {

          autoSave();

          currentCrew = (Crew) cmbCrew.getSelectedItem();

          if (currentCrew != null) {

            // calendar = null;
            // calendar = new ExWebCalendar(currentDate, currentCrew.getSignOnDate());

            calendar.refresh(currentCrew.getSignOnDate());

            errorReportEntry = new ErrorReportEntry();
            errorReportEntry.setEntryDate(getDate(currentDate));
            errorReportEntry.setCrew(currentCrew);
          }

          getSchedule(currentDate);
        }
      }

    } else {
      WebButton btnSource = (WebButton) e.getSource();

      if (btnSource.getClientProperty("command").equals("saveAndNext")) {

        if (currentCrew == null) {
          NotificationManager.showPopup(getOwner(), cmbCrew, new String[] {"Please select crew"});
          return;
        }

        // saveRestingHour();
        // calendar.moveToNext();
        // Calendar calNext = Calendar.getInstance();
        // calNext.setTime(currentDate);
        // calNext.add(Calendar.DAY_OF_MONTH, 1);

        // calendar.setDate(calNext.getTime());

      } else if (btnSource.getClientProperty("command").equals("new")) {

      } else if (btnSource.getClientProperty("command").equals("save")) {

        if (currentCrew == null) {
          NotificationManager.showPopup(getOwner(), cmbCrew, new String[] {"Please select crew"});
          return;
        }

        saveRestingHour();
      }
    }
  }
Exemplo n.º 2
0
  private void saveRestingHour() {

    if (currentCrew != null) {
      EntryTime entryTime = new EntryTime();

      entryTime.setEntryDate(getDate(currentDate));
      entryTime.setCrewId(currentCrew.getId());
      entryTime.setComments(txtComments.getText());
      entryTime.setOnPort(chkOnPort.isSelected());
      entryTime.setSchedule(timeSheet.getSchedule());
      entryTime.setWorkIn24Hours(timeSheet.getTotalWork());
      entryTime.setRestIn24Hours(timeSheet.getTotalRest());

      if (entryTimeDao.addUpdateEntry(entryTime) > 0) {

        if (errorReportEntry != null) new ReportDAO().addErrorReportEntry(errorReportEntry);

        NotificationManager.showNotification(
            "<html>Resting hours has been saved for<br/>"
                + CalendarUtil.format("MMM dd, yyyy", getDate(currentDate))
                + "</html>");
      }
    }
  }