Exemple #1
0
def CancelTicket(transactionList, validServices, loginMode):
    serviceNumber = input()
    if not validation.ValidServNumber(serviceNumber):
        return

    numTickets = input()
    if not validation.validNumberOfTickets(numTickets):
        return
    ticketsCancelled = int(numTickets) + validation.TicketsServiced(
        serviceNumber, "CAN", transactionList)
    if ticketsCancelled > 10 and loginMode == "agent":
        print(
            "error: cannot cancel more than 10 tickets of same service in agent mode"
        )
        return
    totalTicketsCancelled = int(numTickets) + validation.AllTicketsServiced(
        "CAN", transactionList)
    if totalTicketsCancelled > 20 and loginMode == "agent":
        print("error: cannot cancel more than 20 tickets in agent mode")
        return

    if not validation.ServiceExistsVSF(serviceNumber, validServices):
        print("error: service does not exist")
        return
    if validation.ServiceExistsTSF(serviceNumber, transactionList):
        print("error: service has been newly created or newly deleted")
        return
    transactionList.append(
        fileio.CreateTransaction("CAN", serviceNumber, numTickets))
Exemple #2
0
def SellTicket(transactionList, validServices):
    serviceNumber = input()
    if not validation.ValidServNumber(serviceNumber):
        return
    numTickets = input()
    if not validation.validNumberOfTickets(numTickets):
        return
    if not validation.ServiceExistsVSF(serviceNumber, validServices):
        print("error: service does not exist")
        return
    if validation.ServiceExistsTSF(serviceNumber, transactionList):
        print("error: service has been newly created or newly deleted")
        return
    transactionList.append(
        fileio.CreateTransaction("SEL", serviceNumber, numTickets))
Exemple #3
0
def DeleteService(transactionList, validServices):
    serviceNumber = input()
    if not validation.ValidServNumber(serviceNumber):
        return
    serviceName = input()
    if not validation.ValidServName(serviceName):
        return
    if not validation.ServiceExistsVSF(serviceNumber, validServices):
        print("error: service does not exist")
        return
    if validation.ServiceExistsTSF(serviceNumber, transactionList):
        print("error: service has been newly created or newly deleted")
        return

    transactionList.append(
        fileio.CreateTransaction("DEL", serviceNumber, serviceName))
Exemple #4
0
def ChangeTicket(transactionList, validServices, loginMode):
    serviceNumber1 = input()
    if not validation.ValidServNumber(serviceNumber1):
        return
    if not validation.ServiceExistsVSF(serviceNumber1, validServices):
        print("error: source service does not exist")
        return
    if validation.ServiceExistsTSF(serviceNumber1, transactionList):
        print("error: source service has been newly created or newly deleted")
        return

    serviceNumber2 = input()
    if not validation.ValidServNumber(serviceNumber2):
        return
    if not validation.ServiceExistsVSF(serviceNumber2, validServices):
        print("error: destination service does not exist")
        return
    if validation.ServiceExistsTSF(serviceNumber2, transactionList):
        print(
            "error: destination service has been newly created or newly deleted"
        )
        return

    if serviceNumber1 == serviceNumber2:
        print("error: service numbers cannot be identical")
        return

    numTickets = input()
    if not validation.validNumberOfTickets:
        return
    totalTicketsCancelled = int(numTickets) + validation.AllTicketsServiced(
        "CHG", transactionList)
    if totalTicketsCancelled > 20 and loginMode == "agent":
        print("error: cannot cancel more than 20 tickets in agent mode")
        return
    transactionList.append(
        fileio.CreateTransaction("CHG", serviceNumber1, serviceNumber2,
                                 numTickets))