mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
subprocs сохраняются в БД
This commit is contained in:
BIN
DOCS/DBschem.png
Normal file
BIN
DOCS/DBschem.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 264 KiB |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"nodes":[
|
"nodes":[
|
||||||
{"id":"e78057b035cd1b17","x":-640,"y":-460,"width":1351,"height":760,"type":"file","file":"Pasted image 20251107173042.png"}
|
{"id":"3e71087c4a5247a0","x":-1134,"y":-740,"width":1494,"height":808,"type":"file","file":"DBschem.png"}
|
||||||
],
|
],
|
||||||
"edges":[]
|
"edges":[]
|
||||||
}
|
}
|
||||||
@@ -6,16 +6,51 @@
|
|||||||
|
|
||||||
int DataBaseLMS::insertTaskAMM(TaskAmmFim task, int id_trainee)
|
int DataBaseLMS::insertTaskAMM(TaskAmmFim task, int id_trainee)
|
||||||
{
|
{
|
||||||
|
QString queryStr;
|
||||||
|
bool resBool = false;
|
||||||
|
|
||||||
|
resBool = db->transaction();
|
||||||
|
|
||||||
task.ammProcedure.title = task.ammProcedure.title.replace("'", "''"); //Задваиваем одинарные кавычки
|
task.ammProcedure.title = task.ammProcedure.title.replace("'", "''"); //Задваиваем одинарные кавычки
|
||||||
|
|
||||||
QString queryStr = QString("INSERT INTO public.tasks_amm (title, dm_code, fk_trainee_id) "
|
queryStr = QString("INSERT INTO public.tasks_amm (title, dm_code, fk_trainee_id) "
|
||||||
"VALUES ('%1', '%2', %3) "
|
"VALUES ('%1', '%2', %3) "
|
||||||
"RETURNING tasks_amm.task_id").arg(
|
"RETURNING tasks_amm.task_id").arg(
|
||||||
task.ammProcedure.title,
|
task.ammProcedure.title,
|
||||||
task.ammProcedure.dmCode,
|
task.ammProcedure.dmCode,
|
||||||
QString::number(id_trainee));
|
QString::number(id_trainee));
|
||||||
|
|
||||||
return queryExecInt(queryStr);
|
int task_id = queryExecInt(queryStr);
|
||||||
|
if(!task_id)
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(SubProc subProc : task.listSubProc)
|
||||||
|
{
|
||||||
|
subProc.setTitle(subProc.getTitle().replace("'", "''")); //Задваиваем одинарные кавычки
|
||||||
|
|
||||||
|
queryStr = QString("INSERT INTO public.subprocs (dm_code, title, canplay, fk_task_amm_id) "
|
||||||
|
"VALUES ('%1', '%2', '%3', %4) "
|
||||||
|
"RETURNING subprocs.subproc_id").arg(
|
||||||
|
subProc.getDmCode(),
|
||||||
|
subProc.getTitle(),
|
||||||
|
subProc.getModeListStr(),
|
||||||
|
QString::number(task_id));
|
||||||
|
|
||||||
|
int subproc_id = queryExecInt(queryStr);
|
||||||
|
if(!subproc_id)
|
||||||
|
{
|
||||||
|
resBool = db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resBool = db->commit();
|
||||||
|
return task_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DataBaseLMS::updateTaskAMM(TaskAmmFim task)
|
int DataBaseLMS::updateTaskAMM(TaskAmmFim task)
|
||||||
|
|||||||
Reference in New Issue
Block a user