Skip to content

Commit

Permalink
实现修改成绩功能
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyu-coder committed Dec 27, 2020
1 parent c3eaa55 commit 8bf54a2
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 20 deletions.
3 changes: 3 additions & 0 deletions SIM_System.pro
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ SOURCES += \
mainwindow.cpp \
modifyapplywidget.cpp \
modifydeptmsgwidget.cpp \
modifygradewidget.cpp \
modifylessonwidget.cpp \
modifystuwidget.cpp \
modifyteacherwidget.cpp \
Expand Down Expand Up @@ -72,6 +73,7 @@ HEADERS += \
mainwindow.h \
modifyapplywidget.h \
modifydeptmsgwidget.h \
modifygradewidget.h \
modifylessonwidget.h \
modifystuwidget.h \
modifyteacherwidget.h \
Expand Down Expand Up @@ -101,6 +103,7 @@ FORMS += \
mainwindow.ui \
modifyapplywidget.ui \
modifydeptmsgwidget.ui \
modifygradewidget.ui \
modifylessonwidget.ui \
modifystuwidget.ui \
modifyteacherwidget.ui \
Expand Down
2 changes: 1 addition & 1 deletion SIM_System.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2020-12-26T21:05:17. -->
<!-- Written by QtCreator 4.11.0, 2020-12-27T00:32:44. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
2 changes: 1 addition & 1 deletion addteacherwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void AddTeacherWidget::on_ConfirmButton_clicked()
sqls<<"GRANT SELECT ON CourseBasic TO T"+tno+"";
sqls<<"GRANT SELECT ON CTime TO T"+tno+"";
sqls<<"GRANT SELECT ON Tcourse TO T"+tno+"";
sqls<<"GRANT SELECT ON Stu_Cour TO T"+tno+"";
sqls<<"GRANT SELECT,UPDATE ON Stu_Cour TO T"+tno+"";
sqls<<"GRANT SELECT ON Teacher TO T"+tno+"";
sqls<<"GRANT SELECT,INSERT,DELETE ON ScholarAppli TO T"+tno+"";
sqls<<"GRANT SELECT,INSERT,DELETE ON ScholarLst TO T"+tno+"";
Expand Down
2 changes: 1 addition & 1 deletion loadclassfromwebwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void LoadClassFromWebWidget::getLessonMsgFromHtml(){
sqls<<"GRANT SELECT ON CourseBasic TO T"+tno+"";
sqls<<"GRANT SELECT ON CTime TO T"+tno+"";
sqls<<"GRANT SELECT ON Tcourse TO T"+tno+"";
sqls<<"GRANT SELECT ON Stu_Cour TO T"+tno+"";
sqls<<"GRANT SELECT,UPDATE ON Stu_Cour TO T"+tno+"";
sqls<<"GRANT SELECT ON Teacher TO T"+tno+"";
sqls<<"GRANT SELECT,INSERT,DELETE ON ScholarAppli TO T"+tno+"";
sqls<<"GRANT SELECT,INSERT,DELETE ON ScholarLst TO T"+tno+"";
Expand Down
37 changes: 37 additions & 0 deletions modifygradewidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "modifygradewidget.h"
#include "ui_modifygradewidget.h"

ModifyGradeWidget::ModifyGradeWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::ModifyGradeWidget)
{
ui->setupUi(this);
}

ModifyGradeWidget::~ModifyGradeWidget()
{
delete ui;
}


void ModifyGradeWidget::setMsg(QString name,QStringList cnos){
_name=name;
_cnos=cnos;
}

void ModifyGradeWidget::on_toolButton_clicked()
{
QString grade=ui->lineEdit->text();
QString res;
QSqlQuery query;
for(int i=0;i<_cnos.size();i++){
query.exec("update Stu_Cour set Grade="+grade+" where Sno='"+_cnos.at(i)+"' and Cno=(select Cno from CourseBasic where Cname='"+_name+"')");
if(query.lastError().type()!=QSqlError::NoError) res+=query.lastError().text();
}
if(res==""){
QMessageBox::information(this,"修改成绩","修改成绩成功!");
this->close();
}else{
QMessageBox::warning(this,"修改成绩错误",res);
}
}
31 changes: 31 additions & 0 deletions modifygradewidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef MODIFYGRADEWIDGET_H
#define MODIFYGRADEWIDGET_H

#include <QWidget>
#include<adminwindow.h>

namespace Ui {
class ModifyGradeWidget;
}

class ModifyGradeWidget : public QWidget
{
Q_OBJECT

public:
explicit ModifyGradeWidget(QWidget *parent = nullptr);
~ModifyGradeWidget();

void setMsg(QString name,QStringList cnos);

private slots:
void on_toolButton_clicked();

private:
Ui::ModifyGradeWidget *ui;

QString _name;
QStringList _cnos;
};

#endif // MODIFYGRADEWIDGET_H
51 changes: 51 additions & 0 deletions modifygradewidget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ModifyGradeWidget</class>
<widget class="QWidget" name="ModifyGradeWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>198</width>
<height>93</height>
</rect>
</property>
<property name="windowTitle">
<string>修改成绩</string>
</property>
<property name="windowIcon">
<iconset resource="SIMS_res.qrc">
<normaloff>:/SIM_System_Pics/resources/icon_login_2.png</normaloff>:/SIM_System_Pics/resources/icon_login_2.png</iconset>
</property>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>161</width>
<height>23</height>
</rect>
</property>
<property name="placeholderText">
<string>成绩</string>
</property>
</widget>
<widget class="QToolButton" name="toolButton">
<property name="geometry">
<rect>
<x>70</x>
<y>60</y>
<width>47</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</widget>
<resources>
<include location="SIMS_res.qrc"/>
</resources>
<connections/>
</ui>
17 changes: 8 additions & 9 deletions studentwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void StudentWindow::on_FlushButton_1_clicked()
QSqlQuery query;
Data* data=Data::getData();
QString sno=data->sno;
query.exec("select CourseBasic.Cno,Cname,Cchar,Climit,Ccur,Cdept,Ccredit,Cgrade,Stu_Cour.Cterm from CourseBasic,Stu_Cour where CourseBasic.Cno=Stu_Cour.Cno and Stu_Cour.Sno='"+data->sno+"'");
query.exec("select CourseBasic.Cno,Cname,Cchar,Climit,Ccur,Cdept,Ccredit,Cgrade,Stu_Cour.Cterm,Grade from CourseBasic,Stu_Cour where CourseBasic.Cno=Stu_Cour.Cno and Stu_Cour.Sno='"+data->sno+"'");
if(query.lastError().type()==QSqlError::NoError){
while(query.next()){

Expand All @@ -143,25 +143,24 @@ void StudentWindow::on_FlushButton_1_clicked()
qDebug()<<teaQuery.lastError().text();
}
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,3,new QTableWidgetItem(tea));
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,4,new QTableWidgetItem(query.value(3).toString()));
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,5,new QTableWidgetItem(query.value(4).toString()));
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,6,new QTableWidgetItem(query.value(5).toString()));
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,7,new QTableWidgetItem(query.value(6).toString()));
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,8,new QTableWidgetItem(query.value(7).toString()));
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,4,new QTableWidgetItem(query.value(5).toString()));
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,5,new QTableWidgetItem(query.value(6).toString()));
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,6,new QTableWidgetItem(query.value(7).toString()));
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,8,new QTableWidgetItem(query.value(9).toString()));
QSqlQuery timeQuery;
timeQuery.exec("select Wday,Cbegin,Cend from CTime where Cno='"+query.value(0).toString()+"' and Cterm='"+query.value(8).toString()+"'");
QString time;
QStringList timeThansfer;
timeThansfer<<""<<""<<""<<""<<""<<""<<"";
if(timeQuery.lastError().type()==QSqlError::NoError){
while(timeQuery.next()){
time+=""+timeThansfer.at(timeQuery.value(0).toInt())+""+timeQuery.value(1).toString()+"-"+timeQuery.value(2).toString()+"";
time+=""+timeThansfer.at(timeQuery.value(0).toInt()-1)+""+timeQuery.value(1).toString()+"-"+timeQuery.value(2).toString()+"";
}
}else{
QMessageBox::warning(this,"查询课程时间信息错误",timeQuery.lastError().text());
}

ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,9,new QTableWidgetItem(time));
ui->MyLessonWidget->setItem(ui->MyLessonWidget->rowCount()-1,7,new QTableWidgetItem(time));
}
}else{
QMessageBox::warning(this,"查询课程信息错误",query.lastError().text());
Expand Down Expand Up @@ -273,7 +272,7 @@ void StudentWindow::on_ChooseLessonButton_clicked()
QString term;
if(ui->LessonWidget->item(index,9)->text()=="第一学期") term="1";
else term="2";
query.exec("insert into Stu_Cour values('"+data->sno+"','"+ui->LessonWidget->item(index,0)->text()+"','"+term+"',"+ui->LessonWidget->item(index,8)->text()+"); update CourseBasic set Ccur=Ccur+1 where Cno='"+ui->LessonWidget->item(index,0)->text()+"'");
query.exec("insert into Stu_Cour values('"+data->sno+"','"+ui->LessonWidget->item(index,0)->text()+"','"+term+"',''); update CourseBasic set Ccur=Ccur+1 where Cno='"+ui->LessonWidget->item(index,0)->text()+"'");
if(query.lastError().type()==QSqlError::NoError){

}else{
Expand Down
7 changes: 1 addition & 6 deletions studentwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ hover{ background-color: rgba(255, 255, 255, 150);border:2px solid white;border-
</rect>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>118</number>
<number>135</number>
</attribute>
<column>
<property name="text">
Expand Down Expand Up @@ -158,11 +158,6 @@ hover{ background-color: rgba(255, 255, 255, 150);border:2px solid white;border-
<string>学分</string>
</property>
</column>
<column>
<property name="text">
<string>开课院系</string>
</property>
</column>
<column>
<property name="text">
<string>开课年级</string>
Expand Down
21 changes: 20 additions & 1 deletion teacherwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void TeacherWindow::on_StudentLessonBox_currentIndexChanged(const QString &arg1)
ui->StudentWidget->clearContents();
ui->StudentWidget->setRowCount(0);
QSqlQuery query;
query.exec("select CourseBasic.Cno,Cname,Ssex,Sdept,Sgrade from Student,Stu_Cour,CourseBasic where CourseBasic.Cno=Stu_Cour.Cno and Stu_Cour.Sno=Student.Sno and Cname='"+arg1+"'");
query.exec("select Stu_Cour.Sno,Sname,Ssex,Sdept,Sgrade,Grade from Student,Stu_Cour,CourseBasic where CourseBasic.Cno=Stu_Cour.Cno and Stu_Cour.Sno=Student.Sno and Cname='"+arg1+"'");
if(query.lastError().type()==QSqlError::NoError){
while(query.next()){
ui->StudentWidget->setRowCount(ui->StudentWidget->rowCount()+1);
Expand All @@ -127,6 +127,7 @@ void TeacherWindow::on_StudentLessonBox_currentIndexChanged(const QString &arg1)
ui->StudentWidget->setItem(ui->StudentWidget->rowCount()-1,2,new QTableWidgetItem(query.value(2).toString()));
ui->StudentWidget->setItem(ui->StudentWidget->rowCount()-1,3,new QTableWidgetItem(query.value(3).toString()));
ui->StudentWidget->setItem(ui->StudentWidget->rowCount()-1,4,new QTableWidgetItem(query.value(4).toString()));
ui->StudentWidget->setItem(ui->StudentWidget->rowCount()-1,5,new QTableWidgetItem(query.value(5).toString()));

}
}else{
Expand Down Expand Up @@ -155,3 +156,21 @@ void TeacherWindow::on_ProWidget_itemDoubleClicked(QListWidgetItem *item)
widget->setName(name);
widget->show();
}

void TeacherWindow::on_toolButton_clicked()
{
QList<QTableWidgetItem*> items=ui->StudentWidget->selectedItems();
if(items.size()<=0){
QMessageBox::warning(this,"错误","您没有选中任何学生!");
}else{
QString name=ui->StudentLessonBox->currentText();
QStringList cnos;
for(int i=0;i<items.size();i++){
int index=ui->StudentWidget->row(items.at(i));
cnos<<ui->StudentWidget->item(index,0)->text();
}
ModifyGradeWidget *widget=new ModifyGradeWidget();
widget->setMsg(name,cnos);
widget->show();
}
}
3 changes: 3 additions & 0 deletions teacherwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include<addprowidget.h>
#include<addmsgwidget.h>
#include<promsgwidget.h>
#include<modifygradewidget.h>

namespace Ui {
class TeacherWindow;
Expand Down Expand Up @@ -39,6 +40,8 @@ private slots:

void on_ProWidget_itemDoubleClicked(QListWidgetItem *item);

void on_toolButton_clicked();

private:
Ui::TeacherWindow *ui;
};
Expand Down
31 changes: 30 additions & 1 deletion teacherwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ hover{ background-color: rgba(255, 255, 255, 150);border:2px solid white;border-
</rect>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>243</number>
<number>202</number>
</attribute>
<column>
<property name="text">
Expand All @@ -213,6 +213,11 @@ hover{ background-color: rgba(255, 255, 255, 150);border:2px solid white;border-
<string>入学年级</string>
</property>
</column>
<column>
<property name="text">
<string>课程成绩</string>
</property>
</column>
</widget>
<widget class="QWidget" name="widget_3" native="true">
<property name="geometry">
Expand Down Expand Up @@ -248,6 +253,30 @@ hover{ background-color: rgba(255, 255, 255, 150);border:2px solid white;border-
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="styleSheet">
<string notr="true">background-color: rgba(255, 255, 255, 0);border:2px solid white;border-radius:10px;
hover{ background-color: rgba(255, 255, 255, 150);border:2px solid white;border-radius:10px;background-color: rgba(255, 255, 255, 150);border:2px solid white;border-radius:10px;}</string>
</property>
<property name="text">
<string>录入成绩</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down

0 comments on commit 8bf54a2

Please sign in to comment.