forked from Vijay-Gunwant/BankManagement-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateAccount.py
More file actions
127 lines (109 loc) · 4.63 KB
/
Copy pathCreateAccount.py
File metadata and controls
127 lines (109 loc) · 4.63 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import tkinter
from tkinter import *
from tkinter import messagebox
import mysql.connector as mysql
from random import randint
import re
def createAcc(Create, Name, PAN, DOB, Phone):
if Name == "" or PAN == "" or DOB == "":
messagebox.showwarning("Invalid Details!", "Values Can't Be Empty")
return
for x in Name:
if x.isalpha() or x.isspace():
continue
messagebox.showerror("Invalid Name", "Name Can't have numbers/Special Characters")
return
if len(PAN) != 10 or not PAN.isalnum():
messagebox.showerror("Invalid PAN Number", "Please Enter Correct PAN Number")
return
if not re.compile('\d\d\d\d-\d\d-\d\d').search(DOB):
messagebox.showerror("Invalid Date", "Date Should be the format YYYY-MM-DD")
return
if len(str(Phone)) != 10:
messagebox.showerror("Invalid Phone Number", "Phone Number should be of Length 10")
return
con = mysql.connect(host="localhost", user="root", password="vijay@1234", database="bank")
cursor = con.cursor()
cursor.execute('SELECT * FROM customer')
AccNo = randint(1000, 9999)
Password = randint(1000, 9999)
result = cursor.fetchall()
if result:
a = False
while not a:
AccNo = randint(1000, 9999)
for y in result:
if y[4] == str(AccNo):
a = False
break
else:
a = True
for x in result:
if x[1] == PAN:
messagebox.showerror("Repeated Details", "Account Already Exist")
return
x = False
while not x:
Password = randint(1000, 9999)
for y in result:
if y[6] == str(Password):
x = False
break
else:
x = True
cursor.execute(f"INSERT INTO customer VALUES ('{Name}' , '{PAN}','{DOB}',{Phone},{AccNo},{0},{Password})")
messagebox.showinfo("Action Successful", "Account Created Successfully")
con.commit()
Create.destroy()
from AccInfo import AccInfo
AccInfo(Name, PAN, DOB, Phone, AccNo, Password, 0)
def toHome(Create):
Create.destroy()
from HomePage import Home_Creator
Home_Creator()
def SignUp():
# Useful Variables
BackgroundColor = "#c6cdcf"
ButtonColor = "#c8dbde"
Create_Account = tkinter.Tk()
# Window Setting
Create_Account.geometry("500x500")
Create_Account.resizable(False, False)
Create_Account.title("Realities Bank - Create New Account")
Create_Account.iconbitmap("Images/bank.ico")
Create_Account.config(bg=BackgroundColor)
# Logo Of Bank
logo = PhotoImage(file="Images/BankLogo.png")
BankLogo = Label(image=logo, bg=BackgroundColor)
BankLogo.place(x=30, y=0)
# Name Label
NameLabel = Label(text="Full Name(As on PAN Card)", font="Roboto 15 bold", bg=BackgroundColor)
NameLabel.place(x=100, y=120)
NameTextField = Entry(Create_Account, width=25, relief=SUNKEN, font="Roboto 15 italic", bd=3)
NameTextField.place(x=102, y=150)
# PAN Number Label
PAN_NumberLabel = Label(text="PAN Number", font="Roboto 15 bold", bg=BackgroundColor)
PAN_NumberLabel.place(x=100, y=185)
PAN_NumberTextField = Entry(Create_Account, width=25, relief=SUNKEN, font="Roboto 15 italic", bd=3)
PAN_NumberTextField.place(x=102, y=215)
# Date Of Birth Label
DOBLabel = Label(text="DOB(YYYY-MM-DD)", font="Roboto 15 bold", bg=BackgroundColor)
DOBLabel.place(x=100, y=250)
DOBTextField = Entry(Create_Account, width=25, relief=SUNKEN, font="Roboto 15 italic", bd=3)
DOBTextField.place(x=102, y=280)
# Phone Number Label
Phone_NumberLabel = Label(text="Phone Number", font="Roboto 15 bold", bg=BackgroundColor)
Phone_NumberLabel.place(x=100, y=315)
Phone_NumberTextField = Entry(Create_Account, width=25, relief=SUNKEN, font="Roboto 15 italic", bd=3)
Phone_NumberTextField.place(x=102, y=345)
# Submit Button
Submit = Button(text="Create Account", font="Roboto 15 bold", bg=ButtonColor, cursor="hand2",
relief=RAISED, width=15, activebackground=ButtonColor,
command=lambda: createAcc(Create_Account, NameTextField.get(), PAN_NumberTextField.get(),
DOBTextField.get(), Phone_NumberTextField.get()))
Submit.place(x=145, y=400)
# Back Button
Back = Button(text="Back", font="Roboto 15 bold", bg=ButtonColor, cursor="hand2",
relief=RAISED, activebackground=ButtonColor, command=lambda: toHome(Create_Account))
Back.place(x=5, y=450)
Create_Account.mainloop()