Ejemplo n.º 1
0
 def confirm_action(self):
     reply_message = QTextBrowser()
     self.result_plate = dict(prefix=self.plate_level.currentText()[-1],
                              plate_num=self.res.text())
     occupy_query = dbOper().query(
         '''SELECT occupied FROM `plate_nums` where prefix='{prefix}' and plate_num='{plate_num}';'''
         .format(**self.result_plate))
     if occupy_query:
         if occupy_query[0]['occupied'].__str__() == '1':
             QMessageBox.question(
                 self, u"输入无效",
                 u"抱歉,您所输入的牌号\n{}\n已经被占用,请重新选择".format(self.res.text()),
                 QMessageBox.Yes)
         else:
             reply = QMessageBox.question(
                 self, u"选择成功",
                 u"恭喜,您所输入的牌号\n{}\n可以使用,请点击确认".format(self.res.text()),
                 QMessageBox.Yes | QMessageBox.No)
             if reply == QMessageBox.Yes:
                 select_over(user_account=self.user_account,
                             **self.result_plate)
     else:
         dbOper().update(
             '''insert into plate_nums set prefix='{prefix}', plate_num='{plate_num}';'''
             .format(**self.result_plate))
         reply = QMessageBox.question(
             self, u"选择成功",
             u"恭喜,您所输入的牌号\n{}\n可以使用,请点击确认".format(self.res.text()),
             QMessageBox.Yes | QMessageBox.No)
         if reply == QMessageBox.Yes:
             select_over(user_account=self.user_account,
                         **self.result_plate)
             QCoreApplication.instance().quit()
    def create_res(self):
        tmp = self.simi_base[:]
        for idx, k in enumerate(tmp):
            if k == '':
                tmp[idx] = u'.'
        tmp_sql = "SELECT * FROM `plate_nums` where occupied = 0  and plate_num regexp '{regexp}' limit 15".format(
            regexp=''.join(tmp))
        res = dbOper().query(tmp_sql)

        if not res:
            self.error_plate_format.setText(u"抱歉,查询无结果\n请尝试输入其他条件")
            self.error_plate_format.show()
        else:
            for idx, item in enumerate(res):
                button = QPushButton()
                self.res_box.addWidget(button, idx / 3, idx % 3)
                self.res_box.setAlignment(Qt.AlignHCenter)
                tmp_plate = u'沪' + item['prefix'] + '/ ' + item['plate_num']
                button.setText(tmp_plate)
                res_font = QFont()
                res_font.setPointSize(30)
                res_font.setBold(True)
                res_font.setItalic(False)
                res_font.setWeight(20)
                button.setFont(res_font)
                button.kv = item
                button.clicked.connect(self.after_select)
            self.begin_button.setDisabled(1)
Ejemplo n.º 3
0
    def __init__(self, parent=None):
        super(self.__class__, self).__init__(parent)

        titles = [
            u'obt_plate_time', u'name', u'VIN_code', u'mailing_address',
            u'e_mail', u'telephone', u'need_temp_or_not', u'briefing',
            u'plate_num', u'identity', u'regi_time', u'adm_area',
            u'mailing_or_not', u'driv_lic', u'purchase_bill_id'
        ]
        title_values = [
            u"定号时间", u"姓名", u"车辆识别编号", u"邮寄地址", u"电子邮箱", u"电话", u"需要临时牌照",
            u"其他信息", u"车牌号", u"身份证", u"注册时间", u"行政区划", u"是否邮寄", u"驾驶证",
            u"购车发票编号"
        ]
        info_table = QTableWidget()
        info_table.setColumnCount(len(titles))
        info_table.setHorizontalHeaderLabels(title_values)
        query_res = dbOper().query(ACQUIRE)
        for row, item in enumerate(query_res):
            info_table.insertRow(row)
            for col, key in enumerate(titles):
                tmp_item = QTableWidgetItem(unicode(item[key]))
                info_table.setItem(row, col, tmp_item)

        info_table.resizeColumnsToContents()
        layout = QGridLayout()
        layout.addWidget(info_table, 0, 0)
        self.setLayout(layout)
        self.setWindowTitle(u"当前系统注册用户信息")
        self.resize(1000, 618)
        self.setWindowFlags(Qt.WindowStaysOnTopHint)
Ejemplo n.º 4
0
 def login_check(self):
     user = self.username_edit.text()
     pwd = self.password_edit.text()
     if user == 'admin':
         if pwd == 'admin':
             self.loginstate = 1
             self.hide()
             self.admw.show()
         else:
             self.error_login.show()
     else:
         tmp_sql = '''select `regi_time`, `name`, `identity`, `driv_lic`, `briefing`, `plate_num`, `obt_plate_time`, `telephone`, `e_mail`, `purchase_bill_id`, `VIN_code`, `adm_area`, `mailing_address`, `mailing_or_not`, `need_temp_or_not` from customers_info where user_account = '{}' and user_password = "******";'''\
             .format(user, pwd)
         query_res = dbOper().query(tmp_sql)
         if query_res:
             if query_res[0]['obt_plate_time']:
                 tmp_detail = dbOper().query('''select `prefix`, `plate_num` from customers_info where user_account = '{}' and user_password = "******";'''.format(user, pwd))[0]
                 self.already_select.setText(u"您已经选择预定过车牌\n您的车牌号是\n沪{} {}".format(tmp_detail['prefix'], tmp_detail['plate_num']))
                 self.already_select.setWindowTitle(u':-)')
                 self.already_select.show()
             else:
                 self.loginstate = 1
                 self.hide()
                 self.mw.show()
                 txt = u'你的注册信息如下:\n\n\n'
                 headers = u'''姓名 注册时间 身份证号 驾驶证 车牌号 选牌时间 联系电话 电子邮箱 购车发票 VIN编码 行政区划 邮寄地址 是否邮寄 临时号牌'''.split()
                 fin_headers = headers[:]
                 sql_fin = '''SELECT
                                 `regi_time` AS '注册时间',
                                 `name` as '姓名',
                                 `identity` as '身份证号',
                                 `driv_lic` as '驾驶证',
                                 `briefing` as '其他信息',
                                 `plate_num` as '车牌号',
                                 `obt_plate_time` AS '选牌时间',
                                 `telephone` as '联系电话',
                                 `e_mail` as '电子邮箱',
                                 `purchase_bill_id` as '购车发票',
                                 `VIN_code` as 'VIN编码',
                                 `adm_area` as '行政区划',
                                 `mailing_address` as '邮寄地址',
                                 if(`mailing_or_not` > 0, '是','否') as '是否邮寄',
                             if(`need_temp_or_not` > 0, '是','否') as '临时号牌'
                             FROM
                                 customers_info
                             WHERE
                                 user_account = '{}'
                             AND user_password = "******";'''.format(user, pwd)
                 query_res_fin = dbOper().query(sql_fin)
                 tmp_dct = {x: y for x, y in query_res_fin[0].iteritems() if y}
                 n = 0
                 for header in headers:
                     if query_res_fin[0][header]:
                         self.mw.display_info.insertRow(n)
                         self.mw.display_info.setItem(n, 0, QtWidgets.QTableWidgetItem(unicode(query_res_fin[0][header])))
                         n += 1
                     else:
                         fin_headers.pop(n-1)
                         continue
                 self.mw.display_info.setVerticalHeaderLabels(fin_headers)
                 self.mw.display_info.setHorizontalHeaderLabels([u''])
                 self.mw.display_info.setColumnWidth(0, 165)
                 # self.mw.display_info.setUpdatesEnabled(0)
                 # self.mw.display_info
         else:
             self.error_login.show()
     self.mw.ui_custom.user_account = user
     self.mw.ui_recom.console.user_account = user
     self.mw.ui_simi.user_account = user
Ejemplo n.º 5
0
        else:
            try:
                tmp_account = self.account_edit.text()
                assert re.match(
                    r"^[\w\d_]+$",
                    tmp_account) and tmp_account != 'admin', u"账号格式错误,请重新输入"
                if not self.ismail_check.isChecked():
                    res['mailing_address'] = ''
                res['regi_time'] = time.time().__str__()
                # tmp_password = self.pwd_edit.text()
                # assert re.match(r"[\w\d_]*", tmp_password), u"密码格式错误"
            except Exception, e:
                self.regi_res.setText(e.message)
            else:
                exist_query = dbOper().query(
                    '''select * from customers_info where user_account='{user_account}' or identity='{identity}';'''
                    .format(**res))
                if not exist_query:
                    tmp_sql = ADD_CUST.format(**res)
                    dbOper().update(tmp_sql)
                    self.regi_res.setWindowTitle(u":-)")
                    self.regi_res.setText(
                        u"恭喜,注册成功!\n现在可以使用账号 {} 登陆系统".format(tmp_account))
                    self.hide()
                else:
                    self.regi_res.setText(u"用户名/身份证号\n已存在!")
        self.regi_res.show()


if __name__ == "__main__":
    import sys
def should_have_qty(qty=6):
    res = dbOper().query(SELECT_NOT_OCCUPIED.format(qty=qty))
    if len(res) < 6:
        enlarge_table(6 - len(res))
        return should_have_qty()
    return res