-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
109 lines (97 loc) · 2.82 KB
/
Copy pathmainwindow.cpp
File metadata and controls
109 lines (97 loc) · 2.82 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
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "mainpage.h"
#include "admin.h"
#include <QString>
#include "QDebug"
#include <QMessageBox>
#include<QDate>
#include "transaction.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
head MainWindow::user_top;
int MainWindow::count;
QString MainWindow::session;
head next;
bool first = true;
QString gender_name[2] = {"Male", "Female"};
QString type[2] = {"Saving", "Current"};
QString gen_rand(int account)
{
QString tmp_s;
const char alphanum[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
for (int i = 0; i < 7; ++i)
tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)];
tmp_s += QString::number(account);
return tmp_s;
}
void MainWindow::on_pushButton_clicked()
{
QString name = ui->customer_name->text();
QString aadhar = ui->aadhar_no->text();
QString gender = gender_name[ui->gender->currentIndex()];
QString account_type = type[ui->account_type->currentIndex()];
QString number = ui->phone_no->text();
QString dob = ui->dateEdit->date().toString("dd.MM.yyyy");
int opening_amount = (ui->min_amount->text()).toInt();
if(name==""||aadhar==""||number=="")
{
QMessageBox::warning(this,"Credential empty","Kindly fill all the details");
}
else if(opening_amount<500)
{
QMessageBox::warning(this,"Insufficient amount","Opening amount should be atleast 500");
}
else{
Transaction *new_transaction = new Transaction();
new_transaction->type = "Opening amount";
new_transaction->amount=opening_amount;
new_transaction->next=0;
new_transaction->Date =QDate::currentDate().toString("dd.MM.yyyy");
User *user = new User();
user->name = name;
user->transaction = new_transaction;
user->aadhar = aadhar;
user->gender = gender;
user->account_type = account_type;
user->balance = opening_amount;
user->phone = number;
user->dob = dob;
user->account = count;
QString password = gen_rand(count);
user->password = password;
user->next = 0;
if (first)
{
user_top = user;
next = user;
first = false;
}
else
{
next->next = user;
next = user;
}
QString a = QString::number(count);
count++;
QMessageBox::about(this, "User confirmation", "account no. is " + a + " and password is " + password);
}
}
void MainWindow::on_pushButton_menu_clicked()
{
//MainPage *mainpage = new MainPage();
//mainpage->show();
Admin *admin = new Admin();
admin->show();
this->hide();
}