package gui;
import hibernateSwingApi.component.CTextField;
import hibernateSwingApi.hibernate.HibernateManager;
import hibernateSwingApi.utils.Utils;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
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.LineBorder;
import pojos.BankaPOSBilgileri;
import pojos.BankaPOSVadeBilgileri;
import pojos.OdemeBilgileri;
import pojos.UrunSatis;
import pojos.UrunStok;
import pojos.YapilanSatis;
import pojos.YapilanSatisPOSBilgileri;
import pojos.YapilanSatisPOSVadeBilgileri;
import service.AutoClosingMessageDialog;
import service.PSAUtil;
import control.PriceControl;
public class PSAParcaliOdemeEkrani extends JFrame {
private static final long serialVersionUID = 1L;
private static PSAParcaliOdemeEkrani instance;
private JPanel jPanelNakitTutar;
private JLabel jLabelNakitTutar;
private CTextField jTextFieldNakitTutar;
private JLabel jLabelTL;
private JPanel jPanelToplamTutar;
private JLabel jLabelToplamTutar;
private JLabel jLabelToplamTutarBilgisi;
private JPanel jPanelKrediKartTutar;
private JLabel jLabelKrediKartTutar;
private CTextField jTextFieldKrediKartTutar;
private JLabel jLabelTL1;
private JButton jButtonOdemeKaydet;
private JButton jButtonİptal;
private JPanel jPanelPosBilgileri;
private int maxLength;
private int initx;
private int inity;
private int buttonCount;
private int loopTime;
private int panelWidth;
private int panelHeight;
private JLabel jLabelBankaSeciniz;
private YapilanSatis satisBilgi;
private List<UrunSatis> urunListesi = new LinkedList<>();
private List<UrunSatis> satilanUrunListesi = new LinkedList<>();
private UrunSatis urunSatis;
private JLabel jLabelTL2;
private Robot robot;
private JLabel jLabelSecilenBanka;
private JLabel jLabelSecilenBankaBilgisi;
private JLabel jLabelPosVade;
private JLabel jLabelPosVadeBilgisi;
private JButton JButtonBankaSecGeri;
private JPanel jPanelPosBilgisiSon;
private BankaPOSBilgileri posBilgi;
private BankaPOSVadeBilgileri posVadeBilgileri;
private OdemeBilgileri odemeBilgisi;
private int frameState;
private double degisimFiyatFarki;
private double satisFiyati;
public static PSAParcaliOdemeEkrani getInstance(int state,
YapilanSatis satis, List<UrunSatis> urunSatisListesi,
UrunSatis urunSatis, UrunStok urunStok, double fiyatFarki) {
instance = new PSAParcaliOdemeEkrani(state, satis, urunSatisListesi,
urunSatis, urunStok, fiyatFarki);
return instance;
}
public PSAParcaliOdemeEkrani(int state, YapilanSatis satis,
List<UrunSatis> urunSatisListesi, UrunSatis urunSatis2,
UrunStok urunStok, double fiyatFarki) {
setValue(state, satis, urunSatisListesi, urunSatis2, urunStok,
fiyatFarki);
initialize();
}
private void initialize() {
setTitle("PSA MERKEZ PARÇALI ÖDEME EKRANI");
setBounds(0, 0, 730, 400);
setResizable(false);
setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
setIconImage(PSAUtil.getImageIconViaRelativePath("picture/psaIcon.png")
.getImage());
setSize(730, 400);
locateFrameToMiddle();
getContentPane().setLayout(null);
jPanelNakitTutar = new JPanel();
jPanelNakitTutar.setBorder(new LineBorder(new Color(0, 0, 0), 2));
jPanelNakitTutar.setBackground(UIManager.getColor("Button.shadow"));
jPanelNakitTutar.setBounds(469, 90, 250, 70);
getContentPane().add(jPanelNakitTutar);
jPanelNakitTutar.setLayout(null);
jLabelNakitTutar = new JLabel("NAKİT TUTAR");
jLabelNakitTutar.setFont(new Font("Tahoma", Font.BOLD, 14));
jLabelNakitTutar.setHorizontalAlignment(SwingConstants.CENTER);
jLabelNakitTutar.setBounds(36, 11, 202, 14);
jPanelNakitTutar.add(jLabelNakitTutar);
jTextFieldNakitTutar = new CTextField();
jTextFieldNakitTutar.setBounds(89, 36, 98, 20);
jPanelNakitTutar.add(jTextFieldNakitTutar);
jLabelTL = new JLabel("TL");
jLabelTL.setFont(new Font("Tahoma", Font.BOLD, 14));
jLabelTL.setBounds(194, 39, 46, 14);
jPanelNakitTutar.add(jLabelTL);
jPanelToplamTutar = new JPanel();
jPanelToplamTutar.setBorder(new LineBorder(new Color(0, 0, 0), 2));
jPanelToplamTutar.setBackground(UIManager.getColor("Button.shadow"));
jPanelToplamTutar.setBounds(5, 11, 714, 58);
getContentPane().add(jPanelToplamTutar);
jPanelToplamTutar.setLayout(null);
jLabelToplamTutar = new JLabel("TOPLAM TUTAR");
jLabelToplamTutar.setBounds(120, 21, 237, 14);
jPanelToplamTutar.add(jLabelToplamTutar);
jLabelToplamTutar.setFont(new Font("Tahoma", Font.BOLD, 16));
jLabelToplamTutar.setHorizontalAlignment(SwingConstants.CENTER);
jLabelToplamTutarBilgisi = new JLabel("231");
jLabelToplamTutarBilgisi.setBounds(363, 21, 179, 14);
jPanelToplamTutar.add(jLabelToplamTutarBilgisi);
jLabelToplamTutarBilgisi.setHorizontalAlignment(SwingConstants.CENTER);
jLabelToplamTutarBilgisi.setFont(new Font("Tahoma", Font.BOLD, 16));
jLabelTL2 = new JLabel("TL");
jLabelTL2.setFont(new Font("Tahoma", Font.BOLD, 14));
jLabelTL2.setBounds(551, 21, 46, 14);
jPanelToplamTutar.add(jLabelTL2);
jPanelKrediKartTutar = new JPanel();
jPanelKrediKartTutar.setBackground(UIManager.getColor("Button.shadow"));
jPanelKrediKartTutar.setBorder(new LineBorder(new Color(0, 0, 0), 2));
jPanelKrediKartTutar.setBounds(5, 90, 454, 70);
getContentPane().add(jPanelKrediKartTutar);
jPanelKrediKartTutar.setLayout(null);
jLabelKrediKartTutar = new JLabel("KREDİ KARTI TUTAR");
jLabelKrediKartTutar.setHorizontalAlignment(SwingConstants.CENTER);
jLabelKrediKartTutar.setFont(new Font("Tahoma", Font.BOLD, 14));
jLabelKrediKartTutar.setBounds(60, 11, 230, 14);
jPanelKrediKartTutar.add(jLabelKrediKartTutar);
jTextFieldKrediKartTutar = new CTextField();
jTextFieldKrediKartTutar.setBounds(102, 36, 109, 20);
jPanelKrediKartTutar.add(jTextFieldKrediKartTutar);
jLabelTL1 = new JLabel("TL");
jLabelTL1.setFont(new Font("Tahoma", Font.BOLD, 14));
jLabelTL1.setBounds(231, 37, 46, 14);
jPanelKrediKartTutar.add(jLabelTL1);
jButtonOdemeKaydet = new JButton("İŞLEM TAMAMLA");
jButtonOdemeKaydet.setIcon(PSAUtil
.getImageIconViaRelativePath("picture/satisTamamla.png"));
jButtonOdemeKaydet.setFont(new Font("Tahoma", Font.BOLD, 16));
jButtonOdemeKaydet.setBounds(469, 214, 250, 70);
getContentPane().add(jButtonOdemeKaydet);
jButtonİptal = new JButton("İPTAL");
jButtonİptal.setFont(new Font("Tahoma", Font.BOLD, 16));
jButtonİptal.setBounds(469, 295, 250, 70);
jButtonİptal.setIcon(PSAUtil
.getImageIconViaRelativePath("picture/geriButonu.png"));
getContentPane().add(jButtonİptal);
jLabelBankaSeciniz = new JLabel("BANKA SEÇİNİZ");
jLabelBankaSeciniz.setFont(new Font("Tahoma", Font.BOLD, 14));
jLabelBankaSeciniz.setHorizontalAlignment(SwingConstants.CENTER);
jLabelBankaSeciniz.setBounds(5, 171, 454, 14);
getContentPane().add(jLabelBankaSeciniz);
jPanelPosBilgileri = new JPanel();
jPanelPosBilgileri.setBorder(new LineBorder(new Color(0, 0, 0), 2));
jPanelPosBilgileri.setBackground(UIManager.getColor("Button.shadow"));
jPanelPosBilgileri.setLayout(null);
getContentPane().add(jPanelPosBilgileri);
jPanelPosBilgisiSon = new JPanel();
jPanelPosBilgisiSon.setBackground(UIManager.getColor("Button.shadow"));
jPanelPosBilgisiSon.setBorder(new LineBorder(new Color(0, 0, 0), 2));
jPanelPosBilgisiSon.setBounds(5, 196, 454, 169);
getContentPane().add(jPanelPosBilgisiSon);
jPanelPosBilgisiSon.setVisible(false);
jPanelPosBilgisiSon.setLayout(null);
jLabelSecilenBanka = new JLabel("SEÇİLEN BANKA");
jLabelSecilenBanka.setHorizontalAlignment(SwingConstants.LEFT);
jLabelSecilenBanka.setFont(new Font("Tahoma", Font.BOLD, 14));
jLabelSecilenBanka.setBounds(10, 11, 185, 30);
jPanelPosBilgisiSon.add(jLabelSecilenBanka);
jLabelSecilenBankaBilgisi = new JLabel("");
jLabelSecilenBankaBilgisi.setHorizontalAlignment(SwingConstants.CENTER);
jLabelSecilenBankaBilgisi.setFont(new Font("Tahoma", Font.BOLD, 14));
jLabelSecilenBankaBilgisi.setBounds(195, 11, 249, 30);
jPanelPosBilgisiSon.add(jLabelSecilenBankaBilgisi);
jLabelPosVade = new JLabel("SEÇİLEN ÖDEME ŞEKLİ");
jLabelPosVade.setHorizontalAlignment(SwingConstants.LEFT);
jLabelPosVade.setFont(new Font("Tahoma", Font.BOLD, 14));
jLabelPosVade.setBounds(10, 52, 185, 30);
jPanelPosBilgisiSon.add(jLabelPosVade);
jLabelPosVadeBilgisi = new JLabel("");
jLabelPosVadeBilgisi.setHorizontalAlignment(SwingConstants.CENTER);
jLabelPosVadeBilgisi.setFont(new Font("Tahoma", Font.BOLD, 14));
jLabelPosVadeBilgisi.setBounds(195, 52, 249, 30);
jPanelPosBilgisiSon.add(jLabelPosVadeBilgisi);
JButtonBankaSecGeri = new JButton("GERİ");
JButtonBankaSecGeri.setFont(new Font("Tahoma", Font.BOLD, 14));
JButtonBankaSecGeri.setBounds(156, 106, 145, 52);
JButtonBankaSecGeri.setIcon(PSAUtil
.getImageIconViaRelativePath("picture/geriButonu.png"));
jPanelPosBilgisiSon.add(JButtonBankaSecGeri);
initListeners();
fillInfo();
initPosButtons();
}
private void setValue(int state, YapilanSatis satis,
List<UrunSatis> urunSatisListesi, UrunSatis urunSatis2,
UrunStok urunStok, double fiyatFarki) {
frameState = state;
satisBilgi = satis;
urunListesi = urunSatisListesi;
if (frameState == 1) {
degisimFiyatFarki = fiyatFarki;
}
}
private void fillInfo() {
if (frameState == 0) {
jLabelToplamTutarBilgisi.setText(Utils.DECIMAL_FORMAT
.format(satisBilgi.getTutar()));
satisFiyati = satisBilgi.getTutar();
} else {
jLabelToplamTutarBilgisi.setText(Utils.DECIMAL_FORMAT
.format(degisimFiyatFarki));
satisFiyati = degisimFiyatFarki;
}
}
@SuppressWarnings("unchecked")
private void initPosButtons() {
List<BankaPOSBilgileri> posBilgileri = (List<BankaPOSBilgileri>) HibernateManager
.getInstance().get(BankaPOSBilgileri.class, false);
bankaPanelDoldur(posBilgileri, null, true);
}
@SuppressWarnings("unchecked")
private void bankaPanelDoldur(List<?> pojoData, BankaPOSBilgileri pb,
boolean isBanka) {
setSize(730, 400);
jLabelBankaSeciniz.setText("BANKA SEÇİNİZ");
jPanelPosBilgileri.removeAll();
maxLength = 3;
initx = 5;
inity = 5;
buttonCount = 0;
loopTime = 0;
if (isBanka == true) {
List<BankaPOSBilgileri> posBilgileri = (List<BankaPOSBilgileri>) pojoData;
if (posBilgileri.size() == 0) {
AutoClosingMessageDialog.showAutoClosingMessageDialog(
"POS Bilgisi bulunmamaktadır !", 2);
if (frameState == 1) {
jTextFieldKrediKartTutar.setEnabled(false);
jLabelBankaSeciniz.setVisible(false);
}
return;
}
for (int i = 0; i < posBilgileri.size(); i++) {
if (buttonCount % maxLength == 0) {
loopTime++;
if (loopTime == 1) {
initx = 5;
} else {
initx = 5;
inity += 67;
}
butonEkle(posBilgileri.get(i).getBankaAd(), true, pb, null,
isBanka);
buttonCount++;
} else {
initx += 148;
butonEkle(posBilgileri.get(i).getBankaAd(), true, pb, null,
isBanka);
buttonCount++;
}
}
if (loopTime == 1) {
panelHeight = 80;
panelWidth = buttonCount * 148 + 15;
} else {
panelHeight = loopTime * 67 + 13;
panelWidth = maxLength * 148 + 15;
}
jPanelPosBilgileri.setBounds(5, 186, panelWidth, panelHeight);
} else {
butonEkle("TEK ÇEKİM", false, pb, null, isBanka);
buttonCount++;
List<BankaPOSVadeBilgileri> posBilgileri = (List<BankaPOSVadeBilgileri>) pojoData;
for (int i = 0; i < posBilgileri.size(); i++) {
if (buttonCount % maxLength == 0) {
loopTime++;
initx = 5;
inity += 67;
String vadeSayisi = String.valueOf(posBilgileri.get(i)
.getVadeSayisi() + " AY");
butonEkle(vadeSayisi, false, pb, posBilgileri.get(i),
isBanka);
buttonCount++;
} else {
initx += 148;
String vadeSayisi = String.valueOf(posBilgileri.get(i)
.getVadeSayisi() + " AY");
butonEkle(vadeSayisi, false, pb, posBilgileri.get(i),
isBanka);
buttonCount++;
}
}
if (loopTime == 0) {
panelHeight = 80;
} else {
panelHeight = loopTime * 67 + 80;
}
panelWidth = maxLength * 148 + 15;
geriButtonEkle();
jPanelPosBilgileri.setBounds(5, 186, panelWidth, panelHeight + 60);
}
if (jLabelBankaSeciniz.getHeight() + jPanelPosBilgileri.getHeight()
+ 40 + jPanelToplamTutar.getHeight()
+ jPanelKrediKartTutar.getHeight() >= getHeight() - 40) {
setSize(getWidth(),
jLabelBankaSeciniz.getHeight()
+ jPanelPosBilgileri.getHeight() + 80
+ jPanelToplamTutar.getHeight()
+ jPanelKrediKartTutar.getHeight());
}
}
private void geriButtonEkle() {
JButton jButtonGeri = new JButton("GERİ");
jButtonGeri.setBounds(152, panelHeight, 120, 50);
jButtonGeri.setIcon(PSAUtil
.getImageIconViaRelativePath("picture/geriButonu.png"));
jPanelPosBilgileri.add(jButtonGeri);
jButtonGeri.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
initPosButtons();
jLabelBankaSeciniz.setText("BANKA SEÇİNİZ");
}
});
}
private void butonEkle(final String buttonText,
final boolean isBankaButton, final BankaPOSBilgileri pb,
final BankaPOSVadeBilgileri pvb, boolean isBanka) {
JButton jButtonBanka = new JButton(buttonText);
jButtonBanka.setBounds(initx, inity, 148, 67);
if (isBanka == true) {
jButtonBanka.setIcon(PSAUtil
.getImageIconViaRelativePath("picture/bankaEkle.png"));
} else {
jButtonBanka.setIcon(PSAUtil
.getImageIconViaRelativePath("picture/vade.png"));
}
jButtonBanka.setToolTipText(buttonText);
jButtonBanka.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
if (isBankaButton == true) {
bankaButtonClicked(buttonText);
} else {
vadeButtonClicked(pb, pvb);
}
}
});
jPanelPosBilgileri.add(jButtonBanka);
}
protected void vadeButtonClicked(BankaPOSBilgileri pb,
BankaPOSVadeBilgileri pvb) {
posBilgi = pb;
posVadeBilgileri = pvb;
jPanelPosBilgileri.setVisible(false);
jLabelSecilenBankaBilgisi.setText(pb.getBankaAd());
if (pvb == null) {
jLabelPosVadeBilgisi.setText("TEK ÇEKİM");
} else {
jLabelPosVadeBilgisi.setText(String.valueOf(pvb.getVadeSayisi()));
}
jPanelPosBilgisiSon.setVisible(true);
jLabelBankaSeciniz.setText("ÖDEME ŞEKLİ SEÇİLMİŞTİR");
}
protected void bankaButtonClicked(String bankaAd) {
BankaPOSBilgileri ps = (BankaPOSBilgileri) HibernateManager
.getInstance().getObjectWithUniqueColumn(
BankaPOSBilgileri.class, "bankaAd", bankaAd, false);
jPanelPosBilgileri.removeAll();
List<?> posVadeBilgileri = HibernateManager.getInstance()
.getEntitysList(ps, "bankaPosVadeBilgileri");
bankaPanelDoldur(posVadeBilgileri, ps, false);
jLabelBankaSeciniz.setText(bankaAd + " İÇİN ÖDEME ŞEKLİ SEÇİNİZ");
}
protected void anaEkranSetEnable() {
if (frameState == 0) {
PSAAnaEkran.getInstance(null).setEnabled(true);
instance.dispose();
} else {
PSAIadeEkrani.tabloDoldur();
PSAIadeEkrani.getInstance(1).setEnabled(true);
instance.dispose();
}
}
private void initListeners() {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
anaEkranSetEnable();
}
});
jButtonİptal.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
anaEkranSetEnable();
}
});
jTextFieldKrediKartTutar.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent arg0) {
try {
if (jTextFieldKrediKartTutar.getText().trim().equals(""))
return;
robot = new Robot();
if (PriceControl.validate(jTextFieldKrediKartTutar
.getText())) {
if (Math.abs(satisFiyati) >= Double
.parseDouble(jTextFieldKrediKartTutar.getText())) {
double nakitTutar = satisFiyati
- Double.parseDouble(jTextFieldKrediKartTutar
.getText());
String[] nakitTutartoString = decimalControl(String
.valueOf(nakitTutar));
String nakit;
if (nakitTutartoString[1].length() > 1) {
nakit = nakitTutartoString[0] + "."
+ nakitTutartoString[1].substring(0, 2);
} else {
nakit = nakitTutartoString[0] + "."
+ nakitTutartoString[1].substring(0, 1)
+ "0";
;
}
jTextFieldNakitTutar.setText(nakit);
} else {
robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
}
} else {
robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
}
} catch (AWTException e) {
e.printStackTrace();
}
}
});
jTextFieldKrediKartTutar.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
if (jTextFieldKrediKartTutar.getText().length() == 1) {
jTextFieldNakitTutar.setText("");
}
}
}
});
jTextFieldNakitTutar.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent arg0) {
try {
if (jTextFieldNakitTutar.getText().trim().equals(""))
return;
robot = new Robot();
if (PriceControl.validate(jTextFieldNakitTutar.getText())) {
if (Math.abs(satisFiyati) >= Double
.parseDouble(jTextFieldNakitTutar.getText())) {
double krediTutar = satisFiyati
- Double.parseDouble(jTextFieldNakitTutar
.getText());
String[] krediTutartoString = decimalControl(String
.valueOf(krediTutar));
String kredi;
if (krediTutartoString[1].length() > 1) {
kredi = krediTutartoString[0] + "."
+ krediTutartoString[1].substring(0, 2);
} else {
kredi = krediTutartoString[0] + "."
+ krediTutartoString[1].substring(0, 1)
+ "0";
}
jTextFieldKrediKartTutar.setText(kredi);
} else {
robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
}
} else {
robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
}
} catch (AWTException e) {
e.printStackTrace();
}
}
});
jTextFieldNakitTutar.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
if (jTextFieldNakitTutar.getText().length() == 1) {
jTextFieldKrediKartTutar.setText("");
}
}
}
});
jButtonOdemeKaydet.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
islemTamamlaClicked();
}
});
JButtonBankaSecGeri.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
jPanelPosBilgisiSon.setVisible(false);
jPanelPosBilgileri.setVisible(true);
initPosButtons();
}
});
}
protected void islemTamamlaClicked() {
if (frameState == 0) {
anaEkranSatis();
}
}
private void anaEkranSatis() {
if (jTextFieldKrediKartTutar.getText().trim().equals("")
|| Double
.parseDouble(jTextFieldKrediKartTutar.getText().trim()) == 0) {
AutoClosingMessageDialog.showAutoClosingMessageDialog(
"Kredi kart tutarı giriniz !", 2);
return;
}
if (jTextFieldNakitTutar.getText().trim().equals("")
|| Double.parseDouble(jTextFieldNakitTutar.getText().trim()) == 0) {
AutoClosingMessageDialog.showAutoClosingMessageDialog(
"Nakit tutarı giriniz !", 2);
return;
}
if (posBilgi == null) {
AutoClosingMessageDialog.showAutoClosingMessageDialog(
"Banka bilgisi seçiniz !", 2);
return;
}
YapilanSatisPOSVadeBilgileri yspvb = null;
YapilanSatisPOSBilgileri yspb;
if (posVadeBilgileri != null) {
yspvb = new YapilanSatisPOSVadeBilgileri(posVadeBilgileri);
HibernateManager.getInstance().save(yspvb);
yspb = new YapilanSatisPOSBilgileri(posBilgi, yspvb);
HibernateManager.getInstance().save(yspb);
} else {
yspb = new YapilanSatisPOSBilgileri(posBilgi, yspvb);
HibernateManager.getInstance().save(yspb);
}
odemeBilgisi = new OdemeBilgileri();
odemeBilgisi.setSystemName(HibernateManager.getInstance()
.getSystemName());
odemeBilgisi.setKrediKartTutar(Double
.parseDouble(jTextFieldKrediKartTutar.getText()));
odemeBilgisi.setNakitTutar(Double.parseDouble(jTextFieldNakitTutar
.getText()));
odemeBilgisi.setPosBilgisiId(yspb.getId());
if (posVadeBilgileri != null) {
odemeBilgisi.setPosVadeBilgisiId(yspvb.getId());
}
boolean check1 = HibernateManager.getInstance().save(satisBilgi);
if (check1) {
for (int i = 0; i < urunListesi.size(); i++) {
urunSatis = urunListesi.get(i);
urunSatis.setSatisId(satisBilgi.getId());
urunSatis.setTarih(satisBilgi.getTarih());
urunSatis.setYapilanSatis(true);
satilanUrunListesi.add(urunSatis);
HibernateManager.getInstance().save(urunSatis);
}
satisBilgi.setOdemeBilgisi(odemeBilgisi);
satisBilgi.setSatisListesi(satilanUrunListesi);
boolean check = HibernateManager.getInstance().update(satisBilgi);
if (check) {
if (check) {
AutoClosingMessageDialog
.showAutoClosingMessageDialog(
"Parçalı ödeme satış işlemi başarı ile tamamlanmıştır.",
2);
PSAAnaEkran.getDefaultValue();
anaEkranSetEnable();
}
}
}
}
private static String[] decimalControl(String valueOf) {
String[] parts = valueOf.split("\\.");
return parts;
}
private void locateFrameToMiddle() {
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
int w = this.getSize().width;
int h = this.getSize().height;
int x = (dim.width - w) / 2;
int y = (dim.height - h) / 2;
setLocation(x, y);
}
}