private void exportButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_exportButtonActionPerformed
    if (masterTable.getSelectedRow() == -1) {
      return;
    }
    int y = -1;
    if (moneyTable.getRowSorter() == null) {
      month = "За весь период";
      m = -1;
    } else {
      month = monthComboBox.getItemAt(m).toString() + " " + yearField.getText();
      y = Integer.valueOf(yearField.getText());
    }
    int row = masterTable.getSelectedRow();

    String name = masterTable.getValueAt(row, 0).toString();

    int cust_id = (Integer) masterTable.getValueAt(row, 1);

    SaldoCalculator sc;
    double saldo = 0;
    try {
      sc = new CustomerSaldoCalculator(cust_id, m, y, db);
      sc.calculate();
      saldo = sc.finalSaldo;
    } catch (SQLException ex) {
      //            ex.printStackTrace();
    }

    Object add = masterTable.getValueAt(row, 2);
    if (add != null) {
      saldo += (Double) add;
    }

    XLCard exp = new XLCard(moneyTable, productTable, false);
    exp.setPersonName(name);
    exp.setMonth(month);
    exp.setSaldoBegin(saldo);
    try {
      exp.create();
    } catch (Exception ex) {
      //            JOptionPane.showMessageDialog(null, ex.getMessage());
      //            JOptionPane.showMessageDialog(null, ex.toString());
    }
  } // GEN-LAST:event_exportButtonActionPerformed
  private void filterButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_filterButtonActionPerformed
    m = monthComboBox.getSelectedIndex();
    String yearString = yearField.getText();
    if (yearString.equals("")) {
      JOptionPane.showMessageDialog(null, "Введите год", "Ошибка", JOptionPane.ERROR_MESSAGE);
      return;
    }
    int year = Integer.valueOf(yearString);
    infoLabel.setText(
        "Отображаются записи за "
            + monthComboBox.getSelectedItem().toString()
            + " "
            + yearString
            + " года.");
    infoLabel.setVisible(true);
    Date beginDate = new Date();
    Date endDate = new Date();
    beginDate.setYear(year - 1900);
    beginDate.setMonth(m);
    beginDate.setDate(0);
    endDate.setYear(year - 1900);
    endDate.setMonth(m);
    endDate.setDate(SaldoCalculator.daysQuantity(m, year));

    List<RowFilter<Object, Object>> filters = new ArrayList<>(2);
    filters.add(RowFilter.dateFilter(ComparisonType.AFTER, beginDate));
    filters.add(RowFilter.dateFilter(ComparisonType.BEFORE, endDate));

    TableRowSorter moneySorter = new TableRowSorter(moneyTable.getModel());
    moneySorter.setRowFilter(RowFilter.andFilter(filters));
    moneyTable.setRowSorter(moneySorter);

    TableRowSorter productSorter = new TableRowSorter(productTable.getModel());
    productSorter.setRowFilter(RowFilter.andFilter(filters));
    productTable.setRowSorter(productSorter);
  } // GEN-LAST:event_filterButtonActionPerformed