首页 > 开发 > 综合 > 正文

图书管理程序管理员界面

2024-07-21 02:52:46
字体:
来源:转载
供稿:网友

主界面

#ifndef DBAWIN_H#define DBAWIN_H#include<QtGui>class dbawin:public QWidget{ Q_OBJECTpublic slots: void ret(void); void lend(void); void change(void); void changestudent(void);public: dbawin(QWidget *parent=0);public: QLabel lendla,retla; QPushButton lendb,retb,inputb,changb,changes; QLineEdit lendline,retline;};#endif

实现

#include "myWeiget.h"#include "studentinfo.h"#include "studentwin.h"#include "dbawin.h"#include "tushuku.h"#include <QSqlDriver>#include <QSqlDatabase>#include <QSqlQuery>#include <QtSql>dbawin::dbawin(QWidget *parent) :QWidget(parent),lendla(QObject::tr("借书号"),this),lendline(this), retla(QObject::tr("还书号"),this),retline(this), lendb(QObject::tr("借出"),this),retb(QObject::tr("归还"),this), changb(QObject::tr("修改库存图书"),this), changes(QObject::tr("修改学生信息"),this){ retla.setGeometry(30,30,50,30); retline.setGeometry(100,30,100,30); retb.setGeometry(QRect(250,30,60,30)); lendla.setGeometry(30,90,50,30); lendline.setGeometry(100,90,100,30); lendb.setGeometry(QRect(250,90,60,30)); inputb.setGeometry(QRect(80,200,100,40)); changb.setGeometry(QRect(50,200,100,40)); changes.setGeometry(QRect(220,200,100,40)); connect(&lendb,SIGNAL(clicked(void)),this,SLOT(lend(void))); connect(&retb,SIGNAL(clicked(void)),this,SLOT(ret(void))); connect(&changb,SIGNAL(clicked(void)),this,SLOT(change(void))); connect(&changes,SIGNAL(clicked(void)),this,SLOT(changestudent(void)));}void dbawin::lend(){ QString bno=lendline.text().trimmed(); QSqlQuery query; query.PRepare("UPDATE book SET 借阅状态='out' WHERE 书号=:bno"); query.bindValue(":bno",bno); query.exec(); QSqlQuery query2; query2.prepare("select * from book where 书号=:bno"); query2.bindValue(":bno",bno); query2.exec(); QSqlQueryModel *model = new QSqlQueryModel; model->setQuery(query2); QTableView *view = new QTableView; view->setModel(model); view->show();}void dbawin::ret(){ QString bno=retline.text().trimmed(); QSqlQuery query; query.prepare("UPDATE book SET 借阅状态='in' WHERE 书号=:bno"); query.bindValue(":bno",bno); query.exec(); QSqlQuery query2; query2.prepare("select * from book where 书号=:bno"); query2.bindValue(":bno",bno); query2.exec(); QSqlQueryModel *model = new QSqlQueryModel; model->setQuery(query2); QTableView *view = new QTableView; view->setModel(model); view->show();}void dbawin::change(){ tushuku *d= new tushuku(); d->show();}void dbawin::changestudent(){ studentinfo *d= new studentinfo(); d->show();}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表