VIDEO
Muayene.java Sayfası
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class Muayene extends javax.swing.JFrame {
/**
* Creates new form Muayene
*/
public Muayene( ) {
initComponents( );
MuayeneListesiniYukle( );
}
private void MuayeneListesiniYukle( )
{
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );//Veri Tabanına bağlanıyoruz
try{
Statement st=conn.createStatement( );
ResultSet rs=st.executeQuery( "SELECT * FROM [Muayene_Bilgileri]" );//Veri Tabanında Yapılan .... Getiriyoruz
DefaultTableModel DTM = new DefaultTableModel( );//Liste oluşturuyoruz
jTable1.setModel( DTM );//Listeyi tabloya yüklüyoruz
//Aşağıda kolonları oluşturuyoruz
DTM.addColumn( "ID" );
DTM.addColumn( "Araç Sahibi TC" );
DTM.addColumn( "Adı Soyadı" );
DTM.addColumn( "Araç Plaka" );
DTM.addColumn( "Tarih" );
DTM.addColumn( "Fren Sistemi" );
DTM.addColumn( "Gürültü Kirliliği" );
DTM.addColumn( "Zorunlu Ekipmanlar" );
DTM.addColumn( "Aydınlatma Sistemi" );
DTM.addColumn( "Direksiyon Sistemi" );
DTM.addColumn( "Görüş Özellikleri" );
DTM.addColumn( "Taşıt Tanımı" );
DTM.addColumn( "Şasi Bağlantıları" );
DTM.addColumn( "Dingil, Lastik ve Süspansiyon" );
DTM.addColumn( "Trafik Uygunluğu" );
DTM.addColumn( "Sonraki Muayene Tarihi" );
while( rs.next( ) ){
Statement st1=conn.createStatement( );
ResultSet rs1=st1.executeQuery( "SELECT * FROM [Arac_Sahibi] Where [Tc]=" + rs.getString( "Arac_Sahibi_Tc" ) );
rs1.next( );
//Burada Getirdiğimiz kayıtları Satır Olarak tabloya yüklüyoruz
DTM.addRow( new String[]{rs.getString( "ID" ), rs.getString( "Arac_Sahibi_Tc" ), rs1.getString( "AdSoyad" ), rs1.getString( "Arac_Plaka" ),
rs.getString( "Tarih" ), rs.getString( "Fren_Sistemi" ), rs.getString( "Gurultu_Kirliligi" ), rs.getString( "Zorunlu_Ekipmanlar" ),
rs.getString( "Aydinlatma_Sistemi" ), rs.getString( "Direksiyon_Sistemi" ), rs.getString( "Gorus_Ozellikleri" ), rs.getString( "Tasit_Tanimi" ),
rs.getString( "SAsi_Baglantilari" ), rs.getString( "Dingil_Lastik_Suspansiyon" ), rs.getString( "Trafik_Uygunlugu" ), rs.getString( "Sonraki_Muayene_Tarihi" )} );
rs1.close( );
st1.close( );
}
rs.close( );
st.close( );
conn.close( );
}catch( Exception exp ){
JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );
}
}
/**
* 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" )
// //GEN-BEGIN:initComponents
private void initComponents( ) {
jMenuBar1 = new javax.swing.JMenuBar( );
jMenu1 = new javax.swing.JMenu( );
jMenu2 = new javax.swing.JMenu( );
jLabel1 = new javax.swing.JLabel( );
jComboBox1 = new javax.swing.JComboBox<>( );
jTextField1 = new javax.swing.JTextField( );
jButton1 = new javax.swing.JButton( );
jScrollPane1 = new javax.swing.JScrollPane( );
jTable1 = new javax.swing.JTable( );
jMenuBar2 = new javax.swing.JMenuBar( );
jMenu3 = new javax.swing.JMenu( );
jMenu4 = new javax.swing.JMenu( );
jMenu5 = new javax.swing.JMenu( );
jMenu6 = new javax.swing.JMenu( );
jMenu7 = new javax.swing.JMenu( );
jMenu8 = new javax.swing.JMenu( );
jMenu1.setText( "File" );
jMenuBar1.add( jMenu1 );
jMenu2.setText( "Edit" );
jMenuBar1.add( jMenu2 );
setDefaultCloseOperation( javax.swing.WindowConstants.EXIT_ON_CLOSE );
setTitle( "Araç Muayene Takip Programı" );
addWindowListener( new java.awt.event.WindowAdapter( ) {
public void windowActivated( java.awt.event.WindowEvent evt ) {
formWindowActivated( evt );
}
} );
jLabel1.setText( "' a Göre:" );
jComboBox1.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Araç Sahibi TC", "Araç Sahibi Adı Soyadı", "Araç Plaka" } ) );
jButton1.setText( "Ara" );
jButton1.addActionListener( new java.awt.event.ActionListener( ) {
public void actionPerformed( java.awt.event.ActionEvent evt ) {
jButton1ActionPerformed( evt );
}
} );
jTable1.setModel( new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
) );
jScrollPane1.setViewportView( jTable1 );
jMenu3.setText( "Araç Ekle" );
jMenu3.addMouseListener( new java.awt.event.MouseAdapter( ) {
public void mouseClicked( java.awt.event.MouseEvent evt ) {
jMenu3MouseClicked( evt );
}
} );
jMenuBar2.add( jMenu3 );
jMenu4.setText( "Araç Listesi" );
jMenu4.addMouseListener( new java.awt.event.MouseAdapter( ) {
public void mouseClicked( java.awt.event.MouseEvent evt ) {
jMenu4MouseClicked( evt );
}
} );
jMenuBar2.add( jMenu4 );
jMenu5.setText( "Araç Sahibi Ekle" );
jMenu5.addMouseListener( new java.awt.event.MouseAdapter( ) {
public void mouseClicked( java.awt.event.MouseEvent evt ) {
jMenu5MouseClicked( evt );
}
} );
jMenuBar2.add( jMenu5 );
jMenu6.setText( "Araç Sahip Listesi" );
jMenu6.addMouseListener( new java.awt.event.MouseAdapter( ) {
public void mouseClicked( java.awt.event.MouseEvent evt ) {
jMenu6MouseClicked( evt );
}
} );
jMenuBar2.add( jMenu6 );
jMenu7.setText( "Muayene Kayıt" );
jMenu7.addMouseListener( new java.awt.event.MouseAdapter( ) {
public void mouseClicked( java.awt.event.MouseEvent evt ) {
jMenu7MouseClicked( evt );
}
} );
jMenuBar2.add( jMenu7 );
jMenu8.setText( "Yenile" );
jMenu8.addMouseListener( new java.awt.event.MouseAdapter( ) {
public void mouseClicked( java.awt.event.MouseEvent evt ) {
jMenu8MouseClicked( evt );
}
} );
jMenuBar2.add( jMenu8 );
setJMenuBar( jMenuBar2 );
javax.swing.GroupLayout layout = new javax.swing.GroupLayout( getContentPane( ) );
getContentPane( ).setLayout( layout );
layout.setHorizontalGroup(
layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addGroup( layout.createSequentialGroup( )
.addContainerGap( )
.addComponent( jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jLabel1 )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jButton1 )
.addContainerGap( 540, Short.MAX_VALUE ) )
.addComponent( jScrollPane1 )
);
layout.setVerticalGroup(
layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addGroup( layout.createSequentialGroup( )
.addContainerGap( )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel1 )
.addComponent( jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE )
.addComponent( jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE )
.addComponent( jButton1 ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE ) )
);
pack( );
}// //GEN-END:initComponents
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt ) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );//Veri Tabanına bağlanıyoruz
try{
Statement st2=conn.createStatement( );
ResultSet rs2=null;
Statement st3=conn.createStatement( );
ResultSet rs3=null;
if( jComboBox1.getSelectedItem( ).toString( ) == "Araç Sahibi Adı Soyadı" )
{
rs2=st2.executeQuery( "SELECT * FROM [Arac_Sahibi] WHERE [AdSoyad] LIKE '%" + jTextField1.getText( ) + "%'" );
rs2.next( );
}
else if( jComboBox1.getSelectedItem( ).toString( ) == "Araç Plaka" )
{
rs3=st3.executeQuery( "SELECT * FROM [Arac_Sahibi] WHERE [Arac_Plaka] LIKE '%" + jTextField1.getText( ) + "%'" );
rs3.next( );
}
Statement st=conn.createStatement( );
ResultSet rs=null;
if( jComboBox1.getSelectedItem( ).toString( ) == "Araç Sahibi TC" )
{
rs=st.executeQuery( "SELECT * FROM [Muayene_Bilgileri] WHERE [Arac_Sahibi_Tc]='" + jTextField1.getText( ) + "'" );
}
else if( jComboBox1.getSelectedItem( ).toString( ) == "Araç Sahibi Adı Soyadı" )
{
rs=st.executeQuery( "SELECT * FROM [Muayene_Bilgileri] WHERE [Arac_Sahibi_Tc]='" + rs2.getString( "Tc" ) + "'" );
}
else if( jComboBox1.getSelectedItem( ).toString( ) == "Araç Plaka" )
{
rs=st.executeQuery( "SELECT * FROM [Muayene_Bilgileri] WHERE [Arac_Sahibi_Tc]='" + rs3.getString( "Tc" ) + "'" );
}
else
{
rs=st.executeQuery( "SELECT * FROM [Muayene_Bilgileri]" );
}
DefaultTableModel DTM = new DefaultTableModel( );//Liste oluşturuyoruz
jTable1.setModel( DTM );//Listeyi tabloya yüklüyoruz
//Aşağıda kolonları oluşturuyoruz
DTM.addColumn( "ID" );
DTM.addColumn( "Araç Sahibi TC" );
DTM.addColumn( "Adı Soyadı" );
DTM.addColumn( "Araç Plaka" );
DTM.addColumn( "Tarih" );
DTM.addColumn( "Fren Sistemi" );
DTM.addColumn( "Gürültü Kirliliği" );
DTM.addColumn( "Zorunlu Ekipmanlar" );
DTM.addColumn( "Aydınlatma Sistemi" );
DTM.addColumn( "Direksiyon Sistemi" );
DTM.addColumn( "Görüş Özellikleri" );
DTM.addColumn( "Taşıt Tanımı" );
DTM.addColumn( "Şasi Bağlantıları" );
DTM.addColumn( "Dingil, Lastik ve Süspansiyon" );
DTM.addColumn( "Trafik Uygunluğu" );
DTM.addColumn( "Sonraki Muayene Tarihi" );
while( rs.next( ) ){
Statement st1=conn.createStatement( );
ResultSet rs1=st1.executeQuery( "SELECT * FROM [Arac_Sahibi] Where [Tc]=" + rs.getString( "Arac_Sahibi_Tc" ) );
rs1.next( );
//Burada Getirdiğimiz kayıtları Satır Olarak tabloya yüklüyoruz
DTM.addRow( new String[]{rs.getString( "ID" ), rs.getString( "Arac_Sahibi_Tc" ), rs1.getString( "AdSoyad" ), rs1.getString( "Arac_Plaka" ),
rs.getString( "Tarih" ), rs.getString( "Fren_Sistemi" ), rs.getString( "Gurultu_Kirliligi" ), rs.getString( "Zorunlu_Ekipmanlar" ),
rs.getString( "Aydinlatma_Sistemi" ), rs.getString( "Direksiyon_Sistemi" ), rs.getString( "Gorus_Ozellikleri" ), rs.getString( "Tasit_Tanimi" ),
rs.getString( "SAsi_Baglantilari" ), rs.getString( "Dingil_Lastik_Suspansiyon" ), rs.getString( "Trafik_Uygunlugu" ), rs.getString( "Sonraki_Muayene_Tarihi" )} );
rs1.close( );
st1.close( );
}
rs.close( );
st.close( );
conn.close( );
}catch( Exception exp ){
//JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );
System.out.println( exp.getMessage( ) );
}
}//GEN-LAST:event_jButton1ActionPerformed
private void formWindowActivated( java.awt.event.WindowEvent evt ) {//GEN-FIRST:event_formWindowActivated
// TODO add your handling code here:
MuayeneListesiniYukle( );
}//GEN-LAST:event_formWindowActivated
private void jMenu3MouseClicked( java.awt.event.MouseEvent evt ) {//GEN-FIRST:event_jMenu3MouseClicked
// TODO add your handling code here:
Arac_Ekle frm = new Arac_Ekle( );
frm.Guncelle=false;
frm.setVisible( true );
}//GEN-LAST:event_jMenu3MouseClicked
private void jMenu5MouseClicked( java.awt.event.MouseEvent evt ) {//GEN-FIRST:event_jMenu5MouseClicked
// TODO add your handling code here:
Arac_Sahibi_Ekle frm = new Arac_Sahibi_Ekle( );
frm.Guncelle=false;
frm.setVisible( true );
}//GEN-LAST:event_jMenu5MouseClicked
private void jMenu4MouseClicked( java.awt.event.MouseEvent evt ) {//GEN-FIRST:event_jMenu4MouseClicked
// TODO add your handling code here:
Listeler form=new Listeler( );
form.setTitle( "Araç Listesi" );
form.listecinsi="Araclar";
form.setVisible( true );
}//GEN-LAST:event_jMenu4MouseClicked
private void jMenu6MouseClicked( java.awt.event.MouseEvent evt ) {//GEN-FIRST:event_jMenu6MouseClicked
// TODO add your handling code here:
Listeler form=new Listeler( );
form.setTitle( "Araç Sahibi Listesi" );
form.listecinsi="Arac_Sahibi";
form.setVisible( true );
}//GEN-LAST:event_jMenu6MouseClicked
private void jMenu7MouseClicked( java.awt.event.MouseEvent evt ) {//GEN-FIRST:event_jMenu7MouseClicked
// TODO add your handling code here:
Muayene_Kayit frm = new Muayene_Kayit( );
frm.setVisible( true );
}//GEN-LAST:event_jMenu7MouseClicked
private void jMenu8MouseClicked( java.awt.event.MouseEvent evt ) {//GEN-FIRST:event_jMenu8MouseClicked
// TODO add your handling code here:
MuayeneListesiniYukle( );
}//GEN-LAST:event_jMenu8MouseClicked
/**
* @param args the command line arguments
*/
public static void main( String args[] ) {
/* Set the Nimbus look and feel */
//
/* 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( Muayene.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( InstantiationException ex ) {
java.util.logging.Logger.getLogger( Muayene.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( IllegalAccessException ex ) {
java.util.logging.Logger.getLogger( Muayene.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( javax.swing.UnsupportedLookAndFeelException ex ) {
java.util.logging.Logger.getLogger( Muayene.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater( new Runnable( ) {
public void run( ) {
new Muayene( ).setVisible( true );
}
} );
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenu jMenu5;
private javax.swing.JMenu jMenu6;
private javax.swing.JMenu jMenu7;
private javax.swing.JMenu jMenu8;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuBar jMenuBar2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField jTextField1;
// End of variables declaration//GEN-END:variables
}
Muayene_Kayit.java Sayfası
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JOptionPane;
public class Muayene_Kayit extends javax.swing.JFrame {
/**
* Creates new form Muayene_Kayit
*/
public Muayene_Kayit( ) {
initComponents( );
KisiDoldur( );
}
//public String ID, Tc, FrenSistemi, GurultuKirliligi, ZorunluEkipmanlar, AydilatmaSistemi, DireksiyonSistemi, GorusOzellikleri, TasitTanimi, SasiBaglantilari, DingilLastikSuspansiyon, TrafikUygunlugu, SonrakiMuayeneTarihi;//Diğer sayfalardan .... bilgilerini düzenlemek için gereken değişkenler
private void KisiDoldur( )
{
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );//Veri Tabanına Bağlanıyoruz
jComboBox1.removeAllItems( );//Combobox u temizliyoruz
jComboBox1.addItem( "Seçiniz" );//Combobox a seçiniz kaydı ekliyoruz
try{
Statement st=conn.createStatement( );
ResultSet rs=st.executeQuery( "SELECT * FROM [Arac_Sahibi]" );
while( rs.next( ) ){
jComboBox1.addItem( rs.getString( "Tc" ) );//Veri tabanındaki ..... combobox a ekliyoruz
}
rs.close( );
st.close( );
conn.close( );
}catch( Exception exp ){
JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );//Olası hatada hata mesajı veriyoruz
}
}
private String TarihEkle( )
{
DateFormat bicim = new SimpleDateFormat( "dd.MM.yyyy" );
Date tarih = new Date( );
return bicim.format( tarih );
}
/**
* 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" )
// //GEN-BEGIN:initComponents
private void initComponents( ) {
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( );
jLabel7 = new javax.swing.JLabel( );
jLabel8 = new javax.swing.JLabel( );
jLabel9 = new javax.swing.JLabel( );
jLabel10 = new javax.swing.JLabel( );
jLabel11 = new javax.swing.JLabel( );
jLabel12 = new javax.swing.JLabel( );
jComboBox1 = new javax.swing.JComboBox<>( );
jLabel13 = new javax.swing.JLabel( );
jComboBox2 = new javax.swing.JComboBox<>( );
jComboBox3 = new javax.swing.JComboBox<>( );
jComboBox4 = new javax.swing.JComboBox<>( );
jComboBox5 = new javax.swing.JComboBox<>( );
jComboBox6 = new javax.swing.JComboBox<>( );
jComboBox7 = new javax.swing.JComboBox<>( );
jComboBox8 = new javax.swing.JComboBox<>( );
jComboBox9 = new javax.swing.JComboBox<>( );
jComboBox10 = new javax.swing.JComboBox<>( );
jComboBox11 = new javax.swing.JComboBox<>( );
jTextField1 = new javax.swing.JTextField( );
jButton1 = new javax.swing.JButton( );
setTitle( "Muayene Kayıt Sayfası" );
jLabel1.setText( "Araç Sahibi Tc:" );
jLabel2.setText( "Fren Sistemi:" );
jLabel3.setText( "Gürültü Kirliliği:" );
jLabel4.setText( "Zorunlu Ekipmanlar:" );
jLabel5.setText( "Aydınlatma Sistemi:" );
jLabel6.setText( "Direksiyon Sistemi:" );
jLabel7.setText( "Görüş Özellikleri:" );
jLabel8.setText( "Taşıt Tanımı:" );
jLabel9.setText( "Şasi Bağlantıları:" );
jLabel10.setText( "Dingil-Lastik-Süspansiyon:" );
jLabel11.setText( "Trafik Uygunluğu:" );
jLabel12.setText( "Sonraki Muayene Tarihi:" );
jComboBox1.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Item 1", "Item 2", "Item 3", "Item 4" } ) );
jComboBox1.addItemListener( new java.awt.event.ItemListener( ) {
public void itemStateChanged( java.awt.event.ItemEvent evt ) {
jComboBox1ItemStateChanged( evt );
}
} );
jLabel13.setText( "..." );
jComboBox2.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Uygun", "Hafif Kusurlu", "Kusurlu", "Ağır Kusurlu" } ) );
jComboBox3.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Uygun", "Hafif Kusurlu", "Kusurlu", "Ağır Kusurlu" } ) );
jComboBox4.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Uygun", "Hafif Kusurlu", "Kusurlu", "Ağır Kusurlu" } ) );
jComboBox5.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Uygun", "Hafif Kusurlu", "Kusurlu", "Ağır Kusurlu" } ) );
jComboBox6.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Uygun", "Hafif Kusurlu", "Kusurlu", "Ağır Kusurlu" } ) );
jComboBox7.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Uygun", "Hafif Kusurlu", "Kusurlu", "Ağır Kusurlu" } ) );
jComboBox8.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Uygun", "Hafif Kusurlu", "Kusurlu", "Ağır Kusurlu" } ) );
jComboBox9.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Uygun", "Hafif Kusurlu", "Kusurlu", "Ağır Kusurlu" } ) );
jComboBox10.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Uygun", "Hafif Kusurlu", "Kusurlu", "Ağır Kusurlu" } ) );
jComboBox11.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Trafiğe Çıkabilir", "Trafiğe Çıkamaz" } ) );
jButton1.setText( "Tamam" );
jButton1.addActionListener( new java.awt.event.ActionListener( ) {
public void actionPerformed( java.awt.event.ActionEvent evt ) {
jButton1ActionPerformed( 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( )
.addContainerGap( )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jButton1 )
.addGroup( layout.createSequentialGroup( )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addComponent( jLabel6, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel7, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel8, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel9, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel10, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel1, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel11, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel2, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel12, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel3, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel4, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel5, javax.swing.GroupLayout.Alignment.TRAILING ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addComponent( jLabel13 )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING, false )
.addComponent( jComboBox11, javax.swing.GroupLayout.Alignment.LEADING, 0, 148, Short.MAX_VALUE )
.addComponent( jComboBox10, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jComboBox9, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jComboBox8, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jComboBox7, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jComboBox6, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jComboBox5, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jComboBox4, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jComboBox3, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jComboBox2, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jComboBox1, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jTextField1 ) ) ) ) )
.addContainerGap( javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ) )
);
layout.setVerticalGroup(
layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addGroup( layout.createSequentialGroup( )
.addContainerGap( )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel1 )
.addComponent( jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jLabel13 )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel2 )
.addComponent( jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel3 )
.addComponent( jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel4 )
.addComponent( jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel5 )
.addComponent( jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel6 )
.addComponent( jComboBox6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel7 )
.addComponent( jComboBox7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel8 )
.addComponent( jComboBox8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel9 )
.addComponent( jComboBox9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel10 )
.addComponent( jComboBox10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel11 )
.addComponent( jComboBox11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel12 )
.addComponent( jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jButton1 )
.addContainerGap( javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ) )
);
pack( );
}// //GEN-END:initComponents
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt ) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );
try{
Statement st=conn.createStatement( );
st.executeUpdate( "INSERT INTO [Muayene_Bilgileri] ( [Arac_Sahibi_Tc], [Tarih], [Fren_Sistemi], [Gurultu_Kirliligi], [Zorunlu_Ekipmanlar], [Aydinlatma_Sistemi], [Direksiyon_Sistemi], [Gorus_Ozellikleri], [Tasit_Tanimi], [Sasi_Baglantilari], [Dingil_Lastik_Suspansiyon], [Trafik_Uygunlugu], [Sonraki_Muayene_Tarihi] ) Values( '" + jComboBox1.getSelectedItem( ).toString( ) + "', '" + TarihEkle( ) + "', '" + jComboBox2.getSelectedItem( ).toString( ) + "', '" + jComboBox3.getSelectedItem( ).toString( ) + "', '" + jComboBox4.getSelectedItem( ).toString( ) + "', '" + jComboBox5.getSelectedItem( ).toString( ) + "', '" + jComboBox6.getSelectedItem( ).toString( ) + "', '" + jComboBox7.getSelectedItem( ).toString( ) + "', '" + jComboBox8.getSelectedItem( ).toString( ) + "', '" + jComboBox9.getSelectedItem( ).toString( ) + "', '" + jComboBox10.getSelectedItem( ).toString( ) + "', '" + jComboBox11.getSelectedItem( ).toString( ) + "', '" + jTextField1.getText( ) + "' )" );
Statement st1=conn.createStatement( );
ResultSet rs1=st1.executeQuery( "SELECT * FROM [Arac_Sahibi] WHERE [Tc]='" + jComboBox1.getSelectedItem( ).toString( ) + "'" );
rs1.next( );
Statement st3=conn.createStatement( );
st3.executeUpdate( "Update [Arac_Bilgileri] Set [Muayene_Tarihi]='" + TarihEkle( ) + "', [Sonraki_Muayene_Tarihi]='" + jTextField1.getText( ) + "' Where [Plaka]='" + rs1.getString( "Arac_Plaka" ) + "'" );
JOptionPane.showMessageDialog( rootPane, "Muayene Bilgileri Eklendi." );
st.close( );
st1.close( );
st3.close( );
rs1.close( );
conn.close( );
this.setVisible( false );//Ekleme veya güncelleme işlemi bittikten sonra sayfayı gizler
}catch( Exception exp ){
JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );
System.out.println( exp.getMessage( ) );
}
}//GEN-LAST:event_jButton1ActionPerformed
private void jComboBox1ItemStateChanged( java.awt.event.ItemEvent evt ) {//GEN-FIRST:event_jComboBox1ItemStateChanged
// TODO add your handling code here:
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );//Veri Tabanına Bağlanıyoruz
try{
Statement st=conn.createStatement( );
ResultSet rs=st.executeQuery( "SELECT * FROM [Arac_Sahibi] WHERE [Tc]='" + jComboBox1.getSelectedItem( ).toString( ) + "'" );
while( rs.next( ) ){
jLabel13.setText( rs.getString( "AdSoyad" ) );//Veri tabanındaki ..... combobox a ekliyoruz
}
rs.close( );
st.close( );
conn.close( );
}catch( Exception exp ){
//JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );//Olası hatada hata mesajı veriyoruz
}
}//GEN-LAST:event_jComboBox1ItemStateChanged
/**
* @param args the command line arguments
*/
public static void main( String args[] ) {
/* Set the Nimbus look and feel */
//
/* 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( Muayene_Kayit.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( InstantiationException ex ) {
java.util.logging.Logger.getLogger( Muayene_Kayit.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( IllegalAccessException ex ) {
java.util.logging.Logger.getLogger( Muayene_Kayit.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( javax.swing.UnsupportedLookAndFeelException ex ) {
java.util.logging.Logger.getLogger( Muayene_Kayit.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater( new Runnable( ) {
public void run( ) {
new Muayene_Kayit( ).setVisible( true );
}
} );
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox10;
private javax.swing.JComboBox jComboBox11;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JComboBox jComboBox3;
private javax.swing.JComboBox jComboBox4;
private javax.swing.JComboBox jComboBox5;
private javax.swing.JComboBox jComboBox6;
private javax.swing.JComboBox jComboBox7;
private javax.swing.JComboBox jComboBox8;
private javax.swing.JComboBox jComboBox9;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
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.JTextField jTextField1;
// End of variables declaration//GEN-END:variables
}
Listeler.java Sayfası
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class Listeler extends javax.swing.JFrame {
/**
* Creates new form Listeler
*/
public Listeler( ) {
initComponents( );
}
public String listecinsi;//Liste türünü belirlemek için gereken genel değişken
public String[] satırBilgisiAl( int seçilensatır ) //Tabloda hangi satıra tıklandığını bulmak için yzdığımız kod
{
int sütünsayısı=jTable1.getColumnCount( );
String[] result = new String[sütünsayısı];
for ( int i = 0; i < sütünsayısı; i + + )
{
result[i] = jTable1.getModel( ).getValueAt( seçilensatır, i ).toString( );
}
return result;
}
private void AracSahibiYukle( )// kayıtlarının yüklenmesini sağlayan fonksiyon
{
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );
try{
Statement st=conn.createStatement( );
ResultSet rs=st.executeQuery( "SELECT * FROM [Arac_Sahibi]" );
DefaultTableModel DTM = new DefaultTableModel( );
jTable1.setModel( DTM );
DTM.addColumn( "Tc" );
DTM.addColumn( "Ad Soyad" );
DTM.addColumn( "Doğum Tarihi" );
DTM.addColumn( "Doğum Yeri" );
DTM.addColumn( "Cinsiyet" );
DTM.addColumn( "Eposta" );
DTM.addColumn( "Telefon" );
DTM.addColumn( "Adres" );
DTM.addColumn( "Araç Plakası" );
while( rs.next( ) ){
DTM.addRow( new String[]{rs.getString( "Tc" ), rs.getString( "AdSoyad" ), rs.getString( "DTarihi" ), rs.getString( "DYeri" ), rs.getString( "Cinsiyet" ), rs.getString( "Eposta" ), rs.getString( "Tel" ), rs.getString( "Adres" ), rs.getString( "Arac_Plaka" )} );
}
rs.close( );
st.close( );
conn.close( );
jLabel1.setText( "Araç Sahibi Tc:" );
}catch( Exception exp ){
JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );
}
}
private void AraclariYukle( )// kayıtlarının yüklenmesini sağlayan fonksiyon
{
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );
try{
Statement st=conn.createStatement( );
ResultSet rs=st.executeQuery( "SELECT * FROM [Arac_Bilgileri]" );
DefaultTableModel DTM = new DefaultTableModel( );
jTable1.setModel( DTM );
DTM.addColumn( "Plaka" );
DTM.addColumn( "Marka" );
DTM.addColumn( "Model" );
DTM.addColumn( "Motor Hacmi" );
DTM.addColumn( "Kapı Sayısı" );
DTM.addColumn( "Renk" );
DTM.addColumn( "Araç Türü" );
DTM.addColumn( "Ağırlık" );
DTM.addColumn( "Muayene Tarihi" );
DTM.addColumn( "Sonraki Muayene Tarihi" );
while( rs.next( ) ){
DTM.addRow( new String[]{rs.getString( "Plaka" ), rs.getString( "Marka" ), rs.getString( "Model" ), rs.getString( "Motor_Hacmi" ),
rs.getString( "Kapi_Sayisi" ), rs.getString( "Renk" ), rs.getString( "Arac_Turu" ), rs.getString( "Agirlik" ), rs.getString( "Muayene_Tarihi" ), rs.getString( "Sonraki_Muayene_Tarihi" )} );
}
rs.close( );
st.close( );
conn.close( );
jLabel1.setText( "Araç Plaka:" );
}catch( Exception exp ){
JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );
}
}
/**
* 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" )
// //GEN-BEGIN:initComponents
private void initComponents( ) {
jLabel1 = new javax.swing.JLabel( );
jTextField1 = new javax.swing.JTextField( );
jButton1 = new javax.swing.JButton( );
jButton2 = new javax.swing.JButton( );
jScrollPane1 = new javax.swing.JScrollPane( );
jTable1 = new javax.swing.JTable( );
addWindowListener( new java.awt.event.WindowAdapter( ) {
public void windowActivated( java.awt.event.WindowEvent evt ) {
formWindowActivated( evt );
}
public void windowOpened( java.awt.event.WindowEvent evt ) {
formWindowOpened( evt );
}
} );
jLabel1.setText( "jLabel1" );
jButton1.setText( "Düzenle" );
jButton1.addActionListener( new java.awt.event.ActionListener( ) {
public void actionPerformed( java.awt.event.ActionEvent evt ) {
jButton1ActionPerformed( evt );
}
} );
jButton2.setText( "Sil" );
jButton2.addActionListener( new java.awt.event.ActionListener( ) {
public void actionPerformed( java.awt.event.ActionEvent evt ) {
jButton2ActionPerformed( evt );
}
} );
jTable1.setModel( new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
) );
jTable1.addMouseListener( new java.awt.event.MouseAdapter( ) {
public void mouseClicked( java.awt.event.MouseEvent evt ) {
jTable1MouseClicked( evt );
}
} );
jScrollPane1.setViewportView( jTable1 );
javax.swing.GroupLayout layout = new javax.swing.GroupLayout( getContentPane( ) );
getContentPane( ).setLayout( layout );
layout.setHorizontalGroup(
layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addGroup( layout.createSequentialGroup( )
.addContainerGap( )
.addComponent( jLabel1 )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jButton2 )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jButton1 )
.addContainerGap( ) )
.addComponent( jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 908, Short.MAX_VALUE )
);
layout.setVerticalGroup(
layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addGroup( layout.createSequentialGroup( )
.addContainerGap( )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel1 )
.addComponent( jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE )
.addComponent( jButton1 )
.addComponent( jButton2 ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE ) )
);
pack( );
}// //GEN-END:initComponents
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt ) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
String[] seciliSatir = satırBilgisiAl( jTable1.getSelectedRow( ) );
if( listecinsi.equals( "Arac_Sahibi" ) == true )//Düzenle butonuna tıklandığında eğer liste tipi ... listesi ise ... bilgilerini güncellemek için ... düzenleme sayfasına veri gönderiyoruz
{
Arac_Sahibi_Ekle frm = new Arac_Sahibi_Ekle( );
frm.Guncelle=true;
frm.Tc=seciliSatir[0].toString( );
frm.AdSoyad=seciliSatir[1].toString( );
frm.DTarihi=seciliSatir[2].toString( );
frm.DYeri=seciliSatir[3].toString( );
frm.Cinsiyet=seciliSatir[4].toString( );
frm.Eposta=seciliSatir[5].toString( );
frm.Telefon=seciliSatir[6].toString( );
frm.Adres=seciliSatir[7].toString( );
frm.Plaka=seciliSatir[8].toString( );
frm.setVisible( true );
}
else
{
Arac_Ekle frm = new Arac_Ekle( );
frm.Guncelle=true;
frm.Plaka=seciliSatir[0].toString( );
frm.Marka=seciliSatir[1].toString( );
frm.Model=seciliSatir[2].toString( );
frm.MotorHacmi=seciliSatir[3].toString( );
frm.KapiSayisi=seciliSatir[4].toString( );
frm.Renk=seciliSatir[5].toString( );
frm.AracTuru=seciliSatir[6].toString( );
frm.Agirlik=seciliSatir[7].toString( );
frm.MuayeneTarihi=seciliSatir[8].toString( );
frm.SonrakiMuayeneTarihi=seciliSatir[9].toString( );
frm.setVisible( true );
}
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed( java.awt.event.ActionEvent evt ) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
String[] seciliSatir = satırBilgisiAl( jTable1.getSelectedRow( ) );
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );
try{
if( listecinsi.equals( "Arac_Sahibi" ) == true )//liste tipi ... listesi ise tablodan seçili olan kişiyi silmek için kullanılan kod
{
Statement st=conn.createStatement( );
st.executeUpdate( "Delete From [Arac_Sahibi] Where [Tc]='" + jTextField1.getText( ) + "'" );
JOptionPane.showMessageDialog( rootPane, "Araç Sahibi Silindi." );
st.close( );
conn.close( );
AracSahibiYukle( );
}
else
{
//liste tipi ... listesi ise seçili ... silmek için kullanılan kod
Statement st=conn.createStatement( );
st.executeUpdate( "Delete From [Arac_Bilgileri] Where [Plaka]='" + jTextField1.getText( ) + "'" );
JOptionPane.showMessageDialog( rootPane, "Araç Silindi." );
st.close( );
conn.close( );
}
}catch( Exception exp ){
JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );
System.out.println( exp.getMessage( ) );
}
}//GEN-LAST:event_jButton2ActionPerformed
private void jTable1MouseClicked( java.awt.event.MouseEvent evt ) {//GEN-FIRST:event_jTable1MouseClicked
// TODO add your handling code here:
//Tablo üzerinde nereye tıklandığını ve tıklandığı satırdaki ilk sütundaki veriyi textfielde yazdıran kod
String[] seciliSatir = satırBilgisiAl( jTable1.getSelectedRow( ) );
jTextField1.setText( seciliSatir[0].toString( ) );
}//GEN-LAST:event_jTable1MouseClicked
private void formWindowOpened( java.awt.event.WindowEvent evt ) {//GEN-FIRST:event_formWindowOpened
// TODO add your handling code here:
if( listecinsi.equals( "Arac_Sahibi" ) == true )AracSahibiYukle( );//listeler sayfası açılırken ... kayıtlarını yükler
else AraclariYukle( );//Listeler sayfası açılırken ... bilgilerini yükler
}//GEN-LAST:event_formWindowOpened
private void formWindowActivated( java.awt.event.WindowEvent evt ) {//GEN-FIRST:event_formWindowActivated
// TODO add your handling code here:
if( listecinsi.equals( "Arac_Sahibi" ) == true )AracSahibiYukle( );//listeler sayfası açılırken ... kayıtlarını yükler
else AraclariYukle( );//Listeler sayfası açılırken ... bilgilerini yükler
}//GEN-LAST:event_formWindowActivated
/**
* @param args the command line arguments
*/
public static void main( String args[] ) {
/* Set the Nimbus look and feel */
//
/* 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( Listeler.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( InstantiationException ex ) {
java.util.logging.Logger.getLogger( Listeler.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( IllegalAccessException ex ) {
java.util.logging.Logger.getLogger( Listeler.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( javax.swing.UnsupportedLookAndFeelException ex ) {
java.util.logging.Logger.getLogger( Listeler.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater( new Runnable( ) {
public void run( ) {
new Listeler( ).setVisible( true );
}
} );
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
private javax.swing.JTextField jTextField1;
// End of variables declaration//GEN-END:variables
}
Arac_Sahibi_Ekle.java Sayfası
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
public class Arac_Sahibi_Ekle extends javax.swing.JFrame {
/**
* Creates new form Arac_Sahibi_Ekle
*/
public Arac_Sahibi_Ekle( ) {
initComponents( );
AracDoldur( );
}
public String Tc, AdSoyad, DTarihi, DYeri, Cinsiyet, Adres, Telefon, Eposta, Plaka;//Diğer sayfalardan .... bilgilerini düzenlemek için gereken değişkenler
public boolean Guncelle;
private void AracDoldur( )
{
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );//Veri Tabanına Bağlanıyoruz
jComboBox2.removeAllItems( );//Combobox u temizliyoruz
jComboBox2.addItem( "Seçiniz" );//Combobox a seçiniz kaydı ekliyoruz
try{
Statement st=conn.createStatement( );
ResultSet rs=st.executeQuery( "SELECT * FROM [Arac_Bilgileri]" );
while( rs.next( ) ){
jComboBox2.addItem( rs.getString( "Plaka" ) );//Veri tabanındaki ..... combobox a ekliyoruz
}
rs.close( );
st.close( );
conn.close( );
}catch( Exception exp ){
JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );//Olası hatada hata mesajı veriyoruz
}
}
/**
* 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" )
// //GEN-BEGIN:initComponents
private void initComponents( ) {
jComboBox2 = new javax.swing.JComboBox<>( );
jLabel11 = new javax.swing.JLabel( );
jTextField7 = new javax.swing.JTextField( );
jTextField4 = new javax.swing.JTextField( );
jLabel6 = new javax.swing.JLabel( );
jLabel4 = new javax.swing.JLabel( );
jTextField2 = new javax.swing.JTextField( );
jLabel2 = new javax.swing.JLabel( );
jLabel3 = new javax.swing.JLabel( );
jButton1 = new javax.swing.JButton( );
jTextField3 = new javax.swing.JTextField( );
jTextField6 = new javax.swing.JTextField( );
jTextField5 = new javax.swing.JTextField( );
jLabel1 = new javax.swing.JLabel( );
jLabel5 = new javax.swing.JLabel( );
jLabel7 = new javax.swing.JLabel( );
jLabel9 = new javax.swing.JLabel( );
jComboBox1 = new javax.swing.JComboBox<>( );
jTextField1 = new javax.swing.JFormattedTextField( );
setTitle( "Araç Sahibi Ekle Düzenle" );
addWindowListener( new java.awt.event.WindowAdapter( ) {
public void windowOpened( java.awt.event.WindowEvent evt ) {
formWindowOpened( evt );
}
} );
jComboBox2.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Item 1", "Item 2", "Item 3", "Item 4" } ) );
jComboBox2.addItemListener( new java.awt.event.ItemListener( ) {
public void itemStateChanged( java.awt.event.ItemEvent evt ) {
jComboBox2ItemStateChanged( evt );
}
} );
jLabel11.setText( "Cinsiyet:" );
jLabel6.setText( "Telefon:" );
jLabel4.setText( "Doğum Yeri:" );
jLabel2.setText( "Ad Soyad:" );
jLabel3.setText( "Doğum Tarihi:" );
jButton1.setText( "Tamam" );
jButton1.addActionListener( new java.awt.event.ActionListener( ) {
public void actionPerformed( java.awt.event.ActionEvent evt ) {
jButton1ActionPerformed( evt );
}
} );
jLabel1.setText( "TC:" );
jLabel5.setText( "Adres:" );
jLabel7.setText( "Eposta:" );
jLabel9.setText( "Araç Plaka:" );
jComboBox1.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Bay", "Bayan" } ) );
try {
jTextField1.setFormatterFactory( new javax.swing.text.DefaultFormatterFactory( new javax.swing.text.MaskFormatter( "###########" ) ) );
} catch ( java.text.ParseException ex ) {
ex.printStackTrace( );
}
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( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup( )
.addGap( 178, 178, 178 )
.addComponent( jButton1 ) )
.addGroup( layout.createSequentialGroup( )
.addGap( 22, 22, 22 )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel6 )
.addComponent( jLabel5 )
.addComponent( jLabel7 )
.addComponent( jLabel9 ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addComponent( jTextField7, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jTextField6, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jTextField5 )
.addComponent( jComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ) ) )
.addGroup( layout.createSequentialGroup( )
.addContainerGap( )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel11 )
.addComponent( jLabel4 )
.addComponent( jLabel2 )
.addComponent( jLabel3 )
.addComponent( jLabel1 ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addComponent( jTextField4 )
.addComponent( jComboBox1, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jTextField2, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jTextField3, javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jTextField1 ) ) ) )
.addContainerGap( ) )
);
layout.setVerticalGroup(
layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addGroup( layout.createSequentialGroup( )
.addContainerGap( )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel1 )
.addComponent( jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel2 )
.addComponent( jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel3 )
.addComponent( jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel4 )
.addComponent( jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel11 )
.addComponent( jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE )
.addComponent( jLabel7 ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE )
.addComponent( jLabel6 ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE )
.addComponent( jLabel5 ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE )
.addComponent( jLabel9 ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jButton1 )
.addContainerGap( javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ) )
);
pack( );
}// //GEN-END:initComponents
private void jComboBox2ItemStateChanged( java.awt.event.ItemEvent evt ) {//GEN-FIRST:event_jComboBox2ItemStateChanged
// TODO add your handling code here:
}//GEN-LAST:event_jComboBox2ItemStateChanged
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt ) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );
try{
Statement st=conn.createStatement( );
if( Guncelle == false )//Eğer bu sayfaya veri güncellemek için gelinmediyse yeni kayıt yapan kod
{
st.executeUpdate( "INSERT INTO [Arac_Sahibi] ( [Tc], [AdSoyad], [DTarihi], [DYeri], [Cinsiyet], [Eposta], [Tel], [Adres], [Arac_Plaka] ) Values( '" + jTextField1.getText( ) + "', '" + jTextField2.getText( ) + "', '" + jTextField3.getText( ) + "', '" + jTextField4.getText( ) + "', '" + jComboBox1.getSelectedItem( ).toString( ) + "', '" + jTextField5.getText( ) + "', '" + jTextField6.getText( ) + "', '" + jTextField7.getText( ) + "', '" + jComboBox2.getSelectedItem( ).toString( ) + "' )" );
JOptionPane.showMessageDialog( rootPane, "Araç Sahibi Eklendi." );
}
else
{
//Eğer Güncelleme yapılacaksa gereken kod
st.executeUpdate( "Update [Arac_Sahibi] Set [AdSoyad]='" + jTextField2.getText( ) + "', [DTarihi]='" + jTextField3.getText( ) + "', [DYeri]='" + jTextField4.getText( ) + "', [Cinsiyet]='" + jComboBox1.getSelectedItem( ).toString( ) + "', [Eposta]='" + jTextField5.getText( ) + "', [Tel]='" + jTextField6.getText( ) + "', [Adres]='" + jTextField7.getText( ) + "', [Arac_Plaka]='" + jComboBox2.getSelectedItem( ).toString( ) + "' Where [Tc]='" + jTextField1.getText( ) + "'" );
JOptionPane.showMessageDialog( rootPane, "Araç Sahibi Bilgileri Güncellendi." );
}
st.close( );
conn.close( );
this.setVisible( false );//Ekleme veya güncelleme işlemi bittikten sonra sayfayı gizler
}catch( Exception exp ){
JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );
System.out.println( exp.getMessage( ) );
}
}//GEN-LAST:event_jButton1ActionPerformed
private void formWindowOpened( java.awt.event.WindowEvent evt ) {//GEN-FIRST:event_formWindowOpened
// TODO add your handling code here:
if( Guncelle )//Eğer sayfaya veri güncellemek için gelindiyse gerekli alanları dolduran kod
{
jTextField1.setText( Tc );
jTextField1.setEnabled( !Guncelle );
jTextField2.setText( AdSoyad );
jTextField3.setText( DTarihi );
jTextField4.setText( DYeri );
jComboBox1.setSelectedItem( Cinsiyet );
jTextField5.setText( Eposta );
jTextField6.setText( Telefon );
jTextField7.setText( Adres );
jComboBox2.setSelectedItem( Plaka );
}
}//GEN-LAST:event_formWindowOpened
/**
* @param args the command line arguments
*/
public static void main( String args[] ) {
/* Set the Nimbus look and feel */
//
/* 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( Arac_Sahibi_Ekle.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( InstantiationException ex ) {
java.util.logging.Logger.getLogger( Arac_Sahibi_Ekle.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( IllegalAccessException ex ) {
java.util.logging.Logger.getLogger( Arac_Sahibi_Ekle.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( javax.swing.UnsupportedLookAndFeelException ex ) {
java.util.logging.Logger.getLogger( Arac_Sahibi_Ekle.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater( new Runnable( ) {
public void run( ) {
new Arac_Sahibi_Ekle( ).setVisible( true );
}
} );
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel11;
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 jLabel9;
private javax.swing.JFormattedTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
// End of variables declaration//GEN-END:variables
}
Arac_Ekle.java Sayfası
import java.sql.Connection;
import java.sql.Statement;
import javax.swing.JOptionPane;
public class Arac_Ekle extends javax.swing.JFrame {
/**
* Creates new form Arac_Ekle
*/
public Arac_Ekle( ) {
initComponents( );
}
public String Plaka, Marka, Model, MotorHacmi, KapiSayisi, Renk, AracTuru, Agirlik, MuayeneTarihi, SonrakiMuayeneTarihi;//Diğer sayfalardan .... bilgilerini düzenlemek için gereken değişkenler
public boolean Guncelle;
/**
* 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" )
// //GEN-BEGIN:initComponents
private void initComponents( ) {
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( );
jLabel7 = new javax.swing.JLabel( );
jLabel8 = new javax.swing.JLabel( );
jLabel9 = new javax.swing.JLabel( );
jLabel10 = new javax.swing.JLabel( );
jTextField1 = new javax.swing.JTextField( );
jTextField2 = new javax.swing.JTextField( );
jTextField3 = new javax.swing.JTextField( );
jTextField4 = new javax.swing.JTextField( );
jTextField5 = new javax.swing.JTextField( );
jTextField6 = new javax.swing.JTextField( );
jComboBox1 = new javax.swing.JComboBox<>( );
jTextField7 = new javax.swing.JTextField( );
jTextField8 = new javax.swing.JTextField( );
jTextField9 = new javax.swing.JTextField( );
jButton1 = new javax.swing.JButton( );
setTitle( "Araç Ekle Düzenle" );
addWindowListener( new java.awt.event.WindowAdapter( ) {
public void windowOpened( java.awt.event.WindowEvent evt ) {
formWindowOpened( evt );
}
} );
jLabel1.setText( "Plaka:" );
jLabel2.setText( "Marka:" );
jLabel3.setText( "Model:" );
jLabel4.setText( "Motor Hacmi:" );
jLabel5.setText( "Kapı Sayısı:" );
jLabel6.setText( "Renk:" );
jLabel7.setText( "Araç Türü:" );
jLabel8.setText( "Ağırlık:" );
jLabel9.setText( "Muayene Tarihi:" );
jLabel10.setText( "Snrk Muayene Tarihi:" );
jComboBox1.setModel( new javax.swing.DefaultComboBoxModel<>( new String[] { "Seçiniz", "Ticari", "Kişisel" } ) );
jButton1.setText( "Tamam" );
jButton1.addActionListener( new java.awt.event.ActionListener( ) {
public void actionPerformed( java.awt.event.ActionEvent evt ) {
jButton1ActionPerformed( 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( )
.addContainerGap( )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING )
.addComponent( jLabel10 )
.addComponent( jLabel9 )
.addComponent( jLabel8 )
.addComponent( jLabel7 )
.addComponent( jLabel6 )
.addComponent( jLabel5 )
.addComponent( jLabel4 )
.addComponent( jLabel3 )
.addComponent( jLabel2 )
.addComponent( jLabel1 ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false )
.addComponent( jTextField1 )
.addComponent( jTextField2 )
.addComponent( jTextField3 )
.addComponent( jTextField4 )
.addComponent( jTextField5 )
.addComponent( jTextField6 )
.addComponent( jComboBox1, 0, 136, Short.MAX_VALUE )
.addComponent( jTextField7 )
.addComponent( jTextField8 )
.addComponent( jTextField9 ) )
.addContainerGap( javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ) )
.addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup( )
.addContainerGap( javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE )
.addComponent( jButton1 )
.addContainerGap( ) )
);
layout.setVerticalGroup(
layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
.addGroup( layout.createSequentialGroup( )
.addContainerGap( )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel1 )
.addComponent( jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel2 )
.addComponent( jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel3 )
.addComponent( jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel4 )
.addComponent( jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel5 )
.addComponent( jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel6 )
.addComponent( jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel7 )
.addComponent( jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel8 )
.addComponent( jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel9 )
.addComponent( jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addGroup( layout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE )
.addComponent( jLabel10 )
.addComponent( jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE ) )
.addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED )
.addComponent( jButton1 )
.addContainerGap( javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE ) )
);
pack( );
}// //GEN-END:initComponents
private void formWindowOpened( java.awt.event.WindowEvent evt ) {//GEN-FIRST:event_formWindowOpened
// TODO add your handling code here:
if( Guncelle )//Eğer sayfaya veri güncellemek için gelindiyse gerekli alanları dolduran kod
{
jTextField1.setText( Plaka );
jTextField1.setEnabled( !Guncelle );
jTextField2.setText( Marka );
jTextField3.setText( Model );
jTextField4.setText( MotorHacmi );
jTextField5.setText( KapiSayisi );
jTextField6.setText( Renk );
jTextField7.setText( Agirlik );
jTextField8.setText( MuayeneTarihi );
jTextField9.setText( SonrakiMuayeneTarihi );
jComboBox1.setSelectedItem( AracTuru );
}
}//GEN-LAST:event_formWindowOpened
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt ) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
Baglanti baglanti=new Baglanti( );
Connection conn=baglanti.baglan( );
try{
Statement st=conn.createStatement( );
if( Guncelle == false )//Eğer bu sayfaya veri güncellemek için gelinmediyse yeni kayıt yapan kod
{
st.executeUpdate( "INSERT INTO [Arac_Bilgileri] ( [Plaka], [Marka], [Model], [Motor_Hacmi], [Kapi_Sayisi], [Renk], [Arac_Turu], [Agirlik], [Muayene_Tarihi], [Sonraki_Muayene_Tarihi] ) Values( '" + jTextField1.getText( ) + "', '" + jTextField2.getText( ) + "', '" + jTextField3.getText( ) + "', '" + jTextField4.getText( ) + "', '" + jTextField5.getText( ) + "', '" + jTextField6.getText( ) + "', '" + jComboBox1.getSelectedItem( ).toString( ) + "', '" + jTextField7.getText( ) + "', '" + jTextField8.getText( ) + "', '" + jTextField9.getText( ) + "' )" );
JOptionPane.showMessageDialog( rootPane, "Araç Eklendi." );
}
else
{
//Eğer Güncelleme yapılacaksa gereken kod
st.executeUpdate( "Update [Arac_Bilgileri] Set [Marka]='" + jTextField2.getText( ) + "', [Model]='" + jTextField3.getText( ) + "', [Motor_Hacmi]='" + jTextField4.getText( ) + "', [Kapi_Sayisi]='" + jTextField5.getText( ) + "', [Renk]='" + jTextField6.getText( ) + "', [Arac_Turu]='" + jComboBox1.getSelectedItem( ).toString( ) + "', [Agirlik]='" + jTextField7.getText( ) + "', [Muayene_Tarihi]='" + jTextField8.getText( ) + "', [Sonraki_Muayene_Tarihi]='" + jTextField9.getText( ) + "' Where [Plaka]='" + jTextField1.getText( ) + "'" );
JOptionPane.showMessageDialog( rootPane, "Araç Bilgileri Güncellendi." );
}
st.close( );
conn.close( );
this.setVisible( false );//Ekleme veya güncelleme işlemi bittikten sonra sayfayı gizler
}catch( Exception exp ){
JOptionPane.showMessageDialog( rootPane, exp.getMessage( ) );
System.out.println( exp.getMessage( ) );
}
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main( String args[] ) {
/* Set the Nimbus look and feel */
//
/* 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( Arac_Ekle.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( InstantiationException ex ) {
java.util.logging.Logger.getLogger( Arac_Ekle.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( IllegalAccessException ex ) {
java.util.logging.Logger.getLogger( Arac_Ekle.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
} catch ( javax.swing.UnsupportedLookAndFeelException ex ) {
java.util.logging.Logger.getLogger( Arac_Ekle.class.getName( ) ).log( java.util.logging.Level.SEVERE, null, ex );
}
//
/* Create and display the form */
java.awt.EventQueue.invokeLater( new Runnable( ) {
public void run( ) {
new Arac_Ekle( ).setVisible( true );
}
} );
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
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.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
private javax.swing.JTextField jTextField8;
private javax.swing.JTextField jTextField9;
// End of variables declaration//GEN-END:variables
}
Baglanti.java Sayfası
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
//Veri Tabanına bağlanmak için kullandığımız class
public class Baglanti {
private Connection conn;
public Connection baglan( ){
return conn;
}
public Baglanti( ){
String path;
try{
File file = new File( "." );
path=file.getAbsolutePath( );
conn=DriverManager.getConnection( "jdbc:ucanaccess://" + path + "srcmuayene.accdb" );
}catch( Exception exp ){
System.out.println( "Veri Tabanı Bağlantısı Kurulamadı!!!" );
System.out.println( exp.getMessage( ) );
}
}
}
Yazar: TRCodeRooTeR
Tarih: 2022-08-06 02:32:11
Görüntüleme: 862
Yorum: 1