山东大学数据库实验课设2019.12

   1 from PyQt5 import QtCore, QtGui, QtWidgets
   2 from dl import *
   3 from shoujiemian import *
   4 from dzdl import *
   5 from glydl import *
   6 from zc import *
   7 from dzzc import *
   8 from glyzc import *
   9 from dzdlcw import *
  10 from dzcz import *
  11 from dzxxcx import *
  12 from dzxgmm import *
  13 from xgmmsuccessful import *
  14 from xgmmfail import *
  15 from dzjs import *
  16 from jsxxcx import *
  17 from hsxxcx import *
  18 from dzzcsuccess import *
  19 from dzzcfail import *
  20 from glycz import *
  21 from jssuccess import *
  22 from jsfail import *
  23 from hssuccess import *
  24 from hsfail import *
  25 from pccz import *
  26 from wxskhhh import *
  27 from glydzxxcz import *
  28 from glyhsxxcz import *
  29 from glyjsxxcz import *
  30 from glypcxxcz import *
  31 from glysjcz import *
  32 from glyxgmm import *
  33 from dzxxscsuccess import *
  34 from dzxxscfail import *
  35 from tjsuccess import *
  36 from tjfail import *
  37 from pcfail import *
  38 from cqpc import *
  39 from xjcg import *
  40 from xjfail import *
  41 from unexpected import *
  42 import pymysql,sys,re
  43 from PyQt5.QtCore import QDate, QTime, QDateTime, Qt
  44 from PyQt5.QtWidgets import (QFrame,QApplication,QDialog, QDialogButtonBox,
  45         QMessageBox,QVBoxLayout, QLineEdit,QTableWidgetItem,QTableWidget,QHBoxLayout)
  46 
  47 global dzid,glyid
  48 
  49 def ok(num):
  50     pattern = re.compile(r'^[-+]?[-0-9]\d*\.\d*|[-+]?\.?[0-9]\d*$')
  51     result = pattern.match(num)
  52     if result:
  53         return True
  54     else:
  55         return False
  56 
  57 class Ui_Dialog(QtWidgets.QDialog, Ui_2):
  58     def __init__(self):
  59         super(Ui_Dialog, self).__init__()
  60         self.setupUi(self)
  61 
  62 class First(QtWidgets.QMainWindow,Ui_1):
  63     def __init__(self):
  64         super(First,self).__init__()
  65         self.setupUi(self)
  66 
  67 class Ui_dzdl(QtWidgets.QDialog, Ui_3):
  68     def __init__(self):
  69         super(Ui_dzdl, self).__init__()
  70         self.setupUi(self)
  71     def Clean(self):
  72         self.lineEdit.setText("")
  73         self.lineEdit_2.setText("")
  74     def get_word(self):
  75         global dzid
  76         dzid = self.lineEdit.text()
  77         dzpassword = self.lineEdit_2.text()
  78         dzcount=cur.execute("SELECT * FROM 读者信息 where Reader_id='%s' and Password='%s';" % (dzid,dzpassword))
  79         if dzcount!=0:
  80             dzd.hide()
  81             dzcz.show()
  82             dzcz.pushButton.clicked.connect(dzcz.hide)
  83             dzcz.pushButton.clicked.connect(dzxxcx.dzxxcxshow)
  84             dzcz.pushButton.clicked.connect(dzxxcx.show)#从读者操作界面进入读者信息查询界面
  85 
  86             dzcz.pushButton_2.clicked.connect(dzcz.hide)
  87             dzcz.pushButton_2.clicked.connect(dzxgmm.show)#从读者操作界面进入到修改密码界面
  88 
  89             dzxgmm.pushButton_3.clicked.connect(dzxgmm.get_word)#调用get_word函数
  90 
  91             dzxgmm.pushButton.clicked.connect(dzxgmm.hide)
  92             dzxgmm.pushButton.clicked.connect(dzxgmm.Clean)
  93             dzxgmm.pushButton.clicked.connect(dzcz.show)  # 从读者操作界面返回到登录界面
  94 
  95             dzjs.pushButton.clicked.connect(dzjs.dimquery)#调用模糊查询函数
  96 
  97             dzjs.pushButton_6.clicked.connect(dzjs.exactquery)  # 调用精准查询函数
  98 
  99             dzjs.pushButton_2.clicked.connect(dzjs.borrowbook)  # 调用借书函数
 100 
 101             dzjs.pushButton_5.clicked.connect(dzjs.returnbook)  # 调用还书函数
 102 
 103             dzjs.pushButton_7.clicked.connect(dzjs.renew)  # 调用续借函数
 104 
 105             dzcz.pushButton_3.clicked.connect(dzcz.hide)
 106             dzcz.pushButton_3.clicked.connect(dzjs.show)  # 从读者操作界面进入到借书操作界面
 107 
 108             dzjs.pushButton_3.clicked.connect(dzjs.hide)
 109             dzjs.pushButton_3.clicked.connect(dzjs.Clean)
 110             dzjs.pushButton_3.clicked.connect(dzcz.show)  # 从借书操作界面返回到读者操作界面
 111 
 112             dzcz.pushButton_9.clicked.connect(dzd.Clean)
 113             dzcz.pushButton_9.clicked.connect(dzcz.hide)
 114             dzcz.pushButton_9.clicked.connect(dzd.show)  # 从读者操作界面返回到登录界面
 115 
 116             dzcz.pushButton_5.clicked.connect(dzcz.hide)
 117             dzcz.pushButton_5.clicked.connect(jsxxcx.jsxxcxshow)
 118             dzcz.pushButton_5.clicked.connect(jsxxcx.show)#从读者操作界面进入到借书信息查询界面
 119 
 120             dzcz.pushButton_6.clicked.connect(dzcz.hide)
 121             dzcz.pushButton_6.clicked.connect(hsxxcx.hsxxcxshow)
 122             dzcz.pushButton_6.clicked.connect(hsxxcx.show)#从读者操作界面进入到还书信息查询界面
 123 
 124             dzcz.pushButton_7.clicked.connect(dzcz.hide)
 125             dzcz.pushButton_7.clicked.connect(pccz.show)  # 从读者操作界面进入到赔偿操作界面
 126 
 127             pccz.pushButton_4.clicked.connect(pccz.dimquery)#模糊查询
 128 
 129             pccz.pushButton_5.clicked.connect(pccz.exactquery)#精准查询
 130 
 131             pccz.pushButton_3.clicked.connect(pccz.pay) #调用赔偿函数
 132 
 133             jsxxcx.pushButton.clicked.connect(jsxxcx.hide)
 134             jsxxcx.pushButton.clicked.connect(dzcz.show)#从借书信息查询界面回到读者操作界面
 135 
 136             hsxxcx.pushButton.clicked.connect(hsxxcx.hide)
 137             hsxxcx.pushButton.clicked.connect(dzcz.show)#从还书信息查询界面回到读者操作界面
 138 
 139             dzxxcx.pushButton.clicked.connect(dzxxcx.hide)
 140             dzxxcx.pushButton.clicked.connect(dzcz.show)#从读者信息查询界面回到读者操作界面
 141 
 142             pccz.pushButton.clicked.connect(pccz.hide)
 143             pccz.pushButton.clicked.connect(pccz.Clean)
 144             pccz.pushButton.clicked.connect(dzcz.show)  # 从赔偿操作界面回到读者操作界面
 145         else:
 146             dzdlcw.show()
 147 
 148 class Ui_glydl(QtWidgets.QDialog, Ui_4):
 149     def __init__(self):
 150         super(Ui_glydl, self).__init__()
 151         self.setupUi(self)
 152     def Clean(self):
 153         self.lineEdit.setText("")
 154         self.lineEdit_2.setText("")
 155     def get_word(self):
 156         global glyid
 157         glyid = self.lineEdit.text()
 158         glypassword = self.lineEdit_2.text()
 159         glycount=cur.execute("SELECT * FROM 管理员 where Admin_id='%s' and Password='%s';" % (glyid,glypassword))
 160         if glycount != 0:
 161 
 162             glyd.hide()
 163             glycz.show()
 164 
 165             self.lineEdit.setText("")
 166             self.lineEdit_2.setText("")
 167 
 168             glycz.pushButton.clicked.connect(glycz.hide)
 169             glycz.pushButton.clicked.connect(glydzxxcz.show)  # 从管理员操作界面进入管理员读者信息操作界面
 170 
 171             glydzxxcz.pushButton_3.clicked.connect(glydzxxcz.hide)
 172             glydzxxcz.pushButton_3.clicked.connect(glydzxxcz.Clean)
 173             glydzxxcz.pushButton_3.clicked.connect(glycz.show)  # 从管理员读者信息操作界面进入管理员操作界面
 174 
 175             glydzxxcz.pushButton.clicked.connect(glydzxxcz.dimquery) #读者信息模糊查询
 176 
 177             glydzxxcz.pushButton_5.clicked.connect(glydzxxcz.exactquery) #读者信息精准查询
 178 
 179             glydzxxcz.pushButton_2.clicked.connect(glydzxxcz.Delete) #读者信息删除
 180 
 181             glycz.pushButton_2.clicked.connect(glycz.hide)
 182             glycz.pushButton_2.clicked.connect(glyxgmm.show)  # 从管理员操作界面进入管理员修改密码界面
 183 
 184             glyxgmm.pushButton_3.clicked.connect(glyxgmm.xgmm)  # 调用修改密码函数
 185 
 186             glyxgmm.pushButton.clicked.connect(glyxgmm.hide)
 187             glyxgmm.pushButton.clicked.connect(glyxgmm.Clean)
 188             glyxgmm.pushButton.clicked.connect(glycz.show)# 从管理员修改密码界面返回管理员操作界面
 189 
 190             glycz.pushButton_5.clicked.connect(glycz.hide)
 191             glycz.pushButton_5.clicked.connect(glysjcz.show)  # 从管理员操作界面进入管理员书籍操作界面
 192 
 193             glysjcz.pushButton.clicked.connect(glysjcz.dimquery)#模糊查询
 194 
 195             glysjcz.pushButton_2.clicked.connect(glysjcz.exactquery)#精确查询
 196 
 197             glysjcz.pushButton_3.clicked.connect(glysjcz.add)#添加书籍
 198 
 199             glysjcz.pushButton_6.clicked.connect(glysjcz.Delete)#删除书籍
 200 
 201             glysjcz.pushButton_4.clicked.connect(glysjcz.hide)
 202             glysjcz.pushButton_4.clicked.connect(glysjcz.Clean)
 203             glysjcz.pushButton_4.clicked.connect(glycz.show)  # 从管理员书籍操作界面返回管理员操作界面
 204 
 205             glycz.pushButton_7.clicked.connect(glycz.hide)
 206             glycz.pushButton_7.clicked.connect(glypcxxcz.show)  # 从管理员操作界面进入管理员赔偿信息查询界面
 207 
 208             glypcxxcz.pushButton_3.clicked.connect(glypcxxcz.dimquery)#模糊查询
 209 
 210             glypcxxcz.pushButton_4.clicked.connect(glypcxxcz.exactquery)#精确查询
 211 
 212             glypcxxcz.pushButton.clicked.connect(glypcxxcz.hide)
 213             glypcxxcz.pushButton.clicked.connect(glypcxxcz.Clean)
 214             glypcxxcz.pushButton.clicked.connect(glycz.show)  # 从管理员赔偿信息查询界面返回管理员操作界面
 215 
 216             glycz.pushButton_6.clicked.connect(glycz.hide)
 217             glycz.pushButton_6.clicked.connect(glyjsxxcz.show)  # 从管理员操作界面进入管理员借书信息查询界面
 218 
 219             glyjsxxcz.pushButton.clicked.connect(glyjsxxcz.dimquery)#模糊查询
 220 
 221             glyjsxxcz.pushButton_2.clicked.connect(glyjsxxcz.exactquery)#精确查询
 222 
 223             glyjsxxcz.pushButton_3.clicked.connect(glyjsxxcz.hide)
 224             glyjsxxcz.pushButton_3.clicked.connect(glyjsxxcz.Clean)
 225             glyjsxxcz.pushButton_3.clicked.connect(glycz.show)  # 从管理员借书信息查询界面返回管理员操作界面
 226 
 227             glycz.pushButton_8.clicked.connect(glycz.hide)
 228             glycz.pushButton_8.clicked.connect(glyhsxxcz.show)  # 从管理员操作界面进入管理员还书信息查询界面
 229 
 230             glyhsxxcz.pushButton.clicked.connect(glyhsxxcz.dimquery)  # 模糊查询
 231 
 232             glyhsxxcz.pushButton_2.clicked.connect(glyhsxxcz.exactquery)  # 精确查询
 233 
 234             glyhsxxcz.pushButton_3.clicked.connect(glyhsxxcz.hide)
 235             glyhsxxcz.pushButton_3.clicked.connect(glyhsxxcz.Clean)
 236             glyhsxxcz.pushButton_3.clicked.connect(glycz.show) # 从管理员还书信息查询界面返回管理员操作界面
 237 
 238             glycz.pushButton_3.clicked.connect(glycz.hide)
 239             glycz.pushButton_3.clicked.connect(glyd.show)  # 从管理员操作界面进入管理员登陆界面
 240 
 241             glycz.pushButton_9.clicked.connect(glycz.hide)
 242             glycz.pushButton_9.clicked.connect(unexpected.show)  # 从管理员操作界面进入意外处理界面
 243 
 244             unexpected.pushButton.clicked.connect(unexpected.hide)
 245             unexpected.pushButton.clicked.connect(glycz.show)  # 从意外处理界面进入管理员操作界面
 246 
 247             unexpected.pushButton_3.clicked.connect(unexpected.add)#调用添加函数
 248             unexpected.pushButton.clicked.connect(unexpected.Clean)  # 调用清空函数
 249         else:
 250             dzdlcw.show()
 251 
 252 
 253 class Ui_zc(QtWidgets.QDialog, Ui_5):
 254     def __init__(self):
 255         super(Ui_zc, self).__init__()
 256         self.setupUi(self)
 257 
 258 class Ui_dzzc(QtWidgets.QDialog, Ui_6):
 259     def __init__(self):
 260         super(Ui_dzzc, self).__init__()
 261         self.setupUi(self)
 262     def Clean(self):
 263         self.lineEdit.setText("")
 264         self.lineEdit_2.setText("")
 265         self.lineEdit_3.setText("")
 266         self.lineEdit_4.setText("")
 267     def get_word(self):
 268         dzname = self.lineEdit.text()
 269         dzid = self.lineEdit_2.text()
 270         pw = self.lineEdit_3.text()
 271         sex = self.lineEdit_4.text()
 272         count = cur.execute("SELECT * FROM 读者信息 where reader_id='%s';" % (dzid))
 273         if count==0:
 274             if dzname!=""and dzid !="" and pw!="" and sex!="":
 275                 if sex!="" and sex!="":
 276                     sex="未知"
 277                 cur.execute("INSERT INTO 读者信息 values('%s','%s','%s','%s',0,null,null)" % (dzname,dzid,pw,sex))
 278                 conn.commit()
 279                 dzzcsuccess.show()
 280                 self.lineEdit.setText("")
 281                 self.lineEdit_2.setText("")
 282                 self.lineEdit_3.setText("")
 283                 self.lineEdit_4.setText("")
 284             else:
 285                 dzzcfail.show()
 286         else:
 287              dzzcfail.show()
 288 
 289 class Ui_glyzc(QtWidgets.QDialog, Ui_7):
 290     def __init__(self):
 291         super(Ui_glyzc, self).__init__()
 292         self.setupUi(self)
 293     def Clean(self):
 294         self.lineEdit.setText("")
 295         self.lineEdit_2.setText("")
 296         self.lineEdit_3.setText("")
 297     def get_word(self):
 298         glyname = self.lineEdit.text()
 299         glyid = self.lineEdit_2.text()
 300         pw = self.lineEdit_3.text()
 301         count = cur.execute("SELECT * FROM 管理员 where admin_id='%s';" % (glyid))
 302         if glyname!="" and glyid!="" and pw!="":
 303             if count==0:
 304                 if glyname!=""and glyid !="" and pw!="":
 305                     cur.execute("INSERT INTO 管理员 values('%s','%s','%s')" % (glyname,glyid,pw))
 306                     conn.commit()
 307                     self.lineEdit.setText("")
 308                     self.lineEdit_2.setText("")
 309                     self.lineEdit_3.setText("")
 310                     dzzcsuccess.show()
 311                 else:
 312                     dzzcfail.show()
 313             else:
 314                 dzzcfail.show()
 315 
 316 class Ui_dzdlcw(QtWidgets.QDialog, Ui_8):
 317     def __init__(self):
 318         super(Ui_dzdlcw, self).__init__()
 319         self.setupUi(self)
 320 
 321 class Ui_dzcz(QtWidgets.QDialog, Ui_9):
 322     def __init__(self):
 323         super(Ui_dzcz, self).__init__()
 324         self.setupUi(self)
 325 
 326 class Ui_dzxxcx(QtWidgets.QDialog, Ui_10):
 327     def __init__(self):
 328         super(Ui_dzxxcx, self).__init__()
 329         self.setupUi(self)
 330     def dzxxcxshow(self):
 331         global dzid
 332         cur.execute("SELECT * FROM 读者信息 where Reader_id = '%s';" % (dzid))
 333         data=cur.fetchall()
 334         row=len(data)
 335         vol=len(data[0])
 336         self.tableWidget.setRowCount(row)
 337         self.tableWidget.setColumnCount(vol)
 338         for i in range(row):
 339             for j in range(vol):
 340                 temp_data=data[i][j]
 341                 data1=QTableWidgetItem(str(temp_data))
 342                 self.tableWidget.setItem(i,j,data1)
 343 
 344 class Ui_dzxgmm(QtWidgets.QDialog, Ui_11):
 345     def __init__(self):
 346         super(Ui_dzxgmm, self).__init__()
 347         self.setupUi(self)
 348     def Clean(self):
 349         self.lineEdit.setText("")
 350         self.lineEdit_2.setText("")
 351     def get_word(self):
 352         firstpw = self.lineEdit.text()
 353         secondpw = self.lineEdit_2.text()
 354         global dzid
 355         if  firstpw!="" and secondpw!="":
 356             if firstpw==secondpw and firstpw!="":
 357                 cur.execute("update 读者信息 set password = ('%s') where reader_id='%s'"% (firstpw,dzid))
 358                 conn.commit()
 359                 self.lineEdit.setText("")
 360                 self.lineEdit_2.setText("")
 361                 xgmmsuccessful.show()
 362             else:
 363                 print(firstpw)
 364                 print(secondpw)
 365                 print("hhh")
 366                 xgmmfail.show()
 367 
 368 
 369 class Ui_xgmmsuccessful(QtWidgets.QDialog, Ui_12):
 370     def __init__(self):
 371         super(Ui_xgmmsuccessful, self).__init__()
 372         self.setupUi(self)
 373 
 374 class Ui_xgmmfail(QtWidgets.QDialog, Ui_13):
 375     def __init__(self):
 376         super(Ui_xgmmfail, self).__init__()
 377         self.setupUi(self)
 378 
 379 class Ui_dzjs(QtWidgets.QDialog, Ui_14):
 380     def __init__(self):
 381         super(Ui_dzjs, self).__init__()
 382         self.setupUi(self)
 383     def Clean(self):
 384         self.lineEdit.setText("")
 385         self.lineEdit_2.setText("")
 386         self.lineEdit_3.setText("")
 387         self.lineEdit_4.setText("")
 388         self.tableWidget.setRowCount(0)
 389         self.tableWidget.setColumnCount(0)
 390         self.tableWidget.setHorizontalHeaderLabels(['书名', '索书号', '类型', '价格', '是否可借'])
 391     def dimquery(self):
 392         bookname = self.lineEdit.text()
 393         bookid = self.lineEdit_2.text()
 394         Type = self.lineEdit_3.text()
 395         money = self.lineEdit_4.text()
 396         if ok(money) == False:
 397             sjcount = cur.execute(
 398                 "SELECT * FROM 书籍信息 where Book_id='%s' or book_name='%s' or Type = '%s'" % (
 399                     bookid, bookname, Type))
 400         else:
 401             sjcount = cur.execute(
 402                 "SELECT * FROM 书籍信息 where Book_id='%s' or book_name='%s' or Type = '%s' or money='%f'" % (
 403                 bookid, bookname, Type, float(money)))
 404         if bookname == "" and bookid == "" and Type == "" and money == "":
 405             sjcount = cur.execute("SELECT * FROM 书籍信息")
 406         if sjcount != 0:
 407             data = cur.fetchall()
 408             row = len(data)
 409             vol = len(data[0])
 410             self.tableWidget.setRowCount(row)
 411             self.tableWidget.setColumnCount(vol)
 412             self.tableWidget.setHorizontalHeaderLabels(['书名', '索书号', '类型', '价格', '是否可借'])
 413             for i in range(row):
 414                 for j in range(vol):
 415                     temp_data = data[i][j]
 416                     data1 = QTableWidgetItem(str(temp_data))
 417                     self.tableWidget.setItem(i, j, data1)
 418         else:
 419             self.tableWidget.setRowCount(0)
 420             self.tableWidget.setColumnCount(0)
 421 
 422     def exactquery(self):
 423         bookname = self.lineEdit.text()
 424         bookid = self.lineEdit_2.text()
 425         Type =  self.lineEdit_3.text()
 426         money= self.lineEdit_4.text()
 427         if ok(money)==False:
 428             sjcount = cur.execute(
 429                 "SELECT * FROM 书籍信息 where Book_id='%s' and book_name='%s' and Type = '%s'" % (
 430                 bookid, bookname, Type))
 431         else:
 432             sjcount=cur.execute("SELECT * FROM 书籍信息 where Book_id='%s' and book_name='%s' and Type = '%s' and money='%f'" % (bookid,bookname,Type,float(money)))
 433         if sjcount!=0:
 434             data = cur.fetchall()
 435             row = len(data)
 436             vol = len(data[0])
 437             self.tableWidget.setRowCount(row)
 438             self.tableWidget.setColumnCount(vol)
 439             self.tableWidget.setHorizontalHeaderLabels(['书名', '索书号', '类型', '价格', '是否可借'])
 440             for i in range(row):
 441                 for j in range(vol):
 442                     temp_data = data[i][j]
 443                     data1 = QTableWidgetItem(str(temp_data))
 444                     self.tableWidget.setItem(i, j, data1)
 445         else:
 446             self.tableWidget.setRowCount(0)
 447             self.tableWidget.setColumnCount(0)
 448 
 449     def borrowbook(self):
 450         bookname = self.lineEdit.text()
 451         bookid = self.lineEdit_2.text()
 452         Type = self.lineEdit_3.text()
 453         money = self.lineEdit_4.text()
 454         if ok(money) == False:
 455             sjcount = cur.execute(
 456                 "SELECT * FROM 书籍信息 where Book_id='%s' and book_name='%s' and Type = '%s'" % (
 457                     bookid, bookname, Type))
 458         else:
 459             sjcount = cur.execute(
 460                 "SELECT * FROM 书籍信息 where Book_id='%s' and book_name='%s' and Type = '%s' and money='%f'" % (
 461                 bookid, bookname, Type, float(money)))
 462         if bookname != "" and bookid != "" and Type != "" and money != "":
 463             if sjcount==1:
 464                 data = cur.fetchall()
 465                 now = QDateTime.currentDateTime()
 466                 temp_data = data[0][4]
 467                 if temp_data == "可借":
 468                     jssuccess.show()
 469                     Key = '不可借'
 470                     global dzid
 471                     cur.execute("update 书籍信息 set state=('%s') where book_id = '%s'" % (Key, bookid))
 472                     conn.commit()
 473                     cur.execute("update 读者信息 set number=(number+1) where reader_id = '%s'" % (dzid))
 474                     conn.commit()
 475                     cur.execute("insert into 借书信息 values('%s','%s','%s','%s',6,'未归还')" % (
 476                     bookname, bookid, dzid, now.toString(Qt.ISODate)))
 477                     conn.commit()
 478                 else:
 479                      jsfail.show()
 480             else:
 481                 jsfail.show()
 482 
 483     def returnbook(self):
 484         bookname = self.lineEdit.text()
 485         bookid = self.lineEdit_2.text()
 486         Type = self.lineEdit_3.text()
 487         money = self.lineEdit_4.text()
 488         global dzid
 489         jscount=cur.execute("SELECT * FROM 借书信息 where Book_id='%s' and reader_id='%s' and state='未归还'" % (bookid,dzid))
 490         now = QDateTime.currentDateTime()
 491         if bookname!="" and bookid!="" and Type!="" and money!="":
 492             if jscount==1:
 493                 key = "可借"
 494                 cur.execute("update 书籍信息 set state=('%s') where book_id = '%s'" % (key,bookid))
 495                 conn.commit()
 496                 cur.execute("select * from 借书信息 where book_id = '%s' and reader_id='%s'" % (bookid,dzid))
 497                 data=cur.fetchall()
 498                 row=len(data)
 499                 Starttime=QDateTime.fromString(data[row-1][3],"yyyy-MM-ddThh:mm:ss")
 500                 difftime=float(Starttime.secsTo(now))
 501                 cur.execute("update 借书信息 set state=('已归还') where Book_id='%s' and reader_id='%s' and state='未归还'" % (bookid, dzid))
 502                 conn.commit()
 503                 if difftime>float(data[row-1][4]):#超期了
 504                     cur.execute("select * from 赔偿信息")
 505                     data1=cur.fetchall()
 506                     row1=len(data1)
 507                     row1=row1+1
 508                     cur.execute("select * from 读者信息 where reader_id='%s'" % (dzid))
 509                     data2=cur.fetchall()
 510                     readername=data2[0][0]
 511                     cur.execute(
 512                         "insert into 赔偿信息 values('%s','%s','%s','%s','%s','超期','%f','%s','未支付')" % (str(row1),readername,dzid,bookname,bookid,difftime*0.1,now.toString(Qt.ISODate)))
 513                     conn.commit()
 514                     cur.execute("insert into 还书信息 values('%s','%s','%s','%s','超期')" % (bookname,bookid,dzid,now.toString(Qt.ISODate)))
 515                     conn.commit()
 516                     cur.execute("update 读者信息 set number=(number-1) where reader_id = '%s'" % (dzid))
 517                     conn.commit()
 518                     cqpc.show()
 519                 else:
 520                     cur.execute("insert into 还书信息 values('%s','%s','%s','%s','正常')" % (
 521                     bookname, bookid, dzid, now.toString(Qt.ISODate)))
 522                     conn.commit()
 523                     hssuccess.show()
 524             else:
 525                 hsfail.show()
 526 
 527     def renew(self):
 528         bookname = self.lineEdit.text()
 529         bookid = self.lineEdit_2.text()
 530         Type = self.lineEdit_3.text()
 531         money = self.lineEdit_4.text()
 532         global dzid
 533         jscount = cur.execute(
 534             "SELECT * FROM 借书信息 where Book_id='%s' and reader_id='%s' and state='未归还'" % (bookid, dzid))
 535         now = QDateTime.currentDateTime()
 536         if bookname!="" and bookid!="" and Type!="" and money!="":
 537             if jscount == 1:
 538                 cur.execute("select * from 借书信息 where book_id = '%s' and reader_id='%s'" % (bookid, dzid))
 539                 data = cur.fetchall()
 540                 row = len(data)
 541                 Starttime = QDateTime.fromString(data[row - 1][3], "yyyy-MM-ddThh:mm:ss")
 542                 difftime = float(Starttime.secsTo(now))
 543                 if difftime > float(data[row - 1][4]):  # 超期了
 544                     xjfail.show()
 545                 else:
 546                     cur.execute("update 借书信息 set time=(time+6) where Book_id='%s' and reader_id='%s' and state='未归还'" % (bookid, dzid))
 547                     conn.commit()
 548                     xjcg.show()
 549             else:
 550                 xjfail.show()
 551 
 552 class Ui_jsxxcx(QtWidgets.QDialog, Ui_15):
 553     def __init__(self):
 554         super(Ui_jsxxcx, self).__init__()
 555         self.setupUi(self)
 556     def jsxxcxshow(self):
 557         global dzid
 558         count=cur.execute("SELECT * FROM 借书信息 where Reader_id = '%s';" % (dzid))
 559         if count != 0:
 560             data = cur.fetchall()
 561             row = len(data)
 562             vol = len(data[0])
 563             self.tableWidget.setRowCount(row)
 564             self.tableWidget.setColumnCount(vol)
 565             for i in range(row):
 566                 for j in range(vol):
 567                     temp_data = data[i][j]
 568                     data1 = QTableWidgetItem(str(temp_data))
 569                     self.tableWidget.setItem(i, j, data1)
 570         else:
 571             self.tableWidget.setRowCount(0)
 572             self.tableWidget.setColumnCount(0)
 573             self.tableWidget.setHorizontalHeaderLabels(['书名','索书号','读者编号','借书日期','借书时限'])
 574 
 575 class Ui_hsxxcx(QtWidgets.QDialog, Ui_16):
 576     def __init__(self):
 577         super(Ui_hsxxcx, self).__init__()
 578         self.setupUi(self)
 579     def hsxxcxshow(self):
 580         global dzid
 581         count=cur.execute("SELECT * FROM 还书信息 where Reader_id = '%s';" % (dzid))
 582         if count != 0:
 583             data = cur.fetchall()
 584             row = len(data)
 585             vol = len(data[0])
 586             self.tableWidget.setRowCount(row)
 587             self.tableWidget.setColumnCount(vol)
 588             for i in range(row):
 589                 for j in range(vol):
 590                     temp_data = data[i][j]
 591                     data1 = QTableWidgetItem(str(temp_data))
 592                     self.tableWidget.setItem(i, j, data1)
 593         else:
 594             self.tableWidget.setRowCount(0)
 595             self.tableWidget.setColumnCount(0)
 596             self.tableWidget.setHorizontalHeaderLabels(['书名', '索书号', '读者编号', '还书时间'])
 597 
 598 class Ui_dzzcsuccess(QtWidgets.QDialog, Ui_18):
 599     def __init__(self):
 600         super(Ui_dzzcsuccess, self).__init__()
 601         self.setupUi(self)
 602 
 603 class Ui_dzzcfail(QtWidgets.QDialog, Ui_19):
 604     def __init__(self):
 605         super(Ui_dzzcfail, self).__init__()
 606         self.setupUi(self)
 607 
 608 class Ui_glycz(QtWidgets.QDialog, Ui_20):
 609     def __init__(self):
 610         super(Ui_glycz, self).__init__()
 611         self.setupUi(self)
 612 
 613 class Ui_jssuccess(QtWidgets.QDialog, Ui_21):
 614     def __init__(self):
 615         super(Ui_jssuccess, self).__init__()
 616         self.setupUi(self)
 617 
 618 class Ui_jsfail(QtWidgets.QDialog, Ui_22):
 619     def __init__(self):
 620         super(Ui_jsfail, self).__init__()
 621         self.setupUi(self)
 622 
 623 class Ui_hssuccess(QtWidgets.QDialog, Ui_23):
 624     def __init__(self):
 625         super(Ui_hssuccess, self).__init__()
 626         self.setupUi(self)
 627 
 628 class Ui_hsfail(QtWidgets.QDialog, Ui_24):
 629     def __init__(self):
 630         super(Ui_hsfail, self).__init__()
 631         self.setupUi(self)
 632 
 633 class Ui_pccz(QtWidgets.QDialog, Ui_25):
 634     def __init__(self):
 635         super(Ui_pccz, self).__init__()
 636         self.setupUi(self)
 637     def Clean(self):
 638         self.lineEdit.setText("")
 639         self.lineEdit_2.setText("")
 640         self.lineEdit_3.setText("")
 641         self.lineEdit_4.setText("")
 642         self.tableWidget.setRowCount(0)
 643         self.tableWidget.setColumnCount(0)
 644         self.tableWidget.setHorizontalHeaderLabels(
 645             ['赔偿信息编号', '读者姓名', '读者编号', '书名', '索书号', '赔偿原因', '赔偿金额', '赔偿时间', '是否已支付'])
 646     def dimquery(self):
 647         pcxxid = self.lineEdit.text()
 648         pcreason = self.lineEdit_2.text()
 649         money = self.lineEdit_3.text()
 650         bookid = self.lineEdit_4.text()
 651         if bookid=="" and pcreason=="" and money=="" and pcxxid=="":
 652             global dzid
 653             count = cur.execute("SELECT * FROM 赔偿信息 where Reader_id = '%s';" % (dzid))
 654             self.tableWidget.setHorizontalHeaderLabels(
 655                 ['赔偿信息编号', '读者姓名', '读者编号', '书名', '索书号', '赔偿原因', '赔偿金额', '赔偿时间', '是否已支付'])
 656             if count != 0:
 657                 data = cur.fetchall()
 658                 row = len(data)
 659                 vol = len(data[0])
 660                 self.tableWidget.setRowCount(row)
 661                 self.tableWidget.setColumnCount(vol)
 662                 self.tableWidget.setHorizontalHeaderLabels(
 663                     ['赔偿信息编号', '读者姓名', '读者编号', '书名', '索书号', '赔偿原因', '赔偿金额', '赔偿时间', '是否已支付'])
 664                 for i in range(row):
 665                     for j in range(vol):
 666                         temp_data = data[i][j]
 667                         data1 = QTableWidgetItem(str(temp_data))
 668                         self.tableWidget.setItem(i, j, data1)
 669         else:
 670             if ok(money)==False:
 671                 count = cur.execute("SELECT * FROM 赔偿信息 where Reader_id = '%s' and (book_id='%s' or Reason='%s' or Pay_id='%s');" % (dzid,bookid,pcreason,pcxxid))
 672                 if count != 0:
 673                     data = cur.fetchall()
 674                     row = len(data)
 675                     vol = len(data[0])
 676                     self.tableWidget.setRowCount(row)
 677                     self.tableWidget.setColumnCount(vol)
 678                     self.tableWidget.setHorizontalHeaderLabels(['赔偿信息编号', '读者姓名', '读者编号', '书名', '索书号', '赔偿原因', '赔偿金额', '赔偿时间', '是否已支付'])
 679                     for i in range(row):
 680                         for j in range(vol):
 681                             temp_data = data[i][j]
 682                             data1 = QTableWidgetItem(str(temp_data))
 683                             self.tableWidget.setItem(i, j, data1)
 684                 else:
 685                     self.tableWidget.setRowCount(0)
 686                     self.tableWidget.setColumnCount(0)
 687             else:
 688                 count = cur.execute(
 689                     "SELECT * FROM 赔偿信息 where Reader_id = '%s' and (book_id='%s' or Reason='%s' or Pay_id='%s' or money='%f');" % (
 690                     dzid, bookid, pcreason, pcxxid,float(money)))
 691                 if count != 0:
 692                     data = cur.fetchall()
 693                     row = len(data)
 694                     vol = len(data[0])
 695                     self.tableWidget.setRowCount(row)
 696                     self.tableWidget.setColumnCount(vol)
 697                     self.tableWidget.setHorizontalHeaderLabels(['赔偿信息编号', '读者姓名', '读者编号', '书名', '索书号', '赔偿原因', '赔偿金额', '赔偿时间', '是否已支付'])
 698                     for i in range(row):
 699                         for j in range(vol):
 700                             temp_data = data[i][j]
 701                             data1 = QTableWidgetItem(str(temp_data))
 702                             self.tableWidget.setItem(i, j, data1)
 703 
 704                 else:
 705                     self.tableWidget.setRowCount(0)
 706                     self.tableWidget.setColumnCount(0)
 707 
 708     def exactquery(self):
 709         pcxxid = self.lineEdit.text()
 710         pcreason = self.lineEdit_2.text()
 711         money = self.lineEdit_3.text()
 712         bookid = self.lineEdit_4.text()
 713         if bookid != "" and pcreason != "" and pcxxid != "":
 714             if ok(money)==False:
 715                 count = cur.execute(
 716                     "SELECT * FROM 赔偿信息 where Reader_id = '%s' and book_id='%s' and Reason='%s' and Pay_id='%s';" % (
 717                     dzid, bookid, pcreason, pcxxid))
 718                 if count != 0:
 719                     data = cur.fetchall()
 720                     row = len(data)
 721                     vol = len(data[0])
 722                     self.tableWidget.setRowCount(row)
 723                     self.tableWidget.setColumnCount(vol)
 724                     self.tableWidget.setHorizontalHeaderLabels(
 725                         ['赔偿信息编号', '读者姓名', '读者编号', '书名', '索书号', '赔偿原因', '赔偿金额', '赔偿时间', '是否已支付'])
 726                     for i in range(row):
 727                         for j in range(vol):
 728                             temp_data = data[i][j]
 729                             data1 = QTableWidgetItem(str(temp_data))
 730                             self.tableWidget.setItem(i, j, data1)
 731                 else:
 732                     self.tableWidget.setRowCount(0)
 733                     self.tableWidget.setColumnCount(0)
 734             else:
 735                 count = cur.execute(
 736                     "SELECT * FROM 赔偿信息 where Reader_id = '%s' and book_id='%s' and Reason='%s' and Pay_id='%s' and Money='%f';" % (
 737                         dzid, bookid, pcreason, pcxxid, float(money)))
 738                 if count != 0:
 739                     data = cur.fetchall()
 740                     row = len(data)
 741                     vol = len(data[0])
 742                     self.tableWidget.setRowCount(row)
 743                     self.tableWidget.setColumnCount(vol)
 744                     self.tableWidget.setHorizontalHeaderLabels(
 745                         ['赔偿信息编号', '读者姓名', '读者编号', '书名', '索书号', '赔偿原因', '赔偿金额', '赔偿时间', '是否已支付'])
 746                     for i in range(row):
 747                         for j in range(vol):
 748                             temp_data = data[i][j]
 749                             data1 = QTableWidgetItem(str(temp_data))
 750                             self.tableWidget.setItem(i, j, data1)
 751                 else:
 752                     self.tableWidget.setRowCount(0)
 753                     self.tableWidget.setColumnCount(0)
 754         else:
 755             self.tableWidget.setRowCount(0)
 756             self.tableWidget.setColumnCount(0)
 757             self.tableWidget.setHorizontalHeaderLabels(
 758                 ['赔偿信息编号', '读者姓名', '读者编号', '书名', '索书号', '赔偿原因', '赔偿金额', '赔偿时间', '是否已支付'])
 759 
 760     def pay(self):
 761         pcxxid = self.lineEdit.text()
 762         pcreason = self.lineEdit_2.text()
 763         money = self.lineEdit_3.text()
 764         bookid = self.lineEdit_4.text()
 765         pcxxid =pcxxid
 766         pcreason =pcreason
 767         money =money
 768         bookid =bookid
 769         now = QDateTime.currentDateTime()
 770         if bookid != "" and pcreason != "" and pcxxid != "" and money!="":
 771             if bookid != "" and pcreason != "" and pcxxid != "":
 772                 if ok(money)==False:
 773                     global dzid
 774                     count = cur.execute(
 775                         "SELECT * FROM 赔偿信息 where Reader_id = '%s' and book_id='%s' and Reason='%s' and Pay_id='%s';" % (
 776                         dzid, bookid, pcreason, pcxxid))
 777                     if count == 1:
 778                         data = cur.fetchall()
 779                         if data[0][8]=="未支付":
 780                             wxzfhhh.show()
 781                             cur.execute("update 赔偿信息 set state=('已支付') where Reader_id = '%s' and book_id='%s' and Reason='%s' and Pay_id='%s';" % (dzid, bookid, pcreason, pcxxid))
 782                             conn.commit()
 783                             cur.execute("update 赔偿信息 set date=('%s') where Reader_id = '%s' and book_id='%s' and Reason='%s' and Pay_id='%s';" % (now.toString(Qt.ISODate),dzid, bookid, pcreason, pcxxid))
 784                             conn.commit()
 785                         else:
 786                             pcfail.show()
 787                     else:
 788                         pcfail.show()
 789                 else:
 790                     count = cur.execute("SELECT * FROM 赔偿信息 where Reader_id = '%s' and book_id='%s' and Reason='%s' and Pay_id='%s' and Money='%f';" % (dzid, bookid, pcreason, pcxxid, float(money)))
 791                     if count == 1:
 792                         data = cur.fetchall()
 793                         if data[0][8] == "未支付":
 794                             wxzfhhh.show()
 795                             cur.execute("update 赔偿信息 set state=('已支付') where Reader_id = '%s' and book_id='%s' and Reason='%s' and Pay_id='%s' and Money='%f';" % (dzid, bookid, pcreason, pcxxid,float(money)))
 796                             conn.commit()
 797                             cur.execute(
 798                                 "update 赔偿信息 set date=('%s') where Reader_id = '%s' and book_id='%s' and Reason='%s' and Pay_id='%s' and Money='%f';" % (
 799                                 now.toString(Qt.ISODate), dzid, bookid, pcreason, pcxxid,float(money)))
 800                             conn.commit()
 801                         else:
 802                             pcfail.show()
 803                     else:
 804                         pcfail.show()
 805             else:
 806                 pcfail.show()
 807 
 808 class Ui_wxzfhhh(QtWidgets.QDialog, Ui_26):
 809     def __init__(self):
 810         super(Ui_wxzfhhh, self).__init__()
 811         self.setupUi(self)
 812 
 813 class Ui_glydzxxcz(QtWidgets.QDialog, Ui_27):
 814     def __init__(self):
 815         super(Ui_glydzxxcz, self).__init__()
 816         self.setupUi(self)
 817     def Clean(self):
 818         self.lineEdit.setText("")
 819         self.lineEdit_2.setText("")
 820         self.tableWidget.setRowCount(0)
 821         self.tableWidget.setColumnCount(0)
 822         self.tableWidget.setHorizontalHeaderLabels(['姓名', '读者编号', '密码', '性别', '借书数量', '借书日期', '还书日期'])
 823     def dimquery(self):
 824         readername = self.lineEdit.text()
 825         readerid = self.lineEdit_2.text()
 826         dzcount=cur.execute("select * from 读者信息 where reader_id = '%s' or reader_name = '%s'" % (readerid,readername))
 827         if readername=="" and readerid=="":
 828             dzcount = cur.execute("select * from 读者信息")
 829         if dzcount!=0:
 830             data = cur.fetchall()
 831             row = len(data)
 832             vol = len(data[0])
 833             self.tableWidget.setRowCount(row)
 834             self.tableWidget.setColumnCount(vol)
 835             self.tableWidget.setHorizontalHeaderLabels(['姓名', '读者编号', '密码', '性别', '借书数量','借书日期','还书日期'])
 836             for i in range(row):
 837                 for j in range(vol):
 838                     temp_data = data[i][j]
 839                     data1 = QTableWidgetItem(str(temp_data))
 840                     self.tableWidget.setItem(i, j, data1)
 841         else:
 842             self.tableWidget.setRowCount(0)
 843             self.tableWidget.setColumnCount(0)
 844 
 845 
 846     def exactquery(self):
 847         readername = self.lineEdit.text()
 848         readerid = self.lineEdit_2.text()
 849         dzcount = cur.execute(
 850             "select * from 读者信息 where reader_id = '%s' and reader_name = '%s'" % (readerid, readername))
 851         if dzcount != 0:
 852             data = cur.fetchall()
 853             row = len(data)
 854             vol = len(data[0])
 855             self.tableWidget.setRowCount(row)
 856             self.tableWidget.setColumnCount(vol)
 857             self.tableWidget.setHorizontalHeaderLabels(['姓名', '读者编号', '密码', '性别', '借书数量', '借书日期', '还书日期'])
 858             for i in range(row):
 859                 for j in range(vol):
 860                     temp_data = data[i][j]
 861                     data1 = QTableWidgetItem(str(temp_data))
 862                     self.tableWidget.setItem(i, j, data1)
 863         else:
 864             self.tableWidget.setRowCount(0)
 865             self.tableWidget.setColumnCount(0)
 866 
 867     def Delete(self):
 868         readername = self.lineEdit.text()
 869         readerid = self.lineEdit_2.text()
 870         dzcount = cur.execute(
 871             "select * from 读者信息 where reader_id = '%s' or reader_name = '%s'" % (readerid, readername))
 872         if dzcount == 1:
 873             cur.execute(
 874                 "delete from 读者信息 where reader_id = '%s' or reader_name = '%s'" % (readerid, readername))
 875             conn.commit()
 876             dzxxscsuccess.show()
 877         else:
 878             dzxxscfail.show()
 879 
 880 class Ui_glyhsxxcz(QtWidgets.QDialog, Ui_28):
 881     def __init__(self):
 882         super(Ui_glyhsxxcz, self).__init__()
 883         self.setupUi(self)
 884     def Clean(self):
 885         self.lineEdit.setText("")
 886         self.lineEdit_2.setText("")
 887         self.lineEdit_3.setText("")
 888         self.tableWidget.setRowCount(0)
 889         self.tableWidget.setColumnCount(0)
 890         self.tableWidget.setHorizontalHeaderLabels(['书名', '索书号', '读者编号', '还书时间'])
 891     def dimquery(self):
 892         bookname = self.lineEdit.text()
 893         bookid = self.lineEdit_2.text()
 894         readerid =  self.lineEdit_3.text()
 895         sjcount=cur.execute("SELECT * FROM 还书信息 where book_name='%s' or reader_id='%s' or book_id = '%s'" % (bookname,readerid,bookid))
 896         if bookname=="" and bookid=="" and readerid=="":
 897             sjcount = cur.execute("SELECT * FROM 还书信息")
 898         if sjcount!=0:
 899             data = cur.fetchall()
 900             row = len(data)
 901             vol = len(data[0])
 902             self.tableWidget.setRowCount(row)
 903             self.tableWidget.setColumnCount(vol)
 904             self.tableWidget.setHorizontalHeaderLabels(['书名','索书号','读者编号','还书时间'])
 905             for i in range(row):
 906                 for j in range(vol):
 907                     temp_data = data[i][j]
 908                     data1 = QTableWidgetItem(str(temp_data))
 909                     self.tableWidget.setItem(i, j, data1)
 910         else:
 911             self.tableWidget.setRowCount(0)
 912             self.tableWidget.setColumnCount(0)
 913     def exactquery(self):
 914         bookname = self.lineEdit.text()
 915         bookid = self.lineEdit_2.text()
 916         readerid =  self.lineEdit_3.text()
 917         sjcount=cur.execute("SELECT * FROM 还书信息 where book_name='%s' and reader_id='%s' and book_id = '%s'" % (bookname,readerid,bookid))
 918         if sjcount !=0:
 919             data = cur.fetchall()
 920             row = len(data)
 921             vol = len(data[0])
 922             self.tableWidget.setRowCount(row)
 923             self.tableWidget.setColumnCount(vol)
 924             self.tableWidget.setHorizontalHeaderLabels(['书名','索书号','读者编号','还书时间'])
 925             for i in range(row):
 926                 for j in range(vol):
 927                     temp_data = data[i][j]
 928                     data1 = QTableWidgetItem(str(temp_data))
 929                     self.tableWidget.setItem(i, j, data1)
 930         else:
 931             self.tableWidget.setRowCount(0)
 932             self.tableWidget.setColumnCount(0)
 933 
 934 class Ui_glyjsxxcz(QtWidgets.QDialog, Ui_29):
 935     def __init__(self):
 936         super(Ui_glyjsxxcz, self).__init__()
 937         self.setupUi(self)
 938     def Clean(self):
 939         self.lineEdit.setText("")
 940         self.lineEdit_2.setText("")
 941         self.lineEdit_3.setText("")
 942         self.tableWidget.setRowCount(0)
 943         self.tableWidget.setColumnCount(0)
 944         self.tableWidget.setHorizontalHeaderLabels(['书名','索书号','读者编号','借书日期','借书时限'])
 945     def dimquery(self):
 946         bookname = self.lineEdit.text()
 947         bookid = self.lineEdit_2.text()
 948         readerid =  self.lineEdit_3.text()
 949         sjcount=cur.execute("SELECT * FROM 借书信息 where book_name='%s' or reader_id='%s' or book_id = '%s'" % (bookname,readerid,bookid))
 950         if bookname=="" and bookid=="" and readerid=="":
 951             sjcount = cur.execute("SELECT * FROM 借书信息")
 952         if sjcount!=0:
 953             data = cur.fetchall()
 954             row = len(data)
 955             vol = len(data[0])
 956             self.tableWidget.setRowCount(row)
 957             self.tableWidget.setColumnCount(vol)
 958             self.tableWidget.setHorizontalHeaderLabels(['书名','索书号','读者编号','借书日期','借书时限'])
 959             for i in range(row):
 960                 for j in range(vol):
 961                     temp_data = data[i][j]
 962                     data1 = QTableWidgetItem(str(temp_data))
 963                     self.tableWidget.setItem(i, j, data1)
 964         else:
 965             self.tableWidget.setRowCount(0)
 966             self.tableWidget.setColumnCount(0)
 967     def exactquery(self):
 968         bookname = self.lineEdit.text()
 969         bookid = self.lineEdit_2.text()
 970         readerid = self.lineEdit_3.text()
 971         sjcount = cur.execute(
 972             "SELECT * FROM 借书信息 where book_name='%s' and reader_id='%s' and book_id = '%s'" % (
 973             bookname, readerid, bookid))
 974         if sjcount != 0:
 975             data = cur.fetchall()
 976             row = len(data)
 977             vol = len(data[0])
 978             self.tableWidget.setRowCount(row)
 979             self.tableWidget.setColumnCount(vol)
 980             self.tableWidget.setHorizontalHeaderLabels(['书名', '索书号', '读者编号', '借书日期', '借书时限'])
 981             for i in range(row):
 982                 for j in range(vol):
 983                     temp_data = data[i][j]
 984                     data1 = QTableWidgetItem(str(temp_data))
 985                     self.tableWidget.setItem(i, j, data1)
 986         else:
 987             self.tableWidget.setRowCount(0)
 988             self.tableWidget.setColumnCount(0)
 989 
 990 class Ui_glypcxxcz(QtWidgets.QDialog, Ui_30):
 991     def __init__(self):
 992         super(Ui_glypcxxcz, self).__init__()
 993         self.setupUi(self)
 994     def Clean(self):
 995         self.lineEdit.setText("")
 996         self.lineEdit_2.setText("")
 997         self.lineEdit_3.setText("")
 998         self.lineEdit_4.setText("")
 999         self.tableWidget.setRowCount(0)
1000         self.tableWidget.setColumnCount(0)
1001         self.tableWidget.setHorizontalHeaderLabels(['读者姓名', '读者编号', '书名', '索书号', '赔偿原因', '赔偿金额', '赔偿时间'])
1002 
1003     def dimquery(self):
1004         readername = self.lineEdit.text()
1005         readerid = self.lineEdit_2.text()
1006         bookid =  self.lineEdit_3.text()
1007         reason= self.lineEdit_4.text()
1008         sjcount=cur.execute("SELECT * FROM 赔偿信息 where reader_name='%s' or reader_id='%s' or book_id = '%s' or reason='%s'" % (readername,readerid,bookid,reason))
1009         if readername=="" and readerid=="" and bookid=="" and reason=="":
1010             sjcount = cur.execute("SELECT * FROM 赔偿信息")
1011         if sjcount!=0:
1012             data = cur.fetchall()
1013             row = len(data)
1014             vol = len(data[0])
1015             self.tableWidget.setRowCount(row)
1016             self.tableWidget.setColumnCount(vol)
1017             self.tableWidget.setHorizontalHeaderLabels(['读者姓名', '读者编号', '书名', '索书号', '赔偿原因','赔偿金额','赔偿时间'])
1018             for i in range(row):
1019                 for j in range(vol):
1020                     temp_data = data[i][j]
1021                     data1 = QTableWidgetItem(str(temp_data))
1022                     self.tableWidget.setItem(i, j, data1)
1023         else:
1024             self.tableWidget.setRowCount(0)
1025             self.tableWidget.setColumnCount(0)
1026 
1027     def exactquery(self):
1028         readername = self.lineEdit.text()
1029         readerid = self.lineEdit_2.text()
1030         bookid = self.lineEdit_3.text()
1031         reason = self.lineEdit_4.text()
1032         sjcount = cur.execute(
1033             "SELECT * FROM 赔偿信息 where reader_name='%s' and reader_id='%s' and book_id = '%s' and reason='%s'" % (
1034             readername, readerid, bookid, reason))
1035         if sjcount == 1:
1036             data = cur.fetchall()
1037             row = len(data)
1038             vol = len(data[0])
1039             self.tableWidget.setRowCount(row)
1040             self.tableWidget.setColumnCount(vol)
1041             self.tableWidget.setHorizontalHeaderLabels(['读者姓名', '读者编号', '书名', '索书号', '赔偿原因', '赔偿金额', '赔偿时间'])
1042             for i in range(row):
1043                 for j in range(vol):
1044                     temp_data = data[i][j]
1045                     data1 = QTableWidgetItem(str(temp_data))
1046                     self.tableWidget.setItem(i, j, data1)
1047         else:
1048             self.tableWidget.setRowCount(0)
1049             self.tableWidget.setColumnCount(0)
1050 
1051 class Ui_glysjcz(QtWidgets.QDialog, Ui_31):
1052     def __init__(self):
1053         super(Ui_glysjcz, self).__init__()
1054         self.setupUi(self)
1055     def Clean(self):
1056         self.lineEdit.setText("")
1057         self.lineEdit_2.setText("")
1058         self.lineEdit_3.setText("")
1059         self.lineEdit_4.setText("")
1060         self.tableWidget.setRowCount(0)
1061         self.tableWidget.setColumnCount(0)
1062         self.tableWidget.setHorizontalHeaderLabels(['书名', '索书号', '类型', '价格', '是否可借'])
1063     def dimquery(self):
1064         bookname = self.lineEdit.text()
1065         bookid = self.lineEdit_2.text()
1066         Type =  self.lineEdit_3.text()
1067         money= self.lineEdit_4.text()
1068         if ok(money)==False:
1069             sjcount = cur.execute(
1070                 "SELECT * FROM 书籍信息 where Book_id='%s' or book_name='%s' or Type = '%s'" % (
1071                 bookid, bookname, Type))
1072         else:
1073             sjcount=cur.execute("SELECT * FROM 书籍信息 where Book_id='%s' or book_name='%s' or Type = '%s' or money='%f'" % (bookid,bookname,Type,float(money)))
1074         if bookname=="" and bookid=="" and Type=="" and money=="":
1075             sjcount = cur.execute("SELECT * FROM 书籍信息")
1076         if sjcount!=0:
1077             data = cur.fetchall()
1078             row = len(data)
1079             vol = len(data[0])
1080             self.tableWidget.setRowCount(row)
1081             self.tableWidget.setColumnCount(vol)
1082             self.tableWidget.setHorizontalHeaderLabels(['书名', '索书号', '类型', '价格', '是否可借'])
1083             for i in range(row):
1084                 for j in range(vol):
1085                     temp_data = data[i][j]
1086                     data1 = QTableWidgetItem(str(temp_data))
1087                     self.tableWidget.setItem(i, j, data1)
1088         else:
1089             self.tableWidget.setRowCount(0)
1090             self.tableWidget.setColumnCount(0)
1091     def exactquery(self):
1092         bookname = self.lineEdit.text()
1093         bookid = self.lineEdit_2.text()
1094         Type =  self.lineEdit_3.text()
1095         money= self.lineEdit_4.text()
1096         if ok(money)==False:
1097             sjcount = cur.execute(
1098                 "SELECT * FROM 书籍信息 where Book_id='%s' and book_name='%s' and Type = '%s'" % (
1099                 bookid, bookname, Type))
1100         else:
1101             sjcount=cur.execute("SELECT * FROM 书籍信息 where Book_id='%s' and book_name='%s' and Type = '%s' and money='%f'" % (bookid,bookname,Type,float(money)))
1102         if sjcount!=0:
1103             data = cur.fetchall()
1104             row = len(data)
1105             vol = len(data[0])
1106             self.tableWidget.setRowCount(row)
1107             self.tableWidget.setColumnCount(vol)
1108             self.tableWidget.setHorizontalHeaderLabels(['书名', '索书号', '类型', '价格', '是否可借'])
1109             for i in range(row):
1110                 for j in range(vol):
1111                     temp_data = data[i][j]
1112                     data1 = QTableWidgetItem(str(temp_data))
1113                     self.tableWidget.setItem(i, j, data1)
1114         else:
1115             self.tableWidget.setRowCount(0)
1116             self.tableWidget.setColumnCount(0)
1117     def add(self):
1118         bookname = self.lineEdit.text()
1119         bookid = self.lineEdit_2.text()
1120         Type = self.lineEdit_3.text()
1121         money = self.lineEdit_4.text()
1122         count=cur.execute("SELECT * FROM 书籍信息 where book_id='%s';" % (bookid))
1123         if bookname!="" and bookid !="" and Type !="" and ok(money)==True and float(money)>=0 and count==0:
1124             cur.execute("insert into 书籍信息 values('%s','%s','%s','%s','可借')"%(bookname,bookid,Type,float(money)))
1125             conn.commit()
1126             tjsuccess.show()
1127         else:
1128             tjfail.show()
1129 
1130     def Delete(self):
1131         bookname = self.lineEdit.text()
1132         bookid = self.lineEdit_2.text()
1133         Type = self.lineEdit_3.text()
1134         money = self.lineEdit_4.text()
1135         if ok(money)==True:
1136             sjcount=cur.execute("SELECT * FROM 书籍信息 where Book_id='%s' or book_name='%s' or Type = '%s' or money='%f'" % (bookid,bookname,Type,float(money)))
1137             if sjcount == 1:
1138                 cur.execute("delete from 书籍信息 where Book_id='%s' or book_name='%s' or Type = '%s' or money='%f'" % (bookid,bookname,Type,float(money)))
1139                 conn.commit()
1140                 dzxxscsuccess.show()
1141             else:
1142                 dzxxscfail.show()
1143         else:
1144             dzxxscfail.show()
1145 class Ui_glyxgmm(QtWidgets.QDialog, Ui_32):
1146     def __init__(self):
1147         super(Ui_glyxgmm, self).__init__()
1148         self.setupUi(self)
1149     def Clean(self):
1150         self.lineEdit.setText("")
1151         self.lineEdit_2.setText("")
1152     def xgmm(self):
1153         global glyid
1154         firstpw = self.lineEdit.text()
1155         secondpw = self.lineEdit_2.text()
1156         if firstpw != "" and secondpw != "":
1157             if firstpw == secondpw and firstpw!="":
1158                 cur.execute("update 管理员 set password = ('%s') where admin_id='%s'" % (firstpw, glyid))
1159                 conn.commit()
1160                 self.lineEdit.setText("")
1161                 self.lineEdit_2.setText("")
1162                 xgmmsuccessful.show()
1163             else:
1164                 xgmmfail.show()
1165 
1166 class Ui_dzxxscsuccess(QtWidgets.QDialog, Ui_33):
1167     def __init__(self):
1168         super(Ui_dzxxscsuccess, self).__init__()
1169         self.setupUi(self)
1170 
1171 class Ui_dzxxscfail(QtWidgets.QDialog, Ui_34):
1172     def __init__(self):
1173         super(Ui_dzxxscfail, self).__init__()
1174         self.setupUi(self)
1175 
1176 class Ui_tjfail(QtWidgets.QDialog, Ui_35):
1177     def __init__(self):
1178         super(Ui_tjfail, self).__init__()
1179         self.setupUi(self)
1180 
1181 class Ui_tjsuccess(QtWidgets.QDialog, Ui_36):
1182     def __init__(self):
1183         super(Ui_tjsuccess, self).__init__()
1184         self.setupUi(self)
1185 
1186 class Ui_pcfail(QtWidgets.QDialog, Ui_37):
1187     def __init__(self):
1188         super(Ui_pcfail, self).__init__()
1189         self.setupUi(self)
1190 
1191 class Ui_cqpc(QtWidgets.QDialog, Ui_38):
1192     def __init__(self):
1193         super(Ui_cqpc, self).__init__()
1194         self.setupUi(self)
1195 
1196 class Ui_xjfail(QtWidgets.QDialog, Ui_39):
1197     def __init__(self):
1198         super(Ui_xjfail, self).__init__()
1199         self.setupUi(self)
1200 
1201 class Ui_xjcg(QtWidgets.QDialog, Ui_40):
1202     def __init__(self):
1203         super(Ui_xjcg, self).__init__()
1204         self.setupUi(self)
1205 
1206 class Ui_unexpected(QtWidgets.QDialog, Ui_41):
1207     def __init__(self):
1208         super(Ui_unexpected, self).__init__()
1209         self.setupUi(self)
1210     def Clean(self):
1211         self.lineEdit.setText("")
1212         self.lineEdit_2.setText("")
1213         self.lineEdit_3.setText("")
1214         self.lineEdit_4.setText("")
1215     def add(self):
1216         readername = self.lineEdit.text()
1217         readerid = self.lineEdit_2.text()
1218         bookid = self.lineEdit_3.text()
1219         money = self.lineEdit_4.text()
1220         reason = self.comboBox_2.currentText()
1221         readername = readername
1222         readerid = readerid
1223         bookid = bookid
1224         money = money
1225         reason = reason
1226         jscount = cur.execute(
1227             "SELECT * FROM 借书信息 where Book_id='%s' and reader_id='%s' and state='未归还'" % (bookid, readerid))
1228         now = QDateTime.currentDateTime()
1229         if ok(money)==True and jscount==1 and float(money)>=0:
1230             cur.execute(
1231                 "update 借书信息 set state=('%s') where Book_id='%s' and reader_id='%s' and state='未归还'" % (reason,bookid,readerid))
1232             conn.commit()
1233             cur.execute("update 书籍信息 set state=('%s') where Book_id='%s'" % (reason, bookid))
1234             conn.commit()
1235 
1236             cur.execute("select * from 赔偿信息")
1237             data1 = cur.fetchall()
1238             row1 = len(data1)
1239             row1 = row1 + 1
1240             cur.execute("select * from 书籍信息 where book_id='%s'"% (bookid))
1241             data1 = cur.fetchall()
1242 
1243             cur.execute("insert into 赔偿信息 values('%s','%s','%s','%s','%s','%s','%f','%s','未支付')" % (str(row1), readername, readerid, data1[0][0], bookid, reason, float(money), now.toString(Qt.ISODate)))
1244             conn.commit()
1245             cur.execute("update 读者信息 set number=(number-1) where reader_id = '%s'" % (readerid))
1246             conn.commit()
1247 
1248             tjsuccess.show()
1249         else:
1250             tjfail.show()
1251 
1252 if __name__ == "__main__":
1253 
1254     conn = pymysql.connect("localhost", "root", "1weiANRAN", "图书馆管理系统")
1255     cur = conn.cursor()
1256 
1257     app = QtWidgets.QApplication(sys.argv)
1258     lgin = First()
1259     dial = Ui_Dialog()
1260     dzd = Ui_dzdl()
1261     glyd = Ui_glydl()
1262     zc = Ui_zc()
1263     dzzc = Ui_dzzc()
1264     glyzc = Ui_glyzc()
1265     dzdlcw = Ui_dzdlcw()
1266     dzcz = Ui_dzcz()
1267     dzxxcx = Ui_dzxxcx()
1268     dzxgmm = Ui_dzxgmm()
1269     xgmmsuccessful = Ui_xgmmsuccessful()
1270     xgmmfail = Ui_xgmmfail()
1271     dzjs = Ui_dzjs()
1272     jsxxcx = Ui_jsxxcx()
1273     hsxxcx = Ui_hsxxcx()
1274     dzzcsuccess = Ui_dzzcsuccess()
1275     dzzcfail = Ui_dzzcfail()
1276     glycz = Ui_glycz()
1277     jssuccess = Ui_jssuccess()
1278     jsfail = Ui_jsfail()
1279     hssuccess =Ui_hssuccess()
1280     hsfail = Ui_hsfail()
1281     pccz = Ui_pccz()
1282     wxzfhhh = Ui_wxzfhhh()
1283     glyxgmm = Ui_glyxgmm()
1284     glydzxxcz = Ui_glydzxxcz()
1285     glyhsxxcz = Ui_glyhsxxcz()
1286     glyjsxxcz = Ui_glyjsxxcz()
1287     glypcxxcz = Ui_glypcxxcz()
1288     glysjcz = Ui_glysjcz()
1289     dzxxscsuccess = Ui_dzxxscsuccess()
1290     dzxxscfail = Ui_dzxxscfail()
1291     tjfail = Ui_tjfail()
1292     tjsuccess = Ui_tjsuccess()
1293     pcfail = Ui_pcfail()
1294     cqpc = Ui_cqpc()
1295     xjfail = Ui_xjfail()
1296     xjcg = Ui_xjcg()
1297     unexpected = Ui_unexpected()
1298 
1299     lgin.show()
1300     lgin.pushButton.clicked.connect(lgin.hide)
1301     lgin.pushButton.clicked.connect(dial.show)#登录按钮
1302 
1303     lgin.pushButton_2.clicked.connect(lgin.hide)
1304     lgin.pushButton_2.clicked.connect(zc.show)#注册按钮
1305 
1306     dial.pushButton_3.clicked.connect(dial.hide)
1307     dial.pushButton_3.clicked.connect(lgin.show)#从登录选择界面返回登录首界面
1308 
1309     dial.pushButton.clicked.connect(dial.hide)
1310     dial.pushButton.clicked.connect(dzd.show)#进入读者登陆界面
1311 
1312     dzd.pushButton_2.clicked.connect(dzd.Clean)
1313     dzd.pushButton_2.clicked.connect(dzd.hide)
1314     dzd.pushButton_2.clicked.connect(dial.show)#返回登录选择界面
1315 
1316     dzd.pushButton_3.clicked.connect(dzd.get_word)#调用get_word函数
1317 
1318     dial.pushButton_2.clicked.connect(dial.hide)
1319     dial.pushButton_2.clicked.connect(glyd.show)#进入管理员登陆界面
1320 
1321     glyd.pushButton_2.clicked.connect(glyd.hide)
1322     glyd.pushButton_2.clicked.connect(dial.show)#从管理员登陆界面返回登录选择界面
1323 
1324     zc.pushButton_3.clicked.connect(zc.hide)
1325     zc.pushButton_3.clicked.connect(lgin.show)#从注册选择界面返回登录首界面
1326 
1327     zc.pushButton.clicked.connect(zc.hide)
1328     zc.pushButton.clicked.connect(dzzc.show)#从注册选择界面进入读者注册界面
1329 
1330     dzzc.pushButton_3.clicked.connect(dzzc.get_word)  # 调用get_word函数
1331 
1332     dzzc.pushButton.clicked.connect(dzzc.Clean)  # 调用Clean函数
1333 
1334     glyzc.pushButton.clicked.connect(glyzc.get_word)  # 调用get_word函数
1335 
1336     glyzc.pushButton_2.clicked.connect(glyzc.Clean) # 调用Clean函数
1337 
1338     glyd.pushButton.clicked.connect(glyd.get_word)  # 调用get_word函数
1339 
1340     dzzc.pushButton.clicked.connect(dzzc.hide)
1341     dzzc.pushButton.clicked.connect(zc.show)#从读者注册界面返回注册选择界面
1342 
1343     zc.pushButton_2.clicked.connect(zc.hide)
1344     zc.pushButton_2.clicked.connect(glyzc.show)  # 从注册选择界面进入管理员注册界面
1345 
1346     glyzc.pushButton_2.clicked.connect(glyzc.hide)
1347     glyzc.pushButton_2.clicked.connect(zc.show)  # 从管理员注册界面返回注册选择界面
1348     sys.exit(app.exec_())
posted @ 2019-12-12 19:45  WeiAR  阅读(...)  评论(...编辑  收藏