private void onOK() {
    try {
      if (!updateModel()) return;

      ShiftDAO dao = new ShiftDAO();
      if (shift.getId() == null && dao.exists(shift.getName())) {
        POSMessageDialog.showError(this, com.floreantpos.POSConstants.SHIFT_NAME_ALREADY_EXISTS);
        return;
      }
      dao.saveOrUpdate(shift);

      setCanceled(false);

      dispose();
    } catch (Exception e) {
      POSMessageDialog.showError(this, com.floreantpos.POSConstants.ERROR_SAVING_SHIFT_STATE, e);
    }
  }
  public void updateView() {
    if (shift == null) {
      return;
    }

    tfShiftName.setText(shift.getName());

    Date startTime = shift.getStartTime();
    Date endTime = shift.getEndTime();

    Calendar c = Calendar.getInstance();
    c.setTime(startTime);

    startHour.setSelectedIndex(c.get(Calendar.HOUR) - 1);
    startMin.setSelectedIndex(c.get(Calendar.MINUTE));
    startAmPm.setSelectedIndex(c.get(Calendar.AM_PM) == Calendar.AM ? 0 : 1);

    c.setTime(endTime);
    endHour.setSelectedIndex(c.get(Calendar.HOUR) - 1);
    endMin.setSelectedIndex(c.get(Calendar.MINUTE));
    endAmPm.setSelectedIndex(c.get(Calendar.AM_PM) == Calendar.AM ? 0 : 1);
  }