/
syunya
/
Course2026
Обзор
Документация
Войти
/
syunya
/
Course2026
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/main/java/ru.machine.service/DAO/DatabaseConnection.java
73 строки
2 KB
syunya
Create: Repair.java, Session, Update: DatabaseConnection.java
23 июн 2026, 23:45
Верифицирован
23 июн 2026, 23:45
05ea3da
Код
Авторство
О чём код?
package ru.machine.service.controller; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.event.ActionEvent; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.control.Label; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; import ru.machine.service.dao.UserDAO; import ru.machine.service.model.User; import ru.machine.service.util.Session; public class LoginController { @FXML private TextField loginField; @FXML private PasswordField passwordField; @FXML private Label messageLabel; @FXML private void login() { try { UserDAO dao = new UserDAO(); String login = loginField.getText(); String password = passwordField.getText(); User user = dao.login(login, password); if (user != null) { Session.setCurrentUser(user); // 👉 ПЕРЕХОД В МЕНЮ FXMLLoader loader = new FXMLLoader( getClass().getResource("/main_menu.fxml") ); Stage stage = (Stage) loginField.getScene().getWindow(); Scene scene = new Scene(loader.load(), 1000, 700); stage.setScene(scene); stage.setTitle("Главное меню"); } else { messageLabel.setText("Неверный логин или пароль"); } } catch (Exception ex) { ex.printStackTrace(); messageLabel.setText("Ошибка входа"); } } public void openRegister(ActionEvent actionEvent) { } }