mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
verify в EditInstructor
This commit is contained in:
@@ -31,7 +31,12 @@ EditorTrainees::~EditorTrainees()
|
||||
|
||||
void EditorTrainees::on_btnNewGroup_clicked()
|
||||
{
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_GROUP);
|
||||
Group group;
|
||||
Group group_edit;
|
||||
|
||||
if(editGroup(group, &group_edit))
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_GROUP, 0, &group_edit);
|
||||
|
||||
return;
|
||||
/*
|
||||
if(int id_group = dbLMS->newGroup())
|
||||
@@ -119,7 +124,12 @@ void EditorTrainees::on_btnNewTrainee_clicked()
|
||||
{//Выбрана группа. Можно добавить Обучаемого
|
||||
int id_group = treeItemCurrent->text(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE, id_group);
|
||||
Trainee trainee;
|
||||
Trainee trainee_edit;
|
||||
|
||||
if(editTrainee(trainee, &trainee_edit))
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE, id_group, &trainee_edit);
|
||||
|
||||
return;
|
||||
|
||||
/*
|
||||
@@ -254,39 +264,14 @@ void EditorTrainees::on_btnEdit_clicked()
|
||||
|
||||
int id_group = treeItemCurrent->text(ColumnsTreeTrainees::clmn_ID).toInt();
|
||||
|
||||
DialogEditGroup dlg(this);
|
||||
|
||||
Group group = connectorToServer->getGroup(id_group);
|
||||
if(group.getID() == 0)
|
||||
return;
|
||||
|
||||
dlg.setGroup(group);
|
||||
Group group_edit;
|
||||
|
||||
while (true)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
Group group_edit = dlg.getGroup();
|
||||
|
||||
if(! verifyGroup(group_edit))
|
||||
{
|
||||
dlg.setGroup(group_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_GROUP, id_group, &group_edit);
|
||||
return;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(editGroup(group, &group_edit))
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_GROUP, id_group, &group_edit);
|
||||
}
|
||||
else
|
||||
{//Выбран обучаемый
|
||||
@@ -299,39 +284,14 @@ void EditorTrainees::on_btnEdit_clicked()
|
||||
return;
|
||||
}
|
||||
|
||||
DialogEditTrainee dlg(this);
|
||||
|
||||
Trainee trainee = connectorToServer->getTrainee(id_trainee);
|
||||
if(trainee.getID() == 0)
|
||||
return;
|
||||
|
||||
dlg.setTrainee(trainee);
|
||||
Trainee trainee_edit;
|
||||
|
||||
while (true)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
Trainee trainee_edit = dlg.getTrainee();
|
||||
|
||||
if(! verifyTrainee(trainee_edit))
|
||||
{
|
||||
dlg.setTrainee(trainee_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE, id_trainee, &trainee_edit);
|
||||
return;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(editTrainee(trainee, &trainee_edit))
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_EDIT_TRAINEE, id_trainee, &trainee_edit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,4 +474,64 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EditorTrainees::editGroup(Group group, Group *group_edit)
|
||||
{
|
||||
DialogEditGroup dlg(this);
|
||||
|
||||
dlg.setGroup(group);
|
||||
|
||||
while (true)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
*group_edit = dlg.getGroup();
|
||||
|
||||
if(! verifyGroup(*group_edit))
|
||||
{
|
||||
dlg.setGroup(*group_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorTrainees::editTrainee(Trainee trainee, Trainee *trainee_edit)
|
||||
{
|
||||
DialogEditTrainee dlg(this);
|
||||
|
||||
dlg.setTrainee(trainee);
|
||||
|
||||
while (true)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
*trainee_edit = dlg.getTrainee();
|
||||
|
||||
if(! verifyTrainee(*trainee_edit))
|
||||
{
|
||||
dlg.setTrainee(*trainee_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user