def accept(self): money = str(self.txtMoney.text()) data = [ self.cmbMonth.currentIndex(), self.txtYear.text(), self.txtName.text(), money ] columns = ["month", "year", "name", "money"] bbdd = Bbdd() bbdd.update(columns, data, "conjunta", "id=" + str(self.id)) bbdd.deleteWhere("conjunta_tipster", "conjunta=" + str(self.id)) for i in self.selected: if i in (0, 1): continue bbdd.insert(["conjunta", "tipster"], [self.id, i], "conjunta_tipster") bbdd.close() QMessageBox.information(self, _("Added"), _("New joint purchase added.")) self.close()
def initData(self): bd = Bbdd() where = "id=" + str(self.id) # date dataBonus = bd.select("bonus", None, where)[0] date = QDate.fromString(dataBonus[1], "yyyy-MM-dd") self.txtDate.setDate(date) # cmbBookie data = bd.select("bookie", "name") self.bookieIndexToId = {} index, idCmb = 0, 0 for i in data: id = i[0] if dataBonus[2] == id: idCmb = index name = i[1] self.cmbBookie.addItem(name) self.bookieIndexToId[index] = id index += 1 self.cmbBookie.setCurrentIndex(idCmb) self.txtMoney.setValue(dataBonus[3]) self.chkFree.setChecked(str_to_bool(dataBonus[4])) bd.close()
def setCompetitionComb(self, index_cmb): self.competitions[index_cmb].clear() bd = Bbdd() idRegion = self.regionIndexToIdCmb[index_cmb].get( self.regions[index_cmb].currentIndex()) idSport = self.sportIndexToId.get( self.sports[index_cmb].currentIndex()) where = "region=" + str(idRegion) + " AND sport=" + str(idSport) try: data = bd.select("competition", "name", where) index = 0 self.competitionIndexToIdCmb[index_cmb] = {} for i in data: id = i[0] name = i[1] self.competitions[index_cmb].addItem(name) self.competitionIndexToIdCmb[index_cmb][index] = id index += 1 if index == 0: self.btnAccept.setDisabled(True) else: self.btnAccept.setDisabled(False) except: self.btnAccept.setDisabled(True) bd.close()
def initData(self): # cmbRegion bd = Bbdd() data = bd.select("region", "name") self.regionIndexToId = {} index = 0 for i in data: id = i[0] name = i[1] self.cmbRegion.addItem(name) self.regionIndexToId[index] = id index += 1 # cmbSport bd = Bbdd() data = bd.select("sport", "name") self.sportIndexToId = {} index = 0 for i in data: id = i[0] name = i[1] self.cmbSport.addItem(name) self.sportIndexToId[index] = id index += 1 bd.close()
def initData(self): bd = Bbdd() name = bd.getValue(self.id, "region") self.txtRegion.setText(name) bd.close()
def update(self): if not self.isEmpty(): bd = Bbdd() msg = bd.update(["name", "country"], [self.name, self.country], "bookie", "id=" + self.id) bd.close() if msg != 0: msg = "Se ha producido un error al actualizar la BBDD" if self.ruta is not None: try: if not os.path.exists( expanduser("~") + "/.betcon/resources/bookies"): os.makedirs( expanduser("~") + "/.betcon/resources/bookies") copy2( self.ruta, expanduser("~") + "/.betcon/resources/bookies/" + self.id + ".png") img = Images( expanduser("~") + "/.betcon/resources/bookies/" + self.id + ".png") img.resize(100, 20) except: msg = "Imágen incorrecta" else: msg = "Faltan datos por introducir" return msg
def initCombined(self): bd = Bbdd() data = bd.select("combined", None, "bet=" + str(self.id)) i = 0 for bet in data: self.addCombined() date = QDateTime.fromString(bet[2], "yyyy-MM-dd hh:mm:ss") self.dates[i].setDateTime(date) try: sport = key_from_value(self.sportIndexToId, bet[3]) self.sports[i].setCurrentIndex(sport) self.setRegionComb(i) region = key_from_value(self.regionIndexToIdCmb[i], bet[5]) self.regions[i].setCurrentIndex(region) self.setCompetitionComb(i) competition = key_from_value(self.competitionIndexToIdCmb[i], bet[4]) self.competitions[i].setCurrentIndex(competition) except: print("No data combined") self.players1[i].setCurrentText(bet[6]) self.players2[i].setCurrentText(bet[7]) self.picks[i].setText(bet[8]) self.results[i].setCurrentIndex(int(bet[9])) i += 1 bd.close()
def initData(self): bd = Bbdd() data = bd.select("tipster_month", None, "id=" + str(self.id))[0] dataCmb = bd.select("tipster", "name") self.tipsterIndexToId = {} index, idCmb = 0, 0 idBd = data[3] for i in dataCmb: id = i[0] if id == idBd: idCmb = index name = i[1] self.cmbTipster.addItem(name) self.tipsterIndexToId[index] = id index += 1 self.cmbTipster.setCurrentIndex(idCmb) self.txtYear.setValue(data[2]) self.cmbMonth.setCurrentIndex(data[1]) self.txtMoney.setValue(data[4]) bd.close()
def deleteWhere(table, where): bd = Bbdd() msg = bd.deleteWhere(table, where) bd.close() if msg != 0: msg = "Se ha producido un error al actualizar la BBDD" return msg
def delete(id): bd = Bbdd() msg = bd.delete("bookie", id) bd.close() if msg != 0: msg = "Se ha producido un error al actualizar la BBDD" return msg
def accept(self): data = [] data.append(self.txtDate.text()) data.append(self.cmbAccount.currentIndex() + 1) idBookie = self.bookieIndexToId.get(self.cmbBookie.currentIndex()) data.append(idBookie) if self.cmbType.currentIndex() == 1: type = "-" else: type = "" money = type + str(self.txtMoney.text()) money = str_to_float(money) data.append(money) columns = ["date", "account", "bookie", "money"] bbdd = Bbdd() bbdd.insert(columns, data, "movement") money *= -1 data = ["'+bank+'" + str(money)] columns = ["bank"] account = self.cmbAccount.currentIndex() bbdd.update(columns, data, "bank", "id=" + str(account + 1)) bbdd.close() QMessageBox.information(self, "Añadido", "Movimiento añadido.") self.close()
def export(self): bd = Bbdd() file = OrderedDict() data = bd.select("bet") dataOds = [[ "Fecha", "Deporte", "Competicion", "Región", "Local", "Visitante", "Pick", "Casa", "Mercado", "Tipster", "Stake", "Unidad", "Resultado", "Beneficio", "Apuesta", "Cuota", "Gratuita" ]] for i in data: row = [] row.append(i[1]) row.append(bd.getValue(i[2], "sport")) row.append(bd.getValue(i[3], "competition")) row.append(bd.getValue(i[4], "region")) row.append(i[5]) row.append(i[6]) row.append(i[7]) row.append(bd.getValue(i[8], "bookie")) row.append(bd.getValue(i[9], "market")) row.append(bd.getValue(i[10], "tipster")) row.append(i[11]) row.append(i[12]) row.append(i[13]) row.append(i[14]) row.append(i[15]) row.append(i[16]) row.append("No" if i[17] == 0 else "Sí") dataOds.append(row) bd.close() file.update({"Apuestas": dataOds}) save_data(self.directory, file)
def initTree(self): bd = Bbdd() data = bd.select("tipster_month", "year, month") items = [] for i in data: id = i[0] year = i[2] month = numberToMonth(i[1]+1) tipster = bd.getValue(i[3], "tipster") money = i[4] item = QTreeWidgetItem([str(id), str(year), str(month), str(tipster), str(money)]) items.append(item) self.treeMain.addTopLevelItems(items) data = bd.select("conjunta", "year, month") if len(data) < 1: self.lblConjunta.setVisible(False) self.treeConjunta.setVisible(False) else: items = [] for i in data: id = i[0] year = i[3] month = numberToMonth(i[2] + 1) name = i[1] money = i[4] item = QTreeWidgetItem([str(id), str(year), str(month), str(name), str(money)]) items.append(item) self.treeConjunta.addTopLevelItems(items) bd.close()
def initCombined(self): bd = Bbdd() data = bd.select("combined", None, "bet=" + str(self.id)) i = 0 for bet in data: self.addCombined() date = QDateTime.fromString(bet[2], "yyyy-MM-dd hh:mm:ss") self.dates[i].setDateTime(date) sport = key_from_value(self.sportIndexToId, bet[3]) self.sports[i].setCurrentIndex(sport) self.setRegionComb(i) region = key_from_value(self.regionIndexToIdCmb[i], bet[5]) self.regions[i].setCurrentIndex(region) self.setCompetitionComb(i) competition = key_from_value(self.competitionIndexToIdCmb[i], bet[4]) self.competitions[i].setCurrentIndex(competition) self.players1[i].setCurrentText(bet[6]) self.players2[i].setCurrentText(bet[7]) self.picks[i].setText(bet[8]) result = { "Pendiente": 0, "Acertada": 1, "Fallada": 2, "Nula": 3, "Medio Acertada": 4, "Medio Fallada": 5, "Retirada": 6 }[bet[9]] self.results[i].setCurrentIndex(result) i += 1 bd.close()
def initData(self): bd = Bbdd() data = bd.select("tipster", "name") self.listFree.clear() self.listSelected.clear() self.tipsterIndexToId = {} self.selectedIndexToId = {} index, index2 = 0, 0 for i in data: id = i[0] if id == 1: continue name = i[1] if id in self.selected: self.listSelected.addItem(name) self.selectedIndexToId[index2] = id index2 += 1 else: self.listFree.addItem(name) self.tipsterIndexToId[index] = id index += 1 bd.close()
def accept(self): money = str(str_to_float(self.txtMoney.text())) data = [ self.cmbMonth.currentIndex(), self.txtYear.text(), self.txtName.text(), money ] columns = ["month", "year", "name", "money"] bbdd = Bbdd() bbdd.update(columns, data, "conjunta", "id=" + str(self.id)) bbdd.deleteWhere("conjunta_tipster", "conjunta=" + str(self.id)) for i in self.selected: if i in (0, 1): continue bbdd.insert(["conjunta", "tipster"], [self.id, i], "conjunta_tipster") bbdd.close() QMessageBox.information(self, "Añadido", "Nueva conjunta añadida.") self.close()
def setCompetition(self): self.cmbCompetition.clear() bd = Bbdd() idRegion = self.regionIndexToId.get(self.cmbRegion.currentIndex()) idSport = self.sportIndexToId.get(self.cmbSport.currentIndex()) where = "region=" + str(idRegion) + " AND sport=" + str(idSport) data = bd.select("competition", "name", where) self.competitionIndexToId = {} index = 0 for i in data: id = i[0] name = i[1] self.cmbCompetition.addItem(name) self.competitionIndexToId[index] = id index += 1 if index == 0: self.btnAccept.setDisabled(True) else: self.btnAccept.setDisabled(False) bd.close()
def initData(self): bd = Bbdd() name = bd.getValue(self.id, "tipster") self.txtName.setText(name) bd.close()
def initTree(self): self.treeBookie.clear() data = Bookie.selectAll() items = [] for i in data: bank = Bookie.sumAll("bookie=" + str(i.id)) bank = 0.0 if bank is None else bank bonus = Bookie.sumBonus("bookie=" + str(i.id)) bonus = 0.0 if bonus is None else bonus bank += bonus if 0.01 > bank > -0.01: continue item = QTreeWidgetItem( [i.name, "{0:.2f}".format(bank) + self.coin]) items.append(item) self.treeBookie.addTopLevelItems(items) self.treeMovement.clear() bd = Bbdd() data = bd.select("movement", "date DESC") items = [] for i in data: id = i[0] try: sDate = datetime.strptime(i[1], "%d/%m/%y") except: sDate = datetime.strptime(i[1], "%d/%m/%Y") # Fix for Windows sDate = date.strftime(sDate, "%Y/%m/%d") account = i[2] if account == 1: account = "Banco" elif account == 2: account = "Paypal" elif account == 3: account = "Skrill" bookie = bd.getValue(i[3], "bookie") money = i[4] if money < 0: type = _("Withdrawal to the bank.") else: type = _("Deposit at bookie") item = QTreeWidgetItem([ str(sDate), str(id), bookie, type, str(account), str(money) + self.coin ]) items.append(item) self.treeMovement.addTopLevelItems(items) bd.close()
def initTree(self): year = self.cmbYear.currentText() month = self.cmbMonth.currentText() month = monthToNumber(month) self.treeMain.clear() bd = Bbdd() data = bd.select("bet", "date DESC", "date LIKE '" + year + "-" + month + "%'") index = 0 items = [] for i in data: index += 1 id = i[0] date = i[1][:-3] competition = bd.getValue(i[3], "competition") region = bd.getValue(i[4], "region") player1 = i[5] player2 = i[6] pick = i[7] #bookie = bd.getValue(i[8], "bookie") market = bd.getValue(i[9], "market") # TODO Preload in dictionary tipster = bd.getValue(i[10], "tipster") # TODO Preload in dictionary stake = i[11] one = i[12] result = numberToResult(i[13]) profit = i[14] bet = i[15] quota = i[16] item = QTreeWidgetItem([str(index), str(id), str(date), "", str(competition), str(region), player1, player2, pick, "", market, tipster, str(stake), str(one) + self.coin, str(bet) + self.coin, str(quota), str(result), str(profit) + self.coin]) item = paint_row(item, profit, i[13]) if os.path.isfile(expanduser("~") + "/.betcon/resources/sports/" + str(i[2]) + ".png"): item.setBackground(3, QBrush(QPixmap(expanduser("~") + "/.betcon/resources/sports/" + str(i[2]) + ".png"))) else: if os.path.isfile(directory + "/../resources/sports/" + str(i[2]) + ".png"): item.setBackground(3, QBrush(QPixmap(directory + "/../resources/sports/" + str(i[2]) + ".png"))) else: sport = bd.getValue(i[2], "sport") item.setText(3, sport) if os.path.isfile(expanduser("~") + "/.betcon/resources/bookies/" + str(i[8]) + ".png"): item.setBackground(9, QBrush(QPixmap(expanduser("~") + "/.betcon/resources/bookies/" + str(i[8]) + ".png"))) else: if os.path.isfile(directory + "/../resources/bookies/" + str(i[8]) + ".png"): item.setBackground(9, QBrush(QPixmap(directory + "/../resources/bookies/" + str(i[8]) + ".png"))) else: bookie = bd.getValue(i[8], "bookie") item.setText(9, bookie) items.append(item) self.treeMain.addTopLevelItems(items) bd.close()
def insert(self): if not self.isEmpty(): bd = Bbdd() msg = bd.insert(["name"], [self.name], "bookie") bd.close() else: msg = "Faltan datos por introducir" return msg
def setId(self, id): self.id = id bd = Bbdd() self.name, self.country = bd.select("bookie", None, "id=" + str(self.id), "name, country")[0] bd.close()
def update(self): if not self.isEmpty(): bd = Bbdd() msg = bd.update(["name"], [self.name], "bookie", "id="+self.id) bd.close() if msg != 0: msg = "Se ha producido un error al actualizar la BBDD" else: msg = "Faltan datos por introducir" return msg
def deleteItem(self): resultado = QMessageBox.question(self, "Eliminar", "¿Estas seguro que desas eliminar este pago?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if resultado == QMessageBox.Yes: bd = Bbdd() bd.delete("tipster_month", self.itemSelected) self.mainWindows.setCentralWidget(TipstersMonth(self.mainWindows)) self.mainWindows.enableTools("tipster_money") bd.close()
def deleteItem(self): resultado = QMessageBox.question( self, _("Remove"), _("Are you sure you want to eliminate this payment?"), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if resultado == QMessageBox.Yes: bd = Bbdd() bd.delete("tipster_month", self.itemSelected) self.mainWindows.setCentralWidget(TipstersMonth(self.mainWindows)) self.mainWindows.enableTools("tipster_money") bd.close()
def deleteConjunta(self): resultado = QMessageBox.question(self, "Eliminar", "¿Estás seguro que desas eliminar esta conjunta?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if resultado == QMessageBox.Yes: bd = Bbdd() bd.delete("conjunta", str(self.itemConjunta)) bd.deleteWhere("conjunta_tipster","conjunta=" + str(self.itemConjunta)) self.mainWindows.setCentralWidget(TipstersMonth(self.mainWindows)) self.mainWindows.enableTools("tipster_money") bd.close()
def accept(self): data = [self.txtRegion.text()] columns = ["name"] bbdd = Bbdd() bbdd.insert(columns, data, "region") bbdd.close() QMessageBox.information(self, _("Added"), _("New region added.")) self.close()
def accept(self): data = [self.txtRegion.text()] columns = ["name"] bbdd = Bbdd() bbdd.update(columns, data, "region", "id=" + self.id) bbdd.close() QMessageBox.information(self, _("Updated"), _("Updated region.")) self.close()
def accept(self): data = [self.txtName.text()] columns = ["name"] bbdd = Bbdd() bbdd.update(columns, data, "tipster", "id=" + self.id) bbdd.close() QMessageBox.information(self, "Actualizado", "Tipster actualizado.") self.close()
def accept(self): data = [self.txtName.text()] columns = ["name"] bbdd = Bbdd() bbdd.insert(columns, data, "tipster") bbdd.close() QMessageBox.information(self, "Añadido", "Nuevo tipster añadido.") self.close()