Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
robogroup
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
matteo perini
robogroup
Commits
7b6127f7
Commit
7b6127f7
authored
Jan 10, 2025
by
matteo perini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aggiunto il punto 8
parent
ef5501cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
applicazione.py
applicazione.py
+7
-2
my_lib.py
my_lib.py
+31
-0
No files found.
applicazione.py
View file @
7b6127f7
import
time
import
os
from
termcolor
import
colored
from
my_lib
import
registra_cliente
,
registra_prodotto
,
cerca_cliente_per_prodotto
,
scarica_prodotto
,
lista_clienti
,
scarica_cliente
,
lista_prodotti
from
my_lib
import
registra_cliente
,
registra_prodotto
,
cerca_cliente_per_prodotto
,
scarica_prodotto
,
lista_clienti
,
scarica_cliente
,
lista_prodotti
,
cerca_cliente_per_tessera
def
mostra_menu
():
os
.
system
(
'cls'
if
os
.
name
==
'nt'
else
'clear'
)
# questa riga serve per cancellare il terminale
...
...
@@ -15,11 +15,12 @@ def mostra_menu():
print
(
colored
(
" [5] Ricerca proprietario di un prodotto"
,
"cyan"
,
attrs
=
[
"bold"
]))
print
(
colored
(
" [6] Rimuovi cliente dal db"
,
"cyan"
,
attrs
=
[
"bold"
]))
print
(
colored
(
" [7] Ricerca i prodotti di un cliente"
,
"cyan"
,
attrs
=
[
"bold"
]))
print
(
colored
(
" [8] Ricerca il proprietario di un tag"
,
"cyan"
,
attrs
=
[
"bold"
]))
print
(
colored
(
"
\n
[0] Esci"
,
"magenta"
,
attrs
=
[
"bold"
]))
n
=
input
(
""
)
#leggiamo il tasto inserito dall'utente
if
n
.
isnumeric
()
:
#se è stato inserito un numero entriamo nella funzione che lo controlla
if
int
(
n
)
in
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
0
]:
#il numero è tra le possibilità ipotizzate?
if
int
(
n
)
in
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
0
]:
#il numero è tra le possibilità ipotizzate?
if
int
(
n
)
==
0
:
#se è stato schiacciato lo 0 scrivo arrivederci e esco
print
(
"Arrivederci!"
)
return
0
#serve per uscire dalla funzione
...
...
@@ -50,6 +51,10 @@ def mostra_menu():
elif
int
(
n
)
==
7
:
lista_prodotti
()
time
.
sleep
(
3
)
mostra_menu
()
elif
int
(
n
)
==
8
:
cerca_cliente_per_tessera
()
time
.
sleep
(
3
)
mostra_menu
()
else
:
print
(
"ok"
)
...
...
my_lib.py
View file @
7b6127f7
...
...
@@ -35,6 +35,37 @@ def cerca_cliente_per_prodotto():
else
:
print
(
"Prodotto non associato a nessun cliente"
)
def
cerca_cliente_per_tessera
():
reader
=
SimpleMFRC522
()
con
=
sqlite3
.
connect
(
"mydb.db"
)
cur
=
con
.
cursor
()
def
leggi_cliente
():
try
:
print
(
"Ciao, avvicina il tag del cliente al ricevitore!"
)
id
,
text
=
reader
.
read
()
print
(
id
)
#print(text)
except
:
pass
finally
:
GPIO
.
cleanup
()
return
int
(
id
)
n
=
leggi_cliente
()
database
=
cur
.
execute
(
'SELECT * FROM persone WHERE n_card=?;'
,(
n
,))
yy
=
database
.
fetchall
()
if
len
(
yy
)
>
0
:
for
row
in
yy
:
xx
=
row
[
0
]
print
(
row
)
print
(
"La tessera numero "
,
row
[
3
],
" è intestata a : "
,
row
[
1
],
" "
,
row
[
2
]
)
#cliente = cur.execute('SELECT * FROM persone WHERE n_card=?;',(xx,))
#for i in cliente:
#print(cliente.fetchone())
else
:
print
(
"Tag non associato a nessun cliente"
)
def
registra_prodotto
():
reader
=
SimpleMFRC522
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment