Update code
This commit is contained in:
1 parent
5eca47ef1a
commit
76e215a0de
16 files changed
+396
-396
No files matched your search
@@ -11,23 +11,23 @@ import me.xixu.Static.Information;
|
||||
|
||||
public class TableOperate {
|
||||
|
||||
// 数据库查询连接模板
|
||||
// 数据库查询连接模板
|
||||
public TableOperate() {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动!");
|
||||
System.out.println("成功加载MySQL驱动!");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库!");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库!");
|
||||
|
||||
String sql = "select * from temp"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
System.out.println("编号" + "\t" + "姓名" + "\t" + "年龄");
|
||||
String sql = "select * from temp"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
System.out.println("编号" + "\t" + "姓名" + "\t" + "年龄");
|
||||
while (rs.next()) {
|
||||
System.out.print(rs.getInt(1) + "\t");
|
||||
System.out.print(rs.getString(2) + "\t");
|
||||
@@ -42,23 +42,23 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 是否存在该用户
|
||||
// 是否存在该用户
|
||||
public static boolean isExist_Customer(String user, String password) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-isExist_Customer");
|
||||
System.out.println("成功加载MySQL驱动-isExist_Customer");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-isExist_Customer");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-isExist_Customer");
|
||||
|
||||
String sql = "select * from Customer"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
System.out.println("用户名" + "\t" + "\t" + "\t" + "密码");
|
||||
String sql = "select * from Customer"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
System.out.println("用户名" + "\t" + "\t" + "\t" + "密码");
|
||||
while (rs.next()) {
|
||||
System.out.print(rs.getString(1) + "\t");
|
||||
System.out.print(rs.getString(2) + "\t");
|
||||
@@ -79,23 +79,23 @@ public class TableOperate {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 是否存在该管理员
|
||||
// 是否存在该管理员
|
||||
public static boolean isExist_Manager(String user, String password) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-isExist_Manager");
|
||||
System.out.println("成功加载MySQL驱动-isExist_Manager");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-isExist_Manager");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-isExist_Manager");
|
||||
|
||||
String sql = "select * from Manager"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
System.out.println("用户名" + "\t" + "\t" + "\t" + "密码");
|
||||
String sql = "select * from Manager"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
System.out.println("用户名" + "\t" + "\t" + "\t" + "密码");
|
||||
while (rs.next()) {
|
||||
System.out.print(rs.getString(1) + "\t");
|
||||
System.out.print(rs.getString(2) + "\t");
|
||||
@@ -116,21 +116,21 @@ public class TableOperate {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 注册新用户
|
||||
// 注册新用户
|
||||
public static void regist_Customer(String user, String password) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-regist_Customer");
|
||||
System.out.println("成功加载MySQL驱动-regist_Customer");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-regist_Customer");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-regist_Customer");
|
||||
|
||||
String sql = "insert into Customer values('" + user + "','" + password + "');"; // 要执行的SQL
|
||||
String sql = "insert into Customer values('" + user + "','" + password + "');"; // 要执行的SQL
|
||||
|
||||
PreparedStatement stmts = conn.prepareStatement(sql);
|
||||
stmts.executeUpdate();
|
||||
@@ -143,21 +143,21 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 注册新管理员
|
||||
// 注册新管理员
|
||||
public static void regist_Manager(String user, String password) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-regist_Manager");
|
||||
System.out.println("成功加载MySQL驱动-regist_Manager");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-regist_Manager");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-regist_Manager");
|
||||
|
||||
String sql = "insert into Manager values('" + user + "','" + password + "');"; // 要执行的SQL
|
||||
String sql = "insert into Manager values('" + user + "','" + password + "');"; // 要执行的SQL
|
||||
|
||||
PreparedStatement stmts = conn.prepareStatement(sql);
|
||||
stmts.executeUpdate();
|
||||
@@ -170,22 +170,22 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 改变用户的密码
|
||||
// 改变用户的密码
|
||||
public static void changePassword_Customer(String user, String password, String newPassword) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-changePassword");
|
||||
System.out.println("成功加载MySQL驱动-changePassword");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-changePassword");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-changePassword");
|
||||
|
||||
String sql = "update Customer set customer_password = '" + newPassword + "' where customer_user = '" + user
|
||||
+ "';"; // 要执行的SQL
|
||||
+ "';"; // 要执行的SQL
|
||||
|
||||
PreparedStatement stmts = conn.prepareStatement(sql);
|
||||
stmts.executeUpdate();
|
||||
@@ -198,22 +198,22 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 改变管理员的密码
|
||||
// 改变管理员的密码
|
||||
public static void changePassword_Manager(String user, String password, String newPassword) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-changePassword");
|
||||
System.out.println("成功加载MySQL驱动-changePassword");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-changePassword");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-changePassword");
|
||||
|
||||
String sql = "update Manager set manager_password = '" + newPassword + "' where manager_user = '" + user
|
||||
+ "';"; // 要执行的SQL
|
||||
+ "';"; // 要执行的SQL
|
||||
|
||||
PreparedStatement stmts = conn.prepareStatement(sql);
|
||||
stmts.executeUpdate();
|
||||
@@ -226,23 +226,23 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 是否存在该用户名
|
||||
// 是否存在该用户名
|
||||
public static boolean isExist_Customer_user(String user, String password) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-isExist_Customer");
|
||||
System.out.println("成功加载MySQL驱动-isExist_Customer");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-isExist_Customer");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-isExist_Customer");
|
||||
|
||||
String sql = "select * from Customer"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
System.out.println("用户名" + "\t" + "\t" + "\t" + "密码");
|
||||
String sql = "select * from Customer"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
System.out.println("用户名" + "\t" + "\t" + "\t" + "密码");
|
||||
while (rs.next()) {
|
||||
System.out.print(rs.getString(1) + "\t");
|
||||
System.out.print(rs.getString(2) + "\t");
|
||||
@@ -263,23 +263,23 @@ public class TableOperate {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 是否存在该管理员名称
|
||||
// 是否存在该管理员名称
|
||||
public static boolean isExist_Manager_user(String user, String password) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-isExist_Manager");
|
||||
System.out.println("成功加载MySQL驱动-isExist_Manager");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-isExist_Manager");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-isExist_Manager");
|
||||
|
||||
String sql = "select * from Manager"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
System.out.println("用户名" + "\t" + "\t" + "\t" + "密码");
|
||||
String sql = "select * from Manager"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
System.out.println("用户名" + "\t" + "\t" + "\t" + "密码");
|
||||
while (rs.next()) {
|
||||
System.out.print(rs.getString(1) + "\t");
|
||||
System.out.print(rs.getString(2) + "\t");
|
||||
@@ -300,23 +300,23 @@ public class TableOperate {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 插入新书
|
||||
// 插入新书
|
||||
public static void insertBook(String number, String classnumber, String name, String classname, String price,
|
||||
String state, String total) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-insertBook");
|
||||
System.out.println("成功加载MySQL驱动-insertBook");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-insertBook");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-insertBook");
|
||||
|
||||
String sql = "insert into " + classname + "Book" + " values('" + number + "','" + classnumber + "','" + name
|
||||
+ "','" + classname + "','" + price + "','" + state + "','" + total + "','null','null','null');"; // 要执行的SQL
|
||||
+ "','" + classname + "','" + price + "','" + state + "','" + total + "','null','null','null');"; // 要执行的SQL
|
||||
|
||||
PreparedStatement stmts = conn.prepareStatement(sql);
|
||||
stmts.executeUpdate();
|
||||
@@ -329,22 +329,22 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 新建类别
|
||||
// 新建类别
|
||||
public static void newClass(String classnumber, String classname) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-newClass");
|
||||
System.out.println("成功加载MySQL驱动-newClass");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-newClass");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-newClass");
|
||||
|
||||
String sql = "CREATE TABLE " + classname
|
||||
+ "Book(number VARCHAR(255) primary key,classnumber VARCHAR(255),name VARCHAR(255),classname VARCHAR(255),price VARCHAR(255),state VARCHAR(255),total VARCHAR(255),current VARCHAR(255),dateon VARCHAR(255),dateoff VARCHAR(255));"; // 要执行的SQL
|
||||
+ "Book(number VARCHAR(255) primary key,classnumber VARCHAR(255),name VARCHAR(255),classname VARCHAR(255),price VARCHAR(255),state VARCHAR(255),total VARCHAR(255),current VARCHAR(255),dateon VARCHAR(255),dateoff VARCHAR(255));"; // 要执行的SQL
|
||||
|
||||
PreparedStatement stmts = conn.prepareStatement(sql);
|
||||
stmts.executeUpdate();
|
||||
@@ -357,21 +357,21 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 删除书籍信息
|
||||
// 删除书籍信息
|
||||
public static void deleteBook(String number, String classname) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-deleteBook");
|
||||
System.out.println("成功加载MySQL驱动-deleteBook");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-deleteBook");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-deleteBook");
|
||||
|
||||
String sql = "delete from " + classname + "Book where number = '" + number + "';"; // 要执行的SQL
|
||||
String sql = "delete from " + classname + "Book where number = '" + number + "';"; // 要执行的SQL
|
||||
|
||||
PreparedStatement stmts = conn.prepareStatement(sql);
|
||||
stmts.executeUpdate();
|
||||
@@ -384,24 +384,24 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 查询某类图书信息
|
||||
// 查询某类图书信息
|
||||
public static void search_classname(String classname) {
|
||||
Information.bookarray.clear();
|
||||
try {
|
||||
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-search_classname");
|
||||
System.out.println("成功加载MySQL驱动-search_classname");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-search_classname");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-search_classname");
|
||||
|
||||
String sql = "select * from " + classname + "Book;"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
String sql = "select * from " + classname + "Book;"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
while (rs.next()) {
|
||||
Book book = new Book();
|
||||
book.number = rs.getString(1);
|
||||
@@ -424,21 +424,21 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 借书更改信息
|
||||
// 借书更改信息
|
||||
public static void borrowBook_Update(String classname, String number, String user, String dateoff) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-borrowBook_Customer");
|
||||
System.out.println("成功加载MySQL驱动-borrowBook_Customer");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-borrowBook_Customer");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-borrowBook_Customer");
|
||||
|
||||
String sql = "update " + classname + "Book set state = 'out' where number = '" + number + "';\n"; // 要执行的SQL
|
||||
String sql = "update " + classname + "Book set state = 'out' where number = '" + number + "';\n"; // 要执行的SQL
|
||||
PreparedStatement stmts_state = conn.prepareStatement(sql);
|
||||
stmts_state.executeUpdate();
|
||||
stmts_state.close();
|
||||
@@ -460,22 +460,22 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 创建用户数据库
|
||||
// 创建用户数据库
|
||||
public static void newCustomer(String user) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-newCustomer");
|
||||
System.out.println("成功加载MySQL驱动-newCustomer");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-newCustomer");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-newCustomer");
|
||||
|
||||
String sql = "CREATE TABLE " + user
|
||||
+ "Customer (number VARCHAR(255) primary key,classname VARCHAR(255),name VARCHAR(255),dateoff VARCHAR(255));"; // 要执行的SQL
|
||||
+ "Customer (number VARCHAR(255) primary key,classname VARCHAR(255),name VARCHAR(255),dateoff VARCHAR(255));"; // 要执行的SQL
|
||||
|
||||
PreparedStatement stmts = conn.prepareStatement(sql);
|
||||
stmts.executeUpdate();
|
||||
@@ -488,22 +488,22 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 借书注射到用户信息
|
||||
// 借书注射到用户信息
|
||||
public static void borrowBook_Insert(String classname, String number, String user, String dateoff) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-borrowBook_Insert");
|
||||
System.out.println("成功加载MySQL驱动-borrowBook_Insert");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-borrowBook_Insert");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-borrowBook_Insert");
|
||||
|
||||
String sql = "insert into " + user + "Customer values('" + number + "','" + classname + "','"
|
||||
+ search_bookname(classname, number) + "','" + dateoff + "');"; // 要执行的SQL
|
||||
+ search_bookname(classname, number) + "','" + dateoff + "');"; // 要执行的SQL
|
||||
|
||||
PreparedStatement stmts = conn.prepareStatement(sql);
|
||||
stmts.executeUpdate();
|
||||
@@ -516,21 +516,21 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 还书更新书籍数据库信息
|
||||
// 还书更新书籍数据库信息
|
||||
public static void returnBook_Update(String classname, String number, String user, String dateoff) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-returnBook_Update");
|
||||
System.out.println("成功加载MySQL驱动-returnBook_Update");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-returnBook_Update");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-returnBook_Update");
|
||||
|
||||
String sql = "update " + classname + "Book set state = 'in' where number = '" + number + "';\n"; // 要执行的SQL
|
||||
String sql = "update " + classname + "Book set state = 'in' where number = '" + number + "';\n"; // 要执行的SQL
|
||||
PreparedStatement stmts_state = conn.prepareStatement(sql);
|
||||
stmts_state.executeUpdate();
|
||||
stmts_state.close();
|
||||
@@ -552,21 +552,21 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 还书更新用户的数据库信息
|
||||
// 还书更新用户的数据库信息
|
||||
public static void returnBook_Delete(String number, String user) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-returnBook_Delete");
|
||||
System.out.println("成功加载MySQL驱动-returnBook_Delete");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-returnBook_Delete");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-returnBook_Delete");
|
||||
|
||||
String sql = "delete from " + user + "Customer where number = '" + number + "';"; // 要执行的SQL
|
||||
String sql = "delete from " + user + "Customer where number = '" + number + "';"; // 要执行的SQL
|
||||
|
||||
PreparedStatement stmts = conn.prepareStatement(sql);
|
||||
stmts.executeUpdate();
|
||||
@@ -579,22 +579,22 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 续借更新两者数据库信息
|
||||
// 续借更新两者数据库信息
|
||||
public static void prolongBook_Update(String classname, String number, String dateoff, String user) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-prolongBook_Update");
|
||||
System.out.println("成功加载MySQL驱动-prolongBook_Update");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-prolongBook_Update");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-prolongBook_Update");
|
||||
|
||||
String sql = "update " + classname + "Book set dateoff = '" + dateoff + "' where number = '" + number
|
||||
+ "';\n"; // 要执行的SQL
|
||||
+ "';\n"; // 要执行的SQL
|
||||
PreparedStatement stmts_state = conn.prepareStatement(sql);
|
||||
stmts_state.executeUpdate();
|
||||
stmts_state.close();
|
||||
@@ -611,24 +611,24 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 查询个人图书信息
|
||||
// 查询个人图书信息
|
||||
public static void search_personal(String user) {
|
||||
Information.bookarray.clear();
|
||||
try {
|
||||
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-search_personal");
|
||||
System.out.println("成功加载MySQL驱动-search_personal");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-search_personal");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-search_personal");
|
||||
|
||||
String sql = "select * from " + user + "Customer;"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
String sql = "select * from " + user + "Customer;"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
while (rs.next()) {
|
||||
Book book = new Book();
|
||||
book.number = rs.getString(1);
|
||||
@@ -645,22 +645,22 @@ public class TableOperate {
|
||||
}
|
||||
}
|
||||
|
||||
// 是否存在该Table表
|
||||
// 是否存在该Table表
|
||||
public static boolean isExist_Table(String table) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-isExist_Table");
|
||||
System.out.println("成功加载MySQL驱动-isExist_Table");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-isExist_Table");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-isExist_Table");
|
||||
|
||||
String sql = "show tables"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
String sql = "show tables"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
while (rs.next()) {
|
||||
if (table.equals(rs.getString(1))) {
|
||||
return true;
|
||||
@@ -675,22 +675,22 @@ public class TableOperate {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查找书名
|
||||
// 查找书名
|
||||
public static String search_bookname(String classname, String number) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-search_bookname");
|
||||
System.out.println("成功加载MySQL驱动-search_bookname");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-search_bookname");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-search_bookname");
|
||||
|
||||
String sql = "select * from " + classname + "book where number='" + number + "';"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
String sql = "select * from " + classname + "book where number='" + number + "';"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
while (rs.next()) {
|
||||
return rs.getString(3);
|
||||
}
|
||||
@@ -703,22 +703,22 @@ public class TableOperate {
|
||||
return "null";
|
||||
}
|
||||
|
||||
// 查找书籍状态
|
||||
// 查找书籍状态
|
||||
public static String search_bookstate(String classname, String number) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-search_bookstate");
|
||||
System.out.println("成功加载MySQL驱动-search_bookstate");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-search_bookstate");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-search_bookstate");
|
||||
|
||||
String sql = "select * from " + classname + "book where number='" + number + "';"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
String sql = "select * from " + classname + "book where number='" + number + "';"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
while (rs.next()) {
|
||||
return rs.getString(6);
|
||||
}
|
||||
@@ -731,22 +731,22 @@ public class TableOperate {
|
||||
return "null";
|
||||
}
|
||||
|
||||
// 查找书籍还书日期
|
||||
// 查找书籍还书日期
|
||||
public static int search_bookdateoff(String classname, String number) {
|
||||
try {
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
// 调用Class.forName()方法加载驱动程序
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
System.out.println("成功加载MySQL驱动-search_bookdateoff");
|
||||
System.out.println("成功加载MySQL驱动-search_bookdateoff");
|
||||
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
String url = Information.JDBC_URL; // JDBC的URL
|
||||
Connection conn;
|
||||
|
||||
conn = DriverManager.getConnection(url, Information.username, Information.password);
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-search_bookdateoff");
|
||||
Statement stmt = conn.createStatement(); // 创建Statement对象
|
||||
System.out.println("成功连接到数据库-search_bookdateoff");
|
||||
|
||||
String sql = "select * from " + classname + "book where number='" + number + "';"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
String sql = "select * from " + classname + "book where number='" + number + "';"; // 要执行的SQL
|
||||
ResultSet rs = stmt.executeQuery(sql);// 创建数据对象
|
||||
while (rs.next()) {
|
||||
return Integer.parseInt(rs.getString(10));
|
||||
}
|
||||
|
||||
@@ -34,23 +34,23 @@ import me.xixu.User.UserInterface;
|
||||
|
||||
public class MainInterface extends JFrame implements ActionListener {
|
||||
|
||||
// Main窗口
|
||||
// Main窗口
|
||||
public static JPanel contentPane;
|
||||
// Manager窗口
|
||||
// Manager窗口
|
||||
public static ManagerInterface managerJPanel = new ManagerInterface();
|
||||
public static InsertBook insertJPanel = new InsertBook();
|
||||
public static NewClass newJPanel = new NewClass();
|
||||
public static UpdateBook updateJPanel = new UpdateBook();
|
||||
public static State stateJPanel = new State();
|
||||
public static State_Information stateInfoJPanel = new State_Information();
|
||||
// User窗口
|
||||
// User窗口
|
||||
public static UserInterface userJPanel = new UserInterface();
|
||||
public static BorrowBook borrowJPanel = new BorrowBook();
|
||||
public static BorrowBook_Information borrowInfoJPanel = new BorrowBook_Information();
|
||||
public static ReturnBook returnJPanel = new ReturnBook();
|
||||
public static ProlongBook prolongJPanel = new ProlongBook();
|
||||
public static PersonalInformation personalJPanel = new PersonalInformation();
|
||||
// 主界面窗口
|
||||
// 主界面窗口
|
||||
private JTextField tf_user;
|
||||
private JTextField tf_password;
|
||||
private JLabel label_user;
|
||||
@@ -79,13 +79,13 @@ public class MainInterface extends JFrame implements ActionListener {
|
||||
init();
|
||||
}
|
||||
|
||||
// 初始化窗口
|
||||
// 初始化窗口
|
||||
public void init() {
|
||||
|
||||
// 获取主界面容器
|
||||
// 获取主界面容器
|
||||
container = getContentPane();
|
||||
|
||||
// 初始化主界面
|
||||
// 初始化主界面
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(800, 400, 1300, 1000);
|
||||
setResizable(false);
|
||||
@@ -95,83 +95,83 @@ public class MainInterface extends JFrame implements ActionListener {
|
||||
container.add(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
// 账号输入框
|
||||
// 账号输入框
|
||||
tf_user = new JTextField();
|
||||
tf_user.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_user.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_user.setBounds(409, 248, 526, 75);
|
||||
contentPane.add(tf_user);
|
||||
tf_user.setColumns(10);
|
||||
|
||||
// 密码输入框
|
||||
// 密码输入框
|
||||
tf_password = new JTextField();
|
||||
tf_password.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_password.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_password.setColumns(10);
|
||||
tf_password.setBounds(409, 357, 526, 75);
|
||||
contentPane.add(tf_password);
|
||||
|
||||
// 用户名标签
|
||||
// 用户名标签
|
||||
label_user = new JLabel("\u8D26\u53F7\uFF1A");
|
||||
label_user.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
label_user.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
label_user.setBounds(289, 261, 116, 48);
|
||||
contentPane.add(label_user);
|
||||
|
||||
// 密码标签
|
||||
// 密码标签
|
||||
label_password = new JLabel("\u5BC6\u7801\uFF1A");
|
||||
label_password.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
label_password.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
label_password.setBounds(289, 370, 116, 48);
|
||||
contentPane.add(label_password);
|
||||
|
||||
// 普通用户单选按钮
|
||||
// 普通用户单选按钮
|
||||
rb_customer = new JRadioButton("\u666E\u901A\u7528\u6237");
|
||||
rb_customer.setSelected(true);
|
||||
rb_customer.setFont(new Font("宋体", Font.BOLD, 30));
|
||||
rb_customer.setFont(new Font("宋体", Font.BOLD, 30));
|
||||
rb_customer.setBackground(Color.WHITE);
|
||||
rb_customer.setBounds(409, 515, 170, 37);
|
||||
contentPane.add(rb_customer);
|
||||
|
||||
// 管理人员单选按钮
|
||||
// 管理人员单选按钮
|
||||
rb_manager = new JRadioButton("\u7BA1\u7406\u4EBA\u5458");
|
||||
rb_manager.setFont(new Font("宋体", Font.BOLD, 30));
|
||||
rb_manager.setFont(new Font("宋体", Font.BOLD, 30));
|
||||
rb_manager.setBackground(Color.WHITE);
|
||||
rb_manager.setBounds(765, 515, 170, 37);
|
||||
contentPane.add(rb_manager);
|
||||
// 将选项按钮添加到一个按钮组
|
||||
ButtonGroup bg = new ButtonGroup();// 初始化按钮组
|
||||
bg.add(rb_customer);// 普通用户加入按钮组
|
||||
bg.add(rb_manager);// 管理人员加入按钮组
|
||||
// 将选项按钮添加到一个按钮组
|
||||
ButtonGroup bg = new ButtonGroup();// 初始化按钮组
|
||||
bg.add(rb_customer);// 普通用户加入按钮组
|
||||
bg.add(rb_manager);// 管理人员加入按钮组
|
||||
|
||||
// 登录按钮
|
||||
// 登录按钮
|
||||
btn_login = new JButton("\u767B\u5F55");
|
||||
btn_login.setBackground(Color.LIGHT_GRAY);
|
||||
btn_login.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_login.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_login.setBounds(409, 634, 170, 48);
|
||||
contentPane.add(btn_login);
|
||||
btn_login.addActionListener(this);
|
||||
|
||||
// 注册按钮
|
||||
// 注册按钮
|
||||
btn_register = new JButton("\u6CE8\u518C");
|
||||
btn_register.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_register.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_register.setBackground(Color.LIGHT_GRAY);
|
||||
btn_register.setBounds(765, 634, 170, 48);
|
||||
contentPane.add(btn_register);
|
||||
btn_register.addActionListener(this);
|
||||
|
||||
// 修改密码按钮
|
||||
// 修改密码按钮
|
||||
btn_changePassword = new JButton("\u4FEE\u6539\u5BC6\u7801");
|
||||
btn_changePassword.setFont(new Font("宋体", Font.BOLD, 30));
|
||||
btn_changePassword.setFont(new Font("宋体", Font.BOLD, 30));
|
||||
btn_changePassword.setBackground(Color.LIGHT_GRAY);
|
||||
btn_changePassword.setBounds(1011, 370, 170, 48);
|
||||
contentPane.add(btn_changePassword);
|
||||
|
||||
label = new JLabel("\u56FE\u4E66\u7BA1\u7406\u7CFB\u7EDF");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(529, 69, 294, 105);
|
||||
contentPane.add(label);
|
||||
btn_changePassword.addActionListener(this);
|
||||
}
|
||||
|
||||
// 切换窗口函数
|
||||
// 切换窗口函数
|
||||
// Main->Manager
|
||||
public static void MaintoManager() {
|
||||
if (!flage_manager) {
|
||||
@@ -388,104 +388,104 @@ public class MainInterface extends JFrame implements ActionListener {
|
||||
userJPanel.setVisible(true);
|
||||
}
|
||||
|
||||
// 登录注册事件函数
|
||||
// 登录注册事件函数
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == btn_login) {
|
||||
// 点击登录按钮
|
||||
// 判定用户名密码是否为空
|
||||
// 点击登录按钮
|
||||
// 判定用户名密码是否为空
|
||||
if (tf_user.getText().equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "用户名不能为空", "登录失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "用户名不能为空", "登录失败", JOptionPane.ERROR_MESSAGE);
|
||||
} else if (tf_password.getText().equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "密码不能为空", "登录失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "密码不能为空", "登录失败", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
// 判定是用户还是管理员
|
||||
// 判定是用户还是管理员
|
||||
if (rb_customer.isSelected()) {
|
||||
// 用户
|
||||
// 用户
|
||||
boolean isExist = TableOperate.isExist_Customer(tf_user.getText(), tf_password.getText());
|
||||
if (isExist) {
|
||||
JOptionPane.showMessageDialog(null, "欢迎使用", "用户登录成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "欢迎使用", "用户登录成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
Information.user = tf_user.getText();
|
||||
UserInterface.setUser();
|
||||
MaintoUser();
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "请输入正确的用户名密码", "用户登录失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "请输入正确的用户名密码", "用户登录失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else {
|
||||
// 管理员
|
||||
// 管理员
|
||||
boolean isExist = TableOperate.isExist_Manager(tf_user.getText(), tf_password.getText());
|
||||
if (isExist) {
|
||||
JOptionPane.showMessageDialog(null, "欢迎使用", "管理员登录成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "欢迎使用", "管理员登录成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
Information.manager = tf_user.getText();
|
||||
ManagerInterface.setManager();
|
||||
MaintoManager();
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "请输入正确的用户名密码", "管理员登录失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "请输入正确的用户名密码", "管理员登录失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (e.getSource() == btn_register) {
|
||||
// 点击注册按钮
|
||||
// 判定用户名密码是否为空
|
||||
// 点击注册按钮
|
||||
// 判定用户名密码是否为空
|
||||
if (tf_user.getText().equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "用户名不能为空", "注册失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "用户名不能为空", "注册失败", JOptionPane.ERROR_MESSAGE);
|
||||
} else if (tf_password.getText().equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "密码不能为空", "注册失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "密码不能为空", "注册失败", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
// 判定是用户还是管理员
|
||||
// 判定是用户还是管理员
|
||||
if (rb_customer.isSelected()) {
|
||||
boolean isExist = TableOperate.isExist_Customer_user(tf_user.getText(), tf_password.getText());
|
||||
if (isExist) {
|
||||
JOptionPane.showMessageDialog(null, "该用户已经存在", "用户注册失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "该用户已经存在", "用户注册失败", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "欢迎!", "用户注册成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "欢迎!", "用户注册成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
TableOperate.regist_Customer(tf_user.getText(), tf_password.getText());
|
||||
TableOperate.newCustomer(tf_user.getText());
|
||||
}
|
||||
} else {
|
||||
boolean isExist = TableOperate.isExist_Manager_user(tf_user.getText(), tf_password.getText());
|
||||
if (isExist) {
|
||||
JOptionPane.showMessageDialog(null, "该管理员已经存在", "管理员注册失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "该管理员已经存在", "管理员注册失败", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "欢迎!", "管理员注册成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "欢迎!", "管理员注册成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
TableOperate.regist_Manager(tf_user.getText(), tf_password.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (e.getSource() == btn_changePassword) {
|
||||
if (tf_user.getText().equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "用户名不能为空", "修改失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "用户名不能为空", "修改失败", JOptionPane.ERROR_MESSAGE);
|
||||
} else if (tf_password.getText().equals("")) {
|
||||
JOptionPane.showMessageDialog(null, "密码不能为空", "修改失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "密码不能为空", "修改失败", JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
// 判定是用户还是管理员
|
||||
// 判定是用户还是管理员
|
||||
if (rb_customer.isSelected()) {
|
||||
// 用户
|
||||
// 用户
|
||||
boolean isExist = TableOperate.isExist_Customer(tf_user.getText(), tf_password.getText());
|
||||
if (isExist) {
|
||||
String newPassword = JOptionPane.showInputDialog("请输入新密码");
|
||||
String newPassword = JOptionPane.showInputDialog("请输入新密码");
|
||||
if (!newPassword.equals("")) {
|
||||
TableOperate.changePassword_Customer(tf_user.getText(), tf_password.getText(), newPassword);
|
||||
JOptionPane.showMessageDialog(null, "欢迎使用", "修改密码成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "欢迎使用", "修改密码成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "密码不能为空", "修改密码失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "密码不能为空", "修改密码失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "请输入正确的用户名密码", "修改密码失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "请输入正确的用户名密码", "修改密码失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else {
|
||||
// 管理员
|
||||
// 管理员
|
||||
boolean isExist = TableOperate.isExist_Manager(tf_user.getText(), tf_password.getText());
|
||||
if (isExist) {
|
||||
String newPassword = JOptionPane.showInputDialog("请输入新密码");
|
||||
String newPassword = JOptionPane.showInputDialog("请输入新密码");
|
||||
if (!newPassword.equals("")) {
|
||||
TableOperate.changePassword_Manager(tf_user.getText(), tf_password.getText(), newPassword);
|
||||
JOptionPane.showMessageDialog(null, "欢迎使用", "修改密码成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "欢迎使用", "修改密码成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "密码不能为空", "修改密码失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "密码不能为空", "修改密码失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "请输入正确的用户名密码", "修改密码失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "请输入正确的用户名密码", "修改密码失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,95 +42,95 @@ public class InsertBook extends JPanel implements ActionListener {
|
||||
|
||||
JLabel label = new JLabel("\u65B0\u4E66\u5F55\u5165");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(530, 0, 294, 105);
|
||||
add(label);
|
||||
|
||||
lb_number = new JLabel("\u7F16\u53F7\uFF1A");
|
||||
lb_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_number.setBounds(293, 137, 194, 55);
|
||||
add(lb_number);
|
||||
|
||||
tf_number = new JTextField();
|
||||
tf_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_number.setColumns(10);
|
||||
tf_number.setBounds(486, 127, 526, 75);
|
||||
add(tf_number);
|
||||
|
||||
lb_classnumber = new JLabel("\u5206\u7C7B\u7F16\u53F7\uFF1A");
|
||||
lb_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classnumber.setBounds(293, 233, 194, 55);
|
||||
add(lb_classnumber);
|
||||
|
||||
lb_name = new JLabel("\u4E66\u540D\uFF1A");
|
||||
lb_name.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_name.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_name.setBounds(293, 329, 194, 55);
|
||||
add(lb_name);
|
||||
|
||||
lb_classname = new JLabel("\u5206\u7C7B\u540D\u79F0\uFF1A");
|
||||
lb_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classname.setBounds(293, 435, 194, 55);
|
||||
add(lb_classname);
|
||||
|
||||
lb_price = new JLabel("\u4EF7\u683C\uFF1A");
|
||||
lb_price.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_price.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_price.setBounds(293, 521, 194, 55);
|
||||
add(lb_price);
|
||||
|
||||
lb_state = new JLabel("\u5165\u85CF\u72B6\u6001\uFF1A");
|
||||
lb_state.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_state.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_state.setBounds(293, 617, 194, 55);
|
||||
add(lb_state);
|
||||
|
||||
lb_total = new JLabel("\u6570\u91CF\uFF1A");
|
||||
lb_total.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_total.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_total.setBounds(293, 713, 194, 55);
|
||||
add(lb_total);
|
||||
|
||||
tf_classnumber = new JTextField();
|
||||
tf_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classnumber.setColumns(10);
|
||||
tf_classnumber.setBounds(486, 223, 526, 75);
|
||||
add(tf_classnumber);
|
||||
|
||||
tf_name = new JTextField();
|
||||
tf_name.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_name.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_name.setColumns(10);
|
||||
tf_name.setBounds(486, 319, 526, 75);
|
||||
add(tf_name);
|
||||
|
||||
tf_classname = new JTextField();
|
||||
tf_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classname.setColumns(10);
|
||||
tf_classname.setBounds(486, 415, 526, 75);
|
||||
add(tf_classname);
|
||||
|
||||
tf_price = new JTextField();
|
||||
tf_price.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_price.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_price.setColumns(10);
|
||||
tf_price.setBounds(486, 511, 526, 75);
|
||||
add(tf_price);
|
||||
|
||||
tf_state = new JTextField();
|
||||
tf_state.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_state.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_state.setColumns(10);
|
||||
tf_state.setBounds(486, 607, 526, 75);
|
||||
add(tf_state);
|
||||
|
||||
tf_total = new JTextField();
|
||||
tf_total.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_total.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_total.setColumns(10);
|
||||
tf_total.setBounds(486, 703, 526, 75);
|
||||
add(tf_total);
|
||||
|
||||
btn_submit = new JButton("\u63D0\u4EA4");
|
||||
btn_submit.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_submit.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_submit.setBounds(573, 833, 251, 80);
|
||||
add(btn_submit);
|
||||
btn_submit.addActionListener(this);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
@@ -140,11 +140,11 @@ public class InsertBook extends JPanel implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == back) {
|
||||
// 点击返回按钮
|
||||
// 点击返回按钮
|
||||
MainInterface.InserttoManager();
|
||||
} else if (e.getSource() == btn_submit) {
|
||||
// 点击提交按钮
|
||||
// 判定录入信息是否冲突
|
||||
// 点击提交按钮
|
||||
// 判定录入信息是否冲突
|
||||
String number = tf_number.getText();
|
||||
String classnumber = tf_classnumber.getText();
|
||||
String name = tf_name.getText();
|
||||
@@ -154,7 +154,7 @@ public class InsertBook extends JPanel implements ActionListener {
|
||||
String total = tf_total.getText();
|
||||
|
||||
if (TableOperate.search_bookstate(classname, number).equals("null")) {
|
||||
// 插入书籍信息
|
||||
// 插入书籍信息
|
||||
TableOperate.insertBook(number, classnumber, name, classname, price, state, total);
|
||||
tf_number.setText("");
|
||||
tf_classnumber.setText("");
|
||||
@@ -163,9 +163,9 @@ public class InsertBook extends JPanel implements ActionListener {
|
||||
tf_price.setText("");
|
||||
tf_state.setText("");
|
||||
tf_total.setText("");
|
||||
JOptionPane.showMessageDialog(null, "恭喜", "书籍录入成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "恭喜", "书籍录入成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "书籍信息冲突", "书籍录入失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "书籍信息冲突", "书籍录入失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,51 +31,51 @@ public class ManagerInterface extends JPanel implements ActionListener {
|
||||
|
||||
label = new JLabel("\u7BA1\u7406\u5458\u754C\u9762");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(530, 20, 294, 105);
|
||||
add(label);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
|
||||
btn_insertBook = new JButton("\u5F55\u5165\u65B0\u4E66");
|
||||
btn_insertBook.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_insertBook.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_insertBook.setBounds(21, 241, 280, 505);
|
||||
add(btn_insertBook);
|
||||
btn_insertBook.addActionListener(this);
|
||||
|
||||
btn_newClass = new JButton("\u8BBE\u7ACB\u65B0\u7C7B\u522B");
|
||||
btn_newClass.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_newClass.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_newClass.setBounds(347, 241, 280, 505);
|
||||
add(btn_newClass);
|
||||
btn_newClass.addActionListener(this);
|
||||
|
||||
btn_updateBook = new JButton("\u66F4\u65B0\u4FE1\u606F");
|
||||
btn_updateBook.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_updateBook.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_updateBook.setBounds(673, 241, 280, 505);
|
||||
add(btn_updateBook);
|
||||
btn_updateBook.addActionListener(this);
|
||||
|
||||
btn_state = new JButton("\u9986\u85CF\u72B6\u6001");
|
||||
btn_state.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_state.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_state.setBounds(995, 241, 280, 505);
|
||||
add(btn_state);
|
||||
btn_state.addActionListener(this);
|
||||
|
||||
lb_manager = new JLabel("New label");
|
||||
lb_manager.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lb_manager.setFont(new Font("宋体", Font.BOLD, 28));
|
||||
lb_manager.setFont(new Font("宋体", Font.BOLD, 28));
|
||||
lb_manager.setBounds(954, 0, 348, 56);
|
||||
add(lb_manager);
|
||||
|
||||
}
|
||||
|
||||
// 设置右上角当前管理员
|
||||
// 设置右上角当前管理员
|
||||
public static void setManager() {
|
||||
lb_manager.setText("当前管理员:" + Information.manager);
|
||||
lb_manager.setText("当前管理员:" + Information.manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,40 +33,40 @@ public class NewClass extends JPanel implements ActionListener {
|
||||
|
||||
label = new JLabel("\u65B0\u5EFA\u56FE\u4E66\u5E93");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(542, 20, 294, 105);
|
||||
add(label);
|
||||
|
||||
lb_classnumber = new JLabel("\u5206\u7C7B\u7F16\u53F7\uFF1A");
|
||||
lb_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classnumber.setBounds(361, 260, 194, 55);
|
||||
add(lb_classnumber);
|
||||
|
||||
tf_classnumber = new JTextField();
|
||||
tf_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classnumber.setColumns(10);
|
||||
tf_classnumber.setBounds(555, 250, 399, 75);
|
||||
add(tf_classnumber);
|
||||
|
||||
tf_classname = new JTextField();
|
||||
tf_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classname.setColumns(10);
|
||||
tf_classname.setBounds(555, 431, 399, 75);
|
||||
add(tf_classname);
|
||||
|
||||
lb_classname = new JLabel("\u5206\u7C7B\u540D\u79F0\uFF1A");
|
||||
lb_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classname.setBounds(361, 441, 194, 55);
|
||||
add(lb_classname);
|
||||
|
||||
btn_submit = new JButton("\u63D0\u4EA4");
|
||||
btn_submit.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_submit.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_submit.setBounds(585, 637, 251, 80);
|
||||
add(btn_submit);
|
||||
btn_submit.addActionListener(this);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
@@ -76,17 +76,17 @@ public class NewClass extends JPanel implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == back) {
|
||||
// 点击返回按钮
|
||||
// 点击返回按钮
|
||||
MainInterface.NewClasstoManager();
|
||||
} else if (e.getSource() == btn_submit) {
|
||||
// 点击提交按钮
|
||||
// 点击提交按钮
|
||||
if (!TableOperate.isExist_Table(tf_classname.getText().toLowerCase() + "book")) {
|
||||
TableOperate.newClass(tf_classnumber.getText(), tf_classname.getText());
|
||||
tf_classnumber.setText("");
|
||||
tf_classname.setText("");
|
||||
JOptionPane.showMessageDialog(null, "恭喜", "添加新类别成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "恭喜", "添加新类别成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "该类别已存在", "添加新类别失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "该类别已存在", "添加新类别失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,30 +31,30 @@ public class State extends JPanel implements ActionListener {
|
||||
setLayout(null);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
|
||||
label = new JLabel("\u56FE\u4E66\u5E93\u72B6\u6001\u67E5\u8BE2");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(530, 20, 294, 105);
|
||||
add(label);
|
||||
|
||||
lb_classname = new JLabel("\u4E66\u5E93\u7C7B\u522B\u540D\u79F0\uFF1A");
|
||||
lb_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classname.setBounds(241, 330, 283, 55);
|
||||
add(lb_classname);
|
||||
|
||||
tf_classname = new JTextField();
|
||||
tf_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classname.setColumns(10);
|
||||
tf_classname.setBounds(502, 320, 526, 75);
|
||||
add(tf_classname);
|
||||
|
||||
btn_search = new JButton("\u67E5\u8BE2");
|
||||
btn_search.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_search.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_search.setBounds(558, 567, 251, 80);
|
||||
add(btn_search);
|
||||
btn_search.addActionListener(this);
|
||||
@@ -71,16 +71,16 @@ public class State extends JPanel implements ActionListener {
|
||||
|
||||
Information.search_classname = classname;
|
||||
|
||||
// 查询该类图书信息
|
||||
// 判定是否存在查询类别
|
||||
// 查询该类图书信息
|
||||
// 判定是否存在查询类别
|
||||
if (TableOperate.isExist_Table(classname + "book")) {
|
||||
JOptionPane.showMessageDialog(null, "欢迎", "查询成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "欢迎", "查询成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
TableOperate.search_classname(tf_classname.getText());
|
||||
MainInterface.StatetoStateInfo();
|
||||
State_Information.setTextArea();
|
||||
tf_classname.setText("");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "不存在该类别", "查询失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "不存在该类别", "查询失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class State_Information extends JPanel implements ActionListener {
|
||||
setLayout(null);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
@@ -37,12 +37,12 @@ public class State_Information extends JPanel implements ActionListener {
|
||||
|
||||
textArea.setEditable(false);
|
||||
|
||||
info = "图书编号 分类编号 图书名称 分类名称 价格 状态 获取人 终止日期\n";
|
||||
info = "图书编号 分类编号 图书名称 分类名称 价格 状态 获取人 终止日期\n";
|
||||
|
||||
}
|
||||
|
||||
public static void setTextArea() {
|
||||
info = "图书编号 分类编号 图书名称 分类名称 价格 状态 获取人 终止日期\n";
|
||||
info = "图书编号 分类编号 图书名称 分类名称 价格 状态 获取人 终止日期\n";
|
||||
|
||||
for (int i = 0; i < Information.bookarray.size(); i++) {
|
||||
info = info + " " + Information.bookarray.get(i).number + " ";
|
||||
|
||||
@@ -46,111 +46,111 @@ public class UpdateBook extends JPanel implements ActionListener {
|
||||
|
||||
label = new JLabel("\u66F4\u65B0\u56FE\u4E66\u4FE1\u606F");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(530, 20, 294, 105);
|
||||
add(label);
|
||||
|
||||
lb_old_number = new JLabel("\u65E7\u7F16\u53F7\uFF1A");
|
||||
lb_old_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_old_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_old_number.setBounds(165, 127, 194, 55);
|
||||
add(lb_old_number);
|
||||
|
||||
tf_old_number = new JTextField();
|
||||
tf_old_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_old_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_old_number.setColumns(10);
|
||||
tf_old_number.setBounds(298, 117, 252, 75);
|
||||
add(tf_old_number);
|
||||
|
||||
tf_new_number = new JTextField();
|
||||
tf_new_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_number.setColumns(10);
|
||||
tf_new_number.setBounds(507, 274, 526, 75);
|
||||
add(tf_new_number);
|
||||
|
||||
update = new JLabel("\u66F4\u65B0\u4FE1\u606F");
|
||||
update.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
update.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
update.setBounds(607, 213, 157, 55);
|
||||
add(update);
|
||||
|
||||
tf_new_classnumber = new JTextField();
|
||||
tf_new_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_classnumber.setColumns(10);
|
||||
tf_new_classnumber.setBounds(507, 370, 526, 75);
|
||||
add(tf_new_classnumber);
|
||||
|
||||
tf_old_classname = new JTextField();
|
||||
tf_old_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_old_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_old_classname.setColumns(10);
|
||||
tf_old_classname.setBounds(788, 117, 342, 75);
|
||||
add(tf_old_classname);
|
||||
|
||||
lb_old_classname = new JLabel("\u65E7\u5206\u7C7B\u540D\u79F0\uFF1A");
|
||||
lb_old_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_old_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_old_classname.setBounds(570, 127, 222, 55);
|
||||
add(lb_old_classname);
|
||||
|
||||
tf_new_name = new JTextField();
|
||||
tf_new_name.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_name.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_name.setColumns(10);
|
||||
tf_new_name.setBounds(507, 466, 526, 75);
|
||||
add(tf_new_name);
|
||||
|
||||
tf_new_classname = new JTextField();
|
||||
tf_new_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_classname.setColumns(10);
|
||||
tf_new_classname.setBounds(507, 562, 526, 75);
|
||||
add(tf_new_classname);
|
||||
|
||||
tf_new_price = new JTextField();
|
||||
tf_new_price.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_price.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_price.setColumns(10);
|
||||
tf_new_price.setBounds(507, 658, 526, 75);
|
||||
add(tf_new_price);
|
||||
|
||||
tf_new_state = new JTextField();
|
||||
tf_new_state.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_state.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_new_state.setColumns(10);
|
||||
tf_new_state.setBounds(507, 754, 526, 75);
|
||||
add(tf_new_state);
|
||||
|
||||
lb_new_number = new JLabel("\u65B0\u7F16\u53F7\uFF1A");
|
||||
lb_new_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_number.setBounds(285, 284, 194, 55);
|
||||
add(lb_new_number);
|
||||
|
||||
lb_new_classnumber = new JLabel("\u65B0\u5206\u7C7B\u7F16\u53F7\uFF1A");
|
||||
lb_new_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_classnumber.setBounds(285, 380, 227, 55);
|
||||
add(lb_new_classnumber);
|
||||
|
||||
lb_new_name = new JLabel("\u65B0\u4E66\u540D\uFF1A");
|
||||
lb_new_name.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_name.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_name.setBounds(285, 476, 194, 55);
|
||||
add(lb_new_name);
|
||||
|
||||
lb_new_classname = new JLabel("\u65B0\u5206\u7C7B\u540D\u79F0\uFF1A");
|
||||
lb_new_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_classname.setBounds(285, 572, 227, 55);
|
||||
add(lb_new_classname);
|
||||
|
||||
lb_new_price = new JLabel("\u65B0\u4EF7\u683C\uFF1A");
|
||||
lb_new_price.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_price.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_price.setBounds(285, 668, 227, 55);
|
||||
add(lb_new_price);
|
||||
|
||||
lb_new_state = new JLabel("\u65B0\u72B6\u6001\uFF1A");
|
||||
lb_new_state.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_state.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_new_state.setBounds(285, 764, 232, 55);
|
||||
add(lb_new_state);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
|
||||
btn_submit = new JButton("\u63D0\u4EA4");
|
||||
btn_submit.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_submit.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_submit.setBounds(570, 850, 251, 80);
|
||||
add(btn_submit);
|
||||
btn_submit.addActionListener(this);
|
||||
@@ -160,14 +160,14 @@ public class UpdateBook extends JPanel implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == back) {
|
||||
// 点击返回按钮
|
||||
// 点击返回按钮
|
||||
MainInterface.UpdatetoManager();
|
||||
} else if (e.getSource() == btn_submit) {
|
||||
// 点击更新信息提交按钮
|
||||
// 旧信息
|
||||
// 点击更新信息提交按钮
|
||||
// 旧信息
|
||||
String old_number = tf_old_number.getText();
|
||||
String old_classname = tf_old_classname.getText();
|
||||
// 新信息
|
||||
// 新信息
|
||||
String number = tf_new_number.getText();
|
||||
String classnumber = tf_new_classnumber.getText();
|
||||
String name = tf_new_name.getText();
|
||||
@@ -176,9 +176,9 @@ public class UpdateBook extends JPanel implements ActionListener {
|
||||
String state = tf_new_state.getText();
|
||||
|
||||
if (!TableOperate.search_bookstate(old_classname, old_number).equals("null")) {
|
||||
// 删除旧书籍信息
|
||||
// 删除旧书籍信息
|
||||
TableOperate.deleteBook(old_number, old_classname);
|
||||
// 插入新书籍信息
|
||||
// 插入新书籍信息
|
||||
TableOperate.insertBook(number, classnumber, name, classname, price, state, "1");
|
||||
tf_old_classname.setText("");
|
||||
tf_old_number.setText("");
|
||||
@@ -188,9 +188,9 @@ public class UpdateBook extends JPanel implements ActionListener {
|
||||
tf_new_classname.setText("");
|
||||
tf_new_price.setText("");
|
||||
tf_new_state.setText("");
|
||||
JOptionPane.showMessageDialog(null, "成功", "更新信息成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "成功", "更新信息成功", JOptionPane.OK_CANCEL_OPTION);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "输入信息有误", "更新信息失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "输入信息有误", "更新信息失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ public class Run {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
// 实例化主界面
|
||||
// 实例化主界面
|
||||
MainInterface frame = new MainInterface();
|
||||
// 显示主界面
|
||||
// 显示主界面
|
||||
frame.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -6,21 +6,21 @@ import me.xixu.Book;
|
||||
|
||||
public class Information {
|
||||
|
||||
// 数据库用户名
|
||||
// 数据库用户名
|
||||
public static String username = "root";
|
||||
// 数据库密码
|
||||
// 数据库密码
|
||||
public static String password = "root";
|
||||
// 数据库URL地址
|
||||
// 数据库URL地址
|
||||
public static String JDBC_URL = "jdbc:mysql://localhost:3306/BookManageSYS";
|
||||
// 查询数据库图书类别名称
|
||||
// 查询数据库图书类别名称
|
||||
public static String search_classname = "";
|
||||
// 查询数据库图书列表
|
||||
// 查询数据库图书列表
|
||||
public static ArrayList<Book> bookarray = new ArrayList<Book>();
|
||||
// 当前管理员
|
||||
// 当前管理员
|
||||
public static String manager = "";
|
||||
// 当前用户
|
||||
// 当前用户
|
||||
public static String user = "";
|
||||
// 查询Table列表
|
||||
// 查询Table列表
|
||||
public static ArrayList<String> tablearray = new ArrayList<String>();
|
||||
|
||||
}
|
||||
@@ -31,30 +31,30 @@ public class BorrowBook extends JPanel implements ActionListener {
|
||||
setLayout(null);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
|
||||
label = new JLabel("\u501F\u4E66\u7CFB\u7EDF");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(530, 62, 294, 105);
|
||||
add(label);
|
||||
|
||||
lb_classname = new JLabel("\u4E66\u5E93\u7C7B\u522B\u540D\u79F0\uFF1A");
|
||||
lb_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classname.setBounds(241, 330, 283, 55);
|
||||
add(lb_classname);
|
||||
|
||||
tf_classname = new JTextField();
|
||||
tf_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classname.setColumns(10);
|
||||
tf_classname.setBounds(502, 320, 526, 75);
|
||||
add(tf_classname);
|
||||
|
||||
btn_search = new JButton("\u67E5\u8BE2");
|
||||
btn_search.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_search.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_search.setBounds(558, 567, 251, 80);
|
||||
add(btn_search);
|
||||
btn_search.addActionListener(this);
|
||||
@@ -70,14 +70,14 @@ public class BorrowBook extends JPanel implements ActionListener {
|
||||
String classname = tf_classname.getText();
|
||||
Information.search_classname = classname;
|
||||
|
||||
// 查询该类图书信息
|
||||
// 查询该类图书信息
|
||||
if (TableOperate.isExist_Table(classname + "book")) {
|
||||
TableOperate.search_classname(tf_classname.getText());
|
||||
MainInterface.BorrowtoBorrowInfo();
|
||||
BorrowBook_Information.setTextArea();
|
||||
tf_classname.setText("");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "不存在该类别", "查询失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "不存在该类别", "查询失败", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BorrowBook_Information extends JPanel implements ActionListener {
|
||||
setLayout(null);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
@@ -47,39 +47,39 @@ public class BorrowBook_Information extends JPanel implements ActionListener {
|
||||
textArea.setEditable(false);
|
||||
|
||||
lb_number = new JLabel("\u56FE\u4E66\u7F16\u53F7\uFF1A");
|
||||
lb_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_number.setBounds(152, 39, 185, 55);
|
||||
add(lb_number);
|
||||
|
||||
tf_number = new JTextField();
|
||||
tf_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_number.setColumns(10);
|
||||
tf_number.setBounds(317, 29, 226, 75);
|
||||
add(tf_number);
|
||||
|
||||
btn_borrow = new JButton("\u501F\u4E66");
|
||||
btn_borrow.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_borrow.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_borrow.setBounds(926, 26, 251, 80);
|
||||
add(btn_borrow);
|
||||
btn_borrow.addActionListener(this);
|
||||
|
||||
lb_dateoff = new JLabel("\u671F\u9650\uFF1A");
|
||||
lb_dateoff.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_dateoff.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_dateoff.setBounds(575, 39, 185, 55);
|
||||
add(lb_dateoff);
|
||||
|
||||
tf_dateoff = new JTextField();
|
||||
tf_dateoff.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_dateoff.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_dateoff.setColumns(10);
|
||||
tf_dateoff.setBounds(679, 29, 226, 75);
|
||||
add(tf_dateoff);
|
||||
|
||||
info = "图书编号 分类编号 图书名称 分类名称 价格 状态 获取人 终止日期\n";
|
||||
info = "图书编号 分类编号 图书名称 分类名称 价格 状态 获取人 终止日期\n";
|
||||
|
||||
}
|
||||
|
||||
public static void setTextArea() {
|
||||
info = "图书编号 分类编号 图书名称 分类名称 价格 状态 获取人 终止日期\n";
|
||||
info = "图书编号 分类编号 图书名称 分类名称 价格 状态 获取人 终止日期\n";
|
||||
|
||||
for (int i = 0; i < Information.bookarray.size(); i++) {
|
||||
info = info + " " + Information.bookarray.get(i).number + " ";
|
||||
@@ -107,18 +107,18 @@ public class BorrowBook_Information extends JPanel implements ActionListener {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == back) {
|
||||
// 点击返回按钮
|
||||
// 点击返回按钮
|
||||
MainInterface.BorrowInfotoBorrow();
|
||||
}
|
||||
if (e.getSource() == btn_borrow) {
|
||||
// 点击借书按钮
|
||||
// 先判定是否有此书
|
||||
// 点击借书按钮
|
||||
// 先判定是否有此书
|
||||
if (TableOperate.search_bookname(Information.search_classname, tf_number.getText()).equals("null")) {
|
||||
JOptionPane.showMessageDialog(null, "输入借书信息有误", "借书失败", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "输入借书信息有误", "借书失败", JOptionPane.ERROR_MESSAGE);
|
||||
tf_number.setText("");
|
||||
tf_dateoff.setText("");
|
||||
} else {
|
||||
// 判定此书是否已被借出
|
||||
// 判定此书是否已被借出
|
||||
if (TableOperate.search_bookstate(Information.search_classname, tf_number.getText()).equals("in")) {
|
||||
TableOperate.borrowBook_Update(Information.search_classname, tf_number.getText(), Information.user,
|
||||
tf_dateoff.getText().toString());
|
||||
@@ -129,9 +129,9 @@ public class BorrowBook_Information extends JPanel implements ActionListener {
|
||||
MainInterface.BorrowInfotoBorrow();
|
||||
MainInterface.BorrowtoUser();
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "该书已借出至:"
|
||||
JOptionPane.showMessageDialog(null, "该书已借出至:"
|
||||
+ TableOperate.search_bookdateoff(Information.search_classname, tf_number.getText()),
|
||||
"借书失败", JOptionPane.ERROR_MESSAGE);
|
||||
"借书失败", JOptionPane.ERROR_MESSAGE);
|
||||
tf_number.setText("");
|
||||
tf_dateoff.setText("");
|
||||
}
|
||||
|
||||
@@ -28,14 +28,14 @@ public class PersonalInformation extends JPanel implements ActionListener {
|
||||
setLayout(null);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
|
||||
label = new JLabel("\u4E2A\u4EBA\u4FE1\u606F");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(530, 20, 294, 105);
|
||||
add(label);
|
||||
|
||||
@@ -45,12 +45,12 @@ public class PersonalInformation extends JPanel implements ActionListener {
|
||||
textArea.setBounds(111, 125, 1050, 782);
|
||||
add(textArea);
|
||||
|
||||
info = "图书编号 分类名称 图书名称 还书期限\n";
|
||||
info = "图书编号 分类名称 图书名称 还书期限\n";
|
||||
|
||||
}
|
||||
|
||||
public static void setTextArea() {
|
||||
info = "图书编号 分类名称 图书名称 还书期限\n";
|
||||
info = "图书编号 分类名称 图书名称 还书期限\n";
|
||||
|
||||
for (int i = 0; i < Information.bookarray.size(); i++) {
|
||||
info = info + " " + Information.bookarray.get(i).number + " ";
|
||||
|
||||
@@ -33,52 +33,52 @@ public class ProlongBook extends JPanel implements ActionListener {
|
||||
setLayout(null);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("ËÎÌå", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
|
||||
JLabel label = new JLabel("\u7EED\u501F\u7CFB\u7EDF");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("ËÎÌå", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(530, 20, 294, 105);
|
||||
add(label);
|
||||
|
||||
lb_classname = new JLabel("\u4E66\u5E93\u7C7B\u522B\u540D\u79F0\uFF1A");
|
||||
lb_classname.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
lb_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classname.setBounds(281, 216, 283, 55);
|
||||
add(lb_classname);
|
||||
|
||||
tf_classname = new JTextField();
|
||||
tf_classname.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
tf_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classname.setColumns(10);
|
||||
tf_classname.setBounds(554, 206, 526, 75);
|
||||
add(tf_classname);
|
||||
|
||||
lb_number = new JLabel("\u4E66\u7C4D\u7F16\u53F7\uFF1A");
|
||||
lb_number.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
lb_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_number.setBounds(281, 360, 283, 55);
|
||||
add(lb_number);
|
||||
|
||||
lb_dateoff = new JLabel("\u7EED\u501F\u671F\u9650\uFF1A");
|
||||
lb_dateoff.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
lb_dateoff.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_dateoff.setBounds(281, 498, 283, 55);
|
||||
add(lb_dateoff);
|
||||
|
||||
tf_number = new JTextField();
|
||||
tf_number.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
tf_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_number.setColumns(10);
|
||||
tf_number.setBounds(554, 350, 526, 75);
|
||||
add(tf_number);
|
||||
|
||||
tf_dateoff = new JTextField();
|
||||
tf_dateoff.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
tf_dateoff.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_dateoff.setColumns(10);
|
||||
tf_dateoff.setBounds(554, 488, 526, 75);
|
||||
add(tf_dateoff);
|
||||
|
||||
btn_prolong = new JButton("\u7EED\u501F");
|
||||
btn_prolong.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
btn_prolong.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_prolong.setBounds(554, 661, 251, 80);
|
||||
add(btn_prolong);
|
||||
btn_prolong.addActionListener(this);
|
||||
@@ -87,7 +87,7 @@ public class ProlongBook extends JPanel implements ActionListener {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//
|
||||
//
|
||||
if (e.getSource() == back) {
|
||||
MainInterface.ProlongtoUser();
|
||||
} else if (e.getSource() == btn_prolong) {
|
||||
|
||||
@@ -35,52 +35,52 @@ public class ReturnBook extends JPanel implements ActionListener {
|
||||
setLayout(null);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("ËÎÌå", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
|
||||
label = new JLabel("\u8FD8\u4E66\u7CFB\u7EDF");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("ËÎÌå", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(529, 69, 294, 105);
|
||||
add(label);
|
||||
|
||||
lb_classname = new JLabel("\u4E66\u5E93\u7C7B\u522B\u540D\u79F0\uFF1A");
|
||||
lb_classname.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
lb_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classname.setBounds(240, 302, 283, 55);
|
||||
add(lb_classname);
|
||||
|
||||
tf_classname = new JTextField();
|
||||
tf_classname.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
tf_classname.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_classname.setColumns(10);
|
||||
tf_classname.setBounds(503, 292, 526, 75);
|
||||
add(tf_classname);
|
||||
|
||||
btn_return = new JButton("\u5F52\u8FD8");
|
||||
btn_return.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
btn_return.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
btn_return.setBounds(557, 764, 251, 80);
|
||||
add(btn_return);
|
||||
btn_return.addActionListener(this);
|
||||
|
||||
lb_classnumber = new JLabel("\u56FE\u4E66\u7F16\u53F7\uFF1A");
|
||||
lb_classnumber.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
lb_classnumber.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_classnumber.setBounds(240, 454, 283, 55);
|
||||
add(lb_classnumber);
|
||||
|
||||
tf_number = new JTextField();
|
||||
tf_number.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
tf_number.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_number.setColumns(10);
|
||||
tf_number.setBounds(503, 444, 526, 75);
|
||||
add(tf_number);
|
||||
|
||||
lb_today = new JLabel("\u8FD8\u4E66\u65E5\u671F\uFF1A");
|
||||
lb_today.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
lb_today.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
lb_today.setBounds(240, 590, 283, 55);
|
||||
add(lb_today);
|
||||
|
||||
tf_today = new JTextField();
|
||||
tf_today.setFont(new Font("ËÎÌå", Font.BOLD, 35));
|
||||
tf_today.setFont(new Font("宋体", Font.BOLD, 35));
|
||||
tf_today.setColumns(10);
|
||||
tf_today.setBounds(503, 580, 526, 75);
|
||||
add(tf_today);
|
||||
@@ -98,7 +98,7 @@ public class ReturnBook extends JPanel implements ActionListener {
|
||||
String today = tf_today.getText();
|
||||
|
||||
if (TableOperate.search_bookdateoff(classname, number) < Integer.parseInt(today)) {
|
||||
JOptionPane.showMessageDialog(null, "ллºÏ×÷", "ÇëÈ¥½ÉÄÉ·£¿î", JOptionPane.OK_CANCEL_OPTION);
|
||||
JOptionPane.showMessageDialog(null, "谢谢合作", "请去缴纳罚款", JOptionPane.OK_CANCEL_OPTION);
|
||||
}
|
||||
|
||||
TableOperate.returnBook_Update(classname, number, Information.user, today);
|
||||
|
||||
@@ -31,43 +31,43 @@ public class UserInterface extends JPanel implements ActionListener {
|
||||
setLayout(null);
|
||||
|
||||
back = new JButton("\u8FD4\u56DE");
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setFont(new Font("宋体", Font.PLAIN, 26));
|
||||
back.setBounds(0, 0, 115, 82);
|
||||
add(back);
|
||||
back.addActionListener(this);
|
||||
|
||||
label = new JLabel("\u7528\u6237\u754C\u9762");
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
label.setBounds(512, 47, 294, 105);
|
||||
add(label);
|
||||
|
||||
lb_user = new JLabel("New label");
|
||||
lb_user.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lb_user.setFont(new Font("宋体", Font.BOLD, 28));
|
||||
lb_user.setFont(new Font("宋体", Font.BOLD, 28));
|
||||
lb_user.setBounds(944, 0, 356, 56);
|
||||
add(lb_user);
|
||||
|
||||
btn_borrow = new JButton("\u501F\u4E66");
|
||||
btn_borrow.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_borrow.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_borrow.setBounds(31, 233, 280, 505);
|
||||
add(btn_borrow);
|
||||
btn_borrow.addActionListener(this);
|
||||
|
||||
btn_return = new JButton("\u8FD8\u4E66");
|
||||
btn_return.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_return.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_return.setBounds(351, 233, 280, 505);
|
||||
add(btn_return);
|
||||
btn_return.addActionListener(this);
|
||||
|
||||
btn_prolong = new JButton("\u7EED\u501F");
|
||||
btn_prolong.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_prolong.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_prolong.setBounds(674, 233, 280, 505);
|
||||
add(btn_prolong);
|
||||
btn_prolong.addActionListener(this);
|
||||
|
||||
btn_personal = new JButton("\u4E2A\u4EBA\u4FE1\u606F");
|
||||
btn_personal.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_personal.setFont(new Font("宋体", Font.BOLD, 40));
|
||||
btn_personal.setBounds(999, 233, 280, 505);
|
||||
add(btn_personal);
|
||||
btn_personal.addActionListener(this);
|
||||
@@ -75,7 +75,7 @@ public class UserInterface extends JPanel implements ActionListener {
|
||||
}
|
||||
|
||||
public static void setUser() {
|
||||
lb_user.setText("当前用户:" + Information.user);
|
||||
lb_user.setText("当前用户:" + Information.user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user