Esempio n. 1
0
    def signupFunction(self):
        '''
        获取信息后先检查
        把借书数量转为int
        加密密码
        '''
        self.user = self.signup.getInfo()
        res = database.check_user_info(self.user)
        if res['res'] == 'fail':
            self.errorBox(res['reason'])
            return
        self.user['MAX'] = int(self.user['MAX'])
        self.user['PASSWORD'] = database.encrypt(self.user['PASSWORD'])

        ans, resign = database.signup(self.user)
        self.user['class'] = 'stu'
        self.user.pop('PASSWORD')
        if ans:
            self.signup.setVisible(False)
            print('成功')
            self.display()
        else:
            if resign:
                self.errorBox('账号已经注册,注册失败')
            else:
                self.errorBox('注册失败')
Esempio n. 2
0
 def saveFunction(self):
     if self.passwordInput.text() != self.repPasswordInput.text():
         print('密码不一致')
         return
     if not self.maxNumInput.text().isalnum():
         print('最大数量输入错误')
         return
     if self.passwordInput.text() != '******':
         self.stu_mes['PASSWORD'] = database.encrypt(
             self.passwordInput.text())
     self.stu_mes['SNAME'] = self.nameInput.text()
     self.stu_mes['DEPARTMENT'] = self.deptInput.text()
     self.stu_mes['MAJOR'] = self.majorInput.text()
     self.stu_mes['MAX'] = int(self.maxNumInput.text())
     if not database.update_student(self.stu_mes):
         print('更新失败')
         return
     self.save.setEnabled(False)
     self.nameInput.setEnabled(False)
     self.passwordInput.setEnabled(False)
     self.repPasswordInput.setEnabled(False)
     self.deptInput.setEnabled(False)
     self.majorInput.setEnabled(False)
     self.maxNumInput.setEnabled(False)
     self.setMyStyle()
 def signupFunction(self):
     if self.signup.passwordInput.text(
     ) != self.signup.repPasswordInput.text():
         print('密码不一致')
         return
     if not self.signup.maxNumInput.text().isalnum():
         print('最大数量输入错误')
         return
     for i in range(2, 9):
         item = self.signup.bodyLayout.itemAt(i).widget()
         if item.text() == item.initText:
             item.setText('')
     self.user = {
         'SID': self.signup.accountInput.text(),
         'PASSWORD': database.encrypt(self.signup.passwordInput.text()),
         'SNAME': self.signup.nameInput.text(),
         'DEPARTMENT': self.signup.deptInput.text(),
         'MAJOR': self.signup.majorInput.text(),
         'MAX': int(self.signup.maxNumInput.text()),
         'PUNISHED': 0
     }
     ans = database.signup(self.user)
     self.user['class'] = 'stu'
     self.user.pop('PASSWORD')
     if ans:
         self.signup.setVisible(False)
         print('成功')
         self.display()
     else:
         print('注册失败')
Esempio n. 4
0
 def loginFunction(self):
     user_mes = {
         'ID': self.login.accountInput.text(),
         'PASSWORD': database.encrypt(self.login.passwordInput.text())
     }
     self.user = database.signin(user_mes)
     if self.user is not None:
         self.login.setVisible(False)
         self.display()
     else:
         self.errorBox('登录失败!')
Esempio n. 5
0
 def submitFunction(self):
     if not self.maxNumInput.text().isalnum():
         self.errorBox('最大数量输入错误')
         return
     if self.passwordInput.text() != self.passwordInput.initText:
         if self.passwordInput.text() != self.repPasswordInput.text():
             msgBox = QMessageBox(QMessageBox.Warning, "错误!", '两次输入密码不一致!',
                                  QMessageBox.NoButton, self)
             msgBox.addButton("确认", QMessageBox.AcceptRole)
             msgBox.exec_()
             return
         self.stu_info['PASSWORD'] = database.encrypt(
             self.passwordInput.text())
     self.stu_info['SNAME'] = self.nameInput.text()
     self.stu_info['DEPARTMENT'] = self.deptInput.text()
     self.stu_info['MAJOR'] = self.majorInput.text()
     self.stu_info['MAX'] = int(self.maxNumInput.text())
     self.close()
     self.after_close.emit(self.stu_info)