Пример #1
0
  @Override
  public boolean validate() {
    PegawaiDao d = App.getPegawaiDao();
    if (code.getText().trim().equalsIgnoreCase("")) {
      App.showErrorFieldEmpty(LPegawai.CODE);
      return false;
    } else {
      long tmp = d.countByColumn("code", code.getText().trim());
      if (tmp > 0) {
        App.showErrorDataSudahAda(LPegawai.CODE);
        return false;
      }
    }

    if (nama.getText().trim().equalsIgnoreCase("")) {
      App.showErrorFieldEmpty(LPegawai.NAMA);
      return false;
    }

    if (username.getText().trim().equalsIgnoreCase("")) {
      App.showErrorFieldEmpty(LPegawai.USERNAME);
      return false;
    } else {
      long tmp = d.countByColumn("username", username.getText().trim());
      if (tmp > 0) {
        App.showErrorDataSudahAda(LPegawai.USERNAME);
        return false;
      }
    }

    if (password.getPassword().length > 0) {
      if (password.getPassword().length == ulang.getPassword().length
          && Arrays.equals(password.getPassword(), ulang.getPassword())) {

      } else {
        App.showErrorPasswordTidakSamadenganKonfirmasi();
        ulang.requestFocus();
        return false;
      }
    } else {
      App.showErrorFieldEmpty(LPegawai.PASSWORD);
      password.requestFocus();
      return false;
    }

    if (hakAkses.getSelectedIndex() == 0) {
      App.showErrorEmptySelect(LPegawai.HAK_AKSES);
      return false;
    }

    return true;
  }
Пример #2
0
  @Override
  public void save() {
    Pegawai model = new Pegawai();
    model.setCode(code.getText().trim());
    model.setNama(nama.getText().trim());
    model.setUsername(username.getText().trim());
    UtilAccount u = new UtilAccount();
    String p;
    try {
      p = u.md5(new String(password.getPassword()));
      model.setPassword(p);
    } catch (Exception e) {
      App.printErr(e);
    }
    model.setJenisIdentitas(jenisIdentitas.getText().trim());
    model.setNoIdentitas(noIdentitas.getText().trim());
    model.setAlamat(alamat.getText().trim());
    model.setKota(kota.getText().trim());
    model.setHp(hp.getText().trim());
    model.setStatus(status.getSelectedIndex());
    try {
      HakAks h = (HakAks) hakAkses.getSelectedItem();
      model.setHakAks(h);
    } catch (Exception e) {
      App.printErr(e);
    }

    PegawaiDao d = App.getPegawaiDao();
    d.saveAutoCode(model);
    this.model = model;
  }