Example #1
0
 def bad_input(self):
     print("Choose from above!")
     number=msvcrt.getwch()
     if number=="1":
         self.get_unique_id()
     elif number=="2":
         donor_main()
     elif number=="3":
         main.creat_menu()
     else:
         self.bad_input()
Example #2
0
def end_of_search():
    print('1. New search')
    print('2. Back')
    get=msvcrt.getwch()
    if get=='1':
        main.search_menu()
    elif get=='2':
        main.creat_menu()
    else:
        print('Choose one!')
        end_of_search()
def end_of_delete(kind):
    get=msvcrt.getwch()
    if get=='1':
        if kind=='donor':
            delete_donor_from_csv_file()
        elif kind=='donation_event':
            delete_donations_from_csv_file()
    elif get=='2':
        main.creat_menu()
        return True
    else:
        print("Choose one!")
        end_of_delete(kind)
Example #4
0
def donor_data_modifier():
    lista=[]
    found=0
    os.system('cls')
    change_according_ID=input("What ID you search for: ").lower()
    read_line=open("Data/donor.csv", "r+")
    read_the_list=csv.reader(read_line,delimiter=',',quotechar='"')
    for row in read_the_list:
        if row[7]==change_according_ID:
            found+=1
            lista=row
            print('-'*40)
            name=row[0].split(" ")
            if len(name)==2:
                print("\t "+name[1]+ ", "+ name[0])
            elif len(name)==3:
                print("\t "+name[2]+", "+name[1]+", "+name[0])
            print("\t "+str(row[1])+"kg")
            print("\t "+row[2][0:4]+"."+row[2][5:7]+"."+row[2][8:10]+"  -  "+str(row[3])+" years old")
            print("\t "+row[9])
            print("\t "+row[10])
            print("\t "+"ID: "+row[7])
            print('-'*40)
            print('\n')
    read_line.close()
    if found==0:
        print("This ID not found!")
        msvcrt.getwch()
    else:
        delete_from_csv = open("Data/donor.csv", "r+")
        read_csv_line=delete_from_csv.readlines()
        delete_from_csv.seek(0)
        for i in read_csv_line:
            splitted=i.split(',')
            if change_according_ID!=splitted[7]:
                delete_from_csv.write(i)
        delete_from_csv.truncate()
        delete_from_csv.close()
        write_rows=open("Data/donor.csv", 'a', newline='\n')
        writter=csv.writer(write_rows)
        lista=donor_data_manager(lista)
        writter.writerow(lista)
        write_rows.close()
        msvcrt.getwch()
    main.creat_menu()
Example #5
0
 def add_unique_id_if_not_unique(self):
     with open('Data\donor.csv', 'r+') as read:
             reader = csv.reader(read)
             for row in reader:
                 if row[7].lower() == self.unique_id:
                     print("This unique id is already living in database!\n")
                     print("1. Did you miss type? ID again.")
                     print("2. Add new Donor")
                     print("3. Back to main menu\n")
                     number=msvcrt.getwch()
                     if number=="1":
                         self.unique_id=""
                         self.get_unique_id()
                     elif number=="2":
                         donor_main()
                     elif number=="3":
                         main.creat_menu()
                     else:
                         self.bad_input()
def donation_data_modifier():
    lista=[]
    found=0
    os.system('cls')
    change_according_ID=input("What ID you search for: ").upper()
    read_line=open("Data/donations.csv", "r+")
    read_the_list=csv.reader(read_line,delimiter=',',quotechar='"')
    for row in read_the_list:
        if row[0]==change_according_ID:
            found+=1
            lista=row
            print('-'*40)
            print("\t"+"ID: "+row[0])
            print("\t "+row[1])
            print("\t "+row[2]+" - "+row[3])
            print("\t "+row[4]+' '+ row[5]+' '+row[6])
            print('-'*40)
            print('\n')
    read_line.close()
    if found==0:
        print("This ID not found!")
        msvcrt.getwch()
    else:
        delete_from_csv = open("Data/donations.csv", "r+")
        read_csv_line=delete_from_csv.readlines()
        delete_from_csv.seek(0)
        for i in read_csv_line:
            splitted=i.split(',')
            if change_according_ID!=splitted[0]:
                delete_from_csv.write(i)
        delete_from_csv.truncate()
        delete_from_csv.close()
        write_rows=open("Data/donations.csv", 'a', newline='\n')
        writter=csv.writer(write_rows)
        lista=donation_data_manager(lista)
        writter.writerow(lista)
        write_rows.close()
        msvcrt.getwch()
    main.creat_menu()
Example #7
0
def donation_data_modifier():
    lista = []
    found = 0
    os.system('cls')
    change_according_ID = input("What ID you search for: ").upper()
    read_line = open("Data/donations.csv", "r+")
    read_the_list = csv.reader(read_line, delimiter=',', quotechar='"')
    for row in read_the_list:
        if row[0] == change_according_ID:
            found += 1
            lista = row
            print('-' * 40)
            print("\t" + "ID: " + row[0])
            print("\t " + row[1])
            print("\t " + row[2] + " - " + row[3])
            print("\t " + row[4] + ' ' + row[5] + ' ' + row[6])
            print('-' * 40)
            print('\n')
    read_line.close()
    if found == 0:
        print("This ID not found!")
        msvcrt.getwch()
    else:
        delete_from_csv = open("Data/donations.csv", "r+")
        read_csv_line = delete_from_csv.readlines()
        delete_from_csv.seek(0)
        for i in read_csv_line:
            splitted = i.split(',')
            if change_according_ID != splitted[0]:
                delete_from_csv.write(i)
        delete_from_csv.truncate()
        delete_from_csv.close()
        write_rows = open("Data/donations.csv", 'a', newline='\n')
        writter = csv.writer(write_rows)
        lista = donation_data_manager(lista)
        writter.writerow(lista)
        write_rows.close()
        msvcrt.getwch()
    main.creat_menu()
Example #8
0
def list_donations():
    row_number = -1
    hits = []
    total = []
    counter = 0
    global size
    rows = size[1]
    with open(os.path.join(os.path.dirname(sys.argv[0]), "Data\donations.csv"),
              newline='') as csvfile:
        search_file = csv.reader(csvfile, delimiter=',', quotechar='"')
        for row in search_file:
            if row != "":
                row_number += 1
            if row_number > 0:
                total.append(row)

        if row_number == 0:
            print("There is nothing in the list!")
            msvcrt.getwch()
            main.creat_menu()
        elif row_number > 0:
            print("What should be the order:\n"
                  "1. id\n"
                  "2. date of event\n"
                  "3. start time\n"
                  "4. end time\n"
                  "5. zip_code\n"
                  "6. city\n"
                  "7. address\n"
                  "8. number of available beds\n"
                  "9. planned donor number\n"
                  "10. final_donor_number")
            order_donation = int(input())
            while order_donation not in donation_listing_order:
                print("choose from above")
                order_donation = int(input())
            if int(order_donation) in donor_listing_order:
                for order_int in total:
                    order_int[7] = int(order_int[7])
                    order_int[8] = int(order_int[8])
                    order_int[9] = int(order_int[9])
                total = sorted(total, key=itemgetter(int(order_donation) - 1))
                for i in total:
                    counter += 1
                    hits.append('-' * 40)
                    hits.append(str(counter) + "." + "\t" + "ID: " + i[0])
                    hits.append("\t " + i[1])
                    hits.append("\t " + i[2] + " - " + i[3])
                    hits.append("\t " + i[4] + ' ' + i[5] + ' ' + i[6])
            os.system('cls')
            page_row = (rows - 1) // 5
            page = 0
            length = len(hits)
            while page < length:
                os.system('cls')
                for i in range(0 + page, page_row * 5 + page):
                    if i < length:
                        print(hits[i])
                    else:
                        break
                key = msvcrt.getwch()
                if key == 's':
                    page += page_row * 5
                if key == 'w':
                    page -= page_row * 5
                    if page < 0:
                        page = 0
        main.creat_menu()
Example #9
0
def list_donors():
    counter = 0
    row_number = -1
    hits = []
    total = []
    global size
    rows = size[1]
    with open(os.path.join(os.path.dirname(sys.argv[0]), "Data\donor.csv"),
              newline='') as csvfile:
        search_file = csv.reader(csvfile, delimiter=',', quotechar='"')
        for row in search_file:
            if row != "":
                row_number += 1
            if row_number > 0:
                total.append(row)
        if row_number == 0:
            print("There is nothing in the list!")
            msvcrt.getwch()
            main.creat_menu()
        elif row_number > 0:
            print("What should be the order:\n"
                  "1. name\n"
                  "2. weight\n"
                  "3. date of birth\n"
                  "4. age\n"
                  "5. last donation date\n"
                  "6. sickness\n"
                  "7. gender\n"
                  "8. unique id\n"
                  "9. expiration of id\n"
                  "10. email address\n"
                  "11. blood type\n"
                  "12. mobile_number\n"
                  "13. hemoglobin_level\n")
            order_donor = int(input())
            while order_donor not in donor_listing_order:
                print("choose from above")
                order_donor = int(input())
            if int(order_donor) in donor_listing_order:
                for order_int in total:
                    order_int[1] = int(order_int[1])
                    order_int[3] = int(order_int[3])
                    order_int[12] = int(order_int[12])
                total = sorted(total, key=itemgetter(int(order_donor) - 1))
                for i in total:
                    counter += 1
                    hits.append('-' * 40)
                    name = i[0].split(" ")
                    if len(name) == 2:
                        hits.append(
                            str(counter) + "." + "\t " + name[1] + ", " +
                            name[0])
                    elif len(name) == 3:
                        hits.append(
                            str(counter) + "." + "\t " + name[2] + ", " +
                            name[1] + ", " + name[0])
                    hits.append("\t " + str(i[1]) + "kg")
                    hits.append("\t " + i[2][0:4] + "." + i[2][5:7] + "." +
                                i[2][8:10] + "  -  " + str(i[3]) +
                                " years old")
                    hits.append("\t " + i[9])
                    hits.append("\t " + i[10])
                    hits.append("\t " + "ID: " + i[7])
                os.system('cls')
                page_row = (rows - 1) // 7
                page = 0
                length = len(hits)
                while page < length:
                    os.system('cls')
                    for i in range(0 + page, page_row * 7 + page):
                        if i < length:
                            print(hits[i])
                        else:
                            break
                    key = msvcrt.getwch()
                    if key == 's':
                        page += page_row * 7
                    if key == 'w':
                        page -= page_row * 7
                        if page < 0:
                            page = 0

        main.creat_menu()