Aplikasi POS Amigo, dibangun dengan JavaFX dengan Maven
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.8 KiB

  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package id.amigogroup.posterminal.bayar;
  7. import id.amigogroup.posterminal.SystemValue;
  8. import id.amigogroup.posterminal.util.Fucout;
  9. import java.net.URL;
  10. import java.util.ResourceBundle;
  11. import javafx.fxml.FXML;
  12. import javafx.fxml.Initializable;
  13. import javafx.scene.control.Label;
  14. import javafx.scene.control.TextField;
  15. import javafx.scene.input.KeyEvent;
  16. /**
  17. * FXML Controller class
  18. *
  19. * @author ronal
  20. */
  21. public class FormBayarPoinController implements Initializable {
  22. @FXML
  23. private TextField fldPoin;
  24. @FXML
  25. private Label lblPoin;
  26. @FXML
  27. private Label lblKonversiPoin;
  28. private BayarInterface parent;
  29. int poin = 0;
  30. /**
  31. * Initializes the controller class.
  32. */
  33. @Override
  34. public void initialize(URL url, ResourceBundle rb) {
  35. if (SystemValue.member != null) {
  36. lblPoin.setText(Fucout.getTextColon(Fucout.formatRibuan(SystemValue.member.getPoin())));
  37. poin = SystemValue.member.getPoin();
  38. }
  39. if (SystemValue.konversiPoin != null) {
  40. lblKonversiPoin.setText("(1 poin = "
  41. + Fucout.formatRupiah(SystemValue.konversiPoin.getKonversiPoin())
  42. + ")");
  43. }
  44. Fucout.forceFieldInteger(fldPoin);
  45. }
  46. public void initData(BayarInterface parent) {
  47. this.parent = parent;
  48. }
  49. @FXML
  50. void fldPoinOnKeyReleased(KeyEvent event) {
  51. int bayarPoin = 0;
  52. if (!fldPoin.getText().equals("")) {
  53. try {
  54. bayarPoin = Integer.parseInt(fldPoin.getText());
  55. } catch (NumberFormatException nfe) {
  56. fldPoin.setText("");
  57. }
  58. }
  59. if (parent != null && parent.getBayarContent() != null
  60. && parent.getBayarContent().getNodePoin() != null) {
  61. if (bayarPoin > poin) {
  62. fldPoin.setText(String.valueOf(poin));
  63. fldPoin.positionCaret(fldPoin.getText().length());
  64. bayarPoin = poin;
  65. } else if (bayarPoin <= 0) {
  66. fldPoin.setText("");
  67. bayarPoin = 0;
  68. }
  69. if (bayarPoin > 0) {
  70. lblPoin.setText(Fucout.getTextColon(Fucout.formatRibuan(poin)
  71. + " ("
  72. + Fucout.formatRibuan(bayarPoin) + " = "
  73. + Fucout.formatRibuan(bayarPoin * Fucout.KONVERSI_POIN)
  74. + ")"));
  75. } else {
  76. lblPoin.setText(Fucout.getTextColon(Fucout.formatRibuan(poin)));
  77. }
  78. parent.getBayarContent().setBayarPoin(bayarPoin * Fucout.KONVERSI_POIN);
  79. parent.updateKurangBayarView();
  80. }
  81. }
  82. }