Esempio n. 1
0
  @Override
  public void aksiReset() {
    code.setText("AUTO");

    tgl.setDate(new Date());
    clearText(pelanggan);

    cust = null;

    clearText(jml);
    double p = DataUser.getProduct().field(ProductDao.harga);
    harga.setValue(p);

    clearText(total1);
    diskon.setText("0");
    diskonp.setText("0.00");
    clearText(total);
    bayar.setText("");
    k.setText("0");
    kembali.setText("0");
    setCursor();
  }
Esempio n. 2
0
  public boolean validate(ODatabaseDocumentTx db) {
    if (!(code.getText().equalsIgnoreCase("AUTO") || code.getText().trim().equalsIgnoreCase(""))) {
      long tmp = App.getPenjualanDao().getCountByColumn(db, PenjualanDao.code, code.getText());
      if (tmp > 0) {
        codea = "";
        App.showErrorDataSudahAda(db, PenjualanDao.fcode);
        return false;
      }
    }
    codea = code.getText();
    tgla = tgl.getDate();
    if (tgla == null) {
      tgl.setDate(new Date());
      tgla = new Date();
      App.showErrorFieldEmpty(db, PenjualanDao.ftgl);
      return false;
    }

    if (cust == null) {
      pelanggan.setText("");
      App.showErrorFieldEmpty(db, PenjualanDao.fpelanggan);
      return false;
    } else {
      pelanggana = cust;
    }

    try {
      hargaa = Double.parseDouble(harga.getValue() + "");
      if (hargaa < 0) {
        return false;
      }
    } catch (Exception e) {
      harga.setText("1");
      try {
        harga.commitEdit();
      } catch (ParseException e1) {
      }
      App.printErr(e);
      return false;
    }
    try {
      jmla = Double.parseDouble(jml.getValue() + "");
      if (jmla <= 0) {
        App.showErrorJumlahTidakFalid();
      }
    } catch (Exception e) {
      jml.setText("");
      App.showErrorFieldEmpty(db, PenjualanDao.fjml);
      return false;
    }

    try {
      diskon.commitEdit();
      diskona = Double.parseDouble(diskon.getValue() + "");
      if (diskona < 0) {
        App.showErrorNotValid(db, PenjualanDao.fdiskon);
      }
    } catch (Exception e) {
      App.showErrorFieldEmpty(db, PenjualanDao.fdiskon);
      App.printErr(e);
      return false;
    }

    try {
      diskonp.commitEdit();
      diskonpa = Double.parseDouble(diskonp.getValue() + "");
      if (diskonpa < 0) {
        App.showErrorNotValid(db, PenjualanDao.fdiskonp);
      }
    } catch (Exception e) {
      App.showErrorFieldEmpty(db, PenjualanDao.fdiskonp);
      App.printErr(e);
      return false;
    }

    try {
      if (bayar.getText().equals("")) {
        App.showErrorFieldEmpty(db, PenjualanDao.fbayar);
        return false;
      }
      String stmp = bayar.getText().replaceAll("\\,", "");
      if (stmp == null || stmp.equalsIgnoreCase("")) {
        App.showErrorFieldEmpty(db, PenjualanDao.fbayar);
        return false;
      }
      bayara = Double.parseDouble(stmp);
      if (bayara < 0) {
        App.showErrorNotValid(db, PenjualanDao.fbayar);
      }
    } catch (Exception e) {
      App.showErrorFieldEmpty(db, PenjualanDao.fbayar);
      App.printErr(e);
      return false;
    }

    try {
      k.commitEdit();
      ka = Double.parseDouble(k.getValue() + "");
    } catch (Exception e) {
      App.printErr(e);
      return false;
    }

    try {
      total1.commitEdit();
      total1a = Double.parseDouble(total1.getValue() + "");
    } catch (Exception e) {
      App.printErr(e);
      return false;
    }

    try {
      total.commitEdit();
      totala = Double.parseDouble(total.getValue() + "");
    } catch (Exception e) {
      App.printErr(e);
      return false;
    }

    if (ka > 0) {
      da = bayara;
      notea = App.getT(db, "Hutang");
    } else {
      da = totala;
      notea = App.getT(db, "Lunas");
    }

    producta = DataUser.getProduct();

    return true;
  }