|
| 1 | + |
| 2 | +#Import Required Modules |
| 3 | + |
| 4 | +import os |
| 5 | +import pickle |
| 6 | + |
| 7 | +# List Creation |
| 8 | + |
| 9 | +details_list=[] |
| 10 | +l2=[] |
| 11 | +G = [] |
| 12 | + |
| 13 | +#------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 14 | + |
| 15 | +def file_save(): # Function to save |
| 16 | + NAME_PRO = details_list[0] |
| 17 | + ADDRESS_PRO = details_list[1] |
| 18 | + MOBILE_NO_PRO = details_list[2] |
| 19 | + ROOM_NO_PRO = details_list[3] |
| 20 | + PRICE_PRO = details_list[4] |
| 21 | + f = open("hotel.dat", "ab") |
| 22 | + a=save(NAME_PRO,ADDRESS_PRO,MOBILE_NO_PRO,ROOM_NO_PRO,PRICE_PRO) |
| 23 | + pickle.dump(a,f,protocol=2) |
| 24 | + f.close() |
| 25 | + restart_program() |
| 26 | + |
| 27 | +#------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 28 | + |
| 29 | +def restart_program(): # Function to restart Program |
| 30 | + """Restarts the current program. |
| 31 | + Note: this function does not return. Any cleanup action (like |
| 32 | + saving data) must be done before calling this function.""" |
| 33 | + python = sys.executable |
| 34 | + os.execl(python, python, * sys.argv) |
| 35 | + |
| 36 | + |
| 37 | +#------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +class save: Class Save Function |
| 42 | + def __init__(self, NAME_PRO, ADDRESS_PRO, MOBILE_NO_PRO, ROOM_NO_PRO, PRICE_PRO): |
| 43 | + self.name=NAME_PRO |
| 44 | + self.address=ADDRESS_PRO |
| 45 | + self.mobile_no=MOBILE_NO_PRO |
| 46 | + self.room_no=ROOM_NO_PRO |
| 47 | + self.price=PRICE_PRO |
| 48 | + print(self.name,self.address,self.mobile_no,self.room_no,self.price) |
| 49 | + |
| 50 | + |
| 51 | +#------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 52 | + |
| 53 | + |
| 54 | +import sys |
| 55 | + |
| 56 | +try: |
| 57 | + from Tkinter import * |
| 58 | +except ImportError: |
| 59 | + from tkinter import * |
| 60 | + |
| 61 | +try: |
| 62 | + import ttk |
| 63 | + py3 = False |
| 64 | +except ImportError: |
| 65 | + import tkinter.ttk as ttk |
| 66 | + py3 = True |
| 67 | + |
| 68 | +#------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 69 | + |
| 70 | +class New_Toplevel: |
| 71 | + |
| 72 | + def __init__(self): |
| 73 | + def check_room(): # Function for Checkout |
| 74 | + |
| 75 | + self.rom = str(self.data.get()) # Get Room number |
| 76 | + print(self.rom) |
| 77 | + print("\n") |
| 78 | + |
| 79 | + if self.rom.isdigit() == True and len(self.rom) != 0: |
| 80 | + self.Text1.insert(INSERT, " valid room number ""\n") |
| 81 | + v = int(self.rom) |
| 82 | + f = open("hotel.dat", "rb") |
| 83 | + f1 = open("hote.dat", "ab") |
| 84 | + n = 0 |
| 85 | + try: |
| 86 | + while True: |
| 87 | + s = pickle.load(f) |
| 88 | + if s.room_no == v: |
| 89 | + n = 1 |
| 90 | + name1 = s.name |
| 91 | + |
| 92 | + print(" ") |
| 93 | + else: |
| 94 | + pickle.dump(s, f1) |
| 95 | + |
| 96 | + except EOFError: |
| 97 | + if n == 0: |
| 98 | + self.Text1.insert(INSERT, "NO GUEST FOUND""\n") |
| 99 | + |
| 100 | + elif n == 1: |
| 101 | + |
| 102 | + self.Text1.insert(INSERT, "THANK YOU " + name1.upper() + " FOR VISTING US""\n") |
| 103 | + pass |
| 104 | + |
| 105 | + f.close() # Close file |
| 106 | + f1.close() |
| 107 | + os.remove("hotel.dat") |
| 108 | + os.rename("hote.dat", "hotel.dat") |
| 109 | + |
| 110 | + else: |
| 111 | + |
| 112 | + self.Text1.insert(INSERT, "invalid input please input a valid ROOM NO.""\n") |
| 113 | + |
| 114 | + #--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 115 | + |
| 116 | + root = Tk() # Setting Window |
| 117 | + |
| 118 | + '''This class configures and populates the toplevel window. |
| 119 | + top is the toplevel containing window.''' |
| 120 | + _bgcolor = '#ffffff' # X11 color: 'white' |
| 121 | + _fgcolor = '#000000' # X11 color: 'black' |
| 122 | + _compcolor = '#ffffff' # X11 color: 'white' |
| 123 | + _ana1color = '#ffffff' # X11 color: 'white' |
| 124 | + _ana2color = '#ffffff' # X11 color: 'white' |
| 125 | + font10 = "-family {Courier New} -size 10 -weight normal -slant" \ |
| 126 | + " roman -underline 0 -overstrike 0" |
| 127 | + font11 = "-family {Segoe UI} -size 23 -weight bold -slant " \ |
| 128 | + "roman -underline 0 -overstrike 0" |
| 129 | + font12 = "-family {Segoe UI} -size 24 -weight bold -slant " \ |
| 130 | + "roman -underline 0 -overstrike 0" |
| 131 | + font9 = "-family {Segoe UI} -size 9 -weight normal -slant " \ |
| 132 | + "roman -underline 0 -overstrike 0" |
| 133 | + |
| 134 | + #--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 135 | + |
| 136 | + root.geometry("1011x750") # Setting window Size |
| 137 | + root.title("HOTEL MANAGEMENT") |
| 138 | + root.configure(background="#ffffff") |
| 139 | + root.configure(highlightbackground="#ffffff") |
| 140 | + root.configure(highlightcolor="black") |
| 141 | + |
| 142 | + #--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 143 | + |
| 144 | + self.Frame1 = Frame(root) # Setting Frame |
| 145 | + self.Frame1.place(relx=0.04, rely=0.04, relheight=0.91, relwidth=0.91) |
| 146 | + self.Frame1.configure(relief=GROOVE) |
| 147 | + self.Frame1.configure(borderwidth="2") |
| 148 | + self.Frame1.configure(relief=GROOVE) |
| 149 | + self.Frame1.configure(background="#ffffff") |
| 150 | + self.Frame1.configure(highlightbackground="#ffffff") |
| 151 | + self.Frame1.configure(highlightcolor="black") |
| 152 | + self.Frame1.configure(width=925) |
| 153 | + |
| 154 | + #--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 155 | + |
| 156 | + self.Label1 = Label(self.Frame1) # Set Label for Room number |
| 157 | + self.Label1.place(relx=0.14, rely=0.12, height=46, width=442) |
| 158 | + self.Label1.configure(activebackground="#ffffff") |
| 159 | + self.Label1.configure(activeforeground="black") |
| 160 | + self.Label1.configure(background="#ffffff") |
| 161 | + self.Label1.configure(disabledforeground="#bfbfbf") |
| 162 | + self.Label1.configure(font=font11) |
| 163 | + self.Label1.configure(foreground="#000000") |
| 164 | + self.Label1.configure(highlightbackground="#ffffff") |
| 165 | + self.Label1.configure(highlightcolor="black") |
| 166 | + self.Label1.configure(text='''ENTER THE ROOM NO. :''') |
| 167 | + |
| 168 | + #--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 169 | + |
| 170 | + self.Entry1 = Entry(self.Frame1) # Get data |
| 171 | + self.data=StringVar() |
| 172 | + self.Entry1.place(relx=0.67, rely=0.12,height=44, relwidth=0.07) |
| 173 | + self.Entry1.configure(background="white") |
| 174 | + self.Entry1.configure(disabledforeground="#bfbfbf") |
| 175 | + self.Entry1.configure(font=font10) |
| 176 | + self.Entry1.configure(foreground="#000000") |
| 177 | + self.Entry1.configure(highlightbackground="#ffffff") |
| 178 | + self.Entry1.configure(highlightcolor="black") |
| 179 | + self.Entry1.configure(insertbackground="black") |
| 180 | + self.Entry1.configure(selectbackground="#e6e6e6") |
| 181 | + self.Entry1.configure(selectforeground="black") |
| 182 | + self.Entry1.configure(textvariable=self.data) |
| 183 | + |
| 184 | + #--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 185 | + |
| 186 | + self.Text1 = Text(self.Frame1) |
| 187 | + self.Text1.place(relx=0.05, rely=0.54, relheight=0.4, relwidth=0.89) |
| 188 | + self.Text1.configure(background="white") |
| 189 | + self.Text1.configure(font=font9) |
| 190 | + self.Text1.configure(foreground="black") |
| 191 | + self.Text1.configure(highlightbackground="#ffffff") |
| 192 | + self.Text1.configure(highlightcolor="black") |
| 193 | + self.Text1.configure(insertbackground="black") |
| 194 | + self.Text1.configure(selectbackground="#e6e6e6") |
| 195 | + self.Text1.configure(selectforeground="black") |
| 196 | + self.Text1.configure(width=824) |
| 197 | + self.Text1.configure(wrap=WORD) |
| 198 | + |
| 199 | + #--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 200 | + |
| 201 | + self.Button1 = Button(self.Frame1) # Button for checkout option |
| 202 | + self.Button1.place(relx=0.34, rely=0.28, height=93, width=286) |
| 203 | + self.Button1.configure(activebackground="#ffffff") |
| 204 | + self.Button1.configure(activeforeground="#000000") |
| 205 | + self.Button1.configure(background="#ffffff") |
| 206 | + self.Button1.configure(disabledforeground="#bfbfbf") |
| 207 | + self.Button1.configure(font=font12) |
| 208 | + self.Button1.configure(foreground="#000000") |
| 209 | + self.Button1.configure(highlightbackground="#ffffff") |
| 210 | + self.Button1.configure(highlightcolor="black") |
| 211 | + self.Button1.configure(pady="0") |
| 212 | + self.Button1.configure(text='''CHECK OUT''') |
| 213 | + self.Button1.configure(command=check_room) |
| 214 | + root.mainloop() |
| 215 | + |
| 216 | +#------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 217 | + |
| 218 | +if __name__ == '__main__': |
| 219 | + out=New_Toplevel() |
0 commit comments