from tkinter import *

from tkinter import ttk

import win32api

import win32com. client

import os

root = Tk ( )

root. title ( "B&B data storeage application" )

drive = os . path . realpath ( "" ) [ : 2 ]

def default ( ) :

room_price = open ( drive+ " \d efualt_room.txt" , "w" )

night_price = open ( drive+ " \d efualt_night.txt" , "w" )

Laundry_price = open ( drive+ " \d efualt_laundry.txt" , "w" )

Internet_price = open ( drive+ " \d efualt_internet.txt" , "w" )

Telephone_price = open ( drive+ " \d efualt_telephone.txt" , "w" )

r = str ( input ( "What is the room price?" ) )

n = str ( input ( "What is the price per night?" ) )

l = str ( input ( "What is the laundry price?" ) )

i = str ( input ( "What is the internet price per hour?" ) )

t = str ( input ( "What is the telephone price per hour?" ) )

room_price. write ( r )

night_price. write ( n )

Laundry_price. write ( l )

Internet_price. write ( i )

Telephone_price. write ( t )

def Invoice ( ) :

check = str ( input ( "Have you set default prices? If you havnt this will not work. If you want to change default prices type 'change'." ) )

if check == "no" or "change" :

default ( )

derp = False

while derp == False :

try :

Num_of_rooms = int ( input ( "number of rooms" ) )

derp = True

except ValueError :

win32api. MessageBox ( None , "Please enter a number" , "Error!" )

derp = False

derp = False

derp = False

while derp == False :

try :

Num_of_nights = int ( input ( "number of nights" ) )

derp = True

except ValueError :

win32api. MessageBox ( None , "Please enter a number" , "Error!" )

derp = False

derp = False

Laundry = input ( "Did they use Laundry?" )

Internet = input ( "Did they use the internet?" )

Telephone = input ( "Did they use the telephone?" )

Additional = input ( "Where there any additional services?" )

if Additional == "yes" :

derp = False

while derp == False :

try :

Price = int ( input ( "How much did the additional services cost?" ) )

derp = True

except ValueError :

win32api. MessageBox ( None , "Please enter a number" , "Error!" )

derp = False

else :

Price = 0

if Laundry == "yes" :

default_laundry = open ( drive+ " \d efualt_laundry.txt" , "r" )

for line in default_laundry:

herp = line

derp = str ( herp )

derp_laundry = int ( derp )

Laundry_price = derp_laundry

else :

Laundry_price = 0

if Telephone == "yes" :

derp = False

while derp == False :

try :

telephone_price = int ( input ( "How many hours did they spend on the phone?" ) )

default_telephone = open ( drive+ " \d efualt_telephone.txt" , "r" )

for line in default_telephone:

herp = line

derp = str ( herp )

derp_telephone = int ( derp )

Telephone_price = telephone_price*derp_telephone

derp = True

except ValueError :

win32api. MessageBox ( None , "Please enter a number" , "Error!" )

derp = False

else :

Telephone_price = 0

if Internet == "yes" :

derp = False

while derp == False :

try :

internet_price = int ( input ( "How many hours did they spend on the internet?" ) )

default_internet = open ( drive+ " \d efualt_internet.txt" , "r" )

for line in default_internet:

herp = line

derp = str ( herp )

derp_internet = int ( derp )

Internet_price = internet_price*derp_internet

derp = True

except ValueError :

win32api. MessageBox ( None , "Please enter a number" , "Error!" )

derp = False

else :

Internet_price = 0

default_night = open ( drive+ " \d efualt_night.txt" , "r" )

for line in default_night:

herp = line

derp = str ( herp )

derp_night = int ( derp )

default_room = open ( drive+ " \d efualt_room.txt" , "r" )

for line in default_room:

herp = line

derp = str ( herp )

derp_rooms = int ( derp )

herp_rooms = derp_rooms

herp_nights = derp_night

rooms = Num_of_rooms

nights = Num_of_nights

total = int ( rooms*herp_rooms+nights*herp_nights+Laundry_price+Telephone_price+Internet_price+Price )

herp = str ( total )

Total = Label ( root , text = "Total due:" + herp ) . grid ( row = 5 , column = 2 )

default_cleaner_wage = 0

def cleaner_wage ( ) :

default_cleaner_wage = input ( "What is the mothnly cleaner wage?" )

def Expenture ( ) :

wage = input ( "Do you want to change the cleaner wage?" )

if wage == "yes" :

cleaner_wage ( )

derp = False

while derp == False :

try :

heating = int ( input ( "Please enter heating cost" ) )

derp = True

except ValueError :

win32api. MessageBox ( None , "Please enter a number" , "Error!" )

derp = False

derp = False

while derp == False :

try :

food = int ( input ( "Please enter food costs" ) )

derp = True

except ValueError :

win32api. MessageBox ( None , "Please enter a number" , "Error!" )

derp = False

derp = False

while derp == False :

try :

drinks = int ( input ( "Please enter drinks cost" ) )

derp = True

except ValueError :

win32api. MessageBox ( None , "Please enter a number" , "Error!" )

derp = False

derp = False

while derp == False :

try :

eletric = int ( input ( "Please enter eletic cost" ) )

derp = True

except ValueError :

win32api. MessageBox ( None , "Please enter a number" , "Error!" )

derp = False

derp = False

while derp == False :

try :

morgage = int ( input ( "Please enter morgage cost" ) )

derp = True

except ValueError :

win32api. MessageBox ( None , "Please enter a number" , "Error!" )

derp = False

cleaner_Wage = default_cleaner_wage

Upkeep = int ( heating + food + drinks + eletric + morgage )

return int ( Upkeep + cleaner_Wage )

def Read ( ) :

profit = str ( input ( "How much profit have you made this month?" ) )

with open ( drive+ " \p rofit.txt" , 'r+' ) as f:

f. write ( profit )

for line in f:

herp = line

derp = str ( herp )

derpy = int ( derp )

return int ( derpy )

def income ( ) :

herp = Expenture ( )

derp = Read ( )

ToTal = derp - herp

Profitl = Label ( root , text = "Total profit:" ) . grid ( row = 3 , column = 2 )

Profit = Label ( root , text = str ( ToTal ) ) . grid ( row = 3 , column = 3 )

total_Inl = Label ( root , text = "Income:" ) . grid ( row = 1 , column = 2 )

total_In = Label ( root , text = str ( derp ) ) . grid ( row = 1 , column = 3 )

total_Outl = Label ( root , text = "Expenture:" ) . grid ( row = 2 , column = 2 )

total_Out = Label ( root , text = herp ) . grid ( row = 2 , column = 3 )

def Bookings ( ) :

room = int ( input ( "What room number is the booking in?" ) )

Customer_ID = str ( input ( "Please enter customer ID" ) )

Name = str ( input ( "Please enter first name" ) )

name = str ( input ( "Please enter last name" ) )

Tel_Num = str ( input ( "Please enter telephone number" ) )

Email = str ( input ( "Please enter email address" ) )

Address1 = str ( input ( "Please enter address line 1" ) )

Address2 = str ( input ( "Please enter address line 2" ) )

Postcode = str ( input ( "Please enter postcode" ) )

Credit = str ( input ( "Please enter credit card number" ) )

herp = Customer_ID , Name , name

derp = Tel_Num , Email , Address1

derpy = Address2 , Postcode , Credit

herpy = herp , derp , derpy

if room == 1 :

with open ( drive+ ' \W HY.txt' , 'r+' ) as f:

f. writelines ( Customer_ID + " " )

f. writelines ( name + " " )

f. writelines ( Name + " " )

f. writelines ( Tel_Num + " " )

f. writelines ( Email + " " )

f. writelines ( Address1 + " " )

f. writelines ( Address2 + " " )

f. writelines ( Postcode + " " )

f. writelines ( Credit + " " )

win32api. MessageBox ( None , "Booking created, use the Look Up function to veiw it." , "Booking" )

elif room == 2 :

with open ( drive+ ' \W HY2.txt' , 'r+' ) as e:

e. writelines ( Customer_ID+ " " )

e. writelines ( name+ " " )

e. writelines ( Name+ " " )

e. writelines ( Tel_Num+ " " )

e. writelines ( Email+ " " )

e. writelines ( Address1+ " " )

e. writelines ( Address2+ " " )

e. writelines ( Postcode+ " " )

e. writelines ( Credit+ " " )

win32api. MessageBox ( None , "Booking created, use the Look Up function to veiw it." , "Booking" )

elif room == 3 :

with open ( drive+ ' \W HY3.txt' , 'r+' ) as r:

r. writelines ( Customer_ID+ " " )

r. writelines ( name+ " " )

r. writelines ( Name+ " " )

r. writelines ( Tel_Num+ " " )

r. writelines ( Email+ " " )

r. writelines ( Address1+ " " )

r. writelines ( Address2+ " " )

r. writelines ( Postcode+ " " )

r. writelines ( Credit+ " " )

win32api. MessageBox ( None , "Booking created, use the Look Up function to veiw it." , "Booking" )

elif room == 4 :

with open ( drive+ ' \W HY4.txt' , 'r+' ) as g:

g. writelines ( Customer_ID+ " " )

g. writelines ( name+ " " )

g. writelines ( Name+ " " )

g. writelines ( Tel_Num+ " " )

g. writelines ( Email+ " " )

g. writelines ( Address1+ " " )

g. writelines ( Address2+ " " )

g. writelines ( Postcode+ " " )

g. writelines ( Credit+ " " )

win32api. MessageBox ( None , "Booking created, use the Look Up function to veiw it." , "Booking" )

elif room == 5 :

with open ( drive+ ' \W HY5.txt' , 'r+' ) as h:

h. writelines ( Customer_ID+ " " )

h. writelines ( name+ " " )

h. writelines ( Name+ " " )

h. writelines ( Tel_Num+ " " )

h. writelines ( Email+ " " )

h. writelines ( Address1+ " " )

h. writelines ( Address2+ " " )

h. writelines ( Postcode+ " " )

h. writelines ( Credit+ " " )

win32api. MessageBox ( None , "Booking created, use the Look Up function to veiw it." , "Booking" )

elif room == 6 :

with open ( drive+ ' \W HY6.txt' , 'r+' ) as a:

a. writelines ( Customer_ID+ " " )

a. writelines ( name+ " " )

a. writelines ( Name+ " " )

a. writelines ( Tel_Num+ " " )

a. writelines ( Email+ " " )

a. writelines ( Address1+ " " )

a. writelines ( Address2+ " " )

a. writelines ( Postcode+ " " )

a. writelines ( Credit+ " " )

win32api. MessageBox ( None , "Booking created, use the Look Up function to veiw it." , "Booking" )

elif room == 7 :

with open ( drive+ ' \W HY7.txt' , 'r+' ) as j:

j. writelines ( Customer_ID+ " " )

j. writelines ( name+ " " )

j. writelines ( Name+ " " )

j. writelines ( Tel_Num+ " " )

j. writelines ( Email+ " " )

j. writelines ( Address1+ " " )

j. writelines ( Address2+ " " )

j. writelines ( Postcode+ " " )

j. writelines ( Credit+ " " )

win32api. MessageBox ( None , "Booking cerated, use the Look Up function to veiw it." , "Booking" )

elif room == 8 :

with open ( drive+ ' \W HY8.txt' , 'r+' ) as k:

k. writelines ( Customer_ID+ " " )

k. writelines ( name+ " " )

k. writelines ( Name+ " " )

k. writelines ( Tel_Num+ " " )

k. writelines ( Email+ " " )

k. writelines ( Address1+ " " )

k. writelines ( Address2+ " " )

k. writelines ( Postcode+ " " )

k. writelines ( Credit+ " " )

win32api. MessageBox ( None , "Booking created, use the Look Up function to veiw it." , "Booking" )

else :

win32api. MessageBox ( None , "That isnt a room" )

def look ( ) :

which = int ( input ( "What booking do you want to look up?" ) )

if which == 1 :

with open ( drive+ ' \W HY.txt' , 'r' ) as f:

for line in f:

show = Label ( root , text = line ) . grid ( row = 6 , column = 2 )

elif which == 2 :

with open ( drive+ ' \W HY2.txt' , 'r' ) as f:

for line in f:

Look5 = Label ( root , text = sys . stdout . write ( line ) ) . grid ( row = 7 , column = 2 )

elif which == 3 :

with open ( drive+ ' \W HY3.txt' , 'r' ) as f:

for line in f:

show = Label ( root , text = line ) . grid ( row = 8 , column = 2 )

elif which == 4 :

with open ( drive+ ' \W HY4.txt' , 'r' ) as f:

for line in f:

show = Label ( root , text = line ) . grid ( row = 9 , column = 2 )

elif which == 5 :

with open ( drive+ ' \W HY5.txt' , 'r' ) as f:

for line in f:

show = Label ( root , text = line ) . grid ( row = 10 , column = 2 )

elif which == 6 :

with open ( drive+ ' \W HY6.txt' , 'r' ) as f:

for line in f:

show = Label ( root , text = line ) . grid ( row = 11 , column = 2 )

elif which == 7 :

with open ( drive+ ' \W HY7.txt' , 'r' ) as f:

for line in f:

show = Label ( root , text = line ) . grid ( row = 12 , column = 2 )

elif which == 8 :

with open ( drive+ ' \W HY8.txt' , 'r' ) as f:

for line in f:

show = Label ( root , text = line ) . grid ( row = 13 , column = 2 )

else :

win32api. MessageBox ( None , "Booking number not found." , "Error" )

def wipe ( ) :

open ( drive+ " \p assword.txt" , "w" )

open ( drive+ " \i nvoice1.txt" , "w" )

open ( drive+ " \i nvoice2.txt" , "w" )

open ( drive+ " \i nvoice3.txt" , "w" )

open ( drive+ " \i nvoice4.txt" , "w" )

open ( drive+ " \i nvoice5.txt" , "w" )

open ( drive+ " \p rofit.txt" , "w" )

open ( drive+ " \W HY.txt" , "w" )

open ( drive+ " \W HY2.txt" , "w" )

open ( drive+ " \W HY3.txt" , "w" )

open ( drive+ " \W HY4.txt" , "w" )

open ( drive+ " \W HY5.txt" , "w" )

open ( drive+ " \W HY6.txt" , "w" )

open ( drive+ " \W HY7.txt" , "w" )

open ( drive+ " \W HY8.txt" , "w" )

def wipe2 ( ) :

open ( drive+ " \i nvoice1.txt" , "w" )

open ( drive+ " \i nvoice2.txt" , "w" )

open ( drive+ " \i nvoice3.txt" , "w" )

open ( drive+ " \i nvoice4.txt" , "w" )

open ( drive+ " \i nvoice5.txt" , "w" )

open ( drive+ " \p rofit.txt" , "w" )

open ( drive+ " \W HY.txt" , "w" )

open ( drive+ " \W HY2.txt" , "w" )

open ( drive+ " \W HY3.txt" , "w" )

open ( drive+ " \W HY4.txt" , "w" )

open ( drive+ " \W HY5.txt" , "w" )

open ( drive+ " \W HY6.txt" , "w" )

open ( drive+ " \W HY7.txt" , "w" )

open ( drive+ " \W HY8.txt" , "w" )

win32api. MessageBox ( None , "All data has been wiped" , "Wiping" )

try :

Password = open ( drive+ " \p assword.txt" , "r+" )

except :

win32api. MessageBox ( None , "It would seem the program has failed to detect the drive it is running from. Please install the program to the root of a drive and try again." , "Error" )

def PassworD ( ) :

while True :

password = input ( "Please enter password. If you are yet to set a password, type 'set_password'" )

if password == "set_password" :

wipe ( )

set_password = input ( "Please enter the password you want" )

with open ( drive+ " \p assword.txt" , "r+" ) as f:

f. write ( set_password )

else :

if password in Password:

Welcome = Label ( root , text = "Welcome, what would you like to do?" ) . grid ( row = 1 , column = 1 )

invoice = Button ( root , text = " Calculate an invoice " , command = Invoice ) . grid ( row = 3 , column = 1 )

expenture = Button ( root , text = " Show monthly expenture and profit " , command = income ) . grid ( row = 4 , column = 1 )

Booking = Button ( root , text = " Create a booking " , command = Bookings ) . grid ( row = 5 , column = 1 )

Look = Button ( root , text = " Look up a booking " , command = look ) . grid ( row = 6 , column = 1 )

Wipe = Button ( root , text = " Wipe all stored data " , command = wipe2 ) . grid ( row = 7 , column = 1 )

Exit = Button ( root , text = " Quit " , command = root. quit ) . grid ( row = 9 , column = 1 )

root. mainloop ( )

break

else :

win32api. MessageBox ( None , "Wrong password, closing application" )

break