|
|
@ -1,45 +1,5 @@
|
|
|
|
import tkinter as tk
|
|
|
|
import tkinter as tk
|
|
|
|
from tkinter import messagebox
|
|
|
|
from tkinter import messagebox
|
|
|
|
import pymysql
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 数据库连接配置
|
|
|
|
|
|
|
|
host = 'localhost'
|
|
|
|
|
|
|
|
user = 'root'
|
|
|
|
|
|
|
|
password = '123456'
|
|
|
|
|
|
|
|
db = 'sys'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
# 尝试连接数据库
|
|
|
|
|
|
|
|
conn = pymysql.connect(host=host, user=user, password=password, db=db)
|
|
|
|
|
|
|
|
print("数据库连接成功")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 创建一个Cursor对象
|
|
|
|
|
|
|
|
cursor = conn.cursor()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 定义创建用户表的SQL语句
|
|
|
|
|
|
|
|
create_table_sql = """
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
|
|
|
|
|
|
user_id INT AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
|
|
|
|
username VARCHAR(255) NOT NULL UNIQUE,
|
|
|
|
|
|
|
|
password VARCHAR(255) NOT NULL
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 执行SQL语句创建表
|
|
|
|
|
|
|
|
cursor.execute(create_table_sql)
|
|
|
|
|
|
|
|
print("用户表创建成功")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 提交事务
|
|
|
|
|
|
|
|
conn.commit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except pymysql.MySQLError as e:
|
|
|
|
|
|
|
|
print(f"数据库操作出错: {e}")
|
|
|
|
|
|
|
|
finally:
|
|
|
|
|
|
|
|
# 关闭Cursor和Connection
|
|
|
|
|
|
|
|
if cursor:
|
|
|
|
|
|
|
|
cursor.close()
|
|
|
|
|
|
|
|
if conn:
|
|
|
|
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FootSpaManagementSystem:
|
|
|
|
class FootSpaManagementSystem:
|
|
|
|
def __init__(self,order_info=""):
|
|
|
|
def __init__(self,order_info=""):
|
|
|
@ -183,9 +143,9 @@ class FootSpaManagementSystem:
|
|
|
|
if username and password:
|
|
|
|
if username and password:
|
|
|
|
with open(self.user_data_file, "a") as file:
|
|
|
|
with open(self.user_data_file, "a") as file:
|
|
|
|
file.write(f"{username},{password}\n")
|
|
|
|
file.write(f"{username},{password}\n")
|
|
|
|
messagebox.showinfo("注册成功", "用户注册成功!") # 显示注册成功信息
|
|
|
|
messagebox.showinfo("注册成功", "用户注册成功!") # 显示注册成功消息
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
messagebox.showerror("注册失败", "请输入用户名和密码。") # 显示注册失败信息
|
|
|
|
messagebox.showerror("注册失败", "请输入用户名和密码。")
|
|
|
|
|
|
|
|
|
|
|
|
#用户登录函数
|
|
|
|
#用户登录函数
|
|
|
|
def login_user(self):
|
|
|
|
def login_user(self):
|
|
|
|