-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodifyteacherwidget.cpp
More file actions
56 lines (50 loc) · 1.51 KB
/
modifyteacherwidget.cpp
File metadata and controls
56 lines (50 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "modifyteacherwidget.h"
#include "ui_modifyteacherwidget.h"
ModifyTeacherWidget::ModifyTeacherWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::ModifyTeacherWidget)
{
ui->setupUi(this);
QSqlQuery query;
query.exec("select Dname from Dept");
if(query.lastError().type()==QSqlError::NoError){
QStringList depts;
while(query.next()){
depts<<query.value(0).toString();
}
ui->DeptBox->addItems(depts);
}else{
QMessageBox::warning(this,"查询院系信息错误",query.lastError().text());
}
}
ModifyTeacherWidget::~ModifyTeacherWidget()
{
delete ui;
}
void ModifyTeacherWidget::on_QuitButton_clicked()
{
this->close();
}
void ModifyTeacherWidget::setTno(QString tno_,QString tname_,QString dept_){
this->tno=tno_;
this->tname=tname_;
this->dept=dept_;
}
void ModifyTeacherWidget::flush(){
ui->lineEdit->setText(tno);
ui->NameEdit->setText(tname);
ui->DeptBox->setCurrentText(dept);
}
void ModifyTeacherWidget::on_ConfirmButton_clicked()
{
QString name=ui->NameEdit->text();
QString dep=ui->DeptBox->currentText();
QSqlQuery query;
query.exec("update Teacher set Tname='"+name+"',Tdept='"+dep+"' where Tno='"+tno+"'");
if(query.lastError().type()==QSqlError::NoError){
QMessageBox::information(this,"修改教师信息","修改教师信息成功!");
this->close();
}else{
QMessageBox::warning(this,"修改教师信息错误",query.lastError().text());
}
}