Guest User

Untitled

a guest
Feb 25th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. @Override
  2. public void onClick(View view) {
  3. if (view.getId() == R.id.btnaceptar) {
  4. if (etinicio.getText().toString().isEmpty() || etarticulo.getText().toString().isEmpty() || etcantidad.getText().toString().isEmpty() ){
  5. Toast toast = Toast.makeText(this, "Ingresa una cantidad", Toast.LENGTH_SHORT);
  6. toast.show();
  7. }else{
  8. etinicio.setEnabled(false);
  9. etarticulo.setEnabled(false);
  10. etcantidad.setEnabled(false);
  11. btncomprar.setEnabled(false);
  12. }
  13. }
  14. if (view.getId() == R.id.btncomprar && etinicio.getText().toString().isEmpty() || etarticulo.getText().toString().isEmpty() || etcantidad.getText().toString().isEmpty()) {
  15.  
  16. Toast toast = Toast.makeText(this, "Accion No permitida", Toast.LENGTH_SHORT);
  17. toast.show();
  18. }else{
  19. try{
  20. double inicio = Double.parseDouble(etinicio.getText().toString());
  21. double articulo = Double.parseDouble(etarticulo.getText().toString());
  22. double cantidad = Double.parseDouble(etcantidad.getText().toString());
  23.  
  24. float total = (float) (articulo * cantidad);
  25. float total1 = (float) (inicio - total);
  26. float porciento = (float) ((total1 / inicio) * 100);
  27. String porcentaje = Float.toString(porciento);
  28. tvporcentaje.setText(porcentaje);
  29.  
  30. float suma = (float) (inicio - total);
  31. String resultadosuma = String.valueOf(suma);
  32. tvdisponible.setText(resultadosuma);
  33.  
  34. float suma2 = (float) (inicio - suma);
  35. String resultadosuma2 = String.valueOf(suma2);
  36. tvcompra.setText(resultadosuma2);
  37.  
  38. ObjectAnimator anim = ObjectAnimator.ofInt(pbarra, "progress", 0, 100);
  39. anim.setDuration(2000);
  40. anim.setInterpolator(new DecelerateInterpolator());
  41. //iniciamos el progressbar
  42. anim.start();
  43. //Toast toast = Toast.makeText(this, "Favor de escribir Compras", Toast.LENGTH_SHORT);
  44. //toast.show();
  45. }catch (NumberFormatException e) {
  46. Toast toast = Toast.makeText(this, "Primero Acepta la Transaccion", Toast.LENGTH_SHORT);
  47. toast.show();
  48. }
  49. }
  50. if (view.getId() == R.id.btnceditar) {
  51. etinicio.setEnabled(true);
  52. etarticulo.setEnabled(true);
  53. etcantidad.setEnabled(true);
  54. }
  55. }
Add Comment
Please, Sign In to add comment