package detayliArama.gui;
import giris.gui.PSAAnaEkran;
import hibernateSwingApi.component.CComboBox;
import hibernateSwingApi.component.CTextField;
import hibernateSwingApi.component.TablePanel;
import hibernateSwingApi.hibernate.HibernateManager;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import kullanici.pojos.Kullanici;
import org.hibernate.Query;
import org.hibernate.Session;
import pdf.ReportInfo;
import service.AutoClosingMessageDialog;
import service.PSAUtil;
import urun.pojos.Renk;
import urun.pojos.UrunBeden;
import urun.pojos.UrunCinsiyet;
import urun.pojos.UrunGrup;
import urun.pojos.UrunMarka;
import urun.pojos.UrunModel;
import urun.pojos.UrunSezon;
import urun.pojos.UrunStok;
import urun.pojos.UrunStokDetayliArama;
import cari.pojos.Musteri;
public class PSADetayliArama extends JFrame {
private static final long serialVersionUID = 1L;
private static PSADetayliArama instance;
private JPanel contentPane;
private JLabel jLabelUrunBilgi;
private JPanel cPanelUrunBilgi;
private CComboBox<UrunMarka> cComboBoxUrunMarka;
private JLabel jLabelUrunMarka;
private JLabel jLabelUrunCinsiyet;
private CComboBox<UrunCinsiyet> cComboBoxUrunCinsiyet;
private CTextField cTextFieldUrunRenk;
private CComboBox<UrunBeden> cComboBoxUrunBeden;
private JLabel jLabelUrunBeden;
private JLabel jLabelUrunGrup;
private CComboBox<UrunModel> cComboBoxUrunModel;
private JLabel jLabelUrunModel;
private JLabel jLabelUrunSezon;
private CComboBox<UrunGrup> cComboBoxUrunGrup;
private CComboBox<UrunSezon> cComboBoxUrunSezon;
private JLabel jLabelUrunFirma;
private CComboBox<Musteri> cComboBoxUrunFirma;
private JLabel jLabelUrunRenk;
private JButton jButtonDetayGoster;
private JButton cButtonIptal;
private JLabel jLabelTabloBilgi;
private List<UrunStok> urunListesi;
private List<UrunStokDetayliArama> urunStokDetayListesi;
private Renk secilenRenk = null;
private JLabel jLabelUrunSube;
private CComboBox<String> cComboBoxUrunSube;
private TablePanel cTableAramaSonuc;
private int andGirildimi = 0;
private static final String DEFAULT_COMBOBOX_VALUE = "Seçiniz";
private static final String ALL_COMBOBOX_VALUE = "TÜMÜ";
public static PSADetayliArama getInstance() {
instance = new PSADetayliArama();
return instance;
}
public PSADetayliArama() {
initialize();
}
private void initialize() {
setTitle("PSA ŞUBE DETAYLI ARAMA EKRANI");
setBounds(0, 0, 1010, 506);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setIconImage(PSAUtil.getImageIconViaRelativePath("picture/psaIcon.png")
.getImage());
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
GridBagLayout gbl_contentPane = new GridBagLayout();
gbl_contentPane.columnWidths = new int[] { 330, 649, 0 };
gbl_contentPane.rowHeights = new int[] { 20, 400, 80, 80, 0 };
gbl_contentPane.columnWeights = new double[] { 0.0, 1.0,
Double.MIN_VALUE };
gbl_contentPane.rowWeights = new double[] { 0.0, 1.0, 1.0, 1.0,
Double.MIN_VALUE };
contentPane.setLayout(gbl_contentPane);
jLabelUrunBilgi = new JLabel();
jLabelUrunBilgi.setText("ARAMA KISITLARI");
jLabelUrunBilgi.setHorizontalAlignment(SwingConstants.CENTER);
jLabelUrunBilgi.setFont(new Font("Tahoma", Font.BOLD, 16));
GridBagConstraints gbc_jLabelUrunBilgi = new GridBagConstraints();
gbc_jLabelUrunBilgi.fill = GridBagConstraints.HORIZONTAL;
gbc_jLabelUrunBilgi.anchor = GridBagConstraints.NORTH;
gbc_jLabelUrunBilgi.insets = new Insets(0, 0, 5, 5);
gbc_jLabelUrunBilgi.gridx = 0;
gbc_jLabelUrunBilgi.gridy = 0;
contentPane.add(jLabelUrunBilgi, gbc_jLabelUrunBilgi);
jLabelTabloBilgi = new JLabel();
jLabelTabloBilgi.setText("ARAMA SONUÇ TABLOSU");
jLabelTabloBilgi.setHorizontalAlignment(SwingConstants.CENTER);
jLabelTabloBilgi.setFont(new Font("Tahoma", Font.BOLD, 16));
GridBagConstraints gbc_jLabelTabloBilgi = new GridBagConstraints();
gbc_jLabelTabloBilgi.anchor = GridBagConstraints.NORTH;
gbc_jLabelTabloBilgi.fill = GridBagConstraints.HORIZONTAL;
gbc_jLabelTabloBilgi.insets = new Insets(0, 0, 5, 0);
gbc_jLabelTabloBilgi.gridx = 1;
gbc_jLabelTabloBilgi.gridy = 0;
contentPane.add(jLabelTabloBilgi, gbc_jLabelTabloBilgi);
cPanelUrunBilgi = new JPanel();
cPanelUrunBilgi.setBorder(new LineBorder(new Color(0, 0, 0), 2));
cPanelUrunBilgi.setBackground(UIManager.getColor("Button.shadow"));
GridBagConstraints gbc_cPanelUrunBilgi = new GridBagConstraints();
gbc_cPanelUrunBilgi.fill = GridBagConstraints.BOTH;
gbc_cPanelUrunBilgi.insets = new Insets(0, 0, 5, 5);
gbc_cPanelUrunBilgi.gridx = 0;
gbc_cPanelUrunBilgi.gridy = 1;
contentPane.add(cPanelUrunBilgi, gbc_cPanelUrunBilgi);
GridBagLayout gbl_cPanelUrunBilgi = new GridBagLayout();
gbl_cPanelUrunBilgi.columnWidths = new int[] { 0, 264, 0 };
gbl_cPanelUrunBilgi.rowHeights = new int[] { 20, 20, 20, 20, 20, 21,
22, 20, 20, 0 };
gbl_cPanelUrunBilgi.columnWeights = new double[] { 0.0, 0.0,
Double.MIN_VALUE };
gbl_cPanelUrunBilgi.rowWeights = new double[] { 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE };
cPanelUrunBilgi.setLayout(gbl_cPanelUrunBilgi);
jLabelUrunSube = new JLabel();
jLabelUrunSube.setText("Şube");
jLabelUrunSube.setFont(new Font("Tahoma", Font.BOLD, 14));
GridBagConstraints gbc_jLabelUrunSube = new GridBagConstraints();
gbc_jLabelUrunSube.anchor = GridBagConstraints.WEST;
gbc_jLabelUrunSube.fill = GridBagConstraints.VERTICAL;
gbc_jLabelUrunSube.insets = new Insets(0, 0, 5, 5);
gbc_jLabelUrunSube.gridx = 0;
gbc_jLabelUrunSube.gridy = 0;
cPanelUrunBilgi.add(jLabelUrunSube, gbc_jLabelUrunSube);
cComboBoxUrunSube = new CComboBox<String>(String.class);
GridBagConstraints gbc_cComboBoxUrunSube = new GridBagConstraints();
gbc_cComboBoxUrunSube.fill = GridBagConstraints.BOTH;
gbc_cComboBoxUrunSube.insets = new Insets(0, 0, 5, 0);
gbc_cComboBoxUrunSube.gridx = 1;
gbc_cComboBoxUrunSube.gridy = 0;
cPanelUrunBilgi.add(cComboBoxUrunSube, gbc_cComboBoxUrunSube);
jLabelUrunSezon = new JLabel();
jLabelUrunSezon.setText("Sezonu");
jLabelUrunSezon.setFont(new Font("Tahoma", Font.BOLD, 14));
GridBagConstraints gbc_jLabelUrunSezon = new GridBagConstraints();
gbc_jLabelUrunSezon.anchor = GridBagConstraints.WEST;
gbc_jLabelUrunSezon.fill = GridBagConstraints.VERTICAL;
gbc_jLabelUrunSezon.insets = new Insets(0, 0, 5, 5);
gbc_jLabelUrunSezon.gridx = 0;
gbc_jLabelUrunSezon.gridy = 1;
cPanelUrunBilgi.add(jLabelUrunSezon, gbc_jLabelUrunSezon);
cComboBoxUrunSezon = new CComboBox<UrunSezon>(UrunSezon.class);
GridBagConstraints gbc_cComboBoxUrunSezon = new GridBagConstraints();
gbc_cComboBoxUrunSezon.fill = GridBagConstraints.BOTH;
gbc_cComboBoxUrunSezon.insets = new Insets(0, 0, 5, 0);
gbc_cComboBoxUrunSezon.gridx = 1;
gbc_cComboBoxUrunSezon.gridy = 1;
cPanelUrunBilgi.add(cComboBoxUrunSezon, gbc_cComboBoxUrunSezon);
jLabelUrunGrup = new JLabel();
jLabelUrunGrup.setText("Grubu");
jLabelUrunGrup.setFont(new Font("Tahoma", Font.BOLD, 14));
GridBagConstraints gbc_jLabelUrunGrup = new GridBagConstraints();
gbc_jLabelUrunGrup.anchor = GridBagConstraints.WEST;
gbc_jLabelUrunGrup.fill = GridBagConstraints.VERTICAL;
gbc_jLabelUrunGrup.insets = new Insets(0, 0, 5, 5);
gbc_jLabelUrunGrup.gridx = 0;
gbc_jLabelUrunGrup.gridy = 2;
cPanelUrunBilgi.add(jLabelUrunGrup, gbc_jLabelUrunGrup);
cComboBoxUrunGrup = new CComboBox<UrunGrup>(UrunGrup.class);
GridBagConstraints gbc_cComboBoxUrunGrup = new GridBagConstraints();
gbc_cComboBoxUrunGrup.fill = GridBagConstraints.BOTH;
gbc_cComboBoxUrunGrup.insets = new Insets(0, 0, 5, 0);
gbc_cComboBoxUrunGrup.gridx = 1;
gbc_cComboBoxUrunGrup.gridy = 2;
cPanelUrunBilgi.add(cComboBoxUrunGrup, gbc_cComboBoxUrunGrup);
jLabelUrunModel = new JLabel();
jLabelUrunModel.setText("Modeli");
jLabelUrunModel.setFont(new Font("Tahoma", Font.BOLD, 14));
GridBagConstraints gbc_jLabelUrunModel = new GridBagConstraints();
gbc_jLabelUrunModel.anchor = GridBagConstraints.WEST;
gbc_jLabelUrunModel.fill = GridBagConstraints.VERTICAL;
gbc_jLabelUrunModel.insets = new Insets(0, 0, 5, 5);
gbc_jLabelUrunModel.gridx = 0;
gbc_jLabelUrunModel.gridy = 3;
cPanelUrunBilgi.add(jLabelUrunModel, gbc_jLabelUrunModel);
cComboBoxUrunModel = new CComboBox<UrunModel>(UrunModel.class);
GridBagConstraints gbc_cComboBoxUrunModel = new GridBagConstraints();
gbc_cComboBoxUrunModel.fill = GridBagConstraints.BOTH;
gbc_cComboBoxUrunModel.insets = new Insets(0, 0, 5, 0);
gbc_cComboBoxUrunModel.gridx = 1;
gbc_cComboBoxUrunModel.gridy = 3;
cPanelUrunBilgi.add(cComboBoxUrunModel, gbc_cComboBoxUrunModel);
jLabelUrunBeden = new JLabel();
jLabelUrunBeden.setText("Bedeni");
jLabelUrunBeden.setFont(new Font("Tahoma", Font.BOLD, 14));
GridBagConstraints gbc_jLabelUrunBeden = new GridBagConstraints();
gbc_jLabelUrunBeden.anchor = GridBagConstraints.WEST;
gbc_jLabelUrunBeden.fill = GridBagConstraints.VERTICAL;
gbc_jLabelUrunBeden.insets = new Insets(0, 0, 5, 5);
gbc_jLabelUrunBeden.gridx = 0;
gbc_jLabelUrunBeden.gridy = 4;
cPanelUrunBilgi.add(jLabelUrunBeden, gbc_jLabelUrunBeden);
cComboBoxUrunBeden = new CComboBox<UrunBeden>(UrunBeden.class);
GridBagConstraints gbc_cComboBoxUrunBeden = new GridBagConstraints();
gbc_cComboBoxUrunBeden.fill = GridBagConstraints.BOTH;
gbc_cComboBoxUrunBeden.insets = new Insets(0, 0, 5, 0);
gbc_cComboBoxUrunBeden.gridx = 1;
gbc_cComboBoxUrunBeden.gridy = 4;
cPanelUrunBilgi.add(cComboBoxUrunBeden, gbc_cComboBoxUrunBeden);
jLabelUrunRenk = new JLabel();
jLabelUrunRenk.setText("Rengi");
jLabelUrunRenk.setFont(new Font("Tahoma", Font.BOLD, 14));
GridBagConstraints gbc_jLabelUrunRenk = new GridBagConstraints();
gbc_jLabelUrunRenk.anchor = GridBagConstraints.WEST;
gbc_jLabelUrunRenk.fill = GridBagConstraints.VERTICAL;
gbc_jLabelUrunRenk.insets = new Insets(0, 0, 5, 5);
gbc_jLabelUrunRenk.gridx = 0;
gbc_jLabelUrunRenk.gridy = 5;
cPanelUrunBilgi.add(jLabelUrunRenk, gbc_jLabelUrunRenk);
cTextFieldUrunRenk = new CTextField(30);
cTextFieldUrunRenk.setText("RENK YOK");
cTextFieldUrunRenk.setHorizontalAlignment(SwingConstants.CENTER);
cTextFieldUrunRenk.setForeground(Color.BLACK);
cTextFieldUrunRenk.setEditable(false);
cTextFieldUrunRenk.setBackground(Color.WHITE);
GridBagConstraints gbc_cTextFieldUrunRenk = new GridBagConstraints();
gbc_cTextFieldUrunRenk.fill = GridBagConstraints.BOTH;
gbc_cTextFieldUrunRenk.insets = new Insets(0, 0, 5, 0);
gbc_cTextFieldUrunRenk.gridx = 1;
gbc_cTextFieldUrunRenk.gridy = 5;
cPanelUrunBilgi.add(cTextFieldUrunRenk, gbc_cTextFieldUrunRenk);
jLabelUrunCinsiyet = new JLabel();
jLabelUrunCinsiyet.setText("Cinsiyeti");
jLabelUrunCinsiyet.setFont(new Font("Tahoma", Font.BOLD, 14));
GridBagConstraints gbc_jLabelUrunCinsiyet = new GridBagConstraints();
gbc_jLabelUrunCinsiyet.anchor = GridBagConstraints.WEST;
gbc_jLabelUrunCinsiyet.fill = GridBagConstraints.VERTICAL;
gbc_jLabelUrunCinsiyet.insets = new Insets(0, 0, 5, 5);
gbc_jLabelUrunCinsiyet.gridx = 0;
gbc_jLabelUrunCinsiyet.gridy = 6;
cPanelUrunBilgi.add(jLabelUrunCinsiyet, gbc_jLabelUrunCinsiyet);
cComboBoxUrunCinsiyet = new CComboBox<UrunCinsiyet>(UrunCinsiyet.class);
cComboBoxUrunCinsiyet.setSelectedIndex(-1);
GridBagConstraints gbc_cComboBoxUrunCinsiyet = new GridBagConstraints();
gbc_cComboBoxUrunCinsiyet.fill = GridBagConstraints.BOTH;
gbc_cComboBoxUrunCinsiyet.insets = new Insets(0, 0, 5, 0);
gbc_cComboBoxUrunCinsiyet.gridx = 1;
gbc_cComboBoxUrunCinsiyet.gridy = 6;
cPanelUrunBilgi.add(cComboBoxUrunCinsiyet, gbc_cComboBoxUrunCinsiyet);
jLabelUrunMarka = new JLabel();
jLabelUrunMarka.setText("Markası");
jLabelUrunMarka.setFont(new Font("Tahoma", Font.BOLD, 14));
GridBagConstraints gbc_jLabelUrunMarka = new GridBagConstraints();
gbc_jLabelUrunMarka.anchor = GridBagConstraints.WEST;
gbc_jLabelUrunMarka.fill = GridBagConstraints.VERTICAL;
gbc_jLabelUrunMarka.insets = new Insets(0, 0, 5, 5);
gbc_jLabelUrunMarka.gridx = 0;
gbc_jLabelUrunMarka.gridy = 7;
cPanelUrunBilgi.add(jLabelUrunMarka, gbc_jLabelUrunMarka);
cComboBoxUrunMarka = new CComboBox<UrunMarka>(UrunMarka.class);
cComboBoxUrunMarka.setSelectedIndex(-1);
GridBagConstraints gbc_cComboBoxUrunMarka = new GridBagConstraints();
gbc_cComboBoxUrunMarka.fill = GridBagConstraints.BOTH;
gbc_cComboBoxUrunMarka.insets = new Insets(0, 0, 5, 0);
gbc_cComboBoxUrunMarka.gridx = 1;
gbc_cComboBoxUrunMarka.gridy = 7;
cPanelUrunBilgi.add(cComboBoxUrunMarka, gbc_cComboBoxUrunMarka);
jLabelUrunFirma = new JLabel();
jLabelUrunFirma.setText("Firma");
jLabelUrunFirma.setFont(new Font("Tahoma", Font.BOLD, 14));
GridBagConstraints gbc_jLabelUrunFirma = new GridBagConstraints();
gbc_jLabelUrunFirma.insets = new Insets(0, 0, 0, 5);
gbc_jLabelUrunFirma.anchor = GridBagConstraints.WEST;
gbc_jLabelUrunFirma.fill = GridBagConstraints.VERTICAL;
gbc_jLabelUrunFirma.gridx = 0;
gbc_jLabelUrunFirma.gridy = 8;
cPanelUrunBilgi.add(jLabelUrunFirma, gbc_jLabelUrunFirma);
cComboBoxUrunFirma = new CComboBox<Musteri>(Musteri.class);
cComboBoxUrunFirma.setSelectedIndex(-1);
GridBagConstraints gbc_cComboBoxUrunFirma = new GridBagConstraints();
gbc_cComboBoxUrunFirma.fill = GridBagConstraints.BOTH;
gbc_cComboBoxUrunFirma.gridx = 1;
gbc_cComboBoxUrunFirma.gridy = 8;
cPanelUrunBilgi.add(cComboBoxUrunFirma, gbc_cComboBoxUrunFirma);
cTableAramaSonuc = new TablePanel((String) null,
UrunStokDetayliArama.class);
cTableAramaSonuc.setBorder(new LineBorder(new Color(0, 0, 0), 2));
GridBagConstraints gbc_cTableAramaSonuc = new GridBagConstraints();
gbc_cTableAramaSonuc.gridheight = 3;
gbc_cTableAramaSonuc.insets = new Insets(0, 0, 5, 0);
gbc_cTableAramaSonuc.fill = GridBagConstraints.BOTH;
gbc_cTableAramaSonuc.gridx = 1;
gbc_cTableAramaSonuc.gridy = 1;
contentPane.add(cTableAramaSonuc, gbc_cTableAramaSonuc);
jButtonDetayGoster = new JButton();
jButtonDetayGoster.setText("ARA");
jButtonDetayGoster.setFont(new Font("Tahoma", Font.BOLD, 13));
jButtonDetayGoster.setIcon(PSAUtil
.getImageIconViaRelativePath("picture/detayliArama.png"));
GridBagConstraints gbc_jButtonDetayGoster = new GridBagConstraints();
gbc_jButtonDetayGoster.fill = GridBagConstraints.BOTH;
gbc_jButtonDetayGoster.insets = new Insets(0, 0, 5, 5);
gbc_jButtonDetayGoster.gridx = 0;
gbc_jButtonDetayGoster.gridy = 2;
contentPane.add(jButtonDetayGoster, gbc_jButtonDetayGoster);
cButtonIptal = new JButton();
cButtonIptal.setText("İPTAL");
cButtonIptal.setFont(new Font("Tahoma", Font.BOLD, 13));
cButtonIptal.setIcon(PSAUtil
.getImageIconViaRelativePath("picture/geriButonu.png"));
GridBagConstraints gbc_cButtonIptal = new GridBagConstraints();
gbc_cButtonIptal.fill = GridBagConstraints.BOTH;
gbc_cButtonIptal.insets = new Insets(0, 0, 0, 5);
gbc_cButtonIptal.gridx = 0;
gbc_cButtonIptal.gridy = 3;
contentPane.add(cButtonIptal, gbc_cButtonIptal);
fillComboBox();
initListener();
}
private void fillComboBox() {
List<?> list;
list = HibernateManager.getInstance().get(UrunBeden.class, false);
UrunBeden ub = new UrunBeden();
ub.setBeden(DEFAULT_COMBOBOX_VALUE);
cComboBoxUrunBeden.setInitialObject(ub);
cComboBoxUrunBeden.setObjects(list);
list = HibernateManager.getInstance().get(UrunModel.class, false);
UrunModel um = new UrunModel();
um.setModel(DEFAULT_COMBOBOX_VALUE);
cComboBoxUrunModel.setInitialObject(um);
cComboBoxUrunModel.setObjects(list);
list = HibernateManager.getInstance().get(UrunGrup.class, false);
UrunGrup ug = new UrunGrup();
ug.setGrup(DEFAULT_COMBOBOX_VALUE);
cComboBoxUrunGrup.setInitialObject(ug);
cComboBoxUrunGrup.setObjects(list);
list = HibernateManager.getInstance().get(UrunMarka.class, false);
UrunMarka urunM = new UrunMarka();
urunM.setMarka(DEFAULT_COMBOBOX_VALUE);
cComboBoxUrunMarka.setInitialObject(urunM);
cComboBoxUrunMarka.setObjects(list);
list = HibernateManager.getInstance().get(UrunCinsiyet.class, false);
UrunCinsiyet uc = new UrunCinsiyet();
uc.setCinsiyet(DEFAULT_COMBOBOX_VALUE);
cComboBoxUrunCinsiyet.setInitialObject(uc);
cComboBoxUrunCinsiyet.setObjects(list);
list = HibernateManager.getInstance().getWithCriteria(Musteri.class,
"musteriGrubu", "TOPTANCI", false);
Musteri uf = new Musteri();
uf.setYetkiliKisi(DEFAULT_COMBOBOX_VALUE);
cComboBoxUrunFirma.setInitialObject(uf);
cComboBoxUrunFirma.setObjects(list);
list = HibernateManager.getInstance().get(UrunSezon.class, false);
UrunSezon us = new UrunSezon();
us.setSezon(DEFAULT_COMBOBOX_VALUE);
cComboBoxUrunSezon.setInitialObject(us);
cComboBoxUrunSezon.setObjects(list);
List<?> subeListesi = HibernateManager.getInstance()
.distinctSelectField(Kullanici.class, "systemName");
cComboBoxUrunSube.setObjects(subeListesi);
cComboBoxUrunSube.insertItemAt(ALL_COMBOBOX_VALUE, 0);
cComboBoxUrunSube.setSelectedIndex(0);
}
private void initListener() {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
anaEkranSetEnable();
}
});
cButtonIptal.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
anaEkranSetEnable();
}
});
jButtonDetayGoster.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
detayGosterClicked();
}
});
cTextFieldUrunRenk.addMouseListener(new MouseListener() {
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseClicked(MouseEvent arg0) {
PSARenkSecimEkrani renkSecim = new PSARenkSecimEkrani(instance);
secilenRenk = renkSecim.showDialog();
if (secilenRenk != null) {
cTextFieldUrunRenk.setBackground(secilenRenk.getColor());
cTextFieldUrunRenk.setText(secilenRenk.getName());
} else {
cTextFieldUrunRenk.setBackground(Color.WHITE);
cTextFieldUrunRenk.setText("RENK YOK");
}
}
});
cTableAramaSonuc.getRaporButton().addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
detayliAramRaporClicked();
}
});
}
protected void detayliAramRaporClicked() {
DateFormat dateFormat = new SimpleDateFormat("dd/MMMM/yyyy");
List<String> ustSatir = new ArrayList<>();
ustSatir.add("Tarih : " + dateFormat.format(new Date()));
ReportInfo rapor = new ReportInfo();
rapor.setTitle("DETAYLI ARAMA RAPORU");
rapor.setHeadRows(ustSatir);
cTableAramaSonuc.setReportInfo(rapor);
}
@SuppressWarnings("unchecked")
protected void detayGosterClicked() {
if (detayliAramaFieldKonrol()) {
if (cComboBoxUrunSube.getSelectedItem() != null
&& cComboBoxUrunSube.getSelectedIndex() != 0) {
urunListesi = (List<UrunStok>) detayliAramaHqlQuery();
} else {
urunListesi = (List<UrunStok>) HibernateManager.getInstance()
.get(UrunStok.class, false);
}
} else {
urunListesi = (List<UrunStok>) detayliAramaHqlQuery();
}
if (urunListesi.size() == 0) {
LinkedList<?> list = new LinkedList<>();
cTableAramaSonuc.setObjects(list);
AutoClosingMessageDialog.showAutoClosingMessageDialog(
"Arama sonucu ürün bulunmamaktadır.", 2);
} else {
urunStokDetayListesi = convertToUrunUrunStokDetay(urunListesi);
cTableAramaSonuc.setObjects(urunStokDetayListesi);
}
}
private boolean detayliAramaFieldKonrol() {
if (cComboBoxUrunSezon.getSelectedIndex() == 0
&& cComboBoxUrunGrup.getSelectedIndex() == 0
&& cComboBoxUrunModel.getSelectedIndex() == 0
&& cComboBoxUrunBeden.getSelectedIndex() == 0
&& cComboBoxUrunCinsiyet.getSelectedIndex() == 0
&& cComboBoxUrunMarka.getSelectedIndex() == 0
&& cComboBoxUrunFirma.getSelectedIndex() == 0
&& secilenRenk == null)
return true;
return false;
}
private List<?> detayliAramaHqlQuery() {
Session openSession = HibernateManager.getInstance().openSession();
openSession.beginTransaction();
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("from UrunStok where ");
if (cComboBoxUrunSube.getSelectedItem() != null
&& cComboBoxUrunSube.getSelectedIndex() != 0) {
sBuilder = hqlStringiOlustur(sBuilder, "systemName",
cComboBoxUrunSube.getSelectedItem().toString());
}
if (cComboBoxUrunSezon.getSelectedItem() != null
&& cComboBoxUrunSezon.getSelectedIndex() != 0) {
sBuilder = hqlStringiOlustur(sBuilder, "sezon", cComboBoxUrunSezon
.getSelectedItem().toString());
}
if (cComboBoxUrunGrup.getSelectedItem() != null
&& cComboBoxUrunGrup.getSelectedIndex() != 0) {
sBuilder = hqlStringiOlustur(sBuilder, "grup", cComboBoxUrunGrup
.getSelectedItem().toString());
}
if (cComboBoxUrunModel.getSelectedItem() != null
&& cComboBoxUrunModel.getSelectedIndex() != 0) {
sBuilder = hqlStringiOlustur(sBuilder, "model", cComboBoxUrunModel
.getSelectedItem().toString());
}
if (cComboBoxUrunBeden.getSelectedItem() != null
&& cComboBoxUrunBeden.getSelectedIndex() != 0) {
sBuilder = hqlStringiOlustur(sBuilder, "beden", cComboBoxUrunBeden
.getSelectedItem().toString());
}
if (cComboBoxUrunCinsiyet.getSelectedItem() != null
&& cComboBoxUrunCinsiyet.getSelectedIndex() != 0) {
sBuilder = hqlStringiOlustur(sBuilder, "cinsiyet",
cComboBoxUrunCinsiyet.getSelectedItem().toString());
}
if (cComboBoxUrunMarka.getSelectedItem() != null
&& cComboBoxUrunMarka.getSelectedIndex() != 0) {
sBuilder = hqlStringiOlustur(sBuilder, "marka", cComboBoxUrunMarka
.getSelectedItem().toString());
}
if (cComboBoxUrunFirma.getSelectedItem() != null
&& cComboBoxUrunFirma.getSelectedIndex() != 0) {
sBuilder = hqlStringiOlustur(sBuilder, "firmaAd",
cComboBoxUrunFirma.getSelectedItem().toString());
}
if (secilenRenk != null) {
sBuilder = hqlStringiOlustur(sBuilder, "renkAd",
cTextFieldUrunRenk.getText());
}
String hql = sBuilder.toString();
Query createQuery = openSession.createQuery(hql);
List<?> list = createQuery.list();
openSession.close();
andGirildimi = 0;
return list;
}
public StringBuilder hqlStringiOlustur(StringBuilder sBuilder,
String fieldName, String fieldValue) {
if (andGirildimi == 0) {
sBuilder.append(fieldName + " = '" + fieldValue + "'");
andGirildimi = 1;
} else {
sBuilder.append(" and " + fieldName + " = '" + fieldValue + "'");
}
return sBuilder;
}
protected void anaEkranSetEnable() {
PSAAnaEkran.getInstance(null).setEnabled(true);
instance.dispose();
}
private static List<UrunStokDetayliArama> convertToUrunUrunStokDetay(
List<UrunStok> list) {
List<UrunStokDetayliArama> urunDetayList = new LinkedList<>();
for (UrunStok urunStok : list) {
UrunStokDetayliArama urunStokDetay = new UrunStokDetayliArama(
urunStok);
urunDetayList.add(urunStokDetay);
}
return urunDetayList;
}
}