1 Star 0 Fork 1

QT嵌入式/wisdom

forked from Shui-Qing/wisdom 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
widget.cpp 2.35 KB
一键复制 编辑 原始数据 按行查看 历史
Shui-Qing 提交于 2020-06-15 11:39 . Add files via upload
#include "widget.h"
#include "ui_widget.h"
#include <QSqlDatabase>
#include <QMessageBox>
#include <QSqlError>
#include <QSqlQuery>
#include <QVariantList>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
//添加数据库
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("wisdom.db");
//打开数据库
if(!db.open())
{
QMessageBox::warning(this,"错误:",db.lastError().text());
return;
}
// admin *ad = new admin();
// ad->show();
// Form *form = new Form();
// form->show();
// owner *own = new owner();
// own->show();
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_clicked()
{
int root = ui->comboBox->currentIndex ();
QString username = ui->lineEdit->text();
QString password = ui->lineEdit_2->text();
QSqlQuery query;
query.prepare("select * from user where username=:username and password=:password and root=:root");
query.bindValue(":username",username);
query.bindValue(":password",password);
query.bindValue(":root",root);
query.exec();
if(query.next())
{
if(root==0){
query.prepare("update user set flag=1 where username=:username");
query.bindValue(":username",username);
query.exec();
// qDebug()<<"管理员登录:ad";
this->close();
admin *ad = new admin();
ad->show();
}
if(root==1){
query.prepare("update user set flag=1 where username=:username");
query.bindValue(":username",username);
query.exec();
// qDebug()<<"工作人员登录:form";
this->close();
Form *form = new Form();
form->show();
}
if(root==2){
query.prepare("update user set flag=1 where username=:username");
query.bindValue(":username",username);
query.exec();
// qDebug()<<"业主登录:own";
this->close();
owner *own = new owner();
own->show();
}
// NAME = query.value(1).toString();
}else{
QMessageBox::information(this,tr("错误"),tr("账号或密码错误!"),tr("返回"));
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qt-embedded/wisdom.git
[email protected]:qt-embedded/wisdom.git
qt-embedded
wisdom
wisdom
master

搜索帮助