Skip to content

Commit

Permalink
修复新增教师、学生功能编号设定错误的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyu-coder committed Dec 26, 2020
1 parent 0f3695d commit 6f969a4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
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-24T01:30:55. -->
<!-- Written by QtCreator 4.11.0, 2020-12-26T13:07:37. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
2 changes: 1 addition & 1 deletion addstuwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void AddStuWidget::on_ConfirmButton_clicked()
{
QStringList info;
QSqlQuery query;
query.exec("select COUNT(Sno) from Student");
query.exec("select MAX(Sno) from Student");
if(query.lastError().type()==QSqlError::NoError){
if(query.next()){
int snoIndex=query.value(0).toInt()+1;
Expand Down
4 changes: 2 additions & 2 deletions addteacherwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ void AddTeacherWidget::on_QuitButton_clicked()
void AddTeacherWidget::on_ConfirmButton_clicked()
{
QSqlQuery TeaQuery;
TeaQuery.exec("select COUNT(Tno) from Teacher");
TeaQuery.exec("select MAX(Tno) from Teacher");
if(TeaQuery.lastError().type()==QSqlError::NoError){
if(TeaQuery.next()){
int tnoIndex=TeaQuery.value(0).toInt();
int tnoIndex=TeaQuery.value(0).toInt()+1;
QString tno=QString::number(tnoIndex);
while(tno.size()<4){
tno="0"+tno;
Expand Down

0 comments on commit 6f969a4

Please sign in to comment.