Exemplo n.º 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();
  }
Exemplo n.º 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();
  }
Exemplo n.º 3
0
  void ResetGUI() {
    // Customer
    customer = null;
    lblCustomer.setText(getString(R.string.text_customer));

    // Products
    productAdapter.clear();
    productAdapter.notifyDataSetChanged();

    // Payment Type
    cmbPaymentType.setSelection(0);

    // Total
    totalSale = 0;
    lblTotal.setText(
        getString(R.string.currency_symbol) + Functions.GetFloatValueWithTwoDecimals(totalSale));
  }
Exemplo n.º 4
0
  void SetProduct(Bundle bundle) {
    totalSale += bundle.getFloat("price");
    lblTotal.setText(
        getString(R.string.currency_symbol) + Functions.GetFloatValueWithTwoDecimals(totalSale));

    Product product = new Product(bundle.getInt("id"), bundle.getString("name"));
    product.setPrice(bundle.getFloat("price"));

    if (productAdapter == null) {
      ArrayList<Product> products = new ArrayList<Product>();
      productAdapter = new ProductAdapter(this, products);
      ListView lstProducts = (ListView) findViewById(R.id.lstProductList);
      lstProducts.setAdapter(productAdapter);
    }

    productAdapter.add(product);
    productAdapter.notifyDataSetChanged();
  }
Exemplo n.º 5
0
  boolean ValidateSaveSale() {
    if (customer == null) {
      return false;
    }
    if (productAdapter == null) {
      return false;
    }
    if (productAdapter.getCount() == 0) {
      return false;
    }

    return true;
  }