Sunteți pe pagina 1din 21

import os

import platform

import mysql.connector

import pandas as pd

mydb=mysql.connector.connect(host="localhost", user="root",passwd="admin",database="Abhishek")

mycursor=mydb.cursor()

print("sucessfully connected")

def HotelInsert():

l=[]

Customer_Id=int(input("Enter the customer id:"))

l.append(Customer_Id)

Customer_Name=input("Enter the Customer name:")

l.append(Customer_Name)

Address=input("Enter the Address:")

l.append(Address)

Mobile_no=int(input("Enter the Mobile no:"))

l.append(Mobile_no)

Room_no=int(input("Enter the Room no:"))

l.append(Room_no)

Price=int(input("Enter the Price"))

l.append(Price)
TS=(l)

sql="insert into Hotelmanagement(Customer_Id, Customer_Name, Address, Mobile_no, Room_no, Price)


values (%s,%s,%s,%s,%s,%s)"

mycursor.execute(sql,TS)

mydb.commit()

def HotelView():

print("select the search criteria:")

print("1. Customer id")

print("2. Customer name")

print("3. Address")

print("4. Mobile no")

print("5. Room no")

print("6. Price")

print("7. All")

ch=int(input("enter the choice:"))

if ch==1:

s=int(input(" Customer id:"))

rl=(s,)

sql="select * from Hotelmanagement where Customer_Id=%s"

mycursor.execute(sql,rl)

elif ch==2:

s=input("Customer_Name")
rl=(s,)

sql="select * from Hotelmanagement where Customer_Name=%s"

mycursor.execute(sql,rl)

elif ch==3:

s=input("Address")

rl=(s,)

sql="select * from Hotelmanagement where Address=%s"

mycursor.execute(sql,rl)

elif ch==4:

s=int(input("Mobile_no"))

rl=(s,)

sql="select * from Hotelmanagement where Mobile_no=%s"

mycursor.execute(sql,rl)

elif ch==5:

s=int(input("Room_no"))

rl=(s,)

sql="select * from Hotelmanagement where Room_no=%s"

mycursor.execute(sql,rl)

elif ch==6:

s=int(input("Price"))

rl=(s,)

sql="select * from Hotelmanagement where Price=%s"


elif ch==7:

sql="select * from Hotelmanagement"

mycursor.execute(sql)

res=mycursor.fetchall()

print("the staff details are as follow:")

print("(Customer_Id, Customer_Name, Address, Mobile_no, Room_no, Price)")

for x in res:

print(x)

def OtrInfoInsert():

L=[]

Customer_Id=int(input("Enter the Customer_Id : "))

L.append(Customer_Id)

gender=input("Enter the gender : ")

L.append(gender)

nationality=input("Enter the nationality:")

L.append(nationality)

rcpt_no=int(input("Enter the rcpt no:"))

L.append(rcpt_no)

Price=(L)

sql="insert into otherinformation (Customer_Id, gender, nationality, rcpt_no) values (%s,%s,%s,%s)"

mycursor.execute(sql,Price)
mydb.commit()

def OtrInfoView():

print("Please enter the details to view the Information details :")

Customer_Id=int(input("Enter the Id of the Customer whose information is to be viewed : "))

sql="Select Hotelmanagement.Customer_Id, Hotelmanagement.Customer_Name,


Hotelmanagement.Address, sum(otherinformation.Customer_Id), otherinformation.rcpt_no from
Hotelmanagement INNER JOIN otherinformation ON
Hotelmanagement.Customer_Id=otherinformation.Customer_Id and otherinformation.Customer_Id = %s"

rl=(Customer_Id,)

mycursor.execute(sql,rl)

res=mycursor.fetchall()

for x in res:

print(x)

def removeHotelInfo():

Customer_Id=int(input("Enter the Id of the Customer to be deleted : "))

rl=(Customer_Id,)

sql="Delete from otherinformation where Customer_Id=%s"

mycursor.execute(sql,rl)

sql="Delete from Hotelmanagement where Customer_Id=%s"


mycursor.execute(sql,rl)

mydb.commit()

def MenuSet(): #Function For The Student Management System

print("Enter 1 : To Add Info")

print("Enter 2 : To View Info ")

print("Enter 3 : To Add About Customer ")

print("Enter 4 : To Remove Info")

print("Enter 5 : To View About Customer ")

try: #Using Exceptions For Validation

userInput = int(input("Please Select An Above Option: ")) #Will Take Input From User

except ValueError:

exit("\nHy! That's Not A Number") #Error Message

else:

print("\n") #Print New Line

if(userInput == 1):

HotelInsert()

elif (userInput==2):

HotelView()

elif (userInput==3):

OtrInfoInsert()
elif (userInput==4):

removeHotelInfo()

elif (userInput==5):

OtrInfoView()

else:

print("Enter correct choice. . . ")

MenuSet()

def runAgain():

runAgn = input("\nwant To Run Again Y/n: ")

while(runAgn.lower() == 'y'):

if(platform.system() == "Windows"):

print(os.system('cls'))

else:

print(os.system('clear'))

MenuSet()

runAgn = input("\nwant To Run Again Y/n: ")

runAgain()

S-ar putea să vă placă și