Ejemplo n.º 1
0
def itemSearch():
    query = "SELECT * FROM item WHERE description ILIKE '%{0}%'".format(
        searchTerm.get())
    cur.execute(query)

    rows = cur.fetchall()
    for w in findItemFrameB.winfo_children():
        w.destroy()
    constructItemSearchHeaders()
    i = 1
    for r in rows:
        itemNum = tk.Label(findItemFrameB, text=r[0], bg=bgcolor, fg="black",
                           font="Times 12", borderwidth=1, relief="solid",
                           width=10)
        itemNum.grid(column=0, row=i)
        category = tk.Label(findItemFrameB, text=r[1], bg=bgcolor, fg="black",
                            font="Times 12", borderwidth=1, relief="solid",
                            width=20)
        category.grid(column=1, row=i)
        description = tk.Label(
            findItemFrameB, text=r[2], bg=bgcolor, fg="black", font="Times 12",
            borderwidth=1, relief="solid", width=50)
        description.grid(column=2, row=i)
        risk = tk.Label(findItemFrameB, text=r[3], bg=bgcolor, fg="black",
                        font="Times 12", borderwidth=1, relief="solid",
                        width=10)
        risk.grid(column=3, row=i)
        amount = tk.Label(findItemFrameB, text=r[4], bg=bgcolor, fg="black",
                          font="Times 12", borderwidth=1, relief="solid",
                          width=10)
        amount.grid(column=4, row=i)
        i += 1
Ejemplo n.º 2
0
    def search():
        cur.execute(
            f"SELECT * FROM item WHERE description LIKE '%{searchBar.get()}%'")

        rows = cur.fetchall()

        for r in rows:
            itemNum = tk.Label(b, text="Item#", bg="white", fg="black",
                               font="Times 12", borderwidth=1, relief="solid",
                               width=10)
            itemNum.grid(column=0, row=0)
            category = tk.Label(b, text="Category", bg="white", fg="black",
                                font="Times 12", borderwidth=1, relief="solid",
                                width=20)
            category.grid(column=1, row=0)
            description = tk.Label(b, text="Description", bg="white",
                                   fg="black", font="Times 12", borderwidth=1,
                                   relief="solid", width=50)
            description.grid(column=2, row=0)
            risk = tk.Label(b, text="Risk Level", bg="white", fg="black",
                            font="Times 12", borderwidth=1, relief="solid",
                            width=10)
            risk.grid(column=3, row=0)
            amount = tk.Label(b, text="Amount", bg="white", fg="black",
                              font="Times 12", borderwidth=1, relief="solid",
                              width=10)
            amount.grid(column=4, row=0)
Ejemplo n.º 3
0
def addItemAction():
    #checking for null

    if (itemDetails[1].get() == '') or (itemDetails[3].get()
                                        == '') or (itemDetails[4].get() == ''):
        message = ""
        if itemDetails[1].get() == '':
            message += "\nPlease provide a category."
            warning.configure(text=message)

        if itemDetails[3].get() == '':
            message += "\nPlease select a risk level."
            warning.configure(text=message)

        if itemDetails[4].get() == '':
            message += "\nPlease provide an amount."
            warning.configure(text=message)

    else:
        warning.configure(text="")
        cur.execute(
            f"INSERT INTO item VALUES ({itemDetails[0].cget('text')},'{itemDetails[1].get()}','{itemDetails[2].get()}','{itemDetails[3].get()}',{itemDetails[4].get()});"
        )
        for a in itemDetails:
            if a == itemDetails[0]:
                a.configure(text=int(a.cget("text")) + 1)
            else:
                a.configure(text="")

    findAnItem.configure(state=NORMAL)
Ejemplo n.º 4
0
def submit():
    print(recieptDetails[0].cget('text'))
    if (recieptDetails[0].cget('text') == " "):
        searchBar.configure(text="No Ticket Loaded")
        return

    cur.execute(
        f"UPDATE pawn_ticket pt SET payment_date='{date.today().isoformat()}' WHERE pt.ticket_no = {recieptDetails[0].cget('text')}"
    )
    con.commit()
Ejemplo n.º 5
0
def search():
    cur.execute(
        f"SELECT * FROM item WHERE description ILIKE '%{searchBar.get()}%'")

    rows = cur.fetchall()

    i = 1
    for r in rows:
        itemNum = tk.Label(findItemFrameB,
                           text=r[0],
                           bg=bgcolor,
                           fg="black",
                           font="Times 12",
                           borderwidth=1,
                           relief="solid",
                           width=10)
        itemNum.grid(column=0, row=i)
        category = tk.Label(findItemFrameB,
                            text=r[1],
                            bg=bgcolor,
                            fg="black",
                            font="Times 12",
                            borderwidth=1,
                            relief="solid",
                            width=20)
        category.grid(column=1, row=i)
        description = tk.Label(findItemFrameB,
                               text=r[2],
                               bg=bgcolor,
                               fg="black",
                               font="Times 12",
                               borderwidth=1,
                               relief="solid",
                               width=50)
        description.grid(column=2, row=i)
        risk = tk.Label(findItemFrameB,
                        text=r[3],
                        bg=bgcolor,
                        fg="black",
                        font="Times 12",
                        borderwidth=1,
                        relief="solid",
                        width=10)
        risk.grid(column=3, row=i)
        amount = tk.Label(findItemFrameB,
                          text=r[4],
                          bg=bgcolor,
                          fg="black",
                          font="Times 12",
                          borderwidth=1,
                          relief="solid",
                          width=10)
        amount.grid(column=4, row=i)
        i += 1
Ejemplo n.º 6
0
def addCustomerAction():
    #checking for null

    if (customerDetails[1].get()
            == '') or (customerDetails[2].get()
                       == '') or (customerDetails[4].get() == '') or (
                           customerDetails[5].get()
                           == '') or (customerDetails[8].get()
                                      == '') or (customerDetails[9].get()
                                                 == ''):
        message = ""
        if customerDetails[1].get() == '':
            message += "\nPlease provide your last name."
            warning.configure(text=message)

        if customerDetails[2].get() == '':
            message += "\nPlease provide your given name."
            warning.configure(text=message)

        if customerDetails[4].get() == '':
            message += "\nPlease select your address."
            warning.configure(text=message)

        if customerDetails[5].get() == '':
            message += "\nPlease provide a city."
            warning.configure(text=message)

        if customerDetails[8].get() == '':
            message += "\nPlease provide your postal code."
            warning.configure(text=message)

        if customerDetails[9].get() == '':
            message += "\nPlease provide your birth date."
            warning.configure(text=message)
    else:
        warning.configure(text="")
        cur.execute(
            f"INSERT INTO customer VALUES ({customerDetails[0].cget('text')},'{customerDetails[1].get()}','{customerDetails[2].get()}','{customerDetails[3].get()}','{customerDetails[4].get()}','{customerDetails[5].get()}','{customerDetails[6].get()}','{customerDetails[7].get()}',{customerDetails[8].get()},'{customerDetails[9].get()}');"
        )

        for a in itemDetails:
            if a == itemDetails[0]:
                a.configure(text=int(a.cget("text")) + 1)
            else:
                a.configure(text="")

    print("Integrate sql for adCustomerAction() here")
Ejemplo n.º 7
0
def list_expired():
    cur.execute(
        "SELECT i.item_no, i.category, i.description, p.due_date, i.amount, "
        "r.interest_rate FROM item i, pawn_ticket p, risk r, inventory_tag t "
        "WHERE i.item_no=t.item_no AND t.ticket_no=p.ticket_no AND "
        "i.risk_level=r.risk_level AND p.due_date <= CURRENT_DATE AND "
        "p.payment_date IS NULL;")

    rows = cur.fetchall()

    i = 1
    for r in rows:
        itemNum = tk.Label(expiredItemFrameB, text=r[0], bg=bgcolor,
                           fg="black", font="Times 12", borderwidth=1,
                           relief="solid", width=10)
        itemNum.grid(column=0, row=i)
        category = tk.Label(expiredItemFrameB, text=r[1], bg=bgcolor,
                            fg="black", font="Times 12", borderwidth=1,
                            relief="solid", width=20)
        category.grid(column=1, row=i)
        description = tk.Label(expiredItemFrameB, text=r[2], bg=bgcolor,
                               fg="black", font="Times 12", borderwidth=1,
                               relief="solid", width=40)
        description.grid(column=2, row=i)
        dueDate = tk.Label(expiredItemFrameB, text=r[3], bg=bgcolor,
                           fg="black", font="Times 12", borderwidth=1,
                           relief="solid", width=10)
        dueDate.grid(column=3, row=i)
        amount = tk.Label(expiredItemFrameB, text=r[4], bg=bgcolor, fg="black",
                          font="Times 12", borderwidth=1, relief="solid",
                          width=10)
        amount.grid(column=4, row=i)
        rate = tk.Label(expiredItemFrameB, text=r[5], bg=bgcolor, fg="black",
                        font="Times 12", borderwidth=1, relief="solid",
                        width=10)
        rate.grid(column=5, row=i)
        i += 1
#   We only want certain indices in a certain order from our input data
def indexList(indices, list):
    return [list[i] for i in indices]


chunksize = 10**5
for chunk in pd.read_csv(fileLoc, chunksize=chunksize, skiprows=[0, 1]):
    data = [
        indexList((1, 2, 3, 4, 7, 8, 10, 13, 14, 16), row)
        for row in (chunk.values.tolist())
    ]
    print("Chunk formatted")

    values = b','.join(
        cur.mogrify("(1, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", row)
        for row in data)

    command = b"""INSERT INTO taxi (city_id, pickup_time, dropoff_time, passenger_count, 
                              trip_distance, pickup_location, dropoff_location, fare, 
                              tip, tolls, total) VALUES """ + values

    print("Executing insert")
    cur.execute(command)
    print("Insert finished")

conn.commit()
print("Taxi data committed successfully")

cur.close()
conn.close()
Ejemplo n.º 9
0
def search():
    try:
        int(searchBar.get())
    except Exception:
        searchBar.configure(text="Enter A Ticket Number")
        return

    cur.execute(
        f"SELECT DISTINCT pt.ticket_no, pt.pawn_date, CONCAT(c.last_name, ', ', c.given_name, ' ', c.middle_initial, '.' ), pt.due_date, CONCAT(c.address, ', ', c.city), c.mobile, c.landline FROM pawn_ticket pt, inventory_tag it, customer c WHERE pt.ticket_no={searchBar.get()} AND pt.ticket_no=it.ticket_no;"
    )
    rows = cur.fetchone()

    if (str(rows) == "None"):
        searchBar.configure(text="Cannot Find Ticket")
        return

    a = 0
    for i in recieptDetails:
        i.configure(text=rows[a])
        a += 1

    cur.execute(
        f"SELECT DISTINCT i.category, i.description, i.amount, r.interest_rate, (i.amount * r.interest_rate) FROM pawn_ticket pt, inventory_tag it, item i, risk r WHERE pt.ticket_no={searchBar.get()} AND pt.ticket_no=it.ticket_no AND it.item_no=i.item_no AND i.risk_level=r.risk_level;"
    )
    rows = cur.fetchall()

    a = 1
    for i in rows:
        itemCategory = tk.Label(processPaymentPawnedItems,
                                text=i[0],
                                bg=bgcolor,
                                fg="black",
                                font="Times 12",
                                borderwidth=1,
                                relief="solid",
                                width=20)
        itemCategory.grid(column=0, row=a)
        itemDescription = tk.Label(processPaymentPawnedItems,
                                   text=i[1],
                                   bg=bgcolor,
                                   fg="black",
                                   font="Times 12",
                                   borderwidth=1,
                                   relief="solid",
                                   width=35)
        itemDescription.grid(column=1, row=a)
        itemAmount = tk.Label(processPaymentPawnedItems,
                              text=i[2],
                              bg=bgcolor,
                              fg="black",
                              font="Times 12",
                              borderwidth=1,
                              relief="solid",
                              width=15)
        itemAmount.grid(column=2, row=a)
        itemInterestRate = tk.Label(processPaymentPawnedItems,
                                    text=i[3],
                                    bg=bgcolor,
                                    fg="black",
                                    font="Times 12",
                                    borderwidth=1,
                                    relief="solid",
                                    width=15)
        itemInterestRate.grid(column=3, row=a)
        itemInterest = tk.Label(processPaymentPawnedItems,
                                text=round(i[4], 2),
                                bg=bgcolor,
                                fg="black",
                                font="Times 12",
                                borderwidth=1,
                                relief="solid",
                                width=15)
        itemInterest.grid(column=4, row=a)
        a += 1

    cur.execute(
        f"SELECT COUNT(DISTINCT i.item_no), SUM(DISTINCT (i.amount * (r.interest_rate + 1))), SUM(DISTINCT (i.amount * (r.interest_rate + 1))*0.15), SUM(DISTINCT (i.amount * (r.interest_rate + 1))*1.15) FROM pawn_ticket pt, inventory_tag it, item i, risk r WHERE pt.ticket_no={searchBar.get()} AND pt.ticket_no=it.ticket_no AND it.item_no=i.item_no AND i.risk_level=r.risk_level;"
    )
    rows = cur.fetchone()

    noItems.configure(text=rows[0])

    a = 1
    for i in recieptPaymentDueDetails:
        i.configure(text=round(rows[a], 2))
        a += 1
Ejemplo n.º 10
0
def search():
    #erase previous searches
    i = 0
    for a in regCustomerFrameB.winfo_children():
        if i < len(customerAttributes):
            i += 1
        else:
            a.destroy()

    #create results for current search
    cur.execute(
        f"SELECT * FROM customer WHERE last_name ILIKE '%{searchBar.get()}%'")

    rows = cur.fetchall()

    i = 1
    for r in rows:

        customerID = tk.Button(regCustomerFrameB,
                               text=r[0],
                               bg="white",
                               fg="black",
                               font="Times 12",
                               wraplength=225,
                               command=customerInfo)
        customerID.grid(column=0, row=i)
        lastName = tk.Label(regCustomerFrameB,
                            text=r[1],
                            bg="white",
                            fg="black",
                            font="Times 12",
                            wraplength=225)
        lastName.grid(column=1, row=i)
        givenName = tk.Label(regCustomerFrameB,
                             text=r[2],
                             bg="white",
                             fg="black",
                             font="Times 12",
                             wraplength=225)
        givenName.grid(column=2, row=i)
        middleInitial = tk.Label(regCustomerFrameB,
                                 text=r[3],
                                 bg="white",
                                 fg="black",
                                 font="Times 12",
                                 wraplength=225)
        middleInitial.grid(column=3, row=i)
        address = tk.Label(regCustomerFrameB,
                           text=r[4],
                           bg="white",
                           fg="black",
                           font="Times 12",
                           wraplength=225)
        address.grid(column=4, row=i)
        city = tk.Label(regCustomerFrameB,
                        text=r[5],
                        bg="white",
                        fg="black",
                        font="Times 12",
                        wraplength=225)
        city.grid(column=5, row=i)
        mobile = tk.Label(regCustomerFrameB,
                          text=r[6],
                          bg="white",
                          fg="black",
                          font="Times 12",
                          wraplength=225)
        mobile.grid(column=6, row=i)
        landline = tk.Label(regCustomerFrameB,
                            text=r[7],
                            bg="white",
                            fg="black",
                            font="Times 12",
                            wraplength=225)
        landline.grid(column=7, row=i)
        postalCode = tk.Label(regCustomerFrameB,
                              text=r[8],
                              bg="white",
                              fg="black",
                              font="Times 12",
                              wraplength=225)
        postalCode.grid(column=8, row=i)
        birthDate = tk.Label(regCustomerFrameB,
                             text=r[9],
                             bg="white",
                             fg="black",
                             font="Times 12",
                             wraplength=225)
        birthDate.grid(column=9, row=i)
        i += 1
Ejemplo n.º 11
0
                  width=11)
title = tk.Label(addItemFrameA,
                 text="Add to Item Registry",
                 bg=bgcolor,
                 fg="black",
                 font="Times 32")
blank1.grid(column=0, row=0)
title.grid(column=1, row=0)

#labels & entry fields
itemAttributes = ["Item#", "Category", "Description", "Risk Level", "Amount"]
labelWidth = 20
itemDetails = []
itemNum = 0

if str(cur.execute("SELECT COUNT(*) FROM item;")) != "None":
    itemNum = int(cur.execute("SELECT COUNT(*) FROM item;"))

i = 0
for a in itemAttributes:
    label = tk.Label(addItemFrameB,
                     text=a,
                     bg=bgcolor,
                     fg="black",
                     font="Times 18",
                     borderwidth=1,
                     relief="solid",
                     width=labelWidth)
    label.grid(column=0, row=i)
    if a == "Item#":
        label2 = tk.Label(addItemFrameB,
Ejemplo n.º 12
0
One for every hour of the day, for the seven days of the week (168 time steps)
"""

import sys
sys.path.insert(0, '../db/')

from connect import conn, cur
import numpy as np

#   Time units and cost ratio of distance (for the cost of the ride)
granularity = 10            # 10 minute intervals
N = int(1440 / granularity) # number of intervals
dist_cost = .2              # for estimating cost matrix

#   Number of zones
cur.execute("SELECT count(*) FROM zones WHERE city=%s", [1])
zones = cur.fetchone()[0]

#   Initialize matrices
count = np.zeros((N, zones, zones), dtype=int)
T = np.zeros((N, zones, zones))
R = np.zeros((N, zones, zones))
cost = np.zeros((N, zones, zones))

#   Get trips from db
i=0
cur.execute("""SELECT pickup_time, dropoff_time, pickup_location, dropoff_location, 
               total, trip_distance FROM taxi""")
for record in cur:
    #   Get hour and make index (hour, start location, end location)
    t = (6 * record[0].hour - 1) + int(record[0].minute/10)
Ejemplo n.º 13
0
            Initialize the tables in the database

Currently NYC is hardcoded into the initialization, as this is the only city for 
the scope of this project, but this can quickly be made dynamic (probably make a
zones folder with the zone files named New_York_City-1.csv, loop the dir, parse
the names into cities, put zones in)
"""

#   Connect to db
from connect import conn, cur
import csv

#   Create cities table (just doing NYC for project, but this can be easily extended to others)
cur.execute("""
    DROP TABLE IF EXISTS cities CASCADE;
    CREATE TABLE cities (id serial primary key,
                         city varchar(50) not null);
    INSERT INTO cities VALUES (1, 'New York');
    """)    # Caps doesn't matter for processing, I like this style for readability
print("Cities table created")

#   Create zone table from scratch (may want to make primary key into (borough, zone))
cur.execute("""
    DROP TABLE IF EXISTS zones CASCADE;
    CREATE TABLE zones (id serial primary key,
                        city integer REFERENCES cities(id),
                        borough varchar(50),
                        zone varchar(50),
                        service_zone varchar(50));
    """)
print("Zones table created")
Ejemplo n.º 14
0
def populate_frame(id):
    customerInfoFrameA = Frame(customerInfoFrame)
    customerInfoFrameA.configure(bg="black")
    customerInfoFrameB = Frame(customerInfoFrame)
    customerInfoFrameB.configure(bg=bgcolor)
    customerInfoFrameC = Frame(customerInfoFrame)
    customerInfoFrameC.configure(bg=bgcolor)

    title = tk.Label(customerInfoFrameA, text="Customer Information",
                     bg="black", fg="white", font="Times 32")
    title.grid(column=0, row=0)

    def goBack():
        for a in customerInfoFrame.winfo_children():
            a.destroy()
        customerInfoFrame.grid_remove()
        win.geometry("1200x720")
        regCustomerFrame.grid()

    back = tk.Button(customerInfoFrameA, text="Go Back",
                     font="Times 18", bg=bgcolor, fg="black", command=goBack)
    back.grid(column=1, row=0)

    cur.execute(
        f"SELECT *, CAST((CAST(TO_CHAR(CURRENT_DATE, 'YYYYMMDD') AS INT) - "
        f"CAST(TO_CHAR(birth_date, 'YYYYMMDD') AS INT)) AS INT)/10000 \"Age\" "
        f"FROM customer WHERE customer_id={id}")

    info = cur.fetchone()

    label = tk.Label(customerInfoFrameB, text="Customer ID:", bg="white",
                     fg="black", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="e")
    label.grid(column=0, row=0)
    label = tk.Label(customerInfoFrameB, text=info[0], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="w")
    label.grid(column=1, row=0)

    label = tk.Label(customerInfoFrameB, text="Last Name:", bg="white",
                     fg="black", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="e")
    label.grid(column=0, row=1)
    label = tk.Label(customerInfoFrameB, text=info[1], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="w")
    label.grid(column=1, row=1)
    label = tk.Label(customerInfoFrameB, text="Given Name:", bg="white",
                     fg="black", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="e")
    label.grid(column=2, row=1)
    label = tk.Label(customerInfoFrameB, text=info[2], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="w")
    label.grid(column=3, row=1)
    label = tk.Label(customerInfoFrameB, text="Middle Initial:", bg="white",
                     fg="black", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="e")
    label.grid(column=4, row=1)
    label = tk.Label(customerInfoFrameB, text=info[3], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="w")
    label.grid(column=5, row=1)

    label = tk.Label(customerInfoFrameB, text="Address:", bg="white",
                     fg="black", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="e")
    label.grid(column=0, row=2)
    label = tk.Label(customerInfoFrameB, text=info[4], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=45, anchor="w")
    label.grid(column=1, row=2, columnspan=3)
    label = tk.Label(customerInfoFrameB, text="City:", bg="white", fg="black",
                     font="Times 12", borderwidth=0, relief="solid", width=15,
                     anchor="e")
    label.grid(column=4, row=2)
    label = tk.Label(customerInfoFrameB, text=info[5], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="w")
    label.grid(column=5, row=2)

    label = tk.Label(customerInfoFrameB, text="Mobile:", bg="white",
                     fg="black", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="e")
    label.grid(column=0, row=3)
    label = tk.Label(customerInfoFrameB, text=info[6], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="w")
    label.grid(column=1, row=3)
    label = tk.Label(customerInfoFrameB, text="Landline:", bg="white",
                     fg="black", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="e")
    label.grid(column=2, row=3)
    label = tk.Label(customerInfoFrameB, text=info[7], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="w")
    label.grid(column=3, row=3)
    label = tk.Label(customerInfoFrameB, text="Postal Code:", bg="white",
                     fg="black", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="e")
    label.grid(column=4, row=3)
    label = tk.Label(customerInfoFrameB, text=info[8], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="w")
    label.grid(column=5, row=3)

    label = tk.Label(customerInfoFrameB, text="Birth Date:", bg="white",
                     fg="black", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="e")
    label.grid(column=0, row=4)
    label = tk.Label(customerInfoFrameB, text=info[9], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="w")
    label.grid(column=1, row=4)
    label = tk.Label(customerInfoFrameB, text="Age:", bg="white", fg="black",
                     font="Times 12", borderwidth=0, relief="solid", width=15,
                     anchor="e")
    label.grid(column=2, row=4)
    label = tk.Label(customerInfoFrameB, text=info[10], bg="white",
                     fg="blue", font="Times 12", borderwidth=0,
                     relief="solid", width=15, anchor="w")
    label.grid(column=3, row=4)

    button = tk.Button(customerInfoFrameC, text="Add Pawn",
                       font="Times 18", bg=bgcolor, fg="red", command=temp1)
    button.grid(column=0, row=0)
    button = tk.Button(customerInfoFrameC, text="View Active Pawns",
                       font="Times 18", bg=bgcolor, fg="red", command=temp2)
    button.grid(column=1, row=0)
    button = tk.Button(customerInfoFrameC, text="View History",
                       font="Times 18", bg=bgcolor, fg="red", command=temp3)
    button.grid(column=2, row=0)

    customerInfoFrameA.grid()
    customerInfoFrameB.grid()
    customerInfoFrameC.grid()
Ejemplo n.º 15
0
def customerSearch():
    # erase previous searches
    i = 0
    for a in regCustomerFrameB.winfo_children():
        if i < len(customerAttributes):
            i += 1
        else:
            a.destroy()

    # create results for current search
    cur.execute(
        f"SELECT *, CAST((CAST(TO_CHAR(CURRENT_DATE, 'YYYYMMDD') AS INT) - "
        f"CAST(TO_CHAR(birth_date, 'YYYYMMDD') AS INT)) AS INT)/10000 \"Age\" "
        f"FROM customer WHERE last_name ILIKE '%{searchBar.get()}%' OR "
        f"given_name ILIKE '%{searchBar.get()}%'")

    rows = cur.fetchall()

    i = 1
    for r in rows:

        customerID = tk.Button(
            regCustomerFrameB, text=r[0], bg="white", fg="black",
            font="Times 12", wraplength=225,
            command=lambda: customerInfo(r[0]))
        customerID.grid(column=0, row=i)
        lastName = tk.Label(
            regCustomerFrameB, text=r[1], bg="white", fg="black",
            font="Times 12", wraplength=225)
        lastName.grid(column=1, row=i)
        givenName = tk.Label(
            regCustomerFrameB, text=r[2], bg="white", fg="black",
            font="Times 12", wraplength=225)
        givenName.grid(column=2, row=i)
        middleInitial = tk.Label(
            regCustomerFrameB, text=r[3], bg="white", fg="black",
            font="Times 12", wraplength=225)
        middleInitial.grid(column=3, row=i)
        address = tk.Label(
            regCustomerFrameB, text=r[4], bg="white", fg="black",
            font="Times 12", wraplength=225)
        address.grid(column=4, row=i)
        city = tk.Label(
            regCustomerFrameB, text=r[5], bg="white", fg="black",
            font="Times 12", wraplength=225)
        city.grid(column=5, row=i)
        mobile = tk.Label(
            regCustomerFrameB, text=r[6], bg="white", fg="black",
            font="Times 12", wraplength=225)
        mobile.grid(column=6, row=i)
        landline = tk.Label(
            regCustomerFrameB, text=r[7], bg="white", fg="black",
            font="Times 12", wraplength=225)
        landline.grid(column=7, row=i)
        postalCode = tk.Label(
            regCustomerFrameB, text=r[8], bg="white", fg="black",
            font="Times 12", wraplength=225)
        postalCode.grid(column=8, row=i)
        birthDate = tk.Label(
            regCustomerFrameB, text=r[9], bg="white", fg="black",
            font="Times 12", wraplength=225)
        birthDate.grid(column=9, row=i)
        age = tk.Label(
            regCustomerFrameB, text=r[10], bg="white", fg="black",
            font="Times 12", wraplength=255)
        age.grid(column=10, row=i)
        i += 1