Package cari.gui

Source Code of cari.gui.PSAMusteriEklemeEkrani

package cari.gui;

import hibernateSwingApi.component.CComboBox;
import hibernateSwingApi.component.CTable;
import hibernateSwingApi.component.CTextArea;
import hibernateSwingApi.component.CTextField;
import hibernateSwingApi.hibernate.HibernateManager;
import hibernateSwingApi.utils.Utils;

import java.awt.Color;
import java.awt.Font;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.ParseException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;
import javax.swing.text.MaskFormatter;

import service.AutoClosingMessageDialog;
import service.PSAUtil;
import cari.pojos.Musteri;
import cari.pojos.MusteriBankaBilgileri;

import com.toedter.calendar.JDateChooser;
import com.toedter.calendar.JTextFieldDateEditor;

import control.MailRegex;
import control.MusteriCodeGenerator;

public class PSAMusteriEklemeEkrani extends JFrame {

  private static final long serialVersionUID = 1L;

  private static PSAMusteriEklemeEkrani instance;
  private JPanel cPanelMusteri;
  private JPanel cPanelMusteriEkleme;
  private CTextField cTextFieldTelNo;
  private JButton JButtonMusteriEkle;
  private JButton JButtonMusteriGeri;
  private CTextArea cTextAreaAdres;
  private JLabel cLabelMusteriEkleme;
  private JLabel jLabelTelNo;
  private JLabel jLabelMusteriAdres;
  private JLabel cLabelMusteriBTarih;
  private JLabel cLabelPersonelIcon;
  private JScrollPane cScrollPaneMusteriAdres;
  private JDateChooser jDateChooserMusteriTarih;
  private JButton JButtonTemizle;
  private JLabel jLabelMusteriEmail;
  private CTextField cTextFieldEmail;
  private JLabel jLabelFaksNo;
  private CTextField cTextFieldFaksNo;
  private JLabel jLabelVergiDairesi;
  private CTextField cTextFieldVergiDairesi;
  private CTextField cTextFieldVergiNo;
  private JLabel jLabelVergiNo;
  private CTextField cTextFieldTCNo;
  private JLabel jLabelTCNo;
  private JPanel cPanelMusteriBilgi;
  private JLabel jLabelMusteriBilgileri;
  private JLabel jLabelMusteriKod;
  private JLabel jLabelFaturaUnvan;
  private CTextField cTextFieldFaturaUnvan;
  private CTextField cTextFieldMusteriKod;
  private JLabel jLabelMusteriGrup;
  private CComboBox<String> cComboBoxMusteriGrup;
  private JLabel jLabelMusteriUnvan;
  private CTextField cTextFieldMusteriUnvan;
  private CTextField cTextFieldYetkiliKisi;
  private JLabel jLabelYetkiliKisi;
  private JPanel cPanelBankaBilgi;
  private JLabel jLabelBankaBilgileri;
  private JLabel jLabelBankaAd;
  private CTextField cTextFieldBankaAd;
  private CTextField cTextFiedlBankaSubesi;
  private JLabel jLabelBankaSubesi;
  private CTextField cTextFieldHesapSahibi;
  private JLabel jLabelHesapSahibi;
  private JLabel jLabelHesapNo;
  private CTextField cTextFieldHesapNo;
  private JButton jButtonBankaEkle;
  private CTable cTableBankaBilgi;
  private JScrollPane scrollPane;
  private Musteri musteri;
  private int musteriKod;
  private MusteriBankaBilgileri musteriBanka;
  private List<MusteriBankaBilgileri> musteriBankaBilgileriListesi = new LinkedList<>();
  private int frameState;

  private static final String E_MAIL = "info@altisoft.com.tr";
  private static final String NO_CONTROL = "(___) ___ __ __";

  public static PSAMusteriEklemeEkrani getInstance(int state) {
    instance = new PSAMusteriEklemeEkrani(state);
    return instance;
  }

  public PSAMusteriEklemeEkrani(int state) {
    frameState = state;
    initialize();
  }

  private void initialize() {
    setTitle("PSA CARİ EKLEME EKRANI");
    setBounds(0, 0, 1080, 696);
    setResizable(false);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setIconImage(PSAUtil.getImageIconViaRelativePath("picture/psaIcon.png")
        .getImage());

    cPanelMusteri = new JPanel();
    cPanelMusteri.setBounds(10, 11, 1055, 649);
    cPanelMusteriEkleme = new JPanel();
    cPanelMusteriEkleme.setBounds(0, 26, 1054, 622);
    cPanelMusteriEkleme.setBackground(UIManager.getColor("Button.shadow"));
    getContentPane().add(cPanelMusteri);

    JButtonMusteriEkle = new JButton();
    JButtonMusteriEkle.setBounds(192, 559, 416, 40);
    JButtonMusteriEkle.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/kullaniciEkle.png"));
    JButtonMusteriEkle.setText("CARİ EKLE");
    JButtonMusteriEkle.setFont(new Font("Tahoma", Font.BOLD, 15));

    MaskFormatter mf = null;
    try {
      mf = new MaskFormatter("(###) ### ## ##");
      mf.setPlaceholderCharacter('_');
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    JButtonTemizle = new JButton();
    JButtonTemizle.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/temizle.png"));
    JButtonTemizle.setBounds(926, 11, 108, 27);

    JButtonTemizle.setFont(new Font("Tahoma", Font.BOLD, 9));
    JButtonTemizle.setText("TEM\u0130ZLE");

    cLabelMusteriEkleme = new JLabel();
    cLabelMusteriEkleme.setBounds(0, 0, 921, 20);
    cLabelMusteriEkleme.setFont(new Font("Tahoma", Font.BOLD, 16));
    cLabelMusteriEkleme.setText("CARİ EKLEME");

    cLabelPersonelIcon = new JLabel();
    cLabelPersonelIcon.setHorizontalAlignment(SwingConstants.CENTER);
    cLabelPersonelIcon.setBounds(20, 53, 162, 180);
    cLabelPersonelIcon.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/personelIcon.png"));

    JButtonMusteriGeri = new JButton();
    JButtonMusteriGeri.setBounds(618, 559, 416, 40);
    JButtonMusteriGeri.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/geriButonu.png"));
    JButtonMusteriGeri.setText("\u0130PTAL");
    JButtonMusteriGeri.setFont(new Font("Tahoma", Font.BOLD, 15));

    cPanelMusteriEkleme.setLayout(null);
    cPanelMusteriEkleme.add(cLabelPersonelIcon);
    cPanelMusteriEkleme.add(JButtonTemizle);
    cPanelMusteriEkleme.add(JButtonMusteriEkle);
    cPanelMusteriEkleme.add(JButtonMusteriGeri);

    getContentPane().setLayout(null);
    cPanelMusteri.setLayout(null);
    cPanelMusteri.add(cLabelMusteriEkleme);
    cPanelMusteri.add(cPanelMusteriEkleme);

    cPanelMusteriBilgi = new JPanel();
    cPanelMusteriBilgi.setLayout(null);
    cPanelMusteriBilgi.setBorder(new LineBorder(new Color(0, 0, 0), 2));
    cPanelMusteriBilgi.setBackground(SystemColor.controlShadow);
    cPanelMusteriBilgi.setBounds(192, 53, 416, 495);
    cPanelMusteriEkleme.add(cPanelMusteriBilgi);

    jLabelMusteriBilgileri = new JLabel("CARİ BİLGİLERİ");
    jLabelMusteriBilgileri.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelMusteriBilgileri.setBounds(29, 5, 160, 30);
    cPanelMusteriBilgi.add(jLabelMusteriBilgileri);

    jLabelMusteriKod = new JLabel();
    jLabelMusteriKod.setText("Cari Kod");
    jLabelMusteriKod.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelMusteriKod.setBounds(29, 45, 127, 20);
    cPanelMusteriBilgi.add(jLabelMusteriKod);

    jLabelFaturaUnvan = new JLabel();
    jLabelFaturaUnvan.setText("Fatura Ünvanı");
    jLabelFaturaUnvan.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelFaturaUnvan.setBounds(29, 322, 127, 20);
    cPanelMusteriBilgi.add(jLabelFaturaUnvan);

    cTextFieldFaturaUnvan = new CTextField(20);
    cTextFieldFaturaUnvan.setBounds(166, 322, 220, 20);
    cPanelMusteriBilgi.add(cTextFieldFaturaUnvan);

    cTextFieldMusteriKod = new CTextField(20);
    cTextFieldMusteriKod.setEditable(false);
    cTextFieldMusteriKod.setBounds(166, 46, 220, 20);
    cPanelMusteriBilgi.add(cTextFieldMusteriKod);

    jLabelMusteriGrup = new JLabel();
    jLabelMusteriGrup.setText("Grubu");
    jLabelMusteriGrup.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelMusteriGrup.setBounds(29, 76, 127, 20);
    cPanelMusteriBilgi.add(jLabelMusteriGrup);

    cComboBoxMusteriGrup = new CComboBox<String>(String.class);
    cComboBoxMusteriGrup.setModel(new DefaultComboBoxModel<String>(
        new String[] { "MUSTERI", "TOPTANCI" }));
    cComboBoxMusteriGrup.setSelectedIndex(0);
    cComboBoxMusteriGrup.setBounds(166, 76, 220, 20);
    cPanelMusteriBilgi.add(cComboBoxMusteriGrup);

    jLabelMusteriUnvan = new JLabel();
    jLabelMusteriUnvan.setText("Ünvanı");
    jLabelMusteriUnvan.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelMusteriUnvan.setBounds(29, 107, 127, 20);
    cPanelMusteriBilgi.add(jLabelMusteriUnvan);

    cTextFieldMusteriUnvan = new CTextField(20);
    cTextFieldMusteriUnvan.setBounds(166, 107, 220, 20);
    cPanelMusteriBilgi.add(cTextFieldMusteriUnvan);

    cTextFieldYetkiliKisi = new CTextField(20);
    cTextFieldYetkiliKisi.setBounds(166, 138, 220, 20);
    cPanelMusteriBilgi.add(cTextFieldYetkiliKisi);

    jLabelYetkiliKisi = new JLabel();
    jLabelYetkiliKisi.setText("*Yetkili Kişi");
    jLabelYetkiliKisi.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelYetkiliKisi.setBounds(29, 138, 127, 20);
    cPanelMusteriBilgi.add(jLabelYetkiliKisi);

    jLabelMusteriEmail = new JLabel();
    jLabelMusteriEmail.setBounds(29, 229, 127, 20);
    cPanelMusteriBilgi.add(jLabelMusteriEmail);
    jLabelMusteriEmail.setText("E-posta");
    jLabelMusteriEmail.setFont(new Font("Tahoma", Font.BOLD, 14));

    cTextFieldEmail = new CTextField(40);
    cTextFieldEmail.setBounds(166, 229, 220, 20);
    cPanelMusteriBilgi.add(cTextFieldEmail);
    cTextFieldEmail.setHint(E_MAIL);

    cTextFieldFaksNo = new CTextField(mf);
    cTextFieldFaksNo.setAsNumberTextField();
    cTextFieldFaksNo.setBounds(166, 198, 220, 20);
    cPanelMusteriBilgi.add(cTextFieldFaksNo);

    jLabelFaksNo = new JLabel();
    jLabelFaksNo.setBounds(29, 198, 127, 20);
    cPanelMusteriBilgi.add(jLabelFaksNo);
    jLabelFaksNo.setText("Faks No.");
    jLabelFaksNo.setFont(new Font("Tahoma", Font.BOLD, 14));

    jLabelTelNo = new JLabel();
    jLabelTelNo.setBounds(29, 169, 127, 20);
    cPanelMusteriBilgi.add(jLabelTelNo);
    jLabelTelNo.setText("Tel No.");
    jLabelTelNo.setFont(new Font("Tahoma", Font.BOLD, 14));

    cTextFieldTelNo = new CTextField(mf);
    cTextFieldTelNo.setAsNumberTextField();
    cTextFieldTelNo.setBounds(166, 169, 220, 20);
    cPanelMusteriBilgi.add(cTextFieldTelNo);

    jLabelMusteriAdres = new JLabel();
    jLabelMusteriAdres.setBounds(29, 260, 127, 20);
    cPanelMusteriBilgi.add(jLabelMusteriAdres);
    jLabelMusteriAdres.setText("Adresi");
    jLabelMusteriAdres.setFont(new Font("Tahoma", Font.BOLD, 14));

    cScrollPaneMusteriAdres = new JScrollPane();
    cScrollPaneMusteriAdres.setBounds(166, 260, 220, 51);
    cPanelMusteriBilgi.add(cScrollPaneMusteriAdres);

    cTextAreaAdres = new CTextArea(100);
    cTextAreaAdres.setLineWrap(true);
    cScrollPaneMusteriAdres.setViewportView(cTextAreaAdres);

    jLabelTCNo = new JLabel();
    jLabelTCNo.setBounds(29, 353, 127, 20);
    cPanelMusteriBilgi.add(jLabelTCNo);
    jLabelTCNo.setText("TC No.");
    jLabelTCNo.setFont(new Font("Tahoma", Font.BOLD, 14));

    cTextFieldTCNo = new CTextField(11);
    cTextFieldTCNo.setAsOnlyNumberTextField();
    cTextFieldTCNo.setBounds(166, 353, 220, 20);
    cPanelMusteriBilgi.add(cTextFieldTCNo);

    jLabelVergiDairesi = new JLabel();
    jLabelVergiDairesi.setBounds(29, 384, 127, 20);
    cPanelMusteriBilgi.add(jLabelVergiDairesi);
    jLabelVergiDairesi.setText("Vergi Dairesi");
    jLabelVergiDairesi.setFont(new Font("Tahoma", Font.BOLD, 14));

    cTextFieldVergiDairesi = new CTextField(10);
    cTextFieldVergiDairesi.setBounds(166, 384, 220, 20);
    cPanelMusteriBilgi.add(cTextFieldVergiDairesi);

    jLabelVergiNo = new JLabel();
    jLabelVergiNo.setBounds(29, 415, 127, 20);
    cPanelMusteriBilgi.add(jLabelVergiNo);
    jLabelVergiNo.setText("Vergi No.");
    jLabelVergiNo.setFont(new Font("Tahoma", Font.BOLD, 14));

    cTextFieldVergiNo = new CTextField(20);
    cTextFieldVergiNo.setAsOnlyNumberTextField();
    cTextFieldVergiNo.setBounds(166, 415, 220, 20);
    cPanelMusteriBilgi.add(cTextFieldVergiNo);

    cLabelMusteriBTarih = new JLabel();
    cLabelMusteriBTarih.setBounds(29, 446, 127, 20);
    cPanelMusteriBilgi.add(cLabelMusteriBTarih);
    cLabelMusteriBTarih.setText("Ba\u015Flama Tarihi");
    cLabelMusteriBTarih.setFont(new Font("Tahoma", Font.BOLD, 14));

    jDateChooserMusteriTarih = new JDateChooser(new Date());
    jDateChooserMusteriTarih.setBounds(166, 446, 220, 20);
    cPanelMusteriBilgi.add(jDateChooserMusteriTarih);

    ((JTextFieldDateEditor) jDateChooserMusteriTarih.getDateEditor())
        .setEditable(false);

    cPanelBankaBilgi = new JPanel();
    cPanelBankaBilgi.setLayout(null);
    cPanelBankaBilgi.setBorder(new LineBorder(new Color(0, 0, 0), 2));
    cPanelBankaBilgi.setBackground(SystemColor.controlShadow);
    cPanelBankaBilgi.setBounds(618, 53, 416, 495);
    cPanelMusteriEkleme.add(cPanelBankaBilgi);

    jLabelBankaBilgileri = new JLabel("BANKA BİLGİLERİ");
    jLabelBankaBilgileri.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelBankaBilgileri.setBounds(29, 5, 160, 30);
    cPanelBankaBilgi.add(jLabelBankaBilgileri);

    jLabelBankaAd = new JLabel();
    jLabelBankaAd.setText("*Banka Adı");
    jLabelBankaAd.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelBankaAd.setBounds(29, 46, 127, 20);
    cPanelBankaBilgi.add(jLabelBankaAd);

    cTextFieldBankaAd = new CTextField(20);
    cTextFieldBankaAd.setBounds(166, 46, 220, 20);
    cPanelBankaBilgi.add(cTextFieldBankaAd);

    cTextFiedlBankaSubesi = new CTextField(20);
    cTextFiedlBankaSubesi.setBounds(166, 77, 220, 20);
    cPanelBankaBilgi.add(cTextFiedlBankaSubesi);

    jLabelBankaSubesi = new JLabel();
    jLabelBankaSubesi.setText("Şubesi");
    jLabelBankaSubesi.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelBankaSubesi.setBounds(29, 77, 127, 20);
    cPanelBankaBilgi.add(jLabelBankaSubesi);

    cTextFieldHesapSahibi = new CTextField();
    cTextFieldHesapSahibi.setBounds(166, 137, 220, 20);
    cPanelBankaBilgi.add(cTextFieldHesapSahibi);

    jLabelHesapSahibi = new JLabel();
    jLabelHesapSahibi.setText("Hesap Sahibi");
    jLabelHesapSahibi.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelHesapSahibi.setBounds(29, 137, 127, 20);
    cPanelBankaBilgi.add(jLabelHesapSahibi);

    jLabelHesapNo = new JLabel();
    jLabelHesapNo.setText("Hesap No.");
    jLabelHesapNo.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelHesapNo.setBounds(29, 108, 127, 20);
    cPanelBankaBilgi.add(jLabelHesapNo);

    cTextFieldHesapNo = new CTextField();
    cTextFieldHesapNo.setBounds(166, 108, 220, 20);
    cPanelBankaBilgi.add(cTextFieldHesapNo);

    jButtonBankaEkle = new JButton("EKLE");
    jButtonBankaEkle.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/add.png"));
    jButtonBankaEkle.setFont(new Font("Tahoma", Font.BOLD, 13));
    jButtonBankaEkle.setBounds(29, 168, 357, 40);
    cPanelBankaBilgi.add(jButtonBankaEkle);

    scrollPane = new JScrollPane();
    scrollPane.setBounds(29, 236, 357, 248);
    cPanelBankaBilgi.add(scrollPane);

    cTableBankaBilgi = new CTable((String) null,
        MusteriBankaBilgileri.class);
    scrollPane.setViewportView(cTableBankaBilgi);

    getMusteriKod();
    initListeners();
  }

  private void initListeners() {
    addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent e) {
        geriButtonClicked();
      }
    });

    cTextFieldTelNo.addKeyListener(new KeyAdapter() {
      @Override
      public void keyReleased(KeyEvent arg0) {
        if (arg0.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
          if (cTextFieldTelNo.getText().equals(NO_CONTROL)) {
            cTextFieldTelNo.setValue(null);
          }
        }
      }
    });

    cTextFieldFaksNo.addKeyListener(new KeyAdapter() {
      @Override
      public void keyReleased(KeyEvent arg0) {
        if (arg0.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
          if (cTextFieldFaksNo.getText().equals(NO_CONTROL)) {
            cTextFieldFaksNo.setValue(null);
          }
        }
      }
    });

    JButtonMusteriEkle.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        musteriEkleClicked();
      }
    });

    jButtonBankaEkle.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent arg0) {
        bankaEkleClicked();
      }
    });

    JButtonMusteriGeri.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent arg0) {
        geriButtonClicked();
      }
    });

    JButtonTemizle.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        temizleButtonClicked();
      }
    });

    cTableBankaBilgi.addMouseListener(new java.awt.event.MouseAdapter() {
      @Override
      public void mouseClicked(java.awt.event.MouseEvent evt) {
        cTableBankaBilgiListesiSilClicked();
      }
    });
  }

  protected void cTableBankaBilgiListesiSilClicked() {
    int selectedRow = cTableBankaBilgi.getSelectedRow();
    if (cTableBankaBilgi.getModel()
        .getColumnName(cTableBankaBilgi.getSelectedColumn())
        .equals(" ")) {
      musteriBankaBilgileriListesi.remove(selectedRow);
      cTableBankaBilgi.setObjects(musteriBankaBilgileriListesi);
    }
  }

  protected void bankaEkleClicked() {
    String bankaAd = cTextFieldBankaAd.getText().trim();
    String sube = cTextFiedlBankaSubesi.getText().trim();
    String hesapNo = cTextFieldHesapNo.getText().trim();
    String hesapSahibi = cTextFieldHesapSahibi.getText().trim();

    if (bankaAd.equals("")) {
      AutoClosingMessageDialog.showAutoClosingMessageDialog(
          "Banka eklemek için zorunlu bilgileri doldurunuz.(*)", 2);
      return;
    }

    musteriBanka = new MusteriBankaBilgileri();
    musteriBanka.setBankaAd(bankaAd.toUpperCase());
    if (sube.length() > 0)
      musteriBanka.setBankaSubesi(sube.toUpperCase());
    if (hesapNo.length() > 0)
      musteriBanka.setHesapNo(hesapNo.toUpperCase());
    if (hesapSahibi.length() > 0)
      musteriBanka.setHesapSahibi(hesapSahibi.toUpperCase());
    musteriBankaBilgileriListesi.add(musteriBanka);
    cTableBankaBilgi.setObjects(musteriBankaBilgileriListesi);

    clearBankaBilgi();
  }

  private void getMusteriKod() {
    musteriKod = MusteriCodeGenerator.musteriCodeGenerator();
    cTextFieldMusteriKod.setText(String.valueOf(musteriKod));
    if (frameState == 2) {
      cComboBoxMusteriGrup.setEnabled(false);
      cComboBoxMusteriGrup.setSelectedIndex(0);
    }
  }

  protected void musteriEkleClicked() {
    String musteriUnvan = cTextFieldMusteriUnvan.getText().trim();
    String yetkiliKisi = cTextFieldYetkiliKisi.getText().toString();
    Object musteriTelNo = cTextFieldTelNo.getValue();
    Object musteriFaksNo = cTextFieldFaksNo.getValue();
    String musteriMail = cTextFieldEmail.getText().trim();
    String musteriAdres = cTextAreaAdres.getText().trim();
    String faturaUnvan = cTextFieldFaturaUnvan.getText().trim();
    String musteriTCNo = cTextFieldTCNo.getText().trim();
    String vergiDairesi = cTextFieldVergiDairesi.getText().trim();
    String vergiNo = cTextFieldVergiNo.getText().trim();

    if (musteriMail.length() > 0 && !MailRegex.validate(musteriMail)) {
      Utils.showMessage("E-posta adresinin doğruluğunu kontrol ediniz.");
      return;
    }

    if (yetkiliKisi.equals("")) {
      Utils.showMessage("Lütfen zorunlu alanları doldurunuz.(*)");
      return;
    }

    musteri = new Musteri();
    musteri.setMusteriKod(musteriKod);
    musteri.setMusteriGrubu(cComboBoxMusteriGrup.getSelectedItem()
        .toString());
    if (musteriUnvan.length() > 0)
      musteri.setMusteriUnvan(musteriUnvan.toUpperCase());
    if (yetkiliKisi.length() > 0)
      musteri.setYetkiliKisi(yetkiliKisi.toUpperCase());
    if (musteriTelNo != null)
      musteri.setTelNo(musteriTelNo.toString());
    if (musteriFaksNo != null)
      musteri.setFaksNo(musteriFaksNo.toString());
    if (musteriMail.length() > 0)
      musteri.setMail(musteriMail);
    if (musteriAdres.length() > 0)
      musteri.setAdres(musteriAdres);
    if (faturaUnvan.length() > 0)
      musteri.setFaturaUnvan(faturaUnvan.toUpperCase());
    if (musteriTCNo.length() > 0)
      musteri.setTcNo(musteriTCNo);
    if (vergiDairesi.length() > 0)
      musteri.setVergiDairesi(vergiDairesi.toUpperCase());
    if (vergiNo.length() > 0)
      musteri.setVergiNo(vergiNo);
    musteri.setBaslamaTarihi(jDateChooserMusteriTarih.getDate());
    musteri.setMusteriBankaBilgileri(musteriBankaBilgileriListesi);

    boolean check = HibernateManager.getInstance().save(musteri);
    if (check) {
      AutoClosingMessageDialog.showAutoClosingMessageDialog(
          "Müşteri bilgisi sisteme eklenmiştir.", 2);
      geriButtonClicked();
    }
  }

  protected void temizleButtonClicked() {
    cComboBoxMusteriGrup.setSelectedIndex(0);
    cTextFieldMusteriUnvan.setText(null);
    cTextFieldYetkiliKisi.setText(null);
    cTextFieldTelNo.setValue(null);
    cTextFieldFaksNo.setValue(null);
    cTextFieldEmail.setText(null);
    cTextAreaAdres.setText(null);
    cTextFieldFaturaUnvan.setText(null);
    cTextFieldTCNo.setText(null);
    cTextFieldVergiDairesi.setText(null);
    cTextFieldVergiNo.setText(null);

    clearBankaBilgi();
  }

  private void clearBankaBilgi() {
    cTextFieldBankaAd.setText(null);
    cTextFiedlBankaSubesi.setText(null);
    cTextFieldHesapNo.setText(null);
    cTextFieldHesapSahibi.setText(null);
  }

  protected void geriButtonClicked() {
    instance.dispose();
  }
}
TOP

Related Classes of cari.gui.PSAMusteriEklemeEkrani

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.