Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
|
e404920f62 | 1 year ago |
|
1e3d0a716e | 1 year ago |
|
b3d1bfe19e | 1 year ago |
|
53c980a7e2 | 1 year ago |
|
b5bf1af0a2 | 1 year ago |
|
f65cff173b | 1 year ago |
|
275f725927 | 1 year ago |
|
f2bec40ed4 | 1 year ago |
|
2b8db00340 | 1 year ago |
|
5ecbab8ff1 | 1 year ago |
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.12 (pythonProject)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.12 (pythonProject)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (pythonProject)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/StudentInformationManagementSystem.iml" filepath="$PROJECT_DIR$/.idea/StudentInformationManagementSystem.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,27 @@
|
||||
|
||||
from dao.MysqlConfig import MysqlConfig
|
||||
|
||||
|
||||
class StudentDao:
|
||||
|
||||
@staticmethod # 增删改的方法
|
||||
def update_student(sql, *params):
|
||||
try:
|
||||
MysqlConfig.cursor.execute(sql, params)
|
||||
except Exception as ex:
|
||||
print("出现异常:%s" % ex)
|
||||
MysqlConfig.db.rollback()
|
||||
|
||||
@staticmethod # 查询学生的方法
|
||||
def query_student(sno):
|
||||
sql = "SELECT * FROM t_student WHERE sno = %s" % repr(sno)
|
||||
MysqlConfig.cursor.execute(sql) # 执行语句
|
||||
MysqlConfig.db.commit() # 提交
|
||||
return MysqlConfig.cursor.fetchone() # 返回查询到的结果
|
||||
|
||||
@staticmethod # 查询全部学生的方法
|
||||
def query_all():
|
||||
sql = 'SELECT * FROM t_student;'
|
||||
MysqlConfig.cursor.execute(sql) # 执行语句
|
||||
MysqlConfig.db.commit() # 提交
|
||||
return MysqlConfig.cursor.fetchall() # 返回查询到的结果
|
@ -0,0 +1,21 @@
|
||||
|
||||
from dao.MysqlConfig import MysqlConfig
|
||||
|
||||
|
||||
class UserDao:
|
||||
|
||||
@staticmethod # 增删改的方法
|
||||
def update_user(sql, *params):
|
||||
try:
|
||||
MysqlConfig.cursor.execute(sql, params)
|
||||
except Exception as ex:
|
||||
print("出现异常:%s" % ex)
|
||||
MysqlConfig.db.rollback()
|
||||
|
||||
@staticmethod # 查询用户的方法
|
||||
def query_user(user_name):
|
||||
sql = "SELECT * FROM t_user WHERE user_name = %s" % repr(user_name)
|
||||
MysqlConfig.cursor.execute(sql) # 执行语句
|
||||
MysqlConfig.db.commit() # 提交
|
||||
return MysqlConfig.cursor.fetchone() # 返回查询到的结果
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
from dao.MysqlConfig import MysqlConfig
|
||||
from ui.StudentUI import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
MysqlConfig.create_mysql()
|
||||
StudentUI.init_login()
|
@ -0,0 +1,95 @@
|
||||
from tkinter import END, INSERT
|
||||
from tkinter.messagebox import *
|
||||
|
||||
from dao.StudentDao import StudentDao
|
||||
from utils.ExcelUtils import ExcelUtils
|
||||
|
||||
|
||||
class StudentService:
|
||||
|
||||
@staticmethod
|
||||
def add_student(list_entry):
|
||||
sno = list_entry[0].get()
|
||||
if sno == '':
|
||||
showwarning(title="警告", message="学号不能为空!\n加入失败!")
|
||||
return
|
||||
result = StudentDao.query_student(sno) # 根据学号查询学生
|
||||
if result is not None:
|
||||
showwarning(title="警告", message="学号重复!\n加入失败!")
|
||||
return
|
||||
sql = "INSERT INTO t_student(sno,sname,sex,age,phone,dormNo) VALUES(%s,%s,%s,%s,%s,%s)"
|
||||
StudentDao.update_student(sql, list_entry[0].get(), list_entry[1].get(), list_entry[2].get(),
|
||||
list_entry[3].get(), list_entry[4].get(), list_entry[5].get())
|
||||
showinfo(title="提示", message="加入成功!")
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def delete_student(sno):
|
||||
result = StudentDao.query_student(sno) # 根据学号查询学生
|
||||
if result is None:
|
||||
showerror(title="错误", message="不存在该学生!")
|
||||
return
|
||||
sql = "DELETE FROM t_student WHERE sno = %s"
|
||||
StudentDao.update_student(sql, sno)
|
||||
showinfo(title="提示", message="删除成功!")
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def query_student(sno, list_entry):
|
||||
result = StudentDao.query_student(sno) # 根据学号查询学生
|
||||
if result is None:
|
||||
showwarning(title="警告", message="未查询到相关学生信息!")
|
||||
return
|
||||
list_entry[0].insert(INSERT, result[2])
|
||||
list_entry[1].insert(INSERT, result[3])
|
||||
list_entry[2].insert(INSERT, result[4])
|
||||
list_entry[3].insert(INSERT, result[5])
|
||||
list_entry[4].insert(INSERT, result[6])
|
||||
|
||||
@staticmethod
|
||||
def update_student(sno, list_entry):
|
||||
result = StudentDao.query_student(sno) # 根据学号查询学生
|
||||
if result is None:
|
||||
showerror(title="错误", message="不存在该学生!")
|
||||
return
|
||||
sql = "UPDATE t_student SET sname = %s,sex = %s,age = %s,phone = %s,dormNo = %s WHERE sno = %s"
|
||||
StudentDao.update_student(sql, list_entry[0].get(), list_entry[1].get(), list_entry[2].get(),
|
||||
list_entry[3].get(), list_entry[4].get(), sno)
|
||||
showinfo(title="提示", message="修改成功!")
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def query_all(lb):
|
||||
result = StudentDao.query_all()
|
||||
for row in result:
|
||||
lb.insert(END,
|
||||
"ID:%s 学号:%s 姓名:%s 性别:%s 年龄:%s 电话:%s 宿舍号:%s" % (
|
||||
row[0], row[1], row[2], row[3], row[4], row[5], row[6]))
|
||||
|
||||
@staticmethod
|
||||
def to_excel():
|
||||
data = {}
|
||||
list_Id = []
|
||||
list_sno = []
|
||||
list_name = []
|
||||
list_sex = []
|
||||
list_age = []
|
||||
list_phone = []
|
||||
list_dormNo = []
|
||||
for row in StudentDao.query_all():
|
||||
list_Id.append(row[0])
|
||||
list_sno.append(row[1])
|
||||
list_name.append(row[2])
|
||||
list_sex.append(row[3])
|
||||
list_age.append(row[4])
|
||||
list_phone.append(row[5])
|
||||
list_dormNo.append(row[6])
|
||||
data['ID'] = list_Id
|
||||
data['学号'] = list_sno
|
||||
data['姓名'] = list_name
|
||||
data['性别'] = list_sex
|
||||
data['年龄'] = list_age
|
||||
data['电话'] = list_phone
|
||||
data['宿舍'] = list_dormNo
|
||||
ExcelUtils.to_excel(data)
|
||||
showinfo(title="提示", message="导出成功!")
|
@ -0,0 +1,29 @@
|
||||
from tkinter.messagebox import *
|
||||
|
||||
from dao.UserDao import UserDao
|
||||
|
||||
|
||||
class UserService:
|
||||
|
||||
@staticmethod
|
||||
def login_dispose(user_name, password):
|
||||
user = UserDao.query_user(user_name)
|
||||
if user is None:
|
||||
showwarning(title="警告", message="不存在当前用户!\n请先注册!")
|
||||
return
|
||||
if password != user[2]:
|
||||
showwarning(title="警告", message="密码错误!")
|
||||
return
|
||||
showinfo(title="提示", message="登录成功!")
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def register_dispose(user_name, password):
|
||||
user = UserDao.query_user(user_name)
|
||||
if user is not None:
|
||||
showwarning(title="警告", message="该用户名已使用!")
|
||||
return
|
||||
sql = "INSERT INTO t_user(user_name,user_password) VALUES (%s,%s);"
|
||||
UserDao.update_user(sql, user_name, password)
|
||||
showinfo(title="提示", message="注册成功!")
|
||||
return True
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,23 @@
|
||||
import os
|
||||
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class ExcelUtils:
|
||||
file_path = 'output.xlsx'
|
||||
|
||||
@staticmethod
|
||||
def red_excel():
|
||||
if not os.path.exists(ExcelUtils.file_path):
|
||||
return
|
||||
# 从Excel文件中读取数据
|
||||
data = pd.read_excel('output.xlsx')
|
||||
return data
|
||||
|
||||
@staticmethod
|
||||
def to_excel(data):
|
||||
# 将数据转换为DataFrame
|
||||
df = pd.DataFrame(data)
|
||||
# 导出到Excel文件
|
||||
df.to_excel(ExcelUtils.file_path, index=False)
|
||||
print("导出成功!")
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue