重构各页面代码,从h文件改为cpp文件;
添加硬件接口并添加,readerAPI使用硬件接口获取invenory信息和connect; 完成开卡初始页面,获取卡号和学号。
This commit is contained in:
40
deviceAPI.h
40
deviceAPI.h
@@ -13,42 +13,10 @@ private:
|
||||
QString name = QString("未指定设备名");
|
||||
|
||||
public:
|
||||
bool is_connected()
|
||||
{
|
||||
return connected;
|
||||
}
|
||||
|
||||
bool is_depositAllowed()
|
||||
{
|
||||
return depositAllowed;
|
||||
}
|
||||
|
||||
void setDevice(QString name, Database *db)
|
||||
{
|
||||
QSqlQuery query(db->getDatabase());
|
||||
QString sql = QString("select * from device where `name` = '%1';").arg(name);
|
||||
query.exec(sql);
|
||||
if (query.next())
|
||||
{
|
||||
connected = true;
|
||||
this->name = name;
|
||||
depositAllowed = query.value(2).toBool();
|
||||
}
|
||||
else
|
||||
{
|
||||
connected = false;
|
||||
depositAllowed = false;
|
||||
}
|
||||
}
|
||||
|
||||
QString getName()
|
||||
{
|
||||
if (connected) {
|
||||
if (depositAllowed) return name + QString("(可充值)");
|
||||
else return name + QString("(仅可消费)");
|
||||
}
|
||||
else return QString("未指定设备名");
|
||||
}
|
||||
bool is_connected();
|
||||
bool is_depositAllowed();
|
||||
void setDevice(QString name, Database *db);
|
||||
QString getName();
|
||||
};
|
||||
|
||||
#endif // DEVICEAPI_H
|
||||
|
||||
Reference in New Issue
Block a user