Search in sources :

Example 6 with ShangmaNextday

use of com.kendy.entity.ShangmaNextday in project financial by greatkendy123.

the class ShangmaService method addNextDaySMDetailAction.

/**
 * 实时上码新增次日上码
 *
 * @time 2018年2月4日
 */
public static void addNextDaySMDetailAction() {
    ShangmaInfo smInfo = getSelectShangma();
    if (smInfo == null) {
        ShowUtil.show("请先选择要增加次日的玩家记录!");
        return;
    }
    if (smInfo != null && smInfo.getShangmaName() != null) {
        Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle("次日上码:" + smInfo.getShangmaName());
        dialog.setHeaderText(null);
        ButtonType loginButtonType = new ButtonType("确定", ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 20, 20, 20));
        TextField shangmaJu = new TextField();
        TextField shangmaVal = new TextField();
        grid.add(new Label("第X局:"), 0, 0);
        grid.add(shangmaJu, 1, 0);
        grid.add(new Label("上码:"), 0, 1);
        grid.add(shangmaVal, 1, 1);
        Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        loginButton.setDisable(true);
        shangmaJu.textProperty().addListener((observable, oldValue, newValue) -> {
            loginButton.setDisable(newValue.trim().isEmpty());
        });
        dialog.getDialogPane().setContent(grid);
        Platform.runLater(() -> shangmaJu.requestFocus());
        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(shangmaJu.getText(), shangmaVal.getText());
            }
            return null;
        });
        Optional<Pair<String, String>> result = dialog.showAndWait();
        result.ifPresent(shangmaJuAndVal -> {
            log.info("新增次日上码:shangmaJu=" + shangmaJuAndVal.getKey() + ", shangmaVal=" + shangmaJuAndVal.getValue());
            try {
                Integer.valueOf(shangmaJuAndVal.getKey());
                Integer.valueOf(shangmaJuAndVal.getValue());
            } catch (NumberFormatException e) {
                ShowUtil.show("非法数值:" + shangmaJuAndVal.getKey() + "或" + shangmaJuAndVal.getValue() + "!");
                return;
            }
            ShangmaNextday nextday = new ShangmaNextday();
            nextday.setPlayerId(smInfo.getShangmaPlayerId());
            nextday.setPlayerName(smInfo.getShangmaName());
            nextday.setChangci(getShangmaPaiju(shangmaJuAndVal.getKey()));
            nextday.setShangma(shangmaJuAndVal.getValue());
            nextday.setTime(TimeUtil.getDateTime2());
            // 新增玩家的次日数据
            addNewRecord_nextday(tableND, nextday);
        });
    }
}
Also used : ShangmaInfo(com.kendy.entity.ShangmaInfo) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Node(javafx.scene.Node) Label(javafx.scene.control.Label) TextInputDialog(javafx.scene.control.TextInputDialog) Dialog(javafx.scene.control.Dialog) TextField(javafx.scene.control.TextField) ShangmaNextday(com.kendy.entity.ShangmaNextday) ButtonType(javafx.scene.control.ButtonType) Pair(javafx.util.Pair)

Aggregations

ShangmaNextday (com.kendy.entity.ShangmaNextday)6 ShangmaDetailInfo (com.kendy.entity.ShangmaDetailInfo)3 ShangmaInfo (com.kendy.entity.ShangmaInfo)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Insets (javafx.geometry.Insets)1 Node (javafx.scene.Node)1 ButtonType (javafx.scene.control.ButtonType)1 Dialog (javafx.scene.control.Dialog)1 Label (javafx.scene.control.Label)1 TextField (javafx.scene.control.TextField)1 TextInputDialog (javafx.scene.control.TextInputDialog)1 GridPane (javafx.scene.layout.GridPane)1 Pair (javafx.util.Pair)1