private void btnEditingActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnEditingActionPerformed try { DBCon db = new DBCon(); Home home = new Home(); if (TFhoemnumber.getText().isEmpty()) { JOptionPane.showMessageDialog(this, "Home number can not be null"); } else if (TFownername.getText().isEmpty()) { JOptionPane.showMessageDialog(this, "Please add owner name"); } else if (TFaddress.getText().isEmpty()) { JOptionPane.showMessageDialog(this, "Please enter the address"); } else if (TFmembers.getText().isEmpty()) { JOptionPane.showMessageDialog(this, "Enter the number of members"); } else { home.setHoemnumber(TFhoemnumber.getText()); home.setOwner(TFownername.getText()); home.setAddress(TFaddress.getText()); home.setTpnumber(TFtpnum.getText()); String str = TFmembers.getText(); int num = Integer.parseInt(str); home.setNumofmembers(num); db.editHomeDetails(home); JOptionPane.showMessageDialog(this, "Updated ..."); } } catch (Exception ex) { log.error("Error " + ex); JOptionPane.showMessageDialog(this, "Error, Home May Be Already In Database"); } } // GEN-LAST:event_btnEditingActionPerformed
private void btnDeleteActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDeleteActionPerformed int selectedOption = JOptionPane.showConfirmDialog( null, "Do you want to delete theis Home from the database?", "Choose", JOptionPane.YES_NO_OPTION); if (selectedOption == JOptionPane.YES_OPTION) { try { DBCon db = new DBCon(); String homenumber = TFhoemnumber.getText(); db.delHomedetails(homenumber); JOptionPane.showMessageDialog(this, "Deleted ..."); TFaddress.setText(""); TFhoemnumber.setText(""); TFmembers.setText(""); TFownername.setText(""); TFtpnum.setText(""); } catch (Exception ex) { log.error("Error " + ex); JOptionPane.showMessageDialog(this, "Error"); } } } // GEN-LAST:event_btnDeleteActionPerformed
private void btnSubmitActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnSubmitActionPerformed Home home = null; DBCon db = new DBCon(); try { home = db.searchHome(TFhoemnumber.getText()); } catch (Exception ex) { log.error("Error " + ex); JOptionPane.showMessageDialog(this, "Error"); } if (home == null) { JOptionPane.showMessageDialog(this, "Home not found..."); } TFownername.setText(home.getOwner()); TFaddress.setText(home.getAddress()); TFtpnum.setText(home.getTpnumber()); TFmembers.setText("" + home.getNumofmembers()); } // GEN-LAST:event_btnSubmitActionPerformed