From 146bf31494227f7f69f72fefda82d56bd2b706c1 Mon Sep 17 00:00:00 2001 From: 123456789zs <2660653849@qq.com> Date: Sat, 1 Jun 2024 22:29:36 +0800 Subject: [PATCH] commit_0601 --- pythonProject/technician_data.txt | 8 +-- pythonProject/user_data.txt | 1 + pythonProject/zs1.py | 109 ++++++++++++------------------ 3 files changed, 50 insertions(+), 68 deletions(-) diff --git a/pythonProject/technician_data.txt b/pythonProject/technician_data.txt index 823cf07..c8b0864 100644 --- a/pythonProject/technician_data.txt +++ b/pythonProject/technician_data.txt @@ -1,4 +1,4 @@ -6号技师 -8号技师 -66号技师 -88号技师 \ No newline at end of file +6号技师,13975114012 +8号技师,15206881394 +66号技师,14595462980 +88号技师,13871093842 \ No newline at end of file diff --git a/pythonProject/user_data.txt b/pythonProject/user_data.txt index 1b5d237..a4352ff 100644 --- a/pythonProject/user_data.txt +++ b/pythonProject/user_data.txt @@ -1,2 +1,3 @@ zs,zs + diff --git a/pythonProject/zs1.py b/pythonProject/zs1.py index 33d2e81..4006105 100644 --- a/pythonProject/zs1.py +++ b/pythonProject/zs1.py @@ -17,16 +17,12 @@ class FootSpaManagementSystem: 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() @@ -34,44 +30,36 @@ class FootSpaManagementSystem: 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() + #查看用户函数 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() @@ -81,19 +69,19 @@ class FootSpaManagementSystem: 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") as file: + 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}") + text=f"姓名:{technician_name},电话:{technician_specialty}") label.pack() else: label = tk.Label(technician_info_window, text="暂无技师信息") @@ -102,15 +90,13 @@ class FootSpaManagementSystem: 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() @@ -118,7 +104,6 @@ class FootSpaManagementSystem: 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") @@ -130,10 +115,8 @@ class FootSpaManagementSystem: 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(",") @@ -147,6 +130,7 @@ class FootSpaManagementSystem: else: messagebox.showerror("登录失败", "没有用户数据。") # 显示找不到用户数据的消息 + #注册界面返回初始界面 def surer1(self): self.frame_register.pack_forget() self.main_frame.pack() @@ -155,6 +139,7 @@ class FootSpaManagementSystem: self.frame_register.pack_forget() self.main_frame.pack() + #选择订单界面返回用户界面 def surer2(self): self.frame_order.pack_forget() self.user_frame.pack() @@ -163,6 +148,7 @@ class FootSpaManagementSystem: self.frame_order.pack_forget() self.user_frame.pack() + #选择技师界面返回用户界面 def surer3(self): self.frame_technician.pack_forget() self.user_frame.pack() @@ -171,48 +157,47 @@ class FootSpaManagementSystem: 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 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.root, 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() @@ -226,42 +211,36 @@ class FootSpaManagementSystem: # 创建用户界面框架 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.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() @@ -269,7 +248,6 @@ class FootSpaManagementSystem: 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: @@ -284,32 +262,24 @@ class FootSpaManagementSystem: 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() @@ -318,15 +288,14 @@ class FootSpaManagementSystem: if selected_services: order_number = self.generate_order_number() # 生成订单号 messagebox.showinfo("下单成功", f"您选择了:{', '.join(selected_services)}\n 订单号:{order_number}") - # 显示选择技师的界面 self.show_select_technician_screen() - 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格式生成订单号 @@ -337,50 +306,62 @@ class FootSpaManagementSystem: # 创建选择技师的界面 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.services.items() if selected.get() == 1] - if selected_services: - selected_technicians = [technician for technician, selected in self.technicians.items() if - selected.get() == 1] + selected_technicians = [technician for technician, selected in self.technicians.items() if selected.get() == 1] selected_services_str = ', '.join(selected_services) selected_technicians_str = ', '.join(selected_technicians) - messagebox.showinfo("下单成功", f"您选择了:{selected_services_str}\n所选择的技师: {selected_technicians_str}") - with open(self.order_data_file, "a") as file: file.write(f"{selected_services_str} - {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() # 启动主循环