精华内容
下载资源
问答
  • 本文实例为大家分享了python实现图书管理系统的具体代码,供大家参考,具体内容如下 import mysql.connector import sys, os import time import datetime from tkinter import * from tkinter.messagebox import *...
  • 所使用到的Pycharm Anaconda Mysql Navicat 图形界基于Qt5 数据库信息如下图 属性有些少大家可以自行添加 即使没有Mysql Navicat 也可以使用sql service xxxx也可以创建表对了就能运行起来 如果使用sql service ...

    所使用到的Pycharm Anaconda Mysql Navicat 

    图形界基于Qt5

    数据库信息如下图 属性有些少大家可以自行添加

    即使没有Mysql Navicat 也可以使用sql service xxxx也可以创建表对了就能运行起来

    如果使用sql service xxxx连接的话语句要改一下 具体怎么可百度 不行再留言

    解释器不是Anaconda中的也行 只是Anaconda中的包要比别的多一些 需要自己导入需要的包

    登录页面 账号密码取决于你login表中的数据

     

    主菜单

     

     ps:目前所有提示都是用弹窗进行处理,还没有学习到更深一步,修改也无法更改借阅证号,表中属性较少。所有文件包括ui文件我也放在一个压缩包里,在Pycharm中导入这个文件夹,在project.py这个文件运行就行,其他文件运行无效.

    ##########################################################

    希望大家不要白嫖,点赞收藏评论一下就好!!!!!!

    ##########################################################

    蓝奏云下载链接:https://wwa.lanzoui.com/iy6KSrbkhgb密码:223366

    展开全文
  • 这篇文章主要为大家详细介绍了python实现图书管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下本文实例为大家分享了 python 实现图书管理系统的具体代码,供大家参考,具体内容如下import mysql....

    内容简介:这篇文章主要为大家详细介绍了python实现图书管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

    本文实例为大家分享了 python 实现图书管理系统的具体代码,供大家参考,具体内容如下

    import mysql.connector

    import sys, os

    import time

    import datetime

    from tkinter import *

    from tkinter.messagebox import *

    class Libop:

    user = 'root'

    pwd = ''

    host = 'localhost'

    db = 'library'

    data_file = 'mysql-test.dat'

    def __init__(self):

    print("init")

    try:

    self.library=mysql.connector.connect(user=Libop.user,password=Libop.pwd,host=Libop.host,database=Libop.db)

    self.cursor=self.library.cursor()

    print("Connect successfully")

    except mysql.connector.Error as err:

    print("WTF! initial wrong")

    print("Error: {}".format(err.msg))

    sys.exit()

    def select(self,str):

    try:

    self.cursor.execute(str)

    return self.cursor.fetchall()

    except mysql.connector.Error as err:

    print("WTF! select wrong")

    print("Error:{}".format(err.msg))

    print(str)

    showinfo("ERROR","Please input the parameter correctly")

    def update(self,str):

    try:

    self.cursor.execute(str)

    self.library.commit()

    return 1

    except mysql.connector.Error as err:

    print("WTF! update wrong")

    print("Error:{}".format(err.msg))

    return 0

    def delete(self,str):

    try:

    self.cursor.execute(str)

    self.library.commit()

    except mysql.connector.Error as err:

    print("WTF! delete wrong")

    print("Error:{}".format(err.msg))

    def insert(self,str):

    try:

    self.cursor.execute(str)

    self.library.commit()

    return 1

    except mysql.connector.Error as err:

    print("WTF! insert wrong")

    print("Error:{}".format(err.msg))

    return 0

    LIB = Libop()

    root=Tk()

    root.wm_title("Library System")

    str1=str2=''

    book_type=name=year=publisher=writer=price1=price2=order=''

    cardid=''

    def call_rent(en1,en2,brok):

    st1=en1.get()

    st2=en2.get()

    rent(st1,st2,brok)

    def call_return(en1,en2):

    st1=en1.get()

    st2=en2.get()

    back(st1,st2)

    def login():

    str1=ide.get()

    str2=pwde.get()

    curs=LIB.select("select manage_id,pswd from managers where manage_id='{}' and pswd='{}'".format(str1,str2))

    if ((str1,str2) in curs):

    showinfo('message','login success')

    label_book_id=Label(root,text='BookID:').grid(row=0,column=4,sticky=W)

    label_card_id=Label(root,text='CardID:').grid(row=1,column=4,sticky=W)

    entry_book_id=Entry(root)

    entry_book_id.grid(row=0,column=5,sticky=W)

    entry_card_id=Entry(root)

    entry_card_id.grid(row=1,column=5,sticky=W)

    entry_cardid=Entry(root)

    entry_cardid.grid(row=5,column=0,sticky=W)

    #buttons

    button_insert=Button(root,text='insert book',command=inbook)

    button_insert.grid(row=0,column=2,sticky=W)

    button_return=Button(root,text='rent book')

    button_return.bind("",lambda z:call_rent(entry_book_id,entry_card_id,str1))

    button_return.grid(row=0,column=3,sticky=W)

    button_rent=Button(root,text='return book')

    button_rent.bind("",lambda l:call_return(entry_book_id,entry_card_id))

    button_rent.grid(row=1,column=2,sticky=W)

    button_delete=Button(root,text='delete card')

    button_delete.bind("",lambda j:deletecard(entry_cardid))

    button_delete.grid(row=5,column=2,sticky=W)

    button_add=Button(root,text='add card',command=addwindow)

    button_add.grid(row=5,column=3,sticky=W)

    button_display=Button(root,text='display books')

    button_display.bind("",lambda y:display_rent(entry_cardid))

    button_display.grid(row=5,column=1,sticky=W)

    else:

    showinfo(title='login failure',message="WRONG ID OR PASSWORD!")

    #add a card

    def addwindow():

    top=Toplevel(root)

    label_card_id=Label(top,text='card id:').grid(row=0,column=0,sticky=W)

    label_name=Label(top,text='Name:').grid(row=1,column=0,sticky=W)

    label_unit=Label(top,text='Units:').grid(row=2,column=0,sticky=W)

    label_type=Label(top,text='type:').grid(row=3,column=0,sticky=W)

    entry_card_id=Entry(top)

    entry_card_id.grid(row=0,column=1,sticky=W)

    entry_name=Entry(top)

    entry_name.grid(row=1,column=1,sticky=W)

    entry_unit=Entry(top)

    entry_unit.grid(row=2,column=1,sticky=W)

    entry_type=Entry(top)

    entry_type.grid(row=3,column=1,sticky=W)

    button_constructe=Button(top,text='Add')

    button_constructe.bind("",lambda q:addcard(entry_card_id,entry_name,entry_unit,entry_type))

    button_constructe.grid(row=4)

    def addcard(en1,en2,en3,en4):

    cardid=en1.get()

    name=en2.get()

    unit=en3.get()

    c_type=en4.get()

    select="select card_id from lib_card where card_id='{}'".format(cardid)

    if (c_type not in ('T','S','O')):

    showinfo('error',"NO SUCH TYPE")

    return 0

    line=LIB.select(select)

    if (len(line)!=0):

    showinfo('addition failure',"Already have this ID!")

    else:

    insert="insert into lib_card values('{}','{}','{}','{}')".format(cardid,name,unit,c_type)

    LIB.insert(insert)

    showinfo('ok','addition success')

    return 1

    #insert book

    def inbook():

    insert_book=Toplevel(root)

    insert_book.title('insert book')

    text_insert=Text(insert_book)

    text_insert.pack()

    button_confirm=Button(insert_book,text='confirm')

    button_confirm.bind("",lambda x:booksin(text_insert))

    button_confirm.pack()

    def booksin(text_insert):

    string=text_insert.get('0.0',END)

    string=string.split(' ')

    print(string)

    for line in string:

    if line=='':

    break

    lines=line.split(',')

    bookid=lines[0][1:]

    t=lines[1]

    name=lines[2]

    publisher=lines[3]

    year=lines[4]

    writer=lines[5]

    price=lines[6]

    total=lines[7]

    stock=lines[8][:-1]

    if (int(stock)>int(total) or int(price)<0):

    showinfo('insert error!','stock wrong or price is below 0!')

    continue

    #print("insert into book values('{}','{}','{}','{}',{},'{}',{},{},{})".format(bookid,t,name,publisher,year,writer,price,total,stock))

    t=LIB.insert("insert into book values('{}','{}','{}','{}',{},'{}',{},{},{})".format(bookid,t,name,publisher,year,writer,price,total,stock))

    if (t==0):

    showinfo('error','book {} has been inserted'.format(bookid))

    showinfo('success','insert has been done')

    #original window

    label_type=Label(root,text='TYPE').grid(row=3,sticky=W,column=0)

    label_name=Label(root,text='NAME').grid(row=3,sticky=W,column=1)

    label_year=Label(root,text='YEAR(XXXX-XXXX)').grid(row=3,sticky=W,column=2)

    label_publisher=Label(root,text='PUBLISHER').grid(row=3,sticky=W,column=3)

    label_writer=Label(root,text='WRITER').grid(row=3,sticky=W,column=4)

    label_lowprice=Label(root,text='lowestprice').grid(row=3,sticky=W,column=5)

    label_highprice=Label(root,text='highestprice').grid(row=3,sticky=W,column=6)

    label_order=Label(root,text='order by').grid(row=0,sticky=W,column=6)

    entry_type=Entry(root)

    entry_type.grid(row=4,column=0,sticky=W)

    entry_name=Entry(root)

    entry_name.grid(row=4,column=1,sticky=W)

    entry_year=Entry(root)

    entry_year.grid(row=4,column=2,sticky=W)

    entry_publisher=Entry(root)

    entry_publisher.grid(row=4,column=3,sticky=W)

    entry_writer=Entry(root)

    entry_writer.grid(row=4,column=4,sticky=W)

    entry_price1=Entry(root)

    entry_price1.grid(row=4,column=5,sticky=W)

    entry_price2=Entry(root)

    entry_price2.grid(row=4,column=6,sticky=W)

    #order the result

    order_index=0

    Lb_order=Listbox(root,selectmode=SINGLE,height=6)

    order='name','book_type','T','writer','price','publisher'

    Lb_order.insert(0,order[0])

    Lb_order.insert(1,"type")

    Lb_order.insert(2,"year")

    Lb_order.insert(3,order[3])

    Lb_order.insert(4,order[4])

    Lb_order.insert(5,order[5])

    Lb_order.grid(row=0,column=7,sticky=W)

    Lb_order.selection_set(0)

    def booksearch():

    select="select BookID,book_type,name,publisher,T,writer,price,total,stock from book"

    order_index=Lb_order.curselection()

    if (len(order_index)!=0):

    order_index=order_index[0]

    else:

    order_index=0;

    orders=order[order_index]

    name=entry_name.get()

    book_type=entry_type.get()

    publisher=entry_publisher.get()

    year=entry_year.get()

    writer=entry_writer.get()

    price1=entry_price1.get()

    price2=entry_price2.get()

    year1=year[0:4]

    year2=year[5:9]

    count=0

    if name!='':

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" name='{}'".format(name)

    if book_type!='':

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" book_type='{}'".format(book_type)

    if publisher!='':

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" publisher='{}'".format(publisher)

    if year1!='':

    if year2=='':

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" t={}".format(year1)

    else:

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" T between {} and {}".format(year1,year2)

    if writer!='':

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" writer='{}'".format(writer)

    if price1!='':

    if price2!='':

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" price between {} and {}".format(price1,price2)

    else:

    if count!=0:

    selece+="and"

    else:select+=" where"

    count+=1

    select+=" price={}".format(price1)

    if orders=='':

    select+=" order by name"

    else:

    select+=" order by {}".format(orders)

    print(select)

    curs=LIB.select(select)

    searchresult=Toplevel(root)

    searchresult.title('result')

    text=Text(searchresult)

    text.insert(INSERT,"BookID type name publish year writer price total stock ")

    for (BookIDs,book_types,names,publishers,years,writers,prices,totals,stocks) in curs:

    text.insert(INSERT,"{} {} {} {} {} {} {} {} {} ".format(BookIDs,book_types,names,publishers,years,writers,prices,totals,stocks))

    text.pack()

    def display_rent(en_cardid):

    cardid=en_cardid.get()

    select="select card_id from lib_card where card_id='{}'".format(cardid)

    curs=LIB.select(select)

    order_index=Lb_order.curselection()

    if len(order_index)!=0 :

    order_index=order_index[0]

    else:

    order_index=0;

    orders=order[order_index]

    if ((cardid,) in curs):

    select="select card_id,name,unit,c_type from lib_card where card_id='{}'".format(cardid)

    curs=LIB.select(select)

    top=Toplevel(root)

    text=Text(top)

    for (card_id,name,unit,c_type) in curs:

    text.insert(INSERT,"card_id:{} ".format(card_id))

    text.insert(INSERT,"name:{} ".format(name))

    text.insert(INSERT,"unit:{} ".format(unit))

    text.insert(INSERT,"c_type:{} ".format(c_type))

    select="select BookID,book_type,name,publisher,t,writer,price,total,stock from book natural join record where card_id='{}' and still=1 order by {}".format(cardid,orders)

    curs=LIB.select(select)

    text.insert(INSERT,"BookID type name publish year writer price total stock ")

    for (BookID,book_type,name,publisher,t,writer,price,total,stock) in curs:

    text.insert(INSERT,"{} {} {} {} {} {} {} {} {} ".format(BookID,book_type,name,publisher,t,writer,price,total,stock))

    text.pack()

    else:

    showinfo('Error',"NO SUCH CARD")

    def checkcard(cardid):

    select="select card_id from lib_card where card_id='{}'".format(cardid)

    curs=LIB.select(select)

    if (cardid,) in curs:

    return 1

    else:

    return 0

    def rent(BookID,cardid,brokerage):

    if not (checkcard(cardid)):

    showinfo('error','no such card')

    return 0

    select="select stock from book where BookID='{}'".format(BookID)

    stocks=LIB.select(select)

    #stocks=curs.fetchall()

    stock=stocks[0]

    if (stock>(0,)):

    update="update book set stock=stock-1 where BookID='{}'".format(BookID)

    flag=LIB.update(update)

    if flag:

    insert="insert into record values('','{}','{}',CURDATE(),DATE_ADD(CURDATE(),INTERVAL 1 MONTH),'{}',1)".format(cardid,BookID,brokerage)

    LIB.insert(insert)

    showinfo('rent success','OK')

    else:

    showinfo('rent failure',"stock wrong")

    else:

    select="select return_time from record where BookID='{}' and return_time>=all(select return_time from record where BookID='{}')".format(BookID,BookID)

    date=LIB.select(select)

    #date=curs.fetchall()

    date=str (date)

    showinfo('Out of stock',"There are no more such book,The recent returning will be at:{}-{}-{}".format(date[16:20],date[22:23],date[26:27]))

    return 1

    def back(BookID,cardid):

    if not(checkcard(cardid)): return 0

    select="select BookID from record where BookID='{}' and card_id='{}' and still=1".format(BookID,cardid)

    curs=LIB.select(select)

    if (BookID,) in curs:

    select="select record_id from record where BookID='{}' and card_id='{}' and still=1 order by rent_time".format(BookID,cardid)

    cur=LIB.select(select)

    #cur=curss.fetchall()

    for record in cur:

    recordid=str (record)

    recordid=recordid[1:]

    recordid=recordid[:-2]

    update="update record set still=0 where record_id='{}'".format(recordid)

    LIB.update(update)

    update="update book set stock=stock+1 where BookID='{}'".format(BookID)

    LIB.update(update)

    break

    showinfo('message',"Return Success!")

    return 1

    else:

    showinfo('error',"You can't return the book!")

    return 1

    def deletecard(card):

    cardid=card.get()

    if not (checkcard(cardid)):

    showinfo('error',"NO SUCH CARD")

    return 0

    select="select record_id from record where card_id='{}' and still=1".format(cardid)

    curs=LIB.select(select)

    for record_id in curs:

    showinfo('error',"Some books this card rented haven't been returned")

    return 0

    delete="delete from lib_card where card_id='{}'".format(cardid)

    LIB.delete(delete)

    showinfo('ok','success')

    return 1

    label_id=Label(root,text='ID: ')

    label_id.grid(row=0,sticky=W)

    ide=Entry(root)

    ide.grid(row=0,column=1,sticky=E)

    label_psw=Label(root,text='PassWord: ').grid(row=1,sticky=W)

    pwde=Entry(root,show='*')

    pwde.grid(row=1,column=1,sticky=E)

    log_button=Button(root,text='Login',command=login)

    log_button.grid(row=2,column=1)

    button_search=Button(root,text='Search Book',command=booksearch)

    button_search.grid(row=4,column=7,sticky=W)

    print("all done")

    root.mainloop()

    以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持Codercto.com。

    以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

    gzh.jpg

    关注我们,获取更多IT资讯^_^

    为你推荐:

    相关软件推荐:

    本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。

    展开全文
  • 本文实例为大家分享了python实现图书管理系统的具体代码,供大家参考,具体内容如下import mysql.connectorimport sys, osimport timeimport datetimefrom tkinter import *from tkinter.messagebox import *class ...

    本文实例为大家分享了python实现图书管理系统的具体代码,供大家参考,具体内容如下

    import mysql.connector

    import sys, os

    import time

    import datetime

    from tkinter import *

    from tkinter.messagebox import *

    class Libop:

    user = "root"

    pwd = ""

    host = "localhost"

    db = "library"

    data_file = "mysql-test.dat"

    def __init__(self):

    print("init")

    try:

    self.library=mysql.connector.connect(user=Libop.user,password=Libop.pwd,host=Libop.host,database=Libop.db)

    self.cursor=self.library.cursor()

    print("Connect successfully")

    except mysql.connector.Error as err:

    print("WTF! initial wrong")

    print("Error: {}".format(err.msg))

    sys.exit()

    def select(self,str):

    try:

    self.cursor.execute(str)

    return self.cursor.fetchall()

    except mysql.connector.Error as err:

    print("WTF! select wrong")

    print("Error:{}".format(err.msg))

    print(str)

    showinfo("ERROR","Please input the parameter correctly")

    def update(self,str):

    try:

    self.cursor.execute(str)

    self.library.commit()

    return 1

    except mysql.connector.Error as err:

    print("WTF! update wrong")

    print("Error:{}".format(err.msg))

    return 0

    def delete(self,str):

    try:

    self.cursor.execute(str)

    self.library.commit()

    except mysql.connector.Error as err:

    print("WTF! delete wrong")

    print("Error:{}".format(err.msg))

    def insert(self,str):

    try:

    self.cursor.execute(str)

    self.library.commit()

    return 1

    except mysql.connector.Error as err:

    print("WTF! insert wrong")

    print("Error:{}".format(err.msg))

    return 0

    LIB = Libop()

    root=Tk()

    root.wm_title("Library System")

    str1=str2=""

    book_type=name=year=publisher=writer=price1=price2=order=""

    cardid=""

    def call_rent(en1,en2,brok):

    st1=en1.get()

    st2=en2.get()

    rent(st1,st2,brok)

    def call_return(en1,en2):

    st1=en1.get()

    st2=en2.get()

    back(st1,st2)

    def login():

    str1=ide.get()

    str2=pwde.get()

    curs=LIB.select("select manage_id,pswd from managers where manage_id="{}" and pswd="{}"".format(str1,str2))

    if ((str1,str2) in curs):

    showinfo("message","login success")

    label_book_id=Label(root,text="BookID:").grid(row=0,column=4,sticky=W)

    label_card_id=Label(root,text="CardID:").grid(row=1,column=4,sticky=W)

    entry_book_id=Entry(root)

    entry_book_id.grid(row=0,column=5,sticky=W)

    entry_card_id=Entry(root)

    entry_card_id.grid(row=1,column=5,sticky=W)

    entry_cardid=Entry(root)

    entry_cardid.grid(row=5,column=0,sticky=W)

    #buttons

    button_insert=Button(root,text="insert book",command=inbook)

    button_insert.grid(row=0,column=2,sticky=W)

    button_return=Button(root,text="rent book")

    button_return.bind("",lambda z:call_rent(entry_book_id,entry_card_id,str1))

    button_return.grid(row=0,column=3,sticky=W)

    button_rent=Button(root,text="return book")

    button_rent.bind("",lambda l:call_return(entry_book_id,entry_card_id))

    button_rent.grid(row=1,column=2,sticky=W)

    button_delete=Button(root,text="delete card")

    button_delete.bind("",lambda j:deletecard(entry_cardid))

    button_delete.grid(row=5,column=2,sticky=W)

    button_add=Button(root,text="add card",command=addwindow)

    button_add.grid(row=5,column=3,sticky=W)

    button_display=Button(root,text="display books")

    button_display.bind("",lambda y:display_rent(entry_cardid))

    button_display.grid(row=5,column=1,sticky=W)

    else:

    showinfo(title="login failure",message="WRONG ID OR PASSWORD!")

    #add a card

    def addwindow():

    top=Toplevel(root)

    label_card_id=Label(top,text="card id:").grid(row=0,column=0,sticky=W)

    label_name=Label(top,text="Name:").grid(row=1,column=0,sticky=W)

    label_unit=Label(top,text="Units:").grid(row=2,column=0,sticky=W)

    label_type=Label(top,text="type:").grid(row=3,column=0,sticky=W)

    entry_card_id=Entry(top)

    entry_card_id.grid(row=0,column=1,sticky=W)

    entry_name=Entry(top)

    entry_name.grid(row=1,column=1,sticky=W)

    entry_unit=Entry(top)

    entry_unit.grid(row=2,column=1,sticky=W)

    entry_type=Entry(top)

    entry_type.grid(row=3,column=1,sticky=W)

    button_constructe=Button(top,text="Add")

    button_constructe.bind("",lambda q:addcard(entry_card_id,entry_name,entry_unit,entry_type))

    button_constructe.grid(row=4)

    def addcard(en1,en2,en3,en4):

    cardid=en1.get()

    name=en2.get()

    unit=en3.get()

    c_type=en4.get()

    select="select card_id from lib_card where card_id="{}"".format(cardid)

    if (c_type not in ("T","S","O")):

    showinfo("error","NO SUCH TYPE")

    return 0

    line=LIB.select(select)

    if (len(line)!=0):

    showinfo("addition failure","Already have this ID!")

    else:

    insert="insert into lib_card values("{}","{}","{}","{}")".format(cardid,name,unit,c_type)

    LIB.insert(insert)

    showinfo("ok","addition success")

    return 1

    #insert book

    def inbook():

    insert_book=Toplevel(root)

    insert_book.title("insert book")

    text_insert=Text(insert_book)

    text_insert.pack()

    button_confirm=Button(insert_book,text="confirm")

    button_confirm.bind("",lambda x:booksin(text_insert))

    button_confirm.pack()

    def booksin(text_insert):

    string=text_insert.get("0.0",END)

    string=string.split(" ")

    print(string)

    for line in string:

    if line=="":

    break

    lines=line.split(",")

    bookid=lines[0][1:]

    t=lines[1]

    name=lines[2]

    publisher=lines[3]

    year=lines[4]

    writer=lines[5]

    price=lines[6]

    total=lines[7]

    stock=lines[8][:-1]

    if (int(stock)>int(total) or int(price)<0):

    showinfo("insert error!","stock wrong or price is below 0!")

    continue

    #print("insert into book values("{}","{}","{}","{}",{},"{}",{},{},{})".format(bookid,t,name,publisher,year,writer,price,total,stock))

    t=LIB.insert("insert into book values("{}","{}","{}","{}",{},"{}",{},{},{})".format(bookid,t,name,publisher,year,writer,price,total,stock))

    if (t==0):

    showinfo("error","book {} has been inserted".format(bookid))

    showinfo("success","insert has been done")

    #original window

    label_type=Label(root,text="TYPE").grid(row=3,sticky=W,column=0)

    label_name=Label(root,text="NAME").grid(row=3,sticky=W,column=1)

    label_year=Label(root,text="YEAR(XXXX-XXXX)").grid(row=3,sticky=W,column=2)

    label_publisher=Label(root,text="PUBLISHER").grid(row=3,sticky=W,column=3)

    label_writer=Label(root,text="WRITER").grid(row=3,sticky=W,column=4)

    label_lowprice=Label(root,text="lowestprice").grid(row=3,sticky=W,column=5)

    label_highprice=Label(root,text="highestprice").grid(row=3,sticky=W,column=6)

    label_order=Label(root,text="order by").grid(row=0,sticky=W,column=6)

    entry_type=Entry(root)

    entry_type.grid(row=4,column=0,sticky=W)

    entry_name=Entry(root)

    entry_name.grid(row=4,column=1,sticky=W)

    entry_year=Entry(root)

    entry_year.grid(row=4,column=2,sticky=W)

    entry_publisher=Entry(root)

    entry_publisher.grid(row=4,column=3,sticky=W)

    entry_writer=Entry(root)

    entry_writer.grid(row=4,column=4,sticky=W)

    entry_price1=Entry(root)

    entry_price1.grid(row=4,column=5,sticky=W)

    entry_price2=Entry(root)

    entry_price2.grid(row=4,column=6,sticky=W)

    #order the result

    order_index=0

    Lb_order=Listbox(root,selectmode=SINGLE,height=6)

    order="name","book_type","T","writer","price","publisher"

    Lb_order.insert(0,order[0])

    Lb_order.insert(1,"type")

    Lb_order.insert(2,"year")

    Lb_order.insert(3,order[3])

    Lb_order.insert(4,order[4])

    Lb_order.insert(5,order[5])

    Lb_order.grid(row=0,column=7,sticky=W)

    Lb_order.selection_set(0)

    def booksearch():

    select="select BookID,book_type,name,publisher,T,writer,price,total,stock from book"

    order_index=Lb_order.curselection()

    if (len(order_index)!=0):

    order_index=order_index[0]

    else:

    order_index=0;

    orders=order[order_index]

    name=entry_name.get()

    book_type=entry_type.get()

    publisher=entry_publisher.get()

    year=entry_year.get()

    writer=entry_writer.get()

    price1=entry_price1.get()

    price2=entry_price2.get()

    year1=year[0:4]

    year2=year[5:9]

    count=0

    if name!="":

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" name="{}"".format(name)

    if book_type!="":

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" book_type="{}"".format(book_type)

    if publisher!="":

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" publisher="{}"".format(publisher)

    if year1!="":

    if year2=="":

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" t={}".format(year1)

    else:

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" T between {} and {}".format(year1,year2)

    if writer!="":

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" writer="{}"".format(writer)

    if price1!="":

    if price2!="":

    if count!=0:

    select+=" and"

    else:select+=" where"

    count+=1

    select+=" price between {} and {}".format(price1,price2)

    else:

    if count!=0:

    selece+="and"

    else:select+=" where"

    count+=1

    select+=" price={}".format(price1)

    if orders=="":

    select+=" order by name"

    else:

    select+=" order by {}".format(orders)

    print(select)

    curs=LIB.select(select)

    searchresult=Toplevel(root)

    searchresult.title("result")

    text=Text(searchresult)

    text.insert(INSERT,"BookID type name publish year writer price total stock ")

    for (BookIDs,book_types,names,publishers,years,writers,prices,totals,stocks) in curs:

    text.insert(INSERT,"{} {} {} {} {} {} {} {} {} ".format(BookIDs,book_types,names,publishers,years,writers,prices,totals,stocks))

    text.pack()

    def display_rent(en_cardid):

    cardid=en_cardid.get()

    select="select card_id from lib_card where card_id="{}"".format(cardid)

    curs=LIB.select(select)

    order_index=Lb_order.curselection()

    if len(order_index)!=0 :

    order_index=order_index[0]

    else:

    order_index=0;

    orders=order[order_index]

    if ((cardid,) in curs):

    select="select card_id,name,unit,c_type from lib_card where card_id="{}"".format(cardid)

    curs=LIB.select(select)

    top=Toplevel(root)

    text=Text(top)

    for (card_id,name,unit,c_type) in curs:

    text.insert(INSERT,"card_id:{} ".format(card_id))

    text.insert(INSERT,"name:{} ".format(name))

    text.insert(INSERT,"unit:{} ".format(unit))

    text.insert(INSERT,"c_type:{} ".format(c_type))

    select="select BookID,book_type,name,publisher,t,writer,price,total,stock from book natural join record where card_id="{}" and still=1 order by {}".format(cardid,orders)

    curs=LIB.select(select)

    text.insert(INSERT,"BookID type name publish year writer price total stock ")

    for (BookID,book_type,name,publisher,t,writer,price,total,stock) in curs:

    text.insert(INSERT,"{} {} {} {} {} {} {} {} {} ".format(BookID,book_type,name,publisher,t,writer,price,total,stock))

    text.pack()

    else:

    showinfo("Error","NO SUCH CARD")

    def checkcard(cardid):

    select="select card_id from lib_card where card_id="{}"".format(cardid)

    curs=LIB.select(select)

    if (cardid,) in curs:

    return 1

    else:

    return 0

    def rent(BookID,cardid,brokerage):

    if not (checkcard(cardid)):

    showinfo("error","no such card")

    return 0

    select="select stock from book where BookID="{}"".format(BookID)

    stocks=LIB.select(select)

    #stocks=curs.fetchall()

    stock=stocks[0]

    if (stock>(0,)):

    update="update book set stock=stock-1 where BookID="{}"".format(BookID)

    flag=LIB.update(update)

    if flag:

    insert="insert into record values("","{}","{}",CURDATE(),DATE_ADD(CURDATE(),INTERVAL 1 MONTH),"{}",1)".format(cardid,BookID,brokerage)

    LIB.insert(insert)

    showinfo("rent success","OK")

    else:

    showinfo("rent failure","stock wrong")

    else:

    select="select return_time from record where BookID="{}" and return_time>=all(select return_time from record where BookID="{}")".format(BookID,BookID)

    date=LIB.select(select)

    #date=curs.fetchall()

    date=str (date)

    showinfo("Out of stock","There are no more such book,The recent returning will be at:{}-{}-{}".format(date[16:20],date[22:23],date[26:27]))

    return 1

    def back(BookID,cardid):

    if not(checkcard(cardid)): return 0

    select="select BookID from record where BookID="{}" and card_id="{}" and still=1".format(BookID,cardid)

    curs=LIB.select(select)

    if (BookID,) in curs:

    select="select record_id from record where BookID="{}" and card_id="{}" and still=1 order by rent_time".format(BookID,cardid)

    cur=LIB.select(select)

    #cur=curss.fetchall()

    for record in cur:

    recordid=str (record)

    recordid=recordid[1:]

    recordid=recordid[:-2]

    update="update record set still=0 where record_id="{}"".format(recordid)

    LIB.update(update)

    update="update book set stock=stock+1 where BookID="{}"".format(BookID)

    LIB.update(update)

    break

    showinfo("message","Return Success!")

    return 1

    else:

    showinfo("error","You can"t return the book!")

    return 1

    def deletecard(card):

    cardid=card.get()

    if not (checkcard(cardid)):

    showinfo("error","NO SUCH CARD")

    return 0

    select="select record_id from record where card_id="{}" and still=1".format(cardid)

    curs=LIB.select(select)

    for record_id in curs:

    showinfo("error","Some books this card rented haven"t been returned")

    return 0

    delete="delete from lib_card where card_id="{}"".format(cardid)

    LIB.delete(delete)

    showinfo("ok","success")

    return 1

    label_id=Label(root,text="ID: ")

    label_id.grid(row=0,sticky=W)

    ide=Entry(root)

    ide.grid(row=0,column=1,sticky=E)

    label_psw=Label(root,text="PassWord: ").grid(row=1,sticky=W)

    pwde=Entry(root,show="*")

    pwde.grid(row=1,column=1,sticky=E)

    log_button=Button(root,text="Login",command=login)

    log_button.grid(row=2,column=1)

    button_search=Button(root,text="Search Book",command=booksearch)

    button_search.grid(row=4,column=7,sticky=W)

    print("all done")

    root.mainloop()

    更多学习资料请关注专题《管理系统开发》。

    以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

    展开全文
  • 入门级别的图书管理系统,有数据库文件,有简单界面,可以实现图书信息的增加、修改、删除和查看,很简单,有两个主要界面
  • 项目描述人生苦短,我用Python,咱们今天就来分享一个用Python语言开发的基于Django框架的图书管理系统吧。项目前台和后台界面模板都是自己编写,前台采用Bootstrap框架UI,后台EasyUI框架UI,没有采用Django自动生成...

    项目描述

    人生苦短,我用Python,咱们今天就来分享一个用Python语言开发的基于Django框架的图书管理系统吧。项目前台和后台界面模板都是自己编写,前台采用Bootstrap框架UI,后台EasyUI框架UI,没有采用Django自动生成的那个后台管理,因为那个后台实在是太丑了,丑得惨不忍睹!整个项目主要负责图书信息的添加,修改,多个条件组合查询,删除。虽然系统功能不是很复杂,不过这是一个很好的学习案例,包括了常用字段的设计,比如字符串,浮点型,整型,日期型,图片型,富文本字符串型,文件型和下拉框外键关联型,囊括了所有商业项目设计需要的字段类型,通杀所有商业系统设计原理!当然也是学习的不二选择,好东西值得分享,强烈推荐!

    系统实体对象:

    图书类型:图书类别,类别名称,可借阅天数

    图书:图书条形码,图书名称,图书所在类别,图书价格,库存,出版日期,出版社,图书图片,图书简介,图书文件

    运行环境

    程序开发软件:Pycharm 数据库:mysql

    数据库文件

    压缩包内

    项目技术(必填)

    采用技术: Python语言,Django框架(一个MVT框架,类似Java的SSM框架)

    项目截图(必填)

    gray_loading.png

    gray_loading.png

    gray_loading.png

    运行截图(必填)

    gray_loading.pnggray_loading.pnggray_loading.pnggray_loading.pnggray_loading.pnggray_loading.pnggray_loading.png

    注意事项:

    python采用3.6测试通过,数据库mysql5.6,Django2.2框架

    展开全文
  • 基于python图书管理系统

    热门讨论 2009-06-01 14:41:36
    基于python图书管理系统源代码!!
  • 开发一个图书管理系统,首先需要对此项目进行一个简单的需求分析:主要功能包括:图书信息图书分类用户信息用户借阅统计管理员管理员权限接下来可以进行数据库的设计,在这里我提供一个简单的数据库表结构,如有不...
  • 设计一个GUI界面的系统,模拟图书管理,一个面向学生和学校管理员的系统,图书信息以txt文件存在本地。 管理员:查询图书 增加图书 删除图书 学生:借阅图书 归还图书 任何一个操作都会将所更新的图书...
  • 利用python连接mysql数据库实现图书管理系统 我不知道怎么用pycharm连接数据库,救急
  • 在拿到这个项目的时候,首先是查阅了基于Python图书管理系统可以怎么做,可以通过什么方式搭建,可以以什么样式展现。 据我目前了解到的信息,可以做成这样: 1、命令行形式运作,如输出“Hello World!"般,这个...
  • 主要为大家详细介绍了Python如何实现简易版图书管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
  • python+pyqt模块实现的图书管理系统,自带小型数据库,解压即可使用。
  • python实现图书管理系统,图形化界面版

    万次阅读 多人点赞 2019-03-01 22:09:16
    # 图书管理系统UI界面 import wx import datetime class wxGUI(wx.App): # 登陆界面 def Login(self): self.frame_Login = wx.Frame(None, title=&quot;Login(20177830115邵薪冉)&quot;, size=(500, ...
  • 提示:之前写了一个不连接数据库的图书管理系统,使用csv文件存储信息(链接:python实现界面化图书管理系统,csv格式文件存储信息)。这次写了一个连接数据库MySQL图书管理系统,功能更全。有登录、注册、忘记...
  • 一个用python写的图书管理小程序,界面比较难看但是比较轻量,功能齐全没有什么问题
  • 人生苦短,我用Python,咱们今天就来分享一个用Python语言开发的基于Django框架的图书管理系统吧。项目前台和后台界面模板都是自己编写,前台采用Bootstrap框架UI,后台EasyUI框架UI,没有采用Django自动生成的那个...
  • 程序开发软件:Pycharm 数据库:mysql 采用技术: Django(一个MVT框架,类似Java的SSM框架) 人生苦短,我用Python,咱们今天就来分享一个用Python语言开发的基于Django框架的图书管理系统吧。项
  • 人生苦短,我用Python,咱们今天就来分享一个用Python语言开发的基于Django框架的图书管理系统吧。项目前台和后台界面模板都是自己编写,前台采用Bootstrap框架UI,后台EasyUI框架UI,没有采用Django自动生成的那个...
  • 可以直接使用的工程文件,是一个入门级别的python系统工程,由于做的相对简单适合入门的新手做参考使用,请各位参考,使用方法已经上传.
  • 基于python+mysql图书管理系统,有数据库文件,有图书的增删改查 需wxpython,有简单界面,适合刚入门的同学
  • 图书管理系统python-Django.zip
  • 程序开发软件:Pycharm 数据库:mysql 采用技术: Django(一个MVT框架,类似Java的SSM框架) 人生苦短,我用Python,咱们今天就来分享一个用Python语言开发的基于Django框架的图书管理系统吧。项目前台和后台界面模板...
  • python图书管理系统

    2021-01-12 18:42:23
    {‘book_1’:{‘ISBN’: ‘12345678910121’,‘title’: ‘python’,‘author’: ‘tom’,‘number’: 3,‘borrow_num’: 0}} {‘book_2’:{‘ISBN’: ‘12345678910122’,‘title’: ‘c++’,‘author’: ...
  • 一个简单的基于python图书管理系统 开发平台:pycharm 开发语言:python 数据库:mysql 登录界面 主界面 数据库文件 想要的联系丘丘:793064854。2R带走
  • 这是一个基于Python图书信息管理系统,使用MySQL数据库管理数据,用tkinter做GUI界面。功能齐全,分管理员和读者两个部分,可注册、修改密码、切换登录。对读者系统,内含个人信息展示,可修改个人信息,查询、...
  • python+mysql设计简单GUI的图书管理系统

    千次阅读 多人点赞 2020-07-08 23:22:52
    图书管理系统:界面设计的比较丑请忽略 数据要求 根据系统的需求,将需要的数据分类记录如下: (1) 图书信息:编号、名称、储量、作者、出版时间 (2) 图书借阅信息:读者学号、图书编号、记录编号、借书日期、还...
  • word格式文档PAGE 49专业整理word格式文档专业整理Xxxx大学毕业设计(论文)基于JAVA的图书管理系统设计Design of Library Management System Based on Java学生姓名 xxx学 号 xxxxxxxxx专业班级 xxxxxxxxxx指导...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 4,919
精华内容 1,967
关键字:

pythonmysql图书管理系统

python 订阅
mysql 订阅