コード例 #1
0
  public void save(File f) {
    Properties save = new Properties();
    OutputStream output = null;

    try {
      save.setProperty("provider", selectProviderCb.getValue());
      save.setProperty("grain", selectGrainCb.getValue());
      save.setProperty("weight", weightTf.getText());
      save.setProperty("info", infoTa.getText());

      for (Entry<String, TextField> entry : propertiesTf.entrySet()) {
        TextField tf = entry.getValue();
        String propertyName = entry.getKey();

        save.setProperty(propertyName, tf.getText());
        if (tf.isDisable()) {
          save.setProperty(propertyName + "_ENABLED", "OFF");
        } else {
          save.setProperty(propertyName + "_ENABLED", "ON");
        }
      }

      output = new FileOutputStream(f);
      save.store(output, null);
      mainStage.setTitle(f.getName());
    } catch (Exception ex) {
      infoTa.setText("Не могу сохранить в файл");
    } finally {
      if (output != null) {
        try {
          output.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
コード例 #2
0
  public void HandlerCalcPriceButton(ActionEvent event) {
    try {
      grain = getGrain(selectGrainCb.getValue());
      System.out.println("> " + grain.getName());

      try {
        grain.setWeight(Double.parseDouble(weightTf.getText()));
      } catch (NumberFormatException e) {
        weightTf.requestFocus();
        throw new NumberFormatException("Вес партии зерна");
      }

      for (Entry<String, TextField> entry : propertiesTf.entrySet()) {
        TextField tf = entry.getValue();
        String propertyName = entry.getKey();
        System.out.println("\t> " + propertyName);

        if (!tf.isDisable()) {
          try {
            grain.getProperty(propertyName).setValue(Double.parseDouble(tf.getText()));

          } catch (NumberFormatException e) {
            tf.requestFocus();
            throw new NumberFormatException(grain.getProperty(propertyName).getDescription());
          }

          grain.getProperty(propertyName).setEnabled(true);

        } else {
          grain.getProperty(propertyName).setEnabled(false);
        }
      }

      System.out.println("> before calculator");

      PriceCalculator calculator = new PriceCalculator(grain, dao);
      calculator.calculatePrice();
      infoTa.setText(calculator.toString());

      Supply supply = new Supply();
      supply.setProvider(selectProviderCb.getValue());
      supply.setDate(new Date(Calendar.getInstance().getTimeInMillis()));
      //            supply.setGrain(grain.getName());
      supply.setGrain(grain.getDescription());
      supply.setWeight(grain.getWeight());
      supply.setPrice(calculator.getPrice());

      dao.saveSupply(supply);

    } catch (RestrictiveConditionException e) {
      Utils.showErrorDialog("Ограшичительные кондиции!", e);
      infoTa.clear();
    } catch (DataBaseException e) {
      Utils.showErrorDialog("Обшибка базы данных!", e);
      infoTa.clear();
    } catch (NumberFormatException e) {
      Utils.showErrorDialog("Неверный ввод!", e);
      infoTa.clear();
    } catch (Exception ex) {
      Utils.showErrorDialog("Ошибка!", ex);
      infoTa.clear();
    }
  }
コード例 #3
0
  @FXML
  void Personal_Information_save(ActionEvent event) {
    RadioButton chk = null,
        chk1 = null,
        chk2 = null,
        chk3 = null,
        chk4 = null,
        chk5 = null,
        chk6 = null;
    chk = (RadioButton) phd_CS.getToggleGroup().getSelectedToggle();
    chk = (RadioButton) phd_ECE.getToggleGroup().getSelectedToggle();
    chk = (RadioButton) phd_CB.getToggleGroup().getSelectedToggle();
    chk1 = (RadioButton) gender_male.getToggleGroup().getSelectedToggle();
    chk1 = (RadioButton) gender_female.getToggleGroup().getSelectedToggle();
    chk2 = (RadioButton) Category_general.getToggleGroup().getSelectedToggle();
    chk2 = (RadioButton) Category_obc.getToggleGroup().getSelectedToggle();
    chk2 = (RadioButton) Category_st.getToggleGroup().getSelectedToggle();
    chk2 = (RadioButton) Category_sc.getToggleGroup().getSelectedToggle();
    chk3 = (RadioButton) physically_disabled_no.getToggleGroup().getSelectedToggle();
    chk3 = (RadioButton) physically_disabled_no.getToggleGroup().getSelectedToggle();
    chk4 = (RadioButton) children_yes.getToggleGroup().getSelectedToggle();
    chk4 = (RadioButton) children_no.getToggleGroup().getSelectedToggle();
    chk5 = (RadioButton) cgpa.getToggleGroup().getSelectedToggle();
    chk5 = (RadioButton) marks.getToggleGroup().getSelectedToggle();
    chk6 = (RadioButton) cgpa1.getToggleGroup().getSelectedToggle();
    chk6 = (RadioButton) marks1.getToggleGroup().getSelectedToggle();

    int check = 1;

    if (Email.getText().isEmpty()
        || Name.getText().isEmpty()
        || Address.getText().isEmpty()
        || mobile_no.getText().isEmpty()
        || chk == null
        || phd_ref1.getValue() == null
        || chk1 == null
        || chk2 == null
        || chk3 == null
        || DOB.getValue() == null
        || chk4 == null
        || father_name.getText().isEmpty()
        || nationality.getValue() == null
        || permanent_address.getText().isEmpty()
        || pin_code.getText().isEmpty()
        || tenth_board.getText().isEmpty()
        || tenth_marks.getText().isEmpty()
        || ten_year_passing.getValue() == null
        || twelth_board.getText().isEmpty()
        || twelth_marks.getText().isEmpty()
        || twelvth_year_passing.getValue() == null
        || degree.getText().isEmpty()
        || department.getText().isEmpty()
        || name_of_clg.getText().isEmpty()
        || name_of_uni.getText().isEmpty()
        || city.getText().isEmpty()
        || state.getValue() == null
        || year_of_graduation.getValue() == null
        || chk5 == null) {
      check = 0;
    }
    if (title1_handle.isSelected()) {
      if (Pref1.getValue() == null
          || Pref2.getValue() == null
          || Pref3.getValue() == null
          || Pref3.getValue() == null) check = 0;
    }
    if (title2_handle.isSelected()) {
      if (pg_degree.getText().isEmpty()
          || pg_department.getText().isEmpty()
          || pg_college.getText().isEmpty()
          || pg_title.getText().isEmpty()
          || pg_city.getText().isEmpty()
          || pg_state.getValue() == null
          || pg_year.getValue() == null
          || chk6 == null) {
        check = 0;
      }
    }

    if (title3_handle.isSelected()) {
      if (exam_name.getText().isEmpty()
          || exam_subject.getText().isEmpty()
          || exam_year.getValue() == null
          || exam_score.getText().isEmpty()
          || exam_rank.getText().isEmpty()) {
        check = 0;
      }
    }
    if (title4_handle.isSelected()) {
      if (gate_area.getText().isEmpty()
          || gate_year.getValue() == null
          || gate_marks.getText().isEmpty()
          || gate_score.getText().isEmpty()
          || gate_rank.getText().isEmpty()) {
        check = 0;
      }
    }

    if (check == 0) {
      label.setVisible(true);
      label.setText("Error Some feilds are not filled");
      label.setTextFill(Color.web("#FF0000"));
    }
    if (tenth_marks.getText().isEmpty() == false || twelth_marks.getText().isEmpty() == false) {

      try {
        Double.parseDouble(tenth_marks.getText());
        Double.parseDouble(twelth_marks.getText());

        if (Integer.parseInt(tenth_marks.getText()) < 0
            || Integer.parseInt(tenth_marks.getText()) > 100) {
          check = 0;
          label.setVisible(true);
          label.setText("10th marks are not in format");
          label.setTextFill(Color.web("#FF0000"));
        }

        if (Integer.parseInt(twelth_marks.getText()) < 0
            || Integer.parseInt(twelth_marks.getText()) > 100) {
          check = 0;
          label.setVisible(true);
          label.setText("12th marks are not in format");
          label.setTextFill(Color.web("#FF0000"));
        }

      } catch (Exception e) {
        check = 0;
        label.setVisible(true);
        label.setText("Marks are not in proper format");
        label.setTextFill(Color.web("#FF0000"));
      }
    }
    try {
      if (cgpa_text.getText().isEmpty() == false) {
        Double.parseDouble(cgpa_text.getText());
        if (Integer.parseInt(cgpa_text.getText()) < 0
            || Integer.parseInt(cgpa_text.getText()) > 10) {
          check = 0;
          label.setVisible(true);
          label.setText("Cgpa Marks is not in proper format");
          label.setTextFill(Color.web("#FF0000"));
        }
      }
    } catch (Exception e) {
      check = 0;
      label.setVisible(true);
      label.setText("Cgpa Marks is not in proper format");
      label.setTextFill(Color.web("#FF0000"));
    }
    try {
      if (pg_cgpa.getText().isEmpty() == false) {
        System.out.println("cfgh");
        Double.parseDouble(pg_cgpa.getText());
        if (Integer.parseInt(pg_cgpa.getText()) < 0 || Integer.parseInt(pg_cgpa.getText()) > 10) {
          check = 0;
          label.setVisible(true);
          label.setText("postgraduate cgpa marks is not in proper format");
          label.setTextFill(Color.web("#FF0000"));
        }
      }
    } catch (Exception e) {
      check = 0;
      label.setVisible(true);
      label.setText("postgraduate cgpa marks is not in proper format");
      label.setTextFill(Color.web("#FF0000"));
    }
    try {
      if (marks_text.getText().isEmpty() == false) {
        Double.parseDouble(marks_text.getText());
        if (Integer.parseInt(marks_text.getText()) < 0
            || Integer.parseInt(marks_text.getText()) > 100) {
          check = 0;
          label.setVisible(true);
          label.setText("Marks is not in proper format");
          label.setTextFill(Color.web("#FF0000"));
        }
      }
    } catch (Exception e) {
      check = 0;
      label.setVisible(true);
      label.setText("Marks is not in proper format");
      label.setTextFill(Color.web("#FF0000"));
    }
    try {

      if (pg_marks.getText().isEmpty() == false) {
        Double.parseDouble(pg_marks.getText());
        if (Integer.parseInt(pg_marks.getText()) > 100
            || Integer.parseInt(pg_marks.getText()) < 0) {
          check = 0;
          label.setVisible(true);
          label.setText("undergraduate Marks is not in proper format");
          label.setTextFill(Color.web("#FF0000"));
        }
      }
    } catch (Exception e) {
      check = 0;
      label.setVisible(true);
      label.setText("undergraduate Marks is not in proper format");
      label.setTextFill(Color.web("#FF0000"));
    }

    if (mobile_no.getText().length() != 10 && mobile_no.getText().isEmpty() == false) {
      check = 0;
      label.setVisible(true);
      label.setText("Mobile no. is not correct");
    }
    if (mobile_no.getText().length() == 10) {
      try {
        Double.parseDouble(mobile_no.getText());

      } catch (Exception e) {
        check = 0;
        label.setVisible(true);
        label.setText("Mobile no. is not correct");
      }
    }
    if (DOB.getValue() != null) {
      // System.out.println("shiko");
      DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
      Date date = new Date();
      String[] a = dateFormat.format(date).toString().split("-");
      String[] b = DOB.getValue().toString().split("-");
      System.out.println(Arrays.toString(a));
      System.out.println(Arrays.toString(b));
      if (Integer.parseInt(b[0]) - Integer.parseInt(a[0]) > 0) {
        // System.out.println("shiko1");
        check = 0;
        label.setVisible(true);
        label.setText("DOB is in future");
      } else if (b[0].compareTo(a[0]) == 0) {
        // System.out.println("shiko2");
        if (Integer.parseInt(b[1]) - Integer.parseInt(a[1]) > 0) {
          // System.out.println("shiko3");
          check = 0;
          label.setVisible(true);
          label.setText("DOB is in future");

        } else if (b[1].compareTo(a[1]) == 0) {
          System.out.println("shiko4");
          if (Integer.parseInt(b[2]) - Integer.parseInt(a[2]) > 0) {
            // System.out.println("shiko5");
            check = 0;
            label.setVisible(true);
            label.setText("DOB is in future");
          }
        }
      }
    }
    if (check == 1) {
      System.out.println("hello");
      File f = new File("./src/template.csv");
      File f1 = new File("./src/Feedback.csv");
      try {

        BufferedReader bw12 = new BufferedReader(new FileReader(f1));
        BufferedWriter bw2 = new BufferedWriter(new FileWriter(f));
        String line, Enrollement_id = "0";
        line = bw12.readLine();
        if (Integer.parseInt(Enrollement_id) == 0) {
          bw2.write(line);
          bw2.newLine();
        }
        while ((line = bw12.readLine()) != null) {
          String[] c = line.split(",");
          bw2.write(line);
          bw2.newLine();

          Enrollement_id = c[59];
          //	System.out.println(Enrollement_id.substring(3));
        }
        String text = "";
        text = text + Email.getText() + ",";
        text = text + Name.getText() + ",";
        text = text + Address.getText() + ",";
        text = text + mobile_no.getText() + ",";

        text = text + chk.getText() + ",";
        text = text + phd_ref1.getValue() + ",";
        text = text + phd_ref2.getValue() + ",";
        text = text + phd_ref3.getValue() + ",";

        text = text + chk1.getText() + ",";

        text = text + chk2.getText() + ",";

        text = text + chk3.getText() + ",";
        String[] dob = DOB.getValue().toString().split("-");

        String dob1 = dob[2] + "-" + dob[1] + "-" + dob[0];
        text = text + dob1 + ",";

        text = text + chk4.getText() + ",";

        text = text + father_name.getText() + ",";

        text = text + nationality.getValue().toString() + ",";
        text = text + permanent_address.getText() + ",";
        text = text + pin_code.getText() + ",";

        text = text + tenth_board.getText() + ",";
        text = text + tenth_marks.getText() + ",";
        text = text + ten_year_passing.getValue() + ",";
        text = text + twelth_board.getText() + ",";
        text = text + twelth_marks.getText() + ",";
        text = text + twelvth_year_passing.getValue() + ",";
        text = text + degree.getText() + ",";
        text = text + department.getText() + ",";
        text = text + name_of_clg.getText() + ",";
        text = text + name_of_uni.getText() + ",";
        text = text + city.getText() + ",";
        text = text + state.getValue() + ",";
        text = text + year_of_graduation.getValue() + ",";
        // RadioButton chk5;

        // System.out.println(Integer.parseInt(cgpa_text.getText()));
        if (cgpa.isSelected()) {

          Float a = Float.parseFloat(cgpa_combo.getValue().toString());
          // System.out.println(a+Float.parseFloat(cgpa_text.getText()));
          text = text + "CGPA:" + Float.toString(Float.parseFloat(cgpa_text.getText()) * a) + ",";
        } else if (marks.isSelected()) {
          text = text + "Marks:" + marks_text.getText().toString() + ",";
        }

        if (title1_handle.isSelected()) {
          text = text + "Yes" + ",";
          text = text + Pref1.getValue() + ",";
          text = text + Pref2.getValue() + ",";
          text = text + Pref3.getValue() + ",";
          text = text + Pref4.getValue() + ",";
        } else text = text + "No" + "," + "," + "," + "," + ",";
        if (title2_handle.isSelected()) {
          text = text + "Yes" + ",";
          text = text + pg_degree.getText() + ",";
          text = text + pg_department.getText() + ",";
          text = text + pg_college.getText() + ",";
          text = text + pg_title.getText() + ",";
          text = text + pg_city.getText() + ",";
          text = text + pg_state.getValue() + ",";

          text = text + pg_year.getValue() + ",";

          System.out.println("aasdf" + pg_marks.isDisable());

          if (pg_marks.isDisable()) {

            Float a = Float.parseFloat(pg_division.getValue().toString());
            // System.out.println(a+Float.parseFloat(cgpa_text.getText()));
            text = text + "CGPA:" + Float.toString(Float.parseFloat(pg_cgpa.getText()) * a) + ",";
          } else if (pg_cgpa.isDisable()) {
            text = text + "Marks:" + pg_marks.getText().toString() + ",";
          }
        } else text = text + "No" + "," + "," + "," + "," + "," + "," + "," + "," + ",";
        if (title3_handle.isSelected()) {
          text = text + "Yes" + ",";
          text = text + exam_name.getText() + ",";
          text = text + exam_subject.getText() + ",";
          text = text + exam_year.getValue() + ",";
          text = text + exam_score.getText() + ",";
          text = text + exam_rank.getText() + ",";

        } else text = text + "No" + "," + "," + "," + "," + "," + ",";
        if (title4_handle.isSelected()) {
          text = text + "Yes" + ",";
          text = text + gate_area.getText() + ",";
          text = text + gate_year.getValue() + ",";
          text = text + gate_marks.getText() + ",";
          text = text + gate_score.getText() + ",";
          text = text + gate_rank.getText() + ",";
        } else text = text + "No" + "," + "," + "," + "," + "," + ",";
        text = text + achievement.getText() + ",";
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
        Date date = new Date();
        text = text + dateFormat.format(date).toString() + ",";
        text = text + "PHD" + (Integer.parseInt(Enrollement_id.substring(3)) + 1) + ",";
        System.out.println(text);

        /*
















        */
        bw2.write(text);
        bw2.newLine();
        f1.delete();
        f.renameTo(f1);
        bw2.close();
        bw12.close();
        label.setVisible(true);
        label.setText("Database updated");
        label.setTextFill(Color.web("#FF0000"));

      } catch (IOException e) {

        e.printStackTrace();
      }
    }
  }