# -*- coding: utf-8 -*-
"""
Created on Thu Jul 1 22:24:51 2021
@author: cxyqm
"""
import tkinter as tk
import tkinter.font as tf
import tkinter.ttk as ttk
import tkinter.messagebox as tm
from tkinter import filedialog
import time
from dao import SysDao
from information import InformationPane
from randString import randidcode
class Panels(object):
def __init__(self,master,usrid,wd,ht,x,y):
self.paneroot=master
self.usr=usrid
self.width=wd
self.height=ht
self.X=x
self.Y=y
self.image1=tk.PhotoImage(file=r'images/welcome.png')
self.titlesFont=tf.Font(family="华文新魏",size=20,weight=tf.BOLD)
self.textcolor="#00ffff"
self.Pane = tk.PanedWindow(self.paneroot,width=self.width, height=self.height)
self.Pane.place(x = self.X,y = self.Y)
self.top=None
self.button1()
pass
def button1(self):
self.Pane.destroy()
self.Pane = tk.PanedWindow(self.paneroot,width=self.width, height=self.height)
self.Pane.place(x = self.X,y = self.Y)
self.drawCanvas('欢迎进入幻梦签到系统!')
self.lbFrame = tk.LabelFrame(self.Pane,text = "信 息",width = self.width-20,height = 70)
self.lbFrame.place(x = 10 , y = 60)
return self.Pane
def button2(self):
def getIdentyStatu():
db=SysDao()
identyStatu=db.executeQuery('select statu from userinfo where usrid=?',(self.usr,))
return identyStatu[0][0]
def querySigninfo():
db=SysDao()
sql='select ss.signcode,ss.signid,si.stuno,tf.coursename from authentication au join studentinfo si \
on si.stuno=au.no join tccinfo tf on tf.classname=si.classname join startsign ss \
on tf.tccid=ss.tccid where ss.signstatus=1 and au.usrid=?'
rss=db.executeQuery(sql,(self.usr,))
return rss
def signBt():
params=self.top.getEntryValues()
teEt=params[0]
if len(teEt)<=0:
tm.showinfo('签到',"请输入签到码")
return
if teEt.lower() in self.signrss[0].lower():
try:
sql2='select signstatus from signrecord where signid=? and stuno=?'
param2=[self.signrss[1],self.signrss[2]]
db=SysDao()
suc=db.executeQuery(sql2,param2)
if len(suc)==0:
tm.showinfo('签到',"签到成功,签到课程为:"+self.signrss[3])
sql='insert into signrecord values(?,?,?,?,?)'
param=[None,self.signrss[1],self.signrss[2],1]
param.append(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
success=db.executeUpdate(sql,param)
if success!=1:
tm.showinfo('保存记录','签到数据保存失败')
else:
tm.showinfo('重复签到','您已签到成功,请勿重复签到')
except:
tm.showinfo('系统异常','签到数据保存异常')
else:
tm.showinfo("签到","签到码不正确")
def bt1(event=None):
rss=querySigninfo()
if len(rss)<=0:
tm.showinfo("签到","暂无可签到课程")
return
self.signrss=rss[0]
self.colnamedec=['输入签到码:']
self.top=InformationPane("课程签到",len(self.colnamedec)+1,self.paneroot)
self.top.createPane('签 到',self.colnamedec,'add')
self.top.addButtonCommand(signBt)
if getIdentyStatu()==0:
tm.showinfo('权限不足','请前往个人中心进行信息认证')
return
self.Pane.destroy()
self.Pane = tk.PanedWindow(self.paneroot,width=self.width, height=self.height)
self.Pane.place(x = self.X,y = self.Y)
self.drawCanvas('课堂签到')
self.lbFrametitle=tk.StringVar()
self.lbFrame = tk.LabelFrame(self.Pane,text ='课堂签到',width =self.width-20,height = self.height-50)
self.lbFrame.place(x = 10 , y = 40)
self.signinformation=tk.StringVar()
rss=querySigninfo()
if len(rss)<=0:
self.signinformation.set('当前暂无课程开启签到!')
else:
self.signinformation.set('你有一个课程正在进行签到\n课程名为:'+rss[0][3]+' \n点击进行签到吧!\n如已签到可忽略')
self.bt=tk.Button(self.lbFrame,textvariable=self.signinformation,command=bt1,bg='#00ff80',bd=0)
self.bt.place(width = 200,height = 100,x = 5,y = 10)
return self.Pane
def button3(self):
def getCousename():
db=SysDao()
couseList=db.executeQuery('select distinct tt.coursename from authentication au \
join studentinfo st on au.no=st.stuno join tccinfo tt \
on st.classname=tt.classname where au.usrid=?',(self.usr,))
if len(couseList)<=0:
couseList=[]
return couseList
def bt1():
db=SysDao()
sql="select tt.term,tt.coursename,tc.techname,sr.signstatus,sr.signtime from authentication au \
join signrecord sr on au.no=sr.stuno join startsign st on st.signid=sr.signid \
join tccinfo tt on tt.tccid=st.tccid join teacherinfo tc on tc.techno=tt.techno where au.usrid=?"
rsList=db.executeQuery(sql,(self.usr,))
if len(rsList)<=0:
rsList=[]
self.numberChosen.current(0)
self.numberChosen2.current(0)
self.refreshTree(rsList)
def bt2(event=None):
if len(self.Tree.selection())!=1:
tm.showinfo('查看信息','请选择一行')
return
self.top=InformationPane("查看签到信息",len(self.colnamedec),self.paneroot)
item = self.Tree.selection()[0]
Temp_list = self.Tree.item(item,"values")
self.top.createPane('签到信息',self.colnamedec,'view',Temp_list)
def bt3(event=None):
queryname=self.number.get()
queryidenty=self.idtyOption[self.number2.get()]
db=SysDao()
sql="select tt.term,tt.coursename,tc.techname,sr.signstatus,sr.signtime from authentication au \
join signrecord sr on au.no=sr.stuno join startsign st on st.signid=sr.signid \
join tccinfo tt on tt.tccid=st.tccid join teacherinfo tc on tc.techno=tt.techno \
where au.usrid=? and tt.coursename like '%"+queryname+"%' and sr.signstatus like '%"+queryidenty+"%'"
rsList=db.executeQuery(sql,(self.usr,))
if len(rsList)<=0:
rsList=[]
self.refreshTree(rsList)
self.Pane.destroy()
self.Pane = tk.PanedWindow(self.paneroot,width=self.width, height=self.height)
self.Pane.place(x = self.X,y = self.Y)
self.drawCanvas('签到记录')
self.lbFrame = tk.LabelFrame(self.Pane,text = "签到记录",width =self.width-20,height = self.height-50)
self.lbFrame.place(x = 10 , y = 40)
# 添加控件
self.btnames=['刷新','查看']
self.btcommand=[bt1,bt2]
self.leftButton=[]
i=0
for bname in self.btnames:
bt=tk.Button(self.lbFrame,text=bname,command=self.btcommand[i],bg='#00ff80',bd=0)
bt.place(width = 50,height = 25,x = 5+i*55,y = 10)