-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.cpp
122 lines (117 loc) · 3.42 KB
/
search.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "search.h"
#include "ui_search.h"
extern int count_manager, count_technician, count_salesmanager, count_salesman, delete_number;
extern Manager manager[1000];
extern Technician technician[1000];
extern Salesmanager salesmanager[1000];
extern Salesman salesman[1000];
extern QString expression_id, expression_name, expression_grade, expression_salary;
search::search(QWidget *parent) :
QWidget(parent),
ui(new Ui::search)
{
ui->setupUi(this);
}
search::~search()
{
delete ui;
}
void search::on_pushButton_clicked()
{
QString search = ui->textEdit->toPlainText();
int i, j = 0, many = count_manager + count_technician + count_salesmanager + count_salesman;
combine comb[many + 3], comb_temp;
//try {
for(i = 1; i <= count_manager; i++) {
if(!manager[i].getdel()) {
j++;
comb[j].classname = 1;
comb[j].classid = i;
comb[j].name = manager[i].getName();
}
}
for(i = 1; i <= count_technician; i++) {
if(!technician[i].getdel()) {
j++;
comb[j].classname = 2;
comb[j].classid = i;
comb[j].name = technician[i].getName();
}
}
for(i = 1; i <= count_salesmanager; i++) {
if(!salesmanager[i].getdel()) {
j++;
comb[j].classname = 3;
comb[j].classid = i;
comb[j].name = salesmanager[i].getName();
}
}
for(i = 1; i <= count_salesman; i++) {
if(!salesman[i].getdel()) {
j++;
comb[j].classname = 4;
comb[j].classid = i;
comb[j].name = salesman[i].getName();
}
}
for(i = 1; i < many - delete_number; i++) {
int k = i;
for(j = i; j <= many - delete_number; j++) {
if(comb[j].name < comb[k].name) {
k = j;
}
}
if(k != i) {
comb_temp = comb[k];
comb[k] = comb[i];
comb[i] = comb_temp;
}
}
bool f = false;
for(i = 1; i <= many - delete_number; i++) {
if(comb[i].classname == 1) {
if(manager[comb[i].classid].getName() == search) {
manager[comb[i].classid].show();
f = true;
}
}
if(comb[i].classname == 2) {
if(technician[comb[i].classid].getName() == search) {
technician[comb[i].classid].show();
f = true;
}
}
if(comb[i].classname == 3) {
if(salesmanager[comb[i].classid].getName() == search) {
salesmanager[comb[i].classid].show();
f = true;
}
}
if(comb[i].classname == 4) {
if(salesman[comb[i].classid].getName() == search) {
salesman[comb[i].classid].show();
f = true;
}
}
}
/*if(!f) {
throw search;
}
} catch(QString s) {
QMessageBox::warning(this, "警告", "未找到" + s);
}*/
if(!f) {
QMessageBox::information(this, "查找", "未找到");
}
else {
ui->label_id -> setText(expression_id);
ui->label_grade->setText(expression_grade);
ui->label_name->setText(expression_name);
ui->label_salary->setText(expression_salary);
}
expression_id.clear();
expression_grade.clear();
expression_name.clear();
expression_salary.clear();
ui->textEdit->clear();
}