Fatura Hesaplama

import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.sql.*;
public class Calistir extends JFrame implements ActionListener,ListSelectionListener {
      String[] jlb= {"Ad","SoyAd","Tür","MetreKüp","Tutar"};
	  DefaultListModel<String>[] dlm;
	  JList[] jlist;
	  JTextField[] jtext; 
	  JComboBox<String> jcbtur;
	  DefaultListModel<Integer>[] dlm_id;
	  String[] btn_txt= {"Ekle","Sil","Güncelle"};
	  Connection baglanti;
 	public Calistir() {
       this.setTitle("Su Fatura Hesaplama");
       this.setSize(600, 500);
       this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       this.setLayout(new FlowLayout());
       
       JPanel jpn_main=new JPanel();//Diğer panellerin kaymaması için
       jpn_main.setPreferredSize(new Dimension(600,500));
        
       Dimension boyut=new Dimension(100,25);
       
       dlm=new DefaultListModel[jlb.length];
       jlist=new JList[dlm.length];
       dlm_id=new DefaultListModel[2];
       jcbtur=new JComboBox<String>();
       jcbtur.setPreferredSize(boyut);
       jtext=new JTextField[3];
       for(int i=0;i<jlb.length;i++) {
    	   JPanel jpn=new JPanel();
    	   jpn.setPreferredSize(new Dimension(100,450));
    	   JLabel jlbl=new JLabel(jlb[i]);
    	   jlbl.setPreferredSize(boyut);
    	   jpn.add(jlbl);
    	   dlm[i]=new DefaultListModel<String>();
    	   jlist[i]=new JList<String>(dlm[i]);
    	   jlist[i].addListSelectionListener(this);
    	   JScrollPane scp=new JScrollPane(jlist[i]);
    	   scp.setPreferredSize(new Dimension(100,300));
    	   jpn.add(scp);
    	   if(i<jtext.length) {
    		   jtext[i]=new JTextField();
    		   jtext[i].setPreferredSize(boyut);
    	   }
    	   if(i<2) {
    		   jpn.add(jtext[i]);
    	   dlm_id[i]=new DefaultListModel<Integer>();
    	   }
    		   if(i==2) 
        	   jpn.add(jcbtur);
        	if(i==3)
        		jpn.add(jtext[i-1]);
         if(i<btn_txt.length)
         {
        	 JButton jbtn=new JButton(btn_txt[i]);
        	 jbtn.setPreferredSize(boyut);
        	 jbtn.addActionListener(this);
        	 jbtn.setActionCommand(btn_txt[i]);
        	 jpn.add(jbtn);
        	 
         }
    	   jpn_main.add(jpn);
       }
       combodoldur();
       listedoldur();
       this.add(jpn_main);
       this.setVisible(true);
	}
	
@Override
public void actionPerformed(ActionEvent arg0) {
		
	   switch(arg0.getActionCommand()) {
	   case "Ekle":ekle();break;
	   case "Sil":sil();break;
	   case "Güncelle":guncelle();break;
	   }
		
	}
public void ekle() {
try {
	
	int secilentur=jcbtur.getSelectedIndex();
	if(jtext[0].getText().length()>0&&jtext[1].getText().length()>0&&secilentur>-1){
		int secilenid=dlm_id[0].getElementAt(secilentur);
	    int miktar=Integer.parseInt(jtext[2].getText());
	    PreparedStatement sorgu=baglanti.prepareStatement("insert into Faturalar(Ad,SoyAd,TurID,MetreKup) values(?,?,?,?)");
	     sorgu.setString(1, jtext[0].getText());
	     sorgu.setString(2, jtext[1].getText());
	     sorgu.setInt(3, secilenid);
	     sorgu.setInt(4, miktar);
	     sorgu.executeUpdate();
	     listedoldur();
	     for(int i=0;i<jtext.length;i++)
	    	 jtext[i].setText("");
	}

} catch (Exception e) {
	JOptionPane.showMessageDialog(this,e.getMessage());
}
}
public void sil() {
	try {
		int secilen=jlist[0].getSelectedIndex();
		if(secilen>-1) {
			PreparedStatement sorgu=baglanti.prepareStatement("delete from Faturalar where ID=?");
			sorgu.setInt(1, dlm_id[1].getElementAt(secilen));
			sorgu.executeUpdate();
			listedoldur();
		}
	} catch (Exception e) {
		JOptionPane.showMessageDialog(this,e.getMessage());
	}
	
}
public void guncelle() {
	try {
		int secilentur=jcbtur.getSelectedIndex();
		int secilen=jlist[0].getSelectedIndex();
		if(jtext[0].getText().length()>0&&jtext[1].getText().length()>0&&secilentur>-1&&secilen>-1){
			int secilenid=dlm_id[0].getElementAt(secilentur);
		    int miktar=Integer.parseInt(jtext[2].getText());
		    PreparedStatement sorgu=baglanti.prepareStatement("update Faturalar set Ad=?,SoyAd=?,TurID=?,MetreKup=? where ID=?");
		     sorgu.setString(1, jtext[0].getText());
		     sorgu.setString(2, jtext[1].getText());
		     sorgu.setInt(3, secilenid);
		     sorgu.setInt(4, miktar);
		     sorgu.setInt(5, dlm_id[1].getElementAt(secilen));
		     sorgu.executeUpdate();
		     listedoldur();
		     for(int i=0;i<jtext.length;i++)
		    	 jtext[i].setText("");
		}

	} catch (Exception e) {
		JOptionPane.showMessageDialog(this,e.getMessage());
	}
}
public void baglan() {

  try {
	baglanti=DriverManager.getConnection("jdbc:sqlite:Fatura.db");
} catch (Exception e) {
	JOptionPane.showMessageDialog(this,e.getMessage());
}
}
public void combodoldur() {
	try {
		baglan();
		PreparedStatement sorgu=baglanti.prepareStatement("select ID,TUR from Turler");
	jcbtur.removeAllItems();
	dlm_id[0].clear();
	ResultSet veri=sorgu.executeQuery();
	
	while(veri.next()) {
		jcbtur.addItem(veri.getString("TUR"));
		dlm_id[0].addElement(veri.getInt("ID"));
		
	}
	} catch (Exception e) {
		JOptionPane.showMessageDialog(this,e.getMessage());
	}
}
public void listedoldur() {
	try {
		baglan();
		PreparedStatement sorgu=baglanti.prepareStatement("select t.Tur as 'Tad',f.ID as 'ID',f.Ad as 'Ad',f.SoyAd as 'SoyAd',f.MetreKup as 'MetreKup',t.M0F as 'M0F',t.M25F as 'M25F',t.M35f as 'M35F' from Faturalar f inner join Turler t on t.ID=f.TurID");
	    ResultSet veri=sorgu.executeQuery();
	  
	    for(int i=0;i<dlm.length;i++)
	    	dlm[i].clear();
	    dlm[1].clear();
	   
	    while(veri.next()) {
	    	
	    	dlm_id[1].addElement(veri.getInt("ID"));
	    	dlm[0].addElement(veri.getString("Ad"));
	    	dlm[1].addElement(veri.getString("SoyAd"));
	    	dlm[2].addElement(veri.getString("Tad"));
	    	double metrekup=veri.getDouble("MetreKup");
	    	dlm[3].addElement(metrekup+"");
	    	double tutar=0;
	    	if(0<metrekup&&metrekup<25)
	    		tutar=metrekup*veri.getInt("M0F");
	    	if(25<metrekup&&metrekup<35)
	    		tutar=metrekup*veri.getInt("M0F")+metrekup*veri.getInt("M25F");
	    	if(metrekup>35)
	    		tutar=metrekup*veri.getInt("M0F")+metrekup*veri.getInt("M25F")+metrekup*veri.getInt("M35F");
	    	dlm[4].addElement(""+tutar);
	    }
	
	} catch (Exception e) {
		JOptionPane.showMessageDialog(this,e.getMessage());
	}
}
 public static void main(String[] arg) {
	 
	 new Calistir();
 }

@Override
public void valueChanged(ListSelectionEvent e) {
	JList secilen=(JList)e.getSource();
	for(int i=0;i<jlist.length;i++)
		jlist[i].setSelectedIndex(secilen.getSelectedIndex());
	
}

}

Cafe otomasyon

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Calistir extends JFrame implements ActionListener,ListSelectionListener{
        
		JList<String>[] jlist;
        DefaultListModel<String>[] dlm;
        DefaultListModel<Integer>[] id;
        DefaultListModel<Double> fiyat;
        JTextField jtmiktar;
        JComboBox<String>[] jcb;
        String[] jlb_text= {"Masalar","Ürünler","Miktar","Fiyat","Tutar"};
        String[] btn_isim= {"Ekle","Sil","Güncelle","Adisyon","Göster"};
        Connection baglanti;
        public Calistir() {
		 this.setTitle("Cafe Otomasyon");
		 this.setSize(750, 750);
		 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 this.setLayout(new FlowLayout());
		 
		 JPanel main_jpn=new JPanel();
		 main_jpn.setPreferredSize(new Dimension(700,700));
		 main_jpn.setLayout(new FlowLayout());

		dlm=new DefaultListModel[jlb_text.length];
		jlist=new JList[dlm.length];
		jcb=new JComboBox[2];//
		id=new DefaultListModel[3];
		fiyat=new DefaultListModel<Double>();
		for(int i=0;i<dlm.length;i++)
		{    
			JPanel jpn=new JPanel();
			jpn.setPreferredSize(new Dimension(100,600));
			JLabel jlb=new JLabel(jlb_text[i]);
			jlb.setPreferredSize(new Dimension(100,25));
			dlm[i]=new DefaultListModel<String>();
			jlist[i]=new JList<String>(dlm[i]);
			jlist[i].addListSelectionListener(this);
			JScrollPane  jscp=new JScrollPane(jlist[i]);
			jscp.setPreferredSize(new Dimension(100,350));
			JButton jbtn=new JButton(btn_isim[i]);
			jbtn.setPreferredSize(new Dimension(100,25));
			jbtn.addActionListener(this);
			jbtn.setActionCommand(btn_isim[i]);
			jpn.add(jlb);
			jpn.add(jscp);
			if(i<jcb.length)
			{   id[i]=new DefaultListModel<Integer>();
				jcb[i]=new JComboBox<String>();
				jcb[i].setPreferredSize(new Dimension(100,25));
				jpn.add(jcb[i]);
			}
			if(i==jcb.length)
			{    id[i]=new DefaultListModel<Integer>();
				jtmiktar=new JTextField();
				jtmiktar.setPreferredSize(new Dimension(100,25));
				jpn.add(jtmiktar);
			}
			if(i>jcb.length)
			{
				JPanel bosjpn=new JPanel();
				bosjpn.setPreferredSize(new Dimension(100,25));
				jpn.add(bosjpn);
			}
			jpn.add(jbtn);
			main_jpn.add(jpn);
		}
		 combodoldur();
		 listedoldur();
		 this.add(main_jpn);
		 this.setVisible(true);
	}
  public static void main(String[] arg) {
	  new Calistir();
  }
@Override
public void actionPerformed(ActionEvent arg0) {
	switch(arg0.getActionCommand()) {
	case "Ekle":ekle();break;
	case "Sil":sil();break;
	case "Güncelle":guncelle();break;
	case "Adisyon":adisyon();break;
	case "Göster":goster();break;
	}
	
}
public void ekle() {
	int secilen_masa=jcb[0].getSelectedIndex();
	int secilen_urun=jcb[1].getSelectedIndex();
	if(secilen_masa>-1&&secilen_urun>-1&&jtmiktar.getText().length()>0) {
	try {
		double miktar=Double.parseDouble(jtmiktar.getText());
		int masa_id=id[0].getElementAt(secilen_masa);
		int urun_id=id[1].getElementAt(secilen_urun);
	   	   if(baglanti.isClosed())
			  baglan();
		   PreparedStatement sorgu=baglanti.prepareStatement("insert into Adisyon(MasaID,UrunID,Miktar) values(?,?,?)");
		   sorgu.setInt(1, masa_id);
		   sorgu.setInt(2, urun_id);
		   sorgu.setDouble(3, miktar);
		   sorgu.executeUpdate();
		   baglanti.close();
		   jtmiktar.setText("");
		   jcb[0].setSelectedIndex(0);
		   jcb[1].setSelectedIndex(0);
		   listedoldur();
	}catch(Exception ex)
	{
		JOptionPane.showMessageDialog(this, ex.getMessage());
	}
	}
}
public void sil() {
	int secilen=jlist[0].getSelectedIndex();
	if(secilen>-1) {
 	try {
 		if(baglanti.isClosed())
 			baglan();
         PreparedStatement sorgu=baglanti.prepareStatement("delete from Adisyon where ID=?");
         sorgu.setInt(1, id[2].getElementAt(secilen));
         sorgu.executeUpdate();
         baglanti.close();
         listedoldur();
	}
	catch(Exception ex)
	{
		JOptionPane.showMessageDialog(this, ex.getMessage());
	}
}
}
public void guncelle() {
	int secilen=jlist[0].getSelectedIndex();
	int secilen_masa=jcb[0].getSelectedIndex();
	int secilen_urun=jcb[1].getSelectedIndex();
	if(secilen>-1&&secilen_masa>-1&&secilen_urun>-1) {
	
		try {
			double miktar=Double.parseDouble(jtmiktar.getText());
			
			if(baglanti.isClosed())
				baglan();
		    int masa_id=id[0].getElementAt(secilen_masa);
			int urun_id=id[1].getElementAt(secilen_urun);
			int adisyon_id=id[2].getElementAt(secilen);//liste adisyon idler
		    PreparedStatement sorgu=baglanti.prepareStatement("update Adisyon set MasaID=?,UrunID=?,Miktar=? where ID=?");
			sorgu.setInt(1, masa_id);
			sorgu.setInt(2, urun_id);
			sorgu.setDouble(3, miktar);
			sorgu.setInt(4, adisyon_id);
            sorgu.executeUpdate();
            baglanti.close();
            listedoldur();
            jtmiktar.setText("");
		}
		catch(Exception ex)
		{
			JOptionPane.showMessageDialog(this, ex.getMessage());
		}
	}	
}
public void adisyon() {
	 int secilen=jcb[0].getSelectedIndex();
		if(secilen>-1) {
		try {
			if(baglanti.isClosed())
				baglan();
	       PreparedStatement sorgu=baglanti.prepareStatement("delete from Adisyon where MasaID=?");
		   sorgu.setInt(1, id[0].getElementAt(secilen));
		   sorgu.executeUpdate();
		   baglanti.close();
		  listedoldur();
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
	    
		}
    }
public void goster() {
	 int secilen=jcb[0].getSelectedIndex();
		if(secilen>-1) {
		try {
			if(baglanti.isClosed())
				baglan();
	       PreparedStatement sorgu=baglanti.prepareStatement("select u.UrunAd as 'UrunAd',(u.UrunFiyat*a.Miktar) as 'Tutar' from Adisyon a inner join Urunler u  on u.ID=a.UrunID where a.MasaID=?");
		   sorgu.setInt(1, id[0].getElementAt(secilen));
		   int sayac=0;
		   ResultSet veri=sorgu.executeQuery();
		  String urunler="";
		  double tutar=0.0;
		   while(veri.next())
		   {
			   if(urunler.length()>0)
				   urunler+=",";
			   urunler+=veri.getString("UrunAd");
			   tutar+=veri.getDouble("Tutar");
		   sayac++;
		   }
		   veri.close();
		   baglanti.close();
		   JOptionPane.showMessageDialog(this,"Ürün Sayısı="+sayac+" "+urunler+" Toplam Tutar="+tutar);
		} catch (Exception e) {
			JOptionPane.showMessageDialog(this, e.getMessage());	
			}
		}
}
public void baglan(){
 
	try {
	baglanti=DriverManager.getConnection("jdbc:sqlite:otomasyon.db");
} catch (Exception e) {
	JOptionPane.showMessageDialog(this, e.getMessage());
}	
}
public void combodoldur(){
	PreparedStatement sorgu=null;
	ResultSet veri=null;
try {
	baglan();
	sorgu=baglanti.prepareStatement("select ID,UrunAd,UrunFiyat from Urunler");
	veri=sorgu.executeQuery();
    for(int i=0;i<jcb.length;i++)
    {
    	jcb[i].removeAllItems();
    	id[i].clear();
    }
     fiyat=new DefaultListModel<Double>();
	while(veri.next())
	{
	     jcb[1].addItem(veri.getString("UrunAd"));	
	     id[1].addElement(veri.getInt("ID"));
	     fiyat.addElement(veri.getDouble("UrunFiyat"));
	}
     veri.close();
     sorgu=baglanti.prepareStatement("select ID,MasaAdi from Masalar");
     veri=sorgu.executeQuery();
     while(veri.next())
     {
    	 jcb[0].addItem(veri.getString("MasaAdi"));
    	 id[0].addElement(veri.getInt("ID"));
     }
} catch (Exception e) {
	JOptionPane.showMessageDialog(this, e.getMessage());
}
}
public void listedoldur() {
	try {
		baglan();
		String sql="select a.ID as 'ID',m.MasaAdi as 'MasaAdi',u.UrunAd as 'UrunAd',a.Miktar as 'Miktar',u.UrunFiyat as 'Fiyat',u.UrunFiyat*a.Miktar as 'Tutar'  from Masalar m inner join Adisyon  a on m.ID=a.MasaID inner join Urunler u on u.ID=a.UrunID"; 
		PreparedStatement sorgu=baglanti.prepareStatement(sql);
		for(int i=0;i<dlm.length;i++)
			dlm[i].clear();
		id[2].clear();
		ResultSet veri=sorgu.executeQuery();
		while(veri.next())
		{   id[2].addElement(veri.getInt("ID"));
			dlm[0].addElement(veri.getString("MasaAdi"));
			dlm[1].addElement(veri.getString("UrunAd"));
			double miktar=veri.getDouble("Miktar");
			dlm[2].addElement(miktar+"");
			double fiyat=veri.getDouble("Fiyat");
			dlm[3].addElement(fiyat+"");	
			double tutar=fiyat*miktar;
			dlm[4].addElement(""+tutar);
		}
		veri.close();
		baglanti.close();
	} catch (Exception e) {
		JOptionPane.showMessageDialog(this, e.getMessage());
	}
	
}
@Override
public void valueChanged(ListSelectionEvent e) {
	JList secilen=(JList)e.getSource();
	for(int i=0;i<jlist.length;i++)
		 jlist[i].setSelectedIndex(secilen.getSelectedIndex());
	
}
}

 

Su İhtiyac Hesaplama

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;

public class Calistir extends JFrame implements ActionListener, ListSelectionListener {
      String[] jlbl= {"Ad","SoyAd","Kilo","Günlük Su İhtiyacı"};
	  DefaultListModel<String>[] dlm;
	  DefaultListModel<Integer> dlm_id;
	  JList<String>[] jlist;
 	  JTextField[] jtext;
 	  JTextField[] jtext_gun;
 	  JPanel main_jpn;
	  JButton jbtn;
	  String[] btn_text= {"Ekle","Sil","Güncelle"};
	  Connection baglanti=null;
	  JFrame gun_frm;
	  public Calistir() {
		this.setTitle("Su İhtiyacı Hesaplama");
		this.setSize(450, 450);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setLayout(new FlowLayout());
		
		dlm=new DefaultListModel[jlbl.length];
		jlist=new JList[dlm.length];
		dlm_id=new DefaultListModel<Integer>();
		jtext=new JTextField[dlm.length-1];
		main_jpn=new JPanel();
		main_jpn.setPreferredSize(new Dimension(450,450));
		for(int i=0;i<dlm.length;i++)
		{
			JPanel jpn=new JPanel();
			jpn.setPreferredSize(new Dimension(100,450));
			jpn.setLayout(new FlowLayout());
		    JLabel jlab=new JLabel(jlbl[i]);
		    jlab.setPreferredSize(new Dimension(100,20));
			dlm[i]=new DefaultListModel<String>();
		    jlist[i]=new JList<String>(dlm[i]);
		    jlist[i].addListSelectionListener(this);
           JScrollPane jscp=new JScrollPane(jlist[i]);
           jscp.setPreferredSize(new Dimension(100,300));
           jpn.add(jlab);
           jpn.add(jscp);
            if(i<jtext.length)
            {
            	jtext[i]=new JTextField();
            	jtext[i].setPreferredSize(new Dimension(100,25));
            	jbtn=new JButton(btn_text[i]);
            	jbtn.setPreferredSize(new Dimension(100,25));
            	jbtn.addActionListener(this);
            	jbtn.setActionCommand(btn_text[i]);
            	jpn.add(jtext[i]);
            	jpn.add(jbtn);
            }
           main_jpn.add(jpn);
		}
		verigetir();
		this.add(main_jpn);
		this.setVisible(true);
	}

	@Override
	public void valueChanged(ListSelectionEvent arg0) {//Herhangi jlistler tıklanırsa tıklansın bu fonksiyon çalısır
		  JList jsecilen=(JList)arg0.getSource();
		  for(int i=0;i<jlist.length;i++)
			  jlist[i].setSelectedIndex(jsecilen.getSelectedIndex());
	}
	@Override
	public void actionPerformed(ActionEvent arg0) {
        int secilen=jlist[0].getSelectedIndex();
		switch(arg0.getActionCommand())
		{
		case "Ekle":Ekle();break; 
		case "Sil":Sil();break; 
		case "Güncelle":Guncelle();break; 
		case "guncelle":guncelle(secilen);break;
		case "cıkıs":cıkıs();break;
		}
	}
	public double sayicevir(String s)
	{   
		double sayi=-1;
		try {
			sayi=Double.parseDouble(s);
			return sayi;
		}catch(Exception ex)
		{
			return sayi;
		}	
	}
	public boolean dogrula(JTextField[] txt)
	{
		int sayac=0;
		for(int i=0;i<txt.length;i++)
			if(txt[i].getText().length()>0)
				  sayac++;
		  if(sayac==txt.length)
			  return true;
	         
	return false;
		  }
public void Ekle() {
	double kilo=sayicevir(jtext[2].getText());
	if(dogrula(jtext)&&kilo!=-1) {
		 double ihtiyac=0.032*kilo;
		    int ihtiyac1=(int)(ihtiyac*100);
		    ihtiyac=ihtiyac1/100.0;
		try {
			baglan();
			PreparedStatement sorgu=baglanti.prepareStatement("insert into Sahıslar(S_Ad,S_SoyAd,S_Kilo,S_Suihtiyac) values(?,?,?,?)");
			sorgu.setString(1, jtext[0].getText());
			sorgu.setString(2, jtext[1].getText());
			sorgu.setDouble(3, kilo);
			sorgu.setDouble(4, ihtiyac);
			sorgu.executeUpdate();
			baglanti.close();
			for(int i=0;i<jtext.length;i++)
				    jtext[i].setText("");
			verigetir();
		}catch(Exception ex)
		{
			JOptionPane.showMessageDialog(this, ex.getMessage());
		}
	}
}
public void Sil() {
 int secilen=jlist[0].getSelectedIndex();
 if(secilen>-1)
 {
	 try {
		 baglan();
		 PreparedStatement sorgu=baglanti.prepareStatement("delete from Sahıslar where S_No=?");
		 sorgu.setInt(1, dlm_id.getElementAt(secilen)); 
		 sorgu.executeUpdate();
		 baglanti.close();
		 verigetir();
	 }
	 catch(Exception ex)
	 {
		 JOptionPane.showMessageDialog(this, ex.getMessage());
	 }
 }
	
}	
public void Guncelle() {
 int secilen=jlist[0].getSelectedIndex();
 
	if(secilen>-1)
	{   
		this.setVisible(false);
		gun_frm(dlm,secilen);	
	}
}
public void guncelle(int secilen)
{   double kilo=sayicevir(jtext_gun[2].getText());
	if(dogrula(jtext_gun)&&kilo!=-1&&secilen>-1)
	{
		try {
			baglan();
			PreparedStatement sorgu=baglanti.prepareStatement("update Sahıslar set S_Ad=?,S_SoyAd=?,S_Kilo=?,S_Suihtiyac=? where S_No=?");
			sorgu.setString(1, jtext_gun[0].getText());
			sorgu.setString(2, jtext_gun[1].getText());
			sorgu.setDouble(3, kilo);
			double ihtiyac=0.032*kilo;
			int ihtiyac1=(int)(ihtiyac*100);//Virgulden sonra iki basamak alamak için
            sorgu.setDouble(4,ihtiyac1/100.0);
            sorgu.setInt(5, dlm_id.getElementAt(secilen));
            sorgu.executeUpdate();
            baglanti.close();
            verigetir();//buraya kadar hersey yapılırsa jlistleri dolduruyorum
            this.setVisible(true);//Ana formun visible 'nı true(görünür) yapıyorum
            gun_frm.dispose();//ve gun_frm formun yok ediyorum
		}catch(Exception ex)
		{
			JOptionPane.showMessageDialog(this, ex.getMessage());
			
		}
		
	}
}
public void cıkıs() {
	this.setVisible(true);
	gun_frm.dispose();
}
public void baglan() {
	
	try {
       Class.forName("org.sqlite.JDBC");
	 baglanti=DriverManager.getConnection("jdbc:sqlite:Suihtiyac.db");	
   }
	catch(Exception ex){
	
		JOptionPane.showMessageDialog(this, ex.getMessage());
}
}
public void verigetir()
{
   try {
	   baglan();
	   Statement sorgu=baglanti.createStatement();
	   ResultSet veri=sorgu.executeQuery("select S_No,S_Ad,S_SoyAd,S_Kilo,S_Suihtiyac from Sahıslar");
	   for(int i=0;i<dlm.length;i++)
		   dlm[i].clear();
	   dlm_id.clear();
	   while(veri.next())
	   {
		   dlm_id.addElement(veri.getInt("S_No"));
		   dlm[0].addElement(veri.getString("S_Ad"));
		   dlm[1].addElement(veri.getString("S_SoyAd"));
		   dlm[2].addElement(veri.getDouble("S_Kilo")+"");
		   dlm[3].addElement(veri.getDouble("S_Suihtiyac")+" Lt"); 
	   }
	   veri.close();
	   baglanti.close();
	   
   }catch(Exception ex)	{
	   
	   JOptionPane.showMessageDialog(this, ex.getMessage());
   }

}
public void gun_frm(DefaultListModel<String>[] dlm,int secilen)
{
    gun_frm=new JFrame("Güncelle");
	gun_frm.setSize(250,200);
	gun_frm.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);//X simgesine basıldığında hiç bir sey yapama
	gun_frm.setLayout(new FlowLayout());
    
	JPanel ana_jpn=new JPanel();
	JPanel jpn_lbl=new JPanel();
	JPanel jpn_jtext=new JPanel();
	ana_jpn.setPreferredSize(new Dimension(250,200));
	jpn_lbl.setPreferredSize(new Dimension(40,130));
	jpn_jtext.setPreferredSize(new Dimension(100,130));
	
	jtext_gun=new JTextField[jtext.length];
	for(int i=0;i<jtext_gun.length;i++)
	{
		jtext_gun[i]=new JTextField();
		jtext_gun[i].setPreferredSize(new Dimension(100,20));
	    JLabel jlb_gun= new JLabel(jlbl[i]+":");
	    jlb_gun.setPreferredSize(new Dimension(40,20));
	    jlb_gun.setHorizontalAlignment(JLabel.RIGHT);
	    jpn_lbl.add(jlb_gun);
	    jpn_jtext.add(jtext_gun[i]);
	    jtext_gun[i].setText(dlm[i].getElementAt(secilen));
	}
	jbtn=new JButton("Güncelle");
	jbtn.setPreferredSize(new Dimension(100,20));
	jbtn.addActionListener(this);
	jbtn.setActionCommand("guncelle");
	jpn_jtext.add(jbtn);
	jbtn=new JButton("Çık");
	jbtn.setPreferredSize(new Dimension(100,20));
	jbtn.addActionListener(this);
	jbtn.setActionCommand("cıkıs");
	jpn_jtext.add(jbtn);
	ana_jpn.add(jpn_lbl);
	ana_jpn.add(jpn_jtext);
	gun_frm.add(ana_jpn);
	gun_frm.setVisible(true);	
}
public static void main(String[] args) {
		new Calistir();
	}
}