python实现科研管理系统(带用户界面和mysql数据库)

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介: python实现科研管理系统(带用户界面和mysql数据库)

用python简单实现了一个科研管理系统的数据库大作业,有用户界面,可以实现增删改查功能


下面是6个主要模块,有需要源码的可以私信


1:连接模块 根据自己的mysql数据库输入参数即可连接



import pymysql
def connect():
    conn = pymysql.connect(host='localhost', user='root',password=' ',database='',autocommit=True)#连接数据库library,用户和密码按需修改
    cursor = conn.cursor()
    return cursor, conn

2:登录模块 实现登录界面并且有三种身份,根据数据库里账号密码来判断登录是否正确


from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Login(object):
    def setupUi(self, Login):
        #登录界面
        Login.setObjectName("Login")
        Login.setWindowModality(QtCore.Qt.ApplicationModal)
        Login.resize(800, 600)
        self.label = QtWidgets.QLabel(Login)
        self.label.setGeometry(QtCore.QRect(20, 20, 100, 30))
        self.label.setTextFormat(QtCore.Qt.AutoText)
        self.label.setObjectName("label")
        #用户界面
        self.user = QtWidgets.QLabel(Login)
        self.user.setGeometry(QtCore.QRect(160, 100, 60, 60))
        self.user.setObjectName("user")
        #密码界面
        self.password = QtWidgets.QLabel(Login)
        self.password.setGeometry(QtCore.QRect(160, 150, 60, 26))
        self.password.setObjectName("password")
        #身份界面
        self.identify = QtWidgets.QLabel(Login)
        self.identify.setGeometry(QtCore.QRect(140, 180, 91, 59))
        self.identify.setObjectName("identify")
        #用户行
        self.userline = QtWidgets.QLineEdit(Login)
        self.userline.setGeometry(QtCore.QRect(290, 100, 191, 21))
        self.userline.setObjectName("userline")
        #密码行
        self.pwline = QtWidgets.QLineEdit(Login)
        self.pwline.setGeometry(QtCore.QRect(290, 150, 191, 21))
        self.pwline.setEchoMode(QtWidgets.QLineEdit.Password)
        self.pwline.setObjectName("pwline")
        #ID盒
        self.idbox = QtWidgets.QComboBox(Login)
        self.idbox.setGeometry(QtCore.QRect(320, 200, 121, 22))
        self.idbox.setObjectName("idbox")
        self.idbox.addItem("")
        self.idbox.addItem("")
        self.idbox.addItem("")
        #登录按钮
        self.loginbt = QtWidgets.QPushButton(Login)
        self.loginbt.setGeometry(QtCore.QRect(250, 270, 93, 28))
        self.loginbt.setObjectName("loginbt")
        #退出按钮
        self.exitbt = QtWidgets.QPushButton(Login)
        self.exitbt.setGeometry(QtCore.QRect(420, 270, 93, 28))
        self.exitbt.setObjectName("exitbt")
        self.retranslateUi(Login)
        QtCore.QMetaObject.connectSlotsByName(Login)
    def retranslateUi(self, Login):
        _translate = QtCore.QCoreApplication.translate
        Login.setWindowTitle(_translate("Login", "SCUT科研管理系统"))
        self.label.setText(_translate("Login", "<html><head/><body><p><span style=\" font-size:15pt;\">SCUT</span></p></body></html>"))
        self.user.setText(_translate("Login", "<html><head/><body><p><span style=\" font-size:10pt;\">用户</span></p></body></html>"))
        self.password.setText(_translate("Login", "<html><head/><body><p><span style=\" font-size:12pt;\">密码</span></p></body></html>"))
        self.identify.setText(_translate("Login", "<html><head/><body><p><span style=\" font-size:12pt;\">身份类型</span></p></body></html>"))
        self.idbox.setItemText(0, _translate("Login", "秘书"))
        self.idbox.setItemText(1, _translate("Login", "主任"))
        self.idbox.setItemText(2, _translate("Login", "科研人员"))
        self.loginbt.setText(_translate("Login", "登录"))
        self.exitbt.setText(_translate("Login", "退出"))

3:秘书模块 实现了登录成功后秘书的界面及秘书所能执行的操作


1666355070102.jpg


import time
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QTableWidgetItem,QMessageBox
from connect import *
import  pymysql
cursor,conn=connect()     #连接数据库
class Ui_Reader(object):
    #创建UI
    def setupUi(self, Reader):
        self.loginID=self.getreaderid()
        Reader.setObjectName("Reader")
        Reader.resize(719, 742)
        self.readertab = QtWidgets.QTabWidget(Reader)
        self.readertab.setGeometry(QtCore.QRect(11, 11, 701, 721))
        self.readertab.setObjectName("readertab")
        self.borrowbook = QtWidgets.QWidget()
        self.borrowbook.setObjectName("borrowbook")
        self.returnbookid = QtWidgets.QLineEdit(self.layoutWidget1)
        self.returnbookid.setObjectName("returnbookid")
        self.horizontalLayout_3.addWidget(self.returnbookid)
        self.returnbookbt = QtWidgets.QPushButton(self.layoutWidget1)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.returnbookbt.sizePolicy().hasHeightForWidth())
        self.returnbookbt.setSizePolicy(sizePolicy)
        self.returnbookbt.setObjectName("returnbookbt")
        self.horizontalLayout_3.addWidget(self.returnbookbt)
        self.label_5.setObjectName("label_5")
        self.horizontalLayout_6.addWidget(self.label_5)
        self.author = QtWidgets.QLineEdit(self.widget)
        self.author.setObjectName("author")
        self.horizontalLayout_6.addWidget(self.author)
        self.verticalLayout_4.addLayout(self.horizontalLayout_6)
        self.horizontalLayout_7 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_7.setObjectName("horizontalLayout_7")
        self.label_6 = QtWidgets.QLabel(self.widget)
        self.label_6.setObjectName("label_6")
        self.horizontalLayout_7.addWidget(self.label_6)
        self.type = QtWidgets.QLineEdit(self.widget)
        self.type.setObjectName("type")
        self.horizontalLayout_7.addWidget(self.type)
        self.verticalLayout_4.addLayout(self.horizontalLayout_7)
        self.horizontalLayout_8 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_8.setObjectName("horizontalLayout_8")
        self.label_7 = QtWidgets.QLabel(self.widget)
        self.label_7.setObjectName("label_7")
        self.horizontalLayout_8.addWidget(self.label_7)
        self.press = QtWidgets.QLineEdit(self.widget)
        self.press.setObjectName("press")
        self.horizontalLayout_8.addWidget(self.press)
        self.verticalLayout_4.addLayout(self.horizontalLayout_8)
        self.horizontalLayout_9.addLayout(self.verticalLayout_4)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.pushButton = QtWidgets.QPushButton(self.widget)
        self.pushButton.setObjectName("pushButton")
        self.verticalLayout.addWidget(self.pushButton)
        self.checkbt = QtWidgets.QPushButton(self.widget)
        self.checkbt.setObjectName("checkbt")
        self.verticalLayout.addWidget(self.checkbt)
        self.horizontalLayout_9.addLayout(self.verticalLayout)
        self.readertab.addTab(self.checkbook, "")
        self.userinfo = QtWidgets.QWidget()
        self.userinfo.setObjectName("userinfo")
        self.verticalLayout_9 = QtWidgets.QVBoxLayout(self.userinfo)
        self.verticalLayout_9.setObjectName("verticalLayout_9")
        self.verticalLayout_8 = QtWidgets.QVBoxLayout()
        self.verticalLayout_8.setObjectName("verticalLayout_8")
        self.horizontalLayout_14 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_14.setObjectName("horizontalLayout_14")
        self.verticalLayout_7 = QtWidgets.QVBoxLayout()
        self.verticalLayout_7.setObjectName("verticalLayout_7")
        self.horizontalLayout_10 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_10.setObjectName("horizontalLayout_10")
        self.label_8 = QtWidgets.QLabel(self.userinfo)
        self.label_8.setObjectName("label_8")
        self.horizontalLayout_10.addWidget(self.label_8)
        self.lineEdit_8 = QtWidgets.QLineEdit(self.userinfo)
        self.lineEdit_8.setObjectName("lineEdit_8")
        self.horizontalLayout_10.addWidget(self.lineEdit_8)
        self.verticalLayout_7.addLayout(self.horizontalLayout_10)
        self.horizontalLayout_11 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_11.setObjectName("horizontalLayout_11")
        self.label_9 = QtWidgets.QLabel(self.userinfo)
        self.label_9.setObjectName("label_9")
        self.horizontalLayout_11.addWidget(self.label_9)
        self.lineEdit_9 = QtWidgets.QLineEdit(self.userinfo)
        self.lineEdit_9.setObjectName("lineEdit_9")
        self.horizontalLayout_11.addWidget(self.lineEdit_9)
        self.verticalLayout_7.addLayout(self.horizontalLayout_11)
        self.horizontalLayout_12 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_12.setObjectName("horizontalLayout_12")
        self.verticalLayout_7.addLayout(self.horizontalLayout_12)
        self.horizontalLayout_13 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_13.setObjectName("horizontalLayout_13")
        self.label_11 = QtWidgets.QLabel(self.userinfo)
        self.label_11.setObjectName("label_11")
        self.horizontalLayout_13.addWidget(self.label_11)
        self.lineEdit_11 = QtWidgets.QLineEdit(self.userinfo)
        self.lineEdit_11.setObjectName("lineEdit_11")
        self.horizontalLayout_13.addWidget(self.lineEdit_11)
        self.verticalLayout_7.addLayout(self.horizontalLayout_13)
        self.horizontalLayout_14.addLayout(self.verticalLayout_7)
        self.pushButton_5 = QtWidgets.QPushButton(self.userinfo)
        self.pushButton_5.setObjectName("pushButton_5")
        self.horizontalLayout_14.addWidget(self.pushButton_5)
        self.verticalLayout_8.addLayout(self.horizontalLayout_14)
        self.textBrowser_2 = QtWidgets.QTextBrowser(self.userinfo)
        self.textBrowser_2.setObjectName("textBrowser_2")
        self.verticalLayout_8.addWidget(self.textBrowser_2)
        self.verticalLayout_9.addLayout(self.verticalLayout_8)
        self.readertab.addTab(self.userinfo, "")
        self.pay_2 = QtWidgets.QWidget()
        self.pay_2.setObjectName("pay_2")
        self.gridLayout = QtWidgets.QGridLayout(self.pay_2)
        self.gridLayout.setObjectName("gridLayout")
        self.money = QtWidgets.QLabel(self.pay_2)
        self.money.setText("")
        self.money.setObjectName("money")
        self.gridLayout.addWidget(self.money, 0, 1, 1, 1)
        self.label_12 = QtWidgets.QLabel(self.pay_2)
        self.label_12.setObjectName("label_12")
        self.gridLayout.addWidget(self.label_12, 0, 0, 1, 1)
        self.alipay = QtWidgets.QPushButton(self.pay_2)
        self.alipay.setObjectName("alipay")
        self.gridLayout.addWidget(self.alipay, 1, 2, 1, 1)
        self.wepay = QtWidgets.QPushButton(self.pay_2)
        self.wepay.setObjectName("wepay")
        self.gridLayout.addWidget(self.wepay, 1, 1, 1, 1)
        self.readertab.addTab(self.pay_2, "")
        self.retranslateUi(Reader)
        self.getreaderinfo()
        # self.textBrowser_2.setText(self.readerlogin
        self.readertab.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(Reader)
        self.borrowcheckbt.clicked.connect(self.borrowidcheck)
        self.borrowokbt.clicked.connect(self.submit)
        self.returnbookbt.clicked.connect(self.ReturnBook)
        self.pushButton.clicked.connect(self.selectallbook)
        self.checkbt.clicked.connect(self.selectbook)
        self.pushButton_5.clicked.connect(self.alterinfo)
        self.wepay.clicked.connect(self.paymoney)
        self.alipay.clicked.connect(self.paymoney)
    def retranslateUi(self, Reader):
        _translate = QtCore.QCoreApplication.translate
        Reader.setWindowTitle(_translate("Reader", "读者系统"))
        self.label.setText(_translate("Reader", "秘书个人信息"))
        self.borrowcheckbt.setText(_translate("Reader", "查询"))
        item = self.borrowtable.verticalHeaderItem(0)
        item.setText(_translate("Reader", "1"))
        item = self.borrowtable.horizontalHeaderItem(0)
        item.setText(_translate("Reader", "秘书姓名"))
        item = self.borrowtable.horizontalHeaderItem(1)
        item.setText(_translate("Reader", "秘书工号"))
        item = self.borrowtable.horizontalHeaderItem(2)
        item.setText(_translate("Reader", "秘书性别"))
        item = self.borrowtable.horizontalHeaderItem(3)
        item.setText(_translate("Reader", "秘书归属实验室"))
        item = self.borrowtable.horizontalHeaderItem(4)
        item.setText(_translate("Reader", ""))
        self.borrowokbt.setText(_translate("Reader", "末尾分界线"))
        self.readertab.setTabText(self.readertab.indexOf(self.borrowbook), _translate("Reader", "秘书信息查询"))
        #2
        self.returnbo.setText(_translate("Reader", "修改"))
        self.returnbookbt.setText(_translate("Reader", "确定"))
        self.readertab.setTabText(self.readertab.indexOf(self.returnbook), _translate("Reader", "修改秘书信息"))
        #3
        item = self.tableWidget.horizontalHeaderItem(0)
        item.setText(_translate("Reader", "秘书姓名"))
        item = self.tableWidget.horizontalHeaderItem(1)
        item.setText(_translate("Reader", "秘书工号"))
        item = self.tableWidget.horizontalHeaderItem(2)
        item.setText(_translate("Reader", "秘书性别"))
        item = self.tableWidget.horizontalHeaderItem(3)
        item.setText(_translate("Reader", "秘书归属实验室"))
        item = self.tableWidget.horizontalHeaderItem(4)
        item.setText(_translate("Reader", ""))
        self.label_3.setText(_translate("Reader", "秘书姓名"))
        self.label_4.setText(_translate("Reader", "秘书工号"))
        self.label_5.setText(_translate("Reader", "秘书性别"))
        self.label_6.setText(_translate("Reader", "秘书归属实验室"))
        self.label_7.setText(_translate("Reader", ""))
        self.pushButton.setText(_translate("Reader", "增加秘书信息"))
        self.checkbt.setText(_translate("Reader", "查询添加后的结果"))
        self.readertab.setTabText(self.readertab.indexOf(self.checkbook), _translate("Reader", "增加秘书信息"))
        #4
        self.label_8.setText(_translate("Reader", "秘书姓名"))
        self.label_9.setText(_translate("Reader", "秘书性别"))
        self.label_11.setText(_translate("Reader", ""))
        self.pushButton_5.setText(_translate("Reader", "删除"))
        self.readertab.setTabText(self.readertab.indexOf(self.userinfo), _translate("Reader", "删除秘书信息"))
       #5
        self.label_12.setText(_translate("Reader", "科研成果"))
        self.alipay.setText(_translate("Reader", "论文"))
        self.wepay.setText(_translate("Reader", "专利"))
        self.readertab.setTabText(self.readertab.indexOf(self.pay_2), _translate("Reader", "查询秘书科研成果"))  #####
    #第一个界面的查询
    def borrowidcheck(self):
        bookin=self.borrowbookid.text()
        sql='select * from secreatry'
        res = cursor.execute(sql)
        display=cursor.fetchall()
        print(display)
    #
    def getreaderid(self):
        nowtime = time.strftime("%Y-%m-%d", time.localtime())
        sql='SELECT * FROM secreatry'
        cursor.execute(sql)
    #
    def getreaderinfo(self):
        sql='SELECT * FROM secreatry '
        cursor.execute(sql)
        readerlogined=cursor.fetchall()
    #第二个界面
    def submit(self):
                sql = 'update secreatry set selab="b8-123" where saname="张三"'
                if sql:
                    res = cursor.execute(sql)
                conn.commit()
                QMessageBox.warning(self, "提示", "修改成功!", QMessageBox.Yes)
    #修改
    def ReturnBook(self):
        bookid = self.returnbookid.text()
        sql='SELECT * FROM secreatry'
        res=cursor.execute(sql)
        if res:
            sql = 'update secreatry set selab="b8-802" where sename="张三"'
            res = cursor.execute(sql)
            borrowinfo = cursor.fetchall()
            if res:
                    print(borrowinfo)
                    cursor.execute(sql)
                    conn.commit()
                    QMessageBox.warning(self, "提示", "修改成功!", QMessageBox.Yes)
        else:
            QMessageBox.warning(self, "警告", "修改信息有误 请重新输入!", QMessageBox.Yes)
    #第三个查询
    def selectallbook(self):
        sql='insert into secreatry values("汤德佑","33","男","b8-234")'
        cursor.execute(sql)
        if sql:
            QMessageBox.warning(self, "提示", "添加成功!", QMessageBox.Yes)
        books=cursor.fetchall()
        conn.commit()
    #查询书籍
    def selectbook(self):
        sql='SELECT * FROM secreatry'
        res=cursor.execute(sql)
        display = cursor.fetchall()
        print(display)
    #第四个修改
    def alterinfo(self):
        sql = 'delete from secreatry where sename="汤德佑"'
        if sql:
            cursor.execute(sql)
            result=cursor.fetchall()
            conn.commit()
            QMessageBox.warning(self, "警告", "删除成功", QMessageBox.Yes)
    #第五个支付
    def paymoney(self):
        money=0.00
        sql = 'select * from paper'
        cursor.execute(sql)
        res=cursor.fetchall()
        print(res)
        conn.commit()
        self.getreaderinfo()

4:主任模块 实现了登录后的主任界面及主任的各个功能


1666355107940.jpg

from PyQt5 import QtCore, QtGui, QtWidgets
from connect import *
from PyQt5.QtWidgets import QTableWidgetItem, QMessageBox
import datetime
import time
cursor, conn = connect()
class Ui_bookadmin(object):
    def __init__(self):
        self.dibeingtime = NotImplemented
        self.renqi=NotImplemented
        self.manangedlab=NotImplemented
    def setupUi(self, bookadmin):
        bookadmin.setObjectName("bookadmin")
        bookadmin.resize(846, 796)
        self.tabWidget = QtWidgets.QTabWidget(bookadmin)
        self.tabWidget.setGeometry(QtCore.QRect(20, 20, 811, 761))
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.tab)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label_2 = QtWidgets.QLabel(self.tab)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout.addWidget(self.label_2)
        self.readerid = QtWidgets.QLineEdit(self.tab)
        self.readerid.setObjectName("dibeingtime")
        self.horizontalLayout.addWidget(self.readerid)
        self.label = QtWidgets.QLabel(self.tab)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        self.readername = QtWidgets.QLineEdit(self.tab)
        self.readername.setObjectName("renqi")
        self.horizontalLayout.addWidget(self.readername)
        self.label_3 = QtWidgets.QLabel(self.tab)
        self.label_3.setObjectName("label_3")
        self.horizontalLayout.addWidget(self.label_3)
        self.unit = QtWidgets.QLineEdit(self.tab)
        self.unit.setObjectName("unit")
        self.horizontalLayout.addWidget(self.unit)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.select = QtWidgets.QPushButton(self.tab)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.select.sizePolicy().hasHeightForWidth())
        self.select.setSizePolicy(sizePolicy)
        self.select.setObjectName("select")
        self.horizontalLayout_2.addWidget(self.select)
        self.selectall = QtWidgets.QPushButton(self.tab)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.selectall.sizePolicy().hasHeightForWidth())
        self.selectall.setSizePolicy(sizePolicy)
        self.selectall.setObjectName("selectall")
        self.horizontalLayout_2.addWidget(self.selectall)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.readerinfors = QtWidgets.QTableWidget(self.tab)
        self.readerinfors.setObjectName("directorinfo")
        self.readerinfors.setColumnCount(8)
        self.readerinfors.setRowCount(0)
        item = QtWidgets.QTableWidgetItem()
        self.readerinfors.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.readerinfors.setHorizontalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        self.readerinfors.setHorizontalHeaderItem(2, item)
        item = QtWidgets.QTableWidgetItem()
        self.readerinfors.setHorizontalHeaderItem(3, item)
        item = QtWidgets.QTableWidgetItem()
        self.readerinfors.setHorizontalHeaderItem(4, item)
        item = QtWidgets.QTableWidgetItem()
        self.readerinfors.setHorizontalHeaderItem(5, item)
        item = QtWidgets.QTableWidgetItem()
        self.readerinfors.setHorizontalHeaderItem(6, item)
        item = QtWidgets.QTableWidgetItem()
        self.readerinfors.setHorizontalHeaderItem(7, item)
        self.verticalLayout.addWidget(self.readerinfors)
        self.verticalLayout_2.addLayout(self.verticalLayout)
        self.tabWidget.addTab(self.tab, "")
        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.tab_2)
        self.verticalLayout_5.setObjectName("verticalLayout_5")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.horizontalLayout_13 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_13.setObjectName("horizontalLayout_13")
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.label_4 = QtWidgets.QLabel(self.tab_2)
        self.label_4.setObjectName("label_4")
        self.horizontalLayout_3.addWidget(self.label_4)
        self.bookid = QtWidgets.QLineEdit(self.tab_2)
        self.bookid.setObjectName("bookid")
        self.horizontalLayout_3.addWidget(self.bookid)

5:科研人员模块 实现了登录后的科研人员界面及科研的各个ca


1666355132118.jpg

import pymysql
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QTableWidgetItem,QMessageBox
from connect import *
from PyQt5 import QtCore, QtGui, QtWidgets
cursor,conn=connect()
class Ui_systemadmin(object):
    def __init__(self):
        self.conn = None
    def setupUi(self, systemadmin):
        systemadmin.setObjectName("systemadmin")
        systemadmin.resize(738, 747)
        self.tabWidget = QtWidgets.QTabWidget(systemadmin)
        self.tabWidget.setGeometry(QtCore.QRect(9, 9, 721, 731))
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.widget = QtWidgets.QWidget(self.tab)
        self.widget.setGeometry(QtCore.QRect(10, 10, 701, 691))
        self.widget.setObjectName("widget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.widget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout_7 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_7.setObjectName("horizontalLayout_7")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label = QtWidgets.QLabel(self.widget)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        self.readerid = QtWidgets.QLineEdit(self.widget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.readerid.sizePolicy().hasHeightForWidth())
        self.readerid.setSizePolicy(sizePolicy)
        self.readerid.setObjectName("readerid")
        self.horizontalLayout.addWidget(self.readerid)
        self.horizontalLayout_7.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.label_2 = QtWidgets.QLabel(self.widget)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout_2.addWidget(self.label_2)
        self.readname = QtWidgets.QLineEdit(self.widget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.readname.sizePolicy().hasHeightForWidth())
        self.readname.setSizePolicy(sizePolicy)
        self.readname.setObjectName("readname")
        self.horizontalLayout_2.addWidget(self.readname)
        self.horizontalLayout_7.addLayout(self.horizontalLayout_2)
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.label_4 = QtWidgets.QLabel(self.widget)
        self.label_4.setObjectName("label_4")
        self.horizontalLayout_5.addWidget(self.label_4)
        self.unit = QtWidgets.QComboBox(self.widget)
        self.unit.setObjectName("unit")
        self.unit.addItem("")
        self.unit.addItem("")
        self.unit.addItem("")
        self.unit.addItem("")
        self.horizontalLayout_5.addWidget(self.unit)
        self.horizontalLayout_7.addLayout(self.horizontalLayout_5)
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.label_3 = QtWidgets.QLabel(self.widget)
        self.label_3.setObjectName("label_3")
        self.horizontalLayout_4.addWidget(self.label_3)
        self.sex = QtWidgets.QComboBox(self.widget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sex.sizePolicy().hasHeightForWidth())
        self.sex.setSizePolicy(sizePolicy)
        self.sex.setObjectName("sex")
        self.sex.addItem("")
        self.sex.addItem("")
        self.horizontalLayout_4.addWidget(self.sex)
        self.horizontalLayout_7.addLayout(self.horizontalLayout_4)
        self.verticalLayout.addLayout(self.horizontalLayout_7)
        self.horizontalLayout_13 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_13.setObjectName("horizontalLayout_13")
        self.horizontalLayout_9 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_9.setObjectName("horizontalLayout_9")
        self.label_6 = QtWidgets.QLabel(self.widget)
        self.label_6.setObjectName("label_6")
        self.horizontalLayout_9.addWidget(self.label_6)
        self.readtype = QtWidgets.QComboBox(self.widget)
        self.readtype.setObjectName("readtype")
        self.readtype.addItem("")
        self.readtype.addItem("")
        self.readtype.addItem("")
        self.horizontalLayout_9.addWidget(self.readtype)
        self.horizontalLayout_13.addLayout(self.horizontalLayout_9)
        self.horizontalLayout_10 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_10.setObjectName("horizontalLayout_10")
        self.label_7 = QtWidgets.QLabel(self.widget)
        self.label_7.setObjectName("label_7")
        self.horizontalLayout_10.addWidget(self.label_7)
        self.totalnumber = QtWidgets.QLineEdit(self.widget)
        self.totalnumber.setObjectName("totalnumber")
        self.horizontalLayout_10.addWidget(self.totalnumber)
        self.horizontalLayout_13.addLayout(self.horizontalLayout_10)
        self.horizontalLayout_11 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_11.setObjectName("horizontalLayout_11")
        self.label_8 = QtWidgets.QLabel(self.widget)
        self.label_8.setObjectName("label_8")
        self.horizontalLayout_11.addWidget(self.label_8)
        self.number = QtWidgets.QLineEdit(self.widget)
        self.number.setObjectName("number")
        self.horizontalLayout_11.addWidget(self.number)
        self.horizontalLayout_13.addLayout(self.horizontalLayout_11)
        self.horizontalLayout_12 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_12.setObjectName("horizontalLayout_12")
        self.label_9 = QtWidgets.QLabel(self.widget)
        self.label_9.setObjectName("label_9")
        self.horizontalLayout_12.addWidget(self.label_9)
        self.money = QtWidgets.QLineEdit(self.widget)
        self.money.setObjectName("money")
        self.horizontalLayout_12.addWidget(self.money)
        self.horizontalLayout_13.addLayout(self.horizontalLayout_12)
        self.verticalLayout.addLayout(self.horizontalLayout_13)
        self.horizontalLayout_8 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_8.setObjectName("horizontalLayout_8")
        self.addr = QtWidgets.QPushButton(self.widget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.addr.sizePolicy().hasHeightForWidth())
        self.addr.setSizePolicy(sizePolicy)
        self.addr.setObjectName("addr")
        self.horizontalLayout_8.addWidget(self.addr)
        self.alterr = QtWidgets.QPushButton(self.widget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.alterr.sizePolicy().hasHeightForWidth())
        self.alterr.setSizePolicy(sizePolicy)
        self.alterr.setObjectName("alterr")
        self.horizontalLayout_8.addWidget(self.alterr)
        self.deleter = QtWidgets.QPushButton(self.widget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)

6:主函数模块 最后执行的模块 调用其他模块

import sys
import pymysql
import time
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow,QMessageBox
from login import Ui_Login
from secreatry import Ui_Reader
from connect import *
from repeople import Ui_systemadmin
from director import Ui_bookadmin
cursor,conn=connect()
class Readerui(QtWidgets.QMainWindow, Ui_Reader):
    def __init__(self, parent=None):
        super(Readerui,self).__init__(parent)
        self.setupUi(self)
class bookadminui(QtWidgets.QMainWindow,Ui_bookadmin):
    def __init__(self, parent=None):
       super(bookadminui, self).__init__(parent)
       self.setupUi(self)
class sysadminui(QtWidgets.QMainWindow,Ui_systemadmin):
    def __init__(self, parent=None):
        super(sysadminui, self).__init__(parent)
        self.setupUi(self)
class MyMainForm(QMainWindow, Ui_Login):
    def __init__(self, parent=None):
        super(MyMainForm, self).__init__(parent)
        self.setupUi(self)
        self.exitbt.clicked.connect(self.exit)
        self.loginbt.clicked.connect(self.login)
    def exit(self):    #退出
        rec_code=QMessageBox.question(self, "确认", "好好想想真的要退出吗??", QMessageBox.Yes | QMessageBox.No)
        if rec_code != 65536:
            self.close()
    def login(self):   #登陆
        ID=self.userline.text()
        PW=self.pwline.text()
        if ID=='' or PW=='':
            QMessageBox.warning(self, "警告", "用户名和密码都要输入噢!!!", QMessageBox.Yes)
        else:
            if self.idbox.currentText()=='秘书':
                type='秘书'
                sql = 'select * from secreatry where sename = "%s" and seworknum="%s" '%  (ID, PW)
                res = cursor.execute(sql)
                if res:
                    self.read = Readerui()
                    self.read.show()
                else:
                    QMessageBox.warning(self, "警告", "密码错误,请重新输入!", QMessageBox.Yes)
            elif self.idbox.currentText()=='主任':
                type='主任'
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
4天前
|
机器学习/深度学习 人工智能 算法
猫狗宠物识别系统Python+TensorFlow+人工智能+深度学习+卷积网络算法
宠物识别系统使用Python和TensorFlow搭建卷积神经网络,基于37种常见猫狗数据集训练高精度模型,并保存为h5格式。通过Django框架搭建Web平台,用户上传宠物图片即可识别其名称,提供便捷的宠物识别服务。
106 55
|
25天前
|
机器学习/深度学习 数据采集 供应链
使用Python实现智能食品安全追溯系统的深度学习模型
使用Python实现智能食品安全追溯系统的深度学习模型
54 4
|
14天前
|
机器学习/深度学习 人工智能 算法
【宠物识别系统】Python+卷积神经网络算法+深度学习+人工智能+TensorFlow+图像识别
宠物识别系统,本系统使用Python作为主要开发语言,基于TensorFlow搭建卷积神经网络算法,并收集了37种常见的猫狗宠物种类数据集【'阿比西尼亚猫(Abyssinian)', '孟加拉猫(Bengal)', '暹罗猫(Birman)', '孟买猫(Bombay)', '英国短毛猫(British Shorthair)', '埃及猫(Egyptian Mau)', '缅因猫(Maine Coon)', '波斯猫(Persian)', '布偶猫(Ragdoll)', '俄罗斯蓝猫(Russian Blue)', '暹罗猫(Siamese)', '斯芬克斯猫(Sphynx)', '美国斗牛犬
93 29
【宠物识别系统】Python+卷积神经网络算法+深度学习+人工智能+TensorFlow+图像识别
|
15天前
|
机器学习/深度学习 算法 前端开发
基于Python深度学习的果蔬识别系统实现
果蔬识别系统,主要开发语言为Python,基于TensorFlow搭建ResNet卷积神经网络算法模型,通过对12种常见的果蔬('土豆', '圣女果', '大白菜', '大葱', '梨', '胡萝卜', '芒果', '苹果', '西红柿', '韭菜', '香蕉', '黄瓜')图像数据集进行训练,最后得到一个识别精度较高的模型文件。再基于Django框架搭建Web网页端可视化操作界面,以下为项目实现介绍。
27 4
基于Python深度学习的果蔬识别系统实现
|
10天前
|
关系型数据库 MySQL 数据库
Python处理数据库:MySQL与SQLite详解 | python小知识
本文详细介绍了如何使用Python操作MySQL和SQLite数据库,包括安装必要的库、连接数据库、执行增删改查等基本操作,适合初学者快速上手。
78 15
|
1月前
|
弹性计算 数据管理 数据库
从零开始构建员工管理系统:Python与SQLite3的完美结合
本文介绍如何使用Python和Tkinter构建一个图形界面的员工管理系统(EMS)。系统包括数据库设计、核心功能实现和图形用户界面创建。主要功能有查询、添加、删除员工信息及统计员工数量。通过本文,你将学会如何结合SQLite数据库进行数据管理,并使用Tkinter创建友好的用户界面。
57 2
从零开始构建员工管理系统:Python与SQLite3的完美结合
|
28天前
|
Python
Python之音乐专辑管理系统
音乐专辑管理系统是一款用于管理和维护音乐专辑信息的应用程序,支持添加、删除、修改和查询专辑详情(如专辑名、艺术家、发行日期及曲目列表)。系统运行需Python 3.x环境,硬件要求较低,适合个人及小型团队使用。
51 4
|
28天前
|
数据库连接 Go 数据库
Go语言中的错误注入与防御编程。错误注入通过模拟网络故障、数据库错误等,测试系统稳定性
本文探讨了Go语言中的错误注入与防御编程。错误注入通过模拟网络故障、数据库错误等,测试系统稳定性;防御编程则强调在编码时考虑各种错误情况,确保程序健壮性。文章详细介绍了这两种技术在Go语言中的实现方法及其重要性,旨在提升软件质量和可靠性。
29 1
|
1月前
|
Python
Python实现摇号系统
本文介绍了如何使用Python构建一个简单的摇号系统,包括用户输入、随机抽取、结果展示和日志记录等功能。通过导入`random`、`datetime`和`logging`模块,实现了从参与者名单中随机抽取中奖者,并记录每次摇号的结果,方便后续查看和审计。完整代码示例提供了从功能实现到主程序调用的全过程。
35 2
|
1月前
|
机器学习/深度学习 人工智能 算法
基于Python深度学习的【垃圾识别系统】实现~TensorFlow+人工智能+算法网络
垃圾识别分类系统。本系统采用Python作为主要编程语言,通过收集了5种常见的垃圾数据集('塑料', '玻璃', '纸张', '纸板', '金属'),然后基于TensorFlow搭建卷积神经网络算法模型,通过对图像数据集进行多轮迭代训练,最后得到一个识别精度较高的模型文件。然后使用Django搭建Web网页端可视化操作界面,实现用户在网页端上传一张垃圾图片识别其名称。
78 0
基于Python深度学习的【垃圾识别系统】实现~TensorFlow+人工智能+算法网络