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

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class musteriler {
    
    PreparedStatement ps;
    ResultSet rs;
    
    private String m_no;
    private String m_ad;
    private String m_soyad;
    private String m_tel;
    private String m_email;
    private String m_adres;
    private String m_sehir;
    
    
    public List<musteriler> musteriListesi()
   {
       int sayac = 0,i=0;
       veritabani_baglanti vb = new veritabani_baglanti();
       vb.baglan();
       List<musteriler> mlist = new ArrayList<musteriler>();
       musteriler [] musterilist;
       try
       {
           String sorgu = "select * from musteriler";
           ps = vb.con.prepareStatement(sorgu);
           rs = ps.executeQuery();
           while(rs.next())
           {
               sayac = sayac+1;
           }
           musterilist = new musteriler[sayac];
           String sorgu2 = "select * from musteriler";
           ps = vb.con.prepareStatement(sorgu2);
           rs = ps.executeQuery();
           while(rs.next())
           {
               musterilist[i] = new musteriler();
               musterilist[i].setM_no(rs.getString(1));
               musterilist[i].setM_ad(rs.getString(2));
               musterilist[i].setM_soyad(rs.getString(3));
               musterilist[i].setM_tel(rs.getString(4));
               musterilist[i].setM_email(rs.getString(5));
               musterilist[i].setM_adres(rs.getString(6));
               musterilist[i].setM_sehir(rs.getString(7));
               mlist.add(musterilist[i]);
               i=i+1;
           }
       }
       catch(Exception e)
       {
           System.err.println(e);
           
       }
       return mlist;
   }
    
    public boolean musteri_sil(musteriler msil)
    {
        try
        {
            veritabani_baglanti vb = new veritabani_baglanti();
            vb.baglan();
            
            String sorgu = "delete from musteriler where m_no = ?";
            ps=vb.con.prepareStatement(sorgu);
            ps.setString(1, msil.getM_no());
            ps.execute();
        }
        catch(Exception ex)
        {
            System.err.println(ex);
            return false;
        }
        return true;
        
    }

    public String getM_no() {
        return m_no;
    }

    public void setM_no(String m_no) {
        this.m_no = m_no;
    }

    public String getM_ad() {
        return m_ad;
    }

    public void setM_ad(String m_ad) {
        this.m_ad = m_ad;
    }

    public String getM_soyad() {
        return m_soyad;
    }

    public void setM_soyad(String m_soyad) {
        this.m_soyad = m_soyad;
    }

    public String getM_tel() {
        return m_tel;
    }

    public void setM_tel(String m_tel) {
        this.m_tel = m_tel;
    }

    public String getM_email() {
        return m_email;
    }

    public void setM_email(String m_email) {
        this.m_email = m_email;
    }

    public String getM_adres() {
        return m_adres;
    }

    public void setM_adres(String m_adres) {
        this.m_adres = m_adres;
    }

    public String getM_sehir() {
        return m_sehir;
    }

    public void setM_sehir(String m_sehir) {
        this.m_sehir = m_sehir;
    }
    
    
    
}
