JavaFX+MySQL实现图书管理系统(包含完整代码)

目录

一、功能介绍

1.ER图 

2.学生管理员登陆页面

3.图书馆首页

4.学生图书馆搜索界面

5.学生注册

6.管理员后台

增加书籍

查看借阅记录

​编辑

修改图书

二、功能分解

1.界面展示

2.点击按钮切换页面

普通按钮点击

复杂按钮点击

3.登录注册

创建登陆注册的页面(图为登录)

设置两个输入框的id

带有sql语句的方法

写登录页面登录按钮的点击方法

在FXML文件里设置控件点击事件

注册功能的sql语句方法

4.表格控件的绑定

实体类

表格控件的Controller类

  FXML文件

给整个表格设置id

给各列设置id

5.增、删、改

从表格选择图书并删除

修改

6.模糊查询

7.左外连接查询

三、总代码

页面类

控制器类

HelloController类

图书馆控制类

搜索页面控制类

管理员后台控制类

增加图书页面控制类

修改图书控制类

管理员查看图书借阅记录控制类

实体类

图书馆

管理员后台类

type对应type-name类

JDBC封装以及一个带有sql语句的方法的类

SQL语句方法类

JDBC封装类

FXML文件

登录

登陆失败

注册

注册失败

管理员登陆

图书馆

搜索

借书成功

借书失败

还书成功

还书失败

管理员后台

查询借阅记录

修改图书

增加图书

增加成功


一、功能介绍

1.ER图 

2.学生管理员登陆页面

3.图书馆首页

其他几个按扭点击均会出现不同类型的书

4.学生图书馆搜索界面

5.学生注册

6.管理员后台

增加书籍

查看借阅记录
修改图书

二、功能分解

1.界面展示

在HelloApplication类里,首先定义一个公共舞台 

    public static Stage primaryStage;

然后创建不同的场景,定义一个开始方法展示程序运行时展示的第一个页面

   public void start(Stage primaryStage) throws IOException {this.primaryStage = primaryStage;starScene();}

然后创建其他场景(这里举个例子):

  //学生登录public static void starScene() {try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693,460);primaryStage.setResizable(false);//设置页面大小固定primaryStage.setTitle("欢迎来到网络图书馆");primaryStage.setScene(scene);primaryStage.show();} catch (IOException e) {e.printStackTrace();}}

2.点击按钮切换页面

这个功能实现运用到了控制类 ,JavaFX项目在刚开始创建时有两个类,一个是HelloApplication另一个是HelloController中HelloApplication用于写各种方法并绑定不同的FXML文件,HelloController控制类处理用于控制FXML文件中的UI元素和处理逻辑。

在HelloController类中创建按钮点击时调用的HelloApplication的不同场景来实现页面转换,展示代码如下:

普通按钮点击
 @FXMLpublic void back5(MouseEvent mouseEvent){HelloApplication.BackScene();}

这是普通按钮点击,比如关闭按钮,完成按钮;复杂一点的按钮点击事件需要获取页面数值并传入实现对应功能的包含sql语句的方法中比如:

复杂按钮点击
    //管理员的登录按钮@FXMLpublic void Glogin(MouseEvent mouseEvent) throws SQLException{String y = usernames.getText();//获取id为usernames的textfield的数值String m = passwords.getText();Boolean ok = Student.glogin(y,m);//使用boolean类型的变量去判断sql语句方法执行的结果if(ok){HelloApplication.BackScene();//调用成功之后出现的场景}else {if (!errorDisplayed) {HelloApplication.exit();//失败后调用的页面errorDisplayed = true;}}}

失败之后应出现小弹窗类型的窗口去提醒客户输入信息有误,所以这时候不能去用HelloApplication的公共舞台,需要自己搭建一个舞台。但是此时会出现一个问题就是当信息有误的情况下,一直点击按钮这个方法不断被调用会出现很多个弹窗窗口导致程序变卡也不美观,解决办法就是在HelloController类里创建一个布尔类型的成员变量为false,如果用户输入消息是错误的情况下曾加一个if判断,用于判断成员变量的值是否不为false,如果为true则调用窗口,同时设置它的值为true(注意if语句里面是!成员变量),然后再次点击时就不会多次调用弹窗方法。

3.登录注册

登陆注册功能实现需要连接数据库

创建登陆注册的页面(图为登录)

设置两个输入框的id

带有sql语句的方法
    // login 学生登陆public static boolean login(String username ,String password) throws SQLException {String sql = "select id from library.user where name = ? and password = ? and type=0";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1, username);ps.setString(2, password);ResultSet res = ps.executeQuery();//保存查询结果的集合while (res.next()) {//res.next()是判断下一个结果是否为空,为空代表查询完毕return true;}return false;}
写登录页面登录按钮的点击方法
//学生页面的登录按钮@FXMLpublic void Booklist(MouseEvent mouseEvent) throws SQLException {u = username.getText();String p = password.getText();//SelectController selectController = new SelectController();//selectController.setValues(u);//将变量u通过这种方法传到SelectController类里//TypeController typeController = new TypeController();//typeController.setValues(u);这一部分跟登录方法没有关系Boolean ok = Student.login(u,p);if(ok){HelloApplication.BookScene();}else {if (!errorDisplayed) {HelloApplication.fail();errorDisplayed = true;}}}
在FXML文件里设置控件点击事件

此时一个登录方法就完成了。注册方法跟登陆方法差不多但是要注意在注册时需要对数据库现有数据进行判断以防止重复数据出现。

注册功能的sql语句方法
  //学生注册public static boolean slogin(String name, String npassword) throws SQLException {String sql1 = "select id from library.user where name = ? and password = ? and type=0";//学生和管理员在数据库的一张表通过type的值来区别。这句sql语句是查询库里是否存在有着一模一样的用户名和密码的数据String sql = "insert into library.user (name,password,type) values(?,?,0)";Connection conn = JDBC.getConn();PreparedStatement pg =conn.prepareStatement(sql1);PreparedStatement gp = conn.prepareStatement(sql);pg.setString(1,name);pg.setString(2,npassword);gp.setString(1, name);gp.setString(2, npassword);ResultSet re = pg.executeQuery();int up = gp.executeUpdate();//插入结果后更新的条数,如果插入成功即up不为0while (up == 0 || re.next()){//若插入失败或者查询的结果有重复的都会返回falsereturn false;}return true;}

4.表格控件的绑定

实体类

实体类里主要包括各种实例变量的定义以及get、set方法和构造函数对实例变量进行初始化,注意实例变量的类型必须是SimpleStringProperty类

 private final SimpleStringProperty name;private final SimpleStringProperty writer;private final SimpleIntegerProperty bank;public SBook(String name, String writer, int bank)  {this.name = new SimpleStringProperty(name);this.writer= new SimpleStringProperty(writer);this.bank= new SimpleIntegerProperty(bank);}public String getName() {return name.get();}public SimpleStringProperty nameProperty() {return name;}public void setName(String name) {this.name.set(name);}
表格控件的Controller类

先定义表格控以及各列的id,查询数据库的数据后返回一个结果集(结果集类型自己定义)传输到各列上面,还有一个默认方法initialize即每次进入当前页面就会刷新表格

public class TypeController {public static String n;public TableView tableView;public TableColumn name;public TableColumn writer;public TableColumn bank;public static int a;public static String k;private boolean errorDisplayed = false;public void initialize() throws SQLException {allBook();}public void allBook()throws  SQLException{String sql = "select name,writer,bank from library.book_list";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ResultSet resultSet = ps.executeQuery();ObservableList<SBook> sBookList = FXCollections.observableArrayList();while (resultSet.next()) {String sBookName=resultSet.getString("name");String sBookWriter=resultSet.getString("writer");int sBookBank = resultSet.getInt("bank");SBook sBook = new SBook(sBookName,sBookWriter,sBookBank);sBookList.add(sBook);// 设置其他属性}name.setCellValueFactory(new PropertyValueFactory<>("name"));writer.setCellValueFactory(new PropertyValueFactory<>("writer"));bank.setCellValueFactory(new PropertyValueFactory<>("bank"));tableView.setItems(sBookList);}
  FXML文件

给整个表格设置id

给各列设置id

5.增、删、改

这几个功能分别用在注册功能、借书还书功能、管理员修改功能、管理员删除功能。

从表格选择图书并删除

借书跟删除功能除了sql语句不一样大体一样,这里删除为例:

// 点击删除按钮
public void delete(MouseEvent mouseEvent) throws SQLException {// 获取表格视图的选择模型TableView.TableViewSelectionModel<GBook> selectionModel = GtableView.getSelectionModel();// 获取被选中的项的列表ObservableList<GBook> selectedItems = selectionModel.getSelectedItems();// 检查是否有选中的项if (!selectedItems.isEmpty()) {// 假设只选择了一行,获取选中的第一项GBook selectedItem = selectedItems.get(0);// 检查是否成功获取选中项if (selectedItem != null) {// 获取选中项的作者名字String writerName = selectedItem.getWriter();// 调用删除方法,传入作者名字delete(writerName);}// 从表格视图中移除选中的行ObservableList selectedRows = selectionModel.getSelectedItems();GtableView.getItems().removeAll(selectedRows);} else {// 没有选中项的情况下输出提示System.out.println("请选择一本书");}
}
修改

修改方法主要使用在管理员从图书馆后台选择书籍去对书籍的名字、作者、种类、库存进行修改。这里在选择某一行时要获取这一行图书的信息并存为成员变量,再点击修改时修改页面就会出现原有的信息。

 //管理员看到图书页面的修改按钮@FXMLpublic  void alter(MouseEvent mouseEvent){TableView.TableViewSelectionModel<GBook> selectionModel = GtableView.getSelectionModel();ObservableList<GBook> selectedItems = selectionModel.getSelectedItems();if(!selectedItems.isEmpty()){GBook selectedItem = selectedItems.get(0);if (selectedItem != null) {int i = selectedItem.getId();n = selectedItem.getName();w = selectedItem.getWriter();t = selectedItem.getType();b = selectedItem.getBank();AlterController alterController=new AlterController();alterController.setValue(n,w,t,b,i);//传入修改的页面Controller类,使TextFiled获取数据HelloApplication.AlterScene();}}else{System.out.println("请选择一本书");}}

6.模糊查询

首先使用两个成员变量储存用户输入的值,这两个变量将作为sql语句条件去查询。这里是让用户可以输入书名或者作者名或者两者综合去查询。若两个都输入这时就要筛选同时符合这两个条件的书籍,这里用了MySQL的if函数

    public void sou(MouseEvent mouseEvent) throws SQLException {b = bookname.getText();w = bookwriter.getText();loadData();}public void loadData() throws SQLException {String sql = "select name,writer,bank from library.book_list where if(? = '',true, name like ?) and if( ? = '',true,writer like ?)";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1,b);ps.setString(2,"%"+b+"%");ps.setString(3,w);ps.setString(4,"%"+w+"%");ResultSet resultSet = ps.executeQuery();ObservableList<SBook> sBookList = FXCollections.observableArrayList();while (resultSet.next()) {String sBookName=resultSet.getString("name");String sBookWriter=resultSet.getString("writer");int sBookBank = resultSet.getInt("bank");SBook sBook = new SBook(sBookName,sBookWriter,sBookBank);sBookList.add(sBook);            // 设置其他属性}name.setCellValueFactory(new PropertyValueFactory<>("name"));writer.setCellValueFactory(new PropertyValueFactory<>("writer"));bank.setCellValueFactory(new PropertyValueFactory<>("bank"));tableView.setItems(sBookList);}

7.左外连接查询

这是两表一起查询,在数据库里图书种类我用了数字代替,而在管理员后台看到的是每种数字代表的图书种类。我又额外增添一个type跟type-name对应的表。

    public void initialize() throws SQLException {loadData();}public void loadData() throws SQLException {String sql = "select * from book_list as b left join book_type as bt on b.type=bt.book_type";//查询图书数字代表的名称采用左外连接的方法Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ResultSet resultSet = ps.executeQuery();ObservableList<GBook> gBookList = FXCollections.observableArrayList();while (resultSet.next()) {String gBookName=resultSet.getString("name");String gBookWriter=resultSet.getString("writer");String gBookBank = resultSet.getString("bank");int gBookId= resultSet.getInt("id");String gBookUserName=resultSet.getString("username");String gBookType= resultSet.getString("type_name");GBook gBook = new GBook(gBookName,gBookWriter,gBookBank,gBookUserName,gBookType,gBookId);gBookList.add(gBook);// 设置其他属性}Gname.setCellValueFactory(new PropertyValueFactory<>("name"));Gwriter.setCellValueFactory(new PropertyValueFactory<>("writer"));Gbank.setCellValueFactory(new PropertyValueFactory<>("bank"));UserName.setCellValueFactory(new PropertyValueFactory<>("username"));Gtype.setCellValueFactory(new PropertyValueFactory<>("type"));GtableView.setItems(gBookList);}

三、总代码

虽然采用MVC对包进行分类但是代码并没有遵守。每个表格控件对应一个Controller类,其他功能基本在HelloController类里,带有sql的方法有的写在控制类里,有的单独写了一个类。

页面类

package com.example.controller;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;import java.io.IOException;
public class HelloApplication extends Application {public static Stage primaryStage;public void start(Stage primaryStage) throws IOException {this.primaryStage = primaryStage;starScene();}
//登陆不成功显示的画面public static void fail(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("win.fxml"));Scene scene = new Scene(fxmlLoader.load(), 500,150 );Stage stage = new Stage();stage.setResizable(false);stage.setTitle("登陆失败");stage.setScene(scene);stage.show();} catch (IOException e) {e.printStackTrace();}}//注册显示用户已存在public static void exit(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("exit.fxml"));Scene scene = new Scene(fxmlLoader.load(), 500,150 );Stage stage = new Stage();stage.setResizable(false);stage.setTitle("注册失败");stage.setScene(scene);stage.show();} catch (IOException e) {e.printStackTrace();}}//还书失败public static void backFalse(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("backfalse.fxml"));Scene scene = new Scene(fxmlLoader.load(), 500,150 );Stage stage = new Stage();stage.setResizable(false);stage.setTitle("还书失败");stage.setScene(scene);stage.show();} catch (IOException e) {e.printStackTrace();}}//还书成功public static void backWin(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("backwin.fxml"));Scene scene = new Scene(fxmlLoader.load(), 500,150 );Stage stage = new Stage();stage.setResizable(false);stage.setTitle("还书成功");stage.setScene(scene);stage.show();} catch (IOException e) {e.printStackTrace();}}//借书成功public static void last(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("Last.fxml"));Scene scene = new Scene(fxmlLoader.load(), 500,150 );Stage stage = new Stage();stage.setResizable(false);stage.setTitle("借书成功");stage.setScene(scene);stage.show();} catch (IOException e) {e.printStackTrace();}}//提醒用户还书public static void back(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("back.fxml"));Scene scene = new Scene(fxmlLoader.load(), 500,150 );Stage stage = new Stage();stage.setResizable(false);stage.setTitle("借书失败");stage.setScene(scene);stage.show();} catch (IOException e) {e.printStackTrace();}}//学生登录public static void starScene() {try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693,460);primaryStage.setResizable(false);primaryStage.setTitle("欢迎来到网络图书馆");primaryStage.setScene(scene);primaryStage.show();} catch (IOException e) {e.printStackTrace();}}//管理员登陆public static void loginScene(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("login.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693, 460);primaryStage.setResizable(false);primaryStage.setTitle("图书馆管理");primaryStage.setScene(scene);primaryStage.show();}catch (IOException e){e.printStackTrace();}}//管理员看到的后台数据public static void BackScene(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("backstage.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693, 580);primaryStage.setResizable(false);primaryStage.setTitle("后台管理");primaryStage.setScene(scene);primaryStage.show();}catch (IOException e){e.printStackTrace();}}//增加书籍public static void addBook(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("addBook.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693, 500);primaryStage.setResizable(false);primaryStage.setTitle("后台管理");primaryStage.setScene(scene);primaryStage.show();} catch (IOException e) {throw new RuntimeException(e);}}//添加成功的方法public static void Addwin(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("addwin.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693, 500);primaryStage.setResizable(false);primaryStage.setTitle("成功了");primaryStage.setScene(scene);primaryStage.show();} catch (IOException e) {throw new RuntimeException(e);}}//查看图书被借阅次数的页面public static void inBook(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("inBook.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693, 400);primaryStage.setResizable(false);primaryStage.setTitle("后台管理");primaryStage.setScene(scene);primaryStage.show();}catch (IOException e){e.printStackTrace();}}//注册的方法public static void registerScene(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("zhuce.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693, 460);primaryStage.setResizable(false);primaryStage.setTitle("注册");primaryStage.setScene(scene);primaryStage.show();} catch (IOException e) {throw new RuntimeException(e);}}//学生登陆进去后显示的图书种类public static void BookScene(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("Booktype.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693, 460);primaryStage.setResizable(false);primaryStage.setTitle("图书种类");primaryStage.setScene(scene);primaryStage.show();} catch (IOException e) {throw new RuntimeException(e);}}//管理员修改图书的页面public static void AlterScene(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("alter.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693, 400);primaryStage.setResizable(false);primaryStage.setTitle("修改");primaryStage.setScene(scene);primaryStage.show();} catch (IOException e) {throw new RuntimeException(e);}}//搜索页面public static void select(){try {FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("select.fxml"));Scene scene = new Scene(fxmlLoader.load(), 693, 515);primaryStage.setResizable(false);primaryStage.setTitle("搜索");primaryStage.setScene(scene);primaryStage.show();} catch (IOException e) {throw new RuntimeException(e);}}public static void main(String[] args) {launch(args);}
}

控制器类

HelloController类
package com.example.controller;
import com.example.dao.GBook;
import com.example.dao.JDBC;
import com.example.dao.Student;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Objects;public class HelloController {public int b;public static String u;@FXMLprivate TextField username;@FXMLprivate PasswordField password;@FXMLprivate TextField usernames;@FXMLprivate PasswordField passwords;@FXMLprivate TextField Name;@FXMLprivate PasswordField npassword;@FXMLprivate PasswordField apassword;private boolean errorDisplayed = false;public HelloController() {}//学生登陆页面的按钮点击跳转管理员登陆界面@FXMLpublic void ButtonClick(MouseEvent mouseEvent){HelloApplication.loginScene();}//管理员的登录按钮@FXMLpublic void Glogin(MouseEvent mouseEvent) throws SQLException{String y = usernames.getText();String m = passwords.getText();Boolean ok = Student.glogin(y,m);if(ok){HelloApplication.BackScene();}else {if (!errorDisplayed) {HelloApplication.exit();errorDisplayed = true;}}}//从管理员登录界面退回到学生登陆界面@FXMLpublic void back1(MouseEvent mouseEvent){HelloApplication.starScene();}//添加成功后继续添加书籍的按钮@FXMLpublic void back4(MouseEvent mouseEvent){HelloApplication.addBook();}//添加图书成功之后返回后台的按钮@FXMLpublic void back5(MouseEvent mouseEvent){HelloApplication.BackScene();}//学生页面的注册按钮@FXMLpublic void register(MouseEvent mouseEvent){HelloApplication.registerScene();}//学生页面的登录按钮@FXMLpublic void Booklist(MouseEvent mouseEvent) throws SQLException {u = username.getText();String p = password.getText();SelectController selectController = new SelectController();selectController.setValues(u);TypeController typeController = new TypeController();typeController.setValues(u);Boolean ok = Student.login(u,p);if(ok){HelloApplication.BookScene();}else {// Only display the error page if it hasn't been displayed before.if (!errorDisplayed) {HelloApplication.fail();// Set the flag to true to indicate that the error page has been displayed.errorDisplayed = true;}}}//学生页面的注册按钮@FXMLpublic void regis(MouseEvent mouseEvent) throws SQLException {String u = Name.getText();String p = npassword.getText();String a = apassword.getText();if (Objects.equals(p, a)) {Boolean ok = Student.slogin(u, p);if (ok)HelloApplication.starScene();} else {// Only display the error page if it hasn't been displayed before.if (!errorDisplayed) {HelloApplication.fail();// Set the flag to true to indicate that the error page has been displayed.errorDisplayed = true;}}}//书籍界面通过给b赋值确定图书种类@FXMLpublic void type1(MouseEvent mouseEvent){b=0;}@FXMLpublic void type2(MouseEvent mouseEvent){b=1;}@FXMLpublic void type3(MouseEvent mouseEvent){b=2;}@FXMLpublic void type4(MouseEvent mouseEvent){b=3;}
//种类界面的搜索按钮public void select(MouseEvent mouseEvent) {HelloApplication.select();}public void back7(MouseEvent mouseEvent) throws SQLException {boolean ok = backBook();if(ok){HelloApplication.backWin();}else{HelloApplication.backFalse();}}public boolean backBook() throws SQLException {String sql = "update library.user set BookName = null where name = ?";String sql2 = "update library.book_list set bank = bank+1 where UserName = ? ";String sql3 = "update library.book_list set UserName = null where UserName = ?";Connection con = JDBC.getConn();PreparedStatement ps = con.prepareStatement(sql);PreparedStatement pd = con.prepareStatement(sql2);PreparedStatement pg = con.prepareStatement(sql3);ps.setString(1,u);pd.setString(1,u);pg.setString(1,u);int rs=ps.executeUpdate();int rd = pd.executeUpdate();int rg=pg.executeUpdate();if(rs!=0 & rd!=0){if(rg!=0){return true;}else{return false;}}else {return false;}}public void back9(MouseEvent mouseEvent) {HelloApplication.starScene();}public void back10(MouseEvent mouseEvent) {HelloApplication.starScene();}
}
图书馆控制类
package com.example.controller;
import com.example.dao.JDBC;
import com.example.dao.SBook;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;public class TypeController {public static String n;public TableView tableView;public TableColumn name;public TableColumn writer;public TableColumn bank;public static int a;public static String k;private boolean errorDisplayed = false;public void initialize() throws SQLException {allBook();}public void allBook()throws  SQLException{String sql = "select name,writer,bank from library.book_list";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ResultSet resultSet = ps.executeQuery();ObservableList<SBook> sBookList = FXCollections.observableArrayList();while (resultSet.next()) {String sBookName=resultSet.getString("name");String sBookWriter=resultSet.getString("writer");int sBookBank = resultSet.getInt("bank");SBook sBook = new SBook(sBookName,sBookWriter,sBookBank);sBookList.add(sBook);// 设置其他属性}name.setCellValueFactory(new PropertyValueFactory<>("name"));writer.setCellValueFactory(new PropertyValueFactory<>("writer"));bank.setCellValueFactory(new PropertyValueFactory<>("bank"));tableView.setItems(sBookList);}public void loadData() throws SQLException {String sql = "select name,writer,bank from library.book_list where type = ?";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ps.setInt(1,a);ResultSet resultSet = ps.executeQuery();ObservableList<SBook> sBookList = FXCollections.observableArrayList();while (resultSet.next()) {String sBookName=resultSet.getString("name");String sBookWriter=resultSet.getString("writer");int sBookBank = resultSet.getInt("bank");SBook sBook = new SBook(sBookName,sBookWriter,sBookBank);sBookList.add(sBook);// 设置其他属性}name.setCellValueFactory(new PropertyValueFactory<>("name"));writer.setCellValueFactory(new PropertyValueFactory<>("writer"));bank.setCellValueFactory(new PropertyValueFactory<>("bank"));tableView.setItems(sBookList);}@FXMLpublic void type1(MouseEvent mouseEvent) throws SQLException {a=0;loadData();}@FXMLpublic void type2(MouseEvent mouseEvent) throws SQLException {a=1;loadData();}@FXMLpublic void type3(MouseEvent mouseEvent) throws SQLException {a=2;loadData();}@FXMLpublic void type4(MouseEvent mouseEvent) throws SQLException {a=3;loadData();}
//显示全部书籍public void comein(MouseEvent mouseEvent) throws Exception {initialize();}
//搜索public void select(MouseEvent mouseEvent) {HelloApplication.select();}//还书public void back7(MouseEvent mouseEvent) throws SQLException {boolean ok = backBook();if(ok){HelloApplication.backWin();allBook();}else {// Only display the error page if it hasn't been displayed before.if (!errorDisplayed) {HelloApplication.backFalse();// Set the flag to true to indicate that the error page has been displayed.errorDisplayed = true;}}}public boolean backBook() throws SQLException {String sql = "update library.user set BookName = null where name = ?";String sql2 = "update library.book_list set bank = bank+1 where UserName = ? ";String sql3 = "update library.book_list set UserName = null where UserName = ?";Connection con = JDBC.getConn();PreparedStatement ps = con.prepareStatement(sql);PreparedStatement pd = con.prepareStatement(sql2);PreparedStatement pg = con.prepareStatement(sql3);ps.setString(1,n);pd.setString(1,n);pg.setString(1,n);int rs=ps.executeUpdate();int rd = pd.executeUpdate();int rg=pg.executeUpdate();if(rs!=0 & rd!=0){if(rg!=0){return true;}else{return false;}}else {return false;}}//选好书之后public void OK(MouseEvent mouseEvent) throws SQLException {TableView.TableViewSelectionModel<SBook> selectionModel = tableView.getSelectionModel();ObservableList<SBook> selectedItems = selectionModel.getSelectedItems();if(!selectedItems.isEmpty()){SBook selectedItem = selectedItems.get(0);if(selectedItem != null){k = selectedItem.getName();}}else{System.out.println("请选择一本书");}String sql3 = "select BookName from library.user where name=?";Connection conn = JDBC.getConn();PreparedStatement pb = conn.prepareStatement(sql3);pb.setString(1, n);ResultSet rs = pb.executeQuery();String bk =null;while(rs.next()){bk=rs.getString("BookName");}if (bk ==null) {boolean ok = addName();boolean kc = bank();if(ok & kc){HelloApplication.last();allBook();}else{HelloApplication.back();}}}public boolean addName() throws SQLException {String sql = "update library.book_list set UserName = ? where name = ?";String sql2 = "update library.user set BookName = ? where name = ?";String sql3="insert into library.book_name (BookName,name) values(?,?)";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);PreparedStatement pg = conn.prepareStatement(sql2);PreparedStatement gp = conn.prepareStatement(sql3);ps.setString(1,n);ps.setString(2,k);pg.setString(1,k);pg.setString(2,n);gp.setString(1,k);gp.setString(2,n);int rs = ps.executeUpdate();int rg = pg.executeUpdate();int rp = gp.executeUpdate();if(rs != 0 & rg !=0 & rp != 0){return true;}return false;}public boolean bank() throws SQLException{String sql ="update library.book_list set bank = bank-1 where name = ?";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1,k);int t = ps.executeUpdate();if (t != 0){return true;}return false;}
//返回登陆页面public void back9(MouseEvent mouseEvent) {HelloApplication.starScene();}public void setValues(String u) {n=u;}
}
搜索页面控制类
package com.example.controller;
import com.example.dao.JDBC;
import com.example.dao.SBook;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class SelectController {@FXMLprivate TableView tableView;@FXMLprivate TableColumn name;@FXMLprivate TableColumn writer;@FXMLprivate TableColumn bank;@FXMLprivate TextField bookname;@FXMLprivate TextField bookwriter;public String b;public String w;public static String n;public static String k;public void back7(MouseEvent mouseEvent) {HelloApplication.BookScene();}public void sou(MouseEvent mouseEvent) throws SQLException {b = bookname.getText();w = bookwriter.getText();loadData();}public void loadData() throws SQLException {String sql = "select name,writer,bank from library.book_list where if(? = '',true, name like ?) and if( ? = '',true,writer like ?)";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1,b);ps.setString(2,"%"+b+"%");ps.setString(3,w);ps.setString(4,"%"+w+"%");ResultSet resultSet = ps.executeQuery();ObservableList<SBook> sBookList = FXCollections.observableArrayList();while (resultSet.next()) {String sBookName=resultSet.getString("name");String sBookWriter=resultSet.getString("writer");int sBookBank = resultSet.getInt("bank");SBook sBook = new SBook(sBookName,sBookWriter,sBookBank);sBookList.add(sBook);            // 设置其他属性}name.setCellValueFactory(new PropertyValueFactory<>("name"));writer.setCellValueFactory(new PropertyValueFactory<>("writer"));bank.setCellValueFactory(new PropertyValueFactory<>("bank"));tableView.setItems(sBookList);}public void last(MouseEvent mouseEvent)throws SQLException {TableView.TableViewSelectionModel<SBook> selectionModel = tableView.getSelectionModel();ObservableList<SBook> selectedItems = selectionModel.getSelectedItems();if(!selectedItems.isEmpty()){SBook selectedItem = selectedItems.get(0);if(selectedItem != null){k = selectedItem.getName();}}else {System.out.println("请选择一本书");}String sql = "select BookName from library.user where name = ?";String sql3 = "select bank from library.book_list where name=?";String sql2 ="insert into library.book_name (BookName,name) values(?,?)";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);PreparedStatement pb = conn.prepareStatement(sql3);PreparedStatement pg = conn.prepareStatement(sql2);ps.setString(1, n);pb.setString(1, k);pg.setString(1,k);pg.setString(2,n);ResultSet re = ps.executeQuery();ResultSet rs = pb.executeQuery();int rg=pg.executeUpdate();String bn = null;int bk = 0;while (rs.next()&re.next()&rg!=0) {bk = rs.getInt("bank");bn=re.getString("BookName");}if (bk != 0 &bn ==null) {boolean ok = addName();boolean kc = bank();if(ok & kc){HelloApplication.last();}} else {HelloApplication.back();}}public boolean addName() throws SQLException {String sql = "update library.book_list set UserName = ? where name = ?";String sql2 = "update library.user set BookName = ? where name = ?";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);PreparedStatement pg = conn.prepareStatement(sql2);ps.setString(1,n);ps.setString(2,k);pg.setString(1,k);pg.setString(2,n);int rs = ps.executeUpdate();int rg = pg.executeUpdate();if(rs != 0 & rg !=0){return true;}return false;}public boolean bank() throws SQLException{String sql ="update library.book_list set bank = bank-1 where name = ?";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1,k);int t = ps.executeUpdate();if (t != 0){return true;}return false;}public void setValues(String u) {n=u;}
}
管理员后台控制类
package com.example.controller;
import com.example.dao.GBook;
import com.example.dao.JDBC;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;public class GbookController {public TableView GtableView;public TableColumn Gname;public TableColumn Gwriter;public TableColumn Gbank;public TableColumn Gtype;public TableColumn UserName;private static String n;public static String w;public static String t;public static String b;public void initialize() throws SQLException {loadData();}public void loadData() throws SQLException {String sql = "select * from book_list as b left join book_type as bt on b.type=bt.book_type";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ResultSet resultSet = ps.executeQuery();ObservableList<GBook> gBookList = FXCollections.observableArrayList();while (resultSet.next()) {String gBookName=resultSet.getString("name");String gBookWriter=resultSet.getString("writer");String gBookBank = resultSet.getString("bank");int gBookId= resultSet.getInt("id");String gBookUserName=resultSet.getString("username");String gBookType= resultSet.getString("type_name");GBook gBook = new GBook(gBookName,gBookWriter,gBookBank,gBookUserName,gBookType,gBookId);gBookList.add(gBook);// 设置其他属性}Gname.setCellValueFactory(new PropertyValueFactory<>("name"));Gwriter.setCellValueFactory(new PropertyValueFactory<>("writer"));Gbank.setCellValueFactory(new PropertyValueFactory<>("bank"));UserName.setCellValueFactory(new PropertyValueFactory<>("username"));Gtype.setCellValueFactory(new PropertyValueFactory<>("type"));GtableView.setItems(gBookList);}//删除的方法public Boolean delete(String writer)throws SQLException {String sql="delete from library.book_list where writer = ? ";Connection con = JDBC.getConn();PreparedStatement ps = con.prepareStatement(sql);ps.setString(1,writer);int r = ps.executeUpdate();if(r != 0){return true;}return false;}@FXMLpublic void back2(MouseEvent mouseEvent){HelloApplication.loginScene();}//点击删除按钮public void delete(MouseEvent mouseEvent) throws SQLException {TableView.TableViewSelectionModel<GBook> selectionModel = GtableView.getSelectionModel();ObservableList<GBook> selectedItems = selectionModel.getSelectedItems();if(!selectedItems.isEmpty()){GBook selectedItem = selectedItems.get(0); // 假设只选择了一行if (selectedItem != null) {String s = selectedItem.getWriter();delete(s);}ObservableList selectedRows = selectionModel.getSelectedItems();GtableView.getItems().removeAll(selectedRows);}else{System.out.println("请选择一本书");}}//添加图书@FXMLpublic void AddBook(MouseEvent mouseEvent) throws SQLException {HelloApplication.addBook();}//管理员看到图书页面的修改按钮@FXMLpublic  void alter(MouseEvent mouseEvent){TableView.TableViewSelectionModel<GBook> selectionModel = GtableView.getSelectionModel();ObservableList<GBook> selectedItems = selectionModel.getSelectedItems();if(!selectedItems.isEmpty()){GBook selectedItem = selectedItems.get(0);if (selectedItem != null) {int i = selectedItem.getId();n = selectedItem.getName();w = selectedItem.getWriter();t = selectedItem.getType();b = selectedItem.getBank();AlterController alterController=new AlterController();alterController.setValue(n,w,t,b,i);HelloApplication.AlterScene();}}else{System.out.println("请选择一本书");}}
//点击查看书籍详情public void look(MouseEvent mouseEvent) {TableView.TableViewSelectionModel<GBook> selectionModel = GtableView.getSelectionModel();ObservableList<GBook> selectedItems = selectionModel.getSelectedItems();if (!selectedItems.isEmpty()) {GBook selectedItem = selectedItems.get(0);if (selectedItem != null) {String s = selectedItem.getName();InbookController inbookController = new InbookController();inbookController.setValue(s);HelloApplication.inBook();}} else {System.out.println("No item is selected.");}}
}
增加图书页面控制类
package com.example.controller;import com.example.dao.GBook;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;import java.sql.SQLException;public class AddbookController {@FXMLprivate TextField Aname;@FXMLprivate TextField Awriter;@FXMLprivate TextField Atype;@FXMLpublic void addwin(MouseEvent mouseEvent) throws SQLException {String n = Aname.getText();String w = Awriter.getText();String t = Atype.getText();Boolean ok = GBook.addBook(n,w,t);if(ok){HelloApplication.Addwin();}}@FXMLpublic void back3(MouseEvent mouseEvent){HelloApplication.BackScene();}
}
修改图书控制类
package com.example.controller;
import com.example.dao.JDBC;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class AlterController {public TextField Xname;public TextField Xwriter;public TextField Xtype;public TextField Xbank;public static String u;public static String r;public static String y;public static int i;public static String s;public static String m;public void initialize() throws SQLException {setValue(u,r,y,s,i);Xname.setText(u);Xwriter.setText(r);Xtype.setText(y);Xbank.setText(s);}public void setValue(String a,String b,String c,String e,int d){u=a;r=b;y=c;s=e;i=d;}public boolean alter(String XName,String XWriter,String XType,String Xbank) throws SQLException {String sql1="select book_type from library.book_type where type_name = ?";String sql = "update library.book_list set name=?,writer=? ,type=?,bank=? where id= ? ";Connection con= JDBC.getConn();PreparedStatement pg=con.prepareStatement(sql1);PreparedStatement ps = con.prepareStatement(sql);pg.setString(1,XType);ResultSet re = pg.executeQuery();while (re.next()){m= re.getString("book_type");}ps.setString(1,XName);ps.setString(2,XWriter);ps.setString(3,m);ps.setString(4,Xbank);ps.setInt(5,i);int rs = ps.executeUpdate();if(rs ==0){return false;}return true;}public void finish(MouseEvent mouseEvent) throws SQLException {String m = Xname.getText();String r = Xwriter.getText();String p = Xtype.getText();String q = Xbank.getText();boolean ok =  alter(m,r,p,q);if(ok) {HelloApplication.BackScene();}else{HelloApplication.last();}}public void back8(MouseEvent mouseEvent) {HelloApplication.BackScene();}
}
管理员查看图书借阅记录控制类
package com.example.controller;
import com.example.dao.BookName;
import com.example.dao.JDBC;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;public class InbookController {public static String r;@FXMLprivate TableView BtableView;@FXMLprivate TableColumn Bookname;@FXMLprivate  TableColumn Bname;public void setValue(String s){r=s;}public void initialize() throws SQLException {loadData();}public void loadData() throws SQLException {String sql = "select BookName,name from library.book_name where BookName = ?";Connection conn = JDBC.getConn();PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1,r);ResultSet resultSet = ps.executeQuery();ObservableList<BookName> BookList = FXCollections.observableArrayList();while (resultSet.next()) {String gBookName=resultSet.getString("BookName");String gBookUserName=resultSet.getString("name");BookName Book = new BookName(gBookName,gBookUserName);BookList.add(Book);// 设置其他属性}Bookname.setCellValueFactory(new PropertyValueFactory<>("name"));Bname.setCellValueFactory(new PropertyValueFactory<>("username"));BtableView.setItems(BookList);}public void back11(MouseEvent mouseEvent) {HelloApplication.BackScene();}
}

实体类

图书馆
package com.example.dao;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
public class SBook {private final SimpleStringProperty name;private final SimpleStringProperty writer;private final SimpleIntegerProperty bank;public SBook(String name, String writer, int bank)  {this.name = new SimpleStringProperty(name);this.writer= new SimpleStringProperty(writer);this.bank= new SimpleIntegerProperty(bank);}public String getName() {return name.get();}public SimpleStringProperty nameProperty() {return name;}public void setName(String name) {this.name.set(name);}public String getWriter(){return writer.get();}public SimpleStringProperty writerProperty() {return writer;}public void setWriter(String writer) {this.writer.set(writer);}public SimpleIntegerProperty bankProperty() {return bank;}public void setBank(int bank) {this.bank.set(bank);}public int getBank(){return bank.get();}}
管理员后台类
package com.example.dao;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class GBook {private final SimpleStringProperty name;private final SimpleStringProperty writer;private final SimpleStringProperty username;private final SimpleStringProperty bank;private final SimpleStringProperty type;private final SimpleIntegerProperty id;public GBook(String name, String writer, String bank,String username ,String type,int id)  {this.name = new SimpleStringProperty(name);this.writer= new SimpleStringProperty(writer);this.bank= new SimpleStringProperty(bank);this.id= new SimpleIntegerProperty(id);this.username= new SimpleStringProperty(username);this.type= new SimpleStringProperty(type);}public String getName() {return name.get();}public SimpleStringProperty nameProperty() {return name;}public void setName(String name) {this.name.set(name);}public String getWriter(){return writer.get();}public SimpleStringProperty writerProperty() {return writer;}public void setWriter(String writer) {this.writer.set(writer);}public SimpleStringProperty bankProperty() {return bank;}public void setBank(String bank) {this.bank.set(bank);}public String getBank(){return bank.get();}public String getUsername(){return username.get();}public SimpleStringProperty usernameProperty() {return username;}public void setUsername(String username) {this.username.set(username);}public SimpleStringProperty typeProperty() {return type;}public SimpleIntegerProperty idProperty() {return id;}public void setId(int id) {this.id.set(id);}public int getId(){return id.get();}public void setType(String type) {this.type.set(type);}public String getType(){return type.get();}public static boolean addBook(String Aname,String Awriter,String Atype) throws SQLException {String sql1="select name,writer from library.book_list where name =? and writer = ?";String sql = "insert into library.book_list (name,writer,bank,type) values(?,?,1,?)";Connection conn = JDBC.getConn();PreparedStatement pg = conn.prepareStatement(sql1);PreparedStatement gp = conn.prepareStatement(sql);pg.setString(1,Aname);pg.setString(2,Awriter);gp.setString(1,Aname);gp.setString(2,Awriter);gp.setString(3,Atype);ResultSet re=pg.executeQuery();int up=gp.executeUpdate();if(up ==0 && re.next()){System.out.println("增加失败");return false;}return true;}
}
type对应type-name类
package com.example.dao;
import javafx.beans.property.SimpleStringProperty;public class BookName{private final SimpleStringProperty name;private final SimpleStringProperty username;public BookName(String name, String username) {this.name = new SimpleStringProperty(name);this.username = new SimpleStringProperty(username);}public String getName() {return name.get();}public SimpleStringProperty nameProperty() {return name;}public void setName(String name) {this.name.set(name);}public String getUsername(){return username.get();}public SimpleStringProperty usernameProperty() {return username;}public void setUsername(String username) {this.username.set(username);}
}
JDBC封装以及一个带有sql语句的方法的类
SQL语句方法类
package com.example.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.example.dao.JDBC;
import static com.example.dao.JDBC.getConn;public class Student {// login 学生登陆public static boolean login(String username ,String password) throws SQLException {String sql = "select id from library.user where name = ? and password = ? and type=0";Connection conn = getConn();PreparedStatement ps = conn.prepareStatement(sql);ps.setString(1, username);ps.setString(2, password);ResultSet res = ps.executeQuery();while (res.next()) {return true;}return false;}public static boolean glogin(String usernames, String passwords) throws SQLException {String sql = "select id from library.user where name = ? and password = ? and type=1";Connection conn = getConn();PreparedStatement gp = conn.prepareStatement(sql);gp.setString(1, usernames);gp.setString(2, passwords);ResultSet res =  gp.executeQuery();while (res.next()) {return true;}return false;}public static boolean slogin(String name, String npassword) throws SQLException {String sql1 = "select id from library.user where name = ? and password = ? and type=0";String sql = "insert into library.user (name,password,type) values(?,?,0)";Connection conn = getConn();PreparedStatement pg =conn.prepareStatement(sql1);PreparedStatement gp = conn.prepareStatement(sql);pg.setString(1,name);pg.setString(2,npassword);gp.setString(1, name);gp.setString(2, npassword);ResultSet re = pg.executeQuery();int up = gp.executeUpdate();while (up ==0 || re.next()){return false;}return true;}
}
JDBC封装类
package com.example.dao;
import java.sql.*;
import java.util.Objects;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;public class JDBC {/*** URL地址*/private static final String URL = "jdbc:mysql://127.0.0.1:3306/library?useSSL=false";/*** 登录数据库服务器的账号*/private static final String USER = "root";/*** 登录数据库服务器的密码*/private static final String PASSWORD = "*******";//换为自己的数据库密码/*** 返回数据库连接对象** @return*/public static Connection getConn() {try {return DriverManager.getConnection(URL, USER, PASSWORD);} catch (SQLException e) {e.printStackTrace();}return null;}/*** 关闭资源** @param rs* @param stat* @param conn*/public static void close(ResultSet rs, Statement stat, Connection conn) {try {if (rs != null) {rs.close();}if (stat != null) {stat.close();}if (conn != null) {conn.close();}} catch (SQLException e) {e.printStackTrace();}}/*** 封装通用的更新操作(即通过该方法实现对弈任意数据表的insert,update,delete操作)** @param sql    需要执行的SQL语句* @param params 执行SQL语句时需要传递进去参数* @return 执行结果*/public static boolean exeUpdate(String sql, Object... params) {//获取连接对象Connection conn = getConn();PreparedStatement ps = null;try {//获取预编译对象ps = conn.prepareStatement(sql);//执行参数赋值操作if (Objects.nonNull(params)) {//循环将所有的参数赋值for (int i = 0; i < params.length; i++) {ps.setObject(i + 1, params[i]);}}//执行更新return ps.executeUpdate() > 0;} catch (SQLException e) {e.printStackTrace();} finally {//关闭资源close(null, ps, conn);}return false;}}
FXML文件
登录
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="468.0" prefWidth="705.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.controller.HelloController"><children><ImageView fitHeight="468.0" fitWidth="723.0" layoutY="2.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Button fx:id="login" layoutX="156.0" layoutY="361.0" mnemonicParsing="false" onMouseClicked="#Booklist" prefHeight="27.0" prefWidth="90.0" text="login" textFill="#691818" /><Label contentDisplay="CENTER" layoutX="246.0" layoutY="74.0" prefHeight="52.0" prefWidth="115.0" text="Welcome"><font><Font size="23.0" /></font></Label><Label layoutX="130.0" layoutY="189.0" prefHeight="27.0" prefWidth="115.0" text="Student ID:"><font><Font size="20.0" /></font></Label><Label layoutX="100.0" layoutY="242.0" /><Label layoutX="134.0" layoutY="280.0" prefHeight="27.0" prefWidth="108.0" text="Password:"><font><Font size="20.0" /></font></Label><PasswordField fx:id="password" layoutX="345.0" layoutY="280.0" prefHeight="27.0" prefWidth="161.0" promptText="请输入密码" /><Button layoutX="573.0" layoutY="74.0" mnemonicParsing="false" onMouseClicked="#ButtonClick" prefHeight="35.0" prefWidth="34.0" style="-fx-background-color: powderblue;" text="管" textFill="#691818" textOverrun="CLIP" /><TextField fx:id="username" layoutX="345.0" layoutY="189.0" prefHeight="27.0" prefWidth="161.0" promptText="请输入账号" /><Button layoutX="426.0" layoutY="361.0" mnemonicParsing="false" onMouseClicked="#register" prefHeight="27.0" prefWidth="90.0" text="sign in" /></children>
</AnchorPane>
登陆失败
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="115.0" prefWidth="463.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1"><children><ImageView fitHeight="540.0" fitWidth="744.0" layoutX="-230.0" layoutY="-141.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Label layoutX="99.0" layoutY="42.0" prefHeight="44.0" prefWidth="467.0" text="请输入正确信息"><font><Font size="34.0" /></font></Label></children>
</AnchorPane>
注册
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane prefHeight="468.0" prefWidth="705.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.controller.HelloController"><children><ImageView fitHeight="475.0" fitWidth="737.0" layoutY="-4.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Button layoutX="321.0" layoutY="382.0" mnemonicParsing="false" onMouseClicked="#regis" prefHeight="27.0" prefWidth="70.0" text="注册" /><Label layoutX="179.0" layoutY="156.0" text="姓名:"><font><Font size="20.0" /></font></Label><Label layoutX="178.0" layoutY="232.0" text="密码:"><font><Font size="20.0" /></font></Label><Label layoutX="152.0" layoutY="293.0" text="确认密码:"><font><Font size="20.0" /></font></Label><PasswordField fx:id="npassword" layoutX="350.0" layoutY="234.0" /><PasswordField fx:id="apassword" layoutX="350.0" layoutY="295.0" /><TextField fx:id="Name" layoutX="350.0" layoutY="170.0" /><Button layoutX="523.0" layoutY="106.0" mnemonicParsing="false" onMouseClicked="#back10" prefHeight="23.0" prefWidth="30.0" text="X" /></children>
</AnchorPane>
注册失败
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="115.0" prefWidth="463.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1"><children><ImageView fitHeight="540.0" fitWidth="744.0" layoutX="-230.0" layoutY="-141.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Label layoutX="99.0" layoutY="42.0" prefHeight="44.0" prefWidth="467.0" text="用户已存在"><font><Font size="34.0" /></font></Label></children>
</AnchorPane>
管理员登陆
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="468.0" prefWidth="705.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.controller.HelloController"><children><ImageView fitHeight="476.0" fitWidth="721.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Label contentDisplay="CENTER" layoutX="196.0" layoutY="167.0" prefHeight="30.0" prefWidth="69.0" text="账号:"><font><Font size="23.0" /></font></Label><Label layoutX="196.0" layoutY="246.0" text="密码:"><font><Font size="23.0" /></font></Label><TextField fx:id="usernames" layoutX="353.0" layoutY="166.0" prefHeight="32.0" prefWidth="183.0" /><PasswordField fx:id="passwords" layoutX="353.0" layoutY="245.0" prefHeight="32.0" prefWidth="183.0" /><Label layoutX="277.0" layoutY="105.0" prefHeight="32.0" prefWidth="123.0" text="管理员你好"><font><Font size="24.0" /></font></Label><Button fx:id="glogin" layoutX="302.0" layoutY="314.0" mnemonicParsing="false" onMouseClicked="#Glogin" prefHeight="32.0" prefWidth="73.0" text="登陆" /><Button layoutX="583.0" layoutY="30.0" mnemonicParsing="false" onMouseClicked="#back1" prefHeight="32.0" prefWidth="31.0" style="-fx-background-color: powderblue;" text="X" textFill="#691818" /></children>
</Pane>
图书馆
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?><AnchorPane prefHeight="428.0" prefWidth="693.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.controller.TypeController"><children><ImageView fitHeight="499.0" fitWidth="749.0" layoutX="-13.0" layoutY="-35.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Button layoutX="26.0" layoutY="57.0" mnemonicParsing="false" onMouseClicked="#type1" prefHeight="37.0" prefWidth="66.0" text="历史小说" /><Button layoutX="26.0" layoutY="195.0" mnemonicParsing="false" onMouseClicked="#type3" prefHeight="37.0" prefWidth="66.0" text="霸道总裁" /><Button layoutX="26.0" layoutY="267.0" mnemonicParsing="false" onMouseClicked="#type4" prefHeight="37.0" prefWidth="66.0" text="悬疑探案" /><Button layoutX="26.0" layoutY="124.0" mnemonicParsing="false" onMouseClicked="#type2" prefHeight="37.0" prefWidth="66.0" text="仙侠玄幻" /><Button layoutX="24.0" layoutY="339.0" mnemonicParsing="false" onMouseClicked="#comein" prefHeight="37.0" prefWidth="66.0" text="全部" /><Button layoutX="507.0" layoutY="29.0" mnemonicParsing="false" onMouseClicked="#select" prefHeight="37.0" prefWidth="66.0" text="搜索" /><Button layoutX="201.0" layoutY="29.0" mnemonicParsing="false" onMouseClicked="#back7" prefHeight="37.0" prefWidth="66.0" text="还书" /><Button layoutX="587.0" layoutY="2.0" mnemonicParsing="false" onMouseClicked="#back9" prefHeight="23.0" prefWidth="35.0" text="X" /><TableView fx:id="tableView" layoutX="165.0" layoutY="85.0" prefHeight="311.0" prefWidth="470.0"><columns><TableColumn fx:id="name" prefWidth="203.99996948242188" text="书籍名" /><TableColumn fx:id="writer" prefWidth="187.3333740234375" text="作者" /><TableColumn fx:id="bank" prefWidth="78.0" text="库存" /></columns></TableView><Button layoutX="367.0" layoutY="412.0" mnemonicParsing="false" onMouseClicked="#OK" prefHeight="37.0" prefWidth="66.0" text="选好了" /></children>
</AnchorPane>
搜索
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><Pane prefHeight="656.0" prefWidth="628.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.controller.SelectController"><children><ImageView fitHeight="669.0" fitWidth="993.0" layoutX="-206.0" layoutY="-7.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><TableView fx:id="tableView" layoutX="137.0" layoutY="105.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="371.0" prefWidth="409.0"><columns><TableColumn fx:id="name" prefWidth="145.3333282470703" text="书籍名" /><TableColumn fx:id="writer" prefWidth="126.0" text="作者" /><TableColumn fx:id="bank" prefWidth="136.0" text="库存" /></columns></TableView><Label layoutX="266.0" layoutY="14.0" prefHeight="33.0" prefWidth="184.0" text="欢迎来到网上图书馆"><font><Font size="20.0" /></font></Label><Button layoutX="504.0" layoutY="19.0" mnemonicParsing="false" onMouseClicked="#back7" text="返回" /><Button layoutX="316.0" layoutY="491.0" mnemonicParsing="false" onMouseClicked="#last" text="选好了" /><TextField fx:id="bookname" layoutX="191.0" layoutY="61.0" prefHeight="23.0" prefWidth="124.0" /><TextField fx:id="bookwriter" layoutX="388.0" layoutY="62.0" prefHeight="23.0" prefWidth="124.0" /><Label layoutX="130.0" layoutY="61.0" prefHeight="24.0" prefWidth="61.0" text="书名:"><font><Font size="18.0" /></font></Label><Label layoutX="331.0" layoutY="61.0" text="作者:"><font><Font size="18.0" /></font></Label><Button layoutX="524.0" layoutY="62.0" mnemonicParsing="false" onMouseClicked="#sou" prefHeight="23.0" prefWidth="28.0" text="搜" /></children>
</Pane>
借书成功
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="115.0" prefWidth="463.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1"><children><ImageView fitHeight="540.0" fitWidth="744.0" layoutX="-230.0" layoutY="-141.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Label layoutX="99.0" layoutY="42.0" prefHeight="44.0" prefWidth="467.0" text="借书成功"><font><Font size="34.0" /></font></Label></children>
</AnchorPane>
借书失败
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="115.0" prefWidth="463.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1"><children><ImageView fitHeight="433.0" fitWidth="744.0" layoutX="-170.0" layoutY="-101.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Label layoutX="24.0" layoutY="14.0" prefHeight="44.0" prefWidth="467.0" text="1.请先还书"><font><Font size="34.0" /></font></Label><Label layoutX="24.0" layoutY="71.0" prefHeight="44.0" prefWidth="393.0" text="2.没有库存请耐心等待"><font><Font size="34.0" /></font></Label></children>
</AnchorPane>
还书成功
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?><?import javafx.scene.image.*?><?import javafx.scene.layout.*?><?import javafx.scene.text.*?><AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="115.0" prefWidth="463.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1">
<children><ImageView fitHeight="540.0" fitWidth="744.0" layoutX="-230.0" layoutY="-141.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Label layoutX="99.0" layoutY="42.0" prefHeight="44.0" prefWidth="467.0" text="还书成功"><font><Font size="34.0" /></font></Label>
</children>
</AnchorPane>
还书失败
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="115.0" prefWidth="463.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1"><children><ImageView fitHeight="540.0" fitWidth="744.0" layoutX="-230.0" layoutY="-141.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Label layoutX="99.0" layoutY="42.0" prefHeight="44.0" prefWidth="467.0" text="还书失败,请先借书"><font><Font size="34.0" /></font></Label></children>
</AnchorPane>
管理员后台
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane prefHeight="552.0" prefWidth="697.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.controller.GbookController"><children><ImageView fitHeight="690.0" fitWidth="967.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><TableView fx:id="GtableView" layoutX="146.0" layoutY="118.0" prefHeight="410.0" prefWidth="398.0"><columns><TableColumn fx:id="Gname" prefWidth="111.0" text="书籍名" /><TableColumn fx:id="Gwriter" prefWidth="93.66665649414062" text="作者" /><TableColumn fx:id="UserName" prefWidth="91.00003051757812" text="借阅人" /><TableColumn fx:id="Gbank" prefWidth="56.0" text="库存" /><TableColumn fx:id="Gtype" prefWidth="43.6666259765625" text="种类" /></columns></TableView><Button layoutX="484.0" layoutY="70.0" mnemonicParsing="false" onMouseClicked="#AddBook" text="增加书籍" /><Label layoutX="287.0" layoutY="40.0" text="欢迎管理员"><font><Font size="23.0" /></font></Label><Button layoutX="510.0" layoutY="28.0" mnemonicParsing="false" onMouseClicked="#back2" prefHeight="23.0" prefWidth="26.0" style="-fx-background-color: powderblue;" text="X" textFill="#691818" /><Button layoutX="157.0" layoutY="549.0" mnemonicParsing="false" onMouseClicked="#alter" text="修改" /><Button layoutX="484.0" layoutY="549.0" mnemonicParsing="false" onMouseClicked="#delete" text="删除" /><Button layoutX="325.0" layoutY="549.0" mnemonicParsing="false" onMouseClicked="#look" prefHeight="16.0" prefWidth="40.0" text="查看" /></children>
</AnchorPane>
查询借阅记录
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?><AnchorPane prefHeight="444.0" prefWidth="668.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.controller.InbookController"><children><ImageView fitHeight="444.0" fitWidth="679.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><TableView fx:id="BtableView" layoutX="140.0" layoutY="103.0" prefHeight="297.0" prefWidth="423.0"><columns><TableColumn fx:id="Bookname" prefWidth="200.6666488647461" text="书名" /><TableColumn fx:id="Bname" prefWidth="222.00003051757812" text="借阅人" /></columns></TableView><Button layoutX="546.0" layoutY="48.0" mnemonicParsing="false" onMouseClicked="#back11" prefHeight="23.0" prefWidth="36.0" text="X" /></children>
</AnchorPane>
修改图书
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane prefHeight="470.0" prefWidth="699.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.controller.AlterController"><children><ImageView fitHeight="477.0" fitWidth="704.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Button layoutX="303.0" layoutY="351.0" mnemonicParsing="false" onMouseClicked="#finish" prefHeight="34.0" prefWidth="51.0" text="确定" /><Label layoutX="240.0" layoutY="113.0" prefHeight="28.0" prefWidth="63.0" text="书名:"><font><Font size="21.0" /></font></Label><Label layoutX="219.0" layoutY="175.0" text="作者名:"><font><Font size="21.0" /></font></Label><TextField fx:id="Xname" layoutX="378.0" layoutY="113.0" prefHeight="28.0" prefWidth="161.0" promptText="请输入正确信息" /><TextField fx:id="Xwriter" layoutX="378.0" layoutY="175.0" prefHeight="28.0" prefWidth="161.0" promptText="请输入正确信息" /><Label layoutX="238.0" layoutY="227.0" text="种类:"><font><Font size="21.0" /></font></Label><TextField fx:id="Xtype" layoutX="378.0" layoutY="227.0" prefHeight="28.0" prefWidth="161.0" promptText="请输入文字" /><Button layoutX="568.0" layoutY="51.0" mnemonicParsing="false" onMouseClicked="#back8" prefHeight="23.0" prefWidth="34.0" text="X" /><Label layoutX="240.0" layoutY="290.0" text="库存:"><font><Font size="21.0" /></font></Label><TextField fx:id="Xbank" layoutX="378.0" layoutY="290.0" prefHeight="28.0" prefWidth="161.0" promptText="请输入数字" /><Label layoutX="270.0" layoutY="44.0" text="修改图书"><font><Font size="29.0" /></font></Label></children>
</AnchorPane>
增加图书
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane prefHeight="473.0" prefWidth="730.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.controller.AddbookController"><children><ImageView fitHeight="501.0" fitWidth="739.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Label layoutX="296.0" layoutY="93.0" text="添加书籍"><font><Font size="23.0" /></font></Label><Label layoutX="178.0" layoutY="170.0" text="书名:"><font><Font size="22.0" /></font></Label><Label layoutX="188.0" layoutY="246.0" text="作者:"><font><Font size="22.0" /></font></Label><TextField fx:id="Aname" layoutX="362.0" layoutY="177.0" prefHeight="30.0" prefWidth="161.0" /><TextField fx:id="Awriter" layoutX="362.0" layoutY="246.0" prefHeight="30.0" prefWidth="161.0" /><Button layoutX="484.0" layoutY="386.0" mnemonicParsing="false" onMouseClicked="#addwin" prefHeight="29.0" prefWidth="51.0" text="OK" /><Button layoutX="535.0" layoutY="81.0" mnemonicParsing="false" onMouseClicked="#back3" text="返回" /><Label layoutX="188.0" layoutY="317.0" text="种类:"><font><Font size="22.0" /></font></Label><TextField fx:id="Atype" layoutX="362.0" layoutY="313.0" prefHeight="30.0" prefWidth="161.0" /></children>
</AnchorPane>
增加成功
<?xml version="1.0" encoding="UTF-8"?><?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?><AnchorPane prefHeight="412.0" prefWidth="619.0" xmlns="http://javafx.com/javafx/11.0.14-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.controller.HelloController"><children><ImageView fitHeight="417.0" fitWidth="714.0" layoutY="-5.0" pickOnBounds="true" preserveRatio="true"><image><Image url="file:/C:/Users/Lenovo/Desktop/sea.jpg" /></image></ImageView><Label layoutX="237.0" layoutY="104.0" text="添加成功"><font><Font size="38.0" /></font></Label><Button layoutX="169.0" layoutY="252.0" mnemonicParsing="false" onMouseClicked="#back4" prefHeight="35.0" prefWidth="67.0" text="继续添加" /><Button layoutX="427.0" layoutY="252.0" mnemonicParsing="false" onMouseClicked="#back5" prefHeight="35.0" prefWidth="67.0" text="返回" /></children>
</AnchorPane>

OK写完了,里面还有很多小瑕疵,修改图书时不能把图书修改的跟数据库现存的一样,以及修改图书还是要填写数字。欢迎大家来评论区探讨!!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/47063.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

逆向学习思路链接分享

学好逆向先学C 然后我们需要学习好 编码问题CTF常见编码及加解密&#xff08;超全&#xff09; - ruoli-s - 博客园 (cnblogs.com) 并且规划好学习路线 CTF逆向Reverse入门学习路线&#xff08;面向小白&#xff09;_逆向reverse 思路-CSDN博客 并且安好反编译的环境 x64d…

【教学类-67-02】20240716毛毛虫ABB排序

背景需求&#xff1a; 【教学类-67-01】20240715毛毛虫AB排序-CSDN博客文章浏览阅读584次&#xff0c;点赞16次&#xff0c;收藏6次。【教学类-67-01】20240715毛毛虫AB排序https://blog.csdn.net/reasonsummer/article/details/140443310 在AB排序基础上&#xff0c;继续制作…

【Django+Vue3 线上教育平台项目实战】登录功能模块之短信登录与钉钉三方登录

文章目录 前言一、几个关键概念1.HTTP无状态性2.Session机制3.Token认证4.JWT 二、通过手机号验证码登录1.前端短信登录界面2.发送短信接口与短信登录接口3.Vue 设置interceptors拦截器4. 服务端验证采用自定义中间件方式实现5. 操作流程及效果图如下&#xff1a; 三、通过第三…

记录些MySQL题集(9)

MySQL之死锁问题分析、事务隔离与锁机制的底层原理剖析 一、MySQL中的死锁现象 所谓的并发事务&#xff0c;本质上就是MySQL内部多条工作线程并行执行的情况&#xff0c;也正由于MySQL是多线程应用&#xff0c;所以需要具备完善的锁机制来避免线程不安全问题的问题产生&#…

手机如何伪装ip网络地址

伪装IP地址是指通过技术手段修改网络设备的IP地址&#xff0c;使其看起来像是来自另一个网络位置。这种技术通常用于隐藏真实的网络活动&#xff0c;以保护隐私。那么&#xff0c;手机如何伪装IP网络地址&#xff1f; 要在手机上伪装IP地址&#xff0c;‌可以通过下载和安装手机…

数据资产通证化,堪比20年前的房地产?

大数据产业创新服务媒体 ——聚焦数据 改变商业 想象一下&#xff0c;一个简单的点击&#xff0c;一次不经意的搜索&#xff0c;一段简短的对话&#xff0c;它们在数字世界里留下了什么&#xff1f;是的&#xff0c;是数据。这些看似微不足道的数字碎片&#xff0c;汇聚成海&a…

【python】PyQt5的窗口界面的各种交互逻辑实现,轻松掌控图形化界面程序

✨✨ 欢迎大家来到景天科技苑✨✨ &#x1f388;&#x1f388; 养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; &#x1f3c6; 作者简介&#xff1a;景天科技苑 &#x1f3c6;《头衔》&#xff1a;大厂架构师&#xff0c;华为云开发者社区专家博主&#xff0c;…

【中项】系统集成项目管理工程师-第一模块:IT技术和管理-1.1信息与信息化-1.1.2信息系统基础

前言&#xff1a;系统集成项目管理工程师专业&#xff0c;现分享一些教材知识点。 软考同样是国家人社部和工信部组织的国家级考试&#xff0c;全称为“全国计算机与软件专业技术资格&#xff08;水平&#xff09;考试”&#xff0c;目前涵盖了计算机软件、计算机网络、计算机应…

Office动态水印终于来了

在信息安全日益重要的今天&#xff0c;保护敏感信息变得尤为关键。目前&#xff0c;动态水印甚至是盲水印技术已经在各种企业软件中广泛应用&#xff0c;常见的钉钉和企业微信等都已经支持此类技术&#xff0c;用户查看消息时画面会显示对应用户的姓名和工号等&#xff0c;而作…

小程序-视图与逻辑

一、页面导航 声明式导航 编程式导航 导航传参 1.声明式导航传参 2.编程式导航传参 3.在onload中接收导航参数 二、页面事件 下拉刷新 上拉触底 三、生命周期 分类 生命周期函数分类 1.应用的生命周期函数 2.页面的生命周期函数 四、WXS脚本 基础语法 wxs的特点 五、案…

几何相关计算

目录 一、 判断两个矩形是否相交 二、判断两条线段是否相交 三、判断点是否在多边形内 四、垂足计算 五、贝塞尔曲线 六、坐标系 一、 判断两个矩形是否相交 当矩形1的最大值比矩形2的最小值都小&#xff0c;那矩形1和矩形2一定不相交&#xff0c;其他同理。 struct Po…

华为OD 机试真题 - 分割均衡字符串(Python)

题目描述 均衡串定义:字符串只包含两种字符&#xff0c;且两种字符的个数相同。 给定一个均衡字符串&#xff0c;请给出可分割成新的均衡子串的最大个数。 约定字符串中只包含大写的’X"和’Y’两种字符。 输入描述 均衡串:XXYYXY 字符串的长度[2,10000]。给定的字符…

10.1 标注、注记图层和注记整体说明

文章目录 前言标注、注记图层和注记QGis中的标注QGis中的注释(Annotation)图层QGis中的注记 总结 前言 介绍标注、注记图层和注记说明&#xff1a;文章中的示例代码均来自开源项目qgis_cpp_api_apps 标注、注记图层和注记 有时地图需要使用一些文字信息说明其中的地理要素或其…

如何落地实际场景,解决跨境传输共性需求?免费白皮书可下载

在全球化的背景下&#xff0c;海外市场对于数据驱动的产品和服务的需求不断增加&#xff0c;各行业数据跨境传输也日趋频繁&#xff0c;在这种前景下&#xff0c;越来越多的企业寻求更深度的跨国业务及合作&#xff0c;因此&#xff0c;企业数据跨境流动也成为了势不可挡的趋势…

51单片机嵌入式开发:11、 STC89C52RC 实现一个滑动的led点阵程序

STC89C52RC 实现一个滑动的led点阵程序 1 概述2 LED点阵介绍2.1 LED概述2.2 LED点阵注意事项 3 LED点阵原理3.1 Led点阵内部电路3.2 原理图电路 4 软件实现点阵图案的滑动4.1 软件工程代码4.2 Protues仿真 5 扩展74HC595&#xff08;后续专题开展&#xff09;6 总结 第十一节 1…

如何制定高效的媒体公关解决方案

传媒如春雨&#xff0c;润物细无声&#xff0c;大家好&#xff0c;我是51媒体网胡老师。 媒体公关解决方案是指企业或组织为提升品牌形象、塑造公众认知、应对危机事件等目的&#xff0c;通过媒体渠道制定并实施的一系列公关策略和行动计划。这一解决方案旨在通过有效的媒体沟…

socket功能定义和一般模型

1. socket的功能定义 socket是为了使两个应用程序间进行数据交换而存在的一种技术&#xff0c;不仅可以使同一个主机上两个应用程序间可以交换数据&#xff0c;而且可以使网络上的不同主机间上的应用程序间进行通信。 2. 图解socket的服务端/客户端模型

广告投放的智能优化:Kompas.ai如何提高广告效果

在数字广告领域&#xff0c;智能优化已成为提升广告投放效果和投资回报率(ROI)的关键。Kompas.ai&#xff0c;一款先进的广告智能优化工具&#xff0c;利用数据分析和机器学习技术&#xff0c;帮助广告主实现更精准、高效的广告投放。 智能优化在提升广告效果中的作用 智能优化…

30.【C语言】详解printf

1.printf&#xff08;print formate&#xff09;输入函数 01.简单使用 调用前要引用头文件 #include <stdio.h> printf("abc"); 默认情况下打印完光标停留在同一行 \n可以换行 printf("abc\n"); ​ printf("ab\nc"); ​ printf(…

万用表数学功能中的限值(Limits)功能

万用表数学功能中的 限值(Limits)功能 有限值功能的仪表设置上下限的使用方法 创新向上 利向未来 通达世界 限值检查是指示有多少次采样超过指定限值&#xff0c;并且还指示何时超过此限值的数学功能。 限值(Limits)功能 以34465A为例&#xff1a;可以通过[Math] - Limi…