Вы находитесь на странице: 1из 1

private void cmdsimpanActionPerformed(java.awt.event.

ActionEvent evt) {

try{

koneksi();
String sql = "insert into t_rumah values ('"+ txttipe.getText()+"', '"
+ txtluastnh.getText() + "' , '" + txtluasbgn.getText() + "','" +
txtharga.getText() +"','" + txtuang.getText() + "')";
cn.executeUpdate(sql);
conn.close();

tampildata();
//bersih();
JOptionPane.showMessageDialog(null,"Data berhasil di simpan");

}catch (Exception e){


JOptionPane.showMessageDialog(null,"Proses penyimpanan gagal/koneksi
gagal..");
System.out.println(e.getMessage());
}

private void cmdhapusActionPerformed(java.awt.event.ActionEvent evt) {

try{
koneksi();
String sql = "delete from t_rumah " +
"where tipe='" + txttipe.getText() + "'";
cn.executeUpdate(sql);
cn.close();
tampildata();
}catch(Exception e){
JOptionPane.showMessageDialog(null," Gagal dihapus");
System.out.println(e.getMessage());
}

private void cmdubahActionPerformed(java.awt.event.ActionEvent evt) {

try{
koneksi();
String sql = "update t_rumah " +
"set tipe='" + txttipe.getText() + "' ," +
"uang_muka='" + txtuang.getText() + "' where tipe='"+
txttipe.getText() +"'";
cn.executeUpdate(sql);
conn.close();

tampildata();
//bersih();
JOptionPane.showMessageDialog(null,"Data berhasil di update");

}catch (Exception e){


JOptionPane.showMessageDialog(null,"Proses update gagal/koneksi gagal..");
System.out.println(e.getMessage());
}

Вам также может понравиться