Package gui

Source Code of gui.PSAKullaniciGuncellemeEkrani

package gui;

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.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

import pojos.Kullanici;
import service.AutoClosingMessageDialog;
import service.PSAUtil;

public class PSAKullaniciGuncellemeEkrani extends JFrame {

  private static final long serialVersionUID = 1L;
  private static PSAKullaniciGuncellemeEkrani instance;
  private JLabel cLabelKullaniciAd;
  private JLabel cLabelKullaniciSifre;
  private JLabel cLabelKullaniciRol;
  private JLabel cLabelKullaniciIzinAciklama;
  private CTextField cTextFieldKullaniciSifre;
  private JLabel cLabelKullanicBilgiAd;
  private JLabel cLabelKullaniciIcon;
  private JLabel cLabelKulaniciGuncelleme;
  private JPanel cPanelKullanici;
  private JPanel cPanelKullaniciGuncelleme;
  private JComboBox<String> jComboBoxKullaniciRol;
  private JButton JButtonKullaniciGuncelle;
  private JButton JButtonKullaniciGeri;
  private JCheckBox cCheckBoxKasa;
  private JCheckBox cCheckBoxPersonelBilgileri;
  private JCheckBox cCheckBoxUrunEkleme;
  private JCheckBox cCheckBoxYoneticiSayfasi;
  private Kullanici kullanici;
  private JLabel jLabelIsaret;
  private JLabel label;
  private JCheckBox cCheckBoxMüsteriBilgileri;
  private JLabel label_1;
  private JCheckBox cCheckBoxEtiket;
  private JLabel label_4;
  private JCheckBox cCheckBoxIstatistik;
  private JLabel label_5;
  private JCheckBox cCheckBoxBankaDzenle;
  private JLabel label_6;
  private JCheckBox cCheckBoxUrunSevkEt;
  private JCheckBox cCheckBoxUrunSevkBilgi;
  private JLabel label_2;
  private JLabel label_7;
  private JCheckBox cCheckBoxFirmaBilgileri;
  private JLabel label_3;
  private JLabel label_8;
  private JCheckBox cCheckBoxKategori;
  private JCheckBox cCheckBoxStokGuncelleme;
  private JLabel label_9;

  public static PSAKullaniciGuncellemeEkrani getInstance(Kullanici kullanici) {
    if (kullanici != null)
      instance = new PSAKullaniciGuncellemeEkrani(kullanici);
    return instance;
  }

  public PSAKullaniciGuncellemeEkrani(Kullanici kullanici1) {
    kullanici = kullanici1;
    initialize();
  }

  private void initialize() {
    setTitle("PSA MERKEZ KULLANICI BİLGİ GÜNCELLEME EKRANI");
    setResizable(false);
    setBounds(0, 0, 510, 727);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setIconImage(PSAUtil.getImageIconViaRelativePath("picture/psaIcon.png")
        .getImage());
    cPanelKullanici = new JPanel();

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

    cLabelKullaniciIcon = new JLabel();
    cLabelKullaniciIcon.setBounds(194, 11, 96, 115);
    cLabelKullaniciIcon.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/kulaniciIcon.png"));

    cLabelKulaniciGuncelleme = new JLabel();
    cLabelKulaniciGuncelleme.setText("KULLANICI G\u00DCNCELLEME");
    cLabelKulaniciGuncelleme.setFont(new Font("Tahoma", Font.BOLD, 16));

    cLabelKullaniciAd = new JLabel();
    cLabelKullaniciAd.setBounds(89, 132, 127, 20);
    cLabelKullaniciAd.setText("*Kullan\u0131c\u0131 Ad\u0131");
    cLabelKullaniciAd.setFont(new Font("Tahoma", Font.BOLD, 14));

    cLabelKullaniciSifre = new JLabel();
    cLabelKullaniciSifre.setBounds(89, 160, 127, 20);
    cLabelKullaniciSifre.setText("*Kullan\u0131c\u0131 Sifre");
    cLabelKullaniciSifre.setFont(new Font("Tahoma", Font.BOLD, 14));

    cLabelKullaniciRol = new JLabel();
    cLabelKullaniciRol.setBounds(89, 188, 127, 20);
    cLabelKullaniciRol.setText("Kullan\u0131c\u0131 Rol\u00FC");
    cLabelKullaniciRol.setFont(new Font("Tahoma", Font.BOLD, 14));

    jComboBoxKullaniciRol = new JComboBox<>();
    jComboBoxKullaniciRol.setBounds(226, 188, 186, 20);
    jComboBoxKullaniciRol.setModel(new DefaultComboBoxModel<String>(
        new String[] { "KULLANICI", "Y\u00D6NET\u0130C\u0130" }));

    cLabelKullaniciIzinAciklama = new JLabel();
    cLabelKullaniciIzinAciklama.setBounds(109, 244, 278, 23);
    cLabelKullaniciIzinAciklama
        .setText("Kullan\u0131c\u0131n\u0131n yetkili oldu\u011Fu izinleri se\u00E7iniz...");
    cLabelKullaniciIzinAciklama.setFont(new Font("Tahoma", Font.BOLD, 14));

    JButtonKullaniciGuncelle = new JButton();
    JButtonKullaniciGuncelle.setBounds(89, 546, 323, 40);
    JButtonKullaniciGuncelle.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/kullaniciEkle.png"));
    JButtonKullaniciGuncelle.setText("KULLANICI G\u00DCNCELLE");
    JButtonKullaniciGuncelle.setFont(new Font("Tahoma", Font.BOLD, 15));

    JButtonKullaniciGeri = new JButton();
    JButtonKullaniciGeri.setBounds(89, 599, 323, 40);
    JButtonKullaniciGeri.setIcon(PSAUtil
        .getImageIconViaRelativePath("picture/geriButonu.png"));
    JButtonKullaniciGeri.setText("GER\u0130 D\u00D6N");
    JButtonKullaniciGeri.setFont(new Font("Tahoma", Font.BOLD, 15));

    cCheckBoxKasa = new JCheckBox();
    cCheckBoxKasa.setBounds(290, 301, 151, 23);
    cCheckBoxKasa.setText("Satış Bilgileri");

    cCheckBoxPersonelBilgileri = new JCheckBox();
    cCheckBoxPersonelBilgileri.setBounds(290, 327, 151, 24);
    cCheckBoxPersonelBilgileri.setText("Personel Bilgileri");

    cCheckBoxUrunEkleme = new JCheckBox();
    cCheckBoxUrunEkleme.setBounds(27, 274, 189, 24);
    cCheckBoxUrunEkleme.setText("Ürün İşlemleri");

    cCheckBoxYoneticiSayfasi = new JCheckBox();
    cCheckBoxYoneticiSayfasi.setBounds(269, 274, 189, 24);
    cCheckBoxYoneticiSayfasi.setText("Y\u00F6netici Sayfas\u0131");

    cLabelKullanicBilgiAd = new JLabel();
    cLabelKullanicBilgiAd.setBounds(226, 132, 186, 20);
    cLabelKullanicBilgiAd.setText((String) null);

    cTextFieldKullaniciSifre = new CTextField(20);
    cTextFieldKullaniciSifre.setBounds(226, 160, 186, 20);
    cTextFieldKullaniciSifre.setText((String) null);

    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(
        Alignment.LEADING).addGroup(
        groupLayout
            .createSequentialGroup()
            .addContainerGap()
            .addComponent(cPanelKullanici,
                GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE)
            .addGap(9)));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(
        Alignment.LEADING).addGroup(
        groupLayout
            .createSequentialGroup()
            .addContainerGap()
            .addComponent(cPanelKullanici,
                GroupLayout.PREFERRED_SIZE, 677,
                Short.MAX_VALUE).addContainerGap()));
    GroupLayout gl_cPanelKullanici = new GroupLayout(cPanelKullanici);
    gl_cPanelKullanici.setHorizontalGroup(gl_cPanelKullanici
        .createParallelGroup(Alignment.LEADING)
        .addGroup(
            gl_cPanelKullanici
                .createSequentialGroup()
                .addComponent(cLabelKulaniciGuncelleme,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE).addGap(281))
        .addComponent(cPanelKullaniciGuncelleme,
            GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE));
    gl_cPanelKullanici.setVerticalGroup(gl_cPanelKullanici
        .createParallelGroup(Alignment.LEADING).addGroup(
            gl_cPanelKullanici
                .createSequentialGroup()
                .addComponent(cLabelKulaniciGuncelleme,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(cPanelKullaniciGuncelleme,
                    GroupLayout.PREFERRED_SIZE, 655,
                    GroupLayout.PREFERRED_SIZE)
                .addContainerGap()));
    cPanelKullaniciGuncelleme.setLayout(null);
    cPanelKullaniciGuncelleme.add(cLabelKullaniciIcon);
    cPanelKullaniciGuncelleme.add(cLabelKullaniciAd);
    cPanelKullaniciGuncelleme.add(cLabelKullanicBilgiAd);
    cPanelKullaniciGuncelleme.add(cLabelKullaniciSifre);
    cPanelKullaniciGuncelleme.add(cTextFieldKullaniciSifre);
    cPanelKullaniciGuncelleme.add(cLabelKullaniciRol);
    cPanelKullaniciGuncelleme.add(jComboBoxKullaniciRol);
    cPanelKullaniciGuncelleme.add(cLabelKullaniciIzinAciklama);
    cPanelKullaniciGuncelleme.add(cCheckBoxKasa);
    cPanelKullaniciGuncelleme.add(cCheckBoxPersonelBilgileri);
    cPanelKullaniciGuncelleme.add(cCheckBoxUrunEkleme);
    cPanelKullaniciGuncelleme.add(cCheckBoxYoneticiSayfasi);
    cPanelKullaniciGuncelleme.add(JButtonKullaniciGuncelle);
    cPanelKullaniciGuncelleme.add(JButtonKullaniciGeri);

    jLabelIsaret = new JLabel("-");
    jLabelIsaret.setHorizontalAlignment(SwingConstants.CENTER);
    jLabelIsaret.setFont(new Font("Tahoma", Font.BOLD, 16));
    jLabelIsaret.setBounds(270, 305, 14, 14);
    cPanelKullaniciGuncelleme.add(jLabelIsaret);

    label = new JLabel("-");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setFont(new Font("Tahoma", Font.BOLD, 16));
    label.setBounds(270, 332, 14, 14);
    cPanelKullaniciGuncelleme.add(label);

    cCheckBoxMüsteriBilgileri = new JCheckBox();
    cCheckBoxMüsteriBilgileri.setText("Müsteri Bilgileri");
    cCheckBoxMüsteriBilgileri.setBounds(290, 354, 151, 24);
    cPanelKullaniciGuncelleme.add(cCheckBoxMüsteriBilgileri);

    label_1 = new JLabel("-");
    label_1.setHorizontalAlignment(SwingConstants.CENTER);
    label_1.setFont(new Font("Tahoma", Font.BOLD, 16));
    label_1.setBounds(270, 359, 14, 14);
    cPanelKullaniciGuncelleme.add(label_1);

    cCheckBoxEtiket = new JCheckBox();
    cCheckBoxEtiket.setText("Etiket");
    cCheckBoxEtiket.setSelected(true);
    cCheckBoxEtiket.setBounds(289, 381, 151, 24);
    cPanelKullaniciGuncelleme.add(cCheckBoxEtiket);

    label_4 = new JLabel("-");
    label_4.setHorizontalAlignment(SwingConstants.CENTER);
    label_4.setFont(new Font("Tahoma", Font.BOLD, 16));
    label_4.setBounds(269, 386, 14, 14);
    cPanelKullaniciGuncelleme.add(label_4);

    cCheckBoxIstatistik = new JCheckBox();
    cCheckBoxIstatistik.setText("İstatistik");
    cCheckBoxIstatistik.setSelected(true);
    cCheckBoxIstatistik.setBounds(289, 408, 151, 24);
    cPanelKullaniciGuncelleme.add(cCheckBoxIstatistik);

    label_5 = new JLabel("-");
    label_5.setHorizontalAlignment(SwingConstants.CENTER);
    label_5.setFont(new Font("Tahoma", Font.BOLD, 16));
    label_5.setBounds(269, 413, 14, 14);
    cPanelKullaniciGuncelleme.add(label_5);

    cCheckBoxBankaDzenle = new JCheckBox();
    cCheckBoxBankaDzenle.setText("Banka Düzenle");
    cCheckBoxBankaDzenle.setSelected(true);
    cCheckBoxBankaDzenle.setBounds(289, 435, 151, 24);
    cPanelKullaniciGuncelleme.add(cCheckBoxBankaDzenle);

    label_6 = new JLabel("-");
    label_6.setHorizontalAlignment(SwingConstants.CENTER);
    label_6.setFont(new Font("Tahoma", Font.BOLD, 16));
    label_6.setBounds(269, 440, 14, 14);
    cPanelKullaniciGuncelleme.add(label_6);

    cCheckBoxUrunSevkEt = new JCheckBox();
    cCheckBoxUrunSevkEt.setText("Ürün Sevk");
    cCheckBoxUrunSevkEt.setBounds(47, 301, 151, 24);
    cPanelKullaniciGuncelleme.add(cCheckBoxUrunSevkEt);

    cCheckBoxUrunSevkBilgi = new JCheckBox();
    cCheckBoxUrunSevkBilgi.setText("Ürün Sevk Bilgisi");
    cCheckBoxUrunSevkBilgi.setBounds(47, 329, 151, 24);
    cPanelKullaniciGuncelleme.add(cCheckBoxUrunSevkBilgi);

    label_2 = new JLabel("-");
    label_2.setHorizontalAlignment(SwingConstants.CENTER);
    label_2.setFont(new Font("Tahoma", Font.BOLD, 16));
    label_2.setBounds(27, 334, 14, 14);
    cPanelKullaniciGuncelleme.add(label_2);

    label_7 = new JLabel("-");
    label_7.setHorizontalAlignment(SwingConstants.CENTER);
    label_7.setFont(new Font("Tahoma", Font.BOLD, 16));
    label_7.setBounds(27, 306, 14, 14);
    cPanelKullaniciGuncelleme.add(label_7);

    cCheckBoxFirmaBilgileri = new JCheckBox();
    cCheckBoxFirmaBilgileri.setText("Firma Bilgileri");
    cCheckBoxFirmaBilgileri.setBounds(290, 462, 151, 24);
    cPanelKullaniciGuncelleme.add(cCheckBoxFirmaBilgileri);

    label_3 = new JLabel("-");
    label_3.setHorizontalAlignment(SwingConstants.CENTER);
    label_3.setFont(new Font("Tahoma", Font.BOLD, 16));
    label_3.setBounds(270, 467, 14, 14);
    cPanelKullaniciGuncelleme.add(label_3);

    label_8 = new JLabel("-");
    label_8.setHorizontalAlignment(SwingConstants.CENTER);
    label_8.setFont(new Font("Tahoma", Font.BOLD, 16));
    label_8.setBounds(270, 494, 14, 14);
    cPanelKullaniciGuncelleme.add(label_8);

    cCheckBoxKategori = new JCheckBox();
    cCheckBoxKategori.setText("Kategori Düzenle");
    cCheckBoxKategori.setBounds(290, 489, 151, 24);
    cPanelKullaniciGuncelleme.add(cCheckBoxKategori);

    cCheckBoxStokGuncelleme = new JCheckBox();
    cCheckBoxStokGuncelleme.setText("Ürün Ekle/Güncelle/Sil");
    cCheckBoxStokGuncelleme.setBounds(47, 357, 151, 24);
    cPanelKullaniciGuncelleme.add(cCheckBoxStokGuncelleme);

    label_9 = new JLabel("-");
    label_9.setHorizontalAlignment(SwingConstants.CENTER);
    label_9.setFont(new Font("Tahoma", Font.BOLD, 16));
    label_9.setBounds(27, 364, 14, 14);
    cPanelKullaniciGuncelleme.add(label_9);
    cPanelKullanici.setLayout(gl_cPanelKullanici);
    getContentPane().setLayout(groupLayout);

    initListeners();
    kullaniciBilgileriDoldur(kullanici);
    adminControl(kullanici);
  }

  private void adminControl(Kullanici kullanici) {
    if (kullanici.isAdmin()) {
      cCheckBoxKasa.setEnabled(false);
      cCheckBoxPersonelBilgileri.setEnabled(false);
      cCheckBoxUrunSevkEt.setEnabled(false);
      cCheckBoxUrunEkleme.setEnabled(false);
      cCheckBoxYoneticiSayfasi.setEnabled(false);
      cCheckBoxUrunSevkBilgi.setEnabled(false);
      cCheckBoxMüsteriBilgileri.setEnabled(false);
      cCheckBoxEtiket.setEnabled(false);
      cCheckBoxKategori.setEnabled(false);
      cCheckBoxMüsteriBilgileri.setEnabled(false);
      cCheckBoxBankaDzenle.setEnabled(false);
      cCheckBoxIstatistik.setEnabled(false);
      cCheckBoxStokGuncelleme.setEnabled(false);
    }
  }

  private void kullaniciBilgileriDoldur(Kullanici kullanici) {
    cLabelKullanicBilgiAd.setText(kullanici.getKullaniciAdi());
    cTextFieldKullaniciSifre.setText(kullanici.getSifre());
    jComboBoxKullaniciRol.setSelectedItem(kullanici.getRol());
    jComboBoxKullaniciRol.setEnabled(false);
    cCheckBoxPersonelBilgileri.setSelected(checkStateControl(kullanici
        .getPersonel()));
    cCheckBoxUrunEkleme.setSelected(checkStateControl(kullanici.getUrun()));
    cCheckBoxYoneticiSayfasi.setSelected(checkStateControl(kullanici
        .getYonetici()));
    cCheckBoxKasa.setSelected(checkStateControl(kullanici.getKasa()));
    cCheckBoxMüsteriBilgileri.setSelected(checkStateControl(kullanici
        .getMüsteri()));
    cCheckBoxEtiket.setSelected(checkStateControl(kullanici.getEtiket()));
    cCheckBoxBankaDzenle
        .setSelected(checkStateControl(kullanici.getBanka()));
    cCheckBoxIstatistik.setSelected(checkStateControl(kullanici
        .getIstatistik()));
    cCheckBoxFirmaBilgileri.setSelected(checkStateControl(kullanici
        .getFirma()));
    cCheckBoxKategori
        .setSelected(checkStateControl(kullanici.getKategori()));
    cCheckBoxStokGuncelleme.setSelected(checkStateControl(kullanici
        .getStok()));
    cCheckBoxUrunSevkBilgi.setSelected(checkStateControl(kullanici
        .getUrunSevkBilgi()));
    cCheckBoxUrunSevkEt.setSelected(checkStateControl(kullanici
        .getUrunSevk()));
  }

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

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

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

    cCheckBoxYoneticiSayfasi.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        if (evt.getStateChange() == ItemEvent.DESELECTED) {
          cCheckBoxKasa.setSelected(false);
          cCheckBoxMüsteriBilgileri.setSelected(false);
          cCheckBoxPersonelBilgileri.setSelected(false);
          cCheckBoxEtiket.setSelected(false);
          cCheckBoxFirmaBilgileri.setSelected(false);
          cCheckBoxKategori.setSelected(false);
          cCheckBoxBankaDzenle.setSelected(false);
          cCheckBoxIstatistik.setSelected(false);
          cCheckBoxEtiket.setSelected(false);
        }
      }
    });

    cCheckBoxBankaDzenle.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        yoneticiSayfasiControl(evt);
      }
    });

    cCheckBoxFirmaBilgileri.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        yoneticiSayfasiControl(evt);
      }
    });

    cCheckBoxKategori.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        yoneticiSayfasiControl(evt);
      }
    });

    cCheckBoxIstatistik.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        yoneticiSayfasiControl(evt);
      }
    });

    cCheckBoxKasa.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        yoneticiSayfasiControl(evt);
      }
    });

    cCheckBoxMüsteriBilgileri.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        yoneticiSayfasiControl(evt);
      }
    });
    cCheckBoxEtiket.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        yoneticiSayfasiControl(evt);
      }
    });

    cCheckBoxPersonelBilgileri.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        yoneticiSayfasiControl(evt);
      }
    });

    cCheckBoxUrunEkleme.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        if (evt.getStateChange() == ItemEvent.DESELECTED) {
          cCheckBoxUrunSevkEt.setSelected(false);
          cCheckBoxUrunSevkBilgi.setSelected(false);
          cCheckBoxStokGuncelleme.setSelected(false);
        }
      }
    });

    cCheckBoxUrunSevkEt.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        urunSayfasiControl(evt);
      }
    });

    cCheckBoxUrunSevkBilgi.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        urunSayfasiControl(evt);
      }
    });

    cCheckBoxStokGuncelleme.addItemListener(new ItemListener() {
      @Override
      public void itemStateChanged(ItemEvent evt) {
        urunSayfasiControl(evt);
      }
    });

  }

  protected void urunSayfasiControl(ItemEvent evt) {
    if (evt.getStateChange() == ItemEvent.DESELECTED) {
      return;
    }
    cCheckBoxUrunEkleme.setSelected(true);
  }

  protected void yoneticiSayfasiControl(ItemEvent evt) {
    if (evt.getStateChange() == ItemEvent.DESELECTED) {
      return;
    }
    cCheckBoxYoneticiSayfasi.setSelected(true);
  }

  protected void kullaniciEkraniSetEnable() {
    PSAKullaniciEkrani.getInstance(1).setEnabled(true);
    instance.dispose();
  }

  protected void kullaniciGuncelleClicked() {
    if (cTextFieldKullaniciSifre.getText().trim().equals("")) {
      Utils.showMessage("Lütfen zorunlu(*) alanları doldurunuz.");
      return;
    }
    if (!userInfoControl(kullanici)) {
      Utils.showMessage("Kullanıcı ile ilgi güncellenecek bilgi bulunmamaktadır.");
      return;
    }
    kullanici.setSifre(cTextFieldKullaniciSifre.getText());
    kullanici.setRol(jComboBoxKullaniciRol.getSelectedItem().toString());
    kullanici.setYonetici(checkControl(cCheckBoxYoneticiSayfasi));
    kullanici.setKasa(checkControl(cCheckBoxKasa));
    kullanici.setPersonel(checkControl(cCheckBoxPersonelBilgileri));
    kullanici.setMüsteri(checkControl(cCheckBoxMüsteriBilgileri));
    kullanici.setUrunSevk(checkControl(cCheckBoxUrunSevkEt));
    kullanici.setUrunSevkBilgi(checkControl(cCheckBoxUrunSevkBilgi));
    kullanici.setKategori(checkControl(cCheckBoxKategori));
    kullanici.setFirma(checkControl(cCheckBoxFirmaBilgileri));
    kullanici.setUrun(checkControl(cCheckBoxUrunEkleme));
    kullanici.setEtiket(checkControl(cCheckBoxEtiket));
    kullanici.setStok(checkControl(cCheckBoxStokGuncelleme));
    kullanici.setBanka(checkControl(cCheckBoxBankaDzenle));
    kullanici.setIstatistik(checkControl(cCheckBoxIstatistik));
    boolean control = HibernateManager.getInstance().update(kullanici);
    if (control) {
      AutoClosingMessageDialog.showAutoClosingMessageDialog(
          "Kullanıcı ile ilgi bilgi güncellenmiştir.", 2);
      kullaniciEkraniSetEnable();
    }

  }

  private boolean userInfoControl(Kullanici kullanici) {
    boolean control = true;
    String kasa = null;
    String personelBilgileri = null;
    String urunEkleme = null;
    String yoneticiSayfasi = null;
    String müsteri = null;
    String etiket = null;
    String banka = null;
    String urunSevk = null;
    String urunSevkBilgi = null;
    String istatistik = null;
    String firma = null;
    String kategori = null;
    String stokGuncelleme = null;

    if (cCheckBoxKasa.isSelected()) {
      kasa = "EVET";
    } else {
      kasa = "HAYIR";
    }
    if (cCheckBoxEtiket.isSelected()) {
      etiket = "EVET";
    } else {
      etiket = "HAYIR";
    }
    if (cCheckBoxPersonelBilgileri.isSelected()) {
      personelBilgileri = "EVET";
    } else {
      personelBilgileri = "HAYIR";
    }
    if (cCheckBoxUrunSevkEt.isSelected()) {
      urunSevk = "EVET";
    } else {
      urunSevk = "HAYIR";
    }
    if (cCheckBoxUrunSevkBilgi.isSelected()) {
      urunSevkBilgi = "EVET";
    } else {
      urunSevkBilgi = "HAYIR";
    }
    if (cCheckBoxUrunEkleme.isSelected()) {
      urunEkleme = "EVET";
    } else {
      urunEkleme = "HAYIR";
    }
    if (cCheckBoxYoneticiSayfasi.isSelected()) {
      yoneticiSayfasi = "EVET";
    } else {
      yoneticiSayfasi = "HAYIR";
    }
    if (cCheckBoxMüsteriBilgileri.isSelected()) {
      müsteri = "EVET";
    } else {
      müsteri = "HAYIR";
    }
    if (cCheckBoxBankaDzenle.isSelected()) {
      banka = "EVET";
    } else {
      banka = "HAYIR";
    }
    if (cCheckBoxIstatistik.isSelected()) {
      istatistik = "EVET";
    } else {
      istatistik = "HAYIR";
    }

    if (cCheckBoxStokGuncelleme.isSelected()) {
      stokGuncelleme = "EVET";
    } else {
      stokGuncelleme = "HAYIR";
    }

    if (cCheckBoxFirmaBilgileri.isSelected()) {
      firma = "EVET";
    } else {
      firma = "HAYIR";
    }

    if (cCheckBoxKategori.isSelected()) {
      kategori = "EVET";
    } else {
      kategori = "HAYIR";
    }

    if (cTextFieldKullaniciSifre.getText().equals(kullanici.getSifre())
        && kullanici.getKasa().equals(kasa)
        && kullanici.getPersonel().equals(personelBilgileri)
        && kullanici.getUrunSevk().equals(urunSevk)
        && kullanici.getUrun().equals(urunEkleme)
        && kullanici.getYonetici().equals(yoneticiSayfasi)
        && kullanici.getUrunSevkBilgi().equals(urunSevkBilgi)
        && kullanici.getMüsteri().equals(müsteri)
        && kullanici.getEtiket().equals(etiket)
        && kullanici.getFirma().equals(firma)
        && kullanici.getKategori().equals(kategori)
        && kullanici.getBanka().equals(banka)
        && kullanici.getIstatistik().equals(istatistik)
        && kullanici.getStok().equals(stokGuncelleme)
        && kullanici.getRol().equals(
            jComboBoxKullaniciRol.getSelectedItem().toString())) {
      control = false;
    }
    return control;
  }

  private static boolean checkStateControl(String state) {
    boolean checkState = true;
    if (state.equals("HAYIR")) {
      checkState = false;
    }
    return checkState;
  }

  private static String checkControl(JCheckBox cCheckBox) {
    String state = "EVET";
    if (cCheckBox.isSelected() == false) {
      state = "HAYIR";
    }
    return state;
  }
}
TOP

Related Classes of gui.PSAKullaniciGuncellemeEkrani

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.