|
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package id.amigogroup.posterminal.bayar;
-
- import id.amigogroup.posterminal.SystemValue;
- import id.amigogroup.posterminal.util.Fucout;
- import java.net.URL;
- import java.util.ResourceBundle;
- import javafx.fxml.FXML;
- import javafx.fxml.Initializable;
- import javafx.scene.control.Label;
- import javafx.scene.control.TextField;
- import javafx.scene.input.KeyEvent;
-
- /**
- * FXML Controller class
- *
- * @author ronal
- */
- public class FormBayarPoinController implements Initializable {
-
- @FXML
- private TextField fldPoin;
- @FXML
- private Label lblPoin;
- @FXML
- private Label lblKonversiPoin;
-
- private BayarInterface parent;
- int poin = 0;
-
- /**
- * Initializes the controller class.
- */
- @Override
- public void initialize(URL url, ResourceBundle rb) {
- if (SystemValue.member != null) {
- lblPoin.setText(Fucout.getTextColon(Fucout.formatRibuan(SystemValue.member.getPoin())));
- poin = SystemValue.member.getPoin();
- }
- if (SystemValue.konversiPoin != null) {
- lblKonversiPoin.setText("(1 poin = "
- + Fucout.formatRupiah(SystemValue.konversiPoin.getKonversiPoin())
- + ")");
- }
- Fucout.forceFieldInteger(fldPoin);
- }
-
- public void initData(BayarInterface parent) {
- this.parent = parent;
- }
-
- @FXML
- void fldPoinOnKeyReleased(KeyEvent event) {
- int bayarPoin = 0;
- if (!fldPoin.getText().equals("")) {
- try {
- bayarPoin = Integer.parseInt(fldPoin.getText());
- } catch (NumberFormatException nfe) {
- fldPoin.setText("");
- }
- }
- if (parent != null && parent.getBayarContent() != null
- && parent.getBayarContent().getNodePoin() != null) {
- if (bayarPoin > poin) {
- fldPoin.setText(String.valueOf(poin));
- fldPoin.positionCaret(fldPoin.getText().length());
- bayarPoin = poin;
- } else if (bayarPoin <= 0) {
- fldPoin.setText("");
- bayarPoin = 0;
- }
-
- if (bayarPoin > 0) {
- lblPoin.setText(Fucout.getTextColon(Fucout.formatRibuan(poin)
- + " ("
- + Fucout.formatRibuan(bayarPoin) + " = "
- + Fucout.formatRibuan(bayarPoin * Fucout.KONVERSI_POIN)
- + ")"));
- } else {
- lblPoin.setText(Fucout.getTextColon(Fucout.formatRibuan(poin)));
- }
- parent.getBayarContent().setBayarPoin(bayarPoin * Fucout.KONVERSI_POIN);
- parent.updateKurangBayarView();
- }
-
- }
-
- }
|