Package gui

Source Code of gui.PSAMusteriGuncellemeEkrani

package gui;

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

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
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 javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.text.MaskFormatter;

import pojos.BireyselMusteri;
import pojos.KurumsalMusteri;
import pojos.Musteri;
import service.AutoClosingMessageDialog;
import service.PSAUtil;

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

import control.MailRegex;

public class PSAMusteriGuncellemeEkrani extends JFrame {

  private static final long serialVersionUID = 1L;
  private static PSAMusteriGuncellemeEkrani instance;
  private JPanel cPanelPersonel;
  private JPanel cPanelPersonelEkleme;
  private CTextField cTextFieldAd;
  private CTextField cTextFieldSoyad;
  private CTextField cTextFieldTelNo;
  private JButton JButtonMusteriGuncelle;
  private JButton JButtonMusteriGeri;
  private CTextArea cTextAreaAdres;
  private JLabel cLabelPersonelAd;
  private JLabel cLabelMusteriGuncelleme;
  private JLabel cLabelPersonelSoyad;
  private JLabel cLabelPersonelTelNo;
  private JLabel cLabelPersonelAdres;
  private JLabel cLabelMusteriBTarih;
  private JLabel cLabelPersonelIcon;
  private JLabel jLabelTCNo;
  private CTextField cTextFieldTCNo;
  private JScrollPane cScrollPanePersonelAdres;
  private JDateChooser jDateChooserMusteriTarih;
  private JLabel jLabelMusteriEmail;
  private CTextField cTextFieldEmail;
  private ButtonGroup buttonGroup;
  private JRadioButton jRadioButtonBireysel;
  private JRadioButton jRadioButtonKurumsal;
  private JLabel jLabelFaksNo;
  private CTextField cTextFieldFaksNo;
  private JLabel jLabelVergiDairesi;
  private CTextField cTextFieldVergiDairesi;
  private CTextField cTextFieldVergiNo;
  private JLabel jLabelVergiNo;
  private JLabel jLabelFirmaAd;
  private CTextField cTextFieldFirmaAd;
  private Musteri musteriSecilen;
  private BireyselMusteri bm;
  private KurumsalMusteri km;

  private static final String E_MAIL = "info@altisoft.com.tr";
  private static String musteriTuru;
  private final String B_MUSTERI = "bireysel";
  private final String K_MUSTERI = "kurumsal";
  private static final String KONTROL = "-";
  private static final String NO_CONTROL = "(___) ___ __ __";

  public PSAMusteriGuncellemeEkrani(Musteri musteri, String musTuru) {
    musteriSecilen = musteri;
    musteriTuru = musTuru;
    initialize();
  }

  public static PSAMusteriGuncellemeEkrani getInstance(Musteri musteri,
      String musTuru) {
    instance = new PSAMusteriGuncellemeEkrani(musteri, musTuru);
    return instance;
  }

  private void initialize() {
    setTitle("PSA MERKEZ MÜŞTERİ GÜNCELLEME EKRANI");
    setBounds(0, 0, 510, 743);
    setResizable(false);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setIconImage(PSAUtil.getImageIconViaRelativePath("picture/psaIcon.png")
        .getImage());

    cPanelPersonel = new JPanel();
    cPanelPersonelEkleme = new JPanel();
    cPanelPersonelEkleme.setBackground(UIManager.getColor("Button.shadow"));

    cTextFieldAd = new CTextField(20);
    cTextFieldAd.setEnabled(false);
    cTextFieldAd.setBounds(226, 171, 186, 20);

    cTextFieldSoyad = new CTextField(20);
    cTextFieldSoyad.setEnabled(false);
    cTextFieldSoyad.setBounds(226, 199, 186, 20);

    JButtonMusteriGuncelle = new JButton();
    JButtonMusteriGuncelle.setBounds(89, 554, 323, 40);
    JButtonMusteriGuncelle.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/kullaniciEkle.png"));
    JButtonMusteriGuncelle.setText("MÜŞTERİ BİLGİSİ GÜNCELLE");
    JButtonMusteriGuncelle.setFont(new Font("Tahoma", Font.BOLD, 15));

    MaskFormatter mf = null;
    try {
      mf = new MaskFormatter("(###) ### ## ##");
      mf.setPlaceholderCharacter('_');
    } catch (ParseException e) {
      e.printStackTrace();
    }

    cTextFieldTelNo = new CTextField(mf);
    cTextFieldTelNo.setBounds(226, 258, 186, 20);
    cTextFieldTelNo.setAsNumberTextField();

    cLabelMusteriGuncelleme = new JLabel();
    cLabelMusteriGuncelleme.setFont(new Font("Tahoma", Font.BOLD, 16));
    cLabelMusteriGuncelleme.setText("MÜŞTERİ GÜNCELLEME");

    cLabelPersonelAd = new JLabel();
    cLabelPersonelAd.setBounds(89, 171, 127, 20);
    cLabelPersonelAd.setFont(new Font("Tahoma", Font.BOLD, 14));
    cLabelPersonelAd.setText("*Ad\u0131");

    cLabelPersonelSoyad = new JLabel();
    cLabelPersonelSoyad.setBounds(89, 199, 127, 20);
    cLabelPersonelSoyad.setText("*Soyad\u0131");
    cLabelPersonelSoyad.setFont(new Font("Tahoma", Font.BOLD, 14));

    cLabelPersonelTelNo = new JLabel();
    cLabelPersonelTelNo.setBounds(89, 258, 127, 20);
    cLabelPersonelTelNo.setText("Tel No.");
    cLabelPersonelTelNo.setFont(new Font("Tahoma", Font.BOLD, 14));

    cLabelPersonelAdres = new JLabel();
    cLabelPersonelAdres.setBounds(89, 349, 127, 20);
    cLabelPersonelAdres.setText("Adresi");
    cLabelPersonelAdres.setFont(new Font("Tahoma", Font.BOLD, 14));

    cLabelMusteriBTarih = new JLabel();
    cLabelMusteriBTarih.setBounds(89, 504, 127, 20);
    cLabelMusteriBTarih.setText("Ba\u015Flama Tarihi");
    cLabelMusteriBTarih.setFont(new Font("Tahoma", Font.BOLD, 14));

    cLabelPersonelIcon = new JLabel();
    cLabelPersonelIcon.setBounds(194, 11, 96, 116);
    cLabelPersonelIcon.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/personelIcon.png"));

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

    cScrollPanePersonelAdres = new JScrollPane();
    cScrollPanePersonelAdres.setBounds(226, 349, 186, 51);

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

    jDateChooserMusteriTarih = new JDateChooser();
    jDateChooserMusteriTarih.setBounds(226, 504, 186, 20);
    jDateChooserMusteriTarih.setDate(new Date());
    ((JTextFieldDateEditor) jDateChooserMusteriTarih.getDateEditor())
        .setEditable(false);

    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(
        Alignment.LEADING).addGroup(
        groupLayout
            .createSequentialGroup()
            .addContainerGap()
            .addComponent(cPanelPersonel, GroupLayout.DEFAULT_SIZE,
                485, Short.MAX_VALUE).addGap(9)));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(
        Alignment.LEADING).addGroup(
        groupLayout
            .createSequentialGroup()
            .addContainerGap()
            .addComponent(cPanelPersonel,
                GroupLayout.PREFERRED_SIZE, 662,
                Short.MAX_VALUE).addContainerGap()));
    GroupLayout gl_cPanelPersonel = new GroupLayout(cPanelPersonel);
    gl_cPanelPersonel.setHorizontalGroup(gl_cPanelPersonel
        .createParallelGroup(Alignment.LEADING)
        .addGroup(
            gl_cPanelPersonel
                .createSequentialGroup()
                .addComponent(cLabelMusteriGuncelleme,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE).addGap(315))
        .addGroup(
            gl_cPanelPersonel
                .createSequentialGroup()
                .addComponent(cPanelPersonelEkleme,
                    GroupLayout.PREFERRED_SIZE, 484,
                    GroupLayout.PREFERRED_SIZE)
                .addContainerGap(21, Short.MAX_VALUE)));
    gl_cPanelPersonel.setVerticalGroup(gl_cPanelPersonel
        .createParallelGroup(Alignment.LEADING).addGroup(
            gl_cPanelPersonel
                .createSequentialGroup()
                .addComponent(cLabelMusteriGuncelleme,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(cPanelPersonelEkleme,
                    GroupLayout.PREFERRED_SIZE, 667,
                    GroupLayout.PREFERRED_SIZE)));

    cPanelPersonelEkleme.setLayout(null);
    cPanelPersonelEkleme.add(cLabelPersonelIcon);
    cPanelPersonelEkleme.add(cLabelPersonelAd);
    cPanelPersonelEkleme.add(cTextFieldAd);
    cPanelPersonelEkleme.add(cLabelPersonelSoyad);
    cPanelPersonelEkleme.add(cTextFieldSoyad);
    cPanelPersonelEkleme.add(cLabelPersonelTelNo);
    cPanelPersonelEkleme.add(cTextFieldTelNo);
    cPanelPersonelEkleme.add(cLabelMusteriBTarih);
    cPanelPersonelEkleme.add(jDateChooserMusteriTarih);
    cPanelPersonelEkleme.add(JButtonMusteriGuncelle);
    cPanelPersonelEkleme.add(JButtonMusteriGeri);
    cPanelPersonelEkleme.add(cLabelPersonelAdres);
    cPanelPersonelEkleme.add(cScrollPanePersonelAdres);

    jLabelMusteriEmail = new JLabel();
    jLabelMusteriEmail.setText("E-posta");
    jLabelMusteriEmail.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelMusteriEmail.setBounds(89, 318, 127, 20);
    cPanelPersonelEkleme.add(jLabelMusteriEmail);

    cTextFieldEmail = new CTextField(20);
    cTextFieldEmail.setHint(E_MAIL);
    cTextFieldEmail.setBounds(226, 318, 186, 20);
    cPanelPersonelEkleme.add(cTextFieldEmail);

    buttonGroup = new ButtonGroup();

    jRadioButtonBireysel = new JRadioButton("BİREYSEL MÜŞTERİ");
    jRadioButtonBireysel.setEnabled(false);
    jRadioButtonBireysel.setBounds(59, 134, 170, 20);
    cPanelPersonelEkleme.add(jRadioButtonBireysel);

    jRadioButtonKurumsal = new JRadioButton("KURUMSAL MÜŞTERİ");
    jRadioButtonKurumsal.setEnabled(false);
    jRadioButtonKurumsal.setBounds(255, 134, 173, 20);
    cPanelPersonelEkleme.add(jRadioButtonKurumsal);

    jRadioButtonBireysel.setActionCommand(B_MUSTERI);
    jRadioButtonKurumsal.setActionCommand(K_MUSTERI);

    buttonGroup.add(jRadioButtonBireysel);
    buttonGroup.add(jRadioButtonKurumsal);

    jLabelFaksNo = new JLabel();
    jLabelFaksNo.setText("Faks No.");
    jLabelFaksNo.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelFaksNo.setBounds(89, 287, 127, 20);
    cPanelPersonelEkleme.add(jLabelFaksNo);

    cTextFieldFaksNo = new CTextField(mf);
    cTextFieldFaksNo.setEnabled(false);
    cTextFieldFaksNo.setBounds(226, 287, 186, 20);
    cTextFieldFaksNo.setAsNumberTextField();
    cPanelPersonelEkleme.add(cTextFieldFaksNo);

    jLabelVergiDairesi = new JLabel();
    jLabelVergiDairesi.setText("Vergi Dairesi");
    jLabelVergiDairesi.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelVergiDairesi.setBounds(89, 411, 127, 20);
    cPanelPersonelEkleme.add(jLabelVergiDairesi);

    cTextFieldVergiDairesi = new CTextField(10);
    cTextFieldVergiDairesi.setEnabled(false);
    cTextFieldVergiDairesi.setBounds(226, 411, 186, 20);
    cPanelPersonelEkleme.add(cTextFieldVergiDairesi);

    cTextFieldVergiNo = new CTextField(20);
    cTextFieldVergiNo.setEnabled(false);
    cTextFieldVergiNo.setBounds(226, 473, 186, 20);
    cTextFieldVergiNo.setAsOnlyNumberTextField();
    cPanelPersonelEkleme.add(cTextFieldVergiNo);

    jLabelVergiNo = new JLabel();
    jLabelVergiNo.setText("Vergi No.");
    jLabelVergiNo.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelVergiNo.setBounds(89, 473, 127, 20);
    cPanelPersonelEkleme.add(jLabelVergiNo);

    jLabelFirmaAd = new JLabel();
    jLabelFirmaAd.setText("*Firma Adı");
    jLabelFirmaAd.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelFirmaAd.setBounds(89, 227, 127, 20);
    cPanelPersonelEkleme.add(jLabelFirmaAd);

    cTextFieldFirmaAd = new CTextField(20);
    cTextFieldFirmaAd.setEnabled(false);
    cTextFieldFirmaAd.setBounds(226, 227, 186, 20);
    cPanelPersonelEkleme.add(cTextFieldFirmaAd);

    jLabelTCNo = new JLabel();
    jLabelTCNo.setText("TC No.");
    jLabelTCNo.setFont(new Font("Tahoma", Font.BOLD, 14));
    jLabelTCNo.setBounds(89, 442, 127, 20);
    cPanelPersonelEkleme.add(jLabelTCNo);

    cTextFieldTCNo = new CTextField(11);
    cTextFieldTCNo.setAsOnlyNumberTextField();
    cTextFieldTCNo.setBounds(226, 442, 186, 20);
    cPanelPersonelEkleme.add(cTextFieldTCNo);

    cPanelPersonel.setLayout(gl_cPanelPersonel);
    getContentPane().setLayout(groupLayout);

    initListeners();
    fillMusteriInfo();
  }

  private void fillMusteriInfo() {
    if (musteriTuru.equals(B_MUSTERI)) {
      bm = (BireyselMusteri) musteriSecilen;
      jRadioButtonBireysel.setEnabled(true);
      jRadioButtonBireysel.doClick();
      cTextFieldAd.setText(bm.getAd());
      cTextFieldSoyad.setText(bm.getSoyad());
      if (!bm.getTelNo().equals(KONTROL)) {
        cTextFieldTelNo.setValue(bm.getTelNo());
      }
      if (!bm.getMail().equals(KONTROL)) {
        cTextFieldEmail.setText(bm.getMail());
      } else {
        cTextFieldEmail.setText("");
      }
      if (!bm.getTcNo().equals(KONTROL)) {
        cTextFieldTCNo.setText(bm.getTcNo());
      } else {
        cTextFieldTCNo.setText("");
      }
      cTextAreaAdres.setText(bm.getAdres());
    } else if (musteriTuru.equals(K_MUSTERI)) {
      km = (KurumsalMusteri) musteriSecilen;
      jRadioButtonKurumsal.setEnabled(true);
      jRadioButtonKurumsal.doClick();
      cTextFieldFirmaAd.setText(km.getFirmaUnvani());
      if (!km.getTelNo().equals(KONTROL)) {
        cTextFieldTelNo.setValue(km.getTelNo());
      }
      if (!km.getFaksNo().equals(KONTROL)) {
        cTextFieldFaksNo.setValue(km.getFaksNo());
      }
      if (!km.getMail().equals(KONTROL)) {
        cTextFieldEmail.setText(km.getMail());
      } else {
        cTextFieldEmail.setText("");
      }
      if (!km.getTcNo().equals(KONTROL)) {
        cTextFieldTCNo.setText(km.getTcNo());
      } else {
        cTextFieldTCNo.setText("");
      }
      cTextAreaAdres.setText(km.getAdres());
      cTextFieldVergiDairesi.setText(km.getVergiDairesi());
      cTextFieldVergiNo.setText(km.getVergiTCNO());
    }

  }

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

    jRadioButtonBireysel.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent e) {
        bireyselRadioButtonClicked();
      }
    });

    jRadioButtonKurumsal.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent arg0) {
        kurumsalRadioButtonClicked();
      }
    });

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

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

    cTextAreaAdres.addFocusListener(new FocusAdapter() {
      @Override
      public void focusGained(FocusEvent arg0) {
        if (cTextAreaAdres.getText().equals(KONTROL)) {
          cTextAreaAdres.setText("");
        }
      }

      @Override
      public void focusLost(FocusEvent e) {
        if (musteriSecilen.getAdres().equals(KONTROL)) {
          if (cTextAreaAdres.getText().equals("")) {
            cTextAreaAdres.setText(KONTROL);
          }
        }
      }
    });

    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);
          }
        }
      }
    });
  }

  protected void musteriGuncelleClicked() {
    Object bMusteriTelNo = cTextFieldTelNo.getValue();
    String bMusteriMail = cTextFieldEmail.getText().trim();
    String bMusteriAdres = cTextAreaAdres.getText().trim();
    String bMusteriTCNo = cTextFieldTCNo.getText().trim();

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

    if (musteriTuru.equals(B_MUSTERI)) {
      if (!bireyselMusteriControl()) {
        AutoClosingMessageDialog
            .showAutoClosingMessageDialog(
                "Bireysel müşteri ile ilgili güncellenecek bilgi bulunmaktadır.",
                2);
        return;
      }
      if (bMusteriTelNo != null) {
        bm.setTelNo(bMusteriTelNo.toString());
      } else {
        bm.setTelNo("-");
      }
      if (bMusteriMail.length() > 0) {
        bm.setMail(bMusteriMail);
      } else {
        bm.setMail("-");
      }
      if (bMusteriAdres.length() > 0) {
        bm.setAdres(bMusteriAdres);
      } else {
        bm.setAdres("-");
      }
      if (bMusteriTCNo.length() > 0) {
        bm.setTcNo(bMusteriTCNo);
      } else {
        bm.setTcNo("-");
      }
      bm.setBaslamaTarihi(jDateChooserMusteriTarih.getDate());
      boolean check = HibernateManager.getInstance().update(bm);
      if (check)
        AutoClosingMessageDialog
            .showAutoClosingMessageDialog(
                "Bireysel müşteri ile ilgili bilgiler güncellenmiştir.",
                2);
    } else if (musteriTuru.equals(K_MUSTERI)) {
      if (!kurumsalMusteriControl()) {
        AutoClosingMessageDialog
            .showAutoClosingMessageDialog(
                "Kurumsal müşteri ile ilgili güncellenecek bilgi bulunmaktadır.",
                2);
        return;
      }
      Object kMusteriFaksNo = cTextFieldFaksNo.getValue();
      String kurumsalVergiDairesi = cTextFieldVergiDairesi.getText()
          .trim();
      String kurumsalVergiNo = cTextFieldVergiNo.getText().trim();

      if (bMusteriTelNo != null) {
        km.setTelNo(bMusteriTelNo.toString());
      } else {
        km.setTelNo("-");
      }
      if (kMusteriFaksNo != null) {
        km.setFaksNo(kMusteriFaksNo.toString());
      } else {
        km.setFaksNo("-");
      }
      if (bMusteriMail.length() > 0) {
        km.setMail(bMusteriMail);
      } else {
        km.setMail("-");
      }
      if (bMusteriAdres.length() > 0) {
        km.setAdres(bMusteriAdres);
      } else {
        km.setAdres("-");
      }
      if (bMusteriAdres.length() > 0) {
        km.setAdres(bMusteriAdres);
      } else {
        km.setAdres("-");
      }
      if (kurumsalVergiDairesi.length() > 0) {
        km.setVergiDairesi(kurumsalVergiDairesi);
      } else {
        km.setVergiDairesi("-");
      }
      if (kurumsalVergiNo.length() > 0) {
        km.setVergiTCNO(kurumsalVergiNo);
      } else {
        km.setVergiTCNO("-");
      }
      if (bMusteriTCNo.length() > 0) {
        km.setTcNo(bMusteriTCNo);
      } else {
        km.setTcNo("-");
      }
      km.setBaslamaTarihi(jDateChooserMusteriTarih.getDate());
      boolean check = HibernateManager.getInstance().update(km);
      if (check)
        AutoClosingMessageDialog
            .showAutoClosingMessageDialog(
                "Kurumsal müşteri ile ilgili bilgiler güncellenmiştir.",
                2);
    }
  }

  private boolean kurumsalMusteriControl() {
    String musteriMail = cTextFieldEmail.getText().trim();
    if (musteriMail.length() > 0 && !MailRegex.validate(musteriMail)) {
      AutoClosingMessageDialog.showAutoClosingMessageDialog(
          "E-posta adresinin doğruluğunu kontrol ediniz.", 2);
      return false;
    }

    String kMail = null;
    if (cTextFieldEmail.getText().equals("")) {
      kMail = "-";
    } else {
      kMail = cTextFieldEmail.getText();
    }
    String kTCNo = null;
    if (cTextFieldTCNo.getText().equals("")) {
      kTCNo = "-";
    } else {
      kTCNo = cTextFieldTCNo.getText();
    }

    Object telNo = cTextFieldTelNo.getValue();
    Object faksNo = cTextFieldFaksNo.getValue();
    if (telNo == null) {
      telNo = "-";
    }
    if (faksNo == null) {
      faksNo = "-";
    }
    if (km.getFirmaUnvani().equals(cTextFieldFirmaAd.getText())
        && km.getFaksNo().equals(String.valueOf(faksNo))
        && km.getTelNo().equals(String.valueOf(telNo))
        && km.getMail().equals(kMail)
        && km.getTcNo().equals(kTCNo)
        && km.getAdres().equals(cTextAreaAdres.getText())
        && km.getVergiDairesi()
            .equals(cTextFieldVergiDairesi.getText())
        && km.getVergiTCNO().equals(cTextFieldVergiNo.getText())) {
      return false;
    }
    return true;
  }

  private boolean bireyselMusteriControl() {
    String musteriMail = cTextFieldEmail.getText().trim();
    if (musteriMail.length() > 0 && !MailRegex.validate(musteriMail)) {
      AutoClosingMessageDialog.showAutoClosingMessageDialog(
          "E-posta adresinin doğruluğunu kontrol ediniz.", 2);
      return false;
    }
    String mMail = null;
    if (cTextFieldEmail.getText().equals("")) {
      mMail = "-";
    } else {
      mMail = cTextFieldEmail.getText();
    }
    String mTCNo = null;
    if (cTextFieldTCNo.getText().equals("")) {
      mTCNo = "-";
    } else {
      mTCNo = cTextFieldTCNo.getText();
    }

    Object telNo = cTextFieldTelNo.getValue();
    if (telNo == null) {
      telNo = "-";
    }

    if (bm.getAd().equals(cTextFieldAd.getText())
        && bm.getSoyad().equals(cTextFieldSoyad.getText())
        && bm.getTelNo().equals(String.valueOf(telNo))
        && bm.getMail().equals(mMail) && bm.getTcNo().equals(mTCNo)
        && bm.getAdres().equals(cTextAreaAdres.getText())) {
      return false;
    }
    return true;
  }

  protected void geriButtonClicked() {
    PSAMusteriEkrani.getInstance(1).setEnabled(true);
    instance.dispose();
  }

  protected void kurumsalRadioButtonClicked() {
    ekleButtonProperties(K_MUSTERI);
    cLabelPersonelAd.setEnabled(false);
    cLabelPersonelSoyad.setEnabled(false);
    jLabelFirmaAd.setEnabled(true);
    jLabelFaksNo.setEnabled(true);
    cTextFieldFaksNo.setEnabled(true);
    jLabelVergiDairesi.setEnabled(true);
    cTextFieldVergiDairesi.setEnabled(true);
    jLabelVergiNo.setEnabled(true);
    cTextFieldVergiNo.setEnabled(true);
    cTextFieldFirmaAd.requestFocus();
  }

  protected void bireyselRadioButtonClicked() {
    ekleButtonProperties(B_MUSTERI);
    cLabelPersonelAd.setEnabled(true);
    cLabelPersonelSoyad.setEnabled(true);
    jLabelFirmaAd.setEnabled(false);
    jLabelFaksNo.setEnabled(false);
    cTextFieldFaksNo.setEnabled(false);
    jLabelVergiDairesi.setEnabled(false);
    cTextFieldVergiDairesi.setEnabled(false);
    jLabelVergiNo.setEnabled(false);
    cTextFieldVergiNo.setEnabled(false);
    cTextFieldAd.requestFocus();
  }

  private void ekleButtonProperties(String mt) {
    if (mt.equals(B_MUSTERI)) {
      cLabelPersonelIcon.setIcon(PSAUtil
          .getImageIconViaRelativePath("picture/personelIcon.png"));
      JButtonMusteriGuncelle.setIcon(PSAUtil
          .getImageIconViaRelativePath("picture/kullaniciEkle.png"));
    } else if (mt.equals(K_MUSTERI)) {
      cLabelPersonelIcon.setIcon(PSAUtil
          .getImageIconViaRelativePath("picture/firmaBilgileri.png"));
      JButtonMusteriGuncelle.setIcon(PSAUtil
          .getImageIconViaRelativePath("picture/ekle.png"));
    }
    JButtonMusteriGuncelle.setText("MÜŞTERİ BİLGİSİ GÜNCELLE");
  }
}
TOP

Related Classes of gui.PSAMusteriGuncellemeEkrani

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.