|
|
|
@ -73,14 +73,11 @@ def on_inquire_click():
|
|
|
|
|
# 假设query_car_info返回车辆信息的字典,展示相关信息
|
|
|
|
|
message = (
|
|
|
|
|
f"车牌号: {car_info['license_plate']}\n"
|
|
|
|
|
f"车型: {car_info['model']}\n"
|
|
|
|
|
f"颜色: {car_info['color']}\n"
|
|
|
|
|
|
|
|
|
|
f"停放时间: {car_info['parked_time'].strftime('%Y-%m-%d %H:%M:%S')}\n"
|
|
|
|
|
f"取车时间: {car_info['picked_up_time'].strftime('%Y-%m-%d %H:%M:%S') if car_info['picked_up_time'] else '未取车'}"
|
|
|
|
|
)
|
|
|
|
|
messagebox.showinfo("车辆信息", message)
|
|
|
|
|
else:
|
|
|
|
|
messagebox.showerror("查询结果", "未找到该车牌号的车辆信息。")
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
messagebox.showerror("查询错误", f"查询过程中发生错误: {e}")
|
|
|
|
|
else:
|
|
|
|
@ -91,40 +88,17 @@ def on_display_info_click():
|
|
|
|
|
# 调用ParkManage类中的方法来获取所有车辆信息
|
|
|
|
|
car_info= park.display_all_cars_info()
|
|
|
|
|
|
|
|
|
|
if cars_info:
|
|
|
|
|
if car_info:
|
|
|
|
|
# 假设cars_info是一个包含车辆信息的列表,每个元素是车辆的字典表示
|
|
|
|
|
info_text = "\n".join(
|
|
|
|
|
[f"车牌号: {car['license_plate']}, 停放时间: {car['parked_time'].strftime('%Y-%m-%d %H:%M:%S')}"
|
|
|
|
|
f"{', 取车时间: ' + car['picked_up_time'].strftime('%Y-%m-%d %H:%M:%S') if car['picked_up_time'] else ''}"
|
|
|
|
|
for car in cars_info])
|
|
|
|
|
messagebox.showinfo("车辆信息", info_text)
|
|
|
|
|
else:
|
|
|
|
|
messagebox.showinfo("信息提示", "当前没有车辆信息可显示。")
|
|
|
|
|
for car in car_info])
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
messagebox.showerror("错误", f"显示车辆信息时发生错误: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_edit_info_click():
|
|
|
|
|
|
|
|
|
|
# 从界面获取车牌号、车型和颜色
|
|
|
|
|
license_plate = license_plate_entry.get().strip()
|
|
|
|
|
new_model = model_entry.get().strip()
|
|
|
|
|
new_color = color_entry.get().strip()
|
|
|
|
|
|
|
|
|
|
if not license_plate:
|
|
|
|
|
messagebox.showerror("错误", "请输入车牌号进行编辑!")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
# 假设ParkManage类有一个edit_car_info方法用于更新车辆信息
|
|
|
|
|
success = park_manage_instance.edit_car_info(license_plate, new_model=new_model, new_color=new_color)
|
|
|
|
|
|
|
|
|
|
if success:
|
|
|
|
|
messagebox.showinfo("成功", "车辆信息已成功更新。")
|
|
|
|
|
else:
|
|
|
|
|
messagebox.showinfo("失败", "未能找到或更新车辆信息,请检查车牌号是否正确。")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
messagebox.showerror("错误", f"编辑车辆信息时发生错误: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_statistics_click():
|
|
|
|
@ -163,7 +137,7 @@ def on_exit_click():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def refresh_ui():
|
|
|
|
|
"""根据当前模式刷新界面"""
|
|
|
|
|
# 在此函数中移除与编辑车辆信息按钮相关的代码
|
|
|
|
|
for widget in window.winfo_children():
|
|
|
|
|
widget.destroy()
|
|
|
|
|
|
|
|
|
@ -176,9 +150,9 @@ def refresh_ui():
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
if isAdmin:
|
|
|
|
|
# 从这里移除了与编辑车辆信息相关的按钮
|
|
|
|
|
additional_buttons = [
|
|
|
|
|
("显示车辆信息", on_display_info_click),
|
|
|
|
|
("编辑车辆信息", on_edit_info_click),
|
|
|
|
|
("统计信息", on_statistics_click),
|
|
|
|
|
("切换至用户模式", on_switch_mode),
|
|
|
|
|
]
|
|
|
|
@ -191,7 +165,6 @@ def refresh_ui():
|
|
|
|
|
for idx, (text, cmd) in enumerate(buttons):
|
|
|
|
|
tk.Button(window, text=text, command=cmd).pack(fill=tk.X, pady=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main_gui():
|
|
|
|
|
global window
|
|
|
|
|
window = tk.Tk()
|
|
|
|
|