def on_pushButton_3_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet from Login import account from Login import role if role == "学生": message(u"错误", u"您不具有审核权限,只有查看权限") elif role == "教师": #第一志愿被拒绝才会显示第二志愿 sql = "select Student.Sno 学生学号, Student.Sname 学生姓名,Topic.TopicNo 选题编号,Topic.TopicName 选题名称,Topic.Population 当前选题人数,School.SchoolName 学生所在学院,[Select].Wish 志愿,Teacher.Tno 指导老师工号,Teacher.Tname 指导老师,[Select].Admission 录取情况\ from [Select],Topic,Teacher,School,Student\ where ([Select].TopicNo=Topic.TopicNo)and([Select].Tno=Topic.Tno)and(School.SchoolNo=Student.SchoolNo)and([Select].Tno='{}')and([Select].Tno=Teacher.Tno)and([Select].Sno=Student.Sno)and([Select].Wish='第二志愿')and(Student.Sno in(select Sno from [Select] where (Admission='拒绝')and(Wish='第一志愿')))".format( account) query = self.queryFunc(sql) self.view(query) print("第二志愿审核") else: sql = "select Student.Sno 学生学号, Student.Sname 学生姓名,Topic.TopicNo 选题编号,Topic.TopicName 选题名称,Topic.Population 当前选题人数,School.SchoolName 学生所在学院,[Select].Wish 志愿,Teacher.Tno 指导老师工号,Teacher.Tname 指导老师,[Select].Admission 录取情况\ from [Select],Topic,Teacher,School,Student\ where ([Select].TopicNo=Topic.TopicNo)and([Select].Tno=Topic.Tno)and(School.SchoolNo=Student.SchoolNo)and([Select].Tno=Teacher.Tno)and([Select].Sno=Student.Sno)and([Select].Wish='第二志愿')and(Student.Sno in(select Sno from [Select] where (Admission='拒绝')and(Wish='第一志愿')))" query = self.queryFunc(sql) self.view(query) print("第二志愿审核")
def on_pushButton_2_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet query = QSqlQuery(db) #判断该学生是否有一个志愿被通过 query.prepare("select * from [Select] where Sno='{}'".format(Sno)) query.exec_() model = QSqlTableModel() model.setQuery(query) try: ad1 = model.index(0, 4).data() print("try ad1=" + ad1) except: ad1 = "拒绝" try: ad2 = model.index(1, 4).data() print("try ad2=" + ad2) except: ad2 = "拒绝" if ((ad1 == "拒绝") and (ad2 == "拒绝")): message(u"错误", u"该学生的该志愿已经被拒绝") else: print( "update [Select] set Admission='拒绝' where Sno='{}'and TopicNo='{}' and Tno='{}'" .format(Sno, TopicNo, Tno)) query.prepare( "update [Select] set Admission='拒绝' where Sno='{}'and TopicNo='{}' and Tno='{}'" .format(Sno, TopicNo, Tno)) query.exec_() message(u"成功", u"该学生未通过审核")
def on_pushButton_5_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet from Login import role if role == "管理员": my_create = CreateUserDialog() my_create.exec_() else: message(u"错误", u"您不具有该权限")
def on_pushButton_7_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet from Login import role if role == "学生": message(u"错误", u"您不具有修改选题的权限") else: my_top = TopicModifyDialog() my_top.exec_()
def on_pushButton_clicked(self): l1 = self.lineEdit.text() l2 = self.lineEdit_2.text() l3 = self.lineEdit_3.text() from Login import role query = QSqlQuery(db) if role == "教师": from Login import account query.prepare( "insert into Topic values('{}','{}','{}','0','{}')".format( l1, l2, l3, account)) if query.exec(): message(u"成功", u"数据添加成功") else: message(u"错误", u"数据添加失败,请不要插入带重复编号的选题") self.lineEdit.setText('') else: l4 = self.lineEdit_4.text() query.prepare( "insert into Topic values('{}','{}','{}','0','{}')".format( l1, l2, l3, l4)) if query.exec(): message(u"成功", u"数据添加成功") else: message(u"错误", u"数据添加失败,该工号的老师不存在或该工号的老师已经有该编号的选题") self.lineEdit.setText('') self.lineEdit_4.setText('')
def on_pushButton_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet print("select_topic") #判断当前是否已经选择了课题,若一个课题都没选择,则为第一志愿 query = QSqlQuery(db) from Login import account query.prepare("select * from [Select] where Sno='{}'".format(account)) query.exec_() model = QSqlTableModel() model.setQuery(query) nowrow = model.rowCount() print("nowrow=" + str(nowrow)) if (nowrow == 0): query.prepare( "insert into [Select](TopicNo,Sno,Tno,Wish,Admission) values('{}','{}','{}','第一志愿','待定')" .format(TopicNo, account, Tno)) if (query.exec_()): message(u"成功", u"选取第一志愿成功!") elif (nowrow == 1): query.prepare( "insert into [Select](TopicNo,Sno,Tno,Wish,Admission) values('{}','{}','{}','第二志愿','待定')" .format(TopicNo, account, Tno)) if (query.exec_()): message(u"成功", u"选取第二志愿成功!") else: message(u"失败", u"您已经选择该志愿作为第一志愿") else: message(u"警告", u"您已经选择了两个志愿!请取消志愿后再选取")
def on_pushButton_2_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet Tno = self.lineEdit_2.text() my_info = TeacherInfoCreateDialog(Tno) my_info.exec_() from TeacherInfoCreate import Tflag if Tflag == 1: #老师密码加上掩码'b' Tpassword = self.lineEdit_4.text() + 'b' query = QSqlQuery(db) sql1 = "USE [master]" sql2 = "CREATE LOGIN [{0}] WITH PASSWORD=N'{1}', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF".format( Tno, Tpassword) sql3 = "USE [Graduate]" sql4 = "CREATE USER [{0}] FOR LOGIN [{0}]".format(Tno) sql5 = "USE [Graduate]" sql6 = "ALTER ROLE [teacherRole] ADD MEMBER [{0}]".format(Tno) query.prepare(sql1) result1 = query.exec_() print(result1) query.prepare(sql2) result2 = query.exec_() print(result2) query.prepare(sql3) result3 = query.exec_() print(result3) query.prepare(sql4) result4 = query.exec_() print(result4) query.prepare(sql5) result5 = query.exec_() print(result5) query.prepare(sql6) result6 = query.exec_() print(result6) if (result1) and (result2) and (result3) and (result4) and ( result5) and (result6): message(u"成功", u"创建老师账号成功,登录名为工号") else: message(u"失败", u"创建老师账号失败,请不要输入重复的工号")
def on_pushButton_4_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet query = QSqlQuery(db) print( "delete from [Select] where(TopicNo='{}')and(Sno='{}')and(Tno='{}')" .format(TopicNo, Sno, Tno)) query.prepare( "delete from [Select] where(TopicNo='{}')and(Sno='{}')and(Tno='{}')" .format(TopicNo, Sno, Tno)) model = QSqlTableModel() model.setQuery(query) if query.exec_(): model.setQuery(query) newrow = model.rowCount() if newrow < nowrow: message(u"成功", u"撤销选题成功") else: message(u"失败", u"撤销选题失败,您的志愿已被老师同意或拒绝,无法撤销")
def searchInfo(self, account): query = QSqlQuery(db) query.prepare("select * from Teacher where Tno={}".format(account)) if query.exec(): model = QSqlTableModel() model.setQuery(query) l1 = model.index(0, 0).data() self.lineEdit.setText(l1) l2 = model.index(0, 1).data() self.lineEdit_2.setText(l2) l3 = model.index(0, 2).data() self.lineEdit_3.setText(l3) l4 = model.index(0, 3).data() self.lineEdit_4.setText(l4) l5 = model.index(0, 4).data() self.lineEdit_5.setText(l5) l6 = model.index(0, 5).data() self.lineEdit_6.setText(l6) l7 = model.index(0, 6).data() self.lineEdit_7.setText(str(l7)) else: message(u"错误", u"查询失败")
def on_pushButton_3_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet import re l1 = self.lineEdit.text() l2 = self.lineEdit_2.text() l3 = self.lineEdit_3.text() #判断日期输入格式 if (re.search(r"(\d{4}-\d{1,2}-\d{1,2})", l3)) and ((len(l3) >= 8) and (len(l3) <= 10)): print(u"日期输入正确") else: message(u"错误", u"日期输入错误!请重新输入") self.lineEdit_3.setText("") l4 = '' l4 = self.lineEdit_4.text() #判断性别输入格式 if (re.search(r"男|女", l4)) and (len(l4) == 1) and (len(l4) == 1): print(u"性别输入正确") else: message(u"错误", u"性别输入错误!请重新输入") self.lineEdit_4.setText("") l5 = '' l5 = self.lineEdit_5.text() #判断手机号码输入格式 if (re.search(r"\d{11}", l5)) and (len(l5) == 11): print(u"手机号码输入正确") else: message(u"错误", u"手机号错误,应为11位数字!请重新输入") self.lineEdit_5.setText("") l6 = '' l6 = self.lineEdit_6.text() #判断班级号输入格式 if (re.search(r"\d{6}", l6)) and (len(l6) == 6): print(u"班级号输入正确") else: message(u"错误", u"班级号错误,应为6位数字!请重新输入") self.lineEdit_6.setText("") l7 = '' l7 = self.lineEdit_7.text() #判断学院号输入格式 if (re.search(r"\d{2}", l7)) and (len(l7) == 2): print(u"学院号输入正确") else: message(u"错误", u"学院号错误,应为2位数字!请重新输入") self.lineEdit_7.setText("") l8 = '' l8 = self.lineEdit_8.text() #所有数据均输入正确 if ((l1 != "") and (l2 != "") and (l3 != "") and (l4 != "") and (l5 != "") and (l6 != "") and (l7 != "") and (l8 != "")): query = QSqlQuery(db) query.prepare("\ update Student\ set Sno='{}',Sname='{}',Sbirth='{}',Ssex='{}',Sphone='{}',ClassNo='{}',SchoolNo='{}',Sgrade={}\ where Sno={}\ ".format(l1, l2, l3, l4, l5, l6, l7, l8, l1)) if query.exec(): message(u"成功", u"修改数据成功") else: message1 = QMessageBox() message1.setText(u"数据修改失败,请输入正确的学院号和班级号如左图所示") message1.setWindowTitle(u"错误") message1.setIconPixmap(QPixmap("Class.png")) message1.exec_()
def on_pushButton_3_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet import re l1 = self.lineEdit.text() l2 = self.lineEdit_2.text() l3 = self.lineEdit_3.text() #判断日期输入格式 if (re.search(r"(\d{4}-\d{1,2}-\d{1,2})", l3)) and ((len(l3) >= 8) and (len(l3) <= 10)): print(u"日期输入正确") else: message(u"错误", u"日期输入错误!请重新输入") self.lineEdit_3.setText("") l3 = "" l4 = self.lineEdit_4.text() #判断性别输入格式 if (re.search(r"男|女", l4)) and (len(l4) == 1) and (len(l4) == 1): print(u"性别输入正确") else: message(u"错误", u"性别输入错误!请重新输入") self.lineEdit_4.setText("") l4 = "" l5 = self.lineEdit_5.text() #判断手机号码输入格式 if (re.search(r"\d{11}", l5)) and (len(l5) == 11): print(u"手机号码输入正确") else: message(u"错误", u"手机号错误,应为11位数字!请重新输入") self.lineEdit_5.setText("") l5 = "" l6 = self.lineEdit_6.text() #判断班级号输入格式 if (re.search(r"\S{2,3}", l6)) and ((len(l6) >= 2) and (len(l6) <= 3)): print(u"职称输入正确") else: message(u"错误", u"职称输入错误,只能为教授、副教授、讲师其中之一!请重新输入") self.lineEdit_6.setText("") l6 = "" l7 = self.lineEdit_7.text() #判断学院号输入格式 if (re.search(r"\d{2}", l7)) and (len(l7) == 2): print(u"学院号输入正确") else: message(u"错误", u"学院号错误,应为2位数字!请重新输入") self.lineEdit_7.setText("") l7 = "" print("学院号为" + l7) #所有数据均输入正确 if ((l1 != "") and (l2 != "") and (l3 != "") and (l4 != "") and (l5 != "") and (l6 != "") and (l7 != "")): query = QSqlQuery(db) query.prepare("\ insert into Teacher(Tno,Tname,Tbirth,Tsex,Tphone,Title,SchoolNo)\ values('{}','{}','{}','{}','{}','{}','{}')\ ".format(l1, l2, l3, l4, l5, l6, l7)) if query.exec(): message(u"成功", u"插入用户成功") global Tflag Tflag = 1 else: message1 = QMessageBox() message1.setText(u"数据修改失败,请输入正确的学院号如左图所示,或者为输入了重复的工号,请退出重试") message1.setIconPixmap(QPixmap("School.png")) message1.setWindowTitle(u"错误") message1.exec_() else: message(u"错误", u"请将数据填完整")
def on_pushButton_3_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet import re l1 = account l2 = self.lineEdit_2.text() l3 = self.lineEdit_3.text() #判断日期输入格式 if (re.search(r"(\d{4}-\d{1,2}-\d{1,2})", l3)) and ((len(l3) >= 8) and (len(l3) <= 10)): print(u"日期输入正确") else: message(u"错误", u"日期输入错误!请重新输入") self.lineEdit_3.setText("") l4 = '' l4 = self.lineEdit_4.text() #判断性别输入格式 if (re.search(r"男|女", l4)) and (len(l4) == 1) and (len(l4) == 1): print(u"性别输入正确") else: message(u"错误", u"性别输入错误!请重新输入") self.lineEdit_4.setText("") l5 = '' l5 = self.lineEdit_5.text() #判断手机号码输入格式 if (re.search(r"\d{11}", l5)) and (len(l5) == 11): print(u"手机号码输入正确") else: message(u"错误", u"手机号错误,应为11位数字!请重新输入") self.lineEdit_5.setText("") l6 = '' l6 = self.lineEdit_6.text() #判断班级号输入格式 if (re.search(r"\d{6}", l6)) and (len(l6) == 6): print(u"班级号输入正确") else: message(u"错误", u"班级号错误,应为6位数字!请重新输入") self.lineEdit_6.setText("") l7 = '' l7 = self.lineEdit_7.text() #判断学院号输入格式 if (re.search(r"\d{2}", l7)) and (len(l7) == 2): print(u"学院号输入正确") else: message(u"错误", u"学院号错误,应为2位数字!请重新输入") self.lineEdit_7.setText("") l8 = '' l8 = self.lineEdit_8.text() #所有数据均输入正确 if ((l1 != "") and (l2 != "") and (l3 != "") and (l4 != "") and (l5 != "") and (l6 != "") and (l7 != "") and (l8 != "")): query = QSqlQuery(db) query.prepare("\ insert into Student(Sno,Sname,Sbirth,Ssex,Sphone,ClassNo,SchoolNo,Sgrade)\ values('{}','{}','{}','{}','{}','{}','{}','{}')\ ".format(l1, l2, l3, l4, l5, l6, l7, l8)) print("\ insert into Student(Sno,Sname,Sbirth,Ssex,Sphone,ClassNo,SchoolNo,Sgrade)\ values('{}','{}','{}','{}','{}','{}','{}','{}')\ ".format(l1, l2, l3, l4, l5, l6, l7, l8)) if query.exec(): message(u"成功", u"插入用户成功") global Sflag Sflag = 1 else: message1 = QMessageBox() message1.setText(u"创建用户,请输入正确的学院号和班级号如左图所示,或者为输入了重复的学号,请退出重试") message1.setWindowTitle(u"错误") message1.setIconPixmap(QPixmap("Class.png")) message1.exec_() else: message(u"错误", u"请将数据填完整")