Пример #1
0
 def OnAddButton(self, event):
     info = personInfo.personInfo()
     info.name = self.nameTextCtrl.GetValue()
     info.phone = self.phoneTextCtrl.GetValue()
     info.address = self.addressTextCtrl.GetValue()
     self.book.input(info=info)
     self.Destroy()
Пример #2
0
    def setUp(self):
        self.book = addressbook()

        self.testInfo1 = personInfo()
        self.testInfo1.name = "test1"
        self.testInfo1.phone = "0001110000"
        self.testInfo1.address = "abc"
        self.testInfo2 = personInfo()
        self.testInfo2.name = "test2"
        self.testInfo2.phone = "0002220000"
        self.testInfo2.address = "def"
        self.testInfo3 = personInfo()
        self.testInfo3.name = "test3"
        self.testInfo3.phone = "0003330000"
        self.testInfo3.address = "ghi"

        self.book.input(self.testInfo1)
        self.book.input(self.testInfo2)
        self.book.input(self.testInfo3)
Пример #3
0
    def setUp(self):
        self.list = linkedlist()

        self.testInfo1 = personInfo()
        self.testInfo1.name = "test1"
        self.testInfo1.phone = "0001110000"
        self.testInfo1.address = "abc"
        self.testInfo2 = personInfo()
        self.testInfo2.name = "test2"
        self.testInfo2.phone = "0002220000"
        self.testInfo2.address = "def"
        self.testInfo3 = personInfo()
        self.testInfo3.name = "test3"
        self.testInfo3.phone = "0003330000"
        self.testInfo3.address = "ghi"

        self.list.append(self.testInfo1)
        self.list.append(self.testInfo2)
        self.list.append(self.testInfo3)
Пример #4
0
    def test_modify(self):
        testInfo = personInfo()
        testInfo.name = "test4"
        testInfo.phone = "0004440000"
        testInfo.address = "jkl"

        self.book.modify("test1", testInfo)
        self.assertEqual(self.book.getNode(0).data.name, testInfo.name)
        self.assertEqual(self.book.getNode(0).data.phone, testInfo.phone)
        self.assertEqual(self.book.getNode(0).data.address, testInfo.address)
Пример #5
0
    def test_input(self):
        testInfo = personInfo()
        testInfo.name = "test4"
        testInfo.phone = "0004440000"
        testInfo.address = "jkl"

        self.book.input(testInfo)
        self.assertEqual(self.book.getNode(3).data.name, testInfo.name)
        self.assertEqual(self.book.getNode(3).data.phone, testInfo.phone)
        self.assertEqual(self.book.getNode(3).data.address, testInfo.address)
Пример #6
0
    def test_insert(self):
        testInfo = personInfo()
        testInfo.name = "test4"
        testInfo.phone = "0004440000"
        testInfo.address = "jkl"

        self.list.insert(1, testInfo)
        self.assertEqual(self.list.get_length(), 4)
        self.assertEqual(self.list.getNode(1).data.name, testInfo.name)
        self.assertEqual(self.list.getNode(1).data.phone, testInfo.phone)
        self.assertEqual(self.list.getNode(1).data.address, testInfo.address)
Пример #7
0
 def load(self):
     f = open('addressbook.dat','r')
     f.seek(0,2)
     eof = f.tell()
     f.seek(0)
     while True:
         info = personInfo.personInfo()
         info.name = f.readline().rstrip('\n')
         info.phone = f.readline().rstrip('\n')
         info.address = f.readline().rstrip('\n')
         self.list.append(info)
         if eof == f.tell(): break
Пример #8
0
 def OnModifyButton(self, event):
     if self.modifyname:
         ynDialog = wx.MessageBox(
             "Do you modify searched item?", "Yes or No", wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION
         )
         if ynDialog == wx.YES:
             info = personInfo.personInfo()
             info.name = self.nameTextCtrl.GetValue()
             info.phone = self.phoneTextCtrl.GetValue()
             info.address = self.addressTextCtrl.GetValue()
             self.book.modify(self.modifyname, info)
             wx.MessageBox("%s is modified" % self.modifyname, "Info", wx.OK | wx.ICON_INFORMATION)
             self.Destroy()
Пример #9
0
    def load_db(self):
        con = mdb.connect('localhost', 'root', 'digiry3924-', 'studydb')

        with con:
            cur = con.cursor(mdb.cursors.DictCursor)
            cur.execute("SELECT * FROM addressbook")
            rows = cur.fetchall()

            for row in rows:
                info = personInfo.personInfo()
                info.name = row['name']
                info.phone = row['phone']
                info.address = row['address']
                self.list.append(info)