Ejemplo n.º 1
0
    def register(self):
        Session = sessionmaker(bind=engine)
        session = Session()
        try:
            if self.lineEdit.text() == '' or self.lineEdit_2.text() == '':
                CommonUtil.hint_dialog(self, CommonUtil.APP_ICON, '提示',
                                       '请输入用户名和密码')
                return

            users = session.query(user).filter(
                user.name == self.lineEdit.text())
            if users.count() >= 1:
                CommonUtil.hint_dialog(self, CommonUtil.APP_ICON, '提示',
                                       '用户已经存在~')
                return
            else:
                newuser = user()
                newuser.name = self.lineEdit.text().strip()
                newuser.password = self.lineEdit_2.text().strip()
                session.add(newuser)
                session.commit()
        except Exception as e:
            print(e.args)
        finally:
            session.close()
Ejemplo n.º 2
0
    def login(self):
        Session = sessionmaker(bind=engine)
        session = Session()
        try:

            currentuser = self.lineEdit.text().strip()
            currentpass = self.lineEdit_2.text().strip()
            users = session.query(user).filter(
                and_(user.name == currentuser, user.password == currentpass))
            if users.count() >= 1:
                #设置config.ini
                conf = ConfigParser()
                conf.set_user(currentuser, currentpass)
                self.close()
                self.ui1.currentuser = currentuser
                self.ui1.show()
            else:
                CommonUtil.hint_dialog(self, CommonUtil.APP_ICON, '提示',
                                       '用户名或密码错误')
                return
        except Exception as e:
            print(e.args)
        finally:
            session.close()