@FXML
  private void handleDeleteDepartment() {
    int selectedIndex = departmentTable.getSelectionModel().getSelectedIndex();
    if (selectedIndex >= 0) {
      for (int i = main.getEmployees().size() - 1; i >= 0; i--) {
        ViewEmployee vEmp = main.getEmployees().get(i);
        if (vEmp.getDepartment()
            .equals(departmentTable.getSelectionModel().getSelectedItem().getName())) {
          for (ViewDepartment vDep : main.getDepartments()) {
            if (vDep.getDirectorName().equals(vEmp.getLastName() + " " + vEmp.getFirstName())) {
              vDep.setDirectorName("-");
            }
          }
          main.getEmployees().remove(vEmp);
        }
      }
      con.deleteDepartment(departmentTable.getSelectionModel().getSelectedItem().getId());
      departmentTable.getItems().remove(selectedIndex);
    } else {
      Alert alert = new Alert(AlertType.WARNING);
      alert.initOwner(main.getPrimaryStage());
      alert.setTitle("Ничего не выбрано");
      alert.setHeaderText("Не выбран отдел");
      alert.setContentText("Пожалуйста, выберите отдел");

      alert.showAndWait();
    }
  }
  @FXML
  private void handleEditDepartment() {

    ViewDepartment selectedDepartment = departmentTable.getSelectionModel().getSelectedItem();
    if (selectedDepartment != null) {
      boolean okClicked = main.showDepartmentEditDialog(selectedDepartment, false);
      if (okClicked) {}

    } else {
      Alert alert = new Alert(AlertType.WARNING);
      alert.initOwner(main.getPrimaryStage());
      alert.setTitle("Ничего не выбрано");
      alert.setHeaderText("Ни один отдел не выбран");
      alert.setContentText("Пожалуйста, выберите отдел в таблице");

      alert.showAndWait();
    }
  }