private void tambahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tambahActionPerformed
         try {
            Class.forName ("com.mysql.jdbc.Driver");
            String urldb="jdbc:mysql://localhost:3306/restaurant";
            String user=main.dbUser;
            String password=main.dbPassword;
            DefaultTableModel tbl =(DefaultTableModel) tbldetail.getModel();
            
            Connection koneksi=java.sql.DriverManager.getConnection(urldb,user,password);
            String strSQL = "insert into `pesanan`(`no_meja`, `username`, `tgl_pesanan`, `lunas`) "
                          + "values('"+(meja.getSelectedIndex()+1)+"','"+main.username+"',CURRENT_TIMESTAMP, 0)";

            Statement st = koneksi.createStatement();
            st.executeUpdate(strSQL);
            
            int no_pesanan = cariNoPesananTerakhir();
            String nama_makanan;
            int jumlah = 0;
            String sql;
            
            for (int i = 0; i < tbldetail.getRowCount(); i++){
                nama_makanan = tbl.getValueAt(i, 0).toString();
                jumlah = Integer.parseInt(tbl.getValueAt(i, 1).toString());
                sql = "insert into detail_pesanan(`no_pesanan`,`nama`,`jumlah`) values('"+no_pesanan+"','"+nama_makanan+"','"+jumlah+"')";
                st.executeUpdate(sql);
            }
            st.close();
            koneksi.close();
        }catch(ClassNotFoundException cnfe){
            System.out.println("kesalahan saat"+"me-load driver jdbc \n"+cnfe.getMessage());
        }catch(SQLException sqle){
            System.out.println("keslahan saat koneksi atau "+"kesalahan query sql \n"+sqle.getMessage());
        }
    }//GEN-LAST:event_tambahActionPerformed