diff --git a/.gitignore b/.gitignore index d92380b..248fbda 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ links.txt tempCodeRunnerFile.py start program.bat README.md +.vscode/ \ No newline at end of file diff --git a/README.md b/README.md index e7eec97..2a48215 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Branch Information: -The purpose of this branch is to shorten the number of lines of code by removing duplicate lines -as much as possible. +The purpose of this branch is to organize the code in packages and modules. This will soon be merged into the "[shorten-the-code](https://github.com/OJASisLive/Bank-Management-System-Python-SQL/tree/shorten-the-code)" branch. + +After merger, this branch will be deleted. - I have not tested the whole code over here, so if anyone finds any bug, please post it in the [issues section](https://github.com/OJASisLive/Bank-Management-System-Python-SQL/issues/new/choose) and I will look after it then diff --git a/createaccount.py b/createaccount.py deleted file mode 100644 index 087c53e..0000000 --- a/createaccount.py +++ /dev/null @@ -1,82 +0,0 @@ -import dataentering -import mysql.connector - -def ep1(query,cur): - print("-------------Create account Process-------------") - -#client number - acc_no=dataentering.primary_key_no("acc_no") -#client Birth date - birth_date=dataentering.birthdate("Client",10,100) -#client name - first_name,last_name=dataentering.name() -#client Gender - gender=dataentering.gender() -#client Account Type - while True: - print("1.Savings account") - print("2.Current account") - a=input("Enter choice (1 or 2):") - if a== '1': - acc_type='S' - break - elif a=='2': - acc_type='C' - break - else: - print("Wrong input!!") - -#Account creation date - acc_creation_date=dataentering.date2("client",birth_date,"account_creation",10,100) -#client password/pin - while True: - password=input("Enter client login password(max 8 characters, min 4): ") - lp=len(password) - if lp>8: - print("Max 8 characters only.") - elif lp<4: - print("Minimum 4 characters to be entered.") - else: - break - -#mobile no - while True: - mobile_no_str=input("Enter mobile no. (7 to 15 int)") - mobile_no=mobile_no_str - #Thanks to the international phone numbering plan (ITU-T E. 164), - #phone numbers cannot contain more than 15 digits. The shortest - #international phone numbers in use contain seven digits. - try: - mobile_no=int(mobile_no) - except ValueError: - print("acc_no should be an integer!!") - else: - if len(mobile_no_str)>6 and len(mobile_no_str)<16: - mobile_no=mobile_no_str - lmn=len(mobile_no) - break - else: - print("Mobile number can have min 7 digits and max 15!!") - -#email-id - while True: - email_id=input("Enter client Email ID (max 25 char):") - if len(email_id)<26: - break - else: - print("Maximum 25 characters") - - print("=========== Final Data ===========") - print(acc_no,acc_type,first_name,last_name,gender,birth_date,acc_creation_date,mobile_no,email_id,password) - add_client=("INSERT INTO clients " - "(acc_no,type,first_name,last_name,gender,birth_date,accd,mobile_no,email_id,pass) " - "VALUES (%s,%s,%s,%s,%s,%s,%s,LPAD(%s,%s,'0'),%s,LPAD(%s,%s,'0'))") - data_client=(acc_no,acc_type,first_name,last_name,gender,birth_date,acc_creation_date,mobile_no,lmn,email_id,password,lp) - try: - cur.execute(add_client, data_client) - query.commit() - except mysql.connector.Error as err: - print(err.msg) - print("-----------Value addition was unsuccessful!!!!-------------") - else: - print("Values added successfully!!") \ No newline at end of file diff --git a/editaccount.py b/editaccount.py deleted file mode 100644 index d4ce64c..0000000 --- a/editaccount.py +++ /dev/null @@ -1,25 +0,0 @@ -import pickle -import mysql.connector - -from datetime import date - -def age(birthdate): - today = date.today() - age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day)) - return age -acc_no=0 -acc_creation_date=None -birth_date=None -def ep2(conn,cur): - while True: - acc_no=input("Enter acc_no (max 5 int) to edit details: ") - if len(acc_no) <= 5: - try: - acc_no=int(acc_no) - print("Done OK") - except ValueError: - print("acc_no should be an integer!!") - else: - break - else: - print("Maximum length is 5!") \ No newline at end of file diff --git a/editemployee.py b/editemployee.py deleted file mode 100644 index bb215e9..0000000 --- a/editemployee.py +++ /dev/null @@ -1,182 +0,0 @@ -import mysql.connector -from datetime import date -import dataentering - -def age(birthdate): - today = date.today() - age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day)) - return age -emp_no=0 -hire_date=None -birth_date=None -def ap3(conn,cur): - global emp_no - global birth_date - global hire_date - print("---------Edit employee process----------\n") - while True: - emp_no=input(("Enter emp_no of the employee to edit the details: ")) - if len(emp_no) <= 5: - try: - emp_no=int(emp_no) - print("Checking...") - except ValueError: - print("emp_no should be an integer!!") - else: - break - else: - print("Maximum length is 5!") - cur.execute("select * from employees where emp_no={}".format(emp_no)) - results=cur.fetchall() - if results == []: - print(results) - print("That employee number does not exist.") - else: - results1=results[0] - print("1.emp_no:",results1[0]) - print("2.birth_date:",results1[1]) - print("3.first_name:",results1[2]) - print("4.last-name:",results1[3]) - print("5.gender:",results1[4]) - print("6.hire_date:",results1[5]) - print("7.password") - birth_date=results1[1] - hire_date=results1[5] - f2(conn,cur) - -def f2(conn,cur): - global emp_no - global birth_date - global hire_date - print("0 to quit.") - a=input("What would you like to change from the above:") - if a == '1': - en=dataentering.primary_key_no("emp_no") - try: - cur.execute("update employees set emp_no={} where emp_no={}".format(en,emp_no)) - conn.commit() - except mysql.connector.Error as err: - print(err.msg) - print("-----------Value addition was unsuccessful!!!!-------------") - else: - print("Updated employee number...") - - if a == '2': - birth_date=dataentering.birthdate("employee",20,60) - if age(birth_date)-age(hire_date)>=20: - try: - cur.execute("update employees set birth_date='{}' where emp_no={}".format(birth_date,emp_no)) - conn.commit() - except mysql.connector.Error as err: - print(err.msg) - print("-----------Value addition was unsuccessful!!!!-------------") - else: - print("Updated birth date...") - else: - print("Employee must be atleast 20 years of age when hired!!") - print(birth_date,": birth_date") - print(hire_date,":hire date you entered") - - if a == '3': - while True: - first_name=input("Enter first name (max 15 char): ") - if len(first_name)<= 15: - try: - cur.execute("update employees set first_name='{}' where emp_no={}".format(first_name,emp_no)) - conn.commit() - except mysql.connector.Error as err: - print(err.msg) - print("-----------Value addition was unsuccessful!!!!-------------") - break - else: - print("Updated first name...") - break - else: - print("Max 15 characters") - - if a == '4': - while True: - last_name=input("Enter last name (max 15 char): ") - if len(last_name)<= 15: - try: - cur.execute("update employees set last_name='{}' where emp_no={}".format(last_name,emp_no)) - conn.commit() - except mysql.connector.Error as err: - print(err.msg) - print("-----------Value addition was unsuccessful!!!!-------------") - break - else: - print("Updated last name...") - break - else: - print("Max 15 characters") - if a == '5': - while True: - print("1.Male") - print("2.Female") - a=input("Enter choice (1 or 2):") - if a== '1': - try: - cur.execute("update employees set gender='M' where emp_no={}".format(emp_no)) - conn.commit() - except mysql.connector.Error as err: - print(err.msg) - print("-----------Value addition was unsuccessful!!!!-------------") - break - else: - print("Updated gender...") - break - - elif a=='2': - gender='F' - try: - cur.execute("update employees set gender='F' where emp_no={}".format(emp_no)) - conn.commit() - except mysql.connector.Error as err: - print(err.msg) - print("-----------Value addition was unsuccessful!!!!-------------") - break - else: - print("Updated gender...") - break - - else: - print("Wrong input!!") - - if a == '6': - hire_date=dataentering.date2("employee",birth_date,"hire",20,60) - try: - cur.execute("update employees set hire_date='{}' where emp_no={}".format(hire_date,emp_no)) - conn.commit() - except mysql.connector.Error as err: - print(err.msg) - print("-----------Value addition was unsuccessful!!!!-------------") - else: - print("Updated hire date...") - - if a=='7': - print("1.Show the password") - print("2.Change the password") - ans=input("Enter your choice (1,2):") - if ans=='1': - cur.execute("SELECT pass from empass where emp_no={}".format(emp_no)) - result=cur.fetchall() - print(result[0][0], "is the password.") - elif ans=='2': - while True: - password=input("Enter employee login password(max 8 characters, min 4): ") - lp=len(password) - if lp>8: - print("Max 8 characters only.") - elif lp<4: - print("Minimum 4 characters to be entered.") - else: - try: - cur.execute("UPDATE empass set pass=LPAD({},{},'0') where emp_no={}".format(password,lp,emp_no)) - conn.commit() - except mysql.connector.Error as err: - print(err.msg) - print("-----------Password change was unsuccessful!!!!-------------") - else: - print("Password changed successfully!!!") - break \ No newline at end of file diff --git a/src/main/OmJShah/admin/editemployee.py b/src/main/OmJShah/admin/editemployee.py new file mode 100644 index 0000000..6a374d8 --- /dev/null +++ b/src/main/OmJShah/admin/editemployee.py @@ -0,0 +1,131 @@ +import mysql.connector +from datetime import date +from tools import dataentering + +def age(birthdate): + today = date.today() + age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day)) + return age +emp_no=None +hire_date=None +birth_date=None + +def ap3(conn,cur): + global emp_no,birth_date,hire_date + print("---------Edit employee process----------\n") + while True: + print("input ~ to quit") + emp_no=input(("Enter emp_no of the employee to edit the details: ")) + if emp_no=="~": break + if len(emp_no) <= 5: + try: + emp_no=int(emp_no) + print("Checking...") + except ValueError: + print("emp_no should be an integer!!") + else: + next(conn,cur) + break + else: + print("Maximum length is 5!") + +def next(conn,cur): + cur.execute("select * from employees where emp_no={}".format(emp_no)) + results=cur.fetchall() + if len(results)==0: + print("That employee number does not exist.") + else: + results1=results[0] + print("1.emp_no:",results1[0]) + print("2.birth_date:",results1[1]) + print("3.first_name:",results1[2]) + print("4.last-name:",results1[3]) + print("5.gender:",results1[4]) + print("6.hire_date:",results1[5]) + print("7.password") + birth_date=results1[1] + hire_date=results1[5] + f2(conn,cur) + +def f2(conn,cur): + global emp_no,birth_date,hire_date + print("0 to quit.") + a=input("What would you like to change from the above:") + if a == '1': + en=dataentering.primary_key_no("emp_no") + query="update employees set emp_no=%s where emp_no=%s" + data=(en,emp_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated employee number...") + + if a == '2': + birth_date=dataentering.birthdate("employee",20,60) + if age(birth_date)-age(hire_date)>=20: + query="update employees set birth_date=%s where emp_no=%s" + data=(birth_date,emp_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated birth date") + else: + print("Employee must be atleast 20 years of age when hired!!") + print(birth_date,": birth_date") + print(hire_date,":hire date you entered") + + if a == '3': + first_name=dataentering.fname() + query="update employees set first_name=%s where emp_no=%s" + data=(first_name,emp_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated first name...") + + if a == '4': + last_name=dataentering.lname() + query="update employees set last_name=%s where emp_no=%s" + data=(last_name,emp_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated last name...") + + if a == '5': + gender=dataentering.gender() + query="update employees set gender=%s where emp_no=%s" + data=(gender,emp_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated gender...") + + if a == '6': + hire_date=dataentering.date2("employee",birth_date,"hire",20,60) + query="update employees set hire_date=%s where emp_no=%s" + data=(hire_date,emp_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated hire date...") + + if a=='7': + print("1.Show the password") + print("2.Change the password") + ans=input("Enter your choice (1,2):") + if ans=='1': + cur.execute("SELECT pass from empass where emp_no={}".format(emp_no)) + result=cur.fetchall() + print(result[0][0], "is the password.") + elif ans=='2': + while True: + password=input("Enter employee login password(max 8 characters, min 4): ") + lp=len(password) + if lp>8: + print("Max 8 characters only.") + elif lp<4: + print("Minimum 4 characters to be entered.") + else: + query="UPDATE empass set pass=LPAD(%s,%s,'0') where emp_no=%s" + data=(password,lp,emp_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Password changed successfully!!!") + break + else: + break \ No newline at end of file diff --git a/fireemployee.py b/src/main/OmJShah/admin/fireemployee.py similarity index 100% rename from fireemployee.py rename to src/main/OmJShah/admin/fireemployee.py diff --git a/hireemployee.py b/src/main/OmJShah/admin/hireemployee.py similarity index 97% rename from hireemployee.py rename to src/main/OmJShah/admin/hireemployee.py index 59bf5f1..c1cab84 100644 --- a/hireemployee.py +++ b/src/main/OmJShah/admin/hireemployee.py @@ -1,6 +1,5 @@ -from datetime import date import mysql.connector -import dataentering +from tools import dataentering def ap1(query,cur): print("-------------Hire Employee Process-------------") diff --git a/showemployee.py b/src/main/OmJShah/admin/showemployee.py similarity index 96% rename from showemployee.py rename to src/main/OmJShah/admin/showemployee.py index eb26833..fa89c0d 100644 --- a/showemployee.py +++ b/src/main/OmJShah/admin/showemployee.py @@ -1,5 +1,3 @@ -import mysql.connector - def ap4(cur): cur.execute("select * from employees") results=cur.fetchall() diff --git a/src/main/OmJShah/employee/createaccount.py b/src/main/OmJShah/employee/createaccount.py new file mode 100644 index 0000000..6f16f00 --- /dev/null +++ b/src/main/OmJShah/employee/createaccount.py @@ -0,0 +1,49 @@ +from tools import dataentering +import mysql.connector + +def ep1(query,cur): + print("-------------Create account Process-------------") + +#client number + acc_no=dataentering.primary_key_no("acc_no") +#client Birth date + birth_date=dataentering.birthdate("Client",10,100) +#client name + first_name,last_name=dataentering.fname(),dataentering.lname() +#client Gender + gender=dataentering.gender() +#client Account Type + while True: + print("1.Savings account") + print("2.Current account") + a=input("Enter choice (1 or 2):") + if a== '1': + acc_type='S' + break + elif a=='2': + acc_type='C' + break + else: + print("Wrong input!!") + +#Account creation date + acc_creation_date=dataentering.date2("client",birth_date,"account_creation",10,100) +#client password/pin + password,lp=dataentering.clientpassword() + +#mobile no + mobile_no,lmn=dataentering.mobileno() + +#email-id + email_id=dataentering.email() + + print("=========== Final Data ===========") + print(acc_no,acc_type,first_name,last_name,gender,birth_date,acc_creation_date,mobile_no,email_id,password) + add_client=("INSERT INTO clients " + "(acc_no,type,first_name,last_name,gender,birth_date,accd,mobile_no,email_id,pass) " + "VALUES (%s,%s,%s,%s,%s,%s,%s,LPAD(%s,%s,'0'),%s,LPAD(%s,%s,'0'))") + data_client=(acc_no,acc_type,first_name,last_name,gender,birth_date,acc_creation_date,mobile_no,lmn,email_id,password,lp) + + done=dataentering.tableupdate(query,cur,add_client,data_client) + if done: + print("Values added successfully!!") \ No newline at end of file diff --git a/src/main/OmJShah/employee/deleteaccount.py b/src/main/OmJShah/employee/deleteaccount.py new file mode 100644 index 0000000..e69de29 diff --git a/src/main/OmJShah/employee/editaccount.py b/src/main/OmJShah/employee/editaccount.py new file mode 100644 index 0000000..a38833c --- /dev/null +++ b/src/main/OmJShah/employee/editaccount.py @@ -0,0 +1,154 @@ +from datetime import date +from tools import dataentering +import mysql.connector + +acc_no=None +first_name=None +last_name=None +gender=None +birth_date=None +acc_creation_date=None +mobile_no=None +email_id=None +password = None + +def age(birthdate): + today = date.today() + age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day)) + return age + +def ep2(conn,cur): + global acc_no,first_name,last_name,gender,birth_date,acc_creation_date,mobile_no,email_id,password + while True: + print("input ~ to quit") + acc_no=input("Enter acc_no (max 5 int) to edit details: ") + if acc_no=="~": break + if len(acc_no) <= 5: + try: + acc_no=int(acc_no) + print("Done OK") + except ValueError: + print("acc_no should be an integer!!") + else: + print("Maximum length is 5!") + cur.execute("select * from clients where acc_no={}".format(acc_no)) + results=cur.fetchall() + if len(results)==0: + print("That employee number does not exist.") + else: + results1=results[0] + first_name=results1[2] + last_name=results1[3] + gender=results1[4] + birth_date=results1[5] + acc_creation_date=results1[6] + mobile_no=results1[7] + email_id=results1[8] + password=results1[9] + + print("1. first_name",first_name) + print("2. last_name",last_name) + print("3. gender",gender) + print("4. birth_date",birth_date) + print("5. account_creation_date",acc_creation_date) + print("6. mobile_no",mobile_no) + print("7. email_id",email_id) + print("8. password") + print("0 to quit") + ep2f2(conn,cur) + +def ep2f2(conn,cur): + global acc_no,first_name,last_name,gender,birth_date,acc_creation_date,mobile_no,email_id,password + choice=input("What would you like to change from here: ") +#First-name + if choice == "1": + first_name=dataentering.fname() + query="update clients set first_name=%s where acc_no=%s" + data=(first_name,acc_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated first name") + +#Last-name + elif choice == "2": + last_name=dataentering.lname() + query="update clients set last_name=%s where acc_no=%s" + data=(last_name,acc_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated last name") + +#Gender + elif choice == "3": + gender=dataentering.gender() + query="update clients set gender=%s where acc_no=%s" + data=(gender,acc_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated gender") + +#Birth-date + elif choice == "4": + birth_date=dataentering.birthdate("Client",10,100) + if age(birth_date)-age(acc_creation_date)>=10: + query="update clients set birth_date=%s where acc_no=%s" + data=(birth_date,acc_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated birth date") + else: + print("The client should atleast be 10 years of age.") + print("Birth date:",birth_date) + print("Account Creation Date:",acc_creation_date) + +#Account-creation-date(accd) + elif choice == "5": + acc_creation_date=dataentering.date2("client",birth_date,"account_creation",10,100) + query="update clients set accd=%s where acc_no=%s" + data=(acc_creation_date,acc_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated account creation date") + +#Mobile No + elif choice == "6": + mobile_no,lmn=dataentering.mobileno() + query="update clients set mobile_no=LPAD(%s,%s,'0') where acc_no=%s" + data=(mobile_no,lmn,acc_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated mobile number") + +#Email ID + elif choice == "7": + email_id=dataentering.email() + query="update clients set email=%s where acc_no=%s" + data=(mobile_no,acc_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated mobile number") +#Password + elif choice == "8": + while True: + print("1.Show Password") + print("2.Change Password") + print("0 to quit") + if choice == "1": + print("\nThe password will be printed on the next line") + print(password) + print() + elif choice == "2": + password,lp=dataentering.clientpassword() + query="update clients set pass=LPAD(%s,%s,'0') where acc_no=%s" + data=(password,lp,acc_no) + done=dataentering.tableupdate(conn,cur,query,data) + if done: + print("Updated password") + elif choice == "0": + break + else: + print("Wrong input!!") + elif choice == "0": + pass + else: + print("Wrong input!!") \ No newline at end of file diff --git a/check.py b/src/main/OmJShah/initialization/check.py similarity index 100% rename from check.py rename to src/main/OmJShah/initialization/check.py diff --git a/setup.py b/src/main/OmJShah/initialization/setup.py similarity index 94% rename from setup.py rename to src/main/OmJShah/initialization/setup.py index bc233d9..08f74c1 100644 --- a/setup.py +++ b/src/main/OmJShah/initialization/setup.py @@ -1,4 +1,4 @@ -import check +from initialization import check import pickle import mysql.connector @@ -41,7 +41,6 @@ " `emp_no` int(5) NOT NULL," " `pass` varchar(8) NOT NULL," " PRIMARY KEY (`emp_no`)," - " FOREIGN KEY(`emp_no`) REFERENCES employees(emp_no)" ") " ) @@ -52,7 +51,6 @@ " `balance` int NOT NULL," " `loan` enum('YES','NO') NOT NULL," " PRIMARY KEY (`acc_no`)," - " FOREIGN KEY(`acc_no`) REFERENCES clients(acc_no)" ") " ) @@ -62,7 +60,6 @@ " `balance` int NOT NULL," " `overdraft` int NOT NULL," " PRIMARY KEY (`acc_no`)," - " FOREIGN KEY(`acc_no`) REFERENCES clients(acc_no)" ") " ) @@ -76,7 +73,6 @@ " `amt-per-month` int NOT NULL," " `remaining_amt` int NOT NULL," " PRIMARY KEY (`acc_no`)," - " FOREIGN KEY(`acc_no`) REFERENCES clients(acc_no)" ") " ) @@ -86,7 +82,6 @@ " `overdraft_amt` int NOT NULL," " `od_with_interest_remaining` int NOT NULL," " PRIMARY KEY (`acc_no`)," - " FOREIGN KEY(`acc_no`) REFERENCES clients(acc_no)" ") " ) diff --git a/main.py b/src/main/OmJShah/main.py similarity index 75% rename from main.py rename to src/main/OmJShah/main.py index 50d5d22..a31c458 100644 --- a/main.py +++ b/src/main/OmJShah/main.py @@ -1,7 +1,7 @@ -import setup -import check -import accounttype -import connection +from initialization import setup +from initialization import check +from panels import accounttype +from tools import connection query,cur=connection.cc() while True: print("1.Continue") diff --git a/accounttype.py b/src/main/OmJShah/panels/accounttype.py similarity index 93% rename from accounttype.py rename to src/main/OmJShah/panels/accounttype.py index 052630b..bbe254d 100644 --- a/accounttype.py +++ b/src/main/OmJShah/panels/accounttype.py @@ -1,5 +1,5 @@ -import adminpanel -import employeepanel +from panels import adminpanel +from panels import employeepanel def acctype(query,cur): while True: print("--------------Account Selector Menu--------------") diff --git a/adminpanel.py b/src/main/OmJShah/panels/adminpanel.py similarity index 85% rename from adminpanel.py rename to src/main/OmJShah/panels/adminpanel.py index 11221ed..612eb24 100644 --- a/adminpanel.py +++ b/src/main/OmJShah/panels/adminpanel.py @@ -1,7 +1,7 @@ -import hireemployee -import fireemployee -import editemployee -import showemployee +from admin import hireemployee +from admin import fireemployee +from admin import editemployee +from admin import showemployee def ap(query,conn): print("\nWelcome Admin!!") diff --git a/employeepanel.py b/src/main/OmJShah/panels/employeepanel.py similarity index 92% rename from employeepanel.py rename to src/main/OmJShah/panels/employeepanel.py index 2ea8334..b8f441b 100644 --- a/employeepanel.py +++ b/src/main/OmJShah/panels/employeepanel.py @@ -1,4 +1,5 @@ -import createaccount +from employee import createaccount +from employee import editaccount def ep(conn,cur): print("\nWelcome employee!!") @@ -12,8 +13,6 @@ def ep(conn,cur): if ch == "1": print("------------login panel-------------") elif ch == "2": - cur.close() - conn.close() break else: print("Wrong input!!!(1 or 2 only)") @@ -43,14 +42,12 @@ def ep(conn,cur): if choice=="1": createaccount.ep1(conn,cur) elif choice=="2": - break + editaccount.ep2(conn,cur) elif choice=="3": break elif choice=="4": break elif choice=="0": - cur.close() - conn.close() break else: print("Wrong input!") diff --git a/connection.py b/src/main/OmJShah/tools/connection.py similarity index 100% rename from connection.py rename to src/main/OmJShah/tools/connection.py diff --git a/dataentering.py b/src/main/OmJShah/tools/dataentering.py similarity index 75% rename from dataentering.py rename to src/main/OmJShah/tools/dataentering.py index 50ab857..5adc439 100644 --- a/dataentering.py +++ b/src/main/OmJShah/tools/dataentering.py @@ -1,4 +1,5 @@ from datetime import date +import mysql.connector def age(birthdate): today = date.today() @@ -80,7 +81,7 @@ def birthdate(person,minage,maxage): print("Maximum age is {} years!!!".format(maxage)) print("\nwrong input\n") -def name(): +def fname(): #Employee name and client name while True: first_name=input("Enter first name (max 15 char): ") @@ -88,7 +89,9 @@ def name(): break else: print("Max 15 characters") + return first_name +def lname(): while True: last_name=input("Enter last name (max 15 char): ") if len(last_name)<= 15: @@ -96,7 +99,7 @@ def name(): else: print("Max 15 characters") - return first_name,last_name + return last_name def gender(): #Employee Gender and client gender @@ -168,4 +171,55 @@ def date2(person,birth_date,hire_or_creation,minage,maxage): break else: print("{} must atleast be {} years of age!!".format(person,maxage)) - return hire_date \ No newline at end of file + return hire_date + +def mobileno(): + while True: + mobile_no_str=input("Enter mobile no. (7 to 15 int)") + mobile_no=mobile_no_str + #Thanks to the international phone numbering plan (ITU-T E. 164), + #phone numbers cannot contain more than 15 digits. The shortest + #international phone numbers in use contain seven digits. + try: + mobile_no=int(mobile_no) + except ValueError: + print("mobile_no should be an integer!!") + else: + if len(mobile_no_str)>6 and len(mobile_no_str)<16: + mobile_no=mobile_no_str + lmn=len(mobile_no) + break + else: + print("Mobile number can have min 7 digits and max 15!!") + return mobile_no,lmn + +def email(): + while True: + email_id=input("Enter client Email ID (max 25 char):") + if len(email_id)<26: + break + else: + print("Maximum 25 characters") + return email_id + +def clientpassword(): + while True: + password=input("Enter client login password(max 8 characters, min 4): ") + lp=len(password) + if lp>8: + print("Max 8 characters only.") + elif lp<4: + print("Minimum 4 characters to be entered.") + else: + break + return password,lp + +def tableupdate(conn,cur,query,data): + try: + cur.execute(query,data) + conn.commit() + except mysql.connector.Error as err: + print(err.msg) + print("-----------Value addition was unsuccessful!!!!-------------") + else: + return bool(True) \ No newline at end of file