登录界面读取本地txt文件,设置2个角色的登录,管理员以及普通用户角色。废话不说。上代码!
if(ui->comboBox_SF->currentText() == "管理员")
{
QString name = ui->lineEdit_ID->text();
QString password = ui->lineEdit_PWD->text();
//读取文本文件保存的管理员用户名和密码信息
QString FileName = QCoreApplication::applicationDirPath() + "/AdminAccount.txt";
QSettings s(FileName, QSettings::IniFormat);
QString TrueName = s.value("/name", "admin").toString();
QString TruePassword = s.value("/password", "admin").toString();
//判断用户名与密码是否正确
if((name == TrueName) && (password == TruePassword) && (TrueName != NULL) && (TruePassword != NULL))
{
m_mainsence->show();
this->hide();
}
else
{
QMessageBox::warning(this,"警告","账号密码错误!",QMessageBox::Yes);
ui->lineEdit_ID->clear();
ui->lineEdit_PWD->clear();
}
}
else if(ui->comboBox_SF->currentText() == "普通用户")
{
QString name = ui->lineEdit_ID->text();
QString password = ui->lineEdit_PWD->text();
//读取文本文件保存的管理员用户名和密码信息
QString FileName = QCoreApplication::applicationDirPath() + "/AdminAccount.txt";
QSettings s(FileName, QSettings::IniFormat);
QString TrueName = s.value("/name", "GaoTian").toString();
QString TruePassword = s.value("/password", "12345678").toString();
//判断用户名与密码是否正确
if((name == TrueName) && (password == TruePassword) && (TrueName != NULL) && (TruePassword != NULL))
{
m_studentms->show();
this->hide();
}
else
{
QMessageBox::warning(this,"警告","账号密码错误!",QMessageBox::Yes);
ui->lineEdit_ID->clear();
ui->lineEdit_PWD->clear();
}
}
管理员界面
普通用户可以预约教室,以及推荐人数最少的教室的功能(涉及到算法)