Ejemplo n.º 1
0
 def search(self, evt):
     self.ID = self.text5.GetValue()
     if self.ID == "":
         warn0 = wx.MessageDialog(self,
                                  message="请输入书籍编号",
                                  caption="错误警告",
                                  style=wx.YES_DEFAULT | wx.ICON_ERROR)
         warn0.ShowModal()
         warn0.Destroy()
         return
     Book = Table.Book(self.ID)
     list = self.helper.searchBook(Book)
     for x in list:
         print(x)
     if list != None and list != []:
         self.text1.SetLabel(list[0][1])
         self.text2.SetLabel(list[0][2])
         self.text3.SetLabel(list[0][3])
         self.text4.SetLabel(str(list[0][6]))
         self.List1.SetSelection(int(self.YearList.index(list[0][4])))
         self.List3.SetSelection(int(self.TypeList.index(list[0][5])))
     else:
         warn1 = wx.MessageDialog(self,
                                  message="未找到该书籍",
                                  caption="错误警告",
                                  style=wx.YES_DEFAULT | wx.ICON_ERROR)
         warn1.ShowModal()
         warn1.Destroy()
Ejemplo n.º 2
0
 def display(self):
     Alist = self.helper.searchByAccount(self.account)
     for x in Alist:
         index = self.list.InsertItem(self.list.GetItemCount(),
                                      str(x[0]))  #Loan_ID
         self.list.SetItem(index, 1, x[1])  #Book_ID
         book = Table.Book(str(x[1]))
         name = self.helper.searchBook(book)
         if name != None and name != []:
             self.list.SetItem(index, 2, str(name[0][1]))  #Book_name
         self.list.SetItem(index, 3, str(x[3]))  #Loan_date
         self.list.SetItem(index, 4, str(x[4]))  #ddl
         self.list.SetItem(index, 5, str(x[5]))  #returnDate
Ejemplo n.º 3
0
 def Insert(self, evt):
     L = self.helper.getMaxBookID()
     if L != None:
         BookID = int(L[0]) + 1
     else:
         BookID = 10000
     Name = self.text1.GetValue()
     Author = self.text2.GetValue()
     Press = self.text3.GetValue()
     Number = self.text4.GetValue()
     Date = self.YearList[int(self.List1.GetSelection())]
     Type = self.TypeList[int(self.List3.GetSelection())]
     if Name == "" or Author == "" or Press == "" or Number == "" or Date == "" or Type == "":
         warn = wx.MessageDialog(self,
                                 message="所有信息均不能为空",
                                 caption="错误警告",
                                 style=wx.YES_DEFAULT | wx.ICON_ERROR)
         warn.ShowModal()
         warn.Destroy()
         return
     Book = Table.Book(BookID, Name, Author, Press, Date, Type, Number)
     self.helper.BookInsert(Book)
Ejemplo n.º 4
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title="批量入库", size=(300, 300))
        self.helper = dbhelper.DBHelper()
        Dia = wx.FileDialog(parent,
                            message="Choose a file",
                            defaultDir="C:\\Users\Sail\Desktop\DBLab5",
                            style=1)
        L = self.helper.getMaxBookID()
        if L != None and L[0] != None:
            BookID = int(L[0]) + 1
        else:
            BookID = 10000

        if Dia.ShowModal() == wx.ID_OK:
            f = open(Dia.GetPath(), 'r')
            num = 1
            Book = Table.Book(BookID)
            for line in f:
                line.rstrip('\n')
                line = line.split()
                Book.setID(BookID)
                Book.setName(line[0])
                Book.setAuthor(line[1])
                Book.setPress(line[2])
                Book.setPressDate(line[3])
                Book.setType(line[4])
                Book.setNumber(line[5])
                BookID = BookID + 1
                self.helper.BookInsert(Book)
                num = num + 1
                print(line)
            f.close()
            result = wx.MessageDialog(self, message="导入成功", caption="导入结果")
            result.ShowModal()
            result.Destroy()
        Dia.Destroy()
        self.Destroy()
Ejemplo n.º 5
0
 def edit(self, evt):
     global BookID
     Name = self.text1.GetValue()
     Author = self.text2.GetValue()
     Press = self.text3.GetValue()
     Number = self.text4.GetValue()
     Date = self.YearList[self.List1.GetSelection()]
     Type = self.TypeList[self.List3.GetSelection()]
     if Name == "" or Author == "" or Press == "" or Number == "" or Date == "" or Type == "":
         warn = wx.MessageDialog(self,
                                 message="所有信息均不能为空",
                                 caption="错误警告",
                                 style=wx.YES_DEFAULT | wx.ICON_ERROR)
         warn.ShowModal()
         warn.Destroy()
         return
     Book = Table.Book(self.ID, Name, Author, Press, Date, Type, Number)
     self.helper.updateBook(Book, self.ID)
     warn4 = wx.MessageDialog(self,
                              message="修改成功",
                              caption="修改结果",
                              style=wx.YES_DEFAULT)
     warn4.ShowModal()
     warn4.Destroy()
Ejemplo n.º 6
0
 def Borrow(self, evt):
     BookID = self.ID.GetValue()
     if BookID == "":
         warn = wx.MessageDialog(self,
                                 message="书籍编号不能为空",
                                 caption="错误警告",
                                 style=wx.YES_DEFAULT | wx.ICON_ERROR)
         warn.ShowModal()
         warn.Destroy()
         return
     else:
         book = Table.Book(BookID)
         L = self.helper.searchBook(book)
         if L == None or L == []:
             warn1 = wx.MessageDialog(self,
                                      message="图书库中不存在该书籍",
                                      caption="错误警告",
                                      style=wx.YES_DEFAULT | wx.ICON_ERROR)
             warn1.ShowModal()
             warn1.Destroy()
             return
         else:
             for k in L:
                 if int(k[6]) <= 0:
                     warn2 = wx.MessageDialog(self,
                                              message="该书暂无库存",
                                              caption="错误警告",
                                              style=wx.YES_DEFAULT
                                              | wx.ICON_ERROR)
                     warn2.ShowModal()
                     warn2.Destroy()
                     return
                 else:
                     UserInfo = self.helper.getUserAccount(self.account)
                     if int(UserInfo[3]) - int(UserInfo[4]) <= 0:
                         for x in UserInfo:
                             print(x)
                         warn3 = wx.MessageDialog(
                             self,
                             message="当前账户无借书证或借书数已达上限",
                             caption="错误警告",
                             style=wx.YES_DEFAULT | wx.ICON_ERROR)
                         warn3.ShowModal()
                         warn3.Destroy()
                     else:  #借书成功
                         L = self.helper.getMaxBorrowID()
                         if L != None and L[0] != None:
                             LoanID = int(L[0]) + 1
                         else:
                             LoanID = 10000
                         BorrowDate = time.strftime(
                             '%Y-%m-%d', time.localtime(time.time()))
                         DDL = time.strftime(
                             '%Y-%m-%d',
                             time.localtime(time.time() + 24 * 3600 * 60))
                         self.helper.updateNum(BookID,
                                               "-")  #库存变化 借阅变化 更新借阅记录
                         Loan = Table.Loan(BookID,
                                           self.account,
                                           LoanID,
                                           BorrowDate,
                                           DeadLine=DDL)
                         self.helper.LoanInsert(Loan)
                         self.helper.updateUserBorrow(self.account, "+")
                         warn4 = wx.MessageDialog(self,
                                                  message="借阅成功",
                                                  caption="借阅结果",
                                                  style=wx.YES_DEFAULT)
                         warn4.ShowModal()
                         warn4.Destroy()
     self.Destroy()
Ejemplo n.º 7
0
    def __init__(self, parent, User_Type, User_ID=""):
        self.user = User_Type
        self.UserID = User_ID
        style = wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)
        wx.Frame.__init__(self,
                          parent,
                          title="图书管理系统",
                          size=(810, 670),
                          style=style)
        self.helper = dbhelper.DBHelper()
        self.Book = Table.Book("")
        self.SetBackgroundColour("#FFFFFF")
        self.Top = wx.Panel(self, size=(770, 90), pos=(10, 10))  #顶端部分
        self.Display = wx.Panel(self, size=(770, 300), pos=(10, 110))  #顶端部分
        self.Search = wx.Panel(self, size=(500, 200), pos=(10, 420))
        self.Switch = wx.Panel(self, size=(100, 200), pos=(600, 420))
        #----------------------Top---------------------------------------------------
        self.Top_text1 = wx.StaticText(self.Top, label="图书管理系统", pos=(10, 20))
        self.Top_text1.SetFont(wx.Font(30, wx.DECORATIVE, wx.NORMAL, wx.BOLD))

        self.time = wx.StaticText(
            self.Top,
            label="当前日期:" +
            time.strftime('%Y-%m-%d', time.localtime(time.time())),
            pos=(400, 70))
        wx.StaticText(self.Top, label="当前用户:" + self.user, pos=(540, 70))
        if self.user == "游客":
            self.enroll = wx.Button(self.Top,
                                    -1,
                                    label="注册",
                                    pos=(630, 68),
                                    size=(50, 20))
            self.login = wx.Button(self.Top,
                                   -1,
                                   label="登陆",
                                   pos=(700, 68),
                                   size=(50, 20))
            self.Bind(wx.EVT_BUTTON, self.Sign, self.enroll)
            self.Bind(wx.EVT_BUTTON, self.log, self.login)
        else:
            wx.StaticText(self.Top, label="用户名:" + User_ID, pos=(650, 70))
            self.exit_button = wx.Button(self.Top,
                                         -1,
                                         label="退出",
                                         pos=(680, 30),
                                         size=(50, 20))
            self.Bind(wx.EVT_BUTTON, self.exit, self.exit_button)
        #---------------------------------Display-------------------------------------
        self.list = wx.ListCtrl(self.Display,
                                -1,
                                size=(700, 280),
                                style=wx.LC_REPORT | wx.LC_HRULES
                                | wx.LC_VRULES)
        self.list.InsertColumn(0, "书籍编号")
        self.list.InsertColumn(1, "书名")
        self.list.InsertColumn(2, "作者")
        self.list.InsertColumn(3, "出版社")
        self.list.InsertColumn(4, "出版时间")
        self.list.InsertColumn(5, "书籍类型")
        self.list.InsertColumn(6, "余量")

        self.list.SetColumnWidth(0, 100)
        self.list.SetColumnWidth(1, 120)
        self.list.SetColumnWidth(2, 100)
        self.list.SetColumnWidth(3, 80)
        self.list.SetColumnWidth(4, 80)
        self.list.SetColumnWidth(5, 80)
        self.list.SetColumnWidth(6, 80)

        #------------------------------Search----------------------------------
        self.Search.SetFont(wx.Font(12, wx.DECORATIVE, wx.NORMAL, wx.NORMAL))

        wx.StaticText(self.Search, label="书名", pos=(10, 10))
        wx.StaticText(self.Search, label="作者", pos=(150, 10))
        wx.StaticText(self.Search, label="出版社", pos=(300, 10))
        wx.StaticText(self.Search, label="出版时间", pos=(250, 75))
        wx.StaticText(self.Search, label="类型", pos=(10, 75))
        wx.StaticText(self.Search, label="--", pos=(390, 75))

        self.Search_text1 = wx.TextCtrl(self.Search,
                                        -1,
                                        pos=(45, 10),
                                        size=(100, 20))
        self.Search_text2 = wx.TextCtrl(self.Search,
                                        -1,
                                        pos=(185, 10),
                                        size=(100, 20))
        self.Search_text3 = wx.TextCtrl(self.Search,
                                        -1,
                                        pos=(350, 10),
                                        size=(130, 20))

        self.Search_checkBox1 = wx.CheckBox(self.Search,
                                            -1,
                                            "可租借",
                                            pos=(170, 75))
        self.YearList = [str(x) for x in range(1970, 2019)]
        self.TypeList = [
            "计算机", "外语", "文学", "艺术", "经管", "人文社科", "少儿", "生活", "进口原版", "科技",
            "考试", "离职", "学术", "古籍", "哲学", "旅游", "法律", "宗教", "历史", "地理", "政治",
            "军事心理学", "传记", "工具书", "建筑", "才会", "教育", "医学", "电子电工", "农业", "文化",
            "美食", "娱乐时尚", "青春文学", "机械", "美术", "经济", "化工", "汽车与交通运输", "健康",
            "冶(yě)金", "服饰美容", "育儿", "通信", "管理", "摄影", "投资理财", "音乐", "少儿科普",
            "家庭与办公", "儿童文学", "图象图形与多媒体", "程序设计"
        ]
        self.Search_List1 = wx.Choice(self.Search,
                                      -1, (320, 75),
                                      size=(70, 20),
                                      choices=self.YearList)
        self.Search_List2 = wx.Choice(self.Search,
                                      -1, (410, 75),
                                      size=(70, 20),
                                      choices=self.YearList)
        self.Search_List3 = wx.Choice(self.Search,
                                      -1, (45, 70),
                                      size=(100, 25),
                                      choices=self.TypeList)

        self.Search_button1 = wx.Button(self.Search,
                                        -1,
                                        label="搜索",
                                        pos=(100, 120))
        self.Search_button2 = wx.Button(self.Search,
                                        -1,
                                        label="重置",
                                        pos=(220, 120))
        self.Search_button1.Bind(wx.EVT_BUTTON, self.search)
        self.Search_button2.Bind(wx.EVT_BUTTON, self.Search_Clear)

        #---------------------------------------------------------------------------------
        if self.user == "管理员":  #管理员按钮
            self.Switch_button1 = wx.Button(self.Switch,
                                            -1,
                                            label="单册入库",
                                            pos=(10, 10))
            self.Switch_button2 = wx.Button(self.Switch,
                                            -1,
                                            label="批量入库",
                                            pos=(10, 50))
            self.Switch_button3 = wx.Button(self.Switch,
                                            -1,
                                            label="单册编辑",
                                            pos=(10, 90))
            self.Switch_button4 = wx.Button(self.Switch,
                                            -1,
                                            label="用户管理",
                                            pos=(10, 130))
            self.Bind(wx.EVT_BUTTON, self.AddOne, self.Switch_button1)
            self.Bind(wx.EVT_BUTTON, self.AddMul, self.Switch_button2)
            self.Bind(wx.EVT_BUTTON, self.EditOne, self.Switch_button3)
            self.Bind(wx.EVT_BUTTON, self.Manage, self.Switch_button4)
        elif self.user == "用户":  #用户按钮
            self.Switch_button5 = wx.Button(self.Switch,
                                            -1,
                                            label="借阅书籍",
                                            pos=(10, 10))
            self.Switch_button6 = wx.Button(self.Switch,
                                            -1,
                                            label="借阅记录",
                                            pos=(10, 70))
            self.Bind(wx.EVT_BUTTON, self.BorrowBook, self.Switch_button5)
            self.Bind(wx.EVT_BUTTON, self.BorrowRecord, self.Switch_button6)
        self.Show()