Main.pyimport sys
from PySide6.QtWidgets import QApplication,QMainWindow,QWidget,QDialog,QMessageBox
from PyQt6.QtCore import Qt,QDateTime
import Login
import MenuWindow
# import HSJCQueryWindow
import Dbconnect
# 创建Login类和HSJCQueryWindow类
# class HSJCQueryWindow(HSJCQueryWindow.Ui_MainWindow, QMainWindow):
# def __init__(self):
# super(HSJCQueryWindow, self).__init__()
# self.setupUi(self)
class MenuWindow(MenuWindow.Ui_MainWindow, QMainWindow):
def __init__(self):
super(MenuWindow, self).__init__()
self.setupUi(self)
class Login(Login.Ui_MainWindow, QMainWindow):
def __init__(self):
super(Login, self).__init__()
self.setupUi(self)
# 登录验证
def login_check():
username = login.UserNameEdit.text()
password = login.PasswordEdit.text()
message = QMessageBox(login)
#sql = "SELECT user_name,COMM.F_DESCRIPT(password) FROM staff_dict WHERE user_name = '{uname}' AND COMM.F_DESCRIPT(password) = '{pw}'".format(uname=username, pw=password)
sql = "SELECT hrp_user_name,COMM.F_DESCRIPT(password) FROM staff_dict WHERE hrp_user_name = '{uname}' ".format(uname=username)
Dbconnect.cursor.execute(sql)
results = Dbconnect.cursor.fetchall()
for r in results:
if (len(r[0])==None):
message = QMessageBox.warning(login, "注意", "用户名不正确请检查")
else:
if (r[1]==password):
menuwindow.show()
# menu.showFullScreen()
else:
message = QMessageBox.critical(login,'注意','用户名或密码错误')
if __name__ == '__main__':
app = QApplication(sys.argv)
window = QMainWindow()
# 为Login类和MenuWindow类实例化对象
login = Login()
menuwindow = MenuWindow()
# 显示登陆窗口
login.setupUi(window)
window.show()
# 将login_check函数与登录按钮绑定
login.LoginButton.clicked.connect(login_check)
app.exec()
sys.exit(app.exec())
|