Example #1
0
  /// Showd Data on grid table
  public void showgrid() {
    for (Component c : find(this.getPage(), "#showsell > rows > row")) {
      c.detach();
    }
    float sumallprice = 0;
    for (int i = 0; i < pointcount; i++) {
      Row r = new Row();
      r.appendChild(new Label(Integer.toString(idpro.get(i))));
      r.appendChild(new Label(nameproduct.get(i)));
      r.appendChild(new Label(Integer.toString(qty.get(i))));
      r.appendChild(new Label(Integer.toString(unitprice.get(i))));
      r.appendChild(new Label(Integer.toString(price.get(i))));
      r.appendChild(new Label(namecus.get(i)));
      Button but = new Button("Delete");
      but.setId("" + i);
      but.addEventListener(
          "onClick",
          new EventListener() {
            public void onEvent(Event ee) {
              nameproduct.remove(Integer.parseInt(ee.getTarget().getId()));
              qty.remove(Integer.parseInt(ee.getTarget().getId()));
              unitprice.remove(Integer.parseInt(ee.getTarget().getId()));
              price.remove(Integer.parseInt(ee.getTarget().getId()));
              namecus.remove(Integer.parseInt(ee.getTarget().getId()));
              pointcount--;
              txtsum.setValue("0");
              txtvat.setValue("0");
              idsumprice.setValue("0");
              showgrid();
            }
          });
      r.appendChild(but);
      Component v = find(this.getPage(), "#showsell > rows").get(0);
      v.appendChild(r);
      sumallprice = sumallprice + price.get(i);
      float vatc1;
      String vatc2;
      for (Customereng vc : Customereng.findAllCustomerengs()) {
        vatc2 = vc.getTax();
        vatc1 = Float.parseFloat(vatc2);

        float vat = (sumallprice * vatc1) / 100;
        float sumtotal = vat + sumallprice;
        txtsum.setValue(Float.toString(sumallprice));
        txtvat.setValue(Float.toString(vat));
        idsumprice.setValue(Float.toString(sumtotal));
      }
    }
  }