Skip to content

Commit 34c374e

Browse files
Add files via upload
1 parent 467d364 commit 34c374e

File tree

8 files changed

+769
-0
lines changed

8 files changed

+769
-0
lines changed

Diff for: UygulamaSinavi2/Quiz.pro

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
QT += core gui
2+
QT += sql
3+
4+
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
5+
6+
CONFIG += c++11
7+
8+
# You can make your code fail to compile if it uses deprecated APIs.
9+
# In order to do so, uncomment the following line.
10+
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
11+
12+
SOURCES += \
13+
main.cpp \
14+
mainwindow.cpp
15+
16+
HEADERS += \
17+
mainwindow.h
18+
19+
FORMS += \
20+
mainwindow.ui
21+
22+
# Default rules for deployment.
23+
qnx: target.path = /tmp/$${TARGET}/bin
24+
else: unix:!android: target.path = /opt/$${TARGET}/bin
25+
!isEmpty(target.path): INSTALLS += target

Diff for: UygulamaSinavi2/Quiz.pro.user

+319
Large diffs are not rendered by default.

Diff for: UygulamaSinavi2/database.db

12 KB
Binary file not shown.

Diff for: UygulamaSinavi2/main.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "mainwindow.h"
2+
3+
#include <QApplication>
4+
5+
int main(int argc, char *argv[])
6+
{
7+
QApplication a(argc, argv);
8+
MainWindow w;
9+
w.show();
10+
return a.exec();
11+
}

Diff for: UygulamaSinavi2/mainwindow.cpp

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
#include "mainwindow.h"
2+
#include "ui_mainwindow.h"
3+
#include <QSqlDatabase>
4+
#include <QSqlQuery>
5+
#include <QFile>
6+
#include <QSqlTableModel>
7+
#include <QMessageBox>
8+
9+
MainWindow::MainWindow(QWidget *parent)
10+
: QMainWindow(parent)
11+
, ui(new Ui::MainWindow)
12+
{
13+
ui->setupUi(this);
14+
15+
QSqlDatabase Database;
16+
Database = QSqlDatabase::addDatabase("QSQLITE");
17+
Database.setDatabaseName("/home/demir/Quiz/database.db");
18+
19+
if (!Database.open())
20+
{
21+
ui->statusbar->showMessage("Error, Veri tabanına bağlanılamadı X");
22+
}
23+
24+
else{
25+
ui->statusbar->showMessage("Veri tabanına bağlanıldı!");
26+
}
27+
28+
readd();
29+
30+
31+
QSqlTableModel *model;
32+
QSqlTableModel *model2;
33+
34+
model = new QSqlTableModel();
35+
model->setTable("gecenler");
36+
ui->tableView->setModel(model);
37+
model->select();
38+
model2 = new QSqlTableModel();
39+
model2->setTable("kalanlar");
40+
ui->tableView_2->setModel(model2);
41+
model2->select();
42+
43+
}
44+
45+
MainWindow::~MainWindow()
46+
{
47+
delete ui;
48+
}
49+
50+
void MainWindow::readd(){
51+
52+
int flag_run = 0;
53+
54+
QSqlQuery query("SELECT ogr_id FROM gecenler");
55+
if(query.next()==false){
56+
flag_run=1;
57+
58+
}
59+
60+
if(flag_run==1){
61+
62+
QFile file("/home/demir/Quiz/ogrenciler.txt");
63+
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
64+
return;
65+
}
66+
67+
QTextStream in(&file);
68+
QString line;
69+
70+
while (!in.atEnd()) {
71+
72+
line = in.readLine();
73+
74+
QStringList temp;
75+
temp = line.split(" ");
76+
77+
int a = temp.at(3).toInt()*0.4 + temp.at(4).toInt()*0.6;
78+
79+
if(a>=60){
80+
81+
query.prepare("INSERT INTO gecenler(ogr_id, ogr_ad, ogr_soyad, gecme_notu) "
82+
"VALUES (?, ?, ?, ?)");
83+
84+
query.bindValue(0, temp.at(0).toInt());
85+
query.bindValue(1, temp.at(1));
86+
query.bindValue(2, temp.at(2));
87+
query.bindValue(3, a);
88+
query.exec();
89+
90+
}
91+
92+
else{
93+
94+
query.prepare("INSERT INTO kalanlar(ogr_id, ogr_ad, ogr_soyad, gecme_notu) "
95+
"VALUES (?, ?, ?, ?)");
96+
97+
query.bindValue(0, temp.at(0).toInt());
98+
query.bindValue(1, temp.at(1));
99+
query.bindValue(2, temp.at(2));
100+
query.bindValue(3, a);
101+
query.exec();
102+
103+
}
104+
105+
}
106+
107+
}
108+
109+
110+
}
111+
112+
void MainWindow::on_pushButton_clicked()
113+
{
114+
115+
if(ui->lineEdit->text()=="" || ui->lineEdit_2->text()=="" || ui->lineEdit_3->text()=="" || ui->lineEdit_4->text()==""){
116+
117+
QMessageBox messageBox;
118+
messageBox.critical(0,"HATA!","Gerekli Alanları Doldurunuz!");
119+
120+
return;
121+
}
122+
123+
else if(ui->lineEdit_4->text().toInt()>=60){
124+
125+
QSqlQuery query;
126+
query.prepare("INSERT INTO gecenler(ogr_id, ogr_ad, ogr_soyad, gecme_notu) "
127+
"VALUES (?, ?, ?, ?)");
128+
129+
query.bindValue(0, ui->lineEdit->text());
130+
query.bindValue(1, ui->lineEdit_2->text());
131+
query.bindValue(2, ui->lineEdit_3->text());
132+
query.bindValue(3, ui->lineEdit_4->text());
133+
query.exec();
134+
135+
}
136+
137+
else{
138+
139+
QSqlQuery query;
140+
query.prepare("INSERT INTO kalanlar(ogr_id, ogr_ad, ogr_soyad, gecme_notu) "
141+
"VALUES (?, ?, ?, ?)");
142+
143+
query.bindValue(0, ui->lineEdit->text());
144+
query.bindValue(1, ui->lineEdit_2->text());
145+
query.bindValue(2, ui->lineEdit_3->text());
146+
query.bindValue(3, ui->lineEdit_4->text());
147+
query.exec();
148+
149+
}
150+
151+
QSqlTableModel *model;
152+
QSqlTableModel *model2;
153+
154+
model = new QSqlTableModel();
155+
model->setTable("gecenler");
156+
ui->tableView->setModel(model);
157+
model->select();
158+
model2 = new QSqlTableModel();
159+
model2->setTable("kalanlar");
160+
ui->tableView_2->setModel(model2);
161+
model2->select();
162+
163+
}
164+

Diff for: UygulamaSinavi2/mainwindow.h

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef MAINWINDOW_H
2+
#define MAINWINDOW_H
3+
4+
#include <QMainWindow>
5+
6+
QT_BEGIN_NAMESPACE
7+
namespace Ui { class MainWindow; }
8+
QT_END_NAMESPACE
9+
10+
class MainWindow : public QMainWindow
11+
{
12+
Q_OBJECT
13+
14+
public:
15+
MainWindow(QWidget *parent = nullptr);
16+
~MainWindow();
17+
18+
private slots:
19+
void on_pushButton_clicked();
20+
void readd();
21+
22+
private:
23+
Ui::MainWindow *ui;
24+
};
25+
#endif // MAINWINDOW_H

0 commit comments

Comments
 (0)