package tr.org.hmyo.yusufGui;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import
java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import
java.awt.event.WindowFocusListener;
import java.sql.Connection;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import
javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import
javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import
net.sf.jasperreports.engine.JRException;
import
net.sf.jasperreports.engine.JasperFillManager;
import
net.sf.jasperreports.engine.JasperPrint;
import
net.sf.jasperreports.view.JasperViewer;
import tr.org.hmyo.yusuf.Dao.ConnectionToDb;
import
tr.org.hmyo.yusuf.Dao.HayvanBilgileriDao;
import
tr.org.hmyo.yusuf.Dao.KasapekleDao;
import
tr.org.hmyo.yusuf.Dao.KesimYapanDao;
import
tr.org.hmyo.yusuf.Dao.VeterinerDao;
import
tr.org.hmyo.yusuf.Domain.HayvanBilgileriDomain;
import
tr.org.hmyo.yusuf.Domain.KasapDomain;
import
tr.org.hmyo.yusuf.Domain.KesimYapanDomain;
import
tr.org.hmyo.yusuf.Domain.VeterinerDomain;
import
com.toedter.calendar.JDateChooser;
public class AnaPencereGui extends
JFrame implements pencereInfc {
ArkaPlan
plan = new ArkaPlan(new BorderLayout());
public
void initpencere() {
setTitle("MEZBAHANE TAKİP KONTROL
SİSTEMİ");
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
public
JPanel initPanel() {
JPanel
anaJPanel = new JPanel(new BorderLayout());
anaJPanel.setOpaque(false);
JPanel
ortaJPanel = new JPanel(new GridLayout(1, 2, 5, 5));
ortaJPanel.setOpaque(false);
JPanel
ustJPanel = new JPanel(new BorderLayout());
ustJPanel.setOpaque(false);
JPanel
altJPanel = new JPanel(new GridLayout(1, 3, 5, 5));
altJPanel.setOpaque(false);
anaJPanel.add(ortaJPanel,
BorderLayout.CENTER);
anaJPanel.add(altJPanel,
BorderLayout.SOUTH);
anaJPanel.add(ustJPanel,
BorderLayout.NORTH);
JPanel
ortasolJPanel = new JPanel(new BorderLayout());
ortasolJPanel.setOpaque(false);
JPanel
ortasagJPanel = new JPanel(new GridLayout(2, 1, 5, 5));
ortasagJPanel.setOpaque(false);
ortaJPanel.add(ortasolJPanel,
BorderLayout.WEST);
ortaJPanel.add(ortasagJPanel,
BorderLayout.EAST);
JPanel
ortasagust = new JPanel(new GridLayout(8, 2, 5, 5));
ortasagust.setOpaque(false);
JPanel
ortasagalt = new JPanel(new BorderLayout());
ortasagalt.setOpaque(false);
ortasagJPanel.add(ortasagust,
BorderLayout.SOUTH);
ortasagJPanel.add(ortasagalt,
BorderLayout.NORTH);
ortasolJPanel.setBorder(BorderFactory
.createTitledBorder("KASAP
LİSTESİ"));
JPanel
kasapbulJPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
kasapbulJPanel.setOpaque(false);
JLabel
kasapbulJLabel = new JLabel("Kasap Bul");
kasapbulJLabel.setForeground(Color.red);
kasapbulJLabel.setFont(new
Font("verdana", Font.BOLD+Font.ITALIC, 12));
final
JTextField kasapbulField = new JTextField(20);
kasapbulJPanel.add(kasapbulJLabel);
kasapbulJPanel.add(kasapbulField);
ortasolJPanel.add(kasapbulJPanel,
BorderLayout.NORTH);
final
JList kasaplarJList = new JList();
//kasaplarJList.setOpaque(false);
kasaplarJList.setListData(KasapekleDao.listele().toArray());
JScrollPane
kasaplatrJScrollPane = new JScrollPane(kasaplarJList);
kasaplatrJScrollPane.setOpaque(false);
kasaplarJList.setBackground(Color.YELLOW);
List<KasapDomain>
liste = new ArrayList<KasapDomain>();
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
kasaplatrJScrollPane.setOpaque(false);
//
ortasolJPanel.add(kasaplarJList);
ortasolJPanel.add(kasaplatrJScrollPane,
BorderLayout.CENTER);
JPanel
kasabsilJPanel = new JPanel(new GridLayout(1, 1, 5, 5));
kasabsilJPanel.setOpaque(false);
JButton
kasabduzenleButton = new JButton("Kasap Düzenle",
new
ImageIcon("iconslar/duzenle.png"));
kasabduzenleButton.setOpaque(false);
kasabduzenleButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
SwingUtilities.invokeLater(new
Runnable() {
new
HesapBilgileriGuncelleme();
kasabsilJPanel.add(kasabduzenleButton);
ortasolJPanel.add(kasabsilJPanel,
BorderLayout.SOUTH);
ortasagust.setBorder(BorderFactory
.createTitledBorder("KESİM
YAPILAN HAYVANLARIN ÖZELLİKLERİ"));
JLabel
tarihJLabel = new JLabel("TARİH SEÇİNİZ", JLabel.RIGHT);
final
JDateChooser tarihChooser = new JDateChooser(new java.util.Date());
tarihJLabel.setForeground(Color.red);
tarihJLabel.setFont(new
Font("verdana", Font.BOLD+Font.ITALIC, 12));
JLabel
kesilenhayvanJLabel = new JLabel("KESİLEN HAYVAN:", JLabel.RIGHT);
kesilenhayvanJLabel.setForeground(Color.red);
kesilenhayvanJLabel.setFont(new
Font("verdana", Font.BOLD+Font.ITALIC, 12));
JLabel
kupenumarasiJLabel = new JLabel("KÜPE NUMARASI:", JLabel.RIGHT);
kupenumarasiJLabel.setForeground(Color.red);
kupenumarasiJLabel.setFont(new
Font("verdana", Font.BOLD+Font.ITALIC, 12));
JLabel
cinsiyetiJLabel = new JLabel("CİNSİYETİ:", JLabel.RIGHT);
cinsiyetiJLabel.setForeground(Color.red);
cinsiyetiJLabel.setFont(new
Font("verdana", Font.BOLD+Font.ITALIC, 12));
JLabel
veterineradiJLabel = new JLabel("KONTROL EDEN
VETERİNER:",JLabel.RIGHT);
veterineradiJLabel.setForeground(Color.red);
veterineradiJLabel.setFont(new
Font("verdana", Font.BOLD+Font.ITALIC, 12));
JLabel
kesimyapanadiJLabel = new JLabel("KESİM YAPAN KİŞİ:",JLabel.RIGHT);
kesimyapanadiJLabel.setForeground(Color.red);
kesimyapanadiJLabel.setFont(new
Font("verdana", Font.BOLD+Font.ITALIC, 12));
JLabel
tutarJLabel = new JLabel("TUTAR:", JLabel.RIGHT);
tutarJLabel.setForeground(Color.red);
tutarJLabel.setFont(new
Font("verdana", Font.BOLD+Font.ITALIC, 12));
JPanel
radioJPanel = new JPanel(new GridLayout(1, 2, 2, 2));
//radioJPanel.setOpaque(false);
ButtonGroup
group = new ButtonGroup();
final
JRadioButton buyukBasButton = new JRadioButton("Büyük Baş");
buyukBasButton.setOpaque(false);
radioJPanel.add(buyukBasButton);
group.add(buyukBasButton);
final
JRadioButton kucukBasButton = new JRadioButton("Küçük Baş");
//kucukBasButton.setOpaque(false);
kucukBasButton.setSelected(true);
radioJPanel.add(kucukBasButton);
group.add(kucukBasButton);
ortaJPanel.add(radioJPanel);
JPanel
kupeNumarasiJPanel = new JPanel(new GridLayout(1, 3, 4, 4));
//kupeNumarasiJPanel.setOpaque(false);
final
JTextField kupenumarasiField = new JTextField(5);
//kupenumarasiField.setOpaque(false);
kupeNumarasiJPanel.add(kupenumarasiField);
JPanel
cinsiyetradioJPanel = new JPanel(new GridLayout(1, 2, 2, 2));
//cinsiyetradioJPanel.setOpaque(false);
ButtonGroup
cinsiyetgroup = new ButtonGroup();
final
JRadioButton disiButton = new JRadioButton("Dişi");
disiButton.setOpaque(false);
cinsiyetradioJPanel.add(disiButton);
cinsiyetgroup.add(disiButton);
final
JRadioButton erkekButton = new JRadioButton("Erkek");
erkekButton.setOpaque(false);
erkekButton.setSelected(true);
cinsiyetradioJPanel.add(erkekButton);
cinsiyetgroup.add(erkekButton);
final
JComboBox<Object> veterineradiComboBox = new JComboBox<>(
VeterinerDao.listele().toArray());
//veterineradiComboBox.setOpaque(false);
final
JComboBox<Object> kesimyapanComboBox = new JComboBox<>(
KesimYapanDao.listele().toArray());
//kesimyapanComboBox.setOpaque(false);
final
JTextField tutarField = new JTextField(10);
//tutarField.setOpaque(false);
ortasagust.add(tarihJLabel);
ortasagust.add(tarihChooser);
ortasagust.add(kesilenhayvanJLabel);
ortasagust.add(radioJPanel);
ortasagust.add(cinsiyetiJLabel);
ortasagust.add(cinsiyetradioJPanel);
ortasagust.add(kupenumarasiJLabel);
ortasagust.add(kupeNumarasiJPanel);
ortasagust.add(veterineradiJLabel);
ortasagust.add(veterineradiComboBox);
ortasagust.add(kesimyapanadiJLabel);
ortasagust.add(kesimyapanComboBox);
ortasagust.add(tutarJLabel);
ortasagust.add(tutarField);
JPanel
ekleduzenleJPanel = new JPanel(new GridLayout(1, 3, 5, 5));
ekleduzenleJPanel.setOpaque(false);
JButton
ekleButton = new JButton("Ekle", new ImageIcon(
JButton
cikarButton = new JButton("Çıkar", new ImageIcon(
ekleduzenleJPanel.add(ekleButton);
ekleduzenleJPanel.add(cikarButton);
ortasagust.add(ekleduzenleJPanel,
BorderLayout.SOUTH);
ortasagalt.setBorder(BorderFactory
.createTitledBorder("KESİM
YAPILAN HAYVANLARIN LİSTESİ"));
ortasagalt.setBorder(BorderFactory
.createTitledBorder("KESİM
YAPILAN HAYVANLARIN LİSTESİ"));
final
JList kesilenhayvanlarJList = new JList(HayvanBilgileriDao
//kesilenhayvanlarJList.setOpaque(false);
kesilenhayvanlarJList.setBackground(Color.YELLOW);
JScrollPane
kesilenhayvanlarJScrollPane = new JScrollPane(
kesilenhayvanlarJScrollPane.setOpaque(false);
kesilenhayvanlarJScrollPane
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
ortasagalt.add(kesilenhayvanlarJScrollPane,
BorderLayout.CENTER);
JPanel
yazdirtpolamJPanel = new JPanel(new GridLayout(1, 3, 5, 5));
yazdirtpolamJPanel.setOpaque(false);
JButton
yazdırButton = new JButton("Yazdır");
yazdırButton.setOpaque(false);
yazdirtpolamJPanel.add(yazdırButton);
JLabel
toplamJLabel = new JLabel("Toplam");
JTextField
toplamField = new JTextField(4);
toplamField.setOpaque(false);
yazdirtpolamJPanel.add(toplamJLabel);
yazdirtpolamJPanel.add(toplamField);
ortasagalt.add(yazdirtpolamJPanel,
BorderLayout.SOUTH);
JPanel
toolPanel = new JPanel(new BorderLayout());
toolPanel.setOpaque(false);
JToolBar
toolBar = initToolBar();
ustJPanel.add(toolBar,
BorderLayout.NORTH);
kasaplarJList.addListSelectionListener(new
ListSelectionListener() {
public
void valueChanged(ListSelectionEvent arg0) {
if
(!kasaplarJList.isSelectionEmpty()) {
KasapDomain
secilenKasapDomain = (KasapDomain) kasaplarJList
kesilenhayvanlarJList.setListData(HayvanBilgileriDao
.KosulluListeleme(secilenKasapDomain.getId())
kesilenhayvanlarJList.setListData(HayvanBilgileriDao
ekleButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
HayvanBilgileriDomain
yeniHayvanBilgileriDomain = new HayvanBilgileriDomain();
KasapDomain
seciliKasapDomain = (KasapDomain) kasaplarJList
if
(!kasaplarJList.isSelectionEmpty()) {
java.util.Date
tarihDate = tarihChooser.getDate();
Date
tarihlerSQLDate = new Date(tarihDate.getTime());
VeterinerDomain
seciliVeterinerDomain = (VeterinerDomain) veterineradiComboBox
KesimYapanDomain
seciliKesimYapanDomain = (KesimYapanDomain) kesimyapanComboBox
yeniHayvanBilgileriDomain.setTarih(tarihlerSQLDate);
yeniHayvanBilgileriDomain.setKupeNumarasi(kupenumarasiField
yeniHayvanBilgileriDomain
.setVeterinerId(seciliVeterinerDomain.getId());
yeniHayvanBilgileriDomain.setKasapid(seciliKasapDomain
yeniHayvanBilgileriDomain
.setKesimYapanId(seciliKesimYapanDomain.getId());
if
(!tutarField.equals("")) {
double
tutar = Double.parseDouble(tutarField.getText());
yeniHayvanBilgileriDomain.setTutar(tutar);
JOptionPane.showMessageDialog(null,
"tutar giriniz");
if
(buyukBasButton.isSelected()) {
yeniHayvanBilgileriDomain.setKesilenHayvan(0);
if
(kucukBasButton.isSelected()) {
yeniHayvanBilgileriDomain.setKesilenHayvan(1);
if
(disiButton.isSelected()) {
yeniHayvanBilgileriDomain.setCinsiyeti(0);
if
(erkekButton.isSelected()) {
yeniHayvanBilgileriDomain.setCinsiyeti(1);
HayvanBilgileriDao.ekle(yeniHayvanBilgileriDomain);
JOptionPane.showMessageDialog(null,
"Kayıt Başarılı");
JOptionPane.showMessageDialog(null,
"Lütfen
Bir Kasap Seçiniz");
kesilenhayvanlarJList.setListData(HayvanBilgileriDao
.KosulluListeleme(seciliKasapDomain.getId()).toArray());
cikarButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
HayvanBilgileriDomain
silinecekhayvan = (HayvanBilgileriDomain) kesilenhayvanlarJList
if
(silinecekhayvan != null) {
HayvanBilgileriDao.sil(silinecekhayvan);//
silme komutu
kesilenhayvanlarJList.setListData(HayvanBilgileriDao
.listele().toArray());//
Liste
JOptionPane.showMessageDialog(null,
"Lütfen
Kesilecek Hayvanı Seçiniz");
kasapbulField.addKeyListener(new
KeyListener() {
public
void keyTyped(KeyEvent arg0) {
public
void keyReleased(KeyEvent arg0) {
List<KasapDomain>
bulunanOgrenciList = KasapekleDao
.cokluAdaGoreBul(kasapbulField.getText());
kasaplarJList.setListData(bulunanOgrenciList.toArray());
public
void keyPressed(KeyEvent arg0) {
addWindowFocusListener(new
WindowFocusListener() {
public
void windowLostFocus(WindowEvent arg0) {
//
TODO Auto-generated method stub
public
void windowGainedFocus(WindowEvent arg0) {
kasaplarJList.setListData(KasapekleDao.listele().toArray());
DefaultComboBoxModel
veterinerModel = new DefaultComboBoxModel(
VeterinerDao.listele().toArray());
DefaultComboBoxModel
kesimYapanModel = new DefaultComboBoxModel(
KesimYapanDao.listele().toArray());
veterineradiComboBox.setModel(veterinerModel);
kesimyapanComboBox.setModel(kesimYapanModel);
public
JMenuBar initBar() {
//
TODO Auto-generated method stub
public
JToolBar initToolBar() {
JToolBar
toolBar = new JToolBar();
JButton
yenikasapeklemeButton = new JButton("Yeni Kasap Ekle",
new
ImageIcon("iconslar/kaydet.png"));
yenikasapeklemeButton.setToolTipText("Yeni
Kasap Ekleme");
toolBar.add(yenikasapeklemeButton);
yenikasapeklemeButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new
Runnable() {
new
HesapBilgileriGuncelleme();
JButton
veterinerekleButton = new JButton("Veteriner Ekle",
new
ImageIcon("iconslar/kaydet.png"));
veterinerekleButton.setToolTipText("Veteriner
ekle");
toolBar.add(veterinerekleButton);
veterinerekleButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new
Runnable() {
JButton
kesimyapanekleButton = new JButton("Kesim Yapan Ekle",
new
ImageIcon("iconslar/kaydet.png"));
kesimyapanekleButton.setToolTipText("KEsim
YApan");
toolBar.add(kesimyapanekleButton);
JButton
raporButton = new JButton("Rapor");
toolBar.add(raporButton);
// raporButton.addActionListener(new
ActionListener() {
// public
void actionPerformed(ActionEvent arg0) {
// Map
modelMap = new HashedMap();
// modelMap.put("id",
8);
// Connection
conn=ConnectionToDb.getConnection();
// print
= JasperFillManager.fillReport("rapor/report2.jasper",modelMap,conn);
// JasperViewer.viewReport(print,false);
// }
catch (JRException e) {
// //
TODO Auto-generated catch block
raporButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
Connection
conn=ConnectionToDb.getConnection();
JasperPrint
print=JasperFillManager.fillReport("Rapor/report2.jasper",
null,conn);
JasperViewer.viewReport(print,false);
}
catch (JRException e) {
//
TODO Auto-generated catch block
kesimyapanekleButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new
Runnable() {
package tr.org.hmyo.yusufGui;
import java.awt.Graphics;
import java.awt.LayoutManager;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
public class ArkaPlan extends JPanel {
public
ArkaPlan(LayoutManager l){
protected void
paintComponent(Graphics g) {
Image
image = new ImageIcon("iconslar/kuzu.jpg").getImage();
int
bitisX=getSize().width;
int
bitisY=getSize().height;
g.drawImage(image,
baslangicX, baslangicY,bitisX,bitisY, null);
KASAP
BİLGİLERİ Uİ SINIFI
package tr.org.hmyo.yusufGui;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import
java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import
javax.swing.event.ListSelectionEvent;
import
javax.swing.event.ListSelectionListener;
import
com.toedter.calendar.JDateChooser;
import
tr.org.hmyo.yusuf.Dao.KasapekleDao;
import
tr.org.hmyo.yusuf.Dao.KesimYapanDao;
import
tr.org.hmyo.yusuf.Domain.KasapDomain;
import
tr.org.hmyo.yusuf.Domain.KesimYapanDomain;
import
tr.org.hmyo.yusuf.Domain.VeterinerDomain;
public class
HesapBilgileriGuncelleme extends JDialog implements pencereInfc {
public
HesapBilgileriGuncelleme() {
public
void initpencere() {
JPanel
anaJPanel = initPanel();
setTitle("Kasap
Bilgileri");
setLocationRelativeTo(null);
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE
);
setModalityType(DEFAULT_MODALITY_TYPE);
public
JPanel initPanel() {
JPanel
anaJPanel = new JPanel(new BorderLayout());
JPanel
ustJPanel=new JPanel(new GridLayout(6,2,5,5));
JPanel
ortaJPanel=new JPanel(new BorderLayout());
JPanel
altJPanel=new JPanel(new GridLayout(1,3,5,5));
ustJPanel.setBorder(BorderFactory.createTitledBorder("Yeni
Kasap Ekleme"));
JLabel
kasapadiJLabel =new JLabel("KASABIN ÜNVANI:");
JLabel
vatandaslikJLabel = new JLabel("VATANDAŞLIK NUMARASI:", JLabel.LEFT);
JLabel
adiJLabel = new JLabel("ADI SOYADI:", JLabel.LEFT);
JLabel
telefonnoJLabel = new JLabel("TELEFON NUMARASI :", JLabel.LEFT);
JLabel
adersJLabel = new JLabel("ADRES:", JLabel.LEFT);
final JTextField kasabinadiField = new
JTextField(10);
final JTextField vatandaslikField = new
JTextField(10);
final JTextField adiField = new
JTextField(10);
final JTextField kayityarihiField = new
JTextField(10);
final JTextField telefonField = new
JTextField(10);
final JTextField adresField = new
JTextField(10);
ustJPanel.add(kasapadiJLabel);
ustJPanel.add(kasabinadiField);
ustJPanel.add(adiJLabel);
ustJPanel.add(vatandaslikJLabel);
ustJPanel.add(vatandaslikField);
ustJPanel.add(telefonnoJLabel);
ustJPanel.add(telefonField);
ustJPanel.add(adersJLabel);
ustJPanel.add(adresField);
kasabinadiField.setText("");
vatandaslikField.setText("");
telefonField.setText("");
final
JList kasaplar1JList = new JList();
kasaplar1JList.setListData(KasapekleDao.listele().toArray());
JScrollPane
kasaplar1JScrollPane = new JScrollPane(kasaplar1JList);
kasaplar1JList.setBackground(Color.pink);
List<KasapDomain>
liste = new ArrayList<KasapDomain>();
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
ortaJPanel.add(kasaplar1JScrollPane);
JButton
cikisJButton = new JButton("Çıkış", new
ImageIcon("iconslar/cikis.png"));
JButton
kaydetJButton = new JButton("Kaydet", new
ImageIcon("iconslar/kaydet.png"));
JButton
silButton = new JButton("Sil", new
ImageIcon("iconslar/sil.png"));
cikisJButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
silButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
KasapDomain
silinecekkasapDomain = (KasapDomain) kasaplar1JList
if
(silinecekkasapDomain != null) {
KasapekleDao.silme(silinecekkasapDomain);//
silme komutu
kasaplar1JList.setListData(KasapekleDao.listele().toArray());//
Liste
JOptionPane.showMessageDialog(null,
"Lütfen
Bir Kasap Seçiniz");
altJPanel.add(cikisJButton);
altJPanel.add(kaydetJButton);
altJPanel.add(silButton);
//altJPanel.add(altikinciJPanel);
kaydetJButton.addActionListener(new ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
KasapDomain
kasabekle = new KasapDomain();
kasabekle.setKasabUnvani(kasabinadiField.getText());
kasabekle.setKasabadiSoyadi(adiField.getText());
kasabekle.setTcNo(vatandaslikField.getText());
kasabekle.setTelefonu(telefonField.getText());
kasabekle.setAdres(adresField.getText());
KasapekleDao.ekle(kasabekle);
JOptionPane.showMessageDialog(null,
"Kayıt Başarılı");
kasaplar1JList.setListData(KasapekleDao.listele().toArray());
kasaplar1JList.addListSelectionListener(new
ListSelectionListener() {
public
void valueChanged(ListSelectionEvent arg0) {
KasapDomain
duzenlenecekKasapDomain = (KasapDomain) kasaplar1JList
if
(duzenlenecekKasapDomain != null) {
int
id = duzenlenecekKasapDomain.getId();
kasabinadiField.setText(duzenlenecekKasapDomain.getKasabUnvani());
adiField.setText(duzenlenecekKasapDomain.getKasabadiSoyadi());
vatandaslikField.setText(duzenlenecekKasapDomain.getTcNo());
adresField.setText(duzenlenecekKasapDomain.getAdres());
telefonField.setText(duzenlenecekKasapDomain.getTelefonu());
anaJPanel.add(ustJPanel,
BorderLayout.NORTH);
anaJPanel.add(ortaJPanel,
BorderLayout.CENTER);
anaJPanel.add(altJPanel,
BorderLayout.SOUTH);
//
TODO Auto-generated method stub
public
JMenuBar initBar() {
//
TODO Auto-generated method stub
package tr.org.hmyo.yusufGui;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import
java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import
javax.swing.event.ListSelectionEvent;
import
javax.swing.event.ListSelectionListener;
import
tr.org.hmyo.yusuf.Dao.KasapekleDao;
import
tr.org.hmyo.yusuf.Dao.KesimYapanDao;
import
tr.org.hmyo.yusuf.Domain.KasapDomain;
import
tr.org.hmyo.yusuf.Domain.KesimYapanDomain;
public class KesimYapanEkle extends JDialog implements pencereInfc{
public
KesimYapanEkle() {
public
void initpencere() {
JPanel
anaJPanel = initPanel();
setTitle("Kesim
Yapan Ekle");
setLocationRelativeTo(null);
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE
);
setModalityType(DEFAULT_MODALITY_TYPE);
public
JPanel initPanel() {
JPanel
anaJPanel = new JPanel(new BorderLayout());
JPanel ustJPanel = new JPanel(new
GridLayout(4, 2, 5, 5));
ustJPanel.setBorder(BorderFactory.createTitledBorder("Kesim Yapanın
Bilgileri"));
JLabel adiJLabel = new
JLabel("Adı", JLabel.RIGHT);
JLabel soyadiJLabel = new
JLabel("Soyadı", JLabel.RIGHT);
JLabel telefonuJLabel = new JLabel("Telefonu",
JLabel.RIGHT);
JLabel adresiJLabel = new
JLabel("Adresi", JLabel.RIGHT);
final JTextField adiField = new
JTextField(8);
final JTextField soyadiField = new
JTextField(8);
final JTextField telefonuField = new JTextField(8);
final JTextField adresiField = new
JTextField(8);
ustJPanel.add(adiJLabel);
ustJPanel.add(soyadiJLabel);
ustJPanel.add(soyadiField);
ustJPanel.add(telefonuJLabel);
ustJPanel.add(telefonuField);
ustJPanel.add(adresiJLabel);
ustJPanel.add(adresiField);
final JList kisilerJList = new JList();
kisilerJList.setListData(KesimYapanDao.listele().toArray());
JScrollPane kisilerJScrollPane = new
JScrollPane(kisilerJList);
kisilerJList.setBackground(Color.pink);
JPanel altJPanel = new JPanel(new
GridLayout(2, 1));
JLabel idJLabel = new
JLabel("Bul", JLabel.RIGHT);
final JTextField idField = new
JTextField(4);
JPanel bulJPanel = new JPanel(new
GridLayout(1, 3, 5, 5));
JPanel duzenleSilJPanel = new
JPanel(new GridLayout(1, 3, 5, 5));
JButton asilkaydetButton = new
JButton("Kaydet", new ImageIcon("iconslar/kaydet.png"));
duzenleSilJPanel.add(asilkaydetButton);
//kesim yapan eklemeleri için action
verme
asilkaydetButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
KesimYapanDomain
kesimyapan = new KesimYapanDomain();
kesimyapan.setAdi(adiField.getText());
kesimyapan.setSoyadi(soyadiField.getText());
kesimyapan.setTelefunu(telefonuField.getText());
kesimyapan.setAdresi(adresiField.getText());
KesimYapanDao.ekle(kesimyapan);
JOptionPane.showMessageDialog(null,
"Kayıt Başarılı");
kisilerJList.setListData(KesimYapanDao.listele().toArray());
telefonuField.setText("");
JButton silButton = new
JButton("Sil", new ImageIcon("iconslar/sil.png"));
duzenleSilJPanel.add(silButton);
silButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
KesimYapanDomain
silinecekOgrenciDomain = (KesimYapanDomain) kisilerJList
if
(silinecekOgrenciDomain != null) {
KesimYapanDao.sil(silinecekOgrenciDomain);
kisilerJList.setListData(KesimYapanDao.listele().toArray());//
Liste
JOptionPane.showMessageDialog(null,
"Lütfen
Kesim Yapan Seçiniz");
JButton cikislButton = new
JButton("Çıkış", new ImageIcon("iconslar/cikis.png"));
duzenleSilJPanel.add(cikislButton);
altJPanel.add(bulJPanel);
altJPanel.add(duzenleSilJPanel);
anaJPanel.add(ustJPanel,
BorderLayout.NORTH);
anaJPanel.add(kisilerJScrollPane,
BorderLayout.CENTER);
anaJPanel.add(altJPanel,
BorderLayout.SOUTH);
cikislButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
kisilerJList.addListSelectionListener(new ListSelectionListener() {
public
void valueChanged(ListSelectionEvent arg0) {
KesimYapanDomain
KesimYapanDomain = (KesimYapanDomain) kisilerJList
if
(KesimYapanDomain != null) {
int
id = KesimYapanDomain.getId();
adiField.setText(KesimYapanDomain.getAdi());
soyadiField.setText(KesimYapanDomain.getSoyadi());
telefonuField.setText(KesimYapanDomain.getTelefunu());
adresiField.setText(KesimYapanDomain.getAdresi());
idField.addKeyListener(new
KeyListener() {
public
void keyTyped(KeyEvent arg0) {
public
void keyReleased(KeyEvent arg0) {
List<KesimYapanDomain>
bulunankesimyapanList = KesimYapanDao
.cokluAdaGoreBul(idField.getText());
kisilerJList.setListData(bulunankesimyapanList.toArray());
public
void keyPressed(KeyEvent arg0) {
public
JMenuBar initBar() {
//
TODO Auto-generated method stub
VETERİNER EKLEME
KOD KISMI
package tr.org.hmyo.yusufGui;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import
java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import
javax.swing.event.ListSelectionEvent;
import
javax.swing.event.ListSelectionListener;
import
tr.org.hmyo.yusuf.Dao.KesimYapanDao;
import tr.org.hmyo.yusuf.Dao.VeterinerDao;
import
tr.org.hmyo.yusuf.Domain.KesimYapanDomain;
import
tr.org.hmyo.yusuf.Domain.VeterinerDomain;
public class VeterinerEkle extends
JDialog implements pencereInfc{
public
void initpencere() {
JPanel
anaJPanel = initPanel();
setTitle("Veteriner
Ekle");
setLocationRelativeTo(null);
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE
);
setModalityType(DEFAULT_MODALITY_TYPE);
public
JPanel initPanel() {
JPanel
anaJPanel = new JPanel(new BorderLayout());
JPanel ustJPanel = new JPanel(new
GridLayout(4, 2, 5, 5));
ustJPanel.setBorder(BorderFactory.createTitledBorder("Veteriner
Bilgileri"));
JLabel adiJLabel = new
JLabel("Adı", JLabel.RIGHT);
JLabel soyadiJLabel = new
JLabel("Soyadı", JLabel.RIGHT);
JLabel telefonuJLabel = new
JLabel("Telefonu", JLabel.RIGHT);
JLabel adresiJLabel = new
JLabel("Adresi", JLabel.RIGHT);
final JTextField adiField = new
JTextField(8);
final JTextField soyadiField = new
JTextField(8);
final JTextField telefonuField = new
JTextField(8);
final JTextField adresiField = new
JTextField(8);
ustJPanel.add(adiJLabel);
ustJPanel.add(soyadiJLabel);
ustJPanel.add(soyadiField);
ustJPanel.add(telefonuJLabel);
ustJPanel.add(telefonuField);
ustJPanel.add(adresiJLabel);
ustJPanel.add(adresiField);
final JList veterinerJList = new
JList();
List<VeterinerDomain> liste = new
ArrayList<VeterinerDomain>();
JScrollPane kisilerJScrollPane = new
JScrollPane(veterinerJList);
veterinerJList.setBackground(Color.pink);
JPanel altJPanel = new JPanel(new
GridLayout(2, 1));
JLabel idJLabel = new
JLabel("Bul", JLabel.RIGHT);
final JTextField idField = new
JTextField(4);
JPanel bulJPanel = new JPanel(new
GridLayout(1, 3, 5, 5));
JPanel duzenleSilJPanel = new
JPanel(new GridLayout(1, 3, 5, 5));
JButton asılkaydetButton = new
JButton("Kaydet", new ImageIcon("iconslar/kaydet.png"));
veterinerJList.setListData(VeterinerDao.listele().toArray());
asılkaydetButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
VeterinerDomain
yeniVeterinerDomain = new VeterinerDomain();
yeniVeterinerDomain.setAdi(adiField.getText());
yeniVeterinerDomain.setSoyadi(soyadiField.getText());
yeniVeterinerDomain.setTelefunu(telefonuField.getText());
yeniVeterinerDomain.setAdresi(adresiField.getText());
VeterinerDao.ekle(yeniVeterinerDomain);
JOptionPane.showMessageDialog(null,
"Kayıt Başarılı");
veterinerJList.setListData(VeterinerDao.listele().toArray());
telefonuField.setText("");
duzenleSilJPanel.add(asılkaydetButton);
JButton silButton = new
JButton("Sil", new ImageIcon("iconslar/sil.png"));
duzenleSilJPanel.add(silButton);
silButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
VeterinerDomain
silinecekveterinerDomain = (VeterinerDomain) veterinerJList
if
(silinecekveterinerDomain != null) {
VeterinerDao.sil(silinecekveterinerDomain);
veterinerJList.setListData(VeterinerDao.listele().toArray());//
Liste
}
else {// Öğrenci seçilmediyse hata mesajı ver
JOptionPane.showMessageDialog(null,
"Lütfen
Bir Veteriner Seçiniz");
JButton cıkıslButton = new
JButton("Çıkış", new ImageIcon("iconslar/cikis.png"));
duzenleSilJPanel.add(cıkıslButton);
cıkıslButton.addActionListener(new
ActionListener() {
public
void actionPerformed(ActionEvent arg0) {
altJPanel.add(bulJPanel);
altJPanel.add(duzenleSilJPanel);
anaJPanel.add(ustJPanel,
BorderLayout.NORTH);
anaJPanel.add(kisilerJScrollPane,
BorderLayout.CENTER);
anaJPanel.add(altJPanel,
BorderLayout.SOUTH);
veterinerJList.addListSelectionListener(new ListSelectionListener() {
public
void valueChanged(ListSelectionEvent arg0) {
VeterinerDomain
VeterinerDomain = (VeterinerDomain) veterinerJList
if
(VeterinerDomain != null) {
int
id = VeterinerDomain.getId();
adiField.setText(VeterinerDomain.getAdi());
soyadiField.setText(VeterinerDomain.getSoyadi());
telefonuField.setText(VeterinerDomain.getTelefunu());
adresiField.setText(VeterinerDomain.getAdresi());
idField.addKeyListener(new
KeyListener() {
public
void keyTyped(KeyEvent arg0) {
public
void keyReleased(KeyEvent arg0) {
List<VeterinerDomain>
bulunanveterinerList = VeterinerDao
.cokluAdaGoreBul(idField.getText());
veterinerJList.setListData(bulunanveterinerList.toArray());
public
void keyPressed(KeyEvent arg0) {
public
JMenuBar initBar() {
//
TODO Auto-generated method stub
HAYVAN
BİLGİLERİ DOMAİN KOD KISMI
package tr.org.hmyo.yusuf.Domain;
import
tr.org.hmyo.yusuf.Dao.KasapekleDao;
import
tr.org.hmyo.yusuf.Dao.KesimYapanDao;
import
tr.org.hmyo.yusuf.Dao.VeterinerDao;
public class HayvanBilgileriDomain {
private
int kesilenHayvan;
private
String kupeNumarasi;
private
int kesimYapanId;
public
void setId(int id) {
public
int getKasapid() {
public
void setKasapid(int kasapid) {
public
void setTarih(Date tarih) {
public
int getKesilenHayvan() {
public
void setKesilenHayvan(int kesilenHayvan) {
this.kesilenHayvan
= kesilenHayvan;
public
int getCinsiyeti() {
public
void setCinsiyeti(int cinsiyeti) {
this.cinsiyeti
= cinsiyeti;
public
String getKupeNumarasi() {
public
void setKupeNumarasi(String kupeNumarasi) {
this.kupeNumarasi
= kupeNumarasi;
public
int getVeterinerId() {
public
void setVeterinerId(int veterinerId) {
this.veterinerId
= veterinerId;
public
int getKesimYapanId() {
public
void setKesimYapanId(int kesimYapanId) {
this.kesimYapanId
= kesimYapanId;
public
double getTutar() {
public
void setTutar(double tutar) {
public
String toString() {
return
KasapekleDao.ara(kasapid) + "---" + tarih + "---"
+
((kesilenHayvan == 0) ? "Büyük Baş" : "Küçük Baş") +
"---"
+
((cinsiyeti == 0) ? "Dişi" : "Erkek") + "---" +
kupeNumarasi
+
"---" + VeterinerDao.ara(veterinerId) + "---"
+
KesimYapanDao.ara(kesimYapanId) + "---" + tutar;
package tr.org.hmyo.yusuf.Domain;
public class KasapDomain {
int Kasapid;
String
kasabUnvani;
String
kasabadiSoyadi;
String
tcNo;
String
telefonu;
String
adres;
public int getId() {
return Kasapid;
}
public void setId(int id) {
this.Kasapid
= id;
}
public String getKasabUnvani() {
return kasabUnvani;
}
public void setKasabUnvani(String
kasabUnvani) {
this.kasabUnvani = kasabUnvani;
}
public String getKasabadiSoyadi() {
return kasabadiSoyadi;
}
public void setKasabadiSoyadi(String
kasabadiSoyadi) {
this.kasabadiSoyadi = kasabadiSoyadi;
}
public String getTcNo() {
return tcNo;
}
public void setTcNo(String tcNo) {
this.tcNo
= tcNo;
}
public String getTelefonu() {
return telefonu;
}
public void setTelefonu(String telefonu) {
this.telefonu
= telefonu;
}
public String getAdres() {
return adres;
}
public void setAdres(String adres) {
this.adres
= adres;
}
public String toString() {
return Kasapid + " - " + kasabUnvani + " " + kasabadiSoyadi + "
| " +telefonu;
}
}
VETERİNER
DOMAİN KOD KISMI
package tr.org.hmyo.yusuf.Domain;
public class VeterinerDomain {
int id;
String
Adi;
String
Soyadi;
String
Telefunu;
String
Adresi;
public int getId() {
return id;
}
public void setId(int id) {
this.id
= id;
}
public String getAdi() {
return Adi;
}
public void setAdi(String adi) {
Adi = adi;
}
public String getSoyadi() {
return Soyadi;
}
public void setSoyadi(String soyadi) {
Soyadi = soyadi;
}
public String getTelefunu() {
return Telefunu;
}
public void setTelefunu(String telefunu) {
Telefunu = telefunu;
}
public String getAdresi() {
return Adresi;
}
public void setAdresi(String adresi) {
Adresi = adresi;
}
public String toString() {
return id
+ " - " + Adi + " " + Soyadi
+ " | " + Telefunu+ " | " +Adresi;
}
}
KESİMYAPAN
DOMAİN KOD KISMI
package tr.org.hmyo.yusuf.Domain;
public class KesimYapanDomain {
int id;
String Adi;
String Soyadi;
String Telefunu;
String Adresi;
public int
getId() {
return id;
}
public void
setId(int id) {
this.id
= id;
}
public String getAdi() {
return Adi;
}
public void
setAdi(String adi) {
Adi = adi;
}
public String getSoyadi() {
return Soyadi;
}
public void
setSoyadi(String soyadi) {
Soyadi = soyadi;
}
public String getTelefunu() {
return Telefunu;
}
public void
setTelefunu(String telefunu) {
Telefunu = telefunu;
}
public String getAdresi() {
return Adresi;
}
public void
setAdresi(String adresi) {
Adresi = adresi;
}
public String toString() {
return id
+ " - " + Adi + " " + Soyadi
+ " | " + Telefunu + " | " + Adresi;
}
}
package tr.org.hmyo.yusuf.Dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import
tr.org.hmyo.yusuf.Domain.KasapDomain;
import
tr.org.hmyo.yusuf.Domain.KesimYapanDomain;
public class KasapekleDao {
public
static void initTable() {
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
stmt.executeUpdate("CREATE
TABLE Kasabekle(Kasapid INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY(START
WITH 1, INCREMENT BY 1), kasabUnvani VARCHAR(40), kasabadiSoyadi VARCHAR(40),
tcNo VARCHAR(40), telefonu VARCHAR(40), adres VARCHAR(50))");
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public
static void ekle(KasapDomain yenikasapKasapDomain) {
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
stmt.executeUpdate("INSERT
INTO kasabekle(kasabUnvani, kasabadiSoyadi, tcno, telefonu, adres) VALUES('"
+
yenikasapKasapDomain.getKasabUnvani()
+
yenikasapKasapDomain.getKasabadiSoyadi()
+
yenikasapKasapDomain.getTcNo()
+
yenikasapKasapDomain.getTelefonu()
+
yenikasapKasapDomain.getAdres() + "')");
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public
static List<KasapDomain> listele() {
Connection
conn = ConnectionToDb.getConnection();
List<KasapDomain>
liste = new ArrayList<KasapDomain>();
stmt = conn.createStatement();
ResultSet
rs = stmt.executeQuery("SELECT * FROM Kasabekle");
KasapDomain
KasapDomain = new KasapDomain();
KasapDomain.setId(rs.getInt("Kasapid"));
KasapDomain.setKasabUnvani(rs.getString("kasabUnvani"));
KasapDomain.setKasabadiSoyadi(rs.getString("kasabadiSoyadi"));
KasapDomain.setTcNo(rs.getString("tcNo"));
KasapDomain.setTelefonu(rs.getString("telefonu"));
KasapDomain.setAdres(rs.getString("adres"));
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public
static void silme(KasapDomain silinecekkasapDomain) {
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
stmt.executeUpdate("DELETE
FROM Kasabekle WHERE kasapid = "
+
silinecekkasapDomain.getId());
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public
static KasapDomain ara(int Kasapid) {
KasapDomain
bulunankasap = null;
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
.executeQuery("SELECT
* FROM Kasabekle WHERE Kasapid = " + Kasapid);
bulunankasap
= new KasapDomain();
bulunankasap.setId(rs.getInt("Kasapid"));
bulunankasap.setKasabUnvani(rs.getString("kasabUnvani"));
bulunankasap.setKasabadiSoyadi(rs.getString("kasabadiSoyadi"));
bulunankasap.setTcNo(rs.getString("tcNo"));
bulunankasap.setTelefonu(rs.getString("telefonu"));
bulunankasap.setAdres(rs.getString("adres"));
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public
static List<KasapDomain> cokluAdaGoreBul(String kasabUnvani) {
List<KasapDomain>
kasaplarJList = new ArrayList<KasapDomain>();
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
.executeQuery("SELECT
* FROM Kasabekle WHERE kasabUnvani LIKE '%"
KasapDomain
siradakikasapDomain = new KasapDomain();
siradakikasapDomain.setId(rs.getInt("Kasapid"));
siradakikasapDomain.setKasabUnvani(rs.getString("kasabUnvani"));
siradakikasapDomain.setKasabadiSoyadi(rs.getString("kasabadiSoyadi"));
siradakikasapDomain.setTcNo(rs.getString("tcNo"));
siradakikasapDomain.setTelefonu(rs.getString("telefonu"));
siradakikasapDomain.setAdres(rs.getString("adres"));
kasaplarJList.add(siradakikasapDomain);
}
catch (SQLException e) {
//
TODO Auto-generated catch block
HAYVAN
BİLGİLERİ DAO KOD KISMI
package tr.org.hmyo.yusuf.Dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import
tr.org.hmyo.yusuf.Domain.HayvanBilgileriDomain;
import
tr.org.hmyo.yusuf.Domain.KasapDomain;
import
tr.org.hmyo.yusuf.Domain.KesimYapanDomain;
public class HayvanBilgileriDao {
private
static final Statement ConnectionToDerby = null;
public
static void initTable() {
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
stmt.executeUpdate("CREATE
TABLE hayvanBilgileri(id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY(START
WITH 1,INCREMENT BY 1),"
+
"kasapid INTEGER,tarih DATE,kesilenHayvan INTEGER,cinsiyeti
INTEGER,kupeNumarasi VARCHAR(40),veterinerid INTEGER,kesimYapanid INTEGER,tutar
VARCHAR(40))");
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public
static void ekle(HayvanBilgileriDomain yeniHayvanBilgileriDomain) {
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
stmt.executeUpdate("INSERT
INTO hayvanBilgileri(kasapid, tarih, kesilenHayvan, cinsiyeti, kupeNumarasi,
veterinerid, kesimYapanid,tutar) VALUES("
+
yeniHayvanBilgileriDomain.getKasapid()
+
yeniHayvanBilgileriDomain.getTarih()
+
yeniHayvanBilgileriDomain.getKesilenHayvan()
+
yeniHayvanBilgileriDomain.getCinsiyeti()
+
yeniHayvanBilgileriDomain.getKupeNumarasi()
+
yeniHayvanBilgileriDomain.getVeterinerId()
+
yeniHayvanBilgileriDomain.getKesimYapanId()
+
yeniHayvanBilgileriDomain.getTutar() + "')");
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public
static List<HayvanBilgileriDomain> listele() {
Connection
conn = ConnectionToDb.getConnection();
List<HayvanBilgileriDomain>
liste = new ArrayList<HayvanBilgileriDomain>();
stmt
= conn.createStatement();
ResultSet
rs = stmt.executeQuery("SELECT * FROM hayvanBilgileri");
HayvanBilgileriDomain
hayvanBilgileriDomain = new HayvanBilgileriDomain();
hayvanBilgileriDomain.setId(rs.getInt("id"));
hayvanBilgileriDomain.setKasapid(rs.getInt("kasapid"));
hayvanBilgileriDomain.setTarih(rs.getDate("tarih"));
hayvanBilgileriDomain.setKesilenHayvan(rs
.getInt("kesilenHayvan"));
hayvanBilgileriDomain.setCinsiyeti(rs.getInt("cinsiyeti"));
hayvanBilgileriDomain.setKupeNumarasi(rs
.getString("kupeNumarasi"));
hayvanBilgileriDomain.setVeterinerId(rs.getInt("veterinerid"));
.setKesimYapanId(rs.getInt("kesimYapanid"));
hayvanBilgileriDomain.setTutar(rs.getDouble("tutar"));
liste.add(hayvanBilgileriDomain);
}
catch (SQLException e) {
public
static void sil(HayvanBilgileriDomain silinecekhayvan) {
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
stmt.executeUpdate("DELETE
FROM hayvanBilgileri WHERE id = "
+
silinecekhayvan.getId());
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public
static List<HayvanBilgileriDomain> KosulluListeleme(int id) {
Connection
conn = ConnectionToDb.getConnection();
List<HayvanBilgileriDomain>
liste = new ArrayList<HayvanBilgileriDomain>();
stmt
= conn.createStatement();
ResultSet
rs = stmt.executeQuery("SELECT * FROM hayvanBilgileri WHERE
kasapid="+id);
HayvanBilgileriDomain
hayvanBilgileriDomain = new HayvanBilgileriDomain();
hayvanBilgileriDomain.setId(rs.getInt("id"));
hayvanBilgileriDomain.setKasapid(rs.getInt("kasapid"));
hayvanBilgileriDomain.setTarih(rs.getDate("tarih"));
hayvanBilgileriDomain.setKesilenHayvan(rs
.getInt("kesilenHayvan"));
hayvanBilgileriDomain.setCinsiyeti(rs.getInt("cinsiyeti"));
hayvanBilgileriDomain.setKupeNumarasi(rs
.getString("kupeNumarasi"));
hayvanBilgileriDomain.setVeterinerId(rs.getInt("veterinerid"));
.setKesimYapanId(rs.getInt("kesimYapanid"));
hayvanBilgileriDomain.setTutar(rs.getDouble("tutar"));
liste.add(hayvanBilgileriDomain);
}
catch (SQLException e) {
// public
static boolean kupeNoKontrol(HayvanBilgileriDomain yeniKupeNoDomain) {
// HayvanBilgileriDomain kupeNo = new
HayvanBilgileriDomain();
// Connection conn =
ConnectionToDerby.getConnection();
// Statement stmt = conn.createStatement();
// .executeQuery("SELECT * FROM
hayvanBilgileri WHERE kupeNumarasi = = '"
// +
HayvanBilgileriDomain.getkupeNumarasi() + "'");
// } catch (SQLException e) {
Kesim yapan
DAO KOD KISMI
package tr.org.hmyo.yusuf.Dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import
tr.org.hmyo.yusuf.Domain.KasapDomain;
import
tr.org.hmyo.yusuf.Domain.KesimYapanDomain;
public class KesimYapanDao {
public
static void initTable() {
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
stmt.executeUpdate("CREATE
TABLE kesimyapan(id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY(START WITH 1,
INCREMENT BY 1), Adi VARCHAR(40), Soyadi VARCHAR(40), telefonu
VARCHAR(40),adresi VARCHAR(50))");
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public static void
ekle(KesimYapanDomain yeniKesimYapanDomain) {
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
stmt.executeUpdate("INSERT
INTO kesimyapan(Adi,Soyadi,telefonu,adresi) VALUES('"
+
yeniKesimYapanDomain.getAdi()
+
yeniKesimYapanDomain.getSoyadi()
+
yeniKesimYapanDomain.getTelefunu()
+
yeniKesimYapanDomain.getAdresi()
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public static
List<KesimYapanDomain> listele() {
Connection
conn = ConnectionToDb.getConnection();
List<KesimYapanDomain>
liste = new ArrayList<KesimYapanDomain>();
stmt
= conn.createStatement();
ResultSet
rs = stmt.executeQuery("SELECT * FROM kesimyapan");
KesimYapanDomain
KesimYapanDomain = new KesimYapanDomain();
KesimYapanDomain.setId(rs.getInt("id"));
KesimYapanDomain.setAdi(rs.getString("Adi"));
KesimYapanDomain.setSoyadi(rs.getString("soyadi"));
KesimYapanDomain.setTelefunu(rs.getString("telefonu"));
KesimYapanDomain.setAdresi(rs.getString("adresi"));
liste.add(KesimYapanDomain);
}
catch (SQLException e) {
//
TODO Auto-generated catch block
public static void
sil(KesimYapanDomain silinecekkesimyapanDomain) {
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
stmt.executeUpdate("DELETE
FROM kesimyapan WHERE id = "
+
silinecekkesimyapanDomain.getId());
}
catch (SQLException e) {
//
TODO Auto-generated catch block
//-----------kesim yapan arama
public static KesimYapanDomain
ara(int id) {
KesimYapanDomain
bulunankesimyapan = new KesimYapanDomain();
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
.executeQuery("SELECT
* FROM kesimyapan WHERE id = " + id);
bulunankesimyapan.setId(rs.getInt("id"));
bulunankesimyapan.setAdi(rs.getString("Adi"));
bulunankesimyapan.setSoyadi(rs.getString("soyadi"));
bulunankesimyapan.setTelefunu(rs.getString("telefonu"));
bulunankesimyapan.setAdresi(rs.getString("adresi"));
}
catch (SQLException e) {
//
TODO Auto-generated catch block
return
bulunankesimyapan;
public static
List<KesimYapanDomain> cokluAdaGoreBul(String adi) {
List<KesimYapanDomain>
kisilerJList = new ArrayList<KesimYapanDomain>();
Connection
conn = ConnectionToDb.getConnection();
Statement
stmt = conn.createStatement();
.executeQuery("SELECT
* FROM kesimyapan WHERE Adi LIKE '%"
KesimYapanDomain
siradakikesimyapan = new KesimYapanDomain();
siradakikesimyapan.setId(rs.getInt("id"));
siradakikesimyapan.setAdi(rs.getString("Adi"));
siradakikesimyapan.setSoyadi(rs.getString("soyadi"));
siradakikesimyapan.setTelefunu(rs.getString("telefonu"));
siradakikesimyapan.setAdresi(rs.getString("adresi"));
kisilerJList.add(siradakikesimyapan);
}
catch (SQLException e) {
//
TODO Auto-generated catch block
CONNECTİON
TO DB SINIFI KOD KISMI
package tr.org.hmyo.yusuf.Dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectionToDb {
private
static String driver = "org.apache.derby.jdbc.EmbeddedDriver";
private
static String url = "jdbc:derby:BelediyeMezbahaTakip;create=true;";
private
static String user = "";
private
static String pass = "";
ev
= System.getProperty("user.home",".");
sistem
= ev + File.separatorChar + "vt";
System.setProperty("derby.system.home",
sistem);
}
catch (ClassNotFoundException e) {
//
TODO Auto-generated catch block
public
static Connection getConnection() {
conn
= DriverManager.getConnection(url, user, pass);
}
catch (SQLException e) {
//
TODO Auto-generated catch block
ÇALIŞTIR
SINIFI KOD KISMI
package
tr.org.hmyo.yusuf.test;
import
javax.swing.SwingUtilities;
import
javax.swing.UIManager;
import
javax.swing.UnsupportedLookAndFeelException;
import
tr.org.hmyo.yusuf.Dao.HayvanBilgileriDao;
import
tr.org.hmyo.yusuf.Dao.KasapekleDao;
import
tr.org.hmyo.yusuf.Dao.KesimYapanDao;
import
tr.org.hmyo.yusuf.Dao.KullaniciDao;
import
tr.org.hmyo.yusuf.Dao.VeterinerDao;
import
tr.org.hmyo.yusufGui.AnaPencereGui;
import
tr.org.hmyo.yusufGui.KullaniciGirisi;
public static void main(String[] args) {
KullaniciDao.initTable();
HayvanBilgileriDao.initTable();
KesimYapanDao.initTable();
VeterinerDao.initTable();
KasapekleDao.initTable();
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException
e) {
// TODO Auto-generated
catch block
} catch (InstantiationException
e) {
// TODO Auto-generated
catch block
} catch (IllegalAccessException
e) {
// TODO Auto-generated
catch block
} catch
(UnsupportedLookAndFeelException e) {
// TODO Auto-generated
catch block
SwingUtilities.invokeLater(new
Runnable() {