Пример #1
0
 @Override
 public void btnRemove() {
   if (edicion != 0) {
     int i =
         JOptionPane.showConfirmDialog(
             manageMenu,
             "Realmente desea Eliminar Este Usuario?",
             "Atencion",
             JOptionPane.OK_CANCEL_OPTION,
             JOptionPane.QUESTION_MESSAGE);
     if (i == 0) {
       mdlEmployees.deleteObject(mdlEmployees.searchEmployee(edicion));
       javax.swing.JOptionPane.showMessageDialog(manageMenu, "Registro Eliminado");
     }
     searchByField(manageMenu.getSearching().getTxtSearch().getText().toLowerCase());
     edicion = 0;
   } else {
     javax.swing.JOptionPane.showMessageDialog(manageMenu, "No Ha Sido Seleccionado Un Registro");
   }
 }
Пример #2
0
  @Override
  public void btnSave() {
    if (manageEdit.getjRadioButtonNormal().isSelected()) {
      manageEdit.getTxtFieldSpeciality().setText("Sorry 4 Wait");
    }
    if (isEmptyFields()) {
      JOptionPane.showMessageDialog(
          manageEdit,
          "Existen Campos En Blancos Por Favor Completar",
          "Error",
          JOptionPane.ERROR_MESSAGE);
      return;
    }
    if (edicion != 0) {
      if (mdlEmployees.checkIsDoctor(edicion)) {
        if (manageEdit.getjRadioButtonDoctor().isSelected()) {
          isDoctor();
          if (mdlEmployees.checkDuplicateCedula(manageEdit.getTxtFieldCedula().getText())) {
            if (tempDoctor.getCedula().equalsIgnoreCase(manageEdit.getTxtFieldCedula().getText())) {
              update(true);
            } else {
              JOptionPane.showMessageDialog(
                  manageEdit,
                  "Existe Otro Usuario Con El Mismo Numero de Cedula",
                  "Error GRAVE",
                  JOptionPane.ERROR_MESSAGE);
            }
          } else {
            tempDoctor.setCedula(manageEdit.getTxtFieldCedula().getText());
            update(true);
          }

        } else {
          mdlEmployees.deleteObject(tempDoctor);
          tempEmployee = new Employees();
          tempEmployee.setPersonId(edicion);
          isEmployee();
          if (mdlEmployees.checkDuplicateCedula(manageEdit.getTxtFieldCedula().getText())) {
            if (tempEmployee
                .getCedula()
                .equalsIgnoreCase(manageEdit.getTxtFieldCedula().getText())) {
              update(false);
            } else {
              JOptionPane.showMessageDialog(
                  manageEdit,
                  "Existe Otro Usuario Con El Mismo Numero de Cedula",
                  "Error GRAVE",
                  JOptionPane.ERROR_MESSAGE);
            }
          } else {
            tempEmployee.setCedula(manageEdit.getTxtFieldCedula().getText());
            update(false);
          }
        }

      } else {
        if (manageEdit.getjRadioButtonNormal().isSelected()) {
          isEmployee();
          if (mdlEmployees.checkDuplicateCedula(manageEdit.getTxtFieldCedula().getText())) {
            if (tempEmployee
                .getCedula()
                .equalsIgnoreCase(manageEdit.getTxtFieldCedula().getText())) {
              update(true);
            } else {
              JOptionPane.showMessageDialog(
                  manageEdit,
                  "Existe Otro Usuario Con El Mismo Numero de Cedula",
                  "Error GRAVE",
                  JOptionPane.ERROR_MESSAGE);
            }
          } else {
            tempEmployee.setCedula(manageEdit.getTxtFieldCedula().getText());
            update(true);
          }
        } else {
          mdlEmployees.deleteObject(tempEmployee);
          tempDoctor = new Doctor();
          tempDoctor.setPersonId(edicion);
          isDoctor();
          if (mdlEmployees.checkDuplicateCedula(manageEdit.getTxtFieldCedula().getText())) {
            if (tempDoctor.getCedula().equalsIgnoreCase(manageEdit.getTxtFieldCedula().getText())) {
              update(true);
            } else {
              JOptionPane.showMessageDialog(
                  manageEdit,
                  "Existe Otro Usuario Con El Mismo Numero de Cedula",
                  "Error GRAVE",
                  JOptionPane.ERROR_MESSAGE);
            }
          } else {
            tempDoctor.setCedula(manageEdit.getTxtFieldCedula().getText());
            update(true);
          }
        }
      }
    } else {
      if (mdlEmployees.checkDuplicateCedula(manageEdit.getTxtFieldCedula().getText())) {
        JOptionPane.showMessageDialog(
            manageEdit,
            "Existe Otro Cliente Con El Mismo Numero de Cedula",
            "Error GRAVE",
            JOptionPane.ERROR_MESSAGE);
        return;
      }
      insert();
    }
  }