PSQL 02.11.2024

This commit is contained in:
krivoshein
2024-11-02 13:43:57 +03:00
parent 9422c5e257
commit 0f1fa71c33
76 changed files with 576 additions and 493 deletions

View File

@@ -33,8 +33,18 @@ bool DataBaseInstructors::AuthorizationInstructor(QString login, QString passwor
if(listOfInstructors[i].getLogin() == login && listOfInstructors[i].getPassword() == password)
{
listOfInstructors[i].setLoggedIn(true);
return true;
Instructor instructor = listOfInstructors[i];
instructor.setLoggedIn(true);
bool result = dbLMS->updateInstructor(instructor);
if(result)
{
LoadInstructorsPSQL();
return true;
}
else
return false;
}
}
return false;
@@ -45,13 +55,23 @@ bool DataBaseInstructors::deAuthorizationInstructor(QString login)
//Инструкторы
for(int i = 0; i < listOfInstructors.count(); i++)
{
//if(listOfInstructors[i].getArchived())
//continue;
if(listOfInstructors[i].getArchived())
continue;
if(listOfInstructors[i].getLogin() == login)
{
listOfInstructors[i].setLoggedIn(false);
return true;
Instructor instructor = listOfInstructors[i];
instructor.setLoggedIn(false);
bool result = dbLMS->updateInstructor(instructor);
if(result)
{
LoadInstructorsPSQL();
return true;
}
else
return false;
}
}
return false;
@@ -131,46 +151,6 @@ void DataBaseInstructors::deleteInstructor(QString name)
}
}
void DataBaseInstructors::toArchiveInstructor(QString name)
{
//Инструкторы
for(int i = 0; i < listOfInstructors.count(); i++)
{
if(listOfInstructors[i].getName() == name)
if(! listOfInstructors[i].getArchived())
{
Instructor instructor = listOfInstructors[i];
instructor.setArchived(true);
bool result = dbLMS->updateInstructor(instructor);
if(result)
LoadInstructorsPSQL();
//listOfInstructors[i].setArchived(true);
}
}
}
void DataBaseInstructors::fromeArchiveInstructor(QString name)
{
//Инструкторы
for(int i = 0; i < listOfInstructors.count(); i++)
{
if(listOfInstructors[i].getName() == name)
if(listOfInstructors[i].getArchived())
{
Instructor instructor = listOfInstructors[i];
instructor.setArchived(false);
bool result = dbLMS->updateInstructor(instructor);
if(result)
LoadInstructorsPSQL();
//listOfInstructors[i].setArchived(false);
}
}
}
bool DataBaseInstructors::editInstructor(QString name, Instructor instructor)
{
//Инструкторы
@@ -181,7 +161,7 @@ bool DataBaseInstructors::editInstructor(QString name, Instructor instructor)
if( (!checkExistNameInstructor(instructor.getName()) || instructor.getName() == name) &&
(!checkExistLoginInstructor(instructor.getLogin()) || instructor.getLogin() == listOfInstructors[i].getLogin()) )
{
instructor.setID(listOfInstructors[i].getID());
//instructor.setID(listOfInstructors[i].getID());
bool result = dbLMS->updateInstructor(instructor);

View File

@@ -32,8 +32,6 @@ public:
QString newInstructor();
void deleteInstructor(QString name);
void toArchiveInstructor(QString name);
void fromeArchiveInstructor(QString name);
bool editInstructor(QString name, Instructor instructor);
bool isAdmin(QString name);

View File

@@ -3,7 +3,8 @@
DialogEditInstructor::DialogEditInstructor(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogEditInstructor)
ui(new Ui::DialogEditInstructor),
instructorInput()
{
ui->setupUi(this);
}
@@ -15,9 +16,12 @@ DialogEditInstructor::~DialogEditInstructor()
void DialogEditInstructor::setInstructor(Instructor instructor)
{
instructorInput = instructor;
ui->editName ->setText(instructor.getName());
ui->editLogin->setText(instructor.getLogin());
ui->editPassword->setText(instructor.getPassword());
ui->checkIsAdmin->setChecked(instructor.getIsAdmin());
ui->checkArchived->setChecked(instructor.getArchived());
ui->checkLoggedIn->setChecked(instructor.getLoggedIn());
@@ -30,10 +34,12 @@ void DialogEditInstructor::setInstructor(Instructor instructor)
Instructor DialogEditInstructor::getInstructor()
{
Instructor instructor;
Instructor instructor = instructorInput;
instructor.setName(ui->editName->text());
instructor.setLogin(ui->editLogin->text());
instructor.setPassword(ui->editPassword->text());
instructor.setIsAdmin(ui->checkIsAdmin->isChecked());
instructor.setArchived(ui->checkArchived->isChecked());
instructor.setLoggedIn(ui->checkLoggedIn->isChecked());

View File

@@ -22,6 +22,8 @@ public:
private:
Ui::DialogEditInstructor *ui;
Instructor instructorInput;
};
#endif // DIALOGEDITINSTRUCTOR_H

View File

@@ -66,18 +66,28 @@ void EditorInstructors::on_btnToOrFromArchive_clicked()
QString name = treeItemCurrent->text(0);
if(dbInstructors->isArchived(name))
Instructor instructor = dbInstructors->getInstructor(name);
if(instructor.getArchived())
{//Архивный
dbInstructors->fromeArchiveInstructor(name);
loadInstructorsFromDB();
setCurrentInstructor(name);
instructor.setArchived(false);
if(dbInstructors->editInstructor(name, instructor))
{
loadInstructorsFromDB();
setCurrentInstructor(instructor.getName());
}
}
else
{//Не Архивный
dbInstructors->toArchiveInstructor(name);
loadInstructorsFromDB();
if(archiveVisible)
setCurrentInstructor(name);
instructor.setArchived(true);
if(dbInstructors->editInstructor(name, instructor))
{
if(!archiveVisible)
ui->btnArchive->click();
loadInstructorsFromDB();
setCurrentInstructor(instructor.getName());
}
}
}
}

View File

@@ -10,9 +10,9 @@ namespace Ui {
class EditorInstructors;
}
//Диалог для просмотра и управления БД Инструкторов
//Виджет для редактирования БД Инструкторов
class EditorInstructors : /*public QDialog,*/ public InstructorsView
class EditorInstructors : public InstructorsView
{
Q_OBJECT

View File

@@ -20,14 +20,14 @@ void InstructorsView::preparationTreeWidget(QTreeWidget* tree)
reSetHeadTreeWidget();
treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 12pt;"));
treeWidget->header()->setStyleSheet(QStringLiteral("font-size: 10pt;"));
treeWidget->setColumnWidth(0, 200);
treeWidget->setColumnWidth(1, 130);
treeWidget->setColumnWidth(2, 130);
treeWidget->setColumnWidth(3, 130);
treeWidget->setColumnWidth(4, 130);
treeWidget->setColumnWidth(5, 130);
treeWidget->setColumnWidth(0, 250);
treeWidget->setColumnWidth(1, 100);
treeWidget->setColumnWidth(2, 100);
treeWidget->setColumnWidth(3, 100);
treeWidget->setColumnWidth(4, 80);
treeWidget->setColumnWidth(5, 80);
if(typeView == TypeView::onlyView)
{//onlyView

View File

@@ -12,7 +12,7 @@ class ViewerInstructors;
//Виджет только для просмотра БД Инструкторов
class INSTRUCTORSANDTRAINEES_EXPORT ViewerInstructors : /*public QWidget,*/ public InstructorsView
class INSTRUCTORSANDTRAINEES_EXPORT ViewerInstructors : public InstructorsView
{
Q_OBJECT

View File

@@ -23,6 +23,11 @@
<layout class="QHBoxLayout" name="horizontalLayout_1">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="title">
<string>Instructors</string>
</property>