学生信息管理系统使用说明及其报告
目录
学生信息管理系统使用说明及其报告 1
一.使用说明 1
二.studentmanager 数据库表格说明 1
三.本程序需解决的关键技术问题 3
四.功能展现 5
五.心得小结: 10
一.使用说明
该学生信息管理系统使用的数据库为MySQL;
在另外一台电脑上(老师的电脑)运行时运行环境必须满足以下要求:
1,那台电脑必须要安装数据库MySQL;安装引导里一定要将默认的latin1编码换成utf8编码,不然后面会中文乱码
2,在那台电脑的MySQL中导入本人数据库脚本文件 studentmanager.sql (该文件已打包好)(这里推荐使用navicate for mysql 导入 数据库创建是要选择utf8编码,不然后期会出现数据库中文乱码)
3,在MySQL的安装目录下的lib文件夹中的libmysql.dll文件复制到Qt安装目录下的bin目录中
4,最后在原代码中的globle.cpp 文件中更改连接数据库的账号和密码( 更改QString sqluser=“root” 的值为更改账号。本文转载自http://www.biyezuopin.vip/onews.asp?id=14814更改QString sqlpass=“123456” 的值为更改密码。
此处我的数据库账号为root 密码为123456。此处账号密码要对应自己MySQL账号密码)
以上步骤若没完成则会编译运行不了
二.studentmanager 数据库表格说明
该 studentmanager.sql 有六张表:用Navicat for MySQL (数据库图形界面操作软件)
展现的。
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include
#include
#include "manger.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// connect(ui->LoginButton, SIGNAL(clicked()), this, SLOT(on_LoginButton_clicked()));
// ui->hide();
// connect(ui->LoginButton, SIGNAL(clicked()), this, SLOT(show2()));
ui->Login_password->setEchoMode(QLineEdit::Password);
ui->Login_username->setText("xh");
ui->Login_password->setText("1234567");
ui->radioButton_2->setChecked(true);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_LoginButton_clicked()
{
QString username = ui->Login_username->text();
QString password = ui->Login_password->text();
qDebug()<<"用户名:"<radioButton->isChecked()){
QSqlQuery query(db);
db.exec("SET NAMES 'GBK'");
query.exec("select id,username,password from admin");
bool T1=false;
while(query.next())
{
QString user = query.value(1).toString();
QString pass = query.value(2).toString();
qDebug() << user << pass ;
if(username.compare(user)==0&&password.compare(pass)==0){
password_qj=password;
username_qj=username;
T1=true;
this->hide();
m=new manger;
// emit sendData(username+"&"+password);
m->show();
}
}
if(T1==false)
QMessageBox::information(this, "警告", "用户名或密码错误");
}
if( ui->radioButton_2->isChecked()){
QSqlQuery query(db);
db.exec("SET NAMES 'GBK'");
query.exec("select id,name,password from student");
bool T=false;
while(query.next())
{
QString user = query.value(1).toString();
QString pass = query.value(2).toString();
qDebug() << user << pass ;
if(username.compare(user)==0&&password.compare(pass)==0){
password_qj=password;
username_qj=username;
T=true;
this->hide();
f=new studentForm;
// emit sendData(username+"&"+password);
f->show();
}
}
if(T==false)
QMessageBox::information(this, "警告", "用户名或密码错误");
}
}
void MainWindow::show2(){
this->hide();
f=new studentForm;
// connect(f-)
f->show();
}
void MainWindow::on_remitButton_clicked()
{
ui->Login_username->clear();
ui->Login_password->clear();
}