|
|

楼主 |
发表于 2019-9-18 14:07:47
|
显示全部楼层
from tkinter import *
from SQLserver import *
from student_surface import *
def test():
def redestroy(sno,sname):
a=sno
b=sname
surface(a,b)
def log():
a=Tk()
a.iconbitmap('.//ganda.ico')
a.title('学生管理系统')
msg=SQLServer(server="localhost",user="MADAO",password="mayixiang",database="test05")
sql='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='账号错误!').pack()
Button(a,text='确认',width=10,command=a.destroy).pack()
e2.delete(0,len(e2.get()))
elif d==1:
if c==1:
if cipher==e2.get():
sql2='select sname from student where sno=%s'%e1.get()
result2=msg.ExecQuery(sql2)
for row2 in result2:
sname=row2[0]
redestroy(e1.get(),sname)
root.destroy()
else:
Label(a,text='密码错误!').pack()
Button(a,text='确认',width=10,command=a.destroy).pack()
e2.delete(0,len(e2.get()))
a.mainloop()
root=Tk()
root.iconbitmap('.//ganda.ico')
root.title('学生管理系统')
v1=StringVar()
v2=StringVar()
Label(root,text='账号:').grid(row=0,column=0)
Label(root,text='密码:').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='登入',width=10,command=log).grid(row=3,column=0,sticky=W,padx=10,pady=5)
Button(root,text='退出',width=10,command=root.destroy).grid(row=3,column=1,sticky=E,padx=10,pady=5)
root.mainloop()
if __name__=="__main__":
test()
|
|