-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathaddinfo.cpp
82 lines (77 loc) · 2.29 KB
/
addinfo.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "addinfo.h"
#include "ui_addinfo.h"
#include "mysql.h"
AddInfo::AddInfo(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::AddInfo)
{
Sparent=(StuInfoManage*) parent;
ui->setupUi(this);
}
AddInfo::~AddInfo()
{
delete ui;
}
void AddInfo::on_buttonBox_clicked(QAbstractButton *button)
{
if(ui->buttonBox->button(QDialogButtonBox::Ok) == button)
{
my_stu tran;
tran.account = ui->acount->text();
tran.name = ui->name->text();
tran.sex = ui->sex->currentText();
tran.age = ui->age->text().toInt();
tran.identify = ui->identify->text();
tran.tel = ui->tel->text();
tran.enroll_time = ui->enroll->text();
tran.leave_time = ui->leave->text();
tran.scondition = ui->condition->currentText();
tran.text = ui->textEdit->toPlainText();
QProgressDialog dialog(tr("正在添加"),tr("取消"), 0, 30000, this);
dialog.setWindowTitle(tr("进度"));
dialog.setWindowModality(Qt::WindowModal);
dialog.show();
for(int k = 0; k < 30000; k++)
{
dialog.setValue(k);
QCoreApplication::processEvents();
if(dialog.wasCanceled())
{
break;
}
}
dialog.setValue(30000);
MySql mysql;
bool ret = mysql.addstu(&tran);
if(ret == false)
{
QMessageBox::information(this, tr("消息"), tr("添加失败!"), QMessageBox::Ok);
this->close();
Sparent->show();
return;
}
QMessageBox::information(this, tr("消息"), tr("添加成功!"), QMessageBox::Ok);
this->close();
Sparent->show();
return;
}
else if(ui->buttonBox->button(QDialogButtonBox::Cancel) == button)
{
this->close();
QProgressDialog dialog(tr("正在返回主界面"),tr("取消"), 0, 3000, this);
dialog.setWindowTitle(tr("进度"));
dialog.setWindowModality(Qt::WindowModal);
dialog.show();
for(int k = 0; k < 3000; k++)
{
dialog.setValue(k);
QCoreApplication::processEvents();
if(dialog.wasCanceled())
{
break;
}
}
dialog.setValue(3000);
Sparent->show();
}
}