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