|
|
|
|
import tkinter as tk
|
|
|
|
|
from tkinter import messagebox
|
|
|
|
|
|
|
|
|
|
class FootSpaManagementSystem:
|
|
|
|
|
def __init__(self,order_info=""):
|
|
|
|
|
self.root = tk.Tk() # 创建主窗口
|
|
|
|
|
self.root.title("足浴店管理系统")
|
|
|
|
|
self.root.geometry("500x300")
|
|
|
|
|
self.user_data_file = "user_data.txt" # 用户数据文件路径
|
|
|
|
|
self.order_data_file = "order_data.txt" # 订单数据文件路径
|
|
|
|
|
self.order_num = 1000 # 初始化订单号
|
|
|
|
|
self.order_info = order_info
|
|
|
|
|
self.create_main_window() # 创建主界面
|
|
|
|
|
|
|
|
|
|
#初始界面
|
|
|
|
|
def create_main_window(self):
|
|
|
|
|
self.main_frame = tk.Frame(self.root)
|
|
|
|
|
self.main_frame.pack()
|
|
|
|
|
self.welcome_label = tk.Label(self.main_frame, text="欢迎使用足浴店管理系统")
|
|
|
|
|
self.welcome_label.pack()
|
|
|
|
|
self.register_button_main = tk.Button(self.main_frame, text="用户注册", command=self.switch_to_register)
|
|
|
|
|
self.register_button_main.pack()
|
|
|
|
|
self.login_button_main = tk.Button(self.main_frame, text="用户登录", command=self.switch_to_login)
|
|
|
|
|
self.login_button_main.pack()
|
|
|
|
|
self.admin_login_button = tk.Button(self.main_frame, text="管理员登录", command=self.create_admin_login_view)
|
|
|
|
|
self.admin_login_button.pack()
|
|
|
|
|
|
|
|
|
|
#注册界面返回初始界面
|
|
|
|
|
def surer1(self):
|
|
|
|
|
self.frame_register.pack_forget()
|
|
|
|
|
self.main_frame.pack()
|
|
|
|
|
|
|
|
|
|
#选择订单界面返回用户界面
|
|
|
|
|
def surer2(self):
|
|
|
|
|
self.frame_order.pack_forget()
|
|
|
|
|
self.user_frame.pack()
|
|
|
|
|
|
|
|
|
|
#选择技师界面返回用户界面
|
|
|
|
|
def surer3(self):
|
|
|
|
|
self.frame_technician.pack_forget()
|
|
|
|
|
self.user_frame.pack()
|
|
|
|
|
|
|
|
|
|
#删除订单界面返回用户界面
|
|
|
|
|
def surer4(self):
|
|
|
|
|
self.delete_frame.pack_forget()
|
|
|
|
|
self.user_frame.pack()
|
|
|
|
|
|
|
|
|
|
#酒水订单界面返回用户界面
|
|
|
|
|
def surer5(self):
|
|
|
|
|
self.beverage_frame.pack_forget()
|
|
|
|
|
self.user_frame.pack()
|
|
|
|
|
|
|
|
|
|
#管理员登录界面返回初始界面
|
|
|
|
|
def surer6(self):
|
|
|
|
|
self.admin_login_window.pack_forget()
|
|
|
|
|
self.main_frame.pack()
|
|
|
|
|
|
|
|
|
|
#用户登录界面返回初始界面
|
|
|
|
|
def surer7(self):
|
|
|
|
|
self.frame_login.pack_forget()
|
|
|
|
|
self.main_frame.pack()
|
|
|
|
|
|
|
|
|
|
#管理员登录函数
|
|
|
|
|
def admin_login(self):
|
|
|
|
|
admin_username = "zg"
|
|
|
|
|
admin_password = "zg123"
|
|
|
|
|
username = self.username_entry.get()
|
|
|
|
|
password = self.password_entry.get()
|
|
|
|
|
if username == admin_username and password == admin_password:
|
|
|
|
|
messagebox.showinfo("管理员登录", "登录成功!")
|
|
|
|
|
self.show_admin_options()
|
|
|
|
|
else:
|
|
|
|
|
messagebox.showerror("管理员登录", "用户名或密码错误")
|
|
|
|
|
|
|
|
|
|
#管理员登录界面
|
|
|
|
|
def create_admin_login_view(self):
|
|
|
|
|
self.main_frame.pack_forget()
|
|
|
|
|
self.admin_login_window = tk.Frame(self.root)
|
|
|
|
|
self.admin_login_window.pack()
|
|
|
|
|
self.username_label = tk.Label(self.admin_login_window, text="用户名")
|
|
|
|
|
self.username_label.pack()
|
|
|
|
|
self.username_entry = tk.Entry(self.admin_login_window)
|
|
|
|
|
self.username_entry.pack()
|
|
|
|
|
self.password_label = tk.Label(self.admin_login_window, text="密码")
|
|
|
|
|
self.password_label.pack()
|
|
|
|
|
self.password_entry = tk.Entry(self.admin_login_window, show="*")
|
|
|
|
|
self.password_entry.pack()
|
|
|
|
|
self.login_button = tk.Button(self.admin_login_window, text="登录", command=self.admin_login)
|
|
|
|
|
self.login_button.pack()
|
|
|
|
|
self.back_button = tk.Button(self.admin_login_window, text="返回主界面", command=self.surer6)
|
|
|
|
|
self.back_button.pack()
|
|
|
|
|
|
|
|
|
|
#查看用户函数
|
|
|
|
|
def show_user_info(self):
|
|
|
|
|
user_info_window = tk.Toplevel(self.root)
|
|
|
|
|
user_info_window.title("用户信息")
|
|
|
|
|
with open(self.user_data_file, "r") as file:
|
|
|
|
|
user_data = file.readlines()
|
|
|
|
|
if user_data:
|
|
|
|
|
for user_info in user_data:
|
|
|
|
|
username = user_info.strip()
|
|
|
|
|
label = tk.Label(user_info_window, text=username)
|
|
|
|
|
label.pack()
|
|
|
|
|
else:
|
|
|
|
|
label = tk.Label(user_info_window, text="暂无用户信息")
|
|
|
|
|
label.pack()
|
|
|
|
|
|
|
|
|
|
#查看技师函数
|
|
|
|
|
def show_technician_info(self):
|
|
|
|
|
technician_info_window = tk.Toplevel(self.root)
|
|
|
|
|
technician_info_window.title("Technician Information")
|
|
|
|
|
technician_data_file = "technician_data.txt" # 技师数据文件的路径
|
|
|
|
|
try:
|
|
|
|
|
with open(technician_data_file, "r", encoding="utf-8") as file:
|
|
|
|
|
technician_data = file.readlines()
|
|
|
|
|
if technician_data:
|
|
|
|
|
for tech_info in technician_data:
|
|
|
|
|
technician_name, technician_specialty = tech_info.strip().split(",") # 假设数据以逗号分隔
|
|
|
|
|
label = tk.Label(technician_info_window,
|
|
|
|
|
text=f"姓名:{technician_name},电话:{technician_specialty}")
|
|
|
|
|
label.pack()
|
|
|
|
|
else:
|
|
|
|
|
label = tk.Label(technician_info_window, text="暂无技师信息")
|
|
|
|
|
label.pack()
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
|
label = tk.Label(technician_info_window, text="找不到技师数据文件")
|
|
|
|
|
label.pack()
|
|
|
|
|
|
|
|
|
|
#管理员登录后的管理员界面
|
|
|
|
|
def show_admin_options(self):
|
|
|
|
|
self.admin_login_window.pack_forget()
|
|
|
|
|
self.admin_options_window = tk.Frame(self.root)
|
|
|
|
|
self.admin_options_window.pack()
|
|
|
|
|
self.user_info_button = tk.Button(self.admin_options_window, text="查看用户信息", command=self.show_user_info)
|
|
|
|
|
self.user_info_button.pack()
|
|
|
|
|
self.technician_info_button = tk.Button(self.admin_options_window, text="查看技师信息",command=self.show_technician_info)
|
|
|
|
|
self.technician_info_button.pack()
|
|
|
|
|
|
|
|
|
|
#用户注册函数
|
|
|
|
|
def register_user(self):
|
|
|
|
|
username = self.username_entry.get()
|
|
|
|
|
password = self.password_entry.get()
|
|
|
|
|
if username and password:
|
|
|
|
|
with open(self.user_data_file, "a") as file:
|
|
|
|
|
file.write(f"{username},{password}\n")
|
|
|
|
|
messagebox.showinfo("注册成功", "用户注册成功!") # 显示注册成功消息
|
|
|
|
|
else:
|
|
|
|
|
messagebox.showerror("注册失败", "请输入用户名和密码。")
|
|
|
|
|
|
|
|
|
|
#用户登录函数
|
|
|
|
|
def login_user(self):
|
|
|
|
|
username = self.username_entry_login.get()
|
|
|
|
|
password = self.password_entry_login.get()
|
|
|
|
|
with open(self.user_data_file, "r") as file:
|
|
|
|
|
user_data = file.readlines()
|
|
|
|
|
if user_data:
|
|
|
|
|
for user in user_data:
|
|
|
|
|
stored_data = user.strip().split(",")
|
|
|
|
|
if len(stored_data) == 2:
|
|
|
|
|
stored_username, stored_password = stored_data
|
|
|
|
|
if username == stored_username and password == stored_password:
|
|
|
|
|
messagebox.showinfo("登录成功", f"欢迎回来,{username}!") # 显示登录成功消息
|
|
|
|
|
self.show_user_interface() # 在成功登录后显示用户界面
|
|
|
|
|
return
|
|
|
|
|
messagebox.showerror("登录失败", "无效的用户名或密码。") # 显示登录失败消息
|
|
|
|
|
else:
|
|
|
|
|
messagebox.showerror("登录失败", "没有用户数据。") # 显示找不到用户数据的消息
|
|
|
|
|
|
|
|
|
|
#注册界面
|
|
|
|
|
def switch_to_register(self):
|
|
|
|
|
self.main_frame.pack_forget()
|
|
|
|
|
self.frame_register = tk.Frame(self.root)
|
|
|
|
|
self.frame_register.pack()
|
|
|
|
|
self.username_label = tk.Label(self.frame_register, text="用户名:")
|
|
|
|
|
self.username_label.pack()
|
|
|
|
|
self.username_entry = tk.Entry(self.frame_register)
|
|
|
|
|
self.username_entry.pack()
|
|
|
|
|
self.password_label = tk.Label(self.frame_register, text="密码:")
|
|
|
|
|
self.password_label.pack()
|
|
|
|
|
self.password_entry = tk.Entry(self.frame_register, show="*")
|
|
|
|
|
self.password_entry.pack()
|
|
|
|
|
self.register_button = tk.Button(self.frame_register, text="注册", command=self.register_user)
|
|
|
|
|
self.register_button.pack()
|
|
|
|
|
self.back_button = tk.Button(self.frame_register, text="返回主界面", command=self.surer1)
|
|
|
|
|
self.back_button.pack()
|
|
|
|
|
|
|
|
|
|
#用户登录界面
|
|
|
|
|
def switch_to_login(self):
|
|
|
|
|
self.main_frame.pack_forget()
|
|
|
|
|
self.frame_login = tk.Frame(self.root)
|
|
|
|
|
self.frame_login.pack()
|
|
|
|
|
self.username_label_login = tk.Label(self.frame_login, text="用户名:")
|
|
|
|
|
self.username_label_login.pack()
|
|
|
|
|
self.username_entry_login = tk.Entry(self.frame_login)
|
|
|
|
|
self.username_entry_login.pack()
|
|
|
|
|
self.password_label_login = tk.Label(self.frame_login, text="密码:")
|
|
|
|
|
self.password_label_login.pack()
|
|
|
|
|
self.password_entry_login = tk.Entry(self.frame_login, show="*")
|
|
|
|
|
self.password_entry_login.pack()
|
|
|
|
|
self.login_button = tk.Button(self.frame_login, text="登录", command=self.login_user)
|
|
|
|
|
self.login_button.pack()
|
|
|
|
|
self.back_button = tk.Button(self.frame_login, text="返回主界面", command=self.surer7)
|
|
|
|
|
self.back_button.pack()
|
|
|
|
|
|
|
|
|
|
#用户登录后的用户界面
|
|
|
|
|
def show_user_interface(self):
|
|
|
|
|
self.main_frame.pack_forget() # 移除主界面
|
|
|
|
|
if hasattr(self, "frame_register"):
|
|
|
|
|
self.frame_register.pack_forget() # 移除注册界面(如果存在)
|
|
|
|
|
if hasattr(self, "frame_login"):
|
|
|
|
|
self.frame_login.pack_forget() # 移除登录界面(如果存在)
|
|
|
|
|
# 创建用户界面框架
|
|
|
|
|
self.user_frame = tk.Frame(self.root)
|
|
|
|
|
self.user_frame.pack()
|
|
|
|
|
self.order_button = tk.Button(self.user_frame, text="选择订单", command=self.switch_to_order)
|
|
|
|
|
self.order_button.pack()
|
|
|
|
|
self.select_technician = tk.Button(self.user_frame, text="选择技师", command=self.show_select_technician_screen)
|
|
|
|
|
self.select_technician.pack()
|
|
|
|
|
self.view_order_button = tk.Button(self.user_frame, text="查看订单", command=self.view_order)
|
|
|
|
|
self.view_order_button.pack()
|
|
|
|
|
self.delete_order_button = tk.Button(self.user_frame, text="删除订单", command=self.delete_order)
|
|
|
|
|
self.delete_order_button.pack()
|
|
|
|
|
self.beverage_button = tk.Button(self.user_frame, text="订购酒水", command=self.switch_to_beverage_order)
|
|
|
|
|
self.beverage_button.pack()
|
|
|
|
|
|
|
|
|
|
#查看订单
|
|
|
|
|
def view_order(self):
|
|
|
|
|
with open(self.order_data_file, "r") as file:
|
|
|
|
|
orders = file.readlines()
|
|
|
|
|
if orders:
|
|
|
|
|
order_info = "\n".join(orders)
|
|
|
|
|
messagebox.showinfo("查看订单", f"您的订单信息:\n{order_info}")
|
|
|
|
|
else:
|
|
|
|
|
messagebox.showinfo("查看订单", "暂无订单信息。")
|
|
|
|
|
|
|
|
|
|
#删除订单界面
|
|
|
|
|
def delete_order(self):
|
|
|
|
|
self.user_frame.pack_forget() # 移除用户界面
|
|
|
|
|
self.delete_frame = tk.Frame(self.root)
|
|
|
|
|
self.delete_frame.pack()
|
|
|
|
|
self.order_number_label = tk.Label(self.delete_frame, text="请输入订单号:")
|
|
|
|
|
self.order_number_label.pack()
|
|
|
|
|
self.order_number_entry = tk.Entry(self.delete_frame)
|
|
|
|
|
self.order_number_entry.pack()
|
|
|
|
|
self.confirm_delete_button = tk.Button(self.delete_frame, text="确认删除", command=self.confirm_delete)
|
|
|
|
|
self.confirm_delete_button.pack()
|
|
|
|
|
self.back_button_order = tk.Button(self.delete_frame, text="返回用户界面", command=self.surer4)
|
|
|
|
|
self.back_button_order.pack()
|
|
|
|
|
|
|
|
|
|
def confirm_delete(self):
|
|
|
|
|
order_number_to_delete = self.order_number_entry.get()
|
|
|
|
|
with open(self.order_data_file, "r") as file:
|
|
|
|
|
orders = file.readlines()
|
|
|
|
|
if orders:
|
|
|
|
|
with open(self.order_data_file, "w") as file:
|
|
|
|
|
for order in orders:
|
|
|
|
|
if order_number_to_delete not in order:
|
|
|
|
|
file.write(order)
|
|
|
|
|
messagebox.showinfo("删除订单", f"订单号{order_number_to_delete}已删除。")
|
|
|
|
|
else:
|
|
|
|
|
messagebox.showinfo("删除订单", "暂无订单信息。")
|
|
|
|
|
|
|
|
|
|
#选择订单界面
|
|
|
|
|
def switch_to_order(self):
|
|
|
|
|
self.user_frame.pack_forget()
|
|
|
|
|
self.frame_order = tk.Frame(self.root)
|
|
|
|
|
self.frame_order.pack()
|
|
|
|
|
self.order_label = tk.Label(self.frame_order, text="请选择服务:")
|
|
|
|
|
self.order_label.pack()
|
|
|
|
|
self.services = {
|
|
|
|
|
"足浴": tk.IntVar(),
|
|
|
|
|
"按摩": tk.IntVar(),
|
|
|
|
|
"SPA": tk.IntVar(),
|
|
|
|
|
"采耳": tk.IntVar()
|
|
|
|
|
}
|
|
|
|
|
self.foot_spa_checkbox = tk.Checkbutton(self.frame_order, text="足浴", variable=self.services["足浴"])
|
|
|
|
|
self.foot_spa_checkbox.pack()
|
|
|
|
|
self.massage_checkbox = tk.Checkbutton(self.frame_order, text="按摩", variable=self.services["按摩"])
|
|
|
|
|
self.massage_checkbox.pack()
|
|
|
|
|
self.spa_checkbox = tk.Checkbutton(self.frame_order, text="SPA", variable=self.services["SPA"])
|
|
|
|
|
self.spa_checkbox.pack()
|
|
|
|
|
self.ear_cleaning_checkbox = tk.Checkbutton(self.frame_order, text="采耳",variable=self.services["采耳"])
|
|
|
|
|
self.ear_cleaning_checkbox.pack()
|
|
|
|
|
self.confirm_order_button = tk.Button(self.frame_order, text="确认订单", command=self.confirm_order)
|
|
|
|
|
self.confirm_order_button.pack()
|
|
|
|
|
self.back_button_order = tk.Button(self.frame_order, text="返回用户界面", command=self.surer2)
|
|
|
|
|
self.back_button_order.pack()
|
|
|
|
|
|
|
|
|
|
def confirm_order(self):
|
|
|
|
|
selected_services = [service for service, selected in self.services.items() if selected.get() == 1]
|
|
|
|
|
if selected_services:
|
|
|
|
|
order_number = self.generate_order_number() # 生成订单号
|
|
|
|
|
messagebox.showinfo("下单成功", f"您选择了:{', '.join(selected_services)}\n 订单号:{order_number}")
|
|
|
|
|
with open(self.order_data_file, "a") as file:
|
|
|
|
|
file.write(f"{order_number}, {', '.join(selected_services)}{self.order_info}\n")
|
|
|
|
|
else:
|
|
|
|
|
messagebox.showerror("下单失败", "请选择至少一项服务。")
|
|
|
|
|
|
|
|
|
|
#生成订单号函数
|
|
|
|
|
def generate_order_number(self):
|
|
|
|
|
self.order_num += 1
|
|
|
|
|
return f"{self.order_num}" # 以XXXX格式生成订单号
|
|
|
|
|
|
|
|
|
|
# 选择技师界面
|
|
|
|
|
def show_select_technician_screen(self):
|
|
|
|
|
self.user_frame.pack_forget() # 移除用户界面
|
|
|
|
|
# 创建选择技师的界面
|
|
|
|
|
self.frame_technician = tk.Frame(self.root)
|
|
|
|
|
self.frame_technician.pack()
|
|
|
|
|
self.technician_label = tk.Label(self.frame_technician, text="请选择技师:")
|
|
|
|
|
self.technician_label.pack()
|
|
|
|
|
self.technicians = {
|
|
|
|
|
"6号技师": tk.IntVar(),
|
|
|
|
|
"8号技师": tk.IntVar(),
|
|
|
|
|
"66号技师": tk.IntVar(),
|
|
|
|
|
"88号技师": tk.IntVar(),
|
|
|
|
|
}
|
|
|
|
|
self.john_doe_checkbox = tk.Checkbutton(self.frame_technician, text="6号技师",variable=self.technicians["6号技师"])
|
|
|
|
|
self.john_doe_checkbox.pack()
|
|
|
|
|
self.jane_smith_checkbox = tk.Checkbutton(self.frame_technician, text="8号技师",variable=self.technicians["8号技师"])
|
|
|
|
|
self.jane_smith_checkbox.pack()
|
|
|
|
|
self.mike_wilson_checkbox = tk.Checkbutton(self.frame_technician, text="66号技师",variable=self.technicians["66号技师"])
|
|
|
|
|
self.mike_wilson_checkbox.pack()
|
|
|
|
|
self.mike_wilson_checkbox = tk.Checkbutton(self.frame_technician, text="88号技师",variable=self.technicians["88号技师"])
|
|
|
|
|
self.mike_wilson_checkbox.pack()
|
|
|
|
|
self.confirm_technician_button = tk.Button(self.frame_technician, text="确认技师",command=self.confirm_technician)
|
|
|
|
|
self.confirm_technician_button.pack()
|
|
|
|
|
self.back_button_order = tk.Button(self.frame_technician, text="返回用户界面", command=self.surer3)
|
|
|
|
|
self.back_button_order.pack()
|
|
|
|
|
|
|
|
|
|
#选择技师函数
|
|
|
|
|
def confirm_technician(self):
|
|
|
|
|
selected_services = [service for service, selected in self.technicians.items() if selected.get() == 1]
|
|
|
|
|
if selected_services:
|
|
|
|
|
selected_technicians = [technician for technician, selected in self.technicians.items() if selected.get() == 1]
|
|
|
|
|
selected_technicians_str = ', '.join(selected_technicians)
|
|
|
|
|
messagebox.showinfo("下单成功",
|
|
|
|
|
f"您所选择的技师: {selected_technicians_str}")
|
|
|
|
|
with open(self.order_data_file, "a") as file:
|
|
|
|
|
file.write(f" {selected_technicians_str}{self.order_info}\n")
|
|
|
|
|
|
|
|
|
|
#酒水订单界面
|
|
|
|
|
def switch_to_beverage_order(self):
|
|
|
|
|
self.user_frame.pack_forget() # 隐藏主用户界面
|
|
|
|
|
self.beverage_frame = tk.Frame(self.root)
|
|
|
|
|
self.beverage_frame.pack()
|
|
|
|
|
self.beverage_type_label = tk.Label(self.beverage_frame, text="选择酒水类型:")
|
|
|
|
|
self.beverage_type_label.pack()
|
|
|
|
|
self.beverage_type_var = tk.StringVar()
|
|
|
|
|
self.beverage_type_var.set("啤酒") # 默认选择啤酒
|
|
|
|
|
self.beverage_type_options = ["啤酒", "饮料", "茶", "矿泉水"]
|
|
|
|
|
self.beverage_type_menu = tk.OptionMenu(self.beverage_frame, self.beverage_type_var,*self.beverage_type_options)
|
|
|
|
|
self.beverage_type_menu.pack()
|
|
|
|
|
self.confirm_beverage_order_button = tk.Button(self.beverage_frame, text="确认酒水订单",command=self.confirm_beverage_order)
|
|
|
|
|
self.confirm_beverage_order_button.pack()
|
|
|
|
|
self.back_button_beverage = tk.Button(self.beverage_frame, text="返回用户界面", command=self.surer5)
|
|
|
|
|
self.back_button_beverage.pack()
|
|
|
|
|
|
|
|
|
|
#酒水订单函数
|
|
|
|
|
def confirm_beverage_order(self):
|
|
|
|
|
# 获取用户选择的酒水并处理订单过程
|
|
|
|
|
selected_beverage_type = self.beverage_type_var.get()
|
|
|
|
|
# 显示订单确认信息
|
|
|
|
|
messagebox.showinfo("酒水下单成功", "您的酒水订单已确认。")
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
self.root.mainloop() # 启动主循环
|
|
|
|
|
|
|
|
|
|
# 实例化足浴店管理系统
|
|
|
|
|
foot_spa_system = FootSpaManagementSystem()
|
|
|
|
|
foot_spa_system.run()
|