重构各页面代码,从h文件改为cpp文件;
添加硬件接口并添加,readerAPI使用硬件接口获取invenory信息和connect; 完成开卡初始页面,获取卡号和学号。
This commit is contained in:
41
deviceAPI.cpp
Normal file
41
deviceAPI.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "deviceAPI.h"
|
||||
|
||||
bool Device::is_connected()
|
||||
{
|
||||
return connected;
|
||||
}
|
||||
|
||||
|
||||
bool Device::is_depositAllowed()
|
||||
{
|
||||
return depositAllowed;
|
||||
}
|
||||
|
||||
|
||||
void Device::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 Device::getName()
|
||||
{
|
||||
if (connected) {
|
||||
if (depositAllowed) return name + QString("(可充值)");
|
||||
else return name + QString("(仅可消费)");
|
||||
}
|
||||
else return QString("未指定设备名");
|
||||
}
|
||||
Reference in New Issue
Block a user