Пример #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 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");
   }
 }
Пример #3
0
 private void btnPersonData() {
   Persons temp =
       new SearchPersons(manageEdit, true, mdlEmployees.getQueryManager(), 2).personShowSearch();
   edicion = temp.getPersonId();
   manageEdit.setFieldsValue(
       temp.getCedula(),
       temp.getCellphone(),
       temp.getLastName(),
       temp.getName(),
       temp.getTelephone());
   return;
 }
Пример #4
0
 public void update(boolean isDoctor) {
   int i =
       JOptionPane.showConfirmDialog(
           manageEdit,
           "Realmente desea Sobreescribir Los Datos de Este Cliente?",
           "Atencion",
           JOptionPane.OK_CANCEL_OPTION,
           JOptionPane.QUESTION_MESSAGE);
   if (i == 0) {
     if (isDoctor == true) {
       mdlEmployees.updateObject(tempDoctor);
     } else {
       mdlEmployees.updateObject(tempEmployee);
     }
     JOptionPane.showMessageDialog(
         manageEdit,
         "Registro Actualizado Exitosamente",
         "Informacion",
         JOptionPane.INFORMATION_MESSAGE);
     manageEdit.dispose();
   }
 }
Пример #5
0
  @Override
  public void insert() {
    try {
      String i;
      if (manageEdit.getjRadioButtonDoctor().isSelected()) {
        i = "Doctor";
        tempDoctor =
            new Doctor(
                manageEdit.getTxtFieldName().getText(),
                manageEdit.getTxtFieldLastName().getText(),
                manageEdit.getTxtFieldCedula().getText(),
                manageEdit.getTxtFieldJobPosition().getText(),
                manageEdit.getTxtFieldSpeciality().getText(),
                manageEdit.getTxtFieldPhone().getText(),
                manageEdit.getTxtFieldCellPhone().getText());
        mdlEmployees.insertObject(tempDoctor);
      } else {
        i = "Normal";
        tempEmployee =
            new Employees(
                manageEdit.getTxtFieldName().getText(),
                manageEdit.getTxtFieldLastName().getText(),
                manageEdit.getTxtFieldCedula().getText(),
                manageEdit.getTxtFieldJobPosition().getText(),
                manageEdit.getTxtFieldPhone().getText(),
                manageEdit.getTxtFieldCellPhone().getText());
        mdlEmployees.insertObject(tempEmployee);
      }

      JOptionPane.showMessageDialog(
          manageEdit,
          "Registro Insertado Exitosamente",
          "Informacion",
          JOptionPane.INFORMATION_MESSAGE);
      manageEdit.dispose();
    } catch (Exception ex) {
      Logger.getLogger(ControllerEmployee.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Пример #6
0
 public void searchByField(String string) {
   modelSearching.setElements(mdlEmployees.searchAllEmployeeByName("%" + string + "%"));
 }
Пример #7
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();
    }
  }