diff --git a/course_management.sql b/course_management.sql new file mode 100644 index 0000000..7fca8aa --- /dev/null +++ b/course_management.sql @@ -0,0 +1,38 @@ +/* + Navicat Premium Data Transfer + + Source Server : daxueshengxinxi + Source Server Type : MySQL + Source Server Version : 80027 + Source Host : localhost:3306 + Source Schema : denglu + + Target Server Type : MySQL + Target Server Version : 80027 + File Encoding : 65001 + + Date: 27/05/2024 20:37:15 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for course_management +-- ---------------------------- +DROP TABLE IF EXISTS `course_management`; +CREATE TABLE `course_management` ( + `索引` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `老师姓名` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `老师手机号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `老师头像` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `课程编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `课程名称` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `上课地点` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `课程附件` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `课程类型` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `课程开始时间` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `课程结束时间` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/denglu.jpg b/denglu.jpg new file mode 100644 index 0000000..d936411 Binary files /dev/null and b/denglu.jpg differ diff --git a/denglujiemian.sql b/denglujiemian.sql new file mode 100644 index 0000000..7030792 --- /dev/null +++ b/denglujiemian.sql @@ -0,0 +1,37 @@ +/* + Navicat Premium Data Transfer + + Source Server : daxueshengxinxi + Source Server Type : MySQL + Source Server Version : 80027 + Source Host : localhost:3306 + Source Schema : denglu + + Target Server Type : MySQL + Target Server Version : 80027 + File Encoding : 65001 + + Date: 27/05/2024 20:37:28 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for denglujiemian +-- ---------------------------- +DROP TABLE IF EXISTS `denglujiemian`; +CREATE TABLE `denglujiemian` ( + `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名', + `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码' +) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of denglujiemian +-- ---------------------------- +INSERT INTO `denglujiemian` VALUES ('周佳燕', '12345678'); +INSERT INTO `denglujiemian` VALUES ('王俊凯', '134679852'); +INSERT INTO `denglujiemian` VALUES ('小米', '123456789'); +INSERT INTO `denglujiemian` VALUES ('王源', '13456789'); + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/xiugaiyi copy 9.py b/xiugaiyi copy 9.py new file mode 100644 index 0000000..e2b9d12 --- /dev/null +++ b/xiugaiyi copy 9.py @@ -0,0 +1,283 @@ +from tkinter import * +from tkinter import messagebox as msgbox +from tkinter import Label,ttk +import tkinter as tk +import sys +import re +from re import search, split, fullmatch +import pymysql +import os +from PIL import ImageTk, Image +class windows(tk.Tk): + def __init__(self): + super().__init__() + self.geometry("600x400") + self.title("登录界面") + self.geometry("600x600") + + background_image = ImageTk.PhotoImage(Image.open("denglu.jpg")) + background_label = Label(self, image=background_image) + background_label.place(x=0, y=0, relwidth=1, relheight=1) + + self.username = Entry(self) + self.passwd = Entry(self,show="*") + self.username.place(x=300, y=125) + self.passwd.place(x=300, y=175) + + + name1 = Label(self, text="用户名:", font=('宋体', 15), width=10) + name1.place(x=150, y=125) + name2 = Label(self, text="密码:", font=('宋体', 15), width=10) + name2.place(x=150, y=175) + + + button = Button(self, text="登录", font=('宋体', 15), width=10, command=self.js) + button.place(x=150, y=225) + button1 = Button(self, text="注册", font=('宋体', 15), width=10, command=self.zhucece) + button1.place(x=350, y=225) + + self.message_label = Label(self, text="", font=('宋体', 15), width=10) + self.message_label.place(x=450, y=175) + + self.mainloop() + def js(self): + + username = self.username.get() + passwd1 = self.passwd.get() + try: + db = pymysql.connect(host="localhost", user="root", password="123456", database="denglu") + cur = db.cursor() + + + sqlQuery = 'SELECT username, password FROM denglujiemian WHERE username=%s' + cur.execute(sqlQuery, (username,)) + result = cur.fetchone() + if result==None: + self.message_label.config(text="用户名错误,登录失败") + elif result[1]==passwd1: + self.message_label.config(text="登录成功") + self.login_success() + else: + self.message_label.config(text="密码错误,登录失败") + except Exception as e: + self.message_label.config(text="登录失败,失败原因为:%s"% e) + finally: + + cur.close() + db.close() + def login_success(self): + + self.destroy() + + js1_window = Js1Window() + js1_window.mainloop() + def zhucece(self): + + self.destroy() + + js1_ = js1() + js1_.mainloop() +class NextWindow(tk.Tk): + def __init__(self): + super().__init__() + self.geometry("1500x600") + self.title("主界面") + + self.menu_frame = tk.Frame(self, width=200, bg='#ADD8E6') + self.menu_frame.pack(side=tk.LEFT, fill=tk.Y) + + self.content_frame = tk.Frame(self) + self.content_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True,padx=10) + + self.create_menu_items() + + def create_menu_items(self): + menu_items = [ + ("首页", self.on_home_clicked), + ("个人中心", self.on_profile_clicked), + ("管理员管理", self.on_admin_clicked), + ("基础数据管理", self.on_data_management_clicked), + ("公告管理", self.on_announcement_management_clicked), + ("课程管理", self.on_course_management_clicked), + ("老师管理", self.on_teacher_management_clicked), + ("学生管理", self.on_student_management_clicked), + ("资料库管理", self.on_library_management_clicked) + ] + + for text, callback in menu_items: + button = ttk.Button(self.menu_frame, text=text, command=lambda c=callback: c()) + button.pack(side=tk.TOP, fill=tk.X, expand=True,padx=5, pady=5) + + def on_home_clicked(self): + print("点击了: 首页") + def on_profile_clicked(self): + print("点击了: 个人中心") + def on_admin_clicked(self): + print("点击了: 管理员管理") + def on_data_management_clicked(self): + print("点击了: 公告管理") + def on_announcement_management_clicked(self): + print("点击了: 课程管理") + def on_course_management_clicked(self): + # 设置Treeview的列 + self.tree = ttk.Treeview(self) + self.tree["columns"] = ("索引", "老师姓名", "老师手机号", "老师头像", "课程编号", "课程名称", "上课地点", "课程附件", "课程类型", "课程开始时间", "课程结束时间") + self.tree.column("索引", width=50) + self.tree.column("老师姓名", width=100) + self.tree.column("老师手机号", width=120) + self.tree.column("老师头像", width=50, stretch=False) # 假设这里只是占位,不显示真实头像 + self.tree.column("课程编号", width=80) + self.tree.column("课程名称", width=150) + self.tree.column("上课地点", width=100) + self.tree.column("课程附件", width=100) + self.tree.column("课程类型", width=80) + self.tree.column("课程开始时间", width=120) + self.tree.column("课程结束时间", width=120) + self.tree.heading("索引", text="索引") + self.tree.heading("老师姓名", text="老师姓名") + self.tree.heading("老师手机号", text="老师手机号") + self.tree.heading("老师头像", text="老师头像") + self.tree.heading("课程编号", text="课程编号") + self.tree.heading("课程名称", text="课程名称") + self.tree.heading("上课地点", text="上课地点") + self.tree.heading("课程附件", text="课程附件") + self.tree.heading("课程类型", text="课程类型") + self.tree.heading("课程开始时间", text="课程开始时间") + self.tree.heading("课程结束时间", text="课程结束时间") + self.tree.pack(fill="both", expand=True) + + self.populate_tree() + def populate_tree(self): + try: + db = pymysql.connect(host="localhost", user="root", password="123456", database="denglu", charset='utf8mb4') + cur = db.cursor() + + sqlQuery = """ + SELECT + ROW_NUMBER() OVER (ORDER BY some_column) AS 索引, -- 这里用ROW_NUMBER模拟索引,您可能需要调整 + teacher_name AS '老师姓名', + teacher_phone AS '老师手机号', + '头像占位符' AS '老师头像', + course_id AS '课程编号', + course_name AS '课程名称', + classroom AS '上课地点', + attachment_link AS '课程附件', + course_type AS '课程类型', + start_time AS '课程开始时间', + end_time AS '课程结束时间' + FROM your_table_name -- 替换为您的表名 + """ + cur.execute(sqlQuery) + results = cur.fetchall() + + for item in self.tree.get_children(): + self.tree.delete(item) + + for row in results: + self.tree.insert("", "end", values=row) + + cur.close() + db.close() + except pymysql.MySQLError as e: + print(f"Error: {e}") + def on_teacher_management_clicked(self): + print("点击了: 老师管理") + def on_student_management_clicked(self): + print("点击了: 学生管理") + + def on_library_management_clicked(self): + print("点击了: 资料库管理") +class Js1Window(tk.Tk): + def __init__(self): + super().__init__() + self.geometry("600x600") + self.title("欢迎界面") + + background_image = ImageTk.PhotoImage(Image.open("denglu.jpg")) + background_label = Label(self, image=background_image) + background_label.place(x=0, y=0, relwidth=1, relheight=1) + + self.welcome_label = Label(self, text="欢迎进入大学生信息管理系统") + self.welcome_label.pack(pady=20) + + self.quit_button = Button(self, text="退出", command=self.quit) + self.quit_button.pack(side=tk.BOTTOM, pady=10) + + self.after(3000, self.open_next_window) + + self.mainloop() + def open_next_window(self): + self.destroy() + next_window = NextWindow() + next_window.mainloop() +class js1(tk.Tk): + def __init__(self): + super().__init__() + self.geometry("600x600") + self.title("注册界面") + + background_image = ImageTk.PhotoImage(Image.open("denglu.jpg")) + background_label = Label(self, image=background_image) + background_label.place(x=0, y=0, relwidth=1, relheight=1) + + self.username1 = Entry(self) + self.passwd1 = Entry(self, show="*") + self.passwd2 = Entry(self, show="*") + self.username1.place(x=300, y=125) + self.passwd1.place(x=300, y=175) + self.passwd2.place(x=300, y=225) + + name4 = Label(self, text="用户名:", font=('宋体', 15), width=10) + name4.place(x=150, y=125) + name5 = Label(self, text="密码:", font=('宋体', 15), width=10) + name5.place(x=150, y=175) + name6 = Label(self, text="确认密码:", font=('宋体', 15), width=10) + name6.place(x=150, y=225) + + button = Button(self, text="返回", font=('宋体', 15), width=10, command=self.windows) + button.place(x=350, y=300) + button1 = Button(self, text="注册", font=('宋体', 15), width=10, command=self.register) + button1.place(x=200, y=300) + + self.message_label = Label(self, text="", font=('宋体', 10), width=20) + self.message_label.place(x=450, y=125) + + self.message_label = Label(self, text="", font=('宋体', 10), width=20) + self.message_label.place(x=450, y=225) + + self.mainloop() + def windows(self): + self.destroy() + + windows_window = windows() + windows_window.mainloop() + def register(self): + username = self.username1.get() + passwd1 = self.passwd1.get() + passwd2 = self.passwd2.get() + try: + db = pymysql.connect(host="localhost", user="root", password="123456", database="denglu") + cur = db.cursor() + sqlQuery = 'SELECT username FROM denglujiemian WHERE username=%s' + cur.execute(sqlQuery, (username,)) + result = cur.fetchone() + + if passwd1 != passwd2: + self.message_label.config(text="失败!两次输入的密码不一致,请重新输入!") + else: + if not result: + insert_user_sql = "INSERT INTO denglujiemian (username, password) VALUES (%s, %s)" + cur.execute(insert_user_sql, (username, passwd1)) + db.commit() + self.message_label.config(text="成功!恭喜你注册成功!") + else: + self.message_label.config(text="失败!用户名已存在,请重新输入!") + + except pymysql.Error as e: + self.message_label.config(text="注册失败!数据库错误:" + str(e)) + finally: + cur.close() + db.close() +if __name__ == '__main__': + app = windows() + app.mainloop() \ No newline at end of file