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:
@@ -122,7 +122,23 @@ void DataParser::createQueryToDBMessage(ClientQueryToDB *queryToDB, int id, void
|
||||
xmlWriter.writeAttribute("computer_trainee", QString::number(trainee->getComputer().getID()));
|
||||
}
|
||||
}
|
||||
else if(queryToDB->typeQuery == TypeQueryToDB::TYPE_QUERY_EDIT_GROUP)
|
||||
else if(queryToDB->typeQuery == TypeQueryToDB::TYPE_QUERY_NEW_TRAINEE)
|
||||
{
|
||||
Trainee* trainee = (Trainee*)data;
|
||||
if(trainee)
|
||||
{
|
||||
xmlWriter.writeAttribute("trainee_id", QString::number(trainee->getID()));
|
||||
xmlWriter.writeAttribute("name", trainee->getName());
|
||||
xmlWriter.writeAttribute("login", trainee->getLogin());
|
||||
xmlWriter.writeAttribute("password", trainee->getPassword());
|
||||
xmlWriter.writeAttribute("archived", QString::number(trainee->getArchived()));
|
||||
xmlWriter.writeAttribute("logged_in", QString::number(trainee->getLoggedIn()));
|
||||
xmlWriter.writeAttribute("group_trainee", QString::number(id));
|
||||
xmlWriter.writeAttribute("computer_trainee", QString::number(trainee->getComputer().getID()));
|
||||
}
|
||||
}
|
||||
else if(queryToDB->typeQuery == TypeQueryToDB::TYPE_QUERY_EDIT_GROUP ||
|
||||
queryToDB->typeQuery == TypeQueryToDB::TYPE_QUERY_NEW_GROUP)
|
||||
{
|
||||
Group* group = (Group*)data;
|
||||
if(group)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "dialogeditinstructor.h"
|
||||
#include "ui_dialogeditinstructor.h"
|
||||
#include <QPushButton>
|
||||
|
||||
DialogEditInstructor::DialogEditInstructor(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@@ -7,6 +8,7 @@ DialogEditInstructor::DialogEditInstructor(QWidget *parent) :
|
||||
instructorInput()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
verify();
|
||||
}
|
||||
|
||||
DialogEditInstructor::~DialogEditInstructor()
|
||||
@@ -46,3 +48,28 @@ Instructor DialogEditInstructor::getInstructor()
|
||||
|
||||
return instructor;
|
||||
}
|
||||
|
||||
void DialogEditInstructor::on_editName_textChanged(const QString &arg1)
|
||||
{
|
||||
verify();
|
||||
}
|
||||
|
||||
void DialogEditInstructor::on_editLogin_textChanged(const QString &arg1)
|
||||
{
|
||||
verify();
|
||||
}
|
||||
|
||||
void DialogEditInstructor::on_editPassword_textChanged(const QString &arg1)
|
||||
{
|
||||
verify();
|
||||
}
|
||||
|
||||
void DialogEditInstructor::verify()
|
||||
{
|
||||
if(ui->editName->text().trimmed() == QStringLiteral("") ||
|
||||
ui->editLogin->text().trimmed() == QStringLiteral("") ||
|
||||
ui->editPassword->text().trimmed() == QStringLiteral(""))
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
else
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,16 @@ public:
|
||||
void setInstructor(Instructor instructor);
|
||||
Instructor getInstructor();
|
||||
|
||||
private slots:
|
||||
void on_editName_textChanged(const QString &arg1);
|
||||
|
||||
void on_editLogin_textChanged(const QString &arg1);
|
||||
|
||||
void on_editPassword_textChanged(const QString &arg1);
|
||||
|
||||
private:
|
||||
void verify();
|
||||
|
||||
private:
|
||||
Ui::DialogEditInstructor *ui;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ private:
|
||||
bool verifyGroup(Group group);
|
||||
bool verifyTrainee(Trainee trainee);
|
||||
|
||||
bool editGroup(Group group, Group* group_edit);
|
||||
bool editTrainee(Trainee trainee, Trainee* trainee_edit);
|
||||
|
||||
private:
|
||||
Ui::EditorTrainees *ui;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user