Support Forums

Full Version: Busniess Management Script Version 1.4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
  • 1.4

  • Added ability to delete items in list
  • Setup added to avoid errors on first time use


    1.3

  • Fixed clearing list bug
  • Phonebook added
  • Fixed invalid inputs

    1.2

  • Schedule added
  • You can clear your lists

    1.1

  • Primary release
  • Allows you to keep track of your employee's and their salaries

Code:
import os,platform

def menu():
    clearer()
    print "##################################### "
    print "#   Nevets04's Company Management   # "
    print "##################################### "
    print "1) Schedule                           "
    print "2) Salaries                           "
    print "3) Phonebook                          "
    z = int(raw_input("What do you want to do?: "))
    if z == 1:
        schedule()
    elif z == 2:
        salary()
    elif z == 3:
        phone()
    else:
        raw_input("Invalid Option, Press Enter To Continue")
        menu()

def clearer():
    systemver=platform.release()
    if systemver=='XP':
        os.system("cls")
    elif systemver=='Vista':
        os.system("clear")
    else:
        os.system("clear")
clearer()

def add(b):
    clearer()
    c = int(raw_input("How much is %s paid an hour?: $" % b))
    clearer()
    d = int(raw_input("How many hours does %s work a day?: " % b))
    clearer()
    d2 = int(raw_input("How many days does %s work a week?: " % b))
    clearer()
    e = (c * d) * d2
    q = "%s: $%s" %(b,e)
    q = "".join(q)
    print q
    print "1) Yes"
    print "2) No"
    f = int(raw_input("Do you want to save this?: "))
    if f == 1:
        x = open('Employee.txt', 'a')    
        x.write(q)
        x.write('\n')
        x.close()
        menu()
    elif f == 2:
        menu()
    else:
        raw_input("Invalid Option, Press Enter To Continue")
        menu()

def salary():
    clearer()
    print "1) Add an Employee"
    print "2) View Employees"
    print "3) Delete an Employee"    
    print "4) Clear Employees"
    print "9) Main Menu"
    a = int(raw_input("What do you want to do?: "))
    if a == 1:
        add(raw_input("Employee Name: "))
    elif a == 2:
        clearer()
        f = open("Employee.txt", 'r')
        for line in f:
            print line,
        raw_input("Press Enter To Continue")
        menu()
    elif a == 4:
        x = open('Employee.txt', 'w')    
        x.write("")
        x.close()
        menu()
    elif a == 3:
        x = open('Employee.txt','r')
        l = []
        q = 0
        for line in x:
            l.append(str(line))
        b = "".join(l)
        print b
        a = raw_input("Which line do you want to delete?: ")
        r = int(a)
        q = r - 1
        l[q:r] = ""
        b = "".join(l)
        x.close()
        x = open('Employee.txt','w')
        x.write(b)
        x.close()
        menu()
    if a == 9:
        menu()
    else:
        raw_input("Invalid Option, Press Enter To Continue")
        menu()


def schedule():
    clearer()
    print "1) Add an Event"
    print "2) View Shedule"
    print "3) Delete an Event"    
    print "4) Clear Schedule"
    print "9) Main Menu"
    ask = int(raw_input("What do you want to do: "))
    if ask == 1:
        a = raw_input("When is the event?: ")
        b = raw_input("What is the event?: ")
        q = "%s: %s" %(a,b)
        q = "".join(q)
        print q
        print "1) Yes"
        print "2) No"
        f = int(raw_input("Do you want to save this?: "))
        if f == 1:    
            c = open('Schedule.txt', 'a')
            c.write(q)
            c.write("\n")
            c.close()
            menu()
        elif f == 2:
            menu()
        else:
            raw_input("Invalid Option, Press Enter To Continue")
            menu()
    elif ask == 2:
        clearer()
        f = open("Schedule.txt", 'r')
        for line in f:
            print line,
        raw_input("Press Enter To Continue")
        menu()
    elif ask == 4:
        c = open('Schedule.txt', 'w')
        c.write("")
        c.close()
        menu()
    elif ask == 3:
        x = open('Schedule.txt','r')
        l = []
        q = 0
        for line in x:
            l.append(str(line))
        b = "".join(l)
        print b
        a = raw_input("Which line do you want to delete?: ")
        r = int(a)
        q = r - 1
        l[q:r] = ""
        b = "".join(l)
        x.close()
        x = open('Schedule.txt','w')
        x.write(b)
        x.close()
        menu()

    elif ask == 9:
        menu()
    else:
        raw_input("Invalid Option, Press Enter To Continue")
        menu()

def phone():
    clearer()
    print "1) Add a Number"
    print "2) View Phonebook"
    print "3) Delete a Number"
    print "4) Clear Phonebook"
    print "9) Back"
    a1 = int(raw_input("What do you want to do: "))
    if a1 == 1:
        a = raw_input("Name: ")
        b = raw_input("Phone Number: ")
        q = "%s: %s" %(a,b)
        q = "".join(q)
        print q
        print "1) Yes"
        print "2) No"
        c = int(raw_input("Do you want to save this this?: "))
        if c == 1:
            d1=open("Phonebook.txt", 'a')
            d1.write(q)
            d1.write("\n")
            d1.close()
            menu()
        elif c == 2:
            menu()
        else:
            raw_input("Invalid Option, Press Enter To Continue")
            menu()
    elif a1 == 2:
        clearer()
        f = open("Phonebook.txt", 'r')
        for line in f:
            print line,
        raw_input("Press Enter To Continue")    
        menu()
    elif a1 == 4:
        x = open("Phonebook.txt", "w")
        x.write("")
        x.close()
        menu()
    elif a1 == 9:
        menu()
    elif a1 == 3:
        x = open('Phonebook.txt','r')
        l = []
        q = 0
        for line in x:
            l.append(str(line))
        b = "".join(l)
        print b
        a = raw_input("Which line do you want to delete?: ")
        r = int(a)
        q = r - 1
        l[q:r] = ""
        b = "".join(l)
        x.close()
        x = open('Phonebook.txt','w')
        x.write(b)
        x.close()
        menu()
    else:
        raw_input("Invalid Option, Press Enter To Continue")
        menu()        
        
        
menu()
Nice job! I like it Victoire
(11-15-2009, 06:22 PM)uber1337 Wrote: [ -> ]Nice job! I like it Victoire

Thanks.