Пример #1
0
 @Override
 public void btnUpdate() {
   if (edicion != 0) {
     manageEdit = new ManageEmployeesEdit(null, true, this);
     if (mdlEmployees.checkIsDoctor(edicion)) {
       tempDoctor = mdlEmployees.searchDoctorEmployee(edicion);
       manageEdit.setFieldsValueDoctor(
           tempDoctor.getCedula(),
           tempDoctor.getCellphone(),
           tempDoctor.getPosition(),
           tempDoctor.getLastName(),
           tempDoctor.getName(),
           tempDoctor.getTelephone(),
           tempDoctor.getSpeciality());
       isDoctor = true;
     } else {
       tempEmployee = mdlEmployees.searchEmployee(edicion);
       manageEdit.setFieldsValue(
           tempEmployee.getCedula(),
           tempEmployee.getCellphone(),
           tempEmployee.getPosition(),
           tempEmployee.getLastName(),
           tempEmployee.getName(),
           tempEmployee.getTelephone(),
           "");
       isDoctor = false;
     }
     manageEdit.showFrame();
     edicion = 0;
     return;
   } 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();
    }
  }