Example #1
0
def handlesSelectedMainMenuOption(option, DBConnection):
    if (option == MAIN_MENU_NUM_OPTION1):
        sql_functions.InsertTupleTableFator(DBConnection)
        return
    if (option == MAIN_MENU_NUM_OPTION2):
        sql_functions.InsertTupleTablePeso(DBConnection)
        return
    if (option == MAIN_MENU_NUM_OPTION3):
        sql_functions.InsertTupleTableTime(DBConnection)
        return
    if (option == MAIN_MENU_NUM_OPTION4):
        sql_functions.changeFactorStatus(DBConnection)
        return
    if (option == MAIN_MENU_NUM_OPTION5):
        sql_functions.presentsAllFactors(DBConnection)
        return
    if (option == MAIN_MENU_NUM_OPTION6):
        sql_functions.presentsAllWeights(DBConnection)
        return
    if (option == MAIN_MENU_NUM_OPTION7):
        sql_functions.presentsAllTeams(DBConnection)
        return
    if (option == MAIN_MENU_NUM_OPTION8):
        return
    if (option == MAIN_MENU_NUM_OPTION9):
        aux_functions.showOkMessage(4)
        return

    aux_functions.showErrorMessage(1)
Example #2
0
def changeFactorStatus(DBConnection):
    if (not IsThereFactor(DBConnection)):
        aux_functions.showErrorMessage(3)
        return

    nameFactor = getsFactorNameChangeStatus(DBConnection)
    if (nameFactor == None):
        return
    status = bool(factorStatus(DBConnection, nameFactor))
    if (status):
        statusStr = ANSI_GREEN_INITIAL_CODE + VAL_ON_STATUS_FATOR + ANSI_DEFAULT_FINAL_COLOR_CODE
    else:
        statusStr = ANSI_RED_INITIAL_CODE + VAL_OFF_STATUS_FATOR + ANSI_DEFAULT_FINAL_COLOR_CODE

    print(PHROUT_CURRENT_VALUE_CHANGE_FACTOR_STATUS + statusStr)
    newStatus = getsNewStatusChangeStatus()
    newStatusStr = str(newStatus)
    if (status == newStatus):
        aux_functions.showErrorMessage(15)
        return

    cursor = DBConnection.cursor()
    cursor.execute("UPDATE FATOR SET STATUS = " + newStatusStr + " WHERE NOME = '" + nameFactor + "'")
    DBConnection.commit()
    aux_functions.showOkMessage(3)
Example #3
0
def getsAttributeValueNewTupleTablePeso():
    strValue = input(PHR_VALUE_NEW_TUPLE_TABLE_PESO)
    floatValue = float(strValue)
    if (not aux_functions.isNumberInRange(floatValue, 0.00, 1.00)):
        aux_functions.showErrorMessage(9)
        return None
    
    return floatValue
Example #4
0
def getsFactorNameChangeStatus(DBConnection):
    factorName = input(PHR_NAME_CHANGE_FACTOR_STATUS)
    if (factorName == '' or len(factorName) > 45):
        aux_functions.showErrorMessage(14)
        return None
    if (not isAnExistingFactor(DBConnection, factorName)):
        aux_functions.showErrorMessage(8)
        return None
    
    return factorName
Example #5
0
def getsAttributeFactorNameNewTupleTablePeso(DBConnection):
    factorName = input(PHR_FACTOR_NEW_TUPLE_TABLE_PESO)
    if (factorName == '' or len(factorName) > 45):
        aux_functions.showErrorMessage(7)
        return None
    if (not isAnExistingFactor(DBConnection, factorName)):
        aux_functions.showErrorMessage(8)
        return None
    
    return factorName.upper()      
Example #6
0
def presentsAllTeams(DBConnection):
    if (not IsThereTeam(DBConnection)):
        aux_functions.showErrorMessage(19)
        return

    cursor = DBConnection.cursor()
    cursor.execute('SELECT * FROM TIME')    
    queryResult = cursor.fetchall()
    formattedResult = formatResultQueryTableTeam(queryResult)
    print('\n' + PHROUT_HEADER_PRESENT_ALL_TEAMS)
    print(PHROUT_TOTAL_PRESENT_ALL_TABLES + str(len(queryResult)) + '\n')
    print(formattedResult)
    print(PHROUT_FOOTER_PRESENT_ALL_TEAMS)
Example #7
0
def presentsAllWeights(DBConnection):
    if (not IsThereWeight(DBConnection)):
        aux_functions.showErrorMessage(13)
        return

    option = getsOptionPresentationWeights()
    cursor = DBConnection.cursor()
    optionUpper = option.upper()
    if (optionUpper == VAL_Y_AS_YES):
        cursor.execute('SELECT NOME FROM PESO')
        isShowOnlyName = True
    else:
        cursor.execute('SELECT * FROM PESO')
        isShowOnlyName = False
    
    queryResult = cursor.fetchall()
    formattedResult = formatResultQueryTableWeight(queryResult, isShowOnlyName)
    print('\n' + PHROUT_HEADER_PRESENT_ALL_WEIGHTS)
    print(PHROUT_TOTAL_PRESENT_ALL_TABLES + str(len(queryResult)) + '\n')
    print(formattedResult)
    print(PHROUT_FOOTER_PRESENT_ALL_WEIGHTS)
Example #8
0
def InsertTupleTablePeso(DBConnection):
    name = ''
    factorName = ''
    valor = 0.00

    if (not IsThereFactor(DBConnection)):
        aux_functions.showErrorMessage(3)
        return
    name = getsAttributeNameNewTupleTablePeso(DBConnection)
    if (name == None):
        return
    factorName = getsAttributeFactorNameNewTupleTablePeso(DBConnection)
    if (factorName == None):
        return
    valor = getsAttributeValueNewTupleTablePeso()
    if (valor == None):
        return

    cursor = DBConnection.cursor()
    cursor.execute("INSERT INTO peso(nome, nomefator, valor) VALUES ('" + name + "', '" + factorName + "', " + str(valor) + ")")
    DBConnection.commit()
    aux_functions.showOkMessage(2)
Example #9
0
def getsAttributeNameNewTupleTableFator(DBConnection):
    name = input(PHR_NAME_NEW_TUPLE_TABLE_FATOR)
    if (name == ''):
        aux_functions.showErrorMessage(2)
        return None
    if (len(name) > 45):
        aux_functions.showErrorMessage(4)
        return None
    if (isAnExistingFactor(DBConnection, name)):
        aux_functions.showErrorMessage(12)
        return None

    return name.upper()
Example #10
0
def getsAttributeNameNewTupleTableTime(DBConnection):
    name = input(PHR_NAME_NEW_TUPLE_TABLE_TIME)
    if (name == ''):
        aux_functions.showErrorMessage(16)
        return None
    if (len(name) > 100):
        aux_functions.showErrorMessage(17)
        return None
    if (isAnExistingTeam(DBConnection, name)):
        aux_functions.showErrorMessage(18)
        return None

    return name.upper()
Example #11
0
def getsAttributeNameNewTupleTablePeso(DBConnection):
    name = input(PHR_NAME_NEW_TUPLE_TABLE_PESO)
    if (name == ''):
        aux_functions.showErrorMessage(5)
        return None
    if (len(name) > 60):
        aux_functions.showErrorMessage(6)
        return None
    if (isAnExistingWeight(DBConnection, name)):
        aux_functions.showErrorMessage(11)
        return None
    
    
    return name.upper()