连接数据表warehouse

master
金安民 2 months ago
parent dda1cc7ad0
commit 1291d9bbc0

Binary file not shown.

@ -14,8 +14,8 @@ public class DML {
try (Connection conn = DriverManager.getConnection(URL);
Statement stmt = conn.createStatement()) {
// 创建入库记录表
String sql = "CREATE TABLE IF NOT EXISTS inbound_records (" +
String sql = "CREATE TABLE IF NOT EXISTS warehouse (" +
"id TEXT PRIMARY KEY NOT NULL," +
"goods_id TEXT NOT NULL," +
"quantity INTEGER NOT NULL," +
@ -26,39 +26,14 @@ public class DML {
");";
stmt.execute(sql);
System.out.println("入库记录表创建成功");
System.out.println("仓库数据表创建成功");
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void createWarehouseTable() {
try (Connection conn = DriverManager.getConnection(URL);
Statement stmt = conn.createStatement()) {
// 创建仓库存放数据表
String sql = "CREATE TABLE IF NOT EXISTS warehouse (" +
"id TEXT PRIMARY KEY NOT NULL," +
"goods_id TEXT NOT NULL," +
"goods_name TEXT NOT NULL," +
"quantity INTEGER NOT NULL," +
"operation_type TEXT NOT NULL," +
"operator TEXT," +
"operation_time TIMESTAMP," +
"supplier TEXT," +
"customer TEXT," +
"remark TEXT" +
");";
stmt.execute(sql);
System.out.println("仓库数据表创建成功");
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void createLogTable() {
@ -67,7 +42,7 @@ public class DML {
// 创建操作日志数据表
String sql = "CREATE TABLE IF NOT EXISTS operation_logs (" +
"日志id TEXT PRIMARY KEY NOT NULL," + //日志id
"id TEXT PRIMARY KEY NOT NULL," + //日志id
"operation_type TEXT NOT NULL," + // 操作类型(入库、出库、修改等)
"operation_target TEXT NOT NULL," + // 操作对象货物ID或名称
"operator TEXT," + // 操作人
@ -104,7 +79,7 @@ public class DML {
Statement stmt = conn.createStatement()) {
// 删除表的SQL 语句
String sql = "DROP TABLE IF EXISTS 表名";
String sql = "DROP TABLE IF EXISTS inbound_records";
// 执行 SQL 语句
stmt.execute(sql);

@ -115,7 +115,7 @@ public class DataManager {
" WHEN SUM(quantity) < 10 THEN '库存偏低' " +
" ELSE '库存正常' " +
" END as remark " +
"FROM inbound_records " +
"FROM warehouse " +
"GROUP BY goods_id " +
"ORDER BY goods_id";

@ -188,7 +188,7 @@ public class InboundView extends BorderPane {
// 修改数据库连接为相对路径
String url = "jdbc:sqlite:db/dbuml.db3";
try (Connection conn = DriverManager.getConnection(url)) {
String sql = "INSERT INTO inbound_records (id, goods_id, quantity, supplier, inbound_time, operator, remark) " +
String sql = "INSERT INTO warehouse (id, goods_id, quantity, supplier, inbound_time, operator, remark) " +
"VALUES (?, ?, ?, ?, ?, ?, ?)";
try (PreparedStatement pstmt = conn.prepareStatement(sql)) {
@ -256,7 +256,7 @@ public class InboundView extends BorderPane {
private void loadInboundRecords() {
String url = "jdbc:sqlite:db/dbuml.db3";
try (Connection conn = DriverManager.getConnection(url)) {
String sql = "SELECT * FROM inbound_records ORDER BY inbound_time DESC";
String sql = "SELECT * FROM warehouse ORDER BY inbound_time DESC";
try (Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql)) {

Loading…
Cancel
Save