from tkinter import *
from SQLserver import *
from student_surface import *
from log_in import *
def
test ( ):
def
log ( ):
a = Tk (
)
msg = SQLserver (
server = "a"
, user = "b"
, password = "c" ,
database = "test05")
sql2 = ' select * * from syuser'
result = msg . ExecQuery ( sql
)
d = 0
for row in result :
if (
e1 . get (
) = = row[
0
] . rstrip (
)
):
cipher =
row[ 3 ] . rstrip (
)
c = row[
4
]
d = 1
break
elif (
row[ 1 ] . rstrip (
) = = e1 . get (
)
):
cipher = row[
3
] .
rstrip (
)
c = row [
4
]
d =
1
break
elif (
row[
2
] .
rstrip (
) = =
e1 . get (
)
):
cipher = row [
3
] . rstrip (
)
c = row[
4
]
d
=
1
break
if
d
= =
0:
Label (
a
,
text =
'E R R O R ! '
)
.
pack (
)
Button (
a
,
text = ' O K '
,
width =
10
,
command =
a . destroy
) . pack (
)
e2 . delete (
0 , len (
e2 . get (
)
)
)
elif
d = = 1:
if
cipher! = e2 . get ( ):
Label ( a , text = 'E R R O R!') . pack ( )
Button ( a , text = 'O K' , width = 10 , command = a . destroy) . pack ( )
e2 . delete ( 0 , len ( e2 . get ( )))
else:
Label ( a , text = 's u c c e s s!') . pack ( )
Button ( a , text = 'ok' , width = 10 , command = a . destroy) . pack ( )
if
c = = 1:
sql2 = 's e l e c t s n a m e f ro m s t u d e n t w h e r e s n o = %s'%e1 . get ( )
result2 = msg . ExecQuery ( sql2)
for
row2
in
result2:
sname = row2[0]
surface ( e1 . get ( ) , sname)
root . destroy ( )
a . mainloop ( )
root = Tk ( )
root . iconbitmap ( ' . //ganda . ico')
root . title ( 'system')
v1 = StringVar ( )
v2 = StringVar ( )
Label ( root , text = 'id:') . grid ( row = 0 , column = 0)
Label ( root , text = 'password:') . grid ( row = 1 , column = 0)
e1 = Entry ( root , textvariable = v1)
e2 = Entry ( root , textvariable = v2 , show = '*')
e1 . grid ( row = 0 , column = 1 , padx = 10 , pady = 5)
e2 . grid ( row = 1 , column = 1 , padx = 10 , pady = 5)
Button ( root , text = 'login' , width = 10 , command = log) . grid ( row = 3 , column = 0 , sticky = W , padx = 10 , pady = 5)
Button (
root , text = 'out' , width = 10 , command = root . destroy) . grid ( row = 3 , column = 1 , sticky = E , padx = 10 , pady = 5)
root . mainloop (
)
if
__name__ = =
"__m a i n __":
test ( )