-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchWidget.cpp
57 lines (47 loc) · 1.33 KB
/
SearchWidget.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
#include "SearchWidget.h"
SearchWidget::SearchWidget(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
SearchWidget::~SearchWidget()
{
}
//主菜单按钮点击
void SearchWidget::on_returnButton_clicked() {
//将控件重新初始化
ui.numberrLineEdit->clear();
ui.nameShowLabel->setText("NULL");
ui.salGradeShowLabel->setText("NULL");
ui.salaryShowLabel->setText("NULL");
ui.jobShowLabel->setText("NULL");
emit display_Widget(menuWidget);
}
//查询按钮点击
void SearchWidget::on_searchButton_clicked() {
extern list<Employee> employees;
if (ui.numberrLineEdit->text() == "")
{
QMessageBox::about(NULL, "WARNING", "Number cannot be empty");
return;
}
QString number = ui.numberrLineEdit->text();
string tnumber = number.toStdString();
bool has_person = false;
for (list<Employee>::iterator nowit = employees.begin(); nowit != employees.end(); nowit++) {
if ((*nowit).getNo() == tnumber)
{
has_person = true;
ui.nameShowLabel->setText(QString::fromStdString((*nowit).getName()));
ui.salGradeShowLabel->setText(QString::fromStdString((*nowit).getSalGrade()));
ui.salaryShowLabel->setText(QString("%1").arg((*nowit).getSalary()));
ui.jobShowLabel->setText(QString::fromStdString((*nowit).getJob()));
return;
}
}
if (!has_person)
{
QMessageBox::about(NULL, "WARNING", "The number does not exist");
return;
}
}