Example #1
0
def del_staff(id, btn_window):
    cursor.execute(f"select warden_id from blocks")
    warden_list = []
    warden_res = cursor.fetchall()
    for i in range(len(warden_res)):
        warden_list.append(warden_res[i][0])
    if id in warden_list:
        cursor.execute(f"select block_id from blocks where warden_id='{id}'")
        res = cursor.fetchall()
        if len(res) == 1:
            tkinter.messagebox.showerror(
                "RSGH - RMD",
                f"Staff {id} has been assigned as warden of block {res[0][0]}.\nPlease change the warden of the mentioned block before attempting deletion!",
                parent=btn_window)  #Assigned as warden
        else:
            block_list = []
            for i in range(len(res)):
                block_list.append(res[i][0])
            tkinter.messagebox.showerror(
                "RSGH - RMD",
                f"Staff {id} has been assigned as warden of blocks {block_list}.\nPlease change the warden of the mentioned blocks before attempting deletion!",
                parent=btn_window)
    else:
        cursor.execute(f"delete from staff where staff_id='{id}'")
        db.commit()
        filename, heading, data = get_staff_for_show()
        gen_details_pdf(filename, heading, data)
        filename, heading, data = get_staff_for_show()
        gen_details_pdf(filename, heading, data)

        tkinter.messagebox.showinfo(
            f"RSGH - RMD",
            f"Staff {id} has been successfully removed!",
            parent=btn_window)
def get_room_by_cat(cat):
    cursor.execute(
        f"select block_id from blocks where gender='{cat}' and status='vacant'"
    )
    b_ids = cursor.fetchall()
    room_list = []
    for bid in b_ids:
        cursor.execute(
            f"select room_id from room where block_id='{bid[0]}' and status='vacant'"
        )
        rooms = cursor.fetchall()
        for room in rooms:
            room_list.append(room[0])
    return room_list
def get_block_for_show():
    heading_list = [
        'Block ID', 'Type', 'Gender', 'Total Rooms', 'Number of beds',
        'Vacant Beds'
    ]
    cursor.execute(
        f"select block_id, block_type, gender, no_of_rooms, no_of_beds, vacant_beds from blocks"
    )
    return ('block_details', heading_list, cursor.fetchall())
Example #4
0
def extend_block(bid, type, size, num_of_rooms):
    cursor.execute(f"select room_id from room where block_id='{bid}'")
    n = int(cursor.fetchall()[-1][0][2:])

    cursor.execute(f"select block_type from blocks where block_id='{bid}'")
    type = cursor.fetchone()[0]

    if type == "NAC":
        cost_single = 3000
        cost_double = 2500
        cost_tripple = 2000
    elif type == "AC":
        cost_single = 4000
        cost_double = 3500
        cost_tripple = 3000

    if size.lower() == 'single':
        beds = 1
        cost = cost_single
    elif size.lower() == 'double':
        beds = 2
        cost = cost_double
    elif size.lower() == 'triple':
        beds = 3
        cost = cost_tripple

    #Adding rooms
    for num in range(n + 1, n + num_of_rooms + 1):
        cursor.execute(
            f"insert into room values ('{bid}{str(num).zfill(3)}', '{bid}', '{type}', {float(cost)}, {beds}, 0, 'vacant')"
        )

    cursor.execute(
        f"update blocks set no_of_rooms=no_of_rooms+{num_of_rooms}, no_of_beds = no_of_beds+{num_of_rooms*beds}, vacant_beds=vacant_beds+{num_of_rooms*beds}, status='vacant' where block_id='{bid}'"
    )

    db.commit()

    filename, heading, data = get_block_for_show()
    gen_details_pdf(filename, heading, data)
    filename, heading, data = get_room_for_show()
    gen_details_pdf(filename, heading, data)
def get_all_wardens():
    cursor.execute(f"select staff_id from staff where is_warden='Yes'")
    return [res[0] for res in cursor.fetchall()]
def get_updated_w_id(wid):
    cursor.execute(
        f"select staff_id from staff where is_warden='Yes' and staff_id!='{wid}'"
    )
    return [res[0] for res in cursor.fetchall()]
def show_all_blocks():
    cursor.execute("select block_id from blocks")
    return [res[0] for res in cursor.fetchall()]
def get_courses_for_show():
    heading_list = ['Course ID', 'Course Name', 'Semesters']
    cursor.execute(f"select course_id, course_name, num_sems from courses")
    return ('courses_details', heading_list, cursor.fetchall())
def get_mess_for_show():
    heading_list = ['Mess ID']
    cursor.execute(f"select mess_id from mess")
    return ('mess_details', heading_list, cursor.fetchall())
def show_all_staff():
    cursor.execute(f"select staff_id from staff")
    return [res[0] for res in cursor.fetchall()]
def show_courses():
    cursor.execute("select course_id from courses")
    return [res[0] for res in cursor.fetchall()]
def list_stu_paid():
    cursor.execute("select distinct stu_id from transactions")
    return [res[0] for res in cursor.fetchall()]
def get_stu_for_show():
    heading_list = ['Student ID', 'Name', 'Contact', 'Course ID', 'Room ID']
    cursor.execute(
        f"select s.stu_id, sd.name, sd.contact_no, s.course_id, s.room_id from student s, stu_details sd where s.stu_id=sd.stu_id"
    )
    return ('stu_details', heading_list, cursor.fetchall())
def show_all_rooms():
    cursor.execute("select room_id from room")
    return [res[0] for res in cursor.fetchall()]
def show_rooms(type):
    cursor.execute("select room_id from room where type='{type}'")
    return [res[0] for res in cursor.fetchall()]
def get_tranid(sid):
    cursor.execute(
        f"select transaction_id, month_paid from transactions where stu_id='{sid}'"
    )
    return cursor.fetchall()
def show_all_mess():
    cursor.execute("select mess_id from mess")
    return [res[0] for res in cursor.fetchall()]
def show_all_stu():
    cursor.execute("select stu_id from student")
    return [res[0] for res in cursor.fetchall()]
def get_room_for_show():
    heading_list = ['Room ID', 'Block ID', 'Type', 'Total Rooms', 'Occupants']
    cursor.execute(
        f"select room_id, block_id, room_type, no_of_beds, occupants from room"
    )
    return ('room_details', heading_list, cursor.fetchall())
def show_vacant_rooms():
    cursor.execute("select room_id from room where status='vacant'")
    return [res[0] for res in cursor.fetchall()]
def get_staff_for_show():
    heading_list = ['Staff ID', 'Name', 'Gender', 'Date of Birth', 'Contact']
    cursor.execute(
        f"select staff_id, name, gender, dob, contact_no from staff")
    return ('staff_details', heading_list, cursor.fetchall())
def show_rooms_from_block(b_id):
    cursor.execute(
        f"select room_id from room where block_id='{b_id}' and status='vacant'"
    )
    return [res[0] for res in cursor.fetchall()]
def show_vacant_blocks():
    cursor.execute("select block_id from blocks where status='vacant'")
    return [res[0] for res in cursor.fetchall()]