示例#1
0
  public void loadTableData() {

    while (tableModel1.getRowCount() > 0) {
      tableModel1.removeRow(0);
    }

    vatList = dbValue.getVatDetail();
    yearList = dbValue.getFinancialYearDetail();
    /*
     * Collections.sort(yearList, new Comparator<FinancialYearModal>() {
     *
     * @Override public int compare(FinancialYearModal year1,
     * FinancialYearModal year2) {
     *
     * if(year1.getStartYear()==year2.getStartYear()) return 0; else return
     * year1.getStartYear()-year2.getStartYear();
     *
     * } });
     */
    for (int i = 0; i < vatList.size(); i++) {
      int startYear = 0, endYear = 0;
      vatModel = vatList.get(i);
      for (FinancialYearModal yearModel : yearList) {
        if (yearModel.getYearId() == vatModel.getYearId()) {
          startYear = yearModel.getStartYear();
          endYear = yearModel.getEndYear();
        }
      }
      tableModel1.addRow(new Object[] {i + 1, vatModel.getVatPercent(), startYear, endYear});
    }
  }
示例#2
0
  private void save() {

    boolean status = true;
    if (valid.isEmpty(textField1.getText())) {
      status = false;
      new ValidationMSG(this, "Please Insert Start Year");
    } else if (valid.isEmpty(textField2.getText())) {
      status = false;
      new ValidationMSG(this, "Please Insert End Year");
    } else if (Integer.parseInt(textField1.getText()) >= Integer.parseInt(textField2.getText())) {
      status = false;
      new ValidationMSG(this, "Start year should be less then End year");
    } else if (valid.isEmpty(textField3.getText())) {
      status = false;
      new ValidationMSG(this, "Please Insert Vat %");
    }

    if (status) {
      VatModel vatModel = new VatModel();
      vatModel.setVatId(0);
      vatModel.setVatPercent(Float.parseFloat(textField3.getText()));
      vatModel.setYearId(
          tableid.getYearId(
              Integer.parseInt(textField1.getText()), Integer.parseInt(textField2.getText())));
      vatModel.setFirmId(1);
      vatModel.setVatUpdated(0);
      if (!dbinsert.insertVat(vatModel)) {
        new ValidationMSG(this, "Do not insert duplicate value");
      }
      reset();
      loadTableData();
    }
  }