PROJECT TUGAS UJIAN AKHIR SEMESTER

Program ini sebagai salah satu syarat penilaian Ujian Akhir Semester.

Nama : Bunga Hexa Meilana
NIM   : 171021700008
Project: Pembuatan Pendaftaran vaksin

Memberikan deskripsi tentang program yang telah dibuat.
Project ini dibuat untuk mempermudah pekerjaan seseorang, saat ini kebanyakan sekolah dasar membutuhkan data anak-anak yang akan masuk mendaftar sekolah untuk sudah melakukan vaksin melalui catatan buku vaksin yang diberikan ketika anak tersebut melakukan pengecekkan. Dengan kata lain project ini dapat membantu sebagian besar orang tua untuk mengetahui anaknya melakukan vaksin jika dilain waktu mereka lupa sudah/belum melakukannya.

PROGRAM PENDAFTARAN VAKSIN
Berikut Deskripsinya;


1. Deskripsi

Aplikasi ini dibuat untuk mempermudah pekerjaan seseorang dalam mendata pendaftaran pasien melakukan vaksin. Sewaktu-waktu data tersebut dapat diupdate jika ada data pasien yang ingin diganti (Misalkan; menganti re-schedule dokter, vaksin yang akan disuntikkan). Data tersebut juga dapat dihapus kapanpun. 

INPUT

Project ini dibuat untuk memudahkan karyawan dalam mendata pasien yang akan melakukan suntik vaksin. Data berisikan no pasien, nama pasien, tahun lahir, umur, jenis kelamin, pemilihan dokter, dan jenis vaksin yang akan disuntikkan.

PROSES

Proses project ini berjalan ketika karyawan memasukkan data pasien yang ada. Proses yang dilakukan adalah; Karyawan memasukan input data ke program yang telah disediakan (data yang dimasukkan; no pasien, tahun lahir, umur, jenis kelamin, pemilihan dokter, dan jenis vaksin yang akan disuntikkan). Setelah mengisi data pasien, data tersebut akan di simpan pada table. Table yang memuat data pasien yang telah di input melalui database.

OUTPUT

Hasil dari input database dan proses dalam pendaftar data pasien vaksin, menghasilkan daftar data pasien yang telah tersimpan pada table. Jika pada lain kesempatan seorang pasien ingin kembali melakukan vaksin, data yang telah tersimpan dapat digunakan kembali atau diupdate sesuai data yang ada. Sehingga tidak perlu karyawan melakukan pendataan berulang kali.


2. FLOWCHART





3. RUNNING PROGRAM



3.1 DATABASE & NETBEANS



3.2 DATABASE FORMPASIEN



3.3 HASIL RUNNING






3.4 MAIN PAGE




3.5 INPUT DATA




4. SOURCE CODE

import javax.swing.table.DefaultTableModel;
import java.text.SimpleDateFormat;
import com.mysql.jdbc.Statement;
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import koneksi.conek;
import java.util.Scanner;
import java.util.Date;
import java.text.ParseException;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Hisyam9964
 */
public class FrameComboBoxUTS extends javax.swing.JFrame {
    int nomer = 0;
    String key; 
    Scanner in = new Scanner(System.in);
    /**
     * Creates new form form_mahasiswa
     */
    public FrameComboBoxUTS() {
        initComponents();
        datatable();
        
    }
    public void datatable(){
    DefaultTableModel tbl=new DefaultTableModel();
    tbl.addColumn("No Urut");
    tbl.addColumn("Id Pasien");
    tbl.addColumn("Nama Pasien");
    tbl.addColumn("Tanggal Lahir");
    tbl.addColumn("Kelamin");
    tbl.addColumn("Umur");
    tbl.addColumn("Nama Dokter");
    tbl.addColumn("Jenis Imunisasi");
    tbl1.setModel(tbl);
    
    try{
        Statement statement=(Statement)conek.GetConnection().createStatement();
        ResultSet res=statement.executeQuery("Select * from formpasien");
        while(res.next())
        {
            tbl.addRow(new Object[]{
            res.getString("NoUrut"),
            res.getString("KodePasien"),
            res.getString("NamaPasien"),
            res.getString("TanggalLahir"),
            res.getString("JenisKelamin"),
            res.getString("Umur"),
            res.getString("Dokter"),
            res.getString("JenisImunisasi")
            });
            tbl1.setModel(tbl);
            nomer = res.getInt("NoUrut");
        }   
    }
    catch (Exception e){
        JOptionPane.showMessageDialog(rootPane, "salah");
    }
        
        
    }
    
    public SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy");
      /*nomer = nomer + 1;*/
      String gender ;
      String Vaksin = "";
      int check = 0;
        
    /**
     * Creates new form FrameComboBoxUTS
     */
    /*public FrameComboBoxUTS() {
        initComponents();
    }*/

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox8 = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        TxtNPasien = new javax.swing.JTextField();
        JrLaki = new javax.swing.JRadioButton();
        JrPerempuan = new javax.swing.JRadioButton();
        CMbDokter = new javax.swing.JComboBox<>();
        jLabel7 = new javax.swing.JLabel();
        ChkP1 = new javax.swing.JCheckBox();
        ChkP2 = new javax.swing.JCheckBox();
        ChkRtv = new javax.swing.JCheckBox();
        ChkHpB = new javax.swing.JCheckBox();
        ChkCmpk = new javax.swing.JCheckBox();
        ChkPcv = new javax.swing.JCheckBox();
        ChkMmr = new javax.swing.JCheckBox();
        ChkHpv = new javax.swing.JCheckBox();
        tgllahir = new org.jdesktop.swingx.JXDatePicker();
        TxtUmur = new javax.swing.JTextField();
        CmbSimpan = new javax.swing.JButton();
        CmbExit = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbl1 = new javax.swing.JTable();
        jLabel8 = new javax.swing.JLabel();
        TxtNoPasien = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        CmbBatal = new javax.swing.JButton();
        CmbHapus = new javax.swing.JButton();
        CmbUpdate = new javax.swing.JButton();

        jCheckBox1.setText("jCheckBox1");

        jCheckBox8.setText("jCheckBox2");
        jCheckBox8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox8ActionPerformed(evt);
            }
        });

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });

        jLabel1.setText("Id Pasien");

        jLabel2.setText("Nama Pasien");

        jLabel3.setText("Jenis Imunisasi");

        jLabel4.setText("Tanggal Lahir");

        jLabel5.setText("Jenis Kelamin");

        jLabel6.setText("Umur");

        TxtNPasien.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TxtNPasienActionPerformed(evt);
            }
        });

        buttonGroup1.add(JrLaki);
        JrLaki.setText("Laki-Laki");
        JrLaki.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JrLakiActionPerformed(evt);
            }
        });

        buttonGroup1.add(JrPerempuan);
        JrPerempuan.setText("Perempuan");

        CMbDokter.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "--Pilih--", "dr. Annisa, Sp.A", "dr. Annita Ningrum, Sp.A", "dr. Diah Ayu, Sp.A", "dr. Yulia R A, Sp.A", "dr. Bagus Adi P, Sp.A", "dr. Ayu Lestari, Sp.A", " " }));

        jLabel7.setText("Dokter");

        ChkP1.setText("Polio 1");

        ChkP2.setText("Polio 2");
        ChkP2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ChkP2ActionPerformed(evt);
            }
        });

        ChkRtv.setText("Rotavirus");

        ChkHpB.setText("Hepatitis B");

        ChkCmpk.setText("Campak");
        ChkCmpk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ChkCmpkActionPerformed(evt);
            }
        });

        ChkPcv.setText("PCV");

        ChkMmr.setText("MMR");
        ChkMmr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ChkMmrActionPerformed(evt);
            }
        });

        ChkHpv.setText("HPV");
        ChkHpv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ChkHpvActionPerformed(evt);
            }
        });

        TxtUmur.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TxtUmurActionPerformed(evt);
            }
        });

        CmbSimpan.setText("Simpan");
        CmbSimpan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CmbSimpanActionPerformed(evt);
            }
        });

        CmbExit.setText("Keluar");
        CmbExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CmbExitActionPerformed(evt);
            }
        });

        tbl1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"", "", "", "", "", null, null},
                {null, null, null, null, "", null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "No Urut", "Nama Pasien", "Tgl Lahir", "Jenis Kelamin", "Umur", "Dokter", "Jenis Imunisasi"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tbl1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbl1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tbl1);

        jLabel8.setText("PENDAFTARAN VAKSIN");

        TxtNoPasien.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                TxtNoPasienFocusLost(evt);
            }
        });
        TxtNoPasien.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TxtNoPasienActionPerformed(evt);
            }
        });

        jLabel9.setText("Tahun");

        CmbBatal.setText("Batal");
        CmbBatal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CmbBatalActionPerformed(evt);
            }
        });

        CmbHapus.setText("Hapus");
        CmbHapus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CmbHapusActionPerformed(evt);
            }
        });

        CmbUpdate.setText("Update");
        CmbUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CmbUpdateActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(87, 87, 87)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                                        .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(65, 65, 65)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(TxtUmur, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(TxtNPasien, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(tgllahir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(JrLaki, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(JrPerempuan, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addComponent(CMbDokter, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(ChkP1, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                                                    .addComponent(ChkP2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                                .addGap(2, 2, 2)
                                                .addComponent(ChkHpB, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(18, 18, 18)
                                                .addComponent(ChkHpv, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(89, 89, 89))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGap(100, 100, 100)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(ChkCmpk, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(ChkRtv))
                                                .addGap(18, 18, 18))
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                                .addComponent(CmbHapus, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(45, 45, 45)))
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(CmbUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(27, 27, 27)
                                                .addComponent(CmbExit, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(0, 0, Short.MAX_VALUE))
                                            .addGroup(layout.createSequentialGroup()
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(ChkMmr, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(ChkPcv, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                                .addGap(89, 89, 89))))))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addContainerGap()
                                        .addComponent(TxtNoPasien, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addGap(201, 201, 201)
                                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addGap(67, 67, 67))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(97, 97, 97)
                        .addComponent(CmbSimpan)
                        .addGap(42, 42, 42)
                        .addComponent(CmbBatal, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TxtNoPasien, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TxtNPasien, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE)
                    .addComponent(tgllahir, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JrPerempuan, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JrLaki, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(TxtUmur, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CMbDokter, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ChkP1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ChkHpB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(ChkHpv, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ChkP2, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ChkCmpk)
                    .addComponent(ChkPcv))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ChkMmr)
                    .addComponent(ChkRtv))
                .addGap(67, 67, 67)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CmbExit)
                    .addComponent(CmbSimpan)
                    .addComponent(CmbBatal)
                    .addComponent(CmbHapus)
                    .addComponent(CmbUpdate))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void JrLakiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JrLakiActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_JrLakiActionPerformed

    private void jCheckBox8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox8ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox8ActionPerformed

    private void ChkMmrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ChkMmrActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ChkMmrActionPerformed

    private void ChkHpvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ChkHpvActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ChkHpvActionPerformed

    private void TxtUmurActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TxtUmurActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TxtUmurActionPerformed

    private void ChkP2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ChkP2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ChkP2ActionPerformed

    private void ChkCmpkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ChkCmpkActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ChkCmpkActionPerformed

    private void CmbSimpanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CmbSimpanActionPerformed
        
        // TODO add your handling code here:
        int des = JOptionPane.showConfirmDialog(null, "Yakin Akan Simpan Data Ini ???");
        if(des==0){
        
        if(JrLaki.isSelected()) 
        {gender ="Laki - Laki";}
        else if (JrPerempuan.isSelected()){
        gender ="Perempuan";}
       
        String Polio1 = "N";
        if (ChkP1.isSelected())
            {
             Vaksin += ChkP1.getText() + " , ";
             check = check +1;
             Polio1 = "Y";
              }
        String Polio2 = "N";
        if (ChkP2.isSelected())
            {
             Vaksin += ChkP2.getText() + " , ";
             check = check +1;
             Polio2 = "Y";
            }
        String Rotavirus = "N";
        if (ChkRtv.isSelected())
            {
             Vaksin += ChkRtv.getText() + " , ";
             check = check +1;
             Rotavirus = "Y";
            }
        String PCV = "N";
        if (ChkPcv.isSelected())
            {
             Vaksin += ChkPcv.getText() + " , ";
             check = check +1;
             PCV = "Y";
            }
        String HepatitisB = "N";
        if (ChkHpB.isSelected())
            {
             Vaksin += ChkHpB.getText() + " , ";
             check = check +1;
             HepatitisB = "Y";
            }
        String Campak = "N";
        if (ChkCmpk.isSelected())
            {
             Vaksin += ChkCmpk.getText() + " , ";
             check = check +1;
             Campak = "Y";
            }    
        String MMR = "N";
        if (ChkMmr.isSelected())
            {
             Vaksin += ChkMmr.getText() + " , ";
             check = check +1;
             MMR = "Y";
            }
        String HPV = "N";
        if (ChkHpv.isSelected())
            {
             Vaksin += ChkHpv.getText() + " , ";
             check = check +1;
             HPV = "Y";
            }
        
       SimpleDateFormat formater = new SimpleDateFormat("dd-MMMM-yyyy");

        
  /*Simpan Button do this */
            int NoUrut = nomer + 1;
            String KodePasien = TxtNoPasien.getText();
            String NamaPasien = TxtNPasien.getText();
            String TanggalLahir = formater.format(tgllahir.getDate());
            String JenisKelamin = gender;
            int Umur = Integer.parseInt(TxtUmur.getText());
            String Dokter = (String)CMbDokter.getSelectedItem();
            int KodeDokter = CMbDokter.getSelectedIndex();
            String JenisImunisasi = Vaksin;
            
            try{
                Statement statement = (Statement) conek.GetConnection().createStatement();
                statement.executeUpdate("insert into formpasien values(" + NoUrut +",'" + KodePasien + "','"+ NamaPasien + "','" + TanggalLahir + "','" +
                        JenisKelamin + "'," + Umur + "," +KodeDokter+",'" + Dokter + "','" + JenisImunisasi + "','" + Polio1 +"','" 
                + Polio2 + "','" + HepatitisB + "','" + Campak + "','" + Rotavirus + "','" + HPV + "','" + PCV + "','" + MMR +"');");
                statement.close();
                JOptionPane.showMessageDialog(null, "Data Berhasil Disimpan");
            }catch (Exception t){
                t.printStackTrace();
                JOptionPane.showMessageDialog(null, "Data Gagal Disimpan");
            }
    
            
            datatable();
            bersihdata();
        }else {
            JOptionPane.showMessageDialog(null, "Data Batal Disimpan");
            bersihdata();
        }
    }        
   public void bersihdata(){
               Vaksin = "";
               check = 1;
                TxtNoPasien.requestFocus();
                TxtNoPasien.setText(null);
            TxtNPasien.setText(null);
            tgllahir.setDate(null);
            JrLaki.setSelected(false);
            JrPerempuan.setSelected(false);
            TxtUmur.setText(null);
            CMbDokter.setSelectedIndex(0);
            ChkP1.setSelected(false);
            ChkP2.setSelected(false);
            ChkRtv.setSelected(false);
            ChkPcv.setSelected(false);
            ChkHpB.setSelected(false);
            ChkCmpk.setSelected(false);
            ChkMmr.setSelected(false);
            ChkHpv.setSelected(false);
            
           /* TxtNoPasien.setText(String.valueOf(nomer));
            */
            
    }//GEN-LAST:event_CmbSimpanActionPerformed

    
    private void TxtNPasienActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TxtNPasienActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TxtNPasienActionPerformed

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
/*TxtNoPasien.setText(String.valueOf(nomer));        // TODO add your handling code here:*/

    }//GEN-LAST:event_formWindowActivated

    private void CmbExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CmbExitActionPerformed
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_CmbExitActionPerformed

    private void TxtNoPasienActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TxtNoPasienActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_TxtNoPasienActionPerformed

    private void TxtNoPasienFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_TxtNoPasienFocusLost
        
        

        // TODO add your handling code here:
    }//GEN-LAST:event_TxtNoPasienFocusLost

    private void CmbBatalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CmbBatalActionPerformed
        // TODO add your handling code here:
        bersihdata();
    }//GEN-LAST:event_CmbBatalActionPerformed

    private void tbl1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbl1MouseClicked
    DefaultTableModel model = (DefaultTableModel)tbl1.getModel();
    bersih();

        // get the selected row index
       int selectedRowIndex = tbl1.getSelectedRow();
       
        // set the selected row data into jtextfields
       String no = (model.getValueAt(selectedRowIndex, 0).toString());
       key = no;
       try{
        Statement statement=(Statement)conek.GetConnection().createStatement();
        ResultSet res=statement.executeQuery("Select * from formpasien where NoUrut = " + no + "");
        while(res.next())
        {
           
            TxtNoPasien.setText(res.getString("KodePasien"));
            TxtNPasien.setText(res.getString("NamaPasien"));
            TxtUmur.setText(res.getString("Umur"));
            
            /*generate checklist Imunisasi */
            String pol1 = res.getString("Polio1");
            if ("Y".equals(pol1))
            {
                ChkP1.setSelected(true);
            }
            String pol2 = res.getString("Polio2");
            if ("Y".equals(pol2))
            {
                ChkP2.setSelected(true);
            }
            String rtv = res.getString("Rotavirus");
            if ("Y".equals(rtv))
            {
                ChkRtv.setSelected(true);
            }
            String pcv = res.getString("PCV");
            if ("Y".equals(pcv))
            {
                ChkPcv.setSelected(true);
            }
            String hpb = res.getString("HepatitisB");
            if ("Y".equals(hpb))
            {
                ChkHpB.setSelected(true);
            }
            String cmpk = res.getString("Campak");
            if ("Y".equals(cmpk))
            {
                ChkCmpk.setSelected(true);
            }
            String mmr = res.getString("MMR");
            if ("Y".equals(mmr))
            {
                ChkMmr.setSelected(true);
            }
            String hpv = res.getString("HPV");
            if ("Y".equals(hpv))
            {
                ChkHpv.setSelected(true);
            }
            
            /*generate gender button */
            gender = res.getString("JenisKelamin");
            if ("Perempuan".equalsIgnoreCase(gender)) {
                JrPerempuan.setSelected(true);
            
            } else {
                    JrLaki.setSelected(true);
             }
            
            /*generate combo Dokter*/
           int KodeDokter = res.getInt("KodeDokter");
            CMbDokter.setSelectedIndex(KodeDokter);
            
            /*generate tanggal */
            SimpleDateFormat formater = new SimpleDateFormat("dd-MMMM-yyyy");
            String tgl = res.getString("TanggalLahir");
            Date date = formater.parse(tgl);
            tgllahir.setDate(date);
        }
    }
    catch (Exception x){
        JOptionPane.showMessageDialog(rootPane, "salah");
    }
       
       // TODO add your handling code here:
    }//GEN-LAST:event_tbl1MouseClicked

    private void CmbHapusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CmbHapusActionPerformed
        int des = JOptionPane.showConfirmDialog(null, "Yakin Akan Menghapus Data Ini ???");
        if(des==0){
        try{
            Statement statement = (Statement) conek.GetConnection().createStatement();
            statement.executeUpdate("delete from formpasien where NoUrut = " + key +" ");
            JOptionPane.showMessageDialog(rootPane, "Data Berhasil Di Hapus");
            bersih();
            datatable();
        } catch (Exception e){
            
             JOptionPane.showMessageDialog(rootPane, "Data Gagal Di Hapus");
             bersih();
        }
        
        }else{
            JOptionPane.showMessageDialog(rootPane, "Data Batal Di Hapus");
            bersih();
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_CmbHapusActionPerformed

    private void CmbUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CmbUpdateActionPerformed
        int des = JOptionPane.showConfirmDialog(null, "Yakin Akan Update Data Ini ???");
        if(des==0){
         
             if(JrLaki.isSelected()) 
        {gender ="Laki - Laki";}
        else if (JrPerempuan.isSelected()){
        gender ="Perempuan";}
       
        String Polio1 = "N";
        if (ChkP1.isSelected())
            {
             Vaksin += ChkP1.getText() + " , ";
             check = check +1;
             Polio1 = "Y";
              }
        String Polio2 = "N";
        if (ChkP2.isSelected())
            {
             Vaksin += ChkP2.getText() + " , ";
             check = check +1;
             Polio2 = "Y";
            }
        String Rotavirus = "N";
        if (ChkRtv.isSelected())
            {
             Vaksin += ChkRtv.getText() + " , ";
             check = check +1;
             Rotavirus = "Y";
            }
        String PCV = "N";
        if (ChkPcv.isSelected())
            {
             Vaksin += ChkPcv.getText() + " , ";
             check = check +1;
             PCV = "Y";
            }
        String HepatitisB = "N";
        if (ChkHpB.isSelected())
            {
             Vaksin += ChkHpB.getText() + " , ";
             check = check +1;
             HepatitisB = "Y";
            }
        String Campak = "N";
        if (ChkCmpk.isSelected())
            {
             Vaksin += ChkCmpk.getText() + " , ";
             check = check +1;
             Campak = "Y";
            }    
        String MMR = "N";
        if (ChkMmr.isSelected())
            {
             Vaksin += ChkMmr.getText() + " , ";
             check = check +1;
             MMR = "Y";
            }
        String HPV = "N";
        if (ChkHpv.isSelected())
            {
             Vaksin += ChkHpv.getText() + " , ";
             check = check +1;
             HPV = "Y";
            }    
            
            SimpleDateFormat formater = new SimpleDateFormat("dd-MMMM-yyyy");
        String KodePasien = TxtNoPasien.getText();
            String NamaPasien = TxtNPasien.getText();
            String TanggalLahir = formater.format(tgllahir.getDate());
            String JenisKelamin = gender;
            int Umur = Integer.parseInt(TxtUmur.getText());
            String Dokter = (String)CMbDokter.getSelectedItem();
            int KodeDokter = CMbDokter.getSelectedIndex();
            String JenisImunisasi = Vaksin;
            
            try{
                Statement statement = (Statement) conek.GetConnection().createStatement();
                statement.executeUpdate("update formpasien set KodePasien = '" + KodePasien + "',NamaPasien = '"+ NamaPasien + "',TanggalLahir = '" + TanggalLahir + "',JenisKelamin = '" +
                        JenisKelamin + "',Umur = " + Umur + ",KodeDokter = " +KodeDokter+",Dokter = '" + Dokter + "',JenisImunisasi = '" + JenisImunisasi + "',Polio1 = '" + Polio1 +"', Polio2 = '" 
                + Polio2 + "',HepatitisB = '" + HepatitisB + "',Campak = '" + Campak + "',Rotavirus = '" + Rotavirus + "',HPV = '" + HPV + "',PCV = '" + PCV + "', MMR = '" + MMR +"' where NoUrut = "+ key +";");
                statement.close();
                JOptionPane.showMessageDialog(null, "Data Berhasil Disimpan");
            }catch (Exception t){
                t.printStackTrace();
                JOptionPane.showMessageDialog(null, "Data Gagal Disimpan");
            }
    
            
            datatable();
            bersihdata();   
            
        }else{
            JOptionPane.showMessageDialog(rootPane, "Data Batal Di Update");
            bersihdata();
        }
    }//GEN-LAST:event_CmbUpdateActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameComboBoxUTS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameComboBoxUTS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameComboBoxUTS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameComboBoxUTS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrameComboBoxUTS().setVisible(true);
            }
        });
    }

    public void bersih(){
        TxtNoPasien.setText(null);
            TxtNPasien.setText(null);
            tgllahir.setDate(null);
            JrLaki.setSelected(false);
            JrPerempuan.setSelected(false);
            TxtUmur.setText(null);
            CMbDokter.setSelectedIndex(0);
            ChkP1.setSelected(false);
            ChkP2.setSelected(false);
            ChkRtv.setSelected(false);
            ChkPcv.setSelected(false);
            ChkHpB.setSelected(false);
            ChkCmpk.setSelected(false);
            ChkMmr.setSelected(false);
            ChkHpv.setSelected(false);
            key = null;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox<String> CMbDokter;
    private javax.swing.JCheckBox ChkCmpk;
    private javax.swing.JCheckBox ChkHpB;
    private javax.swing.JCheckBox ChkHpv;
    private javax.swing.JCheckBox ChkMmr;
    private javax.swing.JCheckBox ChkP1;
    private javax.swing.JCheckBox ChkP2;
    private javax.swing.JCheckBox ChkPcv;
    private javax.swing.JCheckBox ChkRtv;
    private javax.swing.JButton CmbBatal;
    private javax.swing.JButton CmbExit;
    private javax.swing.JButton CmbHapus;
    private javax.swing.JButton CmbSimpan;
    private javax.swing.JButton CmbUpdate;
    private javax.swing.JRadioButton JrLaki;
    private javax.swing.JRadioButton JrPerempuan;
    private javax.swing.JTextField TxtNPasien;
    private javax.swing.JTextField TxtNoPasien;
    private javax.swing.JTextField TxtUmur;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tbl1;
    private org.jdesktop.swingx.JXDatePicker tgllahir;
    // End of variables declaration//GEN-END:variables

    

     //To change body of generated methods, choose Tools | Templates.
    }


5. PENUTUP

Demikian deskripsi project yang telah dibuat. Yang dikemudian hari semoga program ini dapat digunakan. kurang dan lebihnya terimakasih. 



Comments

Popular posts from this blog

APLIKASI PROGRAM JAVA II (UTS)