Пример #1
0
  private void btnDeleteActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDeleteActionPerformed
    // TODO add your handling code here:
    int response =
        JOptionPane.showConfirmDialog(
            null,
            "Do you want to delete data Permanently?",
            "Confirm",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE);
    if (response == JOptionPane.NO_OPTION) {

    } else if (response == JOptionPane.YES_OPTION) {
      try {
        connection c = new connection();
        Connection con = c.conn();
        Statement stmt1 = con.createStatement();
        int i = stmt1.executeUpdate("delete from tbl_account_VK  where vk_Id=" + vk_Id);
        if (i != 0) {
          dispose();
          viewSVS_PersonalForm();
        }
      } catch (Exception e) {
        JOptionPane.showMessageDialog(rootPane, e, "ERROR!!", JOptionPane.ERROR_MESSAGE);
      }
    } else if (response == JOptionPane.CLOSED_OPTION) {

    }
  } // GEN-LAST:event_btnDeleteActionPerformed
Пример #2
0
  public void updateDb() {

    connection c = new connection();
    Connection con = c.conn();
    try {
      PreparedStatement ps =
          con.prepareStatement(
              "UPDATE tbl_account_VK SET transDate=?,debit=?,credit=?,description=? where vk_Id=?");
      ps.setString(1, todaydate);
      ps.setString(2, txtDebit.getText());
      ps.setString(3, txtCredit.getText());
      ps.setString(4, txtDescription.getText());
      ps.setInt(5, vk_Id);
      int i = ps.executeUpdate();
      if (i != 0) {
        dispose();
        viewSVS_PersonalForm();
      }
      con.close();
      balance = 0;
    } catch (Exception e) {
      balance = 0;
      JOptionPane.showMessageDialog(rootPane, e, "ERROR!!", JOptionPane.ERROR_MESSAGE);
    }
  }
Пример #3
0
  public void truncateTempDbTable() {
    connection c = new connection();
    Connection con = c.conn();
    try {
      PreparedStatement ps = con.prepareStatement("TRUNCATE TABLE tbl_temp_account_VK");
      int i = ps.executeUpdate();
      if (i != 0) {}

      con.close();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(rootPane, e, "ERROR!!", JOptionPane.ERROR_MESSAGE);
      // JOptionPane.showMessageDialog(rootPane,e+"Error SA001");
    }
  }
Пример #4
0
  public void insertIntoTempDbTable() {
    connection c = new connection();
    Connection con = c.conn();
    try {
      PreparedStatement ps =
          con.prepareStatement(
              "INSERT INTO tbl_temp_account_VK (vk_Id,transDate,debit,credit,description) SELECT * FROM tbl_account_VK ORDER BY transDate,vk_Id");
      int i = ps.executeUpdate();
      if (i != 0) {}

      con.close();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(rootPane, e, "ERROR!!", JOptionPane.ERROR_MESSAGE);
      // JOptionPane.showMessageDialog(rootPane,e+"Error SA001");
    }
  }
Пример #5
0
 public void insertIntoDb() {
   connection c = new connection();
   Connection con = c.conn();
   try {
     PreparedStatement ps =
         con.prepareStatement(
             "INSERT INTO tbl_account_VK(transDate,debit,credit,description) VALUES(?,?,?,?)");
     ps.setString(1, todaydate);
     ps.setString(2, txtDebit.getText());
     ps.setString(3, txtCredit.getText());
     ps.setString(4, txtDescription.getText());
     int i = ps.executeUpdate();
     if (i != 0) {
       dispose();
       viewSVS_PersonalForm();
     }
     con.close();
   } catch (Exception e) {
     JOptionPane.showMessageDialog(rootPane, e, "ERROR!!", JOptionPane.ERROR_MESSAGE);
     // JOptionPane.showMessageDialog(rootPane,e+"Error SA001");
   }
 }
Пример #6
0
  public void viewDbSVS_Personal() {
    truncateTempDbTable();
    insertIntoTempDbTable();
    connection c = new connection();
    Connection con = c.conn();
    try {
      Statement stmt = con.createStatement();
      ResultSet rs =
          stmt.executeQuery(
              "SELECT X.vk_Id,X.transDate,X.description, X.debit, X.credit, SUM(Y.bal) balance FROM( SELECT *,credit-debit bal FROM tbl_temp_account_VK) X JOIN( SELECT *,credit-debit bal FROM tbl_temp_account_VK) Y ON Y.id <= X.id WHERE MONTH(X.transDate)=MONTH(CURRENT_DATE) and YEAR(X.transDate)=YEAR(CURRENT_DATE) GROUP BY X.id");
      jTable1.setModel(DbUtils.resultSetToTableModel(rs));

      jTable1.getColumnModel().getColumn(0).setMinWidth(50);
      jTable1.getColumnModel().getColumn(0).setMaxWidth(50);

      jTable1.getColumnModel().getColumn(1).setMinWidth(100);
      jTable1.getColumnModel().getColumn(1).setMaxWidth(100);

      jTable1.getColumnModel().getColumn(3).setMinWidth(100);
      jTable1.getColumnModel().getColumn(3).setMaxWidth(100);

      jTable1.getColumnModel().getColumn(4).setMinWidth(100);
      jTable1.getColumnModel().getColumn(4).setMaxWidth(100);

      jTable1.getColumnModel().getColumn(5).setMinWidth(100);
      jTable1.getColumnModel().getColumn(5).setMaxWidth(100);

      jTable1.getColumnModel().getColumn(1).setCellRenderer(new DateCellRenderer());
      jTable1.getColumnModel().getColumn(3).setCellRenderer(NumberRenderer.getIntegerRenderer());
      jTable1.getColumnModel().getColumn(4).setCellRenderer(NumberRenderer.getIntegerRenderer());
      jTable1.getColumnModel().getColumn(5).setCellRenderer(NumberRenderer.getIntegerRenderer());
      jTable1.setAutoCreateRowSorter(true);
      con.close();

    } catch (Exception e) {

    }
  }
Пример #7
0
  public void getDetailsAcbqId() {
    try {
      connection c = new connection();
      Connection con = c.conn();
      Statement stmt = con.createStatement();
      ResultSet rs =
          stmt.executeQuery(
              "SELECT transDate,debit,credit,description FROM tbl_account_VK where vk_Id=" + vk_Id);
      while (rs.next()) {
        try {
          jDate.setDate(dateFormat.parse(rs.getString("transDate")));
        } catch (ParseException ex) {
          Logger.getLogger(LabourDetails.class.getName()).log(Level.SEVERE, null, ex);
        }
        txtDebit.setText(rs.getString("debit"));
        txtCredit.setText(rs.getString("credit"));
        txtDescription.setText(rs.getString("description"));
      }
      con.close();
    } catch (SQLException ex) {

    }
  }