mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
before task parser
This commit is contained in:
@@ -1,12 +1,47 @@
|
||||
#include <QMessageBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QSqlError>
|
||||
#include "interfacedatabaselms.h"
|
||||
|
||||
InterfaceDataBaseLMS::InterfaceDataBaseLMS():
|
||||
InterfaceDataBaseLMS::InterfaceDataBaseLMS(QWidget* parent):
|
||||
QWidget(parent),
|
||||
DataBaseLMS()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InterfaceDataBaseLMS::slot_LanguageChanged(QString language)
|
||||
{
|
||||
qtLanguageTranslator.load(QString(QStringLiteral("translations/DataBaseLMS_")) + language, QStringLiteral("."));
|
||||
QCoreApplication::installTranslator(&qtLanguageTranslator);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::ConnectionToDB()
|
||||
{
|
||||
if(!createConnection())
|
||||
{
|
||||
QMessageBox::critical(this, dbName, tr("Connection error: ") + db->lastError().text());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information(this, dbName, tr("Connection is successful!"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::DisConnectionFromDB()
|
||||
{
|
||||
deleteConnection();
|
||||
QMessageBox::information(this, dbName, tr("Disconnection is successful!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::DBisConnected()
|
||||
{
|
||||
return isConnected();
|
||||
}
|
||||
|
||||
//Инструкторы
|
||||
|
||||
bool InterfaceDataBaseLMS::AuthorizationInstructor(QString login, QString password)
|
||||
@@ -39,6 +74,16 @@ bool InterfaceDataBaseLMS::deAuthorizationInstructor(QString login)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::deAuthorizationAllInstructors()
|
||||
{
|
||||
return updateAllInstructorsLoggedIn(false);
|
||||
}
|
||||
|
||||
QString InterfaceDataBaseLMS::getNameInstructorByLogin(QString login)
|
||||
{
|
||||
return selectInstructorNameByLogin(login);
|
||||
}
|
||||
|
||||
QList<Instructor> InterfaceDataBaseLMS::getListInstructors()
|
||||
{
|
||||
return selectAllInstructors();
|
||||
@@ -67,35 +112,35 @@ int InterfaceDataBaseLMS::editInstructor(Instructor instructor)
|
||||
{
|
||||
if(instructor.getName() == QStringLiteral("<instructor>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(instructor.getLogin() == QStringLiteral("<login>"))
|
||||
{//Логин не корректен!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(instructor.getPassword() == QStringLiteral("<password>"))
|
||||
{//Пароль не корректный!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(instructor.getName() == exist_instructor.getName() && instructor.getID() != exist_instructor.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing instructor name has been entered."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(instructor.getLogin() == exist_instructor.getLogin() && instructor.getID() != exist_instructor.getID())
|
||||
{//Логин уже существует!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing instructor login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
@@ -114,6 +159,11 @@ bool InterfaceDataBaseLMS::isArchivedInstructor(int id)
|
||||
return selectInstructorArchived(id);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::isLoggedInInstructor(int id)
|
||||
{
|
||||
return selectInstructorLoggedIn(id);
|
||||
}
|
||||
|
||||
|
||||
//Инструкторы
|
||||
|
||||
@@ -147,6 +197,11 @@ bool InterfaceDataBaseLMS::deAuthorizationTrainee(QString login)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::deAuthorizationAllTrainees()
|
||||
{
|
||||
return updateAllTraineesLoggedIn(false);
|
||||
}
|
||||
|
||||
QList<Task> InterfaceDataBaseLMS::getTasksTrainee(int id)
|
||||
{
|
||||
return selectTasksOfTrainee(id);
|
||||
@@ -154,35 +209,17 @@ QList<Task> InterfaceDataBaseLMS::getTasksTrainee(int id)
|
||||
|
||||
QString InterfaceDataBaseLMS::getNameTraineeOnComputer(QString computer_name)
|
||||
{
|
||||
/*
|
||||
for(Trainee trainee : listOfTrainees)
|
||||
{
|
||||
if(trainee.getComputer().getName() == computer_name)
|
||||
return trainee.getName();
|
||||
}*/
|
||||
return QString(QStringLiteral(""));
|
||||
return selectTraineeNameOnComputer(computer_name);
|
||||
}
|
||||
|
||||
Trainee InterfaceDataBaseLMS::getTraineeOnComputer(QString computer_name)
|
||||
{
|
||||
/*
|
||||
for(Trainee trainee : listOfTrainees)
|
||||
{
|
||||
if(trainee.getComputer().getName() == computer_name)
|
||||
return trainee;
|
||||
}*/
|
||||
return Trainee();
|
||||
return selectTraineeOnComputer(computer_name);
|
||||
}
|
||||
|
||||
QString InterfaceDataBaseLMS::getNameTraineeByLogin(QString login)
|
||||
{
|
||||
/*
|
||||
for(Trainee trainee : listOfTrainees)
|
||||
{
|
||||
if(trainee.getLogin() == login)
|
||||
return trainee.getName();
|
||||
}*/
|
||||
return QString(QStringLiteral(""));
|
||||
return selectTraineeNameByLogin(login);
|
||||
}
|
||||
|
||||
QList<Trainee> InterfaceDataBaseLMS::getListTraineesInGroup(int id)
|
||||
@@ -228,15 +265,15 @@ int InterfaceDataBaseLMS::editGroup(Group group)
|
||||
{
|
||||
if(group.getName() == QStringLiteral("<group>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable group name has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
tr("An existing group name has been entered."));
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing group name has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -262,35 +299,35 @@ int InterfaceDataBaseLMS::editTrainee(Trainee trainee)
|
||||
{
|
||||
if(trainee.getName() == QStringLiteral("<trainee>"))
|
||||
{//Имя не корректно!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(trainee.getLogin() == QStringLiteral("<login>"))
|
||||
{//Логин не корректен!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(trainee.getPassword() == QStringLiteral("<password>"))
|
||||
{//Пароль не корректный!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(trainee.getName() == exist_trainee.getName() && trainee.getID() != exist_trainee.getID())
|
||||
{//Имя уже существует
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee name has been entered."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(trainee.getLogin() == exist_trainee.getLogin() && trainee.getID() != exist_trainee.getID())
|
||||
{//Логин уже существует!
|
||||
QMessageBox::critical(nullptr, tr("Editing error!"),
|
||||
QMessageBox::critical(this, tr("Editing error!"),
|
||||
tr("An existing trainee login has been entered.\nThe changes will not be accepted."));
|
||||
return 0;
|
||||
}
|
||||
@@ -303,3 +340,8 @@ bool InterfaceDataBaseLMS::isArchivedTrainee(int id)
|
||||
{
|
||||
return selectTraineeArchived(id);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::isLoggedInTrainee(int id)
|
||||
{
|
||||
return selectTraineeLoggedIn(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user