forked from jaanos/banka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
banka.py
71 lines (63 loc) · 2.07 KB
/
banka.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Testni projekt o banki.
import sqlite3
import curses
baza = "banka1.db"
class BancniTerminal:
def __init__(self):
self.oseba = None
self.racun = None
self.cur = None
self.menu = "glavni"
self.zazeni()
def zazeni(self):
with sqlite3.connect(baza) as con:
self.cur = con.cursor()
while True:
if self.menu == "glavni":
self.glavniMenu()
elif self.menu == "oseba":
self.izberiOsebo()
elif self.menu == "dodajOsebo":
self.dodajOsebo()
elif self.menu == "izpisRacunov":
self.izpisRacunov()
def glavniMenu(self):
print("-"*10)
print("O - Pregled Osebe")
print("X - Izhod")
izbira = input("> ")
if izbira.lower() == "o":
self.menu = "oseba"
elif izbira.lower() == "x":
exit()
def izberiOsebo(self):
podatki = input("Priimek osebe: ");
self.cur.execute("SELECT EMSO, IME, PRIIMEK FROM Oseba WHERE PRIIMEK LIKE ?", ("%" + podatki + "%",))
stevec = 1
print("Izberi številko pred osebo ali drugo akcijo.")
osebe = self.cur.fetchall()
for emso, ime, priimek in osebe:
print(stevec, priimek, ime, emso)
stevec += 1
print("D - Dodaj osebo")
print("N - Nazaj")
izbira = input("> ")
if izbira.lower() == "d":
self.menu = "dodajOsebo"
return
elif izbira.lower() == "n":
self.menu = "glavni"
return
elif izbira.isdigit():
n = int(izbira) - 1
if n >= 0 and n < len(osebe):
self.oseba = osebe[n]
self.menu = "izpisRacunov"
return
def dodajOsebo(self):
print("Zdaj bi rad dodal osebo.")
self.menu = "glavni"
def izpisRacunov(self):
print("Izpis racunov za ", self.oseba)
self.menu = "glavni"
BancniTerminal()