// 删除设备
public static boolean deleteEqu(String id) {
// delete from equ where id = '10001';
SqliteDb db = new SqliteDb();
Connection conn = db.connect();
id = String.format("delete from equ where id = '%s'", id);
boolean bool = db.executeUpdate(conn, id);
db.disconnect(conn);
return bool;
}
// 查找设备
public static List<Equ> queryAll(String names) {
// select * from equ;
SqliteDb db = new SqliteDb();
Connection conn = db.connect();
names = String.format("select * from %s", names);
List<Equ> bool = db.executeQuery(conn, names);
return bool;
}
// 根据名字模糊查询
public static List<Equ> queryByName(String name) {
// select * from equ where name like '%笔记本%';
SqliteDb db = new SqliteDb();
Connection conn = db.connect();
name = String.format("select * from equ where name like '%s'", name);
List<Equ> bool = db.executeQuery(conn, name);
db.disconnect(conn);
return bool;
}
// 更新设备信息,根据id修改其他信息
public static boolean updateEqu(Equ equ) {
// update equ set name = '华硕' where id = '10001';
String id = equ.getId();
String name = equ.getName();
String location = equ.getLocation();
SqliteDb db = new SqliteDb();
Connection conn = db.connect();
id = String.format("update equ set name = '%s',location = '%s' where id = '%s'", name,location,id);
boolean bool = db.executeUpdate(conn, id);
db.disconnect(conn);
return bool;
}