-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest_blood.cpp
203 lines (167 loc) · 5.73 KB
/
request_blood.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#include "request_blood.h"
#include "ui_request_blood.h"
#include "donate_blood.h"
#include "my_details.h"
#include "mainwindow.h"
#include "about.h"
#include "why_become_donor.h"
#include "userdashboard.h"
request_blood::request_blood(QWidget *parent) :
QDialog(parent),
ui(new Ui::request_blood)
{
setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint);
setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint);
ui->setupUi(this);
QDate d = QDate::currentDate();
ui->dateEdit->setDate(d);
}
request_blood::~request_blood()
{
delete ui;
}
void request_blood::on_my_details_2_clicked()
{
donate_blood dq;
dq.setModal(true);
hide();
dq.exec();
}
void request_blood::on_my_details_3_clicked()
{
request_blood rq;
rq.setModal(true);
hide();
rq.exec();
}
void request_blood::on_my_details_clicked()
{
my_details m1;
m1.setModal(true);
hide();
m1.exec();
}
void request_blood::on_login_clicked()
{
userDashboard ud;
ud.setModal(true);
hide();
ud.exec();
}
void request_blood::on_register_2_clicked()
{
QSqlDatabase db=QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("C:/Users/user/OneDrive/Documents/Final/Databases/final.db");
if(db.open())
{
QString contact_person_name=ui->contact_person->text();
QString patient_name=ui->patient_name->text();
QString age=ui->age->text();
QString blood_group=ui->blood_group->text();
QString gender=ui->gender->text();
QString phone_number=ui->phone_number->text();
QString required_units=ui->required_unit->text();
QString detail=ui->detail->text();
QDate date = ui->dateEdit->date();
QString RequiredDate = date.toString();
if(contact_person_name != "" && patient_name != "" && age != "" && blood_group != "" && gender != "" && phone_number != "" && required_units != "" && detail != ""){
QSqlQuery qry;
qry.prepare("INSERT INTO patient_details(contact_person_name,patient_name,age,blood_group,gender,phone_number,required_units,detail_about_case,Required_Date) "
"VALUES('"+contact_person_name+"', '"+patient_name+"', '"+age+"', '"+blood_group+"', '"+gender+"', '"+phone_number+"', '"+required_units+"', '"+detail+"','"+RequiredDate+"')");
qry.bindValue(":contact_person_name", contact_person_name);
qry.bindValue(":patient_name", patient_name);
qry.bindValue(":age", age);
qry.bindValue(":blood_group", blood_group);
qry.bindValue(":gender", gender);
qry.bindValue(":phone_number", phone_number);
qry.bindValue(":required_units", required_units);
qry.bindValue(":detail_about_case", detail);
qry.bindValue(":Required_Date",RequiredDate);
if(qry.exec())
{
QMessageBox::information(this,"Information","You will be notified soon about blood");
request_blood rq;
rq.setModal(true);
hide();
rq.exec();
}
}
else
{
QMessageBox::information(this, "Error", "Fill in all the input fields .");
}
}
else
{
QMessageBox::information(this,"Error"," Database not connected");
}
}
void request_blood::on_about_clicked()
{
about ab;
ab.setModal(true);
hide();
ab.exec();
}
void request_blood::on_why_clicked()
{
why_become_donor wh;
wh.setModal(true);
hide();
wh.exec();
}
void request_blood::on_home_clicked()
{
this->close();
MainWindow *mainWindow = new MainWindow();
mainWindow->show();
}
void request_blood::on_register_3_clicked()
{
QSqlDatabase db=QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("C:/Users/user/OneDrive/Documents/Final/Databases/final.db");
if(db.open())
{
QString contact_person_name=ui->contact_person->text();
QString patient_name=ui->patient_name->text();
QString age=ui->age->text();
QString blood_group=ui->blood_group->text();
QString gender=ui->gender->text();
QString phone_number=ui->phone_number->text();
QString required_units=ui->required_unit->text();
QString detail=ui->detail->text();
QString status="emergency";
if(contact_person_name != "" && patient_name != "" && age != "" && blood_group != "" && gender != "" && phone_number != "" && required_units != "" && detail != ""){
QSqlQuery qry;
qry.prepare("INSERT INTO patient_details(contact_person_name,patient_name,age,blood_group,gender,phone_number,required_units,detail_about_case,status) "
"VALUES('"+contact_person_name+"', '"+patient_name+"', '"+age+"', '"+blood_group+"', '"+gender+"', '"+phone_number+"', '"+required_units+"', '"+detail+"', '"+status+"')");
qry.bindValue(":contact_person_name", contact_person_name);
qry.bindValue(":patient_name", patient_name);
qry.bindValue(":age", age);
qry.bindValue(":blood_group", blood_group);
qry.bindValue(":gender", gender);
qry.bindValue(":phone_number", phone_number);
qry.bindValue(":required_units", required_units);
qry.bindValue(":detail_about_case", detail);
qry.bindValue(":status", status);
if(qry.exec())
{
QMessageBox::information(this,"Information","You will soon be notified about blood");
}
}
else
{
QMessageBox::information(this, "Error", "Fill in all the input fields .");
}
}
else
{
QMessageBox::information(this,"Error"," Database not connected");
}
}
void request_blood::on_login_2_clicked()
{
this->close();
MainWindow *mainWindow = new MainWindow();
mainWindow->show();
}