-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_patient.cpp
178 lines (136 loc) · 3.23 KB
/
edit_patient.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
#include "edit_patient.h"
#include "ui_edit_patient.h"
#include "mainwindow.h"
#include "about.h"
#include "why_become_donor.h"
#include "admin_dashboard.h"
#include "user_details.h"
#include "patient_requests.h"
#include "edit_donor.h"
#include "donor_request.h".h"
extern int id;
edit_patient::edit_patient(QWidget *parent) :
QDialog(parent),
ui(new Ui::edit_patient)
{
setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint);
setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint);
ui->setupUi(this);
QSqlDatabase db=QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("C:/Users/user/OneDrive/Documents/Final/Databases/final.db");
if(db.open())
{
QSqlQueryModel *modal =new QSqlQueryModel();
QSqlQuery * qry=new QSqlQuery();
qry->prepare("select * from patient_details");
qry->exec();
modal->setQuery(*qry);
ui->tableView->setModel(modal);
qDebug()<<(modal->rowCount());
}
}
edit_patient::~edit_patient()
{
delete ui;
}
void edit_patient::on_pushButton_clicked()
{
QSqlDatabase db=QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("C:/Users/user/OneDrive/Documents/Final/Databases/final.db");
if(db.open())
{
QString userid=ui->userid->text();
if(userid != ""){
QSqlQuery qry;
int count=0;
if(qry.exec("select * from patient_details where patient_id= '"+userid+"'"))
{
while(qry.next())
{
count++;
}
if(count==1)
{
QSqlQuery qry;
if(qry.prepare("DELETE from patient_details where patient_id= :userid " )){
qry.bindValue(":userid", userid);
if(qry.exec())
{
QMessageBox :: critical(this, tr("Deleted"), tr("Deleted"));
patient_requests pr;
pr.setModal(true);
hide();
pr.exec();
}
else
{
QMessageBox :: critical(this, tr("erorr::"), qry.lastError().text());
}
}
}
else
{
QMessageBox::information(this,"Information","Id incorrect");
}
}
}
else
{
QMessageBox::information(this,"Error","Enter user_id ");
}
}
}
void edit_patient::on_my_details_clicked()
{
user_details u1;
u1.setModal(true);
hide();
u1.exec();
}
void edit_patient::on_my_details_2_clicked()
{
patient_requests r1;
r1.setModal(true);
hide();
r1.exec();
}
void edit_patient::on_my_details_3_clicked()
{
donor_request dr;
dr.setModal(true);
hide();
dr.exec();
}
void edit_patient::on_home_clicked()
{
this->close();
MainWindow *mainWindow = new MainWindow();
mainWindow->show();
}
void edit_patient::on_about_clicked()
{
about ab;
ab.setModal(true);
hide();
ab.exec();
}
void edit_patient::on_why_clicked()
{
why_become_donor wh;
wh.setModal(true);
hide();
wh.exec();
}
void edit_patient::on_login_clicked()
{
admin_dashboard u1;
u1.setModal(true);
hide();
u1.exec();
}
void edit_patient::on_login_2_clicked()
{
this->close();
MainWindow *mainWindow = new MainWindow();
mainWindow->show();
}