Some code to start with
This commit is contained in:
commit
79a77ad4ca
2 changed files with 133 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.db
|
132
main.py
Normal file
132
main.py
Normal file
|
@ -0,0 +1,132 @@
|
|||
import sqlite3
|
||||
|
||||
#Create a connection to the database with the new or given inventory
|
||||
con = sqlite3.connect("inventory.db")
|
||||
cur = con.cursor()
|
||||
|
||||
#cur.execute("CREATE TABLE Glaskasten()")
|
||||
|
||||
#different modes of action
|
||||
options = ["Hilfe","Einlagern","Auslagern","Inventur","Search","Info","Quit"] # Umlagern noch hinzufügen
|
||||
description = ["Zeigt die Liste an möglichen Aktionen an","Um einen neuen Gegenstand einzulagern","Um einen Gegenstand auszulagern","Um mit der Inventur zu beginnen","Nach einem bestimmten Gegenstand suchen","Daten eines Gegenstands abrufen","Beendet das Tool"]
|
||||
|
||||
#Variables
|
||||
NamensID = 0
|
||||
Kategorie = "Kategorie"
|
||||
Regal = "Regal"
|
||||
Raum = "Raum"
|
||||
Ort = "Ort"
|
||||
Gegenstand = "Gegenstand" # Name
|
||||
Anzahl = 0
|
||||
Verliehen = "Nein"
|
||||
Reservierung_vorhanden = "Nein"
|
||||
ItemID = 0 #Barcode/ID Gegenstand
|
||||
Letzte_Interaktion = "NaN"
|
||||
|
||||
|
||||
#Functions
|
||||
def __init__():
|
||||
# NamensID - Interner Name z.B. NULL-Schrank
|
||||
# Kategorie - Regal / Schrank
|
||||
# Ort - Raumnummer z.B. D120
|
||||
cur.execute("CREATE TABLE IF NOT EXISTS Lagerraum (NamendsID TEXT, Kategorie TEXT, Ort TEXT)")
|
||||
cur.execute("CREATE TABLE IF NOT EXISTS Regal (NamensID TEXT, Kategorie TEXT, Gegenstand TEXT, Anzahl INTEGER, Verliehen TEXT, Reservierung_vorhanden TEXT)")
|
||||
cur.execute("CREATE TABLE IF NOT EXISTS Gegenstände (Name TEXT, ID INTEGER, Raum TEXT, Regal TEXT, Anzahl INTEGER, Verleihstatus TEXT, Letzte_Interaktion TEXT)")
|
||||
con.commit()
|
||||
|
||||
def print_help():
|
||||
count = 0
|
||||
for element in options:
|
||||
print(element[0] + " - " + element + " " + description[count])
|
||||
count =+ 1
|
||||
|
||||
def einlagern_neu():
|
||||
#Name,ID,Raum,Regal,Anzahl,Verleihstatus,Letzte_Interaktion
|
||||
print("Bitte geben Sie nachfolgen die geforderten Angaben für die Einlagerung ein.")
|
||||
print("Name/Bezeichnung:")
|
||||
Gegenstand = input()
|
||||
print("Scannen Sie den Barcode des Gegenstands:")
|
||||
ItemID = int(input())
|
||||
print(f"In welchem Raum soll {Gegenstand} gelagert werden?")
|
||||
Raum = input()
|
||||
print(f"In welchem Regal/Fach wird {Gegenstand} gelagert?")
|
||||
Regal = input()
|
||||
print("Anzahl an Gegenständen:")
|
||||
Anzahl = int(input())
|
||||
data = (Gegenstand, ItemID, Raum, Regal, Anzahl)
|
||||
cur.execute("INSERT INTO Gegenstände VALUES(?,?,?,?,?,'Auf Lager','sudo');",data)
|
||||
#con.commit()
|
||||
def einlagern(): # Rückkehr von ausgeliehenen Gegenständen
|
||||
print("Gegenstand scannen:")
|
||||
ItemID = int(input())
|
||||
cur.execute("UPDATE Gegenstände WHERE ID=?",ItemID)
|
||||
def auslagern(): # Dauerhaft entfernen
|
||||
print("Gegenstand scannen:")
|
||||
ItemID = int(input())
|
||||
cur.execute("DELETE FROM Gegenstände WHERE ID=?",ItemID)
|
||||
def inventur():
|
||||
print("To be done")
|
||||
def search():
|
||||
print("Gegenstand nach dem gesucht werden soll:")
|
||||
Gegenstand = input()
|
||||
res = cur.execute("SELECT * FROM Gegenstände WHERE Name=?",Gegenstand)
|
||||
res.fetchall()
|
||||
def ausleihen():
|
||||
print("Gegenstand scannen:")
|
||||
ItemID = int(input())
|
||||
cur.execute("UPDATE Gegenstände WHERE ID=? SET Verleihstatus='Verliehen'",ItemID)
|
||||
def info():
|
||||
print("Gegenstand scannen:")
|
||||
ItemID = int(input())
|
||||
res = cur.execute("SELECT * FROM Gegenstände WHERE ID=?",ItemID)
|
||||
res.fetchall()
|
||||
|
||||
|
||||
def option_display(a):
|
||||
for i in a:
|
||||
print(i[0] + " - " + i)
|
||||
|
||||
|
||||
def do_something(x):
|
||||
# Help
|
||||
if x == 0:
|
||||
print_help()
|
||||
# Einlagern_Neu
|
||||
if x == 1:
|
||||
einlagern_neu()
|
||||
# Auslagern
|
||||
if x == 2:
|
||||
auslagern()
|
||||
# Inventur
|
||||
if x == 3:
|
||||
info()#inventur()
|
||||
# Suche
|
||||
if x == 4:
|
||||
search()
|
||||
# Info
|
||||
if x == 5:
|
||||
info()
|
||||
# Quit is defined in the main loop
|
||||
|
||||
#Main loop
|
||||
__init__()
|
||||
print("Choose one of the following actions")
|
||||
option_display(options)
|
||||
run = 1
|
||||
while run:
|
||||
print("What do you want to do? (H for help)")
|
||||
get = input()
|
||||
if len(get) == 1:
|
||||
get = get.upper()
|
||||
count = 0
|
||||
if get == "Q":
|
||||
run = 0
|
||||
for element in options:
|
||||
print(element[0])
|
||||
if get == element[0]:
|
||||
do_something(count)
|
||||
con.commit()
|
||||
break
|
||||
count += 1
|
||||
|
||||
con.close()
|
Loading…
Add table
Reference in a new issue