Beispiel #1
0
 def update():
     
     if field_blank_checking(house_no.get()) == TRUE or field_blank_checking(chat_id.get()) == TRUE or field_blank_checking(name.get()) == TRUE or field_blank_checking(phone_num.get()) == TRUE :
         messagebox.showinfo('Error', 'Please enter all the fields!')
     elif number_format_checking(house_no.get()) == TRUE:
         messagebox.showinfo('Error', 'House number cannot contain alphabet, symbols and whitespaces!')
     elif alphabet_format_checking(name.get()) == TRUE:
         messagebox.showinfo('Error', 'Name cannot contain number, symbols and whitespaces!')
     elif phone_number_format_checking(phone_num.get()) == TRUE:
         messagebox.showinfo('Error', 'Phone number must have the format 0123333444 or +601233334444!')
     else:
             
         try:
             con=pymysql.connect(user='******', password='', host='localhost', database='parking_locator')
             
             cur = con.cursor()
             sql="update resident set chat_id = '%s', name = '%s', phone_number = '%s', lot_area = '%s' where house_no = '%s'" %(chat_id.get(), name.get(), phone_num.get(), tkvar_lot_area_resident.get(), house_no.get())
             cur.execute(sql)
             con.commit()
             con.close()
             messagebox.showinfo('Success', 'Record Modified')
             displayList()
         except:
             messagebox.showinfo('Error', 'Error in data changes')
         finally:
             clear()
def login_verify(event):
    usernameFromUser = usernameVerify.get()
    passwordFromUser = passwordVerify.get()
    usernameLoginEntry.delete(0, END)
    passwordLoginEntry.delete(0, END)

    if field_blank_checking(usernameFromUser) == TRUE or field_blank_checking(
            passwordFromUser) == TRUE:
        messagebox.showinfo('Error',
                            'Both username and password has to be filled!')
    else:

        try:
            con = pymysql.connect(user='******',
                                  password='',
                                  host='localhost',
                                  database='parking_locator')

            cur = con.cursor()
            sql = "select password from admin where username='******'" % usernameFromUser
            cur.execute(sql)
            result = cur.fetchone()
            password_fetched = result[0]

            boolean = verify_password(password_fetched, passwordFromUser)
            con.close()

            if boolean:
                login_sucess()

            else:
                messagebox.showinfo('Error', 'Invalid password')
        except:
            messagebox.showinfo('Error', 'Username not found')
    def register_user(event):
        username_info = username.get()
        password_info = password.get()

        if field_blank_checking(username_info) == TRUE or field_blank_checking(
                password_info) == TRUE:
            messagebox.showinfo(
                'Error', 'Both username and password has to be filled!')
        else:

            try:
                con = pymysql.connect(user='******',
                                      password='',
                                      host='localhost',
                                      database='parking_locator')
                cur = con.cursor()
                '''
                Title: A check if username exist in database with Python
                Website: StackOverflow
                URL: https://stackoverflow.com/questions/57578420/a-check-if-username-exist-in-database-with-python
                Author: stahamtan
                Date Posted: 20 August 2019
                Date Referred: 18 May 2020
                '''
                check_username_exist = cur.execute(
                    "select username from admin where username = '******'" %
                    (username_info))

                if check_username_exist > 0:
                    messagebox.showinfo('Error', 'Username already taken')
                elif password_format_checking(password_info):
                    messagebox.showinfo(
                        'Error',
                        'Invalid password! A password must be between 6 to 12 characters that contains a uppercase letter, lowercase letter, digits as well as symbols.'
                    )
                else:
                    password_info = hash_password(password_info)
                    sql = "insert into admin (username, password) values ('%s','%s')" % (
                        username_info, password_info)
                    cur.execute(sql)
                    con.commit()
                    con.close()
                    messagebox.showinfo('Success', 'Registration Success')
            except:
                messagebox.showinfo('Error', 'Registration Failed')
            finally:
                usernameEntry.delete(0, END)
                passwordEntry.delete(0, END)
Beispiel #4
0
 def search():
     
     if field_blank_checking(house_no.get()) == TRUE:
         messagebox.showinfo('Error', 'Please enter the house number to search!')
     elif number_format_checking(house_no.get()) == TRUE:
         messagebox.showinfo('Error', 'House number cannot contain alphabet, symbols and whitespaces!')
     else:
         
         try:
             con=pymysql.connect(user='******', password='', host='localhost', database='parking_locator')
             
             cur = con.cursor()
             sql="select * from resident where house_no='%s'" %house_no.get()
             cur.execute(sql)
             result = cur.fetchone()
             chat_id.set(result[1])
             name.set(result[2])
             phone_num.set(result[3])            
             tkvar_lot_area_resident.set(result[4])
             
             houseNumberEntry.configure(state='disabled')
             con.close()
         except:
             messagebox.showinfo('No Data', 'No such resident available.')
             clear()
Beispiel #5
0
 def update():
     
     if field_blank_checking(lot_area_id.get()) == TRUE or field_blank_checking(desc.get()) == TRUE or field_blank_checking(capacity.get()) == TRUE :
         messagebox.showinfo('Error', 'Please enter all the fields!')
     elif number_format_checking(capacity.get()) == TRUE:
         messagebox.showinfo('Error', 'Capacity cannot contain alphabet, symbols and whitespaces!')
     else:
             
         try:
             con=pymysql.connect(user='******', password='', host='localhost', database='parking_locator')
             
             cur = con.cursor()
             sql="update parking_lot_details set description = '%s', capacity = '%s' where lot_area_id = '%s'" %(desc.get(), capacity.get(), lot_area_id.get())
             cur.execute(sql)
             con.commit()
             con.close()
             messagebox.showinfo('Success', 'Record Modified')
             displayList()
         except:
             messagebox.showinfo('Error', 'Error in data changes')
         finally:
             clear()
Beispiel #6
0
 def add():
     
     if field_blank_checking(lot_area_id.get()) == TRUE or field_blank_checking(desc.get()) == TRUE or field_blank_checking(capacity.get()) == TRUE :
         messagebox.showinfo('Error', 'Please enter all the fields!')
     elif number_format_checking(capacity.get()) == TRUE:
         messagebox.showinfo('Error', 'Capacity cannot contain alphabet, symbols and whitespaces!')
     else:
         
         try:
             con=pymysql.connect(user='******', password='', host='localhost', database='parking_locator')
             
             cur = con.cursor()
             sql="insert into parking_lot_details values ('%s','%s','%s')" %(lot_area_id.get(), desc.get(), capacity.get())
             cur.execute(sql)
             con.commit()
             con.close()
             messagebox.showinfo('Success', 'Record Saved')
             displayList()
         except:
             messagebox.showinfo('Error', 'Lot Area exists')
         finally:
             clear()
Beispiel #7
0
 def delete():
     if field_blank_checking(lot_area_id.get()) == TRUE :
         messagebox.showinfo('Error', 'Please enter the Lot Area ID to remove it!')
     else:
         try:
             con=pymysql.connect(user='******', password='', host='localhost', database='parking_locator')
             
             cur = con.cursor()
             sql="delete from parking_lot_details where lot_area_id = '%s'" %(lot_area_id.get())
             cur.execute(sql)
             con.commit()
             con.close()
             messagebox.showinfo('Success', 'Record Deleted')
             displayList()
         except:
             messagebox.showinfo('Error', 'Error in data deletion')
         finally:
             clear()
Beispiel #8
0
 def search():
     
     if field_blank_checking(lot_area_id.get()) == TRUE:
         messagebox.showinfo('Error', 'Please enter the Lot Area ID to search!')
     else:
         
         try:
             con=pymysql.connect(user='******', password='', host='localhost', database='parking_locator')
             
             cur = con.cursor()
             sql="select * from parking_lot_details where lot_area_id='%s'" %lot_area_id.get()
             cur.execute(sql)
             result = cur.fetchone()
             desc.set(result[1])
             capacity.set(result[2])
             lotAreaIdEntry.configure(state='disabled')
             con.close()
         except:
             messagebox.showinfo('No Data', 'No such parking lot details available.')
             clear()
Beispiel #9
0
 def delete():
     
     if field_blank_checking(house_no.get()) == TRUE :
         messagebox.showinfo('Error', 'Please enter the house number to remove it!')
     elif number_format_checking(house_no.get()) == TRUE:
         messagebox.showinfo('Error', 'House number cannot contain alphabet, symbols and whitespaces!')
     else:
         try:
             con=pymysql.connect(user='******', password='', host='localhost', database='parking_locator')
             
             cur = con.cursor()
             sql="delete from resident where house_no = '%s'" %(house_no.get())
             cur.execute(sql)
             con.commit()
             con.close()
             messagebox.showinfo('Success', 'Record Deleted')
             displayList()
         except:
             messagebox.showinfo('Error', 'Error in data deletion')
         finally:
             clear()