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.

102 lines
3.0 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.util.Fucout;
  8. import java.net.URL;
  9. import java.util.ResourceBundle;
  10. import javafx.fxml.FXML;
  11. import javafx.fxml.Initializable;
  12. import javafx.scene.control.Label;
  13. import javafx.scene.control.TextField;
  14. import javafx.scene.input.KeyCode;
  15. import javafx.scene.input.KeyEvent;
  16. import javafx.scene.robot.Robot;
  17. /**
  18. * FXML Controller class
  19. *
  20. * @author ronal
  21. */
  22. public class FormBayarKartuController implements Initializable {
  23. @FXML
  24. private TextField fldNoKartu1;
  25. @FXML
  26. private TextField fldNoKartu2;
  27. @FXML
  28. private TextField fldNoKartu3;
  29. @FXML
  30. private TextField fldNoKartu4;
  31. @FXML
  32. private TextField fldBayar;
  33. private BayarInterface parent;
  34. /**
  35. * Initializes the controller class.
  36. */
  37. @Override
  38. public void initialize(URL url, ResourceBundle rb) {
  39. initComponents();
  40. }
  41. public void initData(BayarInterface parent) {
  42. this.parent = parent;
  43. // if (parent != null && parent.getBayarContent() != null
  44. // && parent.getBayarContent().getNodeKartu() != null) {
  45. // parent.getBayarContent().setBayarKartu(50000);
  46. // parent.updateKurangBayarView();
  47. // }
  48. }
  49. private void initComponents() {
  50. Fucout.forceFieldInteger(fldNoKartu1, 4);
  51. Fucout.forceFieldInteger(fldNoKartu2, 4);
  52. Fucout.forceFieldInteger(fldNoKartu3, 4);
  53. Fucout.forceFieldInteger(fldNoKartu4, 4);
  54. }
  55. @FXML
  56. public void fldNomorKartuOnKeyTyped(KeyEvent event) {
  57. if (event.getSource() != null
  58. && event.getSource() instanceof TextField) {
  59. TextField field = (TextField) event.getSource();
  60. if (field.getText().length() >= 4) {
  61. if (event.getCharacter().matches("[0-9]")) {
  62. Robot robot = new Robot();
  63. robot.keyType(KeyCode.TAB);
  64. }
  65. }
  66. }
  67. }
  68. @FXML
  69. void fldBayarOnKeyReleased(KeyEvent event) {
  70. int bayar = 0;
  71. if (!fldBayar.getText().equals("")) {
  72. try {
  73. bayar = Integer.parseInt(fldBayar.getText());
  74. } catch (NumberFormatException nfe) {
  75. fldBayar.setText("");
  76. }
  77. }
  78. if (parent != null && parent.getBayarContent() != null
  79. && parent.getBayarContent().getNodeKartu() != null) {
  80. parent.getBayarContent().setBayarKartu(bayar);
  81. parent.updateKurangBayarView();
  82. if (parent.getBayarContent().getTotalPerluBayar()
  83. < parent.getBayarContent().getTotalBayar()) {
  84. int kembali = parent.getBayarContent().getTotalBayar()
  85. - parent.getBayarContent().getTotalPerluBayar();
  86. }
  87. }
  88. }
  89. }