Computer Programming
Computer Programming
By:
Malveda, Evan Joseph R.
Submitted to:
Mr. Raymond Kit M. Rodriguez
May 2019
Introduction
In the fast changing world, the enhancement of technology increases almost every day.
That enhance or innovation helps the people to do work or make their lives easier. For example,
instead of sending letters to communicate with someone like in the past, people are now capable
of communicating with someone by just typing the message and sending it off in just one tap. In
ordering foods, people don’t need to go to the mall or shop to order or buy the things they want,
instead they shop online and wait for the delivery guy to deliver the item right at their doorstep.
Almost all the things and happenings around the world is manipulated by technology and
through that technology, there is a program involved. Without that program, a certain technology
will not work properly or will not work entirely because it will not follow any rules, restrictions,
As time goes by, programs seize to amaze the user because of its never ending
capabilities that can make the life of user easier. It involves on creating a system where it solves
a certain problem that the user has, that is how the program make things work at ease without
That is why the developer came up with an idea that can help the adviser of a certain
section reduce his/her load of paper works, files and documents that are only important within
the semester or until the school year ends. It is an application where the adviser can check the
requirements of a student without bringing or using any record books. This will ensure that the
data gathered is safely stored without having any problem of missing or misplacing it because it
is on a personal computer or laptop not on a piece of paper or record book. To ensure the safety
of the data inputted at the application, it has a login process where the user cannot enter or use
the application without logging in it. This will make sure that the data inside cannot be altered by
any person except the adviser. For example, the adviser accidentally leave his/her laptop inside a
certain room with the application opened and somebody tries to login, the adviser do not need to
worry because the application has that login process. The login process has only three (3) tries
and if a certain user does not succeed on logging in after three (3) consecutive tries, the
application will be closed temporarily until the adviser opened it and only the adviser knows
The use of this application is limited to only one adviser per section. This will ensure that
the data/information gathered is accurate. It can also prevent the alteration of data when checking
the requirements. The developer also thought that it is easier for the adviser to manipulate the
application if it has only one user (the adviser) and the section he/she is handling.
The application cannot show a message that says “A person tries to login your account.”
if someone attempted to use the application. It cannot also display what has been typed on the
username and password field if someone attempted to after three (3) consecutive tries.
The application only has the requirements of the first year students to be checked because
If the adviser wants to add a student, any character can be used for the SR-Code of the
student. If any character is available for the SR-Code, it means that the SR-Code is not unique
enough.
The application is limited to offline use only, it cannot be used to transfer or send data
online. The application is for desktop or laptop use only, it is not available for mobile devices.
The application is not yet fully developed that is it is open for recommendation to make it
fully functional without experiencing any errors, bugs or problems that can affect the user.
The application should display a message if someone tries to login to the application. If
the adviser uses the application after the attempted login, the application will show what the
There will be restriction on how many characters and what characters you will put on the
SR-Code field when adding a student. This will make sure that the SR-Code of the students will
The application will accept different kind of requirements like exercises, assignments,
The application will be available for online use and is accessible through mobile devices.
Improve the UI of the application to make it appealing to the eye of the user.
Source Code
#include "mainwindow.h"
#include <QApplication>
return a.exec();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QPixmap>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowTitle("Batangas State University");
QPixmap pix("C:/Users/yagur/Documents/LogIn/img/LoginIconAppl.png");
ui->label_pic->setPixmap(pix.scaled(100,100,Qt::KeepAspectRatio));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_Login_clicked()
{
connect_studentinfo();
if(!connect_studentinfo())
{
qDebug()<<"Failed to connect the database";
return;
}
QSqlQuery qr;
disconnect_student();
}
if(count>1){
QMessageBox::warning(this, "Login", "Duplicate username and
password");
}
if(count<1)
{
QMessageBox::warning(this, "Login", "Username and password is
incorrect!");
attempts++;
}
}
if(attempts==3)
{
this->hide();
}
}
#include "dialog.h"
#include "ui_dialog.h"
#include "mainwindow.h"
#include <QMessageBox>
#include "add_students.h"
#include "remove_student.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
this->setWindowTitle("Batangas State University Requirement Checklist");
checklist=QSqlDatabase::addDatabase("QSQLITE");
checklist.setDatabaseName("C:/Users/yagur/Desktop/Database/login
database.db");
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::on_pushButton_clicked()
{
MainWindow database;
database.connect_studentinfo();
students->setQuery(*qr);
ui->tableView_studentinfo->setModel(students);
info->setQuery(*qy);
ui->comboBox->setModel(info);
database.disconnect_student();
}
void Dialog::on_pushButton_submit_clicked()
{
QString name;
name = ui->comboBox->currentText();
MainWindow connect;
if(ui->checkBox_goodmoral->isChecked())
{
connect.connect_studentinfo();
QSqlQuery qu;
qu.prepare("update Information set Good_Moral = 'Passed'
where Name = '"+name+"' ");
if(qu.exec())
{
//QMessageBox::information(this,tr("Update"),tr("Requirement update
successful."));
connect.disconnect_student();
}
}
else if(ui->checkBox_goodmoral->checkState()==Qt::Unchecked)
{
connect.connect_studentinfo();
QSqlQuery qu;
qu.prepare("update Information set Good_Moral = 'N/A' where
Name = '"+name+"' ");
if(qu.exec())
{
// QMessageBox::warning(this,tr("Update"),tr("Requirement
update unsuccessful!"));
connect.disconnect_student();
}
}
if(ui->checkBox_psa->isChecked())
{
connect.connect_studentinfo();
QSqlQuery psa;
psa.prepare("update Information set PSA = 'Passed' where Name
= '"+name+"' ");
if(psa.exec())
{
//QMessageBox::information(this,tr("Update"),tr("Requirement update
successful."));
connect.disconnect_student();
}
}
else if(ui->checkBox_psa->checkState()==Qt::Unchecked)
{
connect.connect_studentinfo();
QSqlQuery psa;
psa.prepare("update Information set PSA = 'N/A' where Name =
'"+name+"' ");
if(psa.exec())
{
//QMessageBox::warning(this,tr("Update"),tr("Requirement
update unsuccessful!"));
connect.disconnect_student();
}
}
if(ui->checkBox_form137->isChecked())
{
connect.connect_studentinfo();
QSqlQuery form;
form.prepare("update Information set Form_137 = 'Passed'
where Name = '"+name+"' ");
if(form.exec())
{
//QMessageBox::information(this,tr("Update"),tr("Requirement update
successful."));
connect.disconnect_student();
}
}
else if(ui->checkBox_form137->checkState()==Qt::Unchecked)
{
connect.connect_studentinfo();
QSqlQuery form;
form.prepare("update Information set Form_137 = 'N/A' where
Name = '"+name+"' ");
if(form.exec())
{
//QMessageBox::warning(this,tr("Update"),tr("Requirement
update unsuccessful!"));
connect.disconnect_student();
}
}
if(ui->checkBox_form138->isChecked())
{
connect.connect_studentinfo();
QSqlQuery forms;
forms.prepare("update Information set Form_138 = 'Passed'
where Name = '"+name+"' ");
if(forms.exec())
{
//QMessageBox::information(this,tr("Update"),tr("Requirement update
successful."));
connect.disconnect_student();
}
}
else if(ui->checkBox_form138->checkState()==Qt::Unchecked)
{
connect.connect_studentinfo();
QSqlQuery forms;
forms.prepare("update Information set Form_138 = 'N/A' where
Name = '"+name+"' ");
if(forms.exec())
{
//QMessageBox::warning(this,tr("Update"),tr("Requirement
update unsuccessful!"));
connect.disconnect_student();
}
}
if(ui->checkBox_medicalcertificate->isChecked())
{
connect.connect_studentinfo();
QSqlQuery med;
med.prepare("update Information set Medical_Certificate =
'Passed' where Name = '"+name+"' ");
if(med.exec())
{
//QMessageBox::information(this,tr("Update"),tr("Requirement update
successful."));
connect.disconnect_student();
}
}
else if(ui->checkBox_medicalcertificate-
>checkState()==Qt::Unchecked)
{
connect.connect_studentinfo();
QSqlQuery med;
med.prepare("update Information set Medical_Certificate =
'N/A' where Name = '"+name+"' ");
if(med.exec())
{
//QMessageBox::warning(this,tr("Update"),tr("Requirement
update unsuccessful!"));
connect.disconnect_student();
}
}
}
void Dialog::on_pushButton_add_clicked()
{
add_students add_students;
add_students.setModal(true);
add_students.exec();
}
void Dialog::on_pushButton_remove_clicked()
{
remove_student remove_students;
remove_students.setModal(true);
remove_students.exec();
}
void Dialog::on_pushButton_logout_clicked()
{
QMessageBox::about(this,"Logout","You are now logged out.");
this->close();
MainWindow *login = new MainWindow;
login->show();
}
if (qry.exec())
{
while (qry.next())
{
Good_Moral = qry.value(2).toString();
}
}
if(Good_Moral == "Passed")
{
ui->checkBox_goodmoral->setChecked(true) ;
}
else if(Good_Moral == "N/A")
{
ui->checkBox_goodmoral->setChecked(false) ;
}
qDebug() << name << Good_Moral;
}
void Dialog::on_comboBox_currentIndexChanged(const QString &arg1)
{
MainWindow con;
// connect(ui->comboBox, SIGNAL(on_comboBox_editTextChanged(Qstring&
name)) , this, SLOT(change_check(Qstring& name)));
con.connect_studentinfo();
QSqlQuery qry;
QString Good_Moral,PSA,f_137,f_138,med_cert;
QString name = arg1;
qry.prepare("select * from Information where Name='"+name+"'");
// qry.bindValue(":name", name);
if (qry.exec())
{
while (qry.next())
{
Good_Moral = qry.value(2).toString();
PSA = qry.value(3).toString();
f_137 = qry.value(4).toString();
f_138 = qry.value(5).toString();
med_cert = qry.value(6).toString();
}
}else
{
qDebug() << Good_Moral << qry.lastQuery() << qry.lastError();
}
if(Good_Moral == "Passed")
{
ui->checkBox_goodmoral->setChecked(true) ;
}
else if(Good_Moral == "N/A")
{
ui->checkBox_goodmoral->setChecked(false) ;
}else if (Good_Moral == NULL) {
ui->checkBox_goodmoral->setChecked(false) ;
}
if(PSA == "Passed")
{
ui->checkBox_psa->setChecked(true) ;
}
else if(PSA == "N/A")
{
ui->checkBox_psa->setChecked(false) ;
}else if (PSA == NULL) {
ui->checkBox_psa->setChecked(false) ;
}
if(f_137 == "Passed")
{
ui->checkBox_form137->setChecked(true) ;
}
else if(f_137 == "N/A")
{
ui->checkBox_form137->setChecked(false) ;
}else if (f_137 == NULL) {
ui->checkBox_form137->setChecked(false) ;
}
if(f_138 == "Passed")
{
ui->checkBox_form138->setChecked(true) ;
}
else if(f_138 == "N/A")
{
ui->checkBox_form138->setChecked(false) ;
}else if (f_138 == NULL) {
ui->checkBox_form138->setChecked(false) ;
}
if(med_cert == "Passed")
{
ui->checkBox_medicalcertificate->setChecked(true) ;
}
else if(med_cert == "N/A")
{
ui->checkBox_medicalcertificate->setChecked(false) ;
}
else if (med_cert == NULL) {
ui->checkBox_medicalcertificate->setChecked(false) ;
}
qDebug() << name;
// QMessageBox::about(this,"","texxtchange");
// QMessageBox::about(this,"","index");
}
#include "add_students.h"
#include "ui_add_students.h"
#include "mainwindow.h"
#include <QMessageBox>
add_students::add_students(QWidget *parent) :
QDialog(parent),
ui(new Ui::add_students)
{
ui->setupUi(this);
this->setWindowTitle("Add Student");
}
add_students::~add_students()
{
delete ui;
}
void add_students::on_pushButton_addstudent_clicked()
{
MainWindow add;
add.connect_studentinfo();
QString srcode, name;
srcode = ui->lineEdit_srcode->text();
name = ui->lineEdit_name->text();
if(!ui->lineEdit_name->text().isEmpty()&&!ui->lineEdit_srcode-
>text().isEmpty())
{
QSqlQuery qr;
else
{
QMessageBox::warning(this,tr("Failed"), tr("Field cannot be empty"));
}
void add_students::on_pushButton_clicked()
{
this->hide();
}
#include "remove_student.h"
#include "ui_remove_student.h"
#include "mainwindow.h"
#include <QString>
#include <QMessageBox>
remove_student::remove_student(QWidget *parent) :
QDialog(parent),
ui(new Ui::remove_student)
{
ui->setupUi(this);
this->setWindowTitle("Remove Student");
MainWindow remove;
remove.connect_studentinfo();
QSqlQueryModel *student = new QSqlQueryModel();
student->setQuery(*qy);
ui->comboBox_student->setModel(student);
remove.disconnect_student();
}
remove_student::~remove_student()
{
delete ui;
}
void remove_student::on_pushButton_removestudent_clicked()
{
QString name;
name=ui->comboBox_student->currentText();
MainWindow remove;
remove.connect_studentinfo();
QSqlQuery qu;
qu.prepare("delete from Information where Name='"+name+"'");
if (qu.exec())
{
QMessageBox::information(this,tr("Remove"),tr("Student removed
succesfully."));
remove.disconnect_student();
this->hide();
}
else
{
QMessageBox::information(this,tr("Error::"),qu.lastError().text());
}
}
void remove_student::on_pushButton_clicked()
{
this->hide();
}
Journal
April 27 - nanood ng tutorial at sinunod ang mga ito kaya nakagawa na ako ng application kung
April 28 - Inayos ang application kung saan magkakaroon ito ng login process para masunod ang
May 4 - nag-isip kung ano ang magiging itsura ng ui after mag-login ang user
May 5 - nanood ng tutorial para malaman kung ano ang maaaring ilagay na button para maging
May 6 - Inayos na ang magiging ui after mag-login at naglagay na rin ng button, combo box,
checkbox at table view ngunit hindi pa nalalagyan ng function ang mga ito
May 7 - Nilagyan ng function ang bawat button sa loob ng window.
May 8 - nanood ng tutorial kung paano iconnect ang table view sa data base para maipakita ang
May 9 - Naconnect na ang table view sa data base at maayos naman na nakikita ang information
dito.
May 10 - Umisip at ginawa ang paraan kung paano papasok ang data ng check box sa loob ng
data base
May 12 - naisipan ko nalang mamahinga sa araw na ito at intayin ang magiging kalbaryo sa mga
susunod na araw
May 13 - Chinecheck ang application kung nagana ba ng ayos at nagpapractice na rin ng mga
posibleng sasabihin
May 16 - naghanap ng paraan kung paano aayusin yung system kung saan dapat nakacheck sa