Ejemplo n.º 1
0
def update_bt_handler():
    try:
        teams_capacity = int(teams_capacity_tb.get())
        bunkhouses_capacity = int(bunkhouses_capacity_tb.get())
    except:
        tkMessageBox.showinfo(title="message",message="Teams and Bunkhouses Capacity must be numbers")
        return
    else:
        Bunkhouse.update_bunkhouses_num(bunkhouses_capacity)
        Team.update_teams_num(teams_capacity)
        cancel_bt_handler()
Ejemplo n.º 2
0
def update_camper_team_bt_handler():
    try:
        camper_id = int(camper_id_tb.get())
        camp_id = int(camp_id_tb.get())
        team_id = int(team_id_tb.get())
    except:
        tkMessageBox.showinfo(
            title="message",
            message="Camper ID, Camp ID and Team ID must be numbers")
        return
    data = Bunkhouse.select_camp_team_bunkhouse(
        camper_id)  #camps, teams, bunkhouses
    if str(camp_id) not in data[0]:
        tkMessageBox.showinfo(
            title="message",
            message="The Camper selected is not registered in this camp")
        return
    team_id_old = data[1][data[0].index(str(camp_id))]
    #check if there is a room available
    available_teams = Team.get_available_team(camp_id)
    if (team_id, ) not in available_teams:
        tkMessageBox.showinfo(title="message",
                              message="This Team is Full, choose another one.")
        return
    Team.decrement_checked_in(team_id_old)
    Team.increment_checked_in(team_id)
    Team.update_team_id(camper_id, camp_id, team_id)
    tkMessageBox.showinfo(title="message",
                          message="Team is updated successfully")
    cancel_team_forum_bt_handler()
Ejemplo n.º 3
0
def check_in_bt_handler():

    try:
        camper_id = int(camper_id_tb.get())
        camp_id = int(camp_id_tb.get())
    except:
        tkMessageBox.showinfo(title="message",
                              message="camper and camp id must be nubmers")
        return
    checked_in_camper = Camper(camper_id)
    checked_in_camp = Camp(camp_id)
    if checked_in_camper.select_camper() == None:
        tkMessageBox.showinfo(title="message", message="camper not found")
        return
    if checked_in_camp.select_camp() == None:
        tkMessageBox.showinfo(title="message", message="camp not found")
        return
    #check if this camper is regestered in this camp
    data = Bunkhouse.select_camp_team_bunkhouse(camper_id)
    if not str(camp_id) in data[0]:
        tkMessageBox.showinfo(
            title="message",
            message="Sorry, You need to register in this camp before Check-in."
        )
        return

    str_buffer = ""
    if slepping_bag_CheckVar.get() == 0:
        str_buffer += "Slepping Bag, "
    if pillow_CheckVar.get() == 0:
        str_buffer += "Pillow, "
    if blanket_CheckVar.get() == 0:
        str_buffer += "Blanket, "
    if spray_CheckVar.get() == 0:
        str_buffer += "Insect Repellent Spray, "
    if bathing_suit_CheckVar.get() == 0:
        str_buffer += "Bathing Suit, "
    if sun_block_CheckVar.get() == 0:
        str_buffer += "Sun Blocking Lotion, "
    if rain_coat_CheckVar.get() == 0:
        str_buffer += "Raincoat, "
    if flashlight_CheckVar.get() == 0:
        str_buffer += "Flashlight, "
    if str_buffer != "":
        f = open("checkin.txt", 'w')
        f.write("Please bring in (" + str_buffer[:-2] + ")")
        f.close()
        import webbrowser
        webbrowser.open("checkin.txt")
        return

    Camp.camper_check_in(camper_id, camp_id)
    tkMessageBox.showinfo(title="message", message="you have checked_in")
    cancel_check_in_bt_handler()
Ejemplo n.º 4
0
def submit_camp_handler():
    if not is_valid_date(start_date_tb.get()):
        tkMessageBox.showinfo(title="message", message="wrong start date.")
        return
    if not is_valid_date(end_date_tb.get()):
        tkMessageBox.showinfo(title="message", message="wrong end date.")
        return
    try:
        bunk_houses_num = int(bunk_houses_num_tb.get())
        teams_num = int(teams_num_tb.get())
        cost = float(cost_tb.get())
    except:
        tkMessageBox.showinfo(title="message",
                              message="wrong number(bunkhouse, team or cost)")
        return
    else:
        tmp_camp = Camp(0, start_date_tb.get(), end_date_tb.get(),
                        bunk_houses_num, teams_num, cost)
        tmp_camp.insert_camp()
        camp_id = tmp_camp.get_camp_id()[0]
        from controller.bunkhouse import Bunkhouse
        for i in range(bunk_houses_num):
            if i % 2 == 0:
                b = Bunkhouse("Male", camp_id)
            else:
                b = Bunkhouse("Female", camp_id)
            b.insert_bunkhouse()

        from controller.team import Team
        for i in range(teams_num):
            team_name = "camp_" + str(camp_id) + "team" + str(i)
            t = Team(camp_id, team_name)
            t.insert_team()
        tkMessageBox.showinfo(title="message", message="record inserted")
        cancel_camp_bt_handler()
Ejemplo n.º 5
0
def start_browse_campers():
    global root
    root = Tk()
    root.title("Browse Campers")
    root.minsize(width=500, height=500)

    browse_camps_tree = Treeview(root)
    browse_camps_tree["columns"] = ("Camper ID", "First Name", "Last Name",
                                    "Date of Birth", "Gender", "Address",
                                    "Camps IDs", "Bunkhouses IDs", "Teams IDs")
    browse_camps_tree.column("Camper ID", width=100)
    browse_camps_tree.column("First Name", width=100)
    browse_camps_tree.column("Last Name", width=100)
    browse_camps_tree.column("Date of Birth", width=100)
    browse_camps_tree.column("Gender", width=100)
    browse_camps_tree.column("Address", width=100)
    browse_camps_tree.column("Camps IDs", width=100)
    browse_camps_tree.column("Bunkhouses IDs", width=100)
    browse_camps_tree.column("Teams IDs", width=100)
    browse_camps_tree.heading("Camper ID", text="Camper ID")
    browse_camps_tree.heading("First Name", text="First Name")
    browse_camps_tree.heading("Last Name", text="Last Name")
    browse_camps_tree.heading("Date of Birth", text="Date of Birth")
    browse_camps_tree.heading("Gender", text="Gender")
    browse_camps_tree.heading("Address", text="Address")
    browse_camps_tree.heading("Camps IDs", text="Camps IDs")
    browse_camps_tree.heading("Bunkhouses IDs", text="Bunkhouses IDs")
    browse_camps_tree.heading("Teams IDs", text="Teams IDs")

    index = 0
    for camper_id in Camper.get_all_ids():
        current_camper = Camper(camper_id[0])
        data = current_camper.select_camper()
        data2 = Bunkhouse.select_camp_team_bunkhouse(camper_id[0])
        browse_camps_tree.insert('',
                                 index,
                                 text="row" + str(index + 1),
                                 values=(camper_id, data[0], data[1], data[2],
                                         data[3], data[4], data2[0][:-2],
                                         data2[2][:-2], data2[1][:-2]))
        index += 1

    browse_camps_tree.pack()

    exit_browse_camp_bt = Button(root,
                                 text="Exit",
                                 width=30,
                                 command=exit_browse_camp_bt_handler)
    exit_browse_camp_bt.pack(expand=True)
    root.mainloop()
Ejemplo n.º 6
0
def update_camper_bunkhouse_bt_handler():
    try:
        camper_id = int(camper_id_tb.get())
        camp_id = int(camp_id_tb.get())
        bunkhouse_id = int(bunkhouse_id_tb.get())
    except:
        tkMessageBox.showinfo(
            title="message",
            message="Camper ID, Camp ID and Bunkhouse ID must be numbers")
        return
    data = Bunkhouse.select_camp_team_bunkhouse(
        camper_id)  #camps, teams, bunkhouses
    if str(camp_id) not in data[0]:
        tkMessageBox.showinfo(
            title="message",
            message="The Camper selected is not registered  in this camp")
        return
    bunkhouse_id_old = data[2][data[0].index(str(camp_id))]
    #check if the camper gender == bunkhouse gender
    myCamper = Camper(camper_id)
    camper_data = myCamper.select_camper()
    bunkhouse_data = Bunkhouse.select_bunkhouse(bunkhouse_id)
    if camper_data[3] != bunkhouse_data[0]:
        tmp = "Error:The Camper selected is " + str(
            camper_data[3]) + " and the bunkhouse selected if for " + str(
                bunkhouse_data[0]) + "s only."
        tkMessageBox.showinfo(title="message", message=tmp)
        return
    #check if there is a room available
    available_bunkhouses = Bunkhouse.get_available_bunkgouses(
        camper_data[3], camp_id)
    if (bunkhouse_id, ) not in available_bunkhouses:
        tkMessageBox.showinfo(
            title="message",
            message="This bunkhouse is Full, choose another one.")
        return
    Bunkhouse.decrement_checked_in(bunkhouse_id_old)
    Bunkhouse.increment_checked_in(bunkhouse_id)
    Bunkhouse.update_bunkhouse_id(camper_id, camp_id, bunkhouse_id)
    tkMessageBox.showinfo(title="message",
                          message="Bunkhouse is updated successfully")
    cancel_bunkhouse_forum_bt_handler()
Ejemplo n.º 7
0
def start_query_browse():
    global root
    root = Tk()
    root.title("Browse Camps, Bunkhouse and Teams")
    root.minsize(width=500, height=500)

    browse_query_tree = Treeview(root)
    browse_query_tree["columns"] = ("1", "2", "3", "4", "5", "6", "7", "8",
                                    "9")
    browse_query_tree.column("1", width=100)
    browse_query_tree.column("2", width=100)
    browse_query_tree.column("3", width=100)
    browse_query_tree.column("4", width=100)
    browse_query_tree.column("5", width=100)
    browse_query_tree.column("6", width=100)
    browse_query_tree.column("7", width=100)
    browse_query_tree.column("8", width=100)
    browse_query_tree.column("9", width=100)
    browse_query_tree.heading("1", text="Bunkhouses IDs")
    browse_query_tree.heading("2", text="Camps IDs")
    browse_query_tree.heading("3", text="Camp Start Date")
    browse_query_tree.heading("4", text="Camp End Date")
    browse_query_tree.heading("5", text="Camper ID")
    browse_query_tree.heading("6", text="First Name")
    browse_query_tree.heading("7", text="Last Name")
    browse_query_tree.heading("8", text="Gender")
    browse_query_tree.heading("9", text="Teams IDs")

    index = 0
    for row_data in Bunkhouse.get_all_query_data():
        browse_query_tree.insert('',
                                 index,
                                 text="row" + str(index + 1),
                                 values=(row_data[0], row_data[1], row_data[2],
                                         row_data[3], row_data[4], row_data[5],
                                         row_data[6], row_data[7],
                                         row_data[8]))
        index += 1

    browse_query_tree.pack()

    exit_bt = Button(root, text="Exit", width=30, command=exit_bt_handler)
    exit_bt.pack(expand=True)
    root.mainloop()
Ejemplo n.º 8
0
def assign_to_camp_bt_handler():
    try:
        camper_id = int(camper_id_tb.get())
        camp_id = int(camp_id_tb.get())
    except:
        tkMessageBox.showinfo(title="message",
                              message="camper and camp id must be nubmers")
        return
    from controller.camper import Camper
    from controller.camp import Camp
    from controller.bunkhouse import Bunkhouse
    from controller.team import Team
    checked_in_camper = Camper(camper_id)
    checked_in_camp = Camp(camp_id)
    if checked_in_camper.select_camper() == None:
        tkMessageBox.showinfo(title="message", message="camper not found")
        return
    if checked_in_camp.select_camp() == None:
        tkMessageBox.showinfo(title="message", message="camp not found")
        return
    #check there is a room for this camper in bunkhouse gender?
    data = checked_in_camper.select_camper()
    gender = data[3]
    bunkhouses_ids = Bunkhouse.get_available_bunkgouses(gender, camp_id)
    if len(bunkhouses_ids) < 1:
        tkMessageBox.showinfo(
            title="message",
            message="Sorry, This camp is not available, Choose another one")
        return
    #check if this camper is already regestered in this camp
    data = Bunkhouse.select_camp_team_bunkhouse(camper_id)
    if str(camp_id) in data[0]:
        tkMessageBox.showinfo(
            title="message",
            message="Sorry, This camper is already registered in this camp")
        return
    teams_ids = Team.get_available_team(camp_id)
    #assign this camper to a team and a bunkhouse and get their ids(inc checked_in_num)
    Bunkhouse.increment_checked_in(bunkhouses_ids[0][0])
    Team.increment_checked_in(teams_ids[0][0])
    #insert a record in Camper_Camp_BunckHouse_Team(camper_id,camp_id,team_id,bunk_house_id,student_checked_in)
    Bunkhouse.insert_check_in(camper_id, camp_id, teams_ids[0][0],
                              bunkhouses_ids[0][0])
    #show a message box saying, the camper checked in successfully
    tkMessageBox.showinfo(title="message",
                          message="Camper Assigned successfully")
    cancel_bt_handler()
Ejemplo n.º 9
0
def assign_to_camp_bt_handler():
    try:
        camper_id = int(camper_id_tb.get())
        camp_id = int(camp_id_tb.get())
    except:
        tkMessageBox.showinfo(title="message",
                              message="camper and camp id must be nubmers")
        return
    from controller.camper import Camper
    from controller.camp import Camp
    from controller.bunkhouse import Bunkhouse
    from controller.team import Team
    checked_in_camper = Camper(camper_id)
    checked_in_camp = Camp(camp_id)
    if checked_in_camper.select_camper() == None:
        tkMessageBox.showinfo(title="message", message="camper not found")
        return
    tmp_camp_data = checked_in_camp.select_camp()
    if tmp_camp_data == None:
        tkMessageBox.showinfo(title="message", message="camp not found")
        return
    #check there is a room for this camper in bunkhouse gender?
    data_camper = checked_in_camper.select_camper()
    gender = data_camper[3]
    bunkhouses_ids = Bunkhouse.get_available_bunkgouses(gender, camp_id)
    if len(bunkhouses_ids) < 1:
        tkMessageBox.showinfo(
            title="message",
            message="Sorry, This camp is not available, Choose another one")
        return
    #check if this camper is already regestered in this camp
    data_camp = Bunkhouse.select_camp_team_bunkhouse(camper_id)
    if str(camp_id) in data_camp[0]:
        tkMessageBox.showinfo(
            title="message",
            message="Sorry, This camper is already registered in this camp")
        return
    teams_ids = Team.get_available_team(camp_id)
    #assign this camper to a team and a bunkhouse and get their ids(inc checked_in_num)
    Bunkhouse.increment_checked_in(bunkhouses_ids[0][0])
    Team.increment_checked_in(teams_ids[0][0])
    #insert a record in Camper_Camp_BunckHouse_Team(camper_id,camp_id,team_id,bunk_house_id,student_checked_in)
    Bunkhouse.insert_check_in(camper_id, camp_id, teams_ids[0][0],
                              bunkhouses_ids[0][0])
    #show a message box saying, the camper checked in successfully
    tkMessageBox.showinfo(title="message",
                          message="Camper Assigned successfully")
    mailing_date = str(datetime.now().date())
    first_name = data_camper[0]
    last_name = data_camper[1]
    address = data_camper[4]
    camp_start_date = tmp_camp_data[0]
    camp_end_date = tmp_camp_data[1]
    f1 = open("Mailing Label.txt", 'w')
    f1.write(mailing_date + "\n" + first_name + ' ' + last_name + "\n" +
             address)
    f1.close()
    import webbrowser
    webbrowser.open("Mailing Label.txt")

    f2 = open("acceptance letter.txt", 'w')
    f2.write("Congratulations " + first_name + ' ' + last_name +
             "! you have been accepted for the camp starting on " +
             camp_start_date + " and ending on " + camp_end_date + ".\nThanks")
    f2.close()
    webbrowser.open("acceptance letter.txt")
    cancel_bt_handler()