Exemplo n.º 1
0
    def invest(self):
        index = self.tableWidget.currentRow()
        if index < 0:
            QMessageBox.information(self, "温馨提示", "请先选择充值的账户", QMessageBox.Yes)
            return
        value, ok = QInputDialog.getInt(self, "正在充值", "请输入充值金额:", 0, 0, 10000, 10)
        if ok:
            reply = MyQMessageBox("充值确认",
                                  "正在给 " + self.tableWidget.item(index, 1).text() + " 充值" + str(
                                      value) + '元,是否充值',
                                  '确认', '取消')
            if reply == 16384:
                person = mysql.query('user_tb', '_id', self.tableWidget.item(index, 0).text())
                balance = float(person[0][4]) + value
                mysql.update(self.tableWidget.item(index, 0).text(), 'balance', str(balance))
                QMessageBox.information(self, "温馨提示", "充值成功", QMessageBox.Yes)

                bills.bill_in(str(value), person[0][1], person[0][2], person[0][3], balance,
                              self.tableWidget.item(index, 0).text())
                if self.is_card_search:
                    self.search_data_by_card(str(person[0][3]))
                elif self.is_search:
                    self.search_data()
                else:
                    self.load_initial_data(self.tableWidget.verticalScrollBar().value())
                self.load_initial_bill()
                self.load_initial_bill()
Exemplo n.º 2
0
def get_index_data(index):
    # date = time.strftime('%Y-%m-%d', time.localtime())
    end_date = datetime.datetime.now().strftime('%Y-%m-%d')

    start_date_timesrtucture = datetime.datetime.strptime(
        msl.select_index(index).ix[-1].name,
        "%Y-%m-%d") + datetime.timedelta(1)
    start_date = start_date_timesrtucture.strftime('%Y-%m-%d')
    if datetime.datetime.now().date() < start_date_timesrtucture.date():
        print "today complete update"
        return "today complete update"
    if msl.select_index_basd_on_date(index, start_date).empty is True:
        print start_date, end_date, index
        df = ts.get_hist_data(index, start=start_date, end=end_date)
        if df.empty is True:
            return {index: None}
        else:
            df['code'] = index
            df['date'] = pd.Series(df.index, index=df.index)
            msl.update(df)
            print df
            return {index: df}
    else:
        print 'This day already has date', start_date, index
        return 'This day already has date'
Exemplo n.º 3
0
def get_today_data(num):
    # date = time.strftime('%Y-%m-%d', time.localtime())
    # print num
    end_date = datetime.datetime.now().strftime('%Y-%m-%d')
    # start_date = select_index('sh').ix[-1].name
    start_date_timesrtucture = datetime.datetime.strptime(
        msl.select_basd_on_code(num).ix[-1].name,
        "%Y-%m-%d") + datetime.timedelta(1)
    start_date = start_date_timesrtucture.strftime('%Y-%m-%d')
    # print end_date, start_date

    if datetime.datetime.now().date() < start_date_timesrtucture.date():
        print "today complete update"
        return "today complete update"
    # print start_date, end_date
    if msl.select_basd_on_date(num, start_date).empty is True:
        print start_date, end_date, num
        df = ts.get_hist_data(num, start=start_date, end=end_date)
        if df.empty is True:
            return {num: None}
        else:
            df['code'] = num
            df['date'] = pd.Series(df.index, index=df.index)
            print df.ix[0], df.ix[-1]
            msl.update(df)
            return {num: df}
    else:
        print 'This day already has date', start_date, index
        return 'This day already has date'
Exemplo n.º 4
0
def saveProfile(uid, rankid):
    if mysql.select('quicks', 'count(*) as count',
                    'where uid="' + str(uid) + '"')[0]['count'] > 0:
        mysql.update('quicks', 'uid=' + str(uid), 'rankid=' + rankid)
    else:
        mysql.insert('quicks', ['uid', 'rankid'], (uid, rankid))
    return True
Exemplo n.º 5
0
 def update(self):
     self.pre_update and self.pre_update()
     L = []
     args = []
     for k, v in self.__mapping__.iteritems():
         if v.updatable:
             if hasattr(self, k):
                 arg = getattr(self, k)
             else:
                 arg = v.default
                 setattr(self, k, arg)
             L.append('`%s`=?' % k)
             args.append(arg)
     pk = self.__primary_key__.name
     args.append(getattr(self, pk))
     mysql.update('update `%s` set %s where %s=?' % (self.__table__, ','.join(L), pk), *args)
     return self
Exemplo n.º 6
0
    def submit(self):

        reply = QMessageBox.information(self, "消费确认",
                                        self.name + "消费" + str(self.cost) + '元?', QMessageBox.Yes | QMessageBox.No)
        if reply == 16384:
            person = mysql.query('user_tb', '_id', self.id)
            balance = float(person[0][4]) - self.cost
            if balance < 0:
                QMessageBox.information(self, "温馨提示", "余额不足,请充值", QMessageBox.Yes)
            else:
                mysql.update(self.id, 'balance', str(balance))
                QMessageBox.information(self, "温馨提示", "消费成功", QMessageBox.Yes)

                bills.bill_out(str(self.cost), str(person[0][1]), str(person[0][2]), str(person[0][3]), balance,
                               self.id)
                MainWindow.load_initial_data()
                MainWindow.load_initial_bill()
        self.close()
Exemplo n.º 7
0
    def add_person(self):

        name = self.lineEdit.text().strip()
        phone = self.lineEdit_1.text().strip()
        card = self.lineEdit_2.text().strip()
        balance = self.doubleSpinBox.text()
        type = self.lineEdit_3.text().strip()

        if phone != '' and mysql.query_str('user_tb', 'phone', phone) and phone != DetailWindow.phone:
            QMessageBox.information(self, "温馨提示", "手机号已存在。", QMessageBox.Yes)
            return
        if mysql.query('user_tb', 'card', card) and card != DetailWindow.card:
            QMessageBox.information(self, "温馨提示", "卡号已存在。", QMessageBox.Yes)
            return
        if self.name != name:
            mysql.update(self.id, 'name', name)
            mysql.update_bill(self.id, 'name', name)
        if self.phone != phone:
            mysql.update(self.id, 'phone', phone)
            mysql.update_bill(self.id, 'phone', phone)
        if self.card != card:
            mysql.update(self.id, 'card', card)
            mysql.update_bill(self.id, 'card', card)
        if self.type != type:
            mysql.update(self.id, 'type', type)
            # mysql.update_bill(self.id, 'type', type)
        if self.balance != balance:
            mysql.update(self.id, 'balance', balance)
            cost = round(float(balance) - float(self.balance), 2)
            bills.bill_change(cost, name, phone, card, balance, self.id)

        QMessageBox.information(self, "温馨提示", "修改成功!", QMessageBox.Yes)
        DetailWindow.close()

        if MainWindow.is_search:
            MainWindow.search_data_by_card(card)
        else:
            MainWindow.load_initial_data(MainWindow.tableWidget.verticalScrollBar().value())
        MainWindow.load_initial_bill()
Exemplo n.º 8
0
    def consume(self):
        index = self.tableWidget.currentRow()
        if index < 0:
            messageBox = QMessageBox()
            messageBox.setWindowTitle('温馨提示')
            messageBox.setText('请先选择要消费的会员')
            messageBox.setStandardButtons(QMessageBox.Yes)
            buttonY = messageBox.button(QMessageBox.Yes)
            buttonY.setText('好的')
            messageBox.exec_()
            return
        value, ok = QInputDialog.getDouble(self, "正在消费", "请输入消费金额:", 0, 0, 1000000, 2)

        if ok:
            reply = MyQMessageBox("消费确认", "确认 " + self.tableWidget.item(index, 1).text() + " 消费了" + str(
                value) + '元?',
                                  '确认', '取消')

            if reply == 16384:
                person = mysql.query('user_tb', '_id', self.tableWidget.item(index, 0).text())
                balance = float(person[0][4]) - value
                if balance < 0:
                    QMessageBox.warning(self, "温馨提示", "余额不足,请充值")
                else:
                    mysql.update(self.tableWidget.item(index, 0).text(), 'balance', str(balance))
                    QMessageBox.information(self, "温馨提示", "消费成功", QMessageBox.Yes)

                    bills.bill_out(str(value), str(person[0][1]), str(person[0][2]), str(person[0][3]), balance,
                                   self.tableWidget.item(index, 0).text())

                    if self.is_card_search:
                        self.search_data_by_card(str(person[0][3]))
                    elif self.is_search:
                        self.search_data()
                    else:
                        self.load_initial_data(self.tableWidget.verticalScrollBar().value())
                    self.load_initial_bill()
Exemplo n.º 9
0
 def delete(self):
     self.pre_delete and self.pre_delete()
     pk = self.__primary_key__.name
     args = (getattr(self, pk), )
     mysql.update('delete from `%s` where `%s`=?' % (self.__table__, pk), *args)
     return self