Пример #1
0
  void SaveSale() {

    if (!ValidateSaveSale()) {
      ShowErrorSaveSale();
      return;
    }

    // Header
    SaleHeader saleHeader = new SaleHeader(0, customer.getId_customer());
    saleHeader.setCustomer_name(customer.getName());
    saleHeader.setTotal(totalSale);
    saleHeader.setId_payment_type(GetIdPaymentTypes());
    saleHeader.setDate_sale(new Date());

    // Details
    for (int i = 0; i < productAdapter.getCount(); i++) {
      Product product = productAdapter.getItem(i);

      SaleDetail saleDetail = new SaleDetail(0, 0);
      saleDetail.setId_product(product.getId_product());
      saleDetail.setProduct_name(product.getName());
      saleDetail.setProduct_price(product.getPrice());
      saleHeader.addDetail(saleDetail);
    }

    saleHeaderHelper.InsertWithDetails(saleHeader);
    ResetGUI();
  }
Пример #2
0
  void DeleteProduct() {
    Product product = productAdapter.getItem(positionProductForDelete);
    totalSale -= product.getPrice();
    lblTotal.setText(
        getString(R.string.currency_symbol) + Functions.GetFloatValueWithTwoDecimals(totalSale));

    productAdapter.remove(product);
    productAdapter.notifyDataSetChanged();
  }