-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
72 lines (62 loc) · 1.89 KB
/
mainwindow.cpp
File metadata and controls
72 lines (62 loc) · 1.89 KB
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
#include "mainwindow.h"
#include "bookreservation.h"
#include "qdatetime.h"
#include "ui_mainwindow.h"
#include<iostream>
using namespace std;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setFixedSize(this->width(), this->height());
setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
}
void MainWindow::delay(int n){
QTime dieTime= QTime::currentTime().addSecs(n);
while (QTime::currentTime() < dieTime)
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
MainWindow::~MainWindow()
{
delete ui;
delete S_Array[2];
}
Student* MainWindow::login(QString name, QString pass){
for (auto x: S_Array){
if(x->getName() == name){
if(x->getPassword() == pass){
ui->Alert->setStyleSheet("color:green");
ui->Alert->setText("Welcome, " + x->getName());
ui->IDHeading->setText("ID : " + x->getID());
ui->BalanceHeading->setText("Balance : " + QString::number(x->getBalance()));
return x;
}
else{
ui->Alert->setStyleSheet("color:red");
ui->Alert->setText("Name is correct but password is not!");
ui->IDHeading->setText("ID : ");
ui->BalanceHeading->setText("Balance : ");
delay(2);
ui->Alert->setText("");
return nullptr;
}
}
else{continue;}
}
ui->Alert->setStyleSheet("color:red");
ui->Alert->setText("Name does not Exist!");
ui->IDHeading->setText("ID : ");
ui->BalanceHeading->setText("Balance : ");
delay(2);
ui->Alert->setText("");
return nullptr;
}
void MainWindow::on_signup_clicked()
{
Student* s = login(ui->NameLine->text(), ui->PasswordLine->text());
if(s!=nullptr){
BR = new BookReservation(this, s);
BR->show();
}
}