mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
до изменения NEW_INSTRUCTOR
This commit is contained in:
@@ -270,22 +270,14 @@ void EditorTrainees::on_btnEdit_clicked()
|
||||
{
|
||||
Group group_edit = dlg.getGroup();
|
||||
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_GROUP, id_group, &group_edit);
|
||||
return;
|
||||
/*
|
||||
if(int id = dbLMS->editGroup(group_edit))
|
||||
{//Отредактировано
|
||||
loadTraineesFromDB();
|
||||
setCurrentGroup(id);
|
||||
return;
|
||||
}
|
||||
else
|
||||
if(! verifyGroup(group_edit))
|
||||
{
|
||||
dlg.setGroup(group_edit);
|
||||
continue;
|
||||
}*/
|
||||
}
|
||||
|
||||
break;
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_GROUP, id_group, &group_edit);
|
||||
return;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return;
|
||||
@@ -303,7 +295,7 @@ void EditorTrainees::on_btnEdit_clicked()
|
||||
|
||||
if(connectorToServer->isLoggedInTrainee(id_trainee))
|
||||
{//Обучаемый залогирован!
|
||||
QMessageBox::critical(this, tr("Error!"), tr("You cannot archive a logged-in trainee."));
|
||||
QMessageBox::critical(this, tr("Error!"), tr("You cannot edit a logged-in trainee."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -323,22 +315,14 @@ void EditorTrainees::on_btnEdit_clicked()
|
||||
{
|
||||
Trainee trainee_edit = dlg.getTrainee();
|
||||
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE, id_trainee, &trainee_edit);
|
||||
return;
|
||||
/*
|
||||
if(int id = dbLMS->editTrainee(trainee_edit))
|
||||
{//Отредактировано
|
||||
loadTraineesFromDB();
|
||||
setCurrentTrainee(id);
|
||||
return;
|
||||
}
|
||||
else
|
||||
if(! verifyTrainee(trainee_edit))
|
||||
{
|
||||
dlg.setTrainee(trainee_edit);
|
||||
continue;
|
||||
}*/
|
||||
}
|
||||
|
||||
break;
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE, id_trainee, &trainee_edit);
|
||||
return;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return;
|
||||
@@ -457,4 +441,77 @@ void EditorTrainees::on_treeWidget_currentItemChanged(QTreeWidgetItem *current,
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorTrainees::verifyGroup(Group group)
|
||||
{
|
||||
//Проверка корректности имени
|
||||
|
||||
if(group.getName() == QStringLiteral("<group>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable group name has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<Group> listGroups = connectorToServer->getListGroups();
|
||||
|
||||
for(Group exist_group : listGroups)
|
||||
{
|
||||
if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing group name has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EditorTrainees::verifyTrainee(Trainee trainee)
|
||||
{
|
||||
//Проверка корректности логина, имени, пароля
|
||||
|
||||
if(trainee.getName() == QStringLiteral("<trainee>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(trainee.getLogin() == QStringLiteral("<login>"))
|
||||
{//Логин не корректен!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(trainee.getPassword() == QStringLiteral("<password>"))
|
||||
{//Пароль не корректный!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<Trainee> listTrainees = connectorToServer->getListTrainees();
|
||||
|
||||
for(Trainee exist_trainee : listTrainees)
|
||||
{
|
||||
if(trainee.getName() == exist_trainee.getName() && trainee.getID() != exist_trainee.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee name has been entered."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(trainee.getLogin() == exist_trainee.getLogin() && trainee.getID() != exist_trainee.getID())
|
||||
{//Логин уже существует!
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ private Q_SLOTS:
|
||||
private:
|
||||
//void setCurrentGroup(int id);
|
||||
//void setCurrentTrainee(int id);
|
||||
bool verifyGroup(Group group);
|
||||
bool verifyTrainee(Trainee trainee);
|
||||
|
||||
private:
|
||||
Ui::EditorTrainees *ui;
|
||||
|
||||
@@ -107,6 +107,7 @@ void TraineesView::loadTraineesFromDB()
|
||||
listGroups = connectorToServer->getListGroups();
|
||||
listTrainees = connectorToServer->getListTrainees();
|
||||
|
||||
|
||||
for(Group group : listGroups)
|
||||
{
|
||||
//Группа
|
||||
@@ -116,6 +117,8 @@ void TraineesView::loadTraineesFromDB()
|
||||
ItemGroup->setText(ColumnsTreeTrainees::clmn_Trainee, group.getName());
|
||||
ItemGroup->setIcon(ColumnsTreeTrainees::clmn_Trainee, QIcon(QStringLiteral(":/icons/group.png")));
|
||||
setItemColor(ItemGroup, QColor(170, 190, 170));
|
||||
|
||||
//ItemGroup->set Property("greenButton", QVariant(true));
|
||||
//((QAbstractItemView*)ItemGroup)->setIconSize(QSize(32, 32));
|
||||
|
||||
//Обучаемые
|
||||
@@ -183,8 +186,8 @@ void TraineesView::loadTraineesFromDB()
|
||||
ItemTrainee->setHidden(true);
|
||||
}
|
||||
|
||||
if(! archiveVisible && cntChildsNotArchived == 0)
|
||||
delete ItemGroup;
|
||||
//if(! archiveVisible && cntChildsNotArchived == 0)
|
||||
//delete ItemGroup;
|
||||
}
|
||||
|
||||
treeWidget->expandAll();
|
||||
|
||||
Reference in New Issue
Block a user