Exemplo n.º 1
0
def userMenu(current_user):
    choice = -1

    while choice != '7':
        print('\n')
        print('1.Change Address')
        print('2.Generate Vehicle Temporary No.')  
        print('3.Transfer Vehicle Registration')                      
        print('4.Sale Transactions Records')
        print('5.Change Vehicle Details')
        print('6.Change Add License Information')
        print('7.Email : User Personal, Vehicle, License Details')
        print('8.Logout')
        choice = input('Enter your choice: ')
        if choice == '1':
            address = input('Address: ').upper()
            city = input('City: ').upper()
            state = input('State: ').upper()
            pincode = int(input('Pincode: '))
            query = "UPDATE account_holder_details SET address = %s, city = %s, state = %s, pincode = %s where user_id=%s "
            cur = db.getCursor()
            if cur.execute(query, (address, city, state, pincode,current_user)):
                db.commit()
                print("")
                print('Address was updated!')
            else:
                print('Address could not be updated')
        if choice == '2':
            user_id = input('User id (Case-Sensitive): ')
            password = input('Password : '******'Vehicle Name :').upper()
            vtype = input('Vehicle Type (2/4 Wheeler) :').upper()
            vmodel = input('Vehicle Model :').upper()
            vprice = input('Vehicle Price :').upper()
            vowner = input('Vehicle Owner Name :').upper()
            new_number = Number(user_id, vname, vtype, vmodel, vprice, vowner)
            
            
            if ((User.authenticate(user_id,password)) and (new_number.save())):
                print("")
                print('Your temporary no. generated successfully!')
                print("")
                random = temp()
                random.gen()
                     
               
            else:
                print('Not Generated')
                
                     
            
                
             
        elif choice == '3':
            user_id = input('User id (Case-Sensitive): ')
            password = input('Password : '******'Vehicle Sale Year :'))
            vnumber = input('Vehicle Number :').upper()
            vnowner = input('Vehicle New Owner Name :').upper()
            vprice = input('Vehicle Sale Price :').upper()
            vpowner = input('No. of Vehicle Previous Owners :').upper()
            vtype = input('Vehicle Type (2/4 Wheeler): ').upper()
            new_transfer = transfer(user_id, vyear, vnumber, vnowner, vprice, vpowner, vtype)
            if((User.authenticate(user_id,password)) and (new_transfer.save())):
                print("")
                print('Your Vehicle Got Transferred to {}!'.format(vnowner))
                Task.active(user_id)
                
            else:
                print('Not Transferred !')
        elif choice == '4':
            user_id = input('Enter User id (Case-Sensitive): ')
            print("")
            stataccount = Task.getStataccount(user_id)
            for statement in stataccount:
                print("Personal User Information:")
                print("First Name | Last Name | Address | City | State")
                print(str(statement[0]) + "|" + str(statement[1]) + "|" + str(statement[5]) + "|" + str(statement[6]) + "|" + str(statement[7]))
                print("")
            statvehicle = Task.getStatvehicle(user_id)
            for stat in statvehicle:
                print("Vehicle Details:")
                print("Vehicle No. | Vehicle Name | Vehicle Type(2/4) | Vehicle Year | Vehicle Owner | Vehicle State")
                print(str(stat[1]) + "|" + str(stat[3]) + "|" + str(stat[2]) + "|" + str(stat[7]) + "|" + str(stat[6]) + "|" + str(stat[8]))
                print("")
            stattransfer = Task.getStattransfer(user_id)
            for state in stattransfer:
                print("Vehicle Transfer Details:")
                print("Vehice Sale Year | Vehicle Number | Vehicle New Owner | Vehicle Sale Price | No. of Previous Owners")
                print(str(state[1]) + "|" + str(state[2]) + "|" + str(state[3]) + "|" + str(state[4]) + "|" + str(state[5]))
            
        elif choice == '5':
            vehicle_no = input('Vehicle No.: ').upper()
            vehicle_type = input('Vehicle Type (2/4 Wheeler): ').upper()
            vehicle_name = input('Vehicle Name: ').upper()
            vehicle_model = input('Vehicle Model: ').upper()
            vehicle_color = input('Vehicle Color: ').upper()
            vehicle_owner = input('Vehicle Owner Name: ').upper()
            vehicle_year = int(input('Vehicle Purchase Year: '))
            query = "UPDATE vehicle_details SET vehicle_no = %s, vehicle_type = %s, vehicle_name = %s, vehicle_model = %s, vehicle_color = %s, vehicle_owner = %s, vehicle_year = %s where user_id=%s "
            cur = db.getCursor()
            if cur.execute(query, (vehicle_no, vehicle_type, vehicle_name, vehicle_model, vehicle_color, vehicle_owner, vehicle_year,current_user)):
                db.commit()
                print("")
                print('Vehicle Details was updated!')
            else:
                print('Vehilce Deatils could not be updated')
                
        elif choice == '6': 
            license_no = input('Enter your License no.: ').upper()
            driver_name = input('Enter Driver Name: ').upper()
            issue_year = int(input('Issued Year: '))
            expire_year = int(input('Expire Year (Valid Upto): '))
            issue_authority = input('Issue Authority: ').upper()
            vehicle_type = input('Vehicle Type (2/4 Wheeler): ').upper()
            query = "UPDATE license_details SET license_no = %s, driver_name = %s, issue_year = %s, expire_year = %s, issue_authority = %s, vehicle_type = %s where user_id=%s "
            cur = db.getCursor()
            if cur.execute(query, (license_no, driver_name, issue_year, expire_year, issue_authority, vehicle_type,current_user)):
                db.commit()
                print("")
                print('License Information was updated!')
            else:
                print('License Information could not be updated')
           
        elif choice == '7': 
            print("")
            print("Note: Enter Your User id - Information Mail attached to ID will be sent!")
            print("")
            user_id = input('Enter User id (Case-Sensitive): ')
            email_id = input('Enter Email-ID: ')
            details_email.getmail(user_id,email_id)
        elif choice == '8':
            mainMenu()
        else:
            print('Invalid option!')