├── media ├── 08c369185d8e46e73446e7c227a32cb8.png ├── 128875292-89e6fea9-c352-40d6-8975-3033489d3c49.png ├── 1457c7a1e929678e4cda2d5ea9f28bdf.png ├── 15ab99de9bcd8bb014d1b7d9b2561f2f.png ├── 162fc94789c2b29d591e60c63694aebf.jpg ├── 18554316e7da07673131975bc2c51ef4.png ├── 18e664f5b63acf301577c40d80d7c734.png ├── 328d8a06c0c746ca35fd5d154065e9eb.png ├── 376bcf8d8ea1fac32434ac436399f92c.png ├── 53e5258d71071129f67dac0ef850c56b.png ├── 55264fc9ce1febaa38f7406e1603fe0e.png ├── 57389bb0f8fdf0ef2c2e8c4ae61b7da8.png ├── 70b575c6e68dfbbea94c0132ddcd44c8.png ├── 7bfdc0959edf48c8ee3b521395fa8116.png ├── 82e93463dbcf48195abe367895723ce7.png ├── 8831360e20f6ef19669f9de7de36edf6.png ├── 9f2f12102cc19842fdef12464368af69.png ├── a8b969de356d5402ab1b91aea1ee76c0.png ├── ae7b9e29f555d6d870838e02afc1a36b.png ├── af09e354224b410d5aa03d58a0a4b864.png ├── af8f35ef5b8a8a966044eea1387f7429.png ├── c0c49c03827fcba081d6be839760577b.png ├── d558b2c12d947e71b3819f6d262bfc04.png └── f0dcfb93fa139172c363a02d1c10eaa1.png ├── qt代码及使用说明书 ├── mysql建库脚本 │ ├── Dump20210728.sql │ └── 如果建库脚本无法使用,可以看这个.docx └── 代码部分 │ ├── addclass.cpp │ ├── addclass.h │ ├── addclass.ui │ ├── addnewcourse.cpp │ ├── addnewcourse.h │ ├── addnewcourse.ui │ ├── addnewgrade.cpp │ ├── addnewgrade.h │ ├── addnewgrade.ui │ ├── addstuinfo.cpp │ ├── addstuinfo.h │ ├── addstuinfo.ui │ ├── all_stu_info.cpp │ ├── all_stu_info.h │ ├── all_stu_info.ui │ ├── allclassinfo.cpp │ ├── allclassinfo.h │ ├── allclassinfo.ui │ ├── allcourseinfo.cpp │ ├── allcourseinfo.h │ ├── allcourseinfo.ui │ ├── classinfomanage.cpp │ ├── classinfomanage.h │ ├── classinfomanage.ui │ ├── coursemanage.cpp │ ├── coursemanage.h │ ├── coursemanage.ui │ ├── database.h │ ├── exporttable.cpp │ ├── exporttable.h │ ├── global.cpp │ ├── global.h │ ├── grademanage.cpp │ ├── grademanage.h │ ├── grademanage.ui │ ├── gradestaticsbycourse.cpp │ ├── gradestaticsbycourse.h │ ├── gradestaticsbycourse.ui │ ├── gradestaticsbystu.cpp │ ├── gradestaticsbystu.h │ ├── gradestaticsbystu.ui │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ ├── manager.cpp │ ├── manager.h │ ├── manager.ui │ ├── myclass.cpp │ ├── myclass.h │ ├── myclass.ui │ ├── mycourse.cpp │ ├── mycourse.h │ ├── mycourse.ui │ ├── myinfo.cpp │ ├── myinfo.h │ ├── myinfo.ui │ ├── myscore.cpp │ ├── myscore.h │ ├── myscore.ui │ ├── resetpwd.cpp │ ├── resetpwd.h │ ├── resetpwd.ui │ ├── searchcourse.cpp │ ├── searchcourse.h │ ├── searchcourse.ui │ ├── selectcoursemanage.cpp │ ├── selectcoursemanage.h │ ├── selectcoursemanage.ui │ ├── studentManager.pro │ ├── studentManager.pro.user │ ├── studentform.cpp │ ├── studentform.h │ ├── studentform.ui │ ├── stuinfomanage.cpp │ ├── stuinfomanage.h │ └── stuinfomanage.ui ├── qt学生信息管理系统演示 └── 学生信息管理系统_袁佳哲.pptx └── readme.md /media/08c369185d8e46e73446e7c227a32cb8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/08c369185d8e46e73446e7c227a32cb8.png -------------------------------------------------------------------------------- /media/128875292-89e6fea9-c352-40d6-8975-3033489d3c49.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/128875292-89e6fea9-c352-40d6-8975-3033489d3c49.png -------------------------------------------------------------------------------- /media/1457c7a1e929678e4cda2d5ea9f28bdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/1457c7a1e929678e4cda2d5ea9f28bdf.png -------------------------------------------------------------------------------- /media/15ab99de9bcd8bb014d1b7d9b2561f2f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/15ab99de9bcd8bb014d1b7d9b2561f2f.png -------------------------------------------------------------------------------- /media/162fc94789c2b29d591e60c63694aebf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/162fc94789c2b29d591e60c63694aebf.jpg -------------------------------------------------------------------------------- /media/18554316e7da07673131975bc2c51ef4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/18554316e7da07673131975bc2c51ef4.png -------------------------------------------------------------------------------- /media/18e664f5b63acf301577c40d80d7c734.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/18e664f5b63acf301577c40d80d7c734.png -------------------------------------------------------------------------------- /media/328d8a06c0c746ca35fd5d154065e9eb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/328d8a06c0c746ca35fd5d154065e9eb.png -------------------------------------------------------------------------------- /media/376bcf8d8ea1fac32434ac436399f92c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/376bcf8d8ea1fac32434ac436399f92c.png -------------------------------------------------------------------------------- /media/53e5258d71071129f67dac0ef850c56b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/53e5258d71071129f67dac0ef850c56b.png -------------------------------------------------------------------------------- /media/55264fc9ce1febaa38f7406e1603fe0e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/55264fc9ce1febaa38f7406e1603fe0e.png -------------------------------------------------------------------------------- /media/57389bb0f8fdf0ef2c2e8c4ae61b7da8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/57389bb0f8fdf0ef2c2e8c4ae61b7da8.png -------------------------------------------------------------------------------- /media/70b575c6e68dfbbea94c0132ddcd44c8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/70b575c6e68dfbbea94c0132ddcd44c8.png -------------------------------------------------------------------------------- /media/7bfdc0959edf48c8ee3b521395fa8116.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/7bfdc0959edf48c8ee3b521395fa8116.png -------------------------------------------------------------------------------- /media/82e93463dbcf48195abe367895723ce7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/82e93463dbcf48195abe367895723ce7.png -------------------------------------------------------------------------------- /media/8831360e20f6ef19669f9de7de36edf6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/8831360e20f6ef19669f9de7de36edf6.png -------------------------------------------------------------------------------- /media/9f2f12102cc19842fdef12464368af69.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/9f2f12102cc19842fdef12464368af69.png -------------------------------------------------------------------------------- /media/a8b969de356d5402ab1b91aea1ee76c0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/a8b969de356d5402ab1b91aea1ee76c0.png -------------------------------------------------------------------------------- /media/ae7b9e29f555d6d870838e02afc1a36b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/ae7b9e29f555d6d870838e02afc1a36b.png -------------------------------------------------------------------------------- /media/af09e354224b410d5aa03d58a0a4b864.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/af09e354224b410d5aa03d58a0a4b864.png -------------------------------------------------------------------------------- /media/af8f35ef5b8a8a966044eea1387f7429.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/af8f35ef5b8a8a966044eea1387f7429.png -------------------------------------------------------------------------------- /media/c0c49c03827fcba081d6be839760577b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/c0c49c03827fcba081d6be839760577b.png -------------------------------------------------------------------------------- /media/d558b2c12d947e71b3819f6d262bfc04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/d558b2c12d947e71b3819f6d262bfc04.png -------------------------------------------------------------------------------- /media/f0dcfb93fa139172c363a02d1c10eaa1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/media/f0dcfb93fa139172c363a02d1c10eaa1.png -------------------------------------------------------------------------------- /qt代码及使用说明书/mysql建库脚本/Dump20210728.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64) 2 | -- 3 | -- Host: localhost Database: student_manager 4 | -- ------------------------------------------------------ 5 | -- Server version 8.0.23 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!50503 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `admin` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `admin`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | /*!50503 SET character_set_client = utf8mb4 */; 25 | CREATE TABLE `admin` ( 26 | `aid` int NOT NULL DEFAULT '0', 27 | `adminName` varchar(10) DEFAULT NULL, 28 | `password` varchar(32) DEFAULT NULL, 29 | PRIMARY KEY (`aid`) 30 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 31 | /*!40101 SET character_set_client = @saved_cs_client */; 32 | 33 | -- 34 | -- Dumping data for table `admin` 35 | -- 36 | 37 | LOCK TABLES `admin` WRITE; 38 | /*!40000 ALTER TABLE `admin` DISABLE KEYS */; 39 | INSERT INTO `admin` VALUES (1,'admin','bdafe63038dfa0ac509cc80321e5433c'),(2,'admin2','bdafe63038dfa0ac509cc80321e5433c'),(3,'yjz','bdafe63038dfa0ac509cc80321e5433c'); 40 | /*!40000 ALTER TABLE `admin` ENABLE KEYS */; 41 | UNLOCK TABLES; 42 | 43 | -- 44 | -- Table structure for table `class` 45 | -- 46 | 47 | DROP TABLE IF EXISTS `class`; 48 | /*!40101 SET @saved_cs_client = @@character_set_client */; 49 | /*!50503 SET character_set_client = utf8mb4 */; 50 | CREATE TABLE `class` ( 51 | `classId` varchar(20) NOT NULL, 52 | `className` varchar(20) DEFAULT NULL, 53 | `major` varchar(20) DEFAULT NULL, 54 | `sNum` int DEFAULT NULL, 55 | `master` varchar(20) DEFAULT NULL, 56 | PRIMARY KEY (`classId`) 57 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 58 | /*!40101 SET character_set_client = @saved_cs_client */; 59 | 60 | -- 61 | -- Dumping data for table `class` 62 | -- 63 | 64 | LOCK TABLES `class` WRITE; 65 | /*!40000 ALTER TABLE `class` DISABLE KEYS */; 66 | INSERT INTO `class` VALUES ('101','软件二班','软件工程',35,'张海英'),('102','软件三班','软件工程',30,'宋亮'); 67 | /*!40000 ALTER TABLE `class` ENABLE KEYS */; 68 | UNLOCK TABLES; 69 | 70 | -- 71 | -- Table structure for table `course` 72 | -- 73 | 74 | DROP TABLE IF EXISTS `course`; 75 | /*!40101 SET @saved_cs_client = @@character_set_client */; 76 | /*!50503 SET character_set_client = utf8mb4 */; 77 | CREATE TABLE `course` ( 78 | `cId` varchar(20) NOT NULL DEFAULT '0', 79 | `object` varchar(20) DEFAULT NULL, 80 | `teacher` varchar(20) DEFAULT NULL, 81 | `time` varchar(20) DEFAULT NULL, 82 | `location` varchar(20) DEFAULT NULL, 83 | `period` varchar(20) DEFAULT NULL, 84 | `credit` varchar(20) DEFAULT NULL, 85 | PRIMARY KEY (`cId`) 86 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 87 | /*!40101 SET character_set_client = @saved_cs_client */; 88 | 89 | -- 90 | -- Dumping data for table `course` 91 | -- 92 | 93 | LOCK TABLES `course` WRITE; 94 | /*!40000 ALTER TABLE `course` DISABLE KEYS */; 95 | INSERT INTO `course` VALUES ('101','计算机网络','黄炜','大二下','一号楼B506','3-4节','4'),('102','Java程序设计','王美红','大二下','四号楼A402','1-4节','2'),('103','微积分I-1','李伟','大一上','一号楼A201','1-4节','4'),('104','微积分I-2','李伟','大一下','一号楼A202','1-4节','4'),('105','大学物理C','许清池','大一下','一号楼A504','9-11节','4'),('106','XML设计基础','宋亮','大二上','一号楼A104','5-6节','4'),('107','数据结构与算法','李贵林','大二上','一号楼B204','1-2节','4'); 96 | /*!40000 ALTER TABLE `course` ENABLE KEYS */; 97 | UNLOCK TABLES; 98 | 99 | -- 100 | -- Table structure for table `score` 101 | -- 102 | 103 | DROP TABLE IF EXISTS `score`; 104 | /*!40101 SET @saved_cs_client = @@character_set_client */; 105 | /*!50503 SET character_set_client = utf8mb4 */; 106 | CREATE TABLE `score` ( 107 | `sid` varchar(20) NOT NULL, 108 | `cid` varchar(20) NOT NULL, 109 | `object` varchar(20) DEFAULT NULL, 110 | `score` varchar(20) DEFAULT NULL, 111 | `teacher` varchar(20) DEFAULT NULL, 112 | KEY `fk_teacher_idx` (`teacher`), 113 | KEY `fk_sId_idx` (`sid`), 114 | KEY `fk_sId_idx1` (`cid`), 115 | CONSTRAINT `fk_courseId` FOREIGN KEY (`sid`) REFERENCES `student` (`sId`) ON DELETE CASCADE ON UPDATE CASCADE, 116 | CONSTRAINT `fk_sId` FOREIGN KEY (`cid`) REFERENCES `course` (`cId`) ON DELETE CASCADE ON UPDATE CASCADE 117 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 118 | /*!40101 SET character_set_client = @saved_cs_client */; 119 | 120 | -- 121 | -- Dumping data for table `score` 122 | -- 123 | 124 | LOCK TABLES `score` WRITE; 125 | /*!40000 ALTER TABLE `score` DISABLE KEYS */; 126 | INSERT INTO `score` VALUES ('11920192203642','102','Java程序设计','95','王美红'),('11920192203643','102','Java程序设计','99','王美红'),('11920192203642','103','微积分I-1','97','李伟'),('11920192203642','105','大学物理C','67','许清池'),('11920192203643','104','微积分I-2','95','李伟'),('11920192203642','104','微积分I-2','59','李伟'); 127 | /*!40000 ALTER TABLE `score` ENABLE KEYS */; 128 | UNLOCK TABLES; 129 | 130 | -- 131 | -- Table structure for table `student` 132 | -- 133 | 134 | DROP TABLE IF EXISTS `student`; 135 | /*!40101 SET @saved_cs_client = @@character_set_client */; 136 | /*!50503 SET character_set_client = utf8mb4 */; 137 | CREATE TABLE `student` ( 138 | `sId` varchar(20) NOT NULL, 139 | `name` varchar(20) DEFAULT NULL, 140 | `sex` varchar(20) DEFAULT NULL, 141 | `age` int DEFAULT NULL, 142 | `major` varchar(20) DEFAULT NULL, 143 | `class` varchar(20) DEFAULT NULL, 144 | `address` varchar(20) DEFAULT NULL, 145 | `phonenumber` varchar(20) DEFAULT NULL, 146 | `password` varchar(32) DEFAULT NULL, 147 | `status` varchar(20) DEFAULT '正常', 148 | PRIMARY KEY (`sId`), 149 | KEY `fk_classId_idx` (`class`), 150 | CONSTRAINT `fk_classId` FOREIGN KEY (`class`) REFERENCES `class` (`classId`) ON DELETE SET NULL ON UPDATE CASCADE 151 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 152 | /*!40101 SET character_set_client = @saved_cs_client */; 153 | 154 | -- 155 | -- Dumping data for table `student` 156 | -- 157 | 158 | LOCK TABLES `student` WRITE; 159 | /*!40000 ALTER TABLE `student` DISABLE KEYS */; 160 | INSERT INTO `student` VALUES ('11920192203642','袁佳哲','男',19,'软件工程','101','河南省','18603899634','bdafe63038dfa0ac509cc80321e5433c','正常'),('11920192203643','程昊天','男',19,'软件工程','102','湖北省','110','e10adc3949ba59abbe56e057f20f883e','冻结'),('11920192203644','徐荪睿','男',19,'软件工程','101','安徽省','120','e10adc3949ba59abbe56e057f20f883e','正常'),('11920192203645','谢建祥','男',19,'软件工程','101','福建省','119','e10adc3949ba59abbe56e057f20f883e','正常'),('11920192203646','李云龙','男',20,'网络安全','101','山东省','120','e10adc3949ba59abbe56e057f20f883e','正常'); 161 | /*!40000 ALTER TABLE `student` ENABLE KEYS */; 162 | UNLOCK TABLES; 163 | 164 | -- 165 | -- Table structure for table `student_course` 166 | -- 167 | 168 | DROP TABLE IF EXISTS `student_course`; 169 | /*!40101 SET @saved_cs_client = @@character_set_client */; 170 | /*!50503 SET character_set_client = utf8mb4 */; 171 | CREATE TABLE `student_course` ( 172 | `sId` varchar(20) NOT NULL, 173 | `cId` varchar(20) NOT NULL, 174 | PRIMARY KEY (`sId`,`cId`), 175 | KEY `fk_cid_idx` (`cId`), 176 | CONSTRAINT `fk_c` FOREIGN KEY (`cId`) REFERENCES `course` (`cId`) ON DELETE CASCADE ON UPDATE CASCADE, 177 | CONSTRAINT `fk_s` FOREIGN KEY (`sId`) REFERENCES `student` (`sId`) ON DELETE CASCADE ON UPDATE CASCADE 178 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 179 | /*!40101 SET character_set_client = @saved_cs_client */; 180 | 181 | -- 182 | -- Dumping data for table `student_course` 183 | -- 184 | 185 | LOCK TABLES `student_course` WRITE; 186 | /*!40000 ALTER TABLE `student_course` DISABLE KEYS */; 187 | INSERT INTO `student_course` VALUES ('11920192203642','102'),('11920192203643','102'),('11920192203642','103'),('11920192203642','104'),('11920192203643','104'),('11920192203642','105'); 188 | /*!40000 ALTER TABLE `student_course` ENABLE KEYS */; 189 | UNLOCK TABLES; 190 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 191 | 192 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 193 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 194 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 195 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 196 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 197 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 198 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 199 | 200 | -- Dump completed on 2021-07-28 8:12:53 201 | -------------------------------------------------------------------------------- /qt代码及使用说明书/mysql建库脚本/如果建库脚本无法使用,可以看这个.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/qt代码及使用说明书/mysql建库脚本/如果建库脚本无法使用,可以看这个.docx -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addclass.cpp: -------------------------------------------------------------------------------- 1 | #include "addclass.h" 2 | #include "ui_addclass.h" 3 | #include "global.h" 4 | #include "classinfomanage.h" 5 | #include 6 | 7 | addClass::addClass(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::addClass) 10 | { 11 | ui->setupUi(this); 12 | } 13 | 14 | addClass::~addClass() 15 | { 16 | delete ui; 17 | } 18 | 19 | void addClass::on_back_button_clicked() 20 | { 21 | classInfoManage *cim = new classInfoManage; 22 | this->hide(); 23 | cim->show(); 24 | } 25 | 26 | void addClass::on_submit_button_clicked() 27 | { 28 | QString classId = ui->classId_lineEdit->text(); 29 | QString className = ui->className_lineEdit->text(); 30 | QString classMajor = ui->classMajor_lineEdit->text(); 31 | QString classNum = ui->classNum_lineEdit->text(); 32 | QString classMaster = ui->classMaster_lineEdit->text(); 33 | 34 | if(classId.isEmpty() || className.isEmpty() || classMajor.isEmpty() || classNum.isEmpty() || classMaster.isEmpty()) 35 | { 36 | QMessageBox::warning(this, "输入出错", "班级信息不能留空!"); 37 | return; 38 | } 39 | 40 | QSqlDatabase db; 41 | connect_to_database(db); 42 | QSqlQuery query(db); 43 | 44 | query.exec("select classId from class where class = '" + classId + "'"); 45 | 46 | if(query.next()) 47 | { 48 | QMessageBox::warning(this, "添加出错", "该班级号已存在!"); 49 | return; 50 | } 51 | 52 | bool isInsertSuccess = query.exec(QString("insert into class values('%0','%1','%2','%3','%4')").arg(classId).arg(className).arg(classMajor).arg(classNum).arg(classMaster)); 53 | 54 | if(isInsertSuccess) 55 | { 56 | QMessageBox::information(this, "提示", "添加成功!"); 57 | } 58 | else { 59 | QMessageBox::warning(this, "添加出错", "请检查输入信息!"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addclass.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDCLASS_H 2 | #define ADDCLASS_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class addClass; 8 | } 9 | 10 | class addClass : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit addClass(QWidget *parent = nullptr); 16 | ~addClass(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | void on_submit_button_clicked(); 22 | 23 | private: 24 | Ui::addClass *ui; 25 | }; 26 | 27 | #endif // ADDCLASS_H 28 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addclass.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | addClass 4 | 5 | 6 | 7 | 0 8 | 0 9 | 450 10 | 479 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 140 20 | 20 21 | 151 22 | 31 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 添加班级信息 35 | 36 | 37 | 38 | 39 | 40 | 50 41 | 50 42 | 321 43 | 16 44 | 45 | 46 | 47 | Qt::Horizontal 48 | 49 | 50 | 51 | 52 | 53 | 110 54 | 400 55 | 51 56 | 28 57 | 58 | 59 | 60 | 提交 61 | 62 | 63 | 64 | 65 | 66 | 260 67 | 400 68 | 61 69 | 28 70 | 71 | 72 | 73 | 返回 74 | 75 | 76 | 77 | 78 | 79 | 70 80 | 90 81 | 281 82 | 271 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 班级名 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 班级人数 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 班级号 116 | 117 | 118 | 119 | 120 | 121 | 122 | 班级专业 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 班主任 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addnewcourse.cpp: -------------------------------------------------------------------------------- 1 | #include "addnewcourse.h" 2 | #include "ui_addnewcourse.h" 3 | #include "global.h" 4 | #include 5 | #include "coursemanage.h" 6 | 7 | addNewCourse::addNewCourse(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::addNewCourse) 10 | { 11 | ui->setupUi(this); 12 | ui->timeBox->addItem("大一上"); 13 | ui->timeBox->addItem("大一下"); 14 | ui->timeBox->addItem("大二上"); 15 | ui->timeBox->addItem("大二下"); 16 | } 17 | 18 | addNewCourse::~addNewCourse() 19 | { 20 | delete ui; 21 | } 22 | 23 | void addNewCourse::on_back_button_clicked() 24 | { 25 | courseManage *cm = new courseManage; 26 | this->hide(); 27 | cm->show(); 28 | } 29 | 30 | void addNewCourse::on_submitButton_clicked() 31 | { 32 | QString cId = ui->courseId_lineEdit->text(); 33 | QString object = ui->object_lineEdit->text(); 34 | QString teacher = ui->teacher_lineEdit->text(); 35 | QString time = ui->timeBox->currentText(); 36 | QString location = ui->location_lineEdit->text(); 37 | QString period = ui->period_lineEdit->text(); 38 | QString credit = ui->credit_lineEdit->text(); 39 | 40 | if(cId.isEmpty() || object.isEmpty() || teacher.isEmpty() || time.isEmpty() || location.isEmpty() 41 | || period.isEmpty() || credit.isEmpty()) 42 | { 43 | QMessageBox::warning(this, "信息出错", "课程信息不能留空!"); 44 | return; 45 | } 46 | 47 | QSqlDatabase db; 48 | connect_to_database(db); 49 | QSqlQuery query(db); 50 | 51 | query.exec("select cId from course where cId = '" + cId + "'"); 52 | if(query.next()) 53 | { 54 | QMessageBox::warning(this, "添加出错", "该课程号已存在!"); 55 | return; 56 | } 57 | 58 | bool isInsertSuccess = query.exec(QString("insert into course values('%0','%1','%2','%3','%4','%5','%6')") 59 | .arg(cId).arg(object).arg(teacher).arg(time).arg(location).arg(period).arg(credit)); 60 | 61 | if(isInsertSuccess) 62 | { 63 | QMessageBox::information(this, "提示", "添加成功"); 64 | } 65 | else { 66 | QMessageBox::warning(this, "添加出错", "请检查填写信息!"); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addnewcourse.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDNEWCOURSE_H 2 | #define ADDNEWCOURSE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class addNewCourse; 8 | } 9 | 10 | class addNewCourse : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit addNewCourse(QWidget *parent = nullptr); 16 | ~addNewCourse(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | void on_submitButton_clicked(); 22 | 23 | private: 24 | Ui::addNewCourse *ui; 25 | }; 26 | 27 | #endif // ADDNEWCOURSE_H 28 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addnewcourse.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | addNewCourse 4 | 5 | 6 | 7 | 0 8 | 0 9 | 396 10 | 447 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 110 20 | 20 21 | 151 22 | 31 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 添加新的课程 35 | 36 | 37 | 38 | 39 | 40 | 40 41 | 50 42 | 301 43 | 16 44 | 45 | 46 | 47 | Qt::Horizontal 48 | 49 | 50 | 51 | 52 | 53 | 180 54 | 400 55 | 61 56 | 28 57 | 58 | 59 | 60 | 提交 61 | 62 | 63 | 64 | 65 | 66 | 260 67 | 400 68 | 61 69 | 28 70 | 71 | 72 | 73 | 返回 74 | 75 | 76 | 77 | 78 | 79 | 60 80 | 90 81 | 261 82 | 291 83 | 84 | 85 | 86 | 87 | 88 | 89 | 课程号 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 课程名 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 任课教师 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 开课学期 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 上课地点 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 上课时间 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 学分数 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addnewgrade.cpp: -------------------------------------------------------------------------------- 1 | #include "addnewgrade.h" 2 | #include "ui_addnewgrade.h" 3 | #include "global.h" 4 | #include "grademanage.h" 5 | #include 6 | 7 | addNewGrade::addNewGrade(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::addNewGrade) 10 | { 11 | ui->setupUi(this); 12 | } 13 | 14 | addNewGrade::~addNewGrade() 15 | { 16 | delete ui; 17 | } 18 | 19 | void addNewGrade::on_back_button_clicked() 20 | { 21 | gradeManage *gm = new gradeManage; 22 | this->hide(); 23 | gm->show(); 24 | } 25 | 26 | void addNewGrade::on_cId_lineEdit_textChanged(const QString &arg1) 27 | { 28 | QString cId = arg1; 29 | 30 | QSqlDatabase db; 31 | connect_to_database(db); 32 | 33 | QSqlQuery query(db); 34 | query.exec("select object,teacher from course where cId = '" + cId + "'"); 35 | 36 | if(query.next()) 37 | { 38 | QString object = query.value(0).toString(); 39 | QString teacher = query.value(1).toString(); 40 | ui->cName_lineEdit->setText(object); 41 | ui->teacher_lineEdit->setText(teacher); 42 | } 43 | else { 44 | ui->cName_lineEdit->clear(); 45 | ui->teacher_lineEdit->clear(); 46 | } 47 | } 48 | 49 | void addNewGrade::on_submit_button_clicked() 50 | { 51 | QString sId = ui->sId_lineEdit->text(); 52 | QString cId = ui->cId_lineEdit->text(); 53 | QString object = ui->cName_lineEdit->text(); 54 | QString score = ui->score_lineEdit->text(); 55 | QString teacher = ui->teacher_lineEdit->text(); 56 | 57 | if(sId.isEmpty() || cId.isEmpty() || object.isEmpty() || score.isEmpty() || teacher.isEmpty()) 58 | { 59 | QMessageBox::warning(this, "插入出错", "信息不能留空!"); 60 | return; 61 | } 62 | 63 | QSqlDatabase db; 64 | connect_to_database(db); 65 | 66 | QSqlQuery query(db); 67 | 68 | query.exec("select sId from student where sId = '" + sId + "'"); 69 | 70 | if(!query.next()) 71 | { 72 | QMessageBox::warning(this, "插入出错", "该学生不存在!"); 73 | return; 74 | } 75 | 76 | query.exec("select sId,cId from student_course where sId = '" + sId + "' and cId = '" + cId + "'"); 77 | 78 | if(!query.next()) 79 | { 80 | QMessageBox::warning(this, "插入出错", "该学生未选择该课程!"); 81 | return; 82 | } 83 | 84 | query.exec("select sId,cId from score where sid = '" + sId + "' and cid = '" + cId + "'"); 85 | 86 | if(query.next()) 87 | { 88 | QMessageBox::warning(this, "插入出错", "该成绩信息已存在!\n请勿重复添加!"); 89 | return; 90 | } 91 | 92 | 93 | bool isInsertSuccess = query.exec(QString("insert into score values('%0','%1','%2','%3','%4')").arg(sId).arg(cId).arg(object).arg(score).arg(teacher)); 94 | 95 | if(isInsertSuccess) 96 | { 97 | QMessageBox::information(this, "提示", "添加成功"); 98 | } 99 | else { 100 | QMessageBox::warning(this, "插入出错", "请检查输入信息!"); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addnewgrade.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDNEWGRADE_H 2 | #define ADDNEWGRADE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class addNewGrade; 8 | } 9 | 10 | class addNewGrade : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit addNewGrade(QWidget *parent = nullptr); 16 | ~addNewGrade(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | //void on_cId_lineEdit_editingFinished(); 22 | 23 | void on_cId_lineEdit_textChanged(const QString &arg1); 24 | 25 | void on_submit_button_clicked(); 26 | 27 | private: 28 | Ui::addNewGrade *ui; 29 | }; 30 | 31 | #endif // ADDNEWGRADE_H 32 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addnewgrade.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | addNewGrade 4 | 5 | 6 | 7 | 0 8 | 0 9 | 405 10 | 426 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 130 20 | 30 21 | 151 22 | 41 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 添加成绩信息 35 | 36 | 37 | 38 | 39 | 40 | 90 41 | 350 42 | 71 43 | 28 44 | 45 | 46 | 47 | 提交 48 | 49 | 50 | 51 | 52 | 53 | 210 54 | 350 55 | 71 56 | 28 57 | 58 | 59 | 60 | 返回 61 | 62 | 63 | 64 | 65 | 66 | 60 67 | 80 68 | 251 69 | 251 70 | 71 | 72 | 73 | 74 | 75 | 76 | 学号 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 课程号 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 课程名 97 | 98 | 99 | 100 | 101 | 102 | 103 | true 104 | 105 | 106 | 107 | 108 | 109 | 110 | 分数 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 任课教师 121 | 122 | 123 | 124 | 125 | 126 | 127 | true 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addstuinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "addstuinfo.h" 2 | #include "ui_addstuinfo.h" 3 | #include "global.h" 4 | #include "stuinfomanage.h" 5 | #include 6 | 7 | addStuInfo::addStuInfo(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::addStuInfo) 10 | { 11 | ui->setupUi(this); 12 | ui->sexBox->addItem("男"); 13 | ui->sexBox->addItem("女"); 14 | } 15 | 16 | addStuInfo::~addStuInfo() 17 | { 18 | delete ui; 19 | } 20 | 21 | void addStuInfo::on_pushButton_3_clicked() 22 | { 23 | this->hide(); 24 | stuinfomanage *sif = new stuinfomanage; 25 | sif->show(); 26 | } 27 | 28 | void addStuInfo::on_clear_button_clicked() 29 | { 30 | ui->sNo_lineEdit->clear(); 31 | ui->sName_lineEdit->clear(); 32 | ui->sexBox->setCurrentIndex(0); 33 | ui->age_lineEdit->clear(); 34 | ui->major_lineEdit->clear(); 35 | ui->address_lineEdit->clear(); 36 | ui->classId_lineEdit->clear(); 37 | ui->phonenum_lineEdit->clear(); 38 | } 39 | 40 | void addStuInfo::on_submit_button_clicked() 41 | { 42 | QString sNo = ui->sNo_lineEdit->text(); 43 | QString name = ui->sName_lineEdit->text(); 44 | QString sex = ui->sexBox->currentText(); 45 | QString age = ui->age_lineEdit->text(); 46 | QString major = ui->major_lineEdit->text(); 47 | QString address = ui->address_lineEdit->text(); 48 | QString Class = ui->classId_lineEdit->text(); 49 | QString phone = ui->phonenum_lineEdit->text(); 50 | 51 | if(sNo.isEmpty() || name.isEmpty() || age.isEmpty() || major.isEmpty() || 52 | address.isEmpty() || Class.isEmpty() || phone.isEmpty()) 53 | { 54 | QMessageBox::warning(this, "警告", "输入信息不能留空!"); 55 | return; 56 | } 57 | 58 | QSqlDatabase db; 59 | connect_to_database(db); 60 | 61 | QSqlQuery query(db); 62 | 63 | query.exec("select sId from student where sId = '" + sNo + "'"); 64 | 65 | if(query.next()) 66 | { 67 | QMessageBox::warning(this, "新增出错", "该学号已经存在!"); 68 | return; 69 | } 70 | 71 | query.exec("select classId from class where classId = '" + Class + "'"); 72 | if(query.size() == 0) 73 | { 74 | QMessageBox::warning(this, "新增出错", "该班级号不存在!"); 75 | return; 76 | } 77 | 78 | bool isInsertSuccess = query.exec(QString("insert into student values('%0','%1','%2','%3','%4','%5','%6','%7','%8','%9')").arg(sNo).arg(name) 79 | .arg(sex).arg(age).arg(major).arg(Class).arg(address).arg(phone).arg("123456").arg("正常")); 80 | 81 | if(isInsertSuccess) 82 | QMessageBox::information(this, "提示", "新增学生成功!"); 83 | else { 84 | QMessageBox::warning(this, "新增失败", "请检查输入信息是否有误"); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addstuinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDSTUINFO_H 2 | #define ADDSTUINFO_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class addStuInfo; 8 | } 9 | 10 | class addStuInfo : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit addStuInfo(QWidget *parent = nullptr); 16 | ~addStuInfo(); 17 | 18 | private slots: 19 | void on_pushButton_3_clicked(); 20 | 21 | void on_clear_button_clicked(); 22 | 23 | void on_submit_button_clicked(); 24 | 25 | private: 26 | Ui::addStuInfo *ui; 27 | }; 28 | 29 | #endif // ADDSTUINFO_H 30 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/addstuinfo.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | addStuInfo 4 | 5 | 6 | 7 | 0 8 | 0 9 | 549 10 | 417 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 160 20 | 20 21 | 201 22 | 41 23 | 24 | 25 | 26 | <h1>添加学生信息</h1> 27 | 28 | 29 | 30 | 31 | 32 | 110 33 | 50 34 | 291 35 | 16 36 | 37 | 38 | 39 | Qt::Horizontal 40 | 41 | 42 | 43 | 44 | 45 | 70 46 | 370 47 | 391 48 | 30 49 | 50 | 51 | 52 | 53 | 54 | 55 | 提交 56 | 57 | 58 | 59 | 60 | 61 | 62 | 清空 63 | 64 | 65 | 66 | 67 | 68 | 69 | 返回 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 110 79 | 70 80 | 311 81 | 271 82 | 83 | 84 | 85 | 86 | 87 | 88 | 学号 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 姓名 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 性别 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 专业 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 年龄 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 班级号 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 籍贯 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 联系方式 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/all_stu_info.cpp: -------------------------------------------------------------------------------- 1 | #include "all_stu_info.h" 2 | #include "ui_all_stu_info.h" 3 | #include "stuinfomanage.h" 4 | #include "exporttable.h" 5 | 6 | all_stu_info::all_stu_info(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::all_stu_info) 9 | { 10 | ui->setupUi(this); 11 | setWindowTitle(QString("Design by 袁佳哲")); 12 | 13 | 14 | for(auto i : list_all_student) 15 | { 16 | int rowCount = ui->tableWidget->rowCount(); 17 | 18 | ui->tableWidget->insertRow(rowCount); 19 | 20 | QStringList rowData = i.toStringList(); 21 | 22 | for (int j = 0; j < rowData.size(); j++) 23 | { 24 | QTableWidgetItem *item = new QTableWidgetItem; 25 | item->setText(rowData.at(j)); 26 | ui->tableWidget->setItem(rowCount, j, item); 27 | } 28 | } 29 | 30 | int columnCount = ui->tableWidget->columnCount(); 31 | int rowCount = ui->tableWidget->rowCount(); 32 | 33 | for(int i = 0; i tableWidget->item(j, i)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter); 38 | } 39 | } 40 | } 41 | 42 | all_stu_info::~all_stu_info() 43 | { 44 | delete ui; 45 | } 46 | 47 | void all_stu_info::on_back_stuButton_clicked() 48 | { 49 | this->hide(); 50 | list_all_student.clear(); 51 | ui->tableWidget->clear(); 52 | stuinfomanage *sfm = new stuinfomanage; 53 | sfm->show(); 54 | } 55 | 56 | void all_stu_info::on_export_button_clicked() 57 | { 58 | Table2Excel(ui->tableWidget, "所有学生信息"); 59 | } 60 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/all_stu_info.h: -------------------------------------------------------------------------------- 1 | #ifndef ALL_STU_INFO_H 2 | #define ALL_STU_INFO_H 3 | 4 | #include 5 | #include "global.h" 6 | #include "studentform.h" 7 | 8 | namespace Ui { 9 | class all_stu_info; 10 | } 11 | 12 | class all_stu_info : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit all_stu_info(QWidget *parent = nullptr); 18 | ~all_stu_info(); 19 | 20 | private slots: 21 | void on_back_stuButton_clicked(); 22 | 23 | void on_export_button_clicked(); 24 | 25 | private: 26 | Ui::all_stu_info *ui; 27 | }; 28 | 29 | #endif // ALL_STU_INFO_H 30 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/all_stu_info.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | all_stu_info 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1164 10 | 569 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 70 20 | 70 21 | 1021 22 | 401 23 | 24 | 25 | 26 | 27 | 学号 28 | 29 | 30 | 31 | 32 | 姓名 33 | 34 | 35 | 36 | 37 | 性别 38 | 39 | 40 | 41 | 42 | 年龄 43 | 44 | 45 | 46 | 47 | 专业 48 | 49 | 50 | 51 | 52 | 班级号 53 | 54 | 55 | 56 | 57 | 籍贯 58 | 59 | 60 | 61 | 62 | 联系电话 63 | 64 | 65 | 66 | 67 | 状态 68 | 69 | 70 | 71 | 72 | 73 | 74 | 440 75 | 10 76 | 171 77 | 41 78 | 79 | 80 | 81 | 82 | Arial 83 | 14 84 | 75 85 | true 86 | 87 | 88 | 89 | 所有学生信息 90 | 91 | 92 | 93 | 94 | 95 | 870 96 | 20 97 | 196 98 | 30 99 | 100 | 101 | 102 | 103 | 104 | 105 | 导出为Excel 106 | 107 | 108 | 109 | 110 | 111 | 112 | 返回 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/allclassinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "allclassinfo.h" 2 | #include "ui_allclassinfo.h" 3 | #include "global.h" 4 | #include "classinfomanage.h" 5 | #include "exporttable.h" 6 | 7 | allClassInfo::allClassInfo(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::allClassInfo) 10 | { 11 | ui->setupUi(this); 12 | 13 | QSqlDatabase db; 14 | connect_to_database(db); 15 | 16 | QSqlQuery query(db); 17 | 18 | query.exec("select classId,className,major,sNum,master from class"); 19 | 20 | while(query.next()) 21 | { 22 | QString classId = query.value(0).toString(); 23 | QString className = query.value(1).toString(); 24 | QString major = query.value(2).toString(); 25 | QString sNum = query.value(3).toString(); 26 | QString master =query.value(4).toString(); 27 | 28 | QStringList q; 29 | q << classId << className << major << sNum << master; 30 | 31 | int rowCount = ui->classInfoTable->rowCount(); 32 | ui->classInfoTable->insertRow(rowCount); 33 | 34 | for(int i = 0; isetText(q.at(i)); 38 | ui->classInfoTable->setItem(rowCount, i, item); 39 | } 40 | } 41 | 42 | int columnCount = ui->classInfoTable->columnCount(); 43 | int rowCount = ui->classInfoTable->rowCount(); 44 | 45 | for(int i = 0; i classInfoTable->item(j, i)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter); 50 | } 51 | } 52 | } 53 | 54 | allClassInfo::~allClassInfo() 55 | { 56 | delete ui; 57 | } 58 | 59 | void allClassInfo::on_back_button_clicked() 60 | { 61 | this->hide(); 62 | classInfoManage *cim = new classInfoManage; 63 | cim->show(); 64 | } 65 | 66 | void allClassInfo::on_export_button_clicked() 67 | { 68 | Table2Excel(ui->classInfoTable, "所有班级信息"); 69 | } 70 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/allclassinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef ALLCLASSINFO_H 2 | #define ALLCLASSINFO_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class allClassInfo; 8 | } 9 | 10 | class allClassInfo : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit allClassInfo(QWidget *parent = nullptr); 16 | ~allClassInfo(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | void on_export_button_clicked(); 22 | 23 | private: 24 | Ui::allClassInfo *ui; 25 | }; 26 | 27 | #endif // ALLCLASSINFO_H 28 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/allclassinfo.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | allClassInfo 4 | 5 | 6 | 7 | 0 8 | 0 9 | 665 10 | 505 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 240 20 | 10 21 | 161 22 | 51 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 所有班级信息 35 | 36 | 37 | 38 | 39 | 40 | 20 41 | 60 42 | 631 43 | 381 44 | 45 | 46 | 47 | 48 | 班级号 49 | 50 | 51 | 52 | 53 | 班级名 54 | 55 | 56 | 57 | 58 | 班级专业 59 | 60 | 61 | 62 | 63 | 班级人数 64 | 65 | 66 | 67 | 68 | 班主任 69 | 70 | 71 | 72 | 73 | 74 | 75 | 400 76 | 460 77 | 196 78 | 30 79 | 80 | 81 | 82 | 83 | 84 | 85 | 导出为Excel 86 | 87 | 88 | 89 | 90 | 91 | 92 | 返回 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/allcourseinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "allcourseinfo.h" 2 | #include "ui_allcourseinfo.h" 3 | #include "global.h" 4 | #include "coursemanage.h" 5 | #include "exporttable.h" 6 | 7 | allCourseInfo::allCourseInfo(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::allCourseInfo) 10 | { 11 | ui->setupUi(this); 12 | 13 | QSqlDatabase db; 14 | connect_to_database(db); 15 | QSqlQuery query(db); 16 | 17 | query.exec("select cId,object,teacher,time,location,period,credit from course"); 18 | 19 | while(query.next()) 20 | { 21 | QString cId = query.value(0).toString(); 22 | QString object = query.value(1).toString(); 23 | QString teacher = query.value(2).toString(); 24 | QString time = query.value(3).toString(); 25 | QString location = query.value(4).toString(); 26 | QString period = query.value(5).toString(); 27 | QString credit = query.value(6).toString(); 28 | 29 | QString courseNum; 30 | 31 | QSqlQuery query1(db); 32 | 33 | query1.exec("select cId, count(*) from student_course where cId = '" + cId + "' group by '" + cId + "'"); 34 | 35 | if(query1.next()) 36 | courseNum = query1.value(1).toString(); 37 | else { 38 | courseNum = "0"; 39 | } 40 | 41 | QStringList q; 42 | q << cId << object << teacher << time << location << period << credit << courseNum; 43 | 44 | int rowCount = ui->courseIInfoTable->rowCount(); 45 | ui->courseIInfoTable->insertRow(rowCount); 46 | 47 | for(int i = 0; isetText(q.at(i)); 51 | ui->courseIInfoTable->setItem(rowCount, i, item); 52 | } 53 | } 54 | 55 | int columnCount = ui->courseIInfoTable->columnCount(); 56 | int rowCount = ui->courseIInfoTable->rowCount(); 57 | 58 | for(int i = 0; i courseIInfoTable->item(j, i)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter); 63 | } 64 | } 65 | } 66 | 67 | allCourseInfo::~allCourseInfo() 68 | { 69 | delete ui; 70 | } 71 | 72 | void allCourseInfo::on_back_button_clicked() 73 | { 74 | this->hide(); 75 | courseManage *cm = new courseManage; 76 | cm->show(); 77 | } 78 | 79 | void allCourseInfo::on_export_button_clicked() 80 | { 81 | Table2Excel(ui->courseIInfoTable, "所有课程信息"); 82 | } 83 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/allcourseinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef ALLCOURSEINFO_H 2 | #define ALLCOURSEINFO_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class allCourseInfo; 8 | } 9 | 10 | class allCourseInfo : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit allCourseInfo(QWidget *parent = nullptr); 16 | ~allCourseInfo(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | void on_export_button_clicked(); 22 | 23 | private: 24 | Ui::allCourseInfo *ui; 25 | }; 26 | 27 | #endif // ALLCOURSEINFO_H 28 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/allcourseinfo.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | allCourseInfo 4 | 5 | 6 | 7 | 0 8 | 0 9 | 886 10 | 511 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 370 20 | 20 21 | 151 22 | 31 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 所有课程信息 35 | 36 | 37 | 38 | 39 | 40 | 40 41 | 80 42 | 811 43 | 361 44 | 45 | 46 | 47 | 48 | 课程号 49 | 50 | 51 | 52 | 53 | 课程名 54 | 55 | 56 | 57 | 58 | 任课教师 59 | 60 | 61 | 62 | 63 | 开课学期 64 | 65 | 66 | 67 | 68 | 上课地点 69 | 70 | 71 | 72 | 73 | 上课时间 74 | 75 | 76 | 77 | 78 | 学分数 79 | 80 | 81 | 82 | 83 | 选课人数 84 | 85 | 86 | 87 | 88 | 89 | 90 | 630 91 | 460 92 | 196 93 | 30 94 | 95 | 96 | 97 | 98 | 99 | 100 | 导出为Excel 101 | 102 | 103 | 104 | 105 | 106 | 107 | 返回 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/classinfomanage.cpp: -------------------------------------------------------------------------------- 1 | #include "classinfomanage.h" 2 | #include "ui_classinfomanage.h" 3 | #include 4 | #include "global.h" 5 | #include "manager.h" 6 | #include "allclassinfo.h" 7 | #include "addclass.h" 8 | 9 | classInfoManage::classInfoManage(QWidget *parent) : 10 | QWidget(parent), 11 | ui(new Ui::classInfoManage) 12 | { 13 | ui->setupUi(this); 14 | ui->delete_button->setDisabled(true); 15 | ui->update_button->setDisabled(true); 16 | } 17 | 18 | classInfoManage::~classInfoManage() 19 | { 20 | delete ui; 21 | } 22 | 23 | void classInfoManage::on_back_button_clicked() 24 | { 25 | this->hide(); 26 | manager *ma = new manager; 27 | ma->show(); 28 | } 29 | 30 | void classInfoManage::on_search_button_clicked() 31 | { 32 | QString classId = ui->classId_lineEdit->text(); 33 | QSqlDatabase db; 34 | connect_to_database(db); 35 | 36 | QSqlQuery query(db); 37 | 38 | query.exec("select className, major, sNum, master from class where classId = '" + classId + "'"); 39 | if(query.next()) 40 | { 41 | QString className = query.value(0).toString(); 42 | QString major = query.value(1).toString(); 43 | QString sNum = query.value(2).toString(); 44 | QString master = query.value(3).toString(); 45 | 46 | ui->className_lineEdit->setText(className); 47 | ui->classMajor_Edit->setText(major); 48 | ui->classNum_lineEdit->setText(sNum); 49 | ui->classMaster_lineEdit->setText(master); 50 | 51 | ui->update_button->setDisabled(false); 52 | ui->delete_button->setDisabled(false); 53 | } 54 | else { 55 | ui->update_button->setDisabled(true); 56 | ui->delete_button->setDisabled(true); 57 | 58 | ui->className_lineEdit->clear(); 59 | ui->classMajor_Edit->clear(); 60 | ui->classNum_lineEdit->clear(); 61 | ui->classMaster_lineEdit->clear(); 62 | 63 | QMessageBox::warning(this, "查询无果", "不存在该班级!"); 64 | 65 | ui->classId_lineEdit->setFocus(); 66 | 67 | } 68 | 69 | } 70 | 71 | void classInfoManage::on_listAll_button_clicked() 72 | { 73 | this->hide(); 74 | allClassInfo *aci = new allClassInfo; 75 | aci->show(); 76 | } 77 | 78 | void classInfoManage::on_add_button_clicked() 79 | { 80 | this->hide(); 81 | addClass *ac = new addClass; 82 | ac->show(); 83 | } 84 | 85 | void classInfoManage::on_update_button_clicked() 86 | { 87 | QSqlDatabase db; 88 | connect_to_database(db); 89 | QSqlQuery query(db); 90 | 91 | QString classId = ui->classId_lineEdit->text(); 92 | QString className = ui->className_lineEdit->text(); 93 | QString major = ui->classMajor_Edit->text(); 94 | QString sNum = ui->classNum_lineEdit->text(); 95 | QString master = ui->classMaster_lineEdit->text(); 96 | 97 | bool isUpdateSuceess = query.exec(QString("update class set className = '%0', " 98 | "major = '%1', sNum = '%2', " 99 | "master = '%3' where classId = '%4'").arg(className).arg(major).arg(sNum).arg(master).arg(classId)); 100 | 101 | if(isUpdateSuceess) 102 | { 103 | QMessageBox::information(this, "提示", "更新班级信息成功"); 104 | } 105 | else { 106 | QMessageBox::warning(this, "更新失败", "请检查输入信息!"); 107 | } 108 | } 109 | 110 | void classInfoManage::on_delete_button_clicked() 111 | { 112 | QString classId = ui->classId_lineEdit->text(); 113 | 114 | QSqlDatabase db; 115 | connect_to_database(db); 116 | QSqlQuery query(db); 117 | 118 | QMessageBox::StandardButton btn; 119 | btn = QMessageBox::question(this, "确认删除", "确定删除此班级信息?", QMessageBox::Yes|QMessageBox::No); 120 | 121 | if(btn == QMessageBox::Yes) 122 | { 123 | bool isDeleteSuccess = query.exec("delete from class where classId = '" + classId + "'"); 124 | if(isDeleteSuccess) 125 | { 126 | QMessageBox::information(this, "提示", "删除成功"); 127 | 128 | ui->classId_lineEdit->clear(); 129 | ui->className_lineEdit->clear(); 130 | ui->classMajor_Edit->clear(); 131 | ui->classNum_lineEdit->clear(); 132 | ui->classMaster_lineEdit->clear(); 133 | 134 | ui->classId_lineEdit->setFocus(); 135 | } 136 | else { 137 | QMessageBox::warning(this, "警告", "删除失败!"); 138 | } 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/classinfomanage.h: -------------------------------------------------------------------------------- 1 | #ifndef CLASSINFOMANAGE_H 2 | #define CLASSINFOMANAGE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class classInfoManage; 8 | } 9 | 10 | class classInfoManage : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit classInfoManage(QWidget *parent = nullptr); 16 | ~classInfoManage(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | void on_search_button_clicked(); 22 | 23 | void on_listAll_button_clicked(); 24 | 25 | void on_add_button_clicked(); 26 | 27 | void on_update_button_clicked(); 28 | 29 | void on_delete_button_clicked(); 30 | 31 | private: 32 | Ui::classInfoManage *ui; 33 | }; 34 | 35 | #endif // CLASSINFOMANAGE_H 36 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/classinfomanage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | classInfoManage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 472 10 | 434 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 140 20 | 10 21 | 171 22 | 51 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 班级信息管理 35 | 36 | 37 | 38 | 39 | 40 | 30 41 | 110 42 | 391 43 | 20 44 | 45 | 46 | 47 | Qt::Horizontal 48 | 49 | 50 | 51 | 52 | 53 | 40 54 | 80 55 | 111 56 | 16 57 | 58 | 59 | 60 | 请输入班级号: 61 | 62 | 63 | 64 | 65 | 66 | 150 67 | 80 68 | 101 69 | 21 70 | 71 | 72 | 73 | 74 | 75 | 76 | 290 77 | 70 78 | 61 79 | 28 80 | 81 | 82 | 83 | 查询 84 | 85 | 86 | 87 | 88 | 89 | 380 90 | 70 91 | 61 92 | 28 93 | 94 | 95 | 96 | 返回 97 | 98 | 99 | 100 | 101 | 102 | 100 103 | 140 104 | 241 105 | 191 106 | 107 | 108 | 109 | 110 | 111 | 112 | 班级名 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 班级专业 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 班级人数 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 班主任 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 20 155 | 360 156 | 411 157 | 30 158 | 159 | 160 | 161 | 162 | 163 | 164 | 更新班级 165 | 166 | 167 | 168 | 169 | 170 | 171 | 删除班级 172 | 173 | 174 | 175 | 176 | 177 | 178 | 查看所有班级 179 | 180 | 181 | 182 | 183 | 184 | 185 | 添加班级 186 | 187 | 188 | 189 | 190 | 191 | 192 | Qt::Vertical 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/coursemanage.cpp: -------------------------------------------------------------------------------- 1 | #include "coursemanage.h" 2 | #include "ui_coursemanage.h" 3 | #include "global.h" 4 | #include "manager.h" 5 | #include 6 | #include "allcourseinfo.h" 7 | #include "addnewcourse.h" 8 | 9 | courseManage::courseManage(QWidget *parent) : 10 | QWidget(parent), 11 | ui(new Ui::courseManage) 12 | { 13 | ui->setupUi(this); 14 | ui->timeBox->addItem("大一上"); 15 | ui->timeBox->addItem("大一下"); 16 | ui->timeBox->addItem("大二上"); 17 | ui->timeBox->addItem("大二下"); 18 | ui->update_button->setDisabled(true); 19 | ui->delete_button->setDisabled(true); 20 | } 21 | 22 | courseManage::~courseManage() 23 | { 24 | delete ui; 25 | } 26 | 27 | void courseManage::on_bakc_button_clicked() 28 | { 29 | manager * m = new manager; 30 | this->hide(); 31 | m->show(); 32 | } 33 | 34 | void courseManage::on_searchButton_clicked() 35 | { 36 | QString cId = ui->courseId_lineEdit->text(); 37 | QSqlDatabase db; 38 | connect_to_database(db); 39 | 40 | QSqlQuery query(db); 41 | 42 | query.exec("select object, teacher, time, location, period, credit from course where cId = '" + cId + "'"); 43 | if(query.next()) 44 | { 45 | QString object = query.value(0).toString(); 46 | QString teacher = query.value(1).toString(); 47 | QString time = query.value(2).toString(); 48 | QString location = query.value(3).toString(); 49 | QString period = query.value(4).toString(); 50 | QString credit = query.value(5).toString(); 51 | 52 | QString courseNum; 53 | 54 | query.exec("select cId, count(*) from student_course where cId = '" + cId + "' group by '" + cId + "'"); 55 | 56 | if(query.next()) 57 | courseNum = query.value(1).toString(); 58 | else { 59 | courseNum = "0"; 60 | } 61 | 62 | ui->courseName_lineEdit->setText(object); 63 | ui->teacher_lineEdit->setText(teacher); 64 | ui->timeBox->setCurrentIndex(ui->timeBox->findText(time)); 65 | ui->location_lineEdit->setText(location); 66 | ui->period_lineEdit->setText(period); 67 | ui->credit_lineEdit->setText(credit); 68 | ui->courseNum_lineEdit->setText(courseNum); 69 | 70 | ui->update_button->setDisabled(false); 71 | ui->delete_button->setDisabled(false); 72 | } 73 | else { 74 | ui->update_button->setDisabled(true); 75 | ui->delete_button->setDisabled(true); 76 | 77 | ui->courseName_lineEdit->clear(); 78 | ui->teacher_lineEdit->clear(); 79 | ui->timeBox->setCurrentIndex(0); 80 | ui->location_lineEdit->clear(); 81 | ui->period_lineEdit->clear(); 82 | ui->credit_lineEdit->clear(); 83 | ui->courseNum_lineEdit->clear(); 84 | 85 | QMessageBox::warning(this, "查询无果", "不存在该课程!"); 86 | 87 | ui->courseId_lineEdit->setFocus(); 88 | 89 | } 90 | } 91 | 92 | void courseManage::on_listAllCourse_button_clicked() 93 | { 94 | this->hide(); 95 | allCourseInfo *aci = new allCourseInfo; 96 | aci->show(); 97 | } 98 | 99 | void courseManage::on_add_button_clicked() 100 | { 101 | addNewCourse *anc = new addNewCourse; 102 | this->hide(); 103 | anc->show(); 104 | } 105 | 106 | void courseManage::on_update_button_clicked() 107 | { 108 | QMessageBox::StandardButton btn; 109 | btn = QMessageBox::question(this, "确认修改", "确定修改此课程信息?", QMessageBox::Yes|QMessageBox::No); 110 | if(btn == QMessageBox::Yes) 111 | { 112 | QSqlDatabase db; 113 | connect_to_database(db); 114 | QSqlQuery query(db); 115 | 116 | QString cId = ui->courseId_lineEdit->text(); 117 | QString object = ui->courseName_lineEdit->text(); 118 | QString teacher = ui->teacher_lineEdit->text(); 119 | QString time = ui->timeBox->currentText(); 120 | QString location = ui->location_lineEdit->text(); 121 | QString period = ui->period_lineEdit->text(); 122 | QString credit = ui->credit_lineEdit->text(); 123 | 124 | bool isUpdateInCourseSuccess = query.exec(QString("update course " 125 | "set object = '%0',teacher = '%1', time='%2',location='%3',period='%4',credit='%5' where cId = '%6'") 126 | .arg(object).arg(teacher).arg(time).arg(location).arg(period).arg(credit).arg(cId)); 127 | 128 | bool isUpdateInScoreSuccess = query.exec(QString("update score " 129 | "set object = '%0',teacher = '%1' where cid = '%2'").arg(object).arg(teacher).arg(cId)); 130 | 131 | if(isUpdateInScoreSuccess && isUpdateInCourseSuccess) 132 | { 133 | QMessageBox::information(this, "提示", "修改成功"); 134 | 135 | } 136 | else { 137 | QMessageBox::warning(this, "修改失败", "请检查输入信息!"); 138 | } 139 | } 140 | 141 | } 142 | 143 | void courseManage::on_delete_button_clicked() 144 | { 145 | QMessageBox::StandardButton btn; 146 | btn = QMessageBox::question(this, "确认删除", "确定删除此课程信息?", QMessageBox::Yes|QMessageBox::No); 147 | if(btn == QMessageBox::Yes) 148 | { 149 | QSqlDatabase db; 150 | connect_to_database(db); 151 | QSqlQuery query(db); 152 | 153 | QString cId = ui->courseId_lineEdit->text(); 154 | 155 | bool isDeleteSuccess = query.exec("delete from course where cId = '" + cId + "'"); 156 | 157 | if(isDeleteSuccess) 158 | { 159 | QMessageBox::information(this, "提示", "删除成功"); 160 | } 161 | else { 162 | QMessageBox::warning(this, "警告", "删除失败!"); 163 | } 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/coursemanage.h: -------------------------------------------------------------------------------- 1 | #ifndef COURSEMANAGE_H 2 | #define COURSEMANAGE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class courseManage; 8 | } 9 | 10 | class courseManage : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit courseManage(QWidget *parent = nullptr); 16 | ~courseManage(); 17 | 18 | private slots: 19 | void on_bakc_button_clicked(); 20 | 21 | void on_searchButton_clicked(); 22 | 23 | void on_listAllCourse_button_clicked(); 24 | 25 | void on_add_button_clicked(); 26 | 27 | void on_update_button_clicked(); 28 | 29 | void on_delete_button_clicked(); 30 | 31 | private: 32 | Ui::courseManage *ui; 33 | }; 34 | 35 | #endif // COURSEMANAGE_H 36 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/coursemanage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | courseManage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 504 10 | 484 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 170 20 | 30 21 | 151 22 | 31 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 课程信息管理 35 | 36 | 37 | 38 | 39 | 40 | 40 41 | 110 42 | 401 43 | 16 44 | 45 | 46 | 47 | Qt::Horizontal 48 | 49 | 50 | 51 | 52 | 53 | 40 54 | 70 55 | 401 56 | 40 57 | 58 | 59 | 60 | 61 | 62 | 63 | 请输入课程号: 64 | 65 | 66 | 67 | 68 | 69 | 70 | 返回 71 | 72 | 73 | 74 | 75 | 76 | 77 | 查询 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 30 90 | 420 91 | 423 92 | 30 93 | 94 | 95 | 96 | 97 | 98 | 99 | 删除课程信息 100 | 101 | 102 | 103 | 104 | 105 | 106 | 查看所有课程 107 | 108 | 109 | 110 | 111 | 112 | 113 | 更新课程信息 114 | 115 | 116 | 117 | 118 | 119 | 120 | 添加课程 121 | 122 | 123 | 124 | 125 | 126 | 127 | Qt::Vertical 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 80 137 | 130 138 | 311 139 | 251 140 | 141 | 142 | 143 | 144 | 145 | 146 | 课程名 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 任课教师 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 上课学期 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 上课地点 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 上课时间 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 学分数 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 选课人数 207 | 208 | 209 | 210 | 211 | 212 | 213 | true 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/database.h: -------------------------------------------------------------------------------- 1 | #ifndef DATABASE_H 2 | #define DATABASE_H 3 | 4 | extern 5 | 6 | #endif // DATABASE_H 7 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/exporttable.cpp: -------------------------------------------------------------------------------- 1 | #include "exporttable.h" 2 | 3 | void Table2Excel(QTableWidget *table, QString title) 4 | { 5 | QString fileName = QFileDialog::getSaveFileName(table, "保存",QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation),"Excel 文件(*.xls *.xlsx)"); 6 | if(fileName != "") 7 | { 8 | QAxObject *excel = new QAxObject; 9 | if(excel->setControl("Excel.Application")) 10 | { 11 | excel->dynamicCall("SetVisible (bool Visible)","false"); 12 | excel->setProperty("DisplayAlerts", false); 13 | QAxObject *workbooks = excel->querySubObject("WorkBooks"); 14 | workbooks->dynamicCall("Add"); 15 | QAxObject *workbook = excel->querySubObject("ActiveWorkBook"); 16 | QAxObject *worksheet = workbook->querySubObject("Worksheets(int)", 1); 17 | 18 | int i,j; 19 | int colcount = table->columnCount(); 20 | int rowcount = table->rowCount(); 21 | 22 | QAxObject *cell,*col; 23 | cell=worksheet->querySubObject("Cells(int,int)", 1, 1); 24 | cell->dynamicCall("SetValue(const QString&)", title); 25 | cell->querySubObject("Font")->setProperty("Size", 18); 26 | //调整行高 27 | worksheet->querySubObject("Range(const QString&)", "1:1")->setProperty("RowHeight", 30); 28 | //合并标题行 29 | QString cellTitle; 30 | cellTitle.append("A1:"); 31 | cellTitle.append(QChar(colcount - 1 + 'A')); 32 | cellTitle.append(QString::number(1)); 33 | QAxObject *range = worksheet->querySubObject("Range(const QString&)", cellTitle); 34 | 35 | range->setProperty("WrapText", true); 36 | range->setProperty("MergeCells", true); 37 | range->setProperty("HorizontalAlignment", -4108);//xlCenter 38 | range->setProperty("VerticalAlignment", -4108);//xlCenter 39 | for(i=0;iquerySubObject("Columns(const QString&)", columnName); 46 | col->setProperty("ColumnWidth", table->columnWidth(i)/6); 47 | cell = worksheet->querySubObject("Cells(int,int)", 2, i+1); 48 | 49 | columnName = table->horizontalHeaderItem(i)->text(); 50 | 51 | cell->dynamicCall("SetValue(const QString&)", columnName); 52 | cell->querySubObject("Font")->setProperty("Bold", true); 53 | cell->querySubObject("Interior")->setProperty("Color",QColor(191, 191, 191)); 54 | cell->setProperty("HorizontalAlignment", -4108);//xlCenter 55 | cell->setProperty("VerticalAlignment", -4108);//xlCenter 56 | } 57 | 58 | 59 | 60 | 61 | for(i=0;iquerySubObject("Cells(int,int)", i+3, j+1)->dynamicCall("SetValue(const QString&)", table->item(i,j)?table->item(i,j)->text():""); 66 | //worksheet->querySubObject("Cells(int,int)", i+3, j+1)->setProperty("VerticalAlignment", -4108); 67 | cell = worksheet->querySubObject("Cells(int,int)", i+3, j+1); 68 | cell->setProperty("HorizontalAlignment", -4108);//xlCenter 69 | cell->setProperty("VerticalAlignment", -4108);//xlCenter 70 | } 71 | } 72 | 73 | 74 | QString lrange; 75 | lrange.append("A2:"); 76 | lrange.append(colcount - 1 + 'A'); 77 | lrange.append(QString::number(table->rowCount() + 2)); 78 | range = worksheet->querySubObject("Range(const QString&)", lrange); 79 | range->querySubObject("Borders")->setProperty("LineStyle", QString::number(1)); 80 | range->querySubObject("Borders")->setProperty("Color", QColor(0, 0, 0)); 81 | 82 | QString rowsName; 83 | rowsName.append("2:"); 84 | rowsName.append(QString::number(table->rowCount() + 2)); 85 | range = worksheet->querySubObject("Range(const QString&)", rowsName); 86 | range->setProperty("RowHeight", 20); 87 | workbook->dynamicCall("SaveAs(const QString&)",QDir::toNativeSeparators(fileName)); 88 | workbook->dynamicCall("Close()"); 89 | excel->dynamicCall("Quit()"); 90 | delete excel; 91 | 92 | excel = NULL; 93 | 94 | if (QMessageBox::question(NULL,"完成","文件已经导出,是否现在打开?",QMessageBox::Yes|QMessageBox::No)==QMessageBox::Yes) 95 | { 96 | QDesktopServices::openUrl(QUrl("file:///" + QDir::toNativeSeparators(fileName))); 97 | } 98 | } 99 | } 100 | else 101 | { 102 | QMessageBox::warning(NULL,"错误","未能创建 Excel 对象,请安装 Microsoft Excel。",QMessageBox::Apply); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/exporttable.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPORTTABLE_H 2 | #define EXPORTTABLE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | extern void Table2Excel(QTableWidget *table, QString title); 11 | 12 | #endif // EXPORTTABLE_H 13 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/global.cpp: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | 3 | QString sqlUser = "root"; 4 | QString sqlPwd = ""; 5 | QString sqlLocalHost = "localhost"; 6 | QString username_Current = ""; 7 | QString pwd_Current = ""; 8 | QString sName_Current = ""; 9 | QVariantList list_all_student; 10 | 11 | void connect_to_database(QSqlDatabase db) 12 | { 13 | if(QSqlDatabase::contains("qt_sql_default_connection")) 14 | db = QSqlDatabase::database("qt_sql_default_connection"); 15 | else 16 | db = QSqlDatabase::addDatabase("QMYSQL"); 17 | 18 | db.setHostName(sqlLocalHost); 19 | db.setUserName(sqlUser); 20 | db.setPassword(sqlPwd); 21 | db.setDatabaseName("student_manager"); 22 | 23 | if(!db.open()) 24 | qDebug() << "connect fail"; 25 | else 26 | { 27 | qDebug() << "success"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/global.h: -------------------------------------------------------------------------------- 1 | #ifndef GLOBAL_H 2 | #define GLOBAL_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | extern QString sqlUser; 11 | extern QString sqlPwd; 12 | extern QString sqlLocalHost; 13 | 14 | extern QString username_Current; 15 | extern QString sName_Current; 16 | extern QString pwd_Current; 17 | 18 | extern QVariantList list_all_student; 19 | 20 | extern void connect_to_database(QSqlDatabase db); 21 | 22 | #endif // GLOBAL_H 23 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/grademanage.h: -------------------------------------------------------------------------------- 1 | #ifndef GRADEMANAGE_H 2 | #define GRADEMANAGE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class gradeManage; 8 | } 9 | 10 | class gradeManage : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit gradeManage(QWidget *parent = nullptr); 16 | ~gradeManage(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | void on_listAll_button_clicked(); 22 | 23 | void on_searchBysNo_clicked(); 24 | 25 | void on_searchBycId_clicked(); 26 | 27 | void on_addGrade_button_clicked(); 28 | 29 | void on_gradeTable_cellClicked(int row, int column); 30 | 31 | //void on_sId_lineEdit_textChanged(const QString &arg1); 32 | 33 | //void on_cId_lineEdit_textChanged(const QString &arg1); 34 | 35 | void on_update_gradeButton_clicked(); 36 | 37 | void on_delete_button_clicked(); 38 | 39 | void on_student_statistics_clicked(); 40 | 41 | void on_course_statistics_clicked(); 42 | 43 | void on_export_button_clicked(); 44 | 45 | private: 46 | Ui::gradeManage *ui; 47 | void updataTable(); 48 | }; 49 | 50 | #endif // GRADEMANAGE_H 51 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/grademanage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | gradeManage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1105 10 | 534 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 450 20 | 20 21 | 151 22 | 31 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 成绩信息管理 35 | 36 | 37 | 38 | 39 | 40 | 30 41 | 90 42 | 751 43 | 401 44 | 45 | 46 | 47 | 48 | 学号 49 | 50 | 51 | 52 | 53 | 课程号 54 | 55 | 56 | 57 | 58 | 课程名 59 | 60 | 61 | 62 | 63 | 得分 64 | 65 | 66 | 67 | 68 | 任课教师 69 | 70 | 71 | 72 | 73 | 74 | 75 | 830 76 | 130 77 | 241 78 | 51 79 | 80 | 81 | 82 | 83 | 84 | 85 | 学号: 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 课程号: 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 830 108 | 200 109 | 222 110 | 65 111 | 112 | 113 | 114 | 115 | 116 | 117 | 根据学号查找 118 | 119 | 120 | 121 | 122 | 123 | 124 | 根据课程号查找 125 | 126 | 127 | 128 | 129 | 130 | 131 | 查看所有成绩 132 | 133 | 134 | 135 | 136 | 137 | 138 | 添加成绩信息 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 810 148 | 280 149 | 267 150 | 65 151 | 152 | 153 | 154 | 155 | 156 | 157 | 删除选中成绩信息 158 | 159 | 160 | 161 | 162 | 163 | 164 | 学生个人成绩统计 165 | 166 | 167 | 168 | 169 | 170 | 171 | 课程成绩统计 172 | 173 | 174 | 175 | 176 | 177 | 178 | 修改选中成绩信息 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 830 188 | 100 189 | 72 190 | 15 191 | 192 | 193 | 194 | 当前选中: 195 | 196 | 197 | 198 | 199 | 200 | 850 201 | 370 202 | 196 203 | 30 204 | 205 | 206 | 207 | 208 | 209 | 210 | 导出为Excel 211 | 212 | 213 | 214 | 215 | 216 | 217 | 返回 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/gradestaticsbycourse.cpp: -------------------------------------------------------------------------------- 1 | #include "gradestaticsbycourse.h" 2 | #include "ui_gradestaticsbycourse.h" 3 | #include "global.h" 4 | #include "grademanage.h" 5 | #include 6 | 7 | gradeStaticsByCourse::gradeStaticsByCourse(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::gradeStaticsByCourse) 10 | { 11 | ui->setupUi(this); 12 | } 13 | 14 | gradeStaticsByCourse::~gradeStaticsByCourse() 15 | { 16 | delete ui; 17 | } 18 | 19 | void gradeStaticsByCourse::on_back_button_clicked() 20 | { 21 | gradeManage *gm = new gradeManage; 22 | this->hide(); 23 | gm->show(); 24 | } 25 | 26 | void gradeStaticsByCourse::on_search_button_clicked() 27 | { 28 | QString cId = ui->cId_lineEdit->text(); 29 | if(cId.isEmpty()) 30 | { 31 | QMessageBox::warning(this, "统计出错", "课程号不能留空!"); 32 | ui->cName_lineEdit->clear(); 33 | ui->teacher_lineEdit->clear(); 34 | ui->maxScore_lineEdit->clear(); 35 | ui->minScore_lineEdit->clear(); 36 | ui->avgScore_lineEdit->clear(); 37 | ui->selectSum_lineEdit->clear(); 38 | ui->notPassSum_lineEdit->clear(); 39 | return; 40 | } 41 | 42 | QSqlDatabase db; 43 | connect_to_database(db); 44 | QSqlQuery query(db); 45 | 46 | query.exec("select cId from course where cId = '" + cId + "'"); 47 | if(!query.next()) 48 | { 49 | QMessageBox::warning(this, "统计出错", "该课程不存在!"); 50 | ui->cName_lineEdit->clear(); 51 | ui->teacher_lineEdit->clear(); 52 | ui->maxScore_lineEdit->clear(); 53 | ui->minScore_lineEdit->clear(); 54 | ui->avgScore_lineEdit->clear(); 55 | ui->selectSum_lineEdit->clear(); 56 | ui->notPassSum_lineEdit->clear(); 57 | return; 58 | } 59 | 60 | query.exec("select object,teacher from course where cId = '" + cId + "'"); 61 | if(query.next()) 62 | { 63 | QString object = query.value(0).toString(); 64 | QString teacher = query.value(1).toString(); 65 | ui->cName_lineEdit->setText(object); 66 | ui->teacher_lineEdit->setText(teacher); 67 | } 68 | 69 | query.exec("select count(sId) from student_course where cId = '" + cId + "'"); 70 | if(query.next()) 71 | { 72 | QString selectSum = query.value(0).toString(); 73 | ui->selectSum_lineEdit->setText(selectSum); 74 | } 75 | 76 | query.exec("select max(score.score), min(score.score), avg(score.score) from score where score.cid = '" + cId + "'"); 77 | 78 | if(query.next()) 79 | { 80 | QString maxScore = query.value(0).toString(); 81 | QString minScore = query.value(1).toString(); 82 | QString avgScore = query.value(2).toString(); 83 | ui->maxScore_lineEdit->setText(maxScore); 84 | ui->minScore_lineEdit->setText(minScore); 85 | ui->avgScore_lineEdit->setText(avgScore); 86 | } 87 | 88 | query.exec("select count(*) from score where cid = '" + cId + "' and score.score < 60"); 89 | 90 | if(query.next()) 91 | { 92 | QString notPassSum = query.value(0).toString(); 93 | ui->notPassSum_lineEdit->setText(notPassSum); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/gradestaticsbycourse.h: -------------------------------------------------------------------------------- 1 | #ifndef GRADESTATICSBYCOURSE_H 2 | #define GRADESTATICSBYCOURSE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class gradeStaticsByCourse; 8 | } 9 | 10 | class gradeStaticsByCourse : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit gradeStaticsByCourse(QWidget *parent = nullptr); 16 | ~gradeStaticsByCourse(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | void on_search_button_clicked(); 22 | 23 | private: 24 | Ui::gradeStaticsByCourse *ui; 25 | }; 26 | 27 | #endif // GRADESTATICSBYCOURSE_H 28 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/gradestaticsbycourse.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | gradeStaticsByCourse 4 | 5 | 6 | 7 | 0 8 | 0 9 | 454 10 | 464 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 130 20 | 20 21 | 201 22 | 41 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 课程成绩信息统计 35 | 36 | 37 | 38 | 39 | 40 | 20 41 | 60 42 | 411 43 | 16 44 | 45 | 46 | 47 | Qt::Horizontal 48 | 49 | 50 | 51 | 52 | 53 | 50 54 | 90 55 | 111 56 | 16 57 | 58 | 59 | 60 | 请输入课程号: 61 | 62 | 63 | 64 | 65 | 66 | 160 67 | 90 68 | 113 69 | 21 70 | 71 | 72 | 73 | 74 | 75 | 76 | 300 77 | 90 78 | 51 79 | 28 80 | 81 | 82 | 83 | 查询 84 | 85 | 86 | 87 | 88 | 89 | 370 90 | 90 91 | 51 92 | 28 93 | 94 | 95 | 96 | 返回 97 | 98 | 99 | 100 | 101 | 102 | 90 103 | 140 104 | 281 105 | 291 106 | 107 | 108 | 109 | 110 | 111 | 112 | 课程名 113 | 114 | 115 | 116 | 117 | 118 | 119 | true 120 | 121 | 122 | 123 | 124 | 125 | 126 | 任课教师 127 | 128 | 129 | 130 | 131 | 132 | 133 | true 134 | 135 | 136 | 137 | 138 | 139 | 140 | 选课人数 141 | 142 | 143 | 144 | 145 | 146 | 147 | true 148 | 149 | 150 | 151 | 152 | 153 | 154 | 课程最高分 155 | 156 | 157 | 158 | 159 | 160 | 161 | true 162 | 163 | 164 | 165 | 166 | 167 | 168 | 课程最低分 169 | 170 | 171 | 172 | 173 | 174 | 175 | true 176 | 177 | 178 | 179 | 180 | 181 | 182 | 课程平均分 183 | 184 | 185 | 186 | 187 | 188 | 189 | true 190 | 191 | 192 | 193 | 194 | 195 | 196 | 不及格人数 197 | 198 | 199 | 200 | 201 | 202 | 203 | true 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/gradestaticsbystu.cpp: -------------------------------------------------------------------------------- 1 | #include "gradestaticsbystu.h" 2 | #include "ui_gradestaticsbystu.h" 3 | #include "grademanage.h" 4 | #include "global.h" 5 | #include 6 | 7 | gradeStaticsByStu::gradeStaticsByStu(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::gradeStaticsByStu) 10 | { 11 | ui->setupUi(this); 12 | } 13 | 14 | gradeStaticsByStu::~gradeStaticsByStu() 15 | { 16 | delete ui; 17 | } 18 | 19 | void gradeStaticsByStu::on_back_button_clicked() 20 | { 21 | this->hide(); 22 | gradeManage *gm = new gradeManage; 23 | gm->show(); 24 | } 25 | 26 | void gradeStaticsByStu::on_start_button_clicked() 27 | { 28 | QString sId = ui->sId_lineEdit->text(); 29 | 30 | if(sId.isEmpty()) 31 | { 32 | QMessageBox::warning(this, "统计出错", "学号信息不能为空"); 33 | ui->creditSum_lineEdit->clear(); 34 | ui->avgGrade_lineEdit->clear(); 35 | ui->maxGrade_lineEdit->clear(); 36 | ui->minGrade_lineEdit->clear(); 37 | ui->notpassSum_lineEdit->clear(); 38 | ui->selectedSum_lineEdit->clear(); 39 | return; 40 | } 41 | 42 | QSqlDatabase db; 43 | connect_to_database(db); 44 | QSqlQuery query(db); 45 | 46 | query.exec("select sId from student where sId = '" + sId + "'"); 47 | 48 | if(!query.next()) 49 | { 50 | QMessageBox::warning(this, "统计出错", "该学生不存在!"); 51 | ui->creditSum_lineEdit->clear(); 52 | ui->avgGrade_lineEdit->clear(); 53 | ui->maxGrade_lineEdit->clear(); 54 | ui->minGrade_lineEdit->clear(); 55 | ui->notpassSum_lineEdit->clear(); 56 | ui->selectedSum_lineEdit->clear(); 57 | return; 58 | } 59 | 60 | query.exec("select sId from student_course where sId = '" + sId + "'"); 61 | if(!query.next()) 62 | { 63 | QMessageBox::warning(this, "统计出错", "该学生没有选课信息!"); 64 | ui->creditSum_lineEdit->clear(); 65 | ui->avgGrade_lineEdit->clear(); 66 | ui->maxGrade_lineEdit->clear(); 67 | ui->minGrade_lineEdit->clear(); 68 | ui->notpassSum_lineEdit->clear(); 69 | ui->selectedSum_lineEdit->clear(); 70 | return; 71 | } 72 | 73 | query.exec("select count(cId) from student_course where sId = '" + sId + "'"); 74 | 75 | if(query.next()) 76 | { 77 | QString courseSum = query.value(0).toString(); 78 | ui->selectedSum_lineEdit->setText(courseSum); 79 | } 80 | 81 | query.exec("select count(*) from score where score < 60 and sid = '" + sId + "'"); 82 | if(query.next()) 83 | { 84 | QString notPassSum = query.value(0).toString(); 85 | ui->notpassSum_lineEdit->setText(notPassSum); 86 | } 87 | 88 | query.exec("select max(score) from score where sid = '" + sId + "'"); 89 | if(query.next()) 90 | { 91 | QString maxScore = query.value(0).toString(); 92 | ui->maxGrade_lineEdit->setText(maxScore); 93 | } 94 | 95 | query.exec("select min(score) from score where sid = '" + sId + "'"); 96 | if(query.next()) 97 | { 98 | QString minScore = query.value(0).toString(); 99 | ui->minGrade_lineEdit->setText(minScore); 100 | } 101 | 102 | query.exec("select avg(score) from score where sid = '" + sId + "'"); 103 | if(query.next()) 104 | { 105 | QString avgScore = query.value(0).toString(); 106 | ui->avgGrade_lineEdit->setText(avgScore); 107 | } 108 | 109 | query.exec("select sum(credit) from course where cId in (select cid from score where sid = '" + sId + "' and score > 60)"); 110 | if(query.next()) 111 | { 112 | QString creditSum = query.value(0).toString(); 113 | ui->creditSum_lineEdit->setText(creditSum); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/gradestaticsbystu.h: -------------------------------------------------------------------------------- 1 | #ifndef GRADESTATICSBYSTU_H 2 | #define GRADESTATICSBYSTU_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class gradeStaticsByStu; 8 | } 9 | 10 | class gradeStaticsByStu : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit gradeStaticsByStu(QWidget *parent = nullptr); 16 | ~gradeStaticsByStu(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | void on_start_button_clicked(); 22 | 23 | private: 24 | Ui::gradeStaticsByStu *ui; 25 | }; 26 | 27 | #endif // GRADESTATICSBYSTU_H 28 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/gradestaticsbystu.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | gradeStaticsByStu 4 | 5 | 6 | 7 | 0 8 | 0 9 | 448 10 | 394 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 160 20 | 20 21 | 151 22 | 21 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 学生信息统计 35 | 36 | 37 | 38 | 39 | 40 | 40 41 | 90 42 | 121 43 | 16 44 | 45 | 46 | 47 | 请输入学生学号: 48 | 49 | 50 | 51 | 52 | 53 | 10 54 | 60 55 | 401 56 | 16 57 | 58 | 59 | 60 | Qt::Horizontal 61 | 62 | 63 | 64 | 65 | 66 | 160 67 | 90 68 | 141 69 | 21 70 | 71 | 72 | 73 | 74 | 75 | 76 | 340 77 | 90 78 | 51 79 | 28 80 | 81 | 82 | 83 | 统计 84 | 85 | 86 | 87 | 88 | 89 | 340 90 | 130 91 | 51 92 | 28 93 | 94 | 95 | 96 | 返回 97 | 98 | 99 | 100 | 101 | 102 | 50 103 | 130 104 | 261 105 | 241 106 | 107 | 108 | 109 | 110 | 111 | 112 | 已修学分 113 | 114 | 115 | 116 | 117 | 118 | 119 | true 120 | 121 | 122 | 123 | 124 | 125 | 126 | 课程最高分 127 | 128 | 129 | 130 | 131 | 132 | 133 | true 134 | 135 | 136 | 137 | 138 | 139 | 140 | 课程平均分 141 | 142 | 143 | 144 | 145 | 146 | 147 | true 148 | 149 | 150 | 151 | 152 | 153 | 154 | 课程最低分 155 | 156 | 157 | 158 | 159 | 160 | 161 | true 162 | 163 | 164 | 165 | 166 | 167 | 168 | 不及格课程数 169 | 170 | 171 | 172 | 173 | 174 | 175 | true 176 | 177 | 178 | 179 | 180 | 181 | 182 | 已选课程数 183 | 184 | 185 | 186 | 187 | 188 | 189 | true 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | //#include 10 | 11 | MainWindow::MainWindow(QWidget *parent) : 12 | QMainWindow(parent), 13 | ui(new Ui::MainWindow) 14 | { 15 | ui->setupUi(this); 16 | ui->Login_password->setEchoMode(QLineEdit::Password); 17 | ui->Login_username->setPlaceholderText("请输入学号或管理员账号"); 18 | ui->Login_password->setPlaceholderText("请输入密码"); 19 | ui->studentButton->setChecked(true); 20 | 21 | loginFailTimes = 0; 22 | 23 | ui->captcha_lineEdit->setVisible(false); 24 | ui->captcha_Label->setVisible(false); 25 | ui->loginFailTimes_Label->setVisible(false); 26 | ui->loginFailTimes_Label->setStyleSheet("color:#ff0000"); 27 | 28 | qsrand(QTime::currentTime().second() * 1000 + QTime::currentTime().msec()); 29 | 30 | captcha = getCaptcha(); 31 | color = getColor(); 32 | 33 | connect(&timer, SIGNAL(timeout()), this, SLOT(onTimeOut())); 34 | timer.start(500); 35 | 36 | } 37 | 38 | MainWindow::~MainWindow() 39 | { 40 | delete ui; 41 | //timer.stop(); 42 | } 43 | 44 | void MainWindow::onTimeOut() 45 | { 46 | qsrand(QTime::currentTime().second() * 1000 + QTime::currentTime().msec()); 47 | color = getColor(); 48 | update(); 49 | } 50 | 51 | void MainWindow::mousePressEvent(QMouseEvent *evt) 52 | { 53 | if(QRect(300, 190, 84, 24).contains(evt->pos())) 54 | { 55 | captcha = getCaptcha(); 56 | repaint(); 57 | } 58 | } 59 | 60 | void MainWindow::paintEvent(QPaintEvent *evt) 61 | { 62 | 63 | if(loginFailTimes >= 3) 64 | { 65 | QPainter painter(this); 66 | 67 | painter.fillRect(300, 190, 84, 24, Qt::lightGray); 68 | 69 | painter.setFont(QFont("Comic Sans MS")); 70 | 71 | for(int i = 0; i < 4; i++) 72 | { 73 | painter.setPen(color[i]); 74 | painter.drawText(300 + 20 * i, 190, 20, 24, Qt::AlignCenter, QString(captcha[i])); 75 | } 76 | 77 | for(int i = 0; i < 100; i++) 78 | { 79 | painter.setPen(color[i % 4]); 80 | painter.drawPoint(300 + qrand()%83, 190 + qrand() % 23); 81 | } 82 | } 83 | } 84 | 85 | QString MainWindow::getCaptcha() 86 | { 87 | QString ret = ""; 88 | 89 | for(int i = 0; i < 4; i++) 90 | { 91 | int c = (qrand() % 2)? 'a' : 'A'; 92 | ret += static_cast(c + qrand() % 26); 93 | } 94 | 95 | return ret; 96 | } 97 | 98 | Qt::GlobalColor* MainWindow::getColor() 99 | { 100 | static Qt::GlobalColor colors[4]; 101 | 102 | for(int i = 0; i < 4; i++) 103 | { 104 | colors[i] = static_cast((qrand() % 16) + 2); 105 | } 106 | 107 | return colors; 108 | } 109 | 110 | void MainWindow::on_LoginButton_clicked() 111 | { 112 | QString input_userName = ui->Login_username->text(); 113 | //QString input_password = ui->Login_password->text(); 114 | QString input_password = QCryptographicHash::hash(ui->Login_password->text().toLatin1(), QCryptographicHash::Md5).toHex(); 115 | QString input_captcha = ui->captcha_lineEdit->text(); 116 | 117 | if(loginFailTimes >= 3) 118 | { 119 | // qDebug() << captcha; 120 | // qDebug() << input_captcha; 121 | if(input_captcha.compare(captcha) != 0) 122 | { 123 | QMessageBox::warning(this, "登录失败", "验证码错误!"); 124 | return; 125 | } 126 | } 127 | 128 | QSqlDatabase db; 129 | connect_to_database(db); 130 | QSqlQuery query(db); 131 | 132 | if(ui->adminButton->isChecked()) 133 | { 134 | 135 | query.exec("select adminName from admin where adminName = '" + input_userName + "'"); 136 | 137 | if(!query.next()) 138 | { 139 | QMessageBox::warning(this, "登录失败", "该用户不存在!"); 140 | return; 141 | } 142 | 143 | query.exec("select aid, adminName, password from admin where adminName = '" + input_userName + "' and password = '" + input_password + "'"); 144 | 145 | bool isLoginSuccess = false; 146 | 147 | if(query.next()) 148 | { 149 | QString userName = query.value(1).toString(); 150 | QString pwd = query.value(2).toString(); 151 | username_Current = userName; 152 | pwd_Current = ui->Login_password->text(); 153 | isLoginSuccess = true; 154 | //QString md5_pwd = QCryptographicHash::hash(pwd.toLatin1(), QCryptographicHash::Md5).toHex(); 155 | this->hide(); 156 | m = new manager; 157 | m->show(); 158 | } 159 | 160 | if(!isLoginSuccess) 161 | { 162 | QMessageBox::warning(this, "登录失败", "密码错误!"); 163 | ui->Login_username->setFocus(); 164 | } 165 | } 166 | 167 | if(ui->studentButton->isChecked()) 168 | { 169 | query.exec("select sId from student where sId = '" + input_userName + "'"); 170 | 171 | if(!query.next()) 172 | { 173 | QMessageBox::warning(this, "登录失败", "该用户不存在!"); 174 | return; 175 | } 176 | 177 | query.exec("select status from student where sId = '" + input_userName + "'"); 178 | if(query.next()) 179 | { 180 | QString status = query.value(0).toString(); 181 | if(status.compare("冻结") == 0) 182 | { 183 | QMessageBox::warning(this, "登录失败", "该用户已被冻结\n请联系管理员进行解冻!"); 184 | return; 185 | } 186 | } 187 | 188 | bool isLoginSuccess = false; 189 | 190 | query.exec("select sId, name, password from student where sId = '" + input_userName + "' and password = '" + input_password + "'"); 191 | 192 | if(query.next()) 193 | { 194 | QString sNo = query.value(0).toString(); 195 | QString sName = query.value(1).toString(); 196 | QString pwd = query.value(2).toString(); 197 | //qDebug() << sNo << sName << pwd; 198 | username_Current = sNo; 199 | pwd_Current = ui->Login_password->text(); 200 | sName_Current = sName; 201 | isLoginSuccess = true; 202 | //qDebug() << "学生" + sName + "登录成功"; 203 | this->hide(); 204 | f = new studentForm; 205 | f->show(); 206 | } 207 | 208 | if(!isLoginSuccess) 209 | { 210 | QMessageBox::warning(this, "警告", "密码错误!"); 211 | loginFailTimes++; 212 | ui->Login_username->setFocus(); 213 | ui->loginFailTimes_Label->setVisible(true); 214 | ui->loginFailTimes_Label->setText(QString("登录失败次数:%0 次").arg(loginFailTimes)); 215 | } 216 | } 217 | 218 | if(loginFailTimes >= 3) 219 | { 220 | ui->captcha_Label->setVisible(true); 221 | ui->captcha_lineEdit->setVisible(true); 222 | ui->adminButton->move(133, 230); 223 | ui->studentButton->move(290, 230); 224 | ui->LoginButton->move(130, 280); 225 | ui->clearButton->move(290, 280); 226 | } 227 | 228 | if(loginFailTimes >= 5 && ui->studentButton->isChecked()) 229 | { 230 | QSqlDatabase db; 231 | connect_to_database(db); 232 | QSqlQuery query(db); 233 | 234 | QString username = ui->Login_username->text(); 235 | 236 | query.exec("update student set status = '冻结' where sId = '" + username + "'"); 237 | 238 | ui->LoginButton->setDisabled(true); 239 | ui->clearButton->setDisabled(true); 240 | 241 | QMessageBox::warning(this, "登录失败", "登录失败次数过多\n您的账户已被冻结!\n请联系管理员进行解冻"); 242 | 243 | } 244 | 245 | } 246 | 247 | void MainWindow::on_clearButton_clicked() 248 | { 249 | ui->Login_username->clear(); 250 | ui->Login_password->clear(); 251 | ui->captcha_lineEdit->clear(); 252 | } 253 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace Ui { 15 | class MainWindow; 16 | } 17 | 18 | class MainWindow : public QMainWindow 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit MainWindow(QWidget *parent = nullptr); 24 | ~MainWindow(); 25 | 26 | private slots: 27 | 28 | void on_LoginButton_clicked(); 29 | 30 | void on_clearButton_clicked(); 31 | 32 | void onTimeOut(); 33 | 34 | private: 35 | Ui::MainWindow *ui; 36 | manager *m; 37 | studentForm *f; 38 | QString captcha; 39 | Qt::GlobalColor *color; 40 | void paintEvent(QPaintEvent* evt); 41 | void mousePressEvent(QMouseEvent *evt); 42 | QString getCaptcha(); 43 | Qt::GlobalColor* getColor(); 44 | QTimer timer; 45 | int loginFailTimes; 46 | }; 47 | 48 | #endif // MAINWINDOW_H 49 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 500 10 | 345 11 | 12 | 13 | 14 | 厦门大学学生管理系统 15 | 16 | 17 | 18 | 19 | 20 | 120 21 | 20 22 | 261 23 | 31 24 | 25 | 26 | 27 | <h1>学生信息管理系统</h1> 28 | 29 | 30 | 0 31 | 32 | 33 | 34 | 35 | 36 | 120 37 | 250 38 | 75 39 | 23 40 | 41 | 42 | 43 | 登入 44 | 45 | 46 | 47 | 48 | 49 | 280 50 | 250 51 | 75 52 | 23 53 | 54 | 55 | 56 | 清空 57 | 58 | 59 | 60 | 61 | 62 | 130 63 | 190 64 | 72 65 | 15 66 | 67 | 68 | 69 | 验证码: 70 | 71 | 72 | 73 | 74 | 75 | 210 76 | 190 77 | 71 78 | 21 79 | 80 | 81 | 82 | 83 | 84 | 85 | 123 86 | 190 87 | 78 88 | 23 89 | 90 | 91 | 92 | 93 | Arial 94 | 10 95 | 50 96 | false 97 | 98 | 99 | 100 | 管理员 101 | 102 | 103 | 104 | 105 | 106 | 280 107 | 190 108 | 61 109 | 23 110 | 111 | 112 | 113 | 114 | Arial 115 | 10 116 | 50 117 | false 118 | 119 | 120 | 121 | 学生 122 | 123 | 124 | 125 | 126 | 127 | 209 128 | 88 129 | 171 130 | 21 131 | 132 | 133 | 134 | 135 | 136 | 137 | 131 138 | 88 139 | 51 140 | 19 141 | 142 | 143 | 144 | 145 | Arial 146 | 10 147 | 50 148 | false 149 | 150 | 151 | 152 | 账号: 153 | 154 | 155 | 156 | 157 | 158 | 131 159 | 133 160 | 51 161 | 19 162 | 163 | 164 | 165 | 166 | Arial 167 | 10 168 | 50 169 | false 170 | 171 | 172 | 173 | 密码: 174 | 175 | 176 | 177 | 178 | 179 | 209 180 | 133 181 | 171 182 | 23 183 | 184 | 185 | 186 | font: 6pt "Arial"; 187 | font: 9pt "Arial"; 188 | 189 | 190 | 191 | 192 | 193 | 0 194 | 320 195 | 141 196 | 16 197 | 198 | 199 | 200 | TextLabel 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | Login_password 210 | returnPressed() 211 | LoginButton 212 | click() 213 | 214 | 215 | 247 216 | 174 217 | 218 | 219 | 184 220 | 278 221 | 222 | 223 | 224 | 225 | Login_username 226 | returnPressed() 227 | LoginButton 228 | click() 229 | 230 | 231 | 335 232 | 136 233 | 234 | 235 | 137 236 | 284 237 | 238 | 239 | 240 | 241 | 242 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/manager.cpp: -------------------------------------------------------------------------------- 1 | #include "manager.h" 2 | #include "ui_manager.h" 3 | #include "global.h" 4 | #include "mainwindow.h" 5 | #include "stuinfomanage.h" 6 | #include "classinfomanage.h" 7 | #include "coursemanage.h" 8 | #include "selectcoursemanage.h" 9 | #include "grademanage.h" 10 | 11 | manager::manager(QWidget *parent) : 12 | QWidget(parent), 13 | ui(new Ui::manager) 14 | { 15 | ui->setupUi(this); 16 | QLabel *lab = ui->label_useradmin; 17 | lab->setStyleSheet("color:#ff0000"); 18 | lab->setText("当前管理员:" + username_Current); 19 | setWindowTitle("Design by 袁佳哲"); 20 | } 21 | 22 | manager::~manager() 23 | { 24 | delete ui; 25 | } 26 | 27 | void manager::on_pushButton_9_clicked() 28 | { 29 | this->hide(); 30 | MainWindow *mw = new MainWindow; 31 | mw->show(); 32 | } 33 | 34 | void manager::on_stu_inform_guanlipushButton_clicked() 35 | { 36 | this->hide(); 37 | stuinfomanage *sif = new stuinfomanage; 38 | sif->show(); 39 | } 40 | 41 | void manager::on_class_managepushButton_clicked() 42 | { 43 | this->hide(); 44 | classInfoManage *cim = new classInfoManage; 45 | cim->show(); 46 | } 47 | 48 | void manager::on_course_manageButton_clicked() 49 | { 50 | this->hide(); 51 | courseManage *cm = new courseManage; 52 | cm->show(); 53 | } 54 | 55 | void manager::on_selectCourse_manageButton_clicked() 56 | { 57 | selectCourseManage *scm = new selectCourseManage; 58 | this->hide(); 59 | scm->show(); 60 | } 61 | 62 | void manager::on_scoremanagepushButton_clicked() 63 | { 64 | gradeManage *gm = new gradeManage; 65 | this->hide(); 66 | gm->show(); 67 | } 68 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/manager.h: -------------------------------------------------------------------------------- 1 | #ifndef MANAGER_H 2 | #define MANAGER_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class manager; 8 | } 9 | 10 | class manager : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit manager(QWidget *parent = nullptr); 16 | ~manager(); 17 | 18 | private slots: 19 | void on_pushButton_9_clicked(); 20 | 21 | void on_stu_inform_guanlipushButton_clicked(); 22 | 23 | void on_class_managepushButton_clicked(); 24 | 25 | void on_course_manageButton_clicked(); 26 | 27 | void on_selectCourse_manageButton_clicked(); 28 | 29 | void on_scoremanagepushButton_clicked(); 30 | 31 | private: 32 | Ui::manager *ui; 33 | }; 34 | 35 | #endif // MANAGER_H 36 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/manager.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | manager 4 | 5 | 6 | 7 | 0 8 | 0 9 | 415 10 | 331 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 270 20 | 30 21 | 81 22 | 21 23 | 24 | 25 | 26 | 管理员端 27 | 28 | 29 | 30 | 31 | 32 | 66 33 | 70 34 | 301 35 | 20 36 | 37 | 38 | 39 | Qt::Horizontal 40 | 41 | 42 | 43 | 44 | 45 | 60 46 | 20 47 | 151 48 | 31 49 | 50 | 51 | 52 | TextLabel 53 | 54 | 55 | 56 | 57 | 58 | 70 59 | 90 60 | 261 61 | 201 62 | 63 | 64 | 65 | 66 | 67 | 68 | 学生信息管理 69 | 70 | 71 | 72 | 73 | 74 | 75 | 班级信息管理 76 | 77 | 78 | 79 | 80 | 81 | 82 | 课程信息管理 83 | 84 | 85 | 86 | 87 | 88 | 89 | 成绩信息管理 90 | 91 | 92 | 93 | 94 | 95 | 96 | 选课信息管理 97 | 98 | 99 | 100 | 101 | 102 | 103 | 返回登录界面 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/myclass.cpp: -------------------------------------------------------------------------------- 1 | #include "myclass.h" 2 | #include "ui_myclass.h" 3 | #include 4 | #include "studentform.h" 5 | #include "global.h" 6 | #include 7 | 8 | myclass::myclass(QWidget *parent) : 9 | QWidget(parent), 10 | ui(new Ui::myclass) 11 | { 12 | ui->setupUi(this); 13 | setWindowTitle(QString("Design by 袁佳哲")); 14 | 15 | QSqlDatabase db; 16 | connect_to_database(db); 17 | 18 | QString uid = username_Current; 19 | QString myClass = ""; 20 | QSqlQuery query(db); 21 | 22 | query.exec("select class from student where sId = "+ uid); 23 | 24 | if(query.next()) 25 | { 26 | myClass = query.value(0).toString(); 27 | } 28 | 29 | query.exec("select classId, className, major, sNum, master from class where classId = " + myClass); 30 | 31 | if(query.next()) 32 | { 33 | QString cId = query.value(0).toString(); 34 | QString cName = query.value(1).toString(); 35 | QString cMajor = query.value(2).toString(); 36 | QString cNum = query.value(3).toString(); 37 | QString cMaster = query.value(4).toString(); 38 | 39 | ui->classId_lineEdit->setText(cId); 40 | ui->className_lineEdit->setText(cName); 41 | ui->classMajor_lineEdit->setText(cMajor); 42 | ui->classNum_lineEdit->setText(cNum); 43 | ui->classMaster_lineEdit->setText(cMaster); 44 | } 45 | 46 | } 47 | 48 | myclass::~myclass() 49 | { 50 | delete ui; 51 | } 52 | 53 | void myclass::on_backButton_clicked() 54 | { 55 | this->hide(); 56 | studentForm * f2 = new studentForm; 57 | f2->show(); 58 | } 59 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/myclass.h: -------------------------------------------------------------------------------- 1 | #ifndef MYCLASS_H 2 | #define MYCLASS_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class myclass; 8 | } 9 | 10 | class myclass : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit myclass(QWidget *parent = nullptr); 16 | ~myclass(); 17 | 18 | private slots: 19 | void on_backButton_clicked(); 20 | 21 | private: 22 | Ui::myclass *ui; 23 | }; 24 | 25 | #endif // MYCLASS_H 26 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/myclass.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | myclass 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 60 20 | 70 21 | 91 22 | 16 23 | 24 | 25 | 26 | 您的班级: 27 | 28 | 29 | 30 | 31 | 32 | 270 33 | 60 34 | 91 35 | 23 36 | 37 | 38 | 39 | 返回主界面 40 | 41 | 42 | 43 | 44 | 45 | 60 46 | 110 47 | 255 48 | 135 49 | 50 | 51 | 52 | 53 | 54 | 55 | 班级编号: 56 | 57 | 58 | 59 | 60 | 61 | 62 | true 63 | 64 | 65 | 66 | 67 | 68 | 69 | 班级名称: 70 | 71 | 72 | 73 | 74 | 75 | 76 | true 77 | 78 | 79 | 80 | 81 | 82 | 83 | 系别专业: 84 | 85 | 86 | 87 | 88 | 89 | 90 | true 91 | 92 | 93 | 94 | 95 | 96 | 97 | 班级人数: 98 | 99 | 100 | 101 | 102 | 103 | 104 | true 105 | 106 | 107 | 108 | 109 | 110 | 111 | 班主任: 112 | 113 | 114 | 115 | 116 | 117 | 118 | true 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/mycourse.cpp: -------------------------------------------------------------------------------- 1 | #include "mycourse.h" 2 | #include "ui_mycourse.h" 3 | #include "studentform.h" 4 | #include "global.h" 5 | #include "searchcourse.h" 6 | #include "exporttable.h" 7 | 8 | mycourse::mycourse(QWidget *parent) : 9 | QWidget(parent), 10 | ui(new Ui::mycourse) 11 | { 12 | ui->setupUi(this); 13 | QString sId = username_Current; 14 | 15 | QSqlDatabase db; 16 | connect_to_database(db); 17 | 18 | QSqlQuery query(db); 19 | 20 | QStringList myCourseIdList; 21 | 22 | query.exec("select cId from student_course where sId = '" + sId + "'"); 23 | 24 | while(query.next()) 25 | { 26 | QString getCId = query.value(0).toString(); 27 | 28 | //qDebug() << getCId; 29 | 30 | myCourseIdList << getCId; 31 | } 32 | 33 | QVariantList myCourseList; 34 | 35 | for(auto i : myCourseIdList) 36 | { 37 | // qDebug() << i; 38 | query.exec("select cId, object, teacher, time, location, period, credit from course where cId = '" + i + "'"); 39 | while(query.next()) 40 | { 41 | QString courseId = query.value(0).toString(); 42 | QString object = query.value(1).toString(); 43 | QString teacher = query.value(2).toString(); 44 | QString time = query.value(3).toString(); 45 | QString location = query.value(4).toString(); 46 | QString period = query.value(5).toString(); 47 | QString credit = query.value(6).toString(); 48 | QStringList q; 49 | q << courseId << object << teacher << time << location << period << credit; 50 | myCourseList.append(q); 51 | } 52 | } 53 | 54 | for(auto i : myCourseList) 55 | { 56 | int rowCount = ui->myCourseTable->rowCount(); 57 | 58 | ui->myCourseTable->insertRow(rowCount); 59 | 60 | QStringList rowData = i.toStringList(); 61 | 62 | for (int j = 0; j < rowData.size(); j++) 63 | { 64 | QTableWidgetItem *item = new QTableWidgetItem; 65 | item->setText(rowData.at(j)); 66 | ui->myCourseTable->setItem(rowCount, j, item); 67 | } 68 | } 69 | 70 | int columnCount = ui->myCourseTable->columnCount(); 71 | int rowCount = ui->myCourseTable->rowCount(); 72 | 73 | for(int i = 0; i myCourseTable->item(j, i)->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter); 78 | } 79 | } 80 | 81 | 82 | } 83 | 84 | mycourse::~mycourse() 85 | { 86 | delete ui; 87 | } 88 | 89 | void mycourse::on_pushButton_2_clicked() 90 | { 91 | this->hide(); 92 | studentForm *f1 = new studentForm; 93 | f1->show(); 94 | } 95 | 96 | void mycourse::on_searchButton_clicked() 97 | { 98 | this->hide(); 99 | searchCourse *sc = new searchCourse; 100 | sc->show(); 101 | } 102 | 103 | void mycourse::on_export_button_clicked() 104 | { 105 | Table2Excel(ui->myCourseTable, "我的课程信息"); 106 | } 107 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/mycourse.h: -------------------------------------------------------------------------------- 1 | #ifndef MYCOURSE_H 2 | #define MYCOURSE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class mycourse; 8 | } 9 | 10 | class mycourse : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit mycourse(QWidget *parent = nullptr); 16 | ~mycourse(); 17 | 18 | private slots: 19 | void on_pushButton_2_clicked(); 20 | 21 | void on_searchButton_clicked(); 22 | 23 | void on_export_button_clicked(); 24 | 25 | private: 26 | Ui::mycourse *ui; 27 | }; 28 | 29 | #endif // MYCOURSE_H 30 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/mycourse.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | mycourse 4 | 5 | 6 | 7 | 0 8 | 0 9 | 956 10 | 442 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 450 20 | 10 21 | 101 22 | 31 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 课程查询 35 | 36 | 37 | 38 | 39 | 40 | 30 41 | 130 42 | 881 43 | 281 44 | 45 | 46 | 47 | 48 | 课程号 49 | 50 | 51 | 52 | 53 | 课程名 54 | 55 | 56 | 57 | 58 | 授课教师 59 | 60 | 61 | 62 | 63 | 开课学期 64 | 65 | 66 | 67 | 68 | 上课教室 69 | 70 | 71 | 72 | 73 | 上课时间 74 | 75 | 76 | 77 | 78 | 学分数 79 | 80 | 81 | 82 | 83 | 84 | 85 | 40 86 | 100 87 | 72 88 | 15 89 | 90 | 91 | 92 | 我的课程: 93 | 94 | 95 | 96 | 97 | 98 | 610 99 | 80 100 | 302 101 | 30 102 | 103 | 104 | 105 | 106 | 107 | 108 | 查询其他课程 109 | 110 | 111 | 112 | 113 | 114 | 115 | 导出为Excel 116 | 117 | 118 | 119 | 120 | 121 | 122 | 返回主界面 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/myinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "myinfo.h" 2 | #include "ui_myinfo.h" 3 | #include "global.h" 4 | #include "studentform.h" 5 | #include "resetpwd.h" 6 | 7 | myInfo::myInfo(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::myInfo) 10 | { 11 | ui->setupUi(this); 12 | 13 | QString sId = username_Current; 14 | 15 | QSqlDatabase db; 16 | connect_to_database(db); 17 | 18 | QSqlQuery query(db); 19 | 20 | query.exec("select sId,name,sex,age,major,class,address,phonenumber from student where sId = '" + sId + "'"); 21 | 22 | while(query.next()) 23 | { 24 | ui->sNo_lineEdit->setText(query.value(0).toString()); 25 | QString name = query.value(1).toString(); 26 | QString sex = query.value(2).toString(); 27 | QString age = query.value(3).toString(); 28 | QString major = query.value(4).toString(); 29 | QString Class = query.value(5).toString(); 30 | QString address = query.value(6).toString(); 31 | QString phone = query.value(7).toString(); 32 | 33 | ui->name_lineEdit->setText(name); 34 | ui->sex_lineEdit->setText(sex); 35 | ui->age_lineEdit->setText(age); 36 | ui->major_lineEdit->setText(major); 37 | ui->address_lineEdit->setText(address); 38 | ui->phone_lineEdit->setText(phone); 39 | } 40 | } 41 | 42 | myInfo::~myInfo() 43 | { 44 | delete ui; 45 | } 46 | 47 | void myInfo::on_back_button_clicked() 48 | { 49 | this->hide(); 50 | studentForm *sf = new studentForm; 51 | sf->show(); 52 | } 53 | 54 | void myInfo::on_resetPwd_button_clicked() 55 | { 56 | this->hide(); 57 | resetPwd *rp = new resetPwd; 58 | rp->show(); 59 | } 60 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/myinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef MYINFO_H 2 | #define MYINFO_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class myInfo; 8 | } 9 | 10 | class myInfo : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit myInfo(QWidget *parent = nullptr); 16 | ~myInfo(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | void on_resetPwd_button_clicked(); 22 | 23 | private: 24 | Ui::myInfo *ui; 25 | }; 26 | 27 | #endif // MYINFO_H 28 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/myinfo.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | myInfo 4 | 5 | 6 | 7 | 0 8 | 0 9 | 491 10 | 445 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 150 20 | 10 21 | 171 22 | 51 23 | 24 | 25 | 26 | 27 | Arial Black 28 | 15 29 | 75 30 | true 31 | 32 | 33 | 34 | 我的个人信息 35 | 36 | 37 | 38 | 39 | 40 | 100 41 | 390 42 | 111 43 | 28 44 | 45 | 46 | 47 | 修改个人密码 48 | 49 | 50 | 51 | 52 | 53 | 260 54 | 390 55 | 93 56 | 28 57 | 58 | 59 | 60 | 返回 61 | 62 | 63 | 64 | 65 | 66 | 100 67 | 80 68 | 271 69 | 281 70 | 71 | 72 | 73 | 74 | 75 | 76 | 学号 77 | 78 | 79 | 80 | 81 | 82 | 83 | true 84 | 85 | 86 | 87 | 88 | 89 | 90 | 姓名 91 | 92 | 93 | 94 | 95 | 96 | 97 | true 98 | 99 | 100 | 101 | 102 | 103 | 104 | 性别 105 | 106 | 107 | 108 | 109 | 110 | 111 | true 112 | 113 | 114 | 115 | 116 | 117 | 118 | 年龄 119 | 120 | 121 | 122 | 123 | 124 | 125 | true 126 | 127 | 128 | 129 | 130 | 131 | 132 | 专业 133 | 134 | 135 | 136 | 137 | 138 | 139 | true 140 | 141 | 142 | 143 | 144 | 145 | 146 | 籍贯 147 | 148 | 149 | 150 | 151 | 152 | 153 | true 154 | 155 | 156 | 157 | 158 | 159 | 160 | 联系方式 161 | 162 | 163 | 164 | 165 | 166 | 167 | true 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/myscore.cpp: -------------------------------------------------------------------------------- 1 | #include "myscore.h" 2 | #include "ui_myscore.h" 3 | #include "global.h" 4 | #include "studentform.h" 5 | 6 | 7 | myScore::myScore(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::myScore) 10 | { 11 | ui->setupUi(this); 12 | ui->sNo_lineEdit->setText(QString(username_Current)); 13 | ui->sNo_lineEdit->setReadOnly(true); 14 | ui->Grade_lineEdit->setReadOnly(true); 15 | ui->classTime_box->addItem("大一上"); 16 | ui->classTime_box->addItem("大一下"); 17 | ui->classTime_box->addItem("大二上"); 18 | ui->classTime_box->addItem("大二下"); 19 | } 20 | 21 | myScore::~myScore() 22 | { 23 | delete ui; 24 | } 25 | 26 | void myScore::on_pushButton_findcore_back_clicked() 27 | { 28 | this->hide(); 29 | studentForm *f1 = new studentForm; 30 | f1->show(); 31 | } 32 | 33 | void myScore::on_findscoreButton_clicked() 34 | { 35 | QString classTime = ui->classTime_box->currentText(); 36 | QString sId = ui->sNo_lineEdit->text(); 37 | QString className = ui->className_Edit->text(); 38 | QString teacher = ui->teacher_lineEdit->text(); 39 | 40 | QSqlDatabase db; 41 | connect_to_database(db); 42 | 43 | QSqlQuery query(db); 44 | 45 | query.exec("select cId from course where object like '%" + className 46 | + "%' and time = '" + classTime + "' and teacher = '" + teacher + "'"); 47 | if(query.next()) 48 | { 49 | QString cId = query.value(0).toString(); 50 | //qDebug() << cId; 51 | 52 | query.exec("select score from score where sid = '" + sId + "' and cid = '" + cId + "'"); 53 | if(query.next()) 54 | { 55 | QString mygrade = query.value(0).toString(); 56 | ui->Grade_lineEdit->setText(mygrade); 57 | } 58 | else { 59 | QMessageBox::warning(this, "无查询结果", "你的该课程没有成绩!"); 60 | ui->Grade_lineEdit->clear(); 61 | } 62 | } 63 | else 64 | { 65 | QMessageBox::warning(this, "无查询结果", "该课程不存在!"); 66 | ui->Grade_lineEdit->clear(); 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/myscore.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSCORE_H 2 | #define MYSCORE_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class myScore; 9 | } 10 | 11 | class myScore : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit myScore(QWidget *parent = nullptr); 17 | ~myScore(); 18 | 19 | private slots: 20 | void on_pushButton_findcore_back_clicked(); 21 | 22 | void on_findscoreButton_clicked(); 23 | 24 | private: 25 | Ui::myScore *ui; 26 | }; 27 | 28 | #endif // MYSCORE_H 29 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/myscore.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | myScore 4 | 5 | 6 | 7 | 0 8 | 0 9 | 392 10 | 334 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 150 20 | 20 21 | 101 22 | 20 23 | 24 | 25 | 26 | font: 14pt "Arial"; 27 | 28 | 29 | 成绩查询 30 | 31 | 32 | 33 | 34 | 35 | 60 36 | 290 37 | 75 38 | 23 39 | 40 | 41 | 42 | font: 9pt "Arial"; 43 | 44 | 45 | 查询 46 | 47 | 48 | 49 | 50 | 51 | 220 52 | 290 53 | 101 54 | 23 55 | 56 | 57 | 58 | font: 9pt "Arial"; 59 | 60 | 61 | 返回主界面 62 | 63 | 64 | 65 | 66 | 67 | 60 68 | 60 69 | 259 70 | 162 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 学号 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 课程名 91 | 92 | 93 | 94 | 95 | 96 | 97 | 开课学期 98 | 99 | 100 | 101 | 102 | 103 | 104 | 授课教师 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 130 120 | 240 121 | 190 122 | 21 123 | 124 | 125 | 126 | 127 | 128 | 129 | 63 130 | 240 131 | 60 132 | 21 133 | 134 | 135 | 136 | 成绩 137 | 138 | 139 | 140 | 141 | 142 | 60 143 | 220 144 | 261 145 | 16 146 | 147 | 148 | 149 | Qt::Horizontal 150 | 151 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/resetpwd.cpp: -------------------------------------------------------------------------------- 1 | #include "resetpwd.h" 2 | #include "ui_resetpwd.h" 3 | #include "global.h" 4 | #include "myinfo.h" 5 | #include 6 | #include "mainwindow.h" 7 | #include 8 | 9 | resetPwd::resetPwd(QWidget *parent) : 10 | QWidget(parent), 11 | ui(new Ui::resetPwd) 12 | { 13 | ui->setupUi(this); 14 | ui->submit_button->setDisabled(true); 15 | ui->error_label->clear(); 16 | ui->error_label->setStyleSheet("color:#ff0000"); 17 | } 18 | 19 | resetPwd::~resetPwd() 20 | { 21 | delete ui; 22 | } 23 | 24 | 25 | void resetPwd::on_back_button_clicked() 26 | { 27 | this->hide(); 28 | myInfo *mf = new myInfo; 29 | mf->show(); 30 | } 31 | 32 | void resetPwd::on_oldPwd_lineEdit_textChanged(const QString &arg1) 33 | { 34 | QString oldPwd = arg1; 35 | 36 | if(oldPwd.compare(pwd_Current) != 0) 37 | { 38 | ui->error_label->setText("原密码输入错误!"); 39 | ui->submit_button->setDisabled(true); 40 | } 41 | else { 42 | ui->error_label->clear(); 43 | } 44 | } 45 | 46 | void resetPwd::on_newPwd_lineEdit_textChanged(const QString &arg1) 47 | { 48 | QString newPwd = arg1; 49 | //qDebug() << arg1 << pwd_Current; 50 | if(newPwd.compare(pwd_Current) == 0) 51 | { 52 | ui->error_label->setText("不可与原密码一致!"); 53 | ui->submit_button->setDisabled(true); 54 | } 55 | else { 56 | ui->error_label->clear(); 57 | } 58 | } 59 | 60 | void resetPwd::on_repeatPwd_lineEdit_textChanged(const QString &arg1) 61 | { 62 | QString repeatedPwd = arg1; 63 | QString newPwd = ui->newPwd_lineEdit->text(); 64 | if(repeatedPwd.compare(newPwd) != 0) 65 | { 66 | ui->error_label->setText("两次密码输入不一致!"); 67 | ui->submit_button->setDisabled(true); 68 | 69 | } 70 | else { 71 | ui->error_label->clear(); 72 | ui->submit_button->setDisabled(false); 73 | } 74 | } 75 | 76 | void resetPwd::on_submit_button_clicked() 77 | { 78 | QMessageBox::StandardButton btn; 79 | btn = QMessageBox::question(this, "确认提交", "确定要修改个人密码吗?", QMessageBox::Yes|QMessageBox::No); 80 | if(btn == QMessageBox::Yes) 81 | { 82 | QSqlDatabase db; 83 | connect_to_database(db); 84 | 85 | QSqlQuery query(db); 86 | 87 | QString sId = username_Current; 88 | //QString newPwd = ui->newPwd_lineEdit->text(); 89 | QString newPwd = QCryptographicHash::hash(ui->newPwd_lineEdit->text().toLatin1(), QCryptographicHash::Md5).toHex(); 90 | 91 | bool isResetPwdSuccess = query.exec("update student set password = '" + newPwd + "' where sId = '" + sId + "'"); 92 | 93 | if(isResetPwdSuccess) 94 | { 95 | QMessageBox::information(this, "提示", "修改成功!请重新登录!", QMessageBox::Yes); 96 | this->hide(); 97 | MainWindow *mw = new MainWindow; 98 | mw->show(); 99 | } 100 | else { 101 | QMessageBox::warning(this, "修改失败", "请检查密码格式!"); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/resetpwd.h: -------------------------------------------------------------------------------- 1 | #ifndef RESETPWD_H 2 | #define RESETPWD_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class resetPwd; 8 | } 9 | 10 | class resetPwd : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit resetPwd(QWidget *parent = nullptr); 16 | ~resetPwd(); 17 | 18 | private slots: 19 | void on_back_button_clicked(); 20 | 21 | void on_oldPwd_lineEdit_textChanged(const QString &arg1); 22 | 23 | void on_newPwd_lineEdit_textChanged(const QString &arg1); 24 | 25 | void on_repeatPwd_lineEdit_textChanged(const QString &arg1); 26 | 27 | void on_submit_button_clicked(); 28 | 29 | private: 30 | Ui::resetPwd *ui; 31 | }; 32 | 33 | #endif // RESETPWD_H 34 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/resetpwd.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | resetPwd 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 110 20 | 20 21 | 151 22 | 41 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 修改个人密码 35 | 36 | 37 | 38 | 39 | 40 | 70 41 | 60 42 | 251 43 | 16 44 | 45 | 46 | 47 | Qt::Horizontal 48 | 49 | 50 | 51 | 52 | 53 | 90 54 | 240 55 | 71 56 | 28 57 | 58 | 59 | 60 | 提交 61 | 62 | 63 | 64 | 65 | 66 | 230 67 | 240 68 | 71 69 | 28 70 | 71 | 72 | 73 | 返回 74 | 75 | 76 | 77 | 78 | 79 | 60 80 | 210 81 | 271 82 | 16 83 | 84 | 85 | 86 | TextLabel 87 | 88 | 89 | 90 | 91 | 92 | 60 93 | 100 94 | 271 95 | 101 96 | 97 | 98 | 99 | 100 | 101 | 102 | 原密码 103 | 104 | 105 | 106 | 107 | 108 | 109 | QLineEdit::Password 110 | 111 | 112 | 113 | 114 | 115 | 116 | 新密码 117 | 118 | 119 | 120 | 121 | 122 | 123 | QLineEdit::Password 124 | 125 | 126 | 127 | 128 | 129 | 130 | 重复密码 131 | 132 | 133 | 134 | 135 | 136 | 137 | QLineEdit::Password 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/searchcourse.cpp: -------------------------------------------------------------------------------- 1 | #include "searchcourse.h" 2 | #include "ui_searchcourse.h" 3 | #include "global.h" 4 | #include "mycourse.h" 5 | #include 6 | 7 | searchCourse::searchCourse(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::searchCourse) 10 | { 11 | ui->setupUi(this); 12 | 13 | setWindowTitle("Design by 袁佳哲"); 14 | 15 | ui->classTimeBox->addItem("大一上"); 16 | ui->classTimeBox->addItem("大一下"); 17 | ui->classTimeBox->addItem("大二上"); 18 | ui->classTimeBox->addItem("大二下"); 19 | } 20 | 21 | searchCourse::~searchCourse() 22 | { 23 | delete ui; 24 | } 25 | 26 | void searchCourse::on_backButton_clicked() 27 | { 28 | this->hide(); 29 | mycourse *mc = new mycourse; 30 | mc->show(); 31 | } 32 | 33 | void searchCourse::on_clearButton_clicked() 34 | { 35 | ui->courName_lineEdit->clear(); 36 | ui->courseName_lineEdit->clear(); 37 | ui->teacher_lineEdit->clear(); 38 | ui->classTimeBox->setCurrentIndex(0); 39 | ui->courseID_lineEdit->clear(); 40 | ui->location_lineEdit->clear(); 41 | ui->credit_lineEdit->clear(); 42 | ui->period_lineEdit->clear(); 43 | } 44 | 45 | void searchCourse::on_searchButton_clicked() 46 | { 47 | 48 | QString courseName = ui->courName_lineEdit->text(); 49 | QString teacher = ui->teacher_lineEdit->text(); 50 | QString courseTime = ui->classTimeBox->currentText(); 51 | 52 | if(courseName.isEmpty() || teacher.isEmpty() || courseName.isEmpty()) 53 | { 54 | QMessageBox::warning(this, "输入出错", "查找信息不能留空!"); 55 | return; 56 | } 57 | 58 | 59 | QSqlDatabase db; 60 | connect_to_database(db); 61 | 62 | QSqlQuery query(db); 63 | 64 | query.exec("select cId,location,period,credit,object from course where object like " 65 | "'%" + courseName + "%' and teacher='" + teacher + "' and time='" + courseTime + "'"); 66 | 67 | if(query.next()) 68 | { 69 | QString courseId = query.value(0).toString(); 70 | QString location = query.value(1).toString(); 71 | QString period = query.value(2).toString(); 72 | QString credit = query.value(3).toString(); 73 | QString courseName = query.value(4).toString(); 74 | 75 | ui->courseID_lineEdit->setText(courseId); 76 | ui->courseName_lineEdit->setText(courseName); 77 | ui->location_lineEdit->setText(location); 78 | ui->period_lineEdit->setText(period); 79 | ui->credit_lineEdit->setText(credit); 80 | } 81 | else 82 | { 83 | QMessageBox::warning(this, "查询无果", "不存在对应教学班!"); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/searchcourse.h: -------------------------------------------------------------------------------- 1 | #ifndef SEARCHCOURSE_H 2 | #define SEARCHCOURSE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class searchCourse; 8 | } 9 | 10 | class searchCourse : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit searchCourse(QWidget *parent = nullptr); 16 | ~searchCourse(); 17 | 18 | private slots: 19 | void on_backButton_clicked(); 20 | 21 | void on_clearButton_clicked(); 22 | 23 | void on_searchButton_clicked(); 24 | 25 | private: 26 | Ui::searchCourse *ui; 27 | }; 28 | 29 | #endif // SEARCHCOURSE_H 30 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/searchcourse.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | searchCourse 4 | 5 | 6 | 7 | 0 8 | 0 9 | 548 10 | 467 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 230 20 | 40 21 | 72 22 | 15 23 | 24 | 25 | 26 | 查询课程: 27 | 28 | 29 | 30 | 31 | 32 | 140 33 | 70 34 | 241 35 | 16 36 | 37 | 38 | 39 | 请输入课程名、授课教师、开课学期 40 | 41 | 42 | 43 | 44 | 45 | 110 46 | 260 47 | 72 48 | 15 49 | 50 | 51 | 52 | 查询结果: 53 | 54 | 55 | 56 | 57 | 58 | 60 59 | 110 60 | 252 61 | 101 62 | 63 | 64 | 65 | 66 | 67 | 68 | 授课教师 69 | 70 | 71 | 72 | 73 | 74 | 75 | 课程名 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 开课学期 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 360 101 | 110 102 | 141 103 | 100 104 | 105 | 106 | 107 | 108 | 109 | 110 | 查询 111 | 112 | 113 | 114 | 115 | 116 | 117 | 重置 118 | 119 | 120 | 121 | 122 | 123 | 124 | 返回“我的课程” 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 110 134 | 290 135 | 240 136 | 135 137 | 138 | 139 | 140 | 141 | 142 | 143 | 课程号 144 | 145 | 146 | 147 | 148 | 149 | 150 | true 151 | 152 | 153 | 154 | 155 | 156 | 157 | 上课时间 158 | 159 | 160 | 161 | 162 | 163 | 164 | true 165 | 166 | 167 | 168 | 169 | 170 | 171 | 上课地点 172 | 173 | 174 | 175 | 176 | 177 | 178 | true 179 | 180 | 181 | 182 | 183 | 184 | 185 | 学分数 186 | 187 | 188 | 189 | 190 | 191 | 192 | true 193 | 194 | 195 | 196 | 197 | 198 | 199 | true 200 | 201 | 202 | 203 | 204 | 205 | 206 | 课程名 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 60 216 | 240 217 | 451 218 | 16 219 | 220 | 221 | 222 | Qt::Horizontal 223 | 224 | 225 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/selectcoursemanage.h: -------------------------------------------------------------------------------- 1 | #ifndef SELECTCOURSEMANAGE_H 2 | #define SELECTCOURSEMANAGE_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class selectCourseManage; 9 | } 10 | 11 | class selectCourseManage : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit selectCourseManage(QWidget *parent = nullptr); 17 | ~selectCourseManage(); 18 | 19 | private slots: 20 | void on_back_button_clicked(); 21 | 22 | void on_searchBySNo_button_clicked(); 23 | 24 | void on_listAll_button_clicked(); 25 | 26 | void on_searchByCId_button_clicked(); 27 | 28 | void on_add_button_clicked(); 29 | 30 | //void on_tableWidget_itemClicked(QTableWidgetItem *item); 31 | 32 | //void on_tableWidget_clicked(const QModelIndex &index); 33 | 34 | void on_tableWidget_cellClicked(int row, int column); 35 | 36 | //void on_updata_button_clicked(); 37 | 38 | void on_delete_button_clicked(); 39 | 40 | void on_export_button_clicked(); 41 | 42 | private: 43 | Ui::selectCourseManage *ui; 44 | void updateTable(); 45 | }; 46 | 47 | #endif // SELECTCOURSEMANAGE_H 48 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/selectcoursemanage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | selectCourseManage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 603 10 | 540 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 120 20 | 10 21 | 151 22 | 41 23 | 24 | 25 | 26 | 27 | Arial 28 | 14 29 | 75 30 | true 31 | 32 | 33 | 34 | 选课信息管理 35 | 36 | 37 | 38 | 39 | 40 | 20 41 | 100 42 | 311 43 | 411 44 | 45 | 46 | 47 | 48 | 学号 49 | 50 | 51 | 52 | 53 | 课程号 54 | 55 | 56 | 57 | 58 | 59 | 60 | 20 61 | 80 62 | 121 63 | 16 64 | 65 | 66 | 67 | 68 | Arial 69 | 10 70 | 75 71 | true 72 | 73 | 74 | 75 | 选课信息 76 | 77 | 78 | 79 | 80 | 81 | 350 82 | 110 83 | 211 84 | 81 85 | 86 | 87 | 88 | 89 | 90 | 91 | 学号 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 课程号 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 390 114 | 220 115 | 131 116 | 215 117 | 118 | 119 | 120 | 121 | 122 | 123 | 添加选课信息 124 | 125 | 126 | 127 | 128 | 129 | 130 | Qt::Horizontal 131 | 132 | 133 | 134 | 135 | 136 | 137 | 根据学号查询 138 | 139 | 140 | 141 | 142 | 143 | 144 | 删除选择信息 145 | 146 | 147 | 148 | 149 | 150 | 151 | 显示所有选课信息 152 | 153 | 154 | 155 | 156 | 157 | 158 | 根据课程号查询 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 350 168 | 90 169 | 72 170 | 15 171 | 172 | 173 | 174 | 当前选中: 175 | 176 | 177 | 178 | 179 | 180 | 360 181 | 460 182 | 196 183 | 30 184 | 185 | 186 | 187 | 188 | 189 | 190 | 导出为Excel 191 | 192 | 193 | 194 | 195 | 196 | 197 | 返回 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/studentManager.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2021-07-20T16:37:39 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | QT += sql 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 11 | 12 | TARGET = studentManager 13 | TEMPLATE = app 14 | 15 | # The following define makes your compiler emit warnings if you use 16 | # any feature of Qt which has been marked as deprecated (the exact warnings 17 | # depend on your compiler). Please consult the documentation of the 18 | # deprecated API in order to know how to port your code away from it. 19 | DEFINES += QT_DEPRECATED_WARNINGS 20 | 21 | # You can also make your code fail to compile if you use deprecated APIs. 22 | # In order to do so, uncomment the following line. 23 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 24 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 25 | 26 | CONFIG += c++11 27 | CONFIG += qaxcontainer 28 | 29 | SOURCES += \ 30 | main.cpp \ 31 | mainwindow.cpp \ 32 | global.cpp \ 33 | manager.cpp \ 34 | studentform.cpp \ 35 | all_stu_info.cpp \ 36 | myclass.cpp \ 37 | myscore.cpp \ 38 | mycourse.cpp \ 39 | searchcourse.cpp \ 40 | stuinfomanage.cpp \ 41 | addstuinfo.cpp \ 42 | myinfo.cpp \ 43 | resetpwd.cpp \ 44 | classinfomanage.cpp \ 45 | allclassinfo.cpp \ 46 | addclass.cpp \ 47 | coursemanage.cpp \ 48 | allcourseinfo.cpp \ 49 | addnewcourse.cpp \ 50 | selectcoursemanage.cpp \ 51 | grademanage.cpp \ 52 | addnewgrade.cpp \ 53 | gradestaticsbystu.cpp \ 54 | gradestaticsbycourse.cpp \ 55 | exporttable.cpp 56 | 57 | HEADERS += \ 58 | mainwindow.h \ 59 | global.h \ 60 | manager.h \ 61 | studentform.h \ 62 | all_stu_info.h \ 63 | myclass.h \ 64 | myscore.h \ 65 | mycourse.h \ 66 | searchcourse.h \ 67 | stuinfomanage.h \ 68 | addstuinfo.h \ 69 | myinfo.h \ 70 | resetpwd.h \ 71 | classinfomanage.h \ 72 | allclassinfo.h \ 73 | addclass.h \ 74 | coursemanage.h \ 75 | allcourseinfo.h \ 76 | addnewcourse.h \ 77 | selectcoursemanage.h \ 78 | grademanage.h \ 79 | addnewgrade.h \ 80 | gradestaticsbystu.h \ 81 | gradestaticsbycourse.h \ 82 | exporttable.h 83 | 84 | FORMS += \ 85 | mainwindow.ui \ 86 | manager.ui \ 87 | studentform.ui \ 88 | all_stu_info.ui \ 89 | myclass.ui \ 90 | myscore.ui \ 91 | mycourse.ui \ 92 | searchcourse.ui \ 93 | stuinfomanage.ui \ 94 | addstuinfo.ui \ 95 | myinfo.ui \ 96 | resetpwd.ui \ 97 | classinfomanage.ui \ 98 | allclassinfo.ui \ 99 | addclass.ui \ 100 | coursemanage.ui \ 101 | allcourseinfo.ui \ 102 | addnewcourse.ui \ 103 | selectcoursemanage.ui \ 104 | grademanage.ui \ 105 | addnewgrade.ui \ 106 | gradestaticsbystu.ui \ 107 | gradestaticsbycourse.ui 108 | 109 | # Default rules for deployment. 110 | qnx: target.path = /tmp/$${TARGET}/bin 111 | else: unix:!android: target.path = /opt/$${TARGET}/bin 112 | !isEmpty(target.path): INSTALLS += target 113 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/studentform.cpp: -------------------------------------------------------------------------------- 1 | #include "studentform.h" 2 | #include "ui_studentform.h" 3 | #include "global.h" 4 | #include "mainwindow.h" 5 | #include "myinfo.h" 6 | #include "myclass.h" 7 | #include "myscore.h" 8 | #include "mycourse.h" 9 | 10 | studentForm::studentForm(QWidget *parent) : 11 | QWidget(parent), 12 | ui(new Ui::studentForm) 13 | { 14 | ui->setupUi(this); 15 | QLabel *lab = ui->label_user; 16 | lab->setStyleSheet("color:#0022ff"); 17 | lab->setText("当前用户:" + sName_Current); 18 | setWindowTitle(QString("Design by 袁佳哲")); 19 | } 20 | 21 | studentForm::~studentForm() 22 | { 23 | delete ui; 24 | } 25 | 26 | void studentForm::on_pushButton_clicked() 27 | { 28 | MainWindow * main; 29 | this->hide(); 30 | main = new MainWindow; 31 | main->show(); 32 | } 33 | 34 | void studentForm::on_pushButton_3_clicked() 35 | { 36 | this->hide(); 37 | myInfo *mf = new myInfo; 38 | mf->show(); 39 | } 40 | 41 | void studentForm::on_stu_findclass_inforButton_clicked() 42 | { 43 | this->hide(); 44 | myclass * myClass = new myclass; 45 | myClass->show(); 46 | 47 | } 48 | 49 | void studentForm::on_pushButton_student_findscore_clicked() 50 | { 51 | this->hide(); 52 | myScore * myscore = new myScore; 53 | myscore->show(); 54 | 55 | } 56 | 57 | void studentForm::on_stu_find_coursebutton_clicked() 58 | { 59 | this->hide(); 60 | mycourse * myCourese = new mycourse; 61 | myCourese->show(); 62 | } 63 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/studentform.h: -------------------------------------------------------------------------------- 1 | #ifndef STUDENTFORM_H 2 | #define STUDENTFORM_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class studentForm; 8 | } 9 | 10 | class studentForm : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit studentForm(QWidget *parent = nullptr); 16 | ~studentForm(); 17 | 18 | private slots: 19 | void on_pushButton_clicked(); 20 | 21 | void on_pushButton_3_clicked(); 22 | 23 | void on_stu_findclass_inforButton_clicked(); 24 | 25 | void on_pushButton_student_findscore_clicked(); 26 | 27 | void on_stu_find_coursebutton_clicked(); 28 | 29 | private: 30 | Ui::studentForm *ui; 31 | }; 32 | 33 | #endif // STUDENTFORM_H 34 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/studentform.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | studentForm 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 140 20 | 230 21 | 101 22 | 23 23 | 24 | 25 | 26 | 返回登录界面 27 | 28 | 29 | 30 | 31 | 32 | 250 33 | 30 34 | 121 35 | 21 36 | 37 | 38 | 39 | 学生端 40 | 41 | 42 | 43 | 44 | 45 | 40 46 | 50 47 | 311 48 | 20 49 | 50 | 51 | 52 | Qt::Horizontal 53 | 54 | 55 | 56 | 57 | 58 | 30 59 | 30 60 | 191 61 | 20 62 | 63 | 64 | 65 | TextLabel 66 | 67 | 68 | 69 | 70 | 71 | 60 72 | 120 73 | 267 74 | 65 75 | 76 | 77 | 78 | 79 | 80 | 81 | 查看个人基本信息 82 | 83 | 84 | false 85 | 86 | 87 | 88 | 89 | 90 | 91 | 班级基本情况 92 | 93 | 94 | 95 | 96 | 97 | 98 | 成绩查询 99 | 100 | 101 | 102 | 103 | 104 | 105 | 课程查询 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/stuinfomanage.cpp: -------------------------------------------------------------------------------- 1 | #include "stuinfomanage.h" 2 | #include "ui_stuinfomanage.h" 3 | #include "global.h" 4 | #include "manager.h" 5 | #include 6 | #include "addstuinfo.h" 7 | #include "all_stu_info.h" 8 | #include 9 | 10 | stuinfomanage::stuinfomanage(QWidget *parent) : 11 | QWidget(parent), 12 | ui(new Ui::stuinfomanage) 13 | { 14 | ui->setupUi(this); 15 | ui->update_button->setDisabled(true); 16 | ui->delete_button->setDisabled(true); 17 | ui->reset_button->setDisabled(true); 18 | 19 | ui->sexBox->addItem("男"); 20 | ui->sexBox->addItem("女"); 21 | ui->statusBox->addItem("正常"); 22 | ui->statusBox->addItem("冻结"); 23 | 24 | } 25 | 26 | stuinfomanage::~stuinfomanage() 27 | { 28 | delete ui; 29 | } 30 | 31 | void stuinfomanage::on_pushButton_7_clicked() 32 | { 33 | manager *ma = new manager; 34 | this->hide(); 35 | ma->show(); 36 | } 37 | 38 | void stuinfomanage::on_pushButton_clicked() 39 | { 40 | QString sNo = ui->sNo_lineEdit->text(); 41 | 42 | if(sNo.isEmpty()) 43 | { 44 | ui->update_button->setDisabled(true); 45 | ui->delete_button->setDisabled(true); 46 | ui->reset_button->setDisabled(true); 47 | 48 | ui->sName_lineEdit->clear(); 49 | ui->sexBox->setCurrentIndex(0); 50 | ui->age_lineEdit->clear(); 51 | ui->major_lineEdit->clear(); 52 | ui->classId_lineEdit->clear(); 53 | ui->address_lineEdit->clear(); 54 | ui->phone_lineEdit->clear(); 55 | ui->statusBox->setCurrentIndex(0); 56 | 57 | QMessageBox::warning(this, "输入错误", "学号信息不能留空!"); 58 | 59 | ui->sNo_lineEdit->setFocus(); 60 | return; 61 | } 62 | 63 | QSqlDatabase db; 64 | connect_to_database(db); 65 | 66 | QSqlQuery query(db); 67 | 68 | query.exec("select name,sex,age,major,class,address,phonenumber,status from student where sId = '" + sNo + "'"); 69 | 70 | if(query.next()) 71 | { 72 | QString name = query.value(0).toString(); 73 | QString sex = query.value(1).toString(); 74 | QString age = query.value(2).toString(); 75 | QString major = query.value(3).toString(); 76 | QString Class = query.value(4).toString(); 77 | QString address = query.value(5).toString(); 78 | QString phonenum = query.value(6).toString(); 79 | QString status = query.value(7).toString(); 80 | 81 | //qDebug() << status; 82 | 83 | ui->sName_lineEdit->setText(name); 84 | ui->sexBox->setCurrentIndex(ui->sexBox->findText(sex)); 85 | ui->age_lineEdit->setText(age); 86 | ui->major_lineEdit->setText(major); 87 | ui->classId_lineEdit->setText(Class); 88 | ui->address_lineEdit->setText(address); 89 | ui->phone_lineEdit->setText(phonenum); 90 | ui->statusBox->setCurrentIndex(ui->statusBox->findText(status)); 91 | 92 | ui->update_button->setDisabled(false); 93 | ui->delete_button->setDisabled(false); 94 | ui->reset_button->setDisabled(false); 95 | } 96 | else 97 | { 98 | ui->update_button->setDisabled(true); 99 | ui->delete_button->setDisabled(true); 100 | ui->reset_button->setDisabled(true); 101 | 102 | ui->sName_lineEdit->clear(); 103 | ui->sexBox->setCurrentIndex(0); 104 | ui->age_lineEdit->clear(); 105 | ui->major_lineEdit->clear(); 106 | ui->classId_lineEdit->clear(); 107 | ui->address_lineEdit->clear(); 108 | ui->phone_lineEdit->clear(); 109 | ui->statusBox->setCurrentIndex(0); 110 | 111 | QMessageBox::warning(this, "查询无果", "该学生不存在"); 112 | 113 | ui->sNo_lineEdit->setFocus(); 114 | 115 | 116 | } 117 | } 118 | 119 | void stuinfomanage::on_update_button_clicked() 120 | { 121 | QString name = ui->sName_lineEdit->text(); 122 | QString sex = ui->sexBox->currentText(); 123 | QString age = ui->age_lineEdit->text(); 124 | QString major = ui->major_lineEdit->text(); 125 | QString Class = ui->classId_lineEdit->text(); 126 | QString address = ui->address_lineEdit->text(); 127 | QString phonenum = ui->phone_lineEdit->text(); 128 | QString sId = ui->sNo_lineEdit->text(); 129 | QString status = ui->statusBox->currentText(); 130 | 131 | QSqlDatabase db; 132 | connect_to_database(db); 133 | QSqlQuery query(db); 134 | 135 | query.exec("select classId from class where classId = '" + Class + "'"); 136 | if(query.size() == 0) 137 | { 138 | QMessageBox::warning(this, "修改失败", "该班级号不存在!"); 139 | return; 140 | } 141 | 142 | bool isUpdateSuccess = query.exec(QString("update student set name = '%0', sex = '%1'," 143 | "age = '%2', major = '%3', class = '%4', address = '%5'," 144 | "phonenumber = '%6', status = '%7' where sId = '%8'").arg(name).arg(sex).arg(age).arg(major).arg(Class) 145 | .arg(address).arg(phonenum).arg(status).arg(sId)); 146 | 147 | if(isUpdateSuccess) 148 | { 149 | //qDebug() << status; 150 | QMessageBox::information(this, "提示", "修改成功"); 151 | } 152 | else { 153 | QMessageBox::warning(this, "提示", "修改失败!请检查输入信息是否有误!"); 154 | } 155 | } 156 | 157 | void stuinfomanage::on_addStuInfo_button_clicked() 158 | { 159 | addStuInfo *asi = new addStuInfo; 160 | this->hide(); 161 | asi->show(); 162 | } 163 | 164 | void stuinfomanage::on_listAllStu_button_clicked() 165 | { 166 | QSqlDatabase db; 167 | connect_to_database(db); 168 | 169 | QSqlQuery query(db); 170 | 171 | query.exec("select sId,name,sex,age,major,class,address,phonenumber,status from student"); 172 | while(query.next()) 173 | { 174 | QStringList q; 175 | QString sId = query.value(0).toString(); 176 | QString name = query.value(1).toString(); 177 | QString sex = query.value(2).toString(); 178 | QString age = query.value(3).toString(); 179 | QString major = query.value(4).toString(); 180 | QString classId = query.value(5).toString(); 181 | QString address = query.value(6).toString(); 182 | QString phonenum = query.value(7).toString(); 183 | //QString password = query.value(8).toString(); 184 | QString status = query.value(8).toString(); 185 | q << sId << name << sex << age << major << classId << address << phonenum << status; 186 | list_all_student.append(q); 187 | } 188 | this->hide(); 189 | all_stu_info * all = new all_stu_info; 190 | all->show(); 191 | } 192 | 193 | void stuinfomanage::on_delete_button_clicked() 194 | { 195 | QMessageBox::StandardButton btn; 196 | btn = QMessageBox::question(this, "确认删除", "确定要删除此学生信息吗?", QMessageBox::Yes|QMessageBox::No); 197 | if(btn == QMessageBox::Yes) 198 | { 199 | QSqlDatabase db; 200 | connect_to_database(db); 201 | QSqlQuery query(db); 202 | 203 | QString sId = ui->sNo_lineEdit->text(); 204 | 205 | bool isDeleteSuccess = query.exec("delete from student where sId = '" + sId + "'"); 206 | 207 | if(isDeleteSuccess) 208 | { 209 | QMessageBox::information(this, "提示", "删除成功"); 210 | ui->sNo_lineEdit->clear(); 211 | ui->sName_lineEdit->clear(); 212 | ui->sexBox->setCurrentIndex(0); 213 | ui->major_lineEdit->clear(); 214 | ui->classId_lineEdit->clear(); 215 | ui->address_lineEdit->clear(); 216 | ui->phone_lineEdit->clear(); 217 | ui->statusBox->setCurrentIndex(0); 218 | 219 | ui->sNo_lineEdit->setFocus(); 220 | 221 | ui->update_button->setDisabled(true); 222 | ui->delete_button->setDisabled(true); 223 | ui->reset_button->setDisabled(true); 224 | 225 | } 226 | else { 227 | QMessageBox::warning(this, "提示", "删除失败"); 228 | } 229 | } 230 | } 231 | 232 | void stuinfomanage::on_reset_button_clicked() 233 | { 234 | QMessageBox::StandardButton btn; 235 | btn = QMessageBox::question(this, "确认重置", "确定要重置此学生密码吗?", QMessageBox::Yes|QMessageBox::No); 236 | if(btn == QMessageBox::Yes) 237 | { 238 | QString sId = ui->sNo_lineEdit->text(); 239 | QSqlDatabase db; 240 | connect_to_database(db); 241 | QSqlQuery query(db); 242 | 243 | QString originPwd = "123456"; 244 | QString md5_pwd = QCryptographicHash::hash(originPwd.toLatin1(),QCryptographicHash::Md5).toHex(); 245 | 246 | bool isResetPwdSuccess = query.exec("update student set password = '" + md5_pwd + "' where sId = '" + sId + "'"); 247 | if(isResetPwdSuccess) 248 | { 249 | QMessageBox::information(this, "提示", "已将此学生密码重置为初始密码"); 250 | } 251 | else { 252 | QMessageBox::warning(this, "警告", "重置失败!"); 253 | } 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/stuinfomanage.h: -------------------------------------------------------------------------------- 1 | #ifndef STUINFOMANAGE_H 2 | #define STUINFOMANAGE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class stuinfomanage; 8 | } 9 | 10 | class stuinfomanage : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit stuinfomanage(QWidget *parent = nullptr); 16 | ~stuinfomanage(); 17 | 18 | private slots: 19 | void on_pushButton_7_clicked(); 20 | 21 | void on_pushButton_clicked(); 22 | 23 | void on_update_button_clicked(); 24 | 25 | void on_addStuInfo_button_clicked(); 26 | 27 | void on_listAllStu_button_clicked(); 28 | 29 | void on_delete_button_clicked(); 30 | 31 | void on_reset_button_clicked(); 32 | 33 | private: 34 | Ui::stuinfomanage *ui; 35 | }; 36 | 37 | #endif // STUINFOMANAGE_H 38 | -------------------------------------------------------------------------------- /qt代码及使用说明书/代码部分/stuinfomanage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | stuinfomanage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 629 10 | 387 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 200 20 | 20 21 | 211 22 | 31 23 | 24 | 25 | 26 | font: 20pt "Arial"; 27 | 28 | 29 | 学生信息管理 30 | 31 | 32 | 33 | 34 | 35 | 70 36 | 100 37 | 131 38 | 16 39 | 40 | 41 | 42 | 请输入学生学号: 43 | 44 | 45 | 46 | 47 | 48 | 210 49 | 100 50 | 141 51 | 21 52 | 53 | 54 | 55 | 56 | 57 | 58 | 60 59 | 130 60 | 471 61 | 16 62 | 63 | 64 | 65 | Qt::Horizontal 66 | 67 | 68 | 69 | 70 | 71 | 130 72 | 300 73 | 338 74 | 65 75 | 76 | 77 | 78 | 79 | 80 | 81 | 修改学生信息 82 | 83 | 84 | 85 | 86 | 87 | 88 | 添加学生信息 89 | 90 | 91 | 92 | 93 | 94 | 95 | 查看所有学生信息信息 96 | 97 | 98 | 99 | 100 | 101 | 102 | 重置此学生密码 103 | 104 | 105 | 106 | 107 | 108 | 109 | 删除学生信息 110 | 111 | 112 | 113 | 114 | 115 | 116 | Qt::Vertical 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 380 126 | 100 127 | 216 128 | 30 129 | 130 | 131 | 132 | 133 | 134 | 135 | 查询 136 | 137 | 138 | 139 | 140 | 141 | 142 | 返回管理员界面 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 61 152 | 161 153 | 455 154 | 107 155 | 156 | 157 | 158 | 159 | 160 | 161 | 姓名 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 班级号 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 性别 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 籍贯 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 年龄 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 联系方式 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 专业 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 状态 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | -------------------------------------------------------------------------------- /qt学生信息管理系统演示/学生信息管理系统_袁佳哲.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/529106896/studentInfoManager/154517e495607e7f4776189df34aa01b742eb342/qt学生信息管理系统演示/学生信息管理系统_袁佳哲.pptx -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # studentInfoManager 2 | 3 | [![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu) 4 | 5 | C++程序设计练习——学生信息管理系统,基于Qt+MySQL 6 | 7 | ## 课程原要求如下: 8 | 9 | ## ![image](media/128875292-89e6fea9-c352-40d6-8975-3033489d3c49.png) 10 | 11 | 具体系统设计如下: 12 | 13 | 学生信息管理系统采用qt 5.9.8进行编写,借助mysql存储数据 14 | 15 | mysql版本为8.0.23 MySQL Community Server 16 | 17 | 数据库管理工具采用MySQL Workbench 8.0 CE 18 | 19 | 将所有需要的数据分为6个表,分别是: 20 | 21 | admin表:管理员信息表,存取管理员的id、管理员账号、管理员密码 22 | 23 | class表:班级信息表,存储班级id、班级名、班级专业、班级人数、班主任 24 | 25 | course表:课程信息表,存储课程id、课程名、任课教师、开课学期、上课地点、上课时间、学分数 26 | 27 | score表:成绩信息表,存储学生id、课程id、课程名、分数、任课教师 28 | 29 | student表:学生信息表,存储学生id、学生姓名、性别、年龄、专业、所属班级id、籍贯、联系方式、学生密码、学生状态 30 | 31 | student_course表:学生选课表,存储选课学生id和对应的选取课程的课程id 32 | 33 | ## 各表结构如下: 34 | 35 | admin表: 36 | 37 | 主码为aid 38 | 39 | ![](media/55264fc9ce1febaa38f7406e1603fe0e.png) 40 | 41 | class表: 42 | 43 | 主码为classId 44 | 45 | ![](media/a8b969de356d5402ab1b91aea1ee76c0.png) 46 | 47 | course表: 48 | 49 | 主码为cId 50 | 51 | ![](media/9f2f12102cc19842fdef12464368af69.png) 52 | 53 | score表: 54 | 55 | ![](media/f0dcfb93fa139172c363a02d1c10eaa1.png) 56 | 57 | 其中sid和cid为外码 58 | 59 | sid参考student表的sId属性 60 | 61 | cid参考course表的cId属性 62 | 63 | student表: 64 | 65 | 主码为sId 66 | 67 | ![](media/af8f35ef5b8a8a966044eea1387f7429.png) 68 | 69 | 其中class为外码 70 | 71 | class参考class表的classId属性 72 | 73 | student_course表: 74 | 75 | 主码为sId和cId 76 | 77 | ![](media/1457c7a1e929678e4cda2d5ea9f28bdf.png) 78 | 79 | 其中sId和cId为外码 80 | 81 | sId参考student表的sId属性 82 | 83 | cId参考course表的cId属性 84 | 85 | 登录流程如下图 86 | 87 | ![](media/162fc94789c2b29d591e60c63694aebf.jpg) 88 | 89 | 学生端功能: 90 | 91 | 1. 学生信息:查看个人基本信息、修改个人密码 92 | 93 | 2. 班级信息:查看个人所属班级基本情况 94 | 95 | 3. 成绩信息:查询个人成绩(可实现模糊查询) 96 | 97 | 4. 课程信息:查看个人所选所有课程、查询其他课程基本信息(可实现模糊查询) 98 | 99 | 管理员端功能: 100 | 101 | 1. 学生信息管理: 102 | 103 | 2. 查询学生基本信息、查看所有学生基本信息、修改学生基本信息、删除学生基本信息、重置学生密码、添加学生信息 104 | 105 | 3. 班级信息管理: 106 | 107 | 4. 查询班级基本信息、查看所有班级信息、修改班级信息、删除班级信息、添加班级信息 108 | 109 | 5. 课程信息管理: 110 | 111 | 6. 查询课程基本信息、查看所有课程信息、修改课程信息、删除课程信息、添加课程信息 112 | 113 | 7. 成绩信息管理: 114 | 115 | 8. 查询成绩信息(包括根据学号查找和根据课程号查找)、查看所有成绩信息、添加成绩信息、修改成绩信息(仅可修改成绩)、学生个人成绩统计、课程成绩统计 116 | 117 | 9. 选课信息管理: 118 | 119 | 10. 查询选课信息(包括根据学号查找和根据课程号查找)、查看所有选课信息、添加选课信息、删除选课信息 120 | 121 | 在学生端和管理员端的使用中,只要有表的界面,都添加了导出为Excel的功能,点击后即可将当前显示的表的信息导出到excel 122 | 123 | 功能实现简单描述: 124 | 125 | 对于各界面之间如何传值,可以设置一个global文件,把需要跨界面/全局使用的一些变量和函数写在global中,如数据库连接所用的端口、用户名、密码、连接函数等 126 | 127 | 系统的核心功能增删改查大部分都是简单的mysql语句,比如查找用的基本都是单表内的select,更新或修改用update,删除就是delete,稍微复杂一点的是统计,部分用到了MySQL的函数,比如sum、count、max、min等,统计选课人数、选课数等用到了两个表的连接操作,但都不难,都是一些很基础的mysql语句 128 | 129 | 稍微特殊的是如下三个功能: 130 | 131 | 第一个是导出为excel,用到了QAxObject类,并且用到了Excel.Application,具体实现过程是参考百度的教程 132 | \+ 133 | 自己改写部分代码,实现效果不能说很完美,因为即使数据很少,导出时还是会有明显的卡顿,其次是导出的单元格格式设置有问题,如学号11920192203642会显示为1.19202E+13 134 | 135 | 第二个是验证码,只需要在登录界面的cpp中设置登陆次数变量,当达到3时启动paintEvent事件,根据随机生成的思维字母以及根据时间随机变化的颜色来绘制验证码,同时重写鼠标单击函数,当单击验证码图片区域时就更新执行repaint来更新验证码 136 | 137 | 第三个是密码加密,因为考虑到隐私安全性问题,将所有用户的密码采用md5码加密的方式存储在数据库中,所有涉及到密码的操作都要经过加密,实现采用QCryptographicHash头文件,具体实现较为简单,不再赘述 138 | 139 | ## 界面截图: 140 | 141 | 所有界面和对应的一些实现类如下: 142 | 143 | ![](media/ae7b9e29f555d6d870838e02afc1a36b.png) 144 | ![](media/82e93463dbcf48195abe367895723ce7.png) 145 | 146 | 下面仅展示部分界面: 147 | 148 | 登录界面: 149 | 150 | ![](media/57389bb0f8fdf0ef2c2e8c4ae61b7da8.png) 151 | 152 | 登录界面失败三次后呈现验证码: 153 | 154 | ![](media/d558b2c12d947e71b3819f6d262bfc04.png) 155 | 156 | 登录失败五次后冻结该用户: 157 | 158 | ![](media/18e664f5b63acf301577c40d80d7c734.png) 159 | 160 | 管理员端主界面: 161 | 162 | ![](media/8831360e20f6ef19669f9de7de36edf6.png) 163 | 学生信息管理: 164 | 165 | ![](media/18554316e7da07673131975bc2c51ef4.png) 166 | 167 | 查看所有学生信息: 168 | 169 | ![](media/53e5258d71071129f67dac0ef850c56b.png) 170 | 171 | 导出学生信息为Excel效果图(excel是测试时导出的,和上图有不同): 172 | 173 | ![](media/70b575c6e68dfbbea94c0132ddcd44c8.png) 174 | 175 | 成绩信息管理: 176 | 177 | ![](media/7bfdc0959edf48c8ee3b521395fa8116.png) 178 | 179 | 学生成绩统计: 180 | 181 | ![](media/08c369185d8e46e73446e7c227a32cb8.png) 182 | 183 | 学生端主界面 184 | 185 | ![](media/376bcf8d8ea1fac32434ac436399f92c.png) 186 | 187 | 个人基本信息界面: 188 | 189 | ![](media/c0c49c03827fcba081d6be839760577b.png) 190 | 191 | 查询个人成绩: 192 | 193 | ![](media/af09e354224b410d5aa03d58a0a4b864.png) 194 | 195 | 课程信息: 196 | 197 | ![](media/328d8a06c0c746ca35fd5d154065e9eb.png) 198 | 199 | 查询其它课程: 200 | 201 | ![](media/15ab99de9bcd8bb014d1b7d9b2561f2f.png) 202 | 203 | 因篇幅限制,以上仅展示部分界面 204 | 205 | ## 未完善的功能: 206 | 207 | 1. 管理员在重置密码、删除用户,或者用户本人在修改面时,向用户发送邮件通知,因为发邮件要用到smtp和pop3,windows版的qt少了一些类,实现起来比较麻烦,如果强行实现效果也比较差,发送两封邮件后就报错了,所以删除了这个功能。如果是linux系统下的qt实现起来就比较容易 208 | 209 | 2. 数据库大部分数据类型都是VARCHAR,可能会有数据类型的隐患 210 | 211 | 3. 所有信息输入的地方都没有对格式和数据类型进行限制,比如密码的长度、某些字段不能包含某些字符等,如果加上正则表达式去限制格式,整体效果会更好 212 | 213 | 4. 考虑到权限的问题,学生端的功能比较少,基本仅限于简单的查找,实际中应该加入学生与管理员的交互,比如学生可以自主修改某些数据,只是需要管理员的审核通过后,修改才能生效 214 | 215 | 5. 登录界面的验证码是在三次密码错误后才显示,但颜色刷新是借助timer来实现的,timer从登录界面加载就开始计时,可能会占用更多资源。目前的验证码仅实现了随机挑选四个大小写字母,实际应该加入一些数字 216 | 217 | 6. (2024.02.17补充)不要使用外键,尽量单表,表之间的关联可以设置关联表。查询时可以选择join连表查询,或者单表查之后在代码里做关联 218 | 219 | 7. (2024.02.27补充)所有的sql语句都是通过字符串拼接的,而且数据库字段类型也基本都是varchar,很容易进行sql注入。但当时是随便写的,这点根本没有考虑,感兴趣的可以修改下 220 | --------------------------------------------------------------------------------