-
Notifications
You must be signed in to change notification settings - Fork 1
/
academicreport.cpp
217 lines (153 loc) · 8.49 KB
/
academicreport.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#include "academicreport.h"
#include "ui_academicreport.h"
#include<QRegExpValidator>
#include <QString>
#include <QFile>
#include <QtDebug>
#include <QSqlRecord>
#include <QFileDialog>
#include <QMessageBox>
#include "add_student.h"
QString registration_num;
AcademicReport::AcademicReport(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::AcademicReport)
{
ui->setupUi(this);
//QString registration_num;
// qDebug() << "This is vale of reg in academic" << registration_num;
//Database Connection
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("data.sqlite3");
db.open();
// set a "cursor"
query = QSqlQuery(db);
query.exec("SELECT * FROM Report_I");
if (query.isActive()){
qDebug()<<"Co//nnection Successful";
query.first();
FillForm();
}else{
qDebug()<< "Database connection:Error";
}
}
void AcademicReport::FillForm()
{
//Name And Address Of the Institution as saved in databse
if(!query.exec("SELECT institution_name, institution_address FROM users WHERE access = 1")) qDebug() << "Error while Extracting name and address";
query.first();
ui->inst_name->setText(query.value(0).toString());
ui->inst_address->setText(query.value(1).toString());
query.exec("SELECT RegistrationNumber, StudentName, Grade FROM Report_I WHERE RegistrationNumber = '"+registration_num+"'");
query.first();
//Genaral Information
ui->Grade->setText(query.value(2).toString());
ui->Redgno->setText(query.value(0).toString());
ui->StudentName->setText(query.value(1).toString());
query.exec("SELECT * FROM Report_I WHERE RegistrationNumber = '"+registration_num+"'");
query.first();
}
AcademicReport::~AcademicReport()
{
delete ui;
db.close();
}
void AcademicReport::on_pushButton_clicked()
{
QSqlQuery updateQuery = QSqlQuery(db);
if(!updateQuery.exec("SELECT * FROM Report_I WHERE RegistrationNumber = '"+registration_num+"'")) qDebug() << "Vakai Xaina";
updateQuery.first();
updateQuery.prepare("UPDATE Report_I SET RollNo = :RollNo,"
" PresentDays = :PresentDays,"
" TotalDays = :TotalDays,"
" MathCredit = :MathCredit, MathGrade = :MathGrade, MathGradeII = :MathGradeII, MathGradeIII = :MathGradeIII, MathRemarks = :MathRemarks,"
" PhysicsCredit = :PhysicsCredit, PhysicsGrade = :PhysicsGrade, PhysicsGradeII = :PhysicsGradeII, PhysicsGradeIII = :PhysicsGradeIII, PhysicsRemarks = :PhysicsRemarks,"
" ChemistryCredit = :ChemistryCredit, ChemistryGrade = :ChemistryGrade, ChemistryGradeII = :ChemistryGradeII, ChemistryGradeIII = :ChemistryGradeIII, ChemistryRemarks = :ChemistryRemarks,"
" BiologyCredit = :BiologyCredit, BiologyGrade = :BiologyGrade, BiologyGradeII = :BiologyGradeII, BiologyGradeIII = :BiologyGradeIII, BiologyRemarks = :BiologyRemarks,"
" EnglishCredit = :EnglishCredit, EnglishGrade = :EnglishGrade, EnglishGradeII = :EnglishGradeII, EnglishGradeIII = :EnglishGradeIII, EnglishRemarks = :EnglishRemarks,"
"GPA = :GPA,"
"IssueDate = :IssueDate,"
"TotalCredit = :TotalCredit,"
"TotalGradePoint = :TotalGradePoint,"
"AssignmentRegularity = :AssignmentRegularity,"
"ReadingSpeaking = :ReadingSpeaking,"
"Attentiveness = :Attentiveness,"
"StationaryMaintenance = :StationaryMaintenance,"
"Discipline = :Discipline,"
"Elocution = :Elocution,"
"ECA = :ECA,"
"Initiative = :Initiative,"
"Neatness = :Neatness,"
"Creativity = :Creativity,"
"Remarks = :Remarks,"
"Grade = :Grade,"
"ClassroomParticipation = :ClassroomParticipation,"
" ComputerCredit = :ComputerCredit, ComputerGrade = :ComputerGrade, ComputerGradeII = :ComputerGradeII, ComputerGradeIII = :ComputerGradeIII, ComputerRemarks = :ComputerRemarks,"
" AbsentDays = :AbsentDays, Id = :Id"
" WHERE RegistrationNumber = '"+registration_num+"'");
//Updating Information on Academic Report
//Bind Values
updateQuery.bindValue(":Id", query.value(0));
updateQuery.bindValue(":RollNo", ui->RollNo->text());
updateQuery.bindValue(":AbsentDays", ui->AbsentDays->text());
updateQuery.bindValue(":PresentDays", ui->PresentDays->text());
updateQuery.bindValue(":TotalDays", ui->Totaldays->text());
updateQuery.bindValue(":MathCredit", ui->MathCredit->text());
updateQuery.bindValue(":MathGrade", ui->MathGrade->text());
updateQuery.bindValue(":MathGradeII", ui->MathGradeII->text());
updateQuery.bindValue(":MathGradeIII", ui->MathGradeIII->text());
updateQuery.bindValue(":MathRemarks", ui->MathRemarks->text());
updateQuery.bindValue(":PhysicsCredit", ui->PhysicsCredit->text());
updateQuery.bindValue(":PhysicsGrade", ui->PhysicsGrade->text());
updateQuery.bindValue(":PhysicsGradeII", ui->PhysicsGradeII->text());
updateQuery.bindValue(":PhysicsGradeIII", ui->PhysicsGradeIII->text());
updateQuery.bindValue(":PhysicsRemarks", ui->PhysicsRemarks->text());
updateQuery.bindValue(":ChemistryCredit", ui->ChemistryCredit->text());
updateQuery.bindValue(":ChemistryGrade", ui->ChemistryGrade->text());
updateQuery.bindValue(":ChemistryGradeII", ui->ChemistryGradeII->text());
updateQuery.bindValue(":ChemistryGradeIII", ui->ChemistryGradeIII->text());
updateQuery.bindValue(":ChemistryRemarks", ui->ChemistryRemarks->text());
updateQuery.bindValue(":BiologyCredit", ui->BiologyCredit->text());
updateQuery.bindValue(":BiologyGrade", ui->BiologyGrade->text());
updateQuery.bindValue(":BiologyGradeII", ui->BiologyGradeII->text());
updateQuery.bindValue(":BiologyGradeIII", ui->BiologyGradeIII->text());
updateQuery.bindValue(":BiologyRemarks", ui->BiologyRemarks->text());
updateQuery.bindValue(":EnglishCredit", ui->EnglishCredit->text());
updateQuery.bindValue(":EnglishGrade", ui->EnglishGrade->text());
updateQuery.bindValue(":EnglishGradeII", ui->EnglishGradeII->text());
updateQuery.bindValue(":EnglishGradeIII", ui->EnglishGradeIII->text());
updateQuery.bindValue(":EnglishRemarks", ui->EnglishRemarks->text());
updateQuery.bindValue(":ComputerCredit", ui->ComputerCredit->text());
updateQuery.bindValue(":ComputerGrade", ui->ComputerGrade->text());
updateQuery.bindValue(":ComputerGradeII", ui->ComputerGradeII->text());
updateQuery.bindValue(":ComputerGradeIII", ui->ComputerGradeIII->text());
updateQuery.bindValue(":ComputerRemarks", ui->ComputerRemarks->text());
updateQuery.bindValue(":GPA", ui->GPA->text());
updateQuery.bindValue(":IssueDate", ui->IssueDate->text());
updateQuery.bindValue(":TotalCredit", ui->TotalCredit->text());
updateQuery.bindValue(":TotalGradePoint", ui->TotalGradePoint->text());
updateQuery.bindValue(":AssignmentRegularity", ui->AssignmentRegularity->text());
updateQuery.bindValue(":ReadingSpeaking", ui->ReadingSpeaking->text());
updateQuery.bindValue(":Attentiveness", ui->Attentiveness->text());
updateQuery.bindValue(":StationaryMaintenance", ui->StationaryMaintenance->text());
updateQuery.bindValue(":Discipline", ui->Discipline->text());
updateQuery.bindValue(":Elocution", ui->Elocution->text());
updateQuery.bindValue(":ECA", ui->ECA->text());
updateQuery.bindValue(":Initiative", ui->Initiative->text());
updateQuery.bindValue(":Neatness", ui->Neatness->text());
updateQuery.bindValue(":Creativity", ui->Creativity->text());
updateQuery.bindValue(":Remarks", ui->Remarks->toPlainText());
updateQuery.bindValue(":Grade", ui->Grade->text());
updateQuery.bindValue(":ClassroomParticipation", ui->ClassroomParticipation->text());
QMessageBox msgBox;
if(!updateQuery.exec())
{
msgBox.setText("Failed to Add.Please Try Again!!!");
msgBox.exec();
}
else
{
msgBox.setText("Successfully Added");
msgBox.exec();
}
}