def change_id(self): new_id = self.ui.comboBox_3.currentText() #获得新的组号 name = self.ui.comboBox_2.currentText() order = 'update `group_rank` set `group_id`=%d where `name`="%s"' % ( int(new_id), name) Class_info.set_data(order) self.ui.label_4.setText('提示:已修改!') pass
def set_sologen(self): #设置最高分小组的口号 #查询最高分得小组号 index = Class_info.get_data("select distinct `group_id` " "from `group_rank` " "ORDER BY `sum_value` DESC LIMIT 1")[0][0] #获取最高分小组的口号 silogen = Class_info.get_data("select `slogan` " "from `group_slogan` " "where `group_id`=%d" % index)[0][0] #设置口号的label self.main_ui.label_86.setText(silogen + '--第%d小组' % index)
def update_group_score(self): #更新小组分数 group_score = Class_info.get_data("select `sum_value` " "from `group_rank` " "group by `group_id`") #把分数装入label中 for i in range(12): self.group_label_box[i].setText(str(group_score[i][0]))
def show_old_slogan_name(self): self.index = int(self.ui.comboBox.currentText()) old_slogan_name = Class_info.get_data( "select `slogan`,`group_name` from `group_slogan` where `group_id`=%d" % self.index)[0] self.ui.label_3.setText(old_slogan_name[0]) self.ui.label_8.setText(old_slogan_name[1])
def update_rank_person(self): #更新个人排名 rank = Class_info.get_data("select `NAME`,`value` " "from `group_rank` " "order by `value` desc " "limit 10 ") #把分数装入label中 for i in range(10): self.rang_person_box[i].setText(rank[i][0]) self.rank_person_score[i].setText(str(rank[i][1]))
def get_group_name(self): # 根据组号回去组员名单 group_name = Class_info.get_data("select Name " "from group_rank " "where group_id=%s" % self.ui.comboBox.currentText()) self.ui.comboBox_2.clear() # 清空combox for i in range(4): # 逐个添加组员名字 self.ui.comboBox_2.addItem(group_name[i][0])
def send_data(self): # 获取当前名字和分数 data = [ self.ui.name_box.currentText(), int(self.ui.score_box.currentText()) ] # print(data) # 根据姓名设置个人的分数 Class_info.set_data("update group_rank " "set `value`=`value`+%d " "where`NAME`='%s'" % (data[1], data[0])) # 计算当前的小组的总分,如果是NULL就设置成0 group_sum_value = Class_info.get_data( "select sum(ifnull(value,0)) " "from group_rank " "where `group_id`=%s" % self.ui.group_id_box.currentText()) Class_info.set_data( "update `group_rank` set `sum_value`=%d where `group_id`=%s" % (group_sum_value[0][0], self.ui.group_id_box.currentText())) #设置加分提示 self.ui.label_5.setText('提示:' + data[0] + ' ' + str(data[1]) + '分!!')
def get_clean_group(self): #获取值日,设置值日人员 #获取当前星期 weekday = QDateTime.currentDateTime().toString('dddd') #通过数据库查询当前星期的值日学生 clean_group = Class_info.get_data("select %s from clean" % weekday) #设置学生标签 self.main_ui.label_79.setText(clean_group[0][0]) self.main_ui.label_80.setText(clean_group[1][0]) self.main_ui.label_81.setText(clean_group[2][0]) self.main_ui.label_82.setText(clean_group[3][0]) self.main_ui.label_83.setText(clean_group[4][0]) self.main_ui.label_84.setText(clean_group[5][0]) self.main_ui.label_85.setText(clean_group[6][0])
def check_user(self): #检查密码是否正确 #获取用户名 name = self.ui.comboBox_6.currentText() #获取密码 password = int(self.ui.lineEdit.text()) #获取真实密码 real_password = Class_info.get_data("select `password` " "from `user` " "where `name`='%s'" % name)[0][0] #比较密码正确与否 if password == real_password: #如果密码正确的话 #关闭当前窗口 self.ui.close() #打开管理员窗口 self.show_admin_ui() else: #如果密码错误 self.ui.label.setText('提示:密码错误')
def update_group_name(self): group_name = Class_info.get_data( "select `group_name` from `group_slogan`") for i in range(12): self.name_group[i].setText(group_name[i][0])
self.main_ui.label_19, self.main_ui.label_20, self.main_ui.label_21, self.main_ui.label_22, self.main_ui.label_23, self.main_ui.label_24, self.main_ui.label_25, self.main_ui.label_26 ] #设置小组分数组 self.group_label_box = [ self.main_ui.group_1_lab, self.main_ui.group_2_lab, self.main_ui.group_3_lab, self.main_ui.group_4_lab, self.main_ui.group_5_lab, self.main_ui.group_6_lab, self.main_ui.group_7_lab, self.main_ui.group_8_lab, self.main_ui.group_9_lab, self.main_ui.group_10_lab, self.main_ui.group_11_lab, self.main_ui.group_12_lab ] self.name_group = [ self.main_ui.name_1, self.main_ui.name_2, self.main_ui.name_3, self.main_ui.name_4, self.main_ui.name_5, self.main_ui.name_6, self.main_ui.name_7, self.main_ui.name_8, self.main_ui.name_9, self.main_ui.name_10, self.main_ui.name_11, self.main_ui.name_12 ] if __name__ == '__main__': QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) #高分辨率自适应 app = QApplication(sys.argv) main_window = Main_window() main_window.main_ui.show() app.exec_() Class_info.exit_db() sys.exit()
def change_name(self): new_name = self.ui.lineEdit_2.text() Class_info.set_data( "update `group_slogan` set `group_name`='%s' where `group_id`=%d" % (new_name, self.index)) self.ui.label_9.setText("提示:已修改!请重启系统。")
def change_slogan(self): new_slogan = self.ui.lineEdit.text() Class_info.set_data( "update `group_slogan` set `slogan`='%s' where `group_id`=%d" % (new_slogan, self.index)) self.ui.label_5.setText("提示:已修改!请重启系统。")
def show_name(self): name = Class_info.get_data( "select `name` from `personal_rank` where `ID`=%d" % int(self.ui.stuid_box.currentText()))[0][0] self.ui.name_label.setText(name)
def reset_group_score(self): #重置小组以及个人分数 order = 'update `group_rank` set `value`=0' Class_info.set_data(order) order = 'update `group_rank` set `sum_value`=0' Class_info.set_data(order) self.ui.label_3.setText('提示:已重置,请重启。')
def save_file(self): #保存文件 file_path, _ = QFileDialog.getSaveFileName(None, "save file", "./", '.xls') Class_info.output_data(file_path)