Pengolahan data penjualan menggunakan Java Server Pages

Berikut Contoh Proggram pengolahan data penjualan handphon 


  • Buat Desain Form
    • Buat file Servlet dengan script
    • out.println(""); String nota = request.getParameter("nota"); if(nota.equals("")){ out.println("Nota Tidak Boleh kosong.kembali"); } int ada=0; try { stmt = conn.createStatement(); String query = "SELECT * FROM tbl_penjualan WHERE nota = '"+nota+"'"; ResultSet rs= stmt.executeQuery(query); while(rs.next()){ ada++; } } catch (Exception e){ out.println(e.toString()); } if (ada !=0){ out.println("Nota sudah ada.kembali"); return; } String nama = request.getParameter("nama"); if(nama.equals("")){ out.println("Nama TIDAK BOLEH KOSONG.kembali"); } int nm=0; try { stmt = conn.createStatement(); String query = "SELECT * FROM tbl_penjualan WHERE nama = '"+nama+"'"; ResultSet rs= stmt.executeQuery(query); while(rs.next()){ nm++; } } catch (Exception e){ out.println(e.toString()); } String alamat = request.getParameter("alamat"); if(alamat.equals("")){ out.println("Alamat Tidak Boleh kosong.kembali"); } int al=0; try { stmt = conn.createStatement(); String query = "SELECT * FROM tbl_penjualan WHERE alamat = '"+alamat+"'"; ResultSet rs= stmt.executeQuery(query); while(rs.next()){ al++; } } catch (Exception e){ out.println(e.toString()); } String merek = request.getParameter("merek"); if(merek.equals("")){ out.println("Merek Hp Tidak Boleh kosong.kembali"); } int mr=0; try { stmt = conn.createStatement(); String query = "SELECT * FROM tbl_penjualan WHERE merek = '"+merek+"'"; ResultSet rs= stmt.executeQuery(query); while(rs.next()){ mr++; } } catch (Exception e){ out.println(e.toString()); } String jbl = request.getParameter("jbl"); String harga = request.getParameter("harga"); if(harga.equals("")){ out.println("Harga Tidak Boleh kosong.kembali"); } int hg=0; try { stmt = conn.createStatement(); String query = "SELECT * FROM tbl_penjualan WHERE harga = '"+harga+"'"; ResultSet rs= stmt.executeQuery(query); while(rs.next()){ hg++; } } catch (Exception e){ out.println(e.toString()); } out.println("data anda
      "); out.println("Nota :"+ nota + "
      "); out.println("nama :"+ nama + "
      "); out.println("Alamat :"+ alamat + "
      "); out.println("Merek Hp :"+ merek + "
      "); out.println("jumlah Jual :"+ jbl + "
      "); out.println("
      "); out.println("Harga :"+ harga + "
      "); try { stmt = conn.createStatement(); String query; query = "INSERT INTO tbl_penjualan VALUES('"+nota+"','"+nama+"','"+alamat+"','"+merek+"','"+jbl+"','"+harga+"')"; stmt.executeUpdate(query); out.println("Data Berhasil Disimpan"); out.println("Lihat Data"); }catch (Exception e){ out.println(e.toString()); } out.println("
    ");

    Download project 

Categories: , Share