├── .gitignore ├── CMakeLists.txt ├── CMakeLists.txt.user ├── DataBases ├── names.txt └── variants.txt ├── README.md ├── Resources ├── Fonts │ ├── Roboto-Light.ttf │ ├── Roboto-Medium.ttf │ └── Roboto-Regular.ttf └── Images │ ├── Homer-Simpson-Looking-Happy 1.png │ ├── image 1.png │ ├── image 2.png │ ├── image 5.png │ ├── image 6.png │ ├── image 7.png │ ├── image 8.png │ ├── image 9.png │ └── png-clipart-homer-simpson-bart-simpson-marge-simpson-lisa-simpson-maggie-simpson-bart-simpson-vertebrate-smiley 1.png ├── add.cpp ├── add.h ├── add.ui ├── addinformation.cpp ├── addinformation.h ├── addinformation.ui ├── backup.cpp ├── backup.h ├── backup.ui ├── correct.cpp ├── correct.h ├── correct.ui ├── create.cpp ├── create.h ├── create.ui ├── dbms.cpp ├── dbms.h ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── populate.cpp ├── populate.h ├── populate.ui ├── print.cpp ├── print.h ├── print.ui ├── printmenu.cpp ├── printmenu.h ├── printmenu.ui └── resources.qrc /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | build-DataBaseLab1-Qt_6_3_2_for_macOS-Debug/ 5 | 6 | *~ 7 | *.autosave 8 | *.a 9 | *.core 10 | *.moc 11 | *.o 12 | *.obj 13 | *.orig 14 | *.rej 15 | *.so 16 | *.so.* 17 | *_pch.h.cpp 18 | *_resource.rc 19 | *.qm 20 | .#* 21 | *.*# 22 | core 23 | !core/ 24 | tags 25 | .DS_Store 26 | .directory 27 | *.debug 28 | Makefile* 29 | *.prl 30 | *.app 31 | moc_*.cpp 32 | ui_*.h 33 | qrc_*.cpp 34 | Thumbs.db 35 | *.res 36 | *.rc 37 | /.qmake.cache 38 | /.qmake.stash 39 | 40 | # qtcreator generated files 41 | *.pro.user* 42 | 43 | # xemacs temporary files 44 | *.flc 45 | 46 | # Vim temporary files 47 | .*.swp 48 | 49 | # Visual Studio generated files 50 | *.ib_pdb_index 51 | *.idb 52 | *.ilk 53 | *.pdb 54 | *.sln 55 | *.suo 56 | *.vcproj 57 | *vcproj.*.*.user 58 | *.ncb 59 | *.sdf 60 | *.opensdf 61 | *.vcxproj 62 | *vcxproj.* 63 | 64 | # MinGW generated files 65 | *.Debug 66 | *.Release 67 | 68 | # Python byte code 69 | *.pyc 70 | 71 | # Binaries 72 | # -------- 73 | *.dll 74 | *.exe 75 | 76 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(DataBaseLab1 VERSION 0.1 LANGUAGES CXX) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | 7 | set(CMAKE_AUTOUIC ON) 8 | set(CMAKE_AUTOMOC ON) 9 | set(CMAKE_AUTORCC ON) 10 | 11 | set(CMAKE_CXX_STANDARD 17) 12 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 13 | 14 | find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) 15 | find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) 16 | 17 | set(PROJECT_SOURCES 18 | main.cpp 19 | mainwindow.cpp 20 | mainwindow.h 21 | mainwindow.ui 22 | create.cpp 23 | create.h 24 | create.ui 25 | resources.qrc 26 | dbms.cpp 27 | dbms.h 28 | populate.cpp 29 | populate.h 30 | populate.ui 31 | addinformation.cpp 32 | addinformation.h 33 | addinformation.ui 34 | add.cpp 35 | add.h 36 | add.ui 37 | correct.cpp 38 | correct.h 39 | correct.ui 40 | print.cpp 41 | print.h 42 | print.ui 43 | printmenu.cpp 44 | printmenu.h 45 | printmenu.ui 46 | backup.cpp 47 | backup.h 48 | backup.ui 49 | ) 50 | 51 | if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) 52 | qt_add_executable(DataBaseLab1 53 | MANUAL_FINALIZATION 54 | ${PROJECT_SOURCES} 55 | ) 56 | # Define target properties for Android with Qt 6 as: 57 | # set_property(TARGET DataBaseLab1 APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR 58 | # ${CMAKE_CURRENT_SOURCE_DIR}/android) 59 | # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation 60 | else() 61 | if(ANDROID) 62 | add_library(DataBaseLab1 SHARED 63 | ${PROJECT_SOURCES} 64 | ) 65 | # Define properties for Android with Qt 5 after find_package() calls as: 66 | # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") 67 | else() 68 | add_executable(DataBaseLab1 69 | ${PROJECT_SOURCES} 70 | ${CPP_SOURCES} 71 | ) 72 | endif() 73 | endif() 74 | 75 | target_link_libraries(DataBaseLab1 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) 76 | 77 | set_target_properties(DataBaseLab1 PROPERTIES 78 | MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com 79 | MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} 80 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 81 | MACOSX_BUNDLE TRUE 82 | WIN32_EXECUTABLE TRUE 83 | ) 84 | 85 | install(TARGETS DataBaseLab1 86 | BUNDLE DESTINATION . 87 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) 88 | 89 | if(QT_VERSION_MAJOR EQUAL 6) 90 | qt_finalize_executable(DataBaseLab1) 91 | endif() 92 | -------------------------------------------------------------------------------- /CMakeLists.txt.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | EnvironmentId 7 | {b2129c23-92e8-4720-9d99-a6bbb16aa623} 8 | 9 | 10 | ProjectExplorer.Project.ActiveTarget 11 | 0 12 | 13 | 14 | ProjectExplorer.Project.EditorSettings 15 | 16 | true 17 | false 18 | true 19 | 20 | Cpp 21 | 22 | CppGlobal 23 | 24 | 25 | 26 | QmlJS 27 | 28 | QmlJSGlobal 29 | 30 | 31 | 2 32 | UTF-8 33 | false 34 | 4 35 | false 36 | 80 37 | true 38 | true 39 | 1 40 | false 41 | true 42 | false 43 | 0 44 | true 45 | true 46 | 0 47 | 8 48 | true 49 | false 50 | 1 51 | true 52 | true 53 | true 54 | *.md, *.MD, Makefile 55 | false 56 | true 57 | 58 | 59 | 60 | ProjectExplorer.Project.PluginSettings 61 | 62 | 63 | true 64 | false 65 | true 66 | true 67 | true 68 | true 69 | 70 | 71 | 0 72 | true 73 | 74 | true 75 | true 76 | Builtin.DefaultTidyAndClazy 77 | 4 78 | 79 | 80 | 81 | true 82 | 83 | 84 | 85 | 86 | ProjectExplorer.Project.Target.0 87 | 88 | Desktop 89 | Qt 6.3.2 for macOS 90 | Qt 6.3.2 for macOS 91 | qt.qt6.632.clang_64_kit 92 | 0 93 | 0 94 | 0 95 | 96 | Debug 97 | -DCMAKE_GENERATOR:STRING=Ninja 98 | -DCMAKE_BUILD_TYPE:STRING=Debug 99 | -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake 100 | -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} 101 | -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} 102 | -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} 103 | -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} 104 | -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} 105 | %{CMAKE_OSX_ARCHITECTURES:DefaultFlag} 106 | 0 107 | /Users/elinakarapetan/Desktop/build-DataBase-Qt_6_3_2_for_macOS-Debug 108 | 109 | 110 | 111 | all 112 | 113 | true 114 | Сборка 115 | CMakeProjectManager.MakeStep 116 | 117 | 1 118 | Сборка 119 | Сборка 120 | ProjectExplorer.BuildSteps.Build 121 | 122 | 123 | 124 | 125 | clean 126 | 127 | true 128 | Сборка 129 | CMakeProjectManager.MakeStep 130 | 131 | 1 132 | Очистка 133 | Очистка 134 | ProjectExplorer.BuildSteps.Clean 135 | 136 | 2 137 | false 138 | 139 | false 140 | 141 | Отладка 142 | CMakeProjectManager.CMakeBuildConfiguration 143 | 144 | 145 | Release 146 | -DCMAKE_GENERATOR:STRING=Ninja 147 | -DCMAKE_BUILD_TYPE:STRING=Release 148 | -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake 149 | -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} 150 | -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} 151 | -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} 152 | -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} 153 | -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} 154 | %{CMAKE_OSX_ARCHITECTURES:DefaultFlag} 155 | /Users/elinakarapetan/Desktop/build-DataBase-Qt_6_3_2_for_macOS-Release 156 | 157 | 158 | 159 | all 160 | 161 | true 162 | CMakeProjectManager.MakeStep 163 | 164 | 1 165 | Сборка 166 | Сборка 167 | ProjectExplorer.BuildSteps.Build 168 | 169 | 170 | 171 | 172 | clean 173 | 174 | true 175 | CMakeProjectManager.MakeStep 176 | 177 | 1 178 | Очистка 179 | Очистка 180 | ProjectExplorer.BuildSteps.Clean 181 | 182 | 2 183 | false 184 | 185 | false 186 | 187 | Выпуск 188 | CMakeProjectManager.CMakeBuildConfiguration 189 | 190 | 191 | RelWithDebInfo 192 | -DCMAKE_GENERATOR:STRING=Ninja 193 | -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo 194 | -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake 195 | -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} 196 | -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} 197 | -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} 198 | -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} 199 | -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} 200 | %{CMAKE_OSX_ARCHITECTURES:DefaultFlag} 201 | /Users/elinakarapetan/Desktop/build-DataBase-Qt_6_3_2_for_macOS-RelWithDebInfo 202 | 203 | 204 | 205 | all 206 | 207 | true 208 | CMakeProjectManager.MakeStep 209 | 210 | 1 211 | Сборка 212 | Сборка 213 | ProjectExplorer.BuildSteps.Build 214 | 215 | 216 | 217 | 218 | clean 219 | 220 | true 221 | CMakeProjectManager.MakeStep 222 | 223 | 1 224 | Очистка 225 | Очистка 226 | ProjectExplorer.BuildSteps.Clean 227 | 228 | 2 229 | false 230 | 231 | false 232 | 233 | Release with Debug Information 234 | CMakeProjectManager.CMakeBuildConfiguration 235 | 236 | 237 | RelWithDebInfo 238 | -DCMAKE_GENERATOR:STRING=Ninja 239 | -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo 240 | -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake 241 | -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} 242 | -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} 243 | -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} 244 | -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} 245 | -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} 246 | %{CMAKE_OSX_ARCHITECTURES:DefaultFlag} 247 | 0 248 | /Users/elinakarapetan/Desktop/build-DataBase-Qt_6_3_2_for_macOS-Profile 249 | 250 | 251 | 252 | all 253 | 254 | true 255 | CMakeProjectManager.MakeStep 256 | 257 | 1 258 | Сборка 259 | Сборка 260 | ProjectExplorer.BuildSteps.Build 261 | 262 | 263 | 264 | 265 | clean 266 | 267 | true 268 | CMakeProjectManager.MakeStep 269 | 270 | 1 271 | Очистка 272 | Очистка 273 | ProjectExplorer.BuildSteps.Clean 274 | 275 | 2 276 | false 277 | 278 | false 279 | 280 | Profile 281 | CMakeProjectManager.CMakeBuildConfiguration 282 | 283 | 284 | MinSizeRel 285 | -DCMAKE_GENERATOR:STRING=Ninja 286 | -DCMAKE_BUILD_TYPE:STRING=MinSizeRel 287 | -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake 288 | -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} 289 | -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} 290 | -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} 291 | -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} 292 | -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} 293 | %{CMAKE_OSX_ARCHITECTURES:DefaultFlag} 294 | /Users/elinakarapetan/Desktop/build-DataBase-Qt_6_3_2_for_macOS-MinSizeRel 295 | 296 | 297 | 298 | all 299 | 300 | true 301 | CMakeProjectManager.MakeStep 302 | 303 | 1 304 | Сборка 305 | Сборка 306 | ProjectExplorer.BuildSteps.Build 307 | 308 | 309 | 310 | 311 | clean 312 | 313 | true 314 | CMakeProjectManager.MakeStep 315 | 316 | 1 317 | Очистка 318 | Очистка 319 | ProjectExplorer.BuildSteps.Clean 320 | 321 | 2 322 | false 323 | 324 | false 325 | 326 | Minimum Size Release 327 | CMakeProjectManager.CMakeBuildConfiguration 328 | 329 | 5 330 | 331 | 332 | 0 333 | Развёртывание 334 | Развёртывание 335 | ProjectExplorer.BuildSteps.Deploy 336 | 337 | 1 338 | 339 | false 340 | ProjectExplorer.DefaultDeployConfiguration 341 | 342 | 1 343 | 344 | true 345 | true 346 | true 347 | 348 | 2 349 | 350 | DataBaseLab1 351 | CMakeProjectManager.CMakeRunConfiguration.DataBaseLab1 352 | DataBaseLab1 353 | false 354 | true 355 | true 356 | false 357 | true 358 | /Users/elinakarapetan/Desktop/build-DataBase-Qt_6_3_2_for_macOS-Debug/DataBaseLab1.app/Contents/MacOS 359 | 360 | 1 361 | 362 | 363 | 364 | ProjectExplorer.Project.TargetCount 365 | 1 366 | 367 | 368 | ProjectExplorer.Project.Updater.FileVersion 369 | 22 370 | 371 | 372 | Version 373 | 22 374 | 375 | 376 | -------------------------------------------------------------------------------- /DataBases/names.txt: -------------------------------------------------------------------------------- 1 | Агеев Максим Александрович 2 | Акимов Андрей Николаевич 3 | Анохин Максим Сергеевич 4 | Антипов Юрий Валерьевич 5 | Антонов Дмитрий Алексеевич 6 | Артемьев Богдан Михайлович 7 | Бабин Кирилл Иванович 8 | Барышев Матвей Ильич 9 | Безухов Андрей Сергеевич 10 | Болотина Светлана Евгеньевна 11 | Борисова Елизавета Юрьевна 12 | Буларкиев Дастан Маратович 13 | Вавилова Дарья Григорьевна 14 | Вагин Олег Александрович 15 | Вайнер Анастасия Георгиевна 16 | Веряскин Данила Валерьевич 17 | Волков Владислав Сергеевич 18 | Волков Филипп Олегович 19 | Володин Илья Сергеевич 20 | Воропаева Надежда Артемовна 21 | Горячев Сергей Николаевич 22 | Грызлов Николай Алексеевич 23 | Даминов Руслан - 24 | Дементьев Егор Васильевич 25 | Доманский Илья Михайлович 26 | Дударев Максим Александрович 27 | Захарова Елизавета Андреевна 28 | Иванашко Анатолий Максимович 29 | Калинин Данил Вадимович 30 | Камышенков Игорь Александрович 31 | Карапетян Элина Камоевна 32 | Карпов Вадим Александрович 33 | Катаурова Анастасия - 34 | Кенегесова Екатерина - 35 | Кобызев Илья Сергеевич 36 | Козин Борис Алексеевич 37 | Коломинский Иван Федорович 38 | Комарова Юлия Андреевна 39 | Кораблева Зоя Константиновна 40 | Кравченко Илья Андреевич 41 | Кравчук Серафим Павлович 42 | Крамник Илья Михайлович 43 | Курихин Иван Владимирович 44 | Курицын Никита Александрович 45 | Курылев Владислав Сергеевич 46 | Кутузов Дмитрий Николаевич 47 | Лакеева Ольга Александровна 48 | Мамонтов Игорь - 49 | Медведев Павел Александрович 50 | Мельник Марина Васильевна 51 | Молчанов Максим Дмитриевич 52 | Муштуков Артём Вадимович 53 | Нишнючкина Алена Алексеевна 54 | Носков Илья Павлович 55 | Обрезкова Алина Андреевна 56 | Парфененков Евгений Даниилович 57 | Пестриков Антон - 58 | Петров Дмитрий Андреевич 59 | Помошников Андрей Владимирович 60 | Романов Станислав Игоревич 61 | Рябов Андрей Дмитриевич 62 | Саляев Максим Александрович 63 | Селезнев Максим Вячеславович 64 | Семенов Никита Сергеевич 65 | Сергеева Олеся Николаевна 66 | Симонова Мария Игоревна 67 | Слепнева Мария Дмитриевна 68 | Сологуб Алина Денисовна 69 | Солынин Даниил Дмитриевич 70 | Сорокин Руслан Нариманович 71 | Сорокин Всеволод Ильич 72 | Стасевич Иван Александрович 73 | Столетов Максим Олегович 74 | Стрельников Петр Викторович 75 | Султанов Руслан Аликович 76 | Сунцов Василий Андреевич 77 | Таланов Алексей Олегович 78 | Тюхменев Пётр Вячеславович 79 | Уразмахатов Отабек Айбекович 80 | Уржумцева Екатерина Владимировна 81 | Хадиев Эдем Икромович 82 | Христолюбова Наталья Васильевна 83 | Чайкин Георгий Максимович 84 | Черепанов Алексей Владимирович 85 | Чернышевский Михаил Алексеевич 86 | Шадрин Антон Альбертович 87 | Шаров Андрей Сергеевич 88 | Шаталина Юлия Юрьевна 89 | Шемановский Роман Андреевич 90 | Шеронов Данил Сергеевич 91 | Шимин Эрика Луна 92 | Шорин Юрий Игоревич 93 | Шуваев Данила Андреевич 94 | Щеглов Владислав Юрьевич -------------------------------------------------------------------------------- /DataBases/variants.txt: -------------------------------------------------------------------------------- 1 | 0 var1 2 | 1 var2 3 | 2 var3 4 | 3 var4 5 | 4 var5 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Database Management System 2 | 3 | Снимок экрана 2022-10-03 в 18 32 58 4 | Снимок экрана 2022-10-03 в 19 05 09 5 | Снимок экрана 2022-10-03 в 18 33 38 6 | -------------------------------------------------------------------------------- /Resources/Fonts/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Fonts/Roboto-Light.ttf -------------------------------------------------------------------------------- /Resources/Fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /Resources/Fonts/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Fonts/Roboto-Regular.ttf -------------------------------------------------------------------------------- /Resources/Images/Homer-Simpson-Looking-Happy 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Images/Homer-Simpson-Looking-Happy 1.png -------------------------------------------------------------------------------- /Resources/Images/image 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Images/image 1.png -------------------------------------------------------------------------------- /Resources/Images/image 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Images/image 2.png -------------------------------------------------------------------------------- /Resources/Images/image 5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Images/image 5.png -------------------------------------------------------------------------------- /Resources/Images/image 6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Images/image 6.png -------------------------------------------------------------------------------- /Resources/Images/image 7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Images/image 7.png -------------------------------------------------------------------------------- /Resources/Images/image 8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Images/image 8.png -------------------------------------------------------------------------------- /Resources/Images/image 9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Images/image 9.png -------------------------------------------------------------------------------- /Resources/Images/png-clipart-homer-simpson-bart-simpson-marge-simpson-lisa-simpson-maggie-simpson-bart-simpson-vertebrate-smiley 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EK14/DBMS/a90314c49c82c162140c59b3f0bbd9f8eb2eaccf/Resources/Images/png-clipart-homer-simpson-bart-simpson-marge-simpson-lisa-simpson-maggie-simpson-bart-simpson-vertebrate-smiley 1.png -------------------------------------------------------------------------------- /add.cpp: -------------------------------------------------------------------------------- 1 | #include "add.h" 2 | #include "ui_add.h" 3 | 4 | ADD::ADD(QWidget *parent, DBMS *dbms, QString database, int index, std::string& str): 5 | QDialog(parent), 6 | ui(new Ui::ADD) 7 | { 8 | ui->setupUi(this); 9 | this->dbms = dbms; 10 | this->parent = parent; 11 | this->database = database; 12 | this->index = index; 13 | this->type = str; 14 | ui->label->setAlignment(Qt::AlignCenter); 15 | ui->label->setStyleSheet(QString("font-size: %1px;" "color: white;").arg(18)); 16 | if(this->type == "Add student"){ 17 | ui->label->setText("Just write down the student\nyou want to add"); 18 | } 19 | else if(this->type == "Add variant") 20 | ui->label->setText("Just write down the variant\nyou want to add"); 21 | else if(this->type == "Remove student") 22 | ui->label->setText("Just write down the student\nyou want to remove"); 23 | else if(this->type == "Remove variant") 24 | ui->label->setText("Just write down the variant\nyou want to remove"); 25 | } 26 | 27 | ADD::~ADD() 28 | { 29 | delete ui; 30 | } 31 | 32 | void ADD::on_pushButton_clicked() 33 | { 34 | if(this->type == "Add student"){ 35 | QString studentName = ui->lineEdit->text(); 36 | this->dbms->addStudent(index, studentName, this); 37 | } 38 | else if(this->type == "Add variant"){ 39 | QString variantName = ui->lineEdit->text(); 40 | this->dbms->addVariant(index, variantName, this); 41 | } 42 | else if(this->type == "Remove student"){ 43 | QString variantName = ui->lineEdit->text(); 44 | this->dbms->remove(index, variantName, this, "students.txt"); 45 | } 46 | else if(this->type == "Remove variant"){ 47 | QString variantName = ui->lineEdit->text(); 48 | this->dbms->remove(index, variantName, this, "variants.txt"); 49 | } 50 | } 51 | 52 | 53 | 54 | 55 | void ADD::on_pushButton_2_clicked() 56 | { 57 | hide(); 58 | parent->show(); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /add.h: -------------------------------------------------------------------------------- 1 | #ifndef ADD_H 2 | #define ADD_H 3 | 4 | #include 5 | #include "dbms.h" 6 | 7 | namespace Ui { 8 | class ADD; 9 | } 10 | 11 | class ADD : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit ADD(QWidget *parent, DBMS *dbms, QString database, int index, std::string& str); 17 | ~ADD(); 18 | 19 | private slots: 20 | void on_pushButton_clicked(); 21 | 22 | void on_pushButton_2_clicked(); 23 | 24 | private: 25 | Ui::ADD *ui; 26 | DBMS *dbms; 27 | QWidget *parent; 28 | QString database; 29 | int index; 30 | std::string type; 31 | }; 32 | 33 | #endif // ADD_H 34 | -------------------------------------------------------------------------------- /add.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ADD 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 400 11 | 12 | 13 | 14 | 15 | 400 16 | 400 17 | 18 | 19 | 20 | 21 | 400 22 | 400 23 | 24 | 25 | 26 | Dialog 27 | 28 | 29 | 30 | 31 | 60 32 | 30 33 | 261 34 | 91 35 | 36 | 37 | 38 | 39 | 40 | 41 | color:white; 42 | 43 | 44 | <html><head/><body><p align="center"><span style=" font-size:18pt;"></span></p></body></html> 45 | 46 | 47 | 48 | 49 | 50 | 51 | background-color: white; 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 150 61 | 130 62 | 81 63 | 32 64 | 65 | 66 | 67 | background-color: white; 68 | 69 | 70 | Add 71 | 72 | 73 | 74 | 75 | 76 | 10 77 | 180 78 | 371 79 | 181 80 | 81 | 82 | 83 | 84 | 85 | 86 | :/Resources/Images/image 9.png 87 | 88 | 89 | 90 | 91 | 92 | 300 93 | 370 94 | 66 95 | 21 96 | 97 | 98 | 99 | background-color: white; 100 | 101 | 102 | Home 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /addinformation.cpp: -------------------------------------------------------------------------------- 1 | #include "addinformation.h" 2 | #include "ui_addinformation.h" 3 | 4 | AddInformation::AddInformation(QWidget *parent, DBMS *dbms): 5 | QDialog(parent), 6 | ui(new Ui::AddInformation) 7 | { 8 | ui->setupUi(this); 9 | this->dbms = dbms; 10 | this->parent = parent; 11 | this->name = ""; 12 | this->index = -1; 13 | } 14 | 15 | AddInformation::~AddInformation() 16 | { 17 | delete ui; 18 | } 19 | 20 | void AddInformation::on_pushButton_clicked() 21 | { 22 | name = ui->lineEdit->text(); 23 | this->index = this->dbms->databaseExist(name.toStdString()); 24 | if (index < 0) 25 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 26 | } 27 | 28 | 29 | void AddInformation::on_pushButton_2_clicked() 30 | { 31 | if(name == "") 32 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 33 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 34 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 35 | else{ 36 | hide(); 37 | std::string type = "Add student"; 38 | windowAdd = new ADD(parent, dbms, name, index, type); 39 | windowAdd->show(); 40 | } 41 | } 42 | 43 | 44 | void AddInformation::on_pushButton_6_clicked() 45 | { 46 | hide(); 47 | parent->show(); 48 | } 49 | 50 | 51 | void AddInformation::on_pushButton_3_clicked() 52 | { 53 | if(name == "") 54 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 55 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 56 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 57 | else{ 58 | hide(); 59 | std::string type = "Add variant"; 60 | windowAdd = new ADD(parent, dbms, name, index, type); 61 | windowAdd->show(); 62 | } 63 | } 64 | 65 | 66 | void AddInformation::on_pushButton_7_clicked() 67 | { 68 | if(name == "") 69 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 70 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 71 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 72 | else{ 73 | hide(); 74 | std::string type = "Remove student"; 75 | windowAdd = new ADD(parent, dbms, name, index, type); 76 | windowAdd->show(); 77 | } 78 | } 79 | 80 | 81 | void AddInformation::on_pushButton_8_clicked() 82 | { 83 | if(name == "") 84 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 85 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 86 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 87 | else{ 88 | hide(); 89 | std::string type = "Remove variant"; 90 | windowAdd = new ADD(parent, dbms, name, index, type); 91 | windowAdd->show(); 92 | } 93 | } 94 | 95 | 96 | void AddInformation::on_pushButton_4_clicked() 97 | { 98 | if(name == "") 99 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 100 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 101 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 102 | else{ 103 | hide(); 104 | std::string file = "students.txt"; 105 | std::string type = "Correct"; 106 | windowCorrection = new Correct(parent, dbms, index, file, type); 107 | windowCorrection->show(); 108 | } 109 | } 110 | 111 | void AddInformation::on_pushButton_5_clicked() 112 | { 113 | if(name == "") 114 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 115 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 116 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 117 | else{ 118 | hide(); 119 | std::string file = "variants.txt"; 120 | std::string type = "Correct"; 121 | windowCorrection = new Correct(parent, dbms, index, file, type); 122 | windowCorrection->show(); 123 | } 124 | } 125 | 126 | -------------------------------------------------------------------------------- /addinformation.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDINFORMATION_H 2 | #define ADDINFORMATION_H 3 | 4 | #include 5 | #include "dbms.h" 6 | #include "add.h" 7 | #include "correct.h" 8 | #include 9 | 10 | namespace Ui { 11 | class AddInformation; 12 | } 13 | 14 | class AddInformation : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit AddInformation(QWidget *parent, DBMS *dbms); 20 | ~AddInformation(); 21 | 22 | private slots: 23 | void on_pushButton_clicked(); 24 | 25 | void on_pushButton_2_clicked(); 26 | 27 | void on_pushButton_6_clicked(); 28 | 29 | void on_pushButton_3_clicked(); 30 | 31 | void on_pushButton_7_clicked(); 32 | 33 | void on_pushButton_8_clicked(); 34 | 35 | void on_pushButton_4_clicked(); 36 | 37 | void on_pushButton_5_clicked(); 38 | 39 | private: 40 | Ui::AddInformation *ui; 41 | DBMS *dbms; 42 | QWidget *parent; 43 | QString name; 44 | ADD *windowAdd; 45 | Correct *windowCorrection; 46 | int index; 47 | }; 48 | 49 | #endif // ADDINFORMATION_H 50 | -------------------------------------------------------------------------------- /addinformation.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | AddInformation 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 400 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 60 20 | 10 21 | 271 22 | 61 23 | 24 | 25 | 26 | <html><head/><body><p><br/></p></body></html> 27 | 28 | 29 | color: white; 30 | 31 | 32 | <html><head/><body><p align="center"><span style=" font-size:18pt;">Okay, you don’t like my table, right?<br/>I don’t care, do whatever you want!</span></p></body></html> 33 | 34 | 35 | 36 | 37 | 38 | 80 39 | 240 40 | 241 41 | 151 42 | 43 | 44 | 45 | 46 | 47 | 48 | :/Resources/Images/image 8.png 49 | 50 | 51 | 52 | 53 | 54 | 330 55 | 360 56 | 61 57 | 32 58 | 59 | 60 | 61 | background-color: white; 62 | 63 | 64 | Home 65 | 66 | 67 | 68 | 69 | 70 | 50 71 | 70 72 | 301 73 | 35 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | color: white; 83 | 84 | 85 | DataBase name: 86 | 87 | 88 | 89 | 90 | 91 | 92 | true 93 | 94 | 95 | background-color: white; 96 | 97 | 98 | 99 | 100 | 101 | 102 | background-color: white; 103 | 104 | 105 | Enter 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 10 117 | 110 118 | 381 119 | 118 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | background-color: white; 129 | 130 | 131 | Add a student 132 | 133 | 134 | 135 | 136 | 137 | 138 | background-color: white; 139 | 140 | 141 | Add a variant 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | background-color: white; 153 | 154 | 155 | Remove a student 156 | 157 | 158 | 159 | 160 | 161 | 162 | background-color: white; 163 | 164 | 165 | Remove a variant 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | background-color: white; 177 | 178 | 179 | Correct the student name 180 | 181 | 182 | 183 | 184 | 185 | 186 | background-color: white; 187 | 188 | 189 | Correct the variant name 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | -------------------------------------------------------------------------------- /backup.cpp: -------------------------------------------------------------------------------- 1 | #include "backup.h" 2 | #include "ui_backup.h" 3 | namespace fs = std::__fs::filesystem; 4 | 5 | BackUp::BackUp(QWidget *parent, DBMS *dbms): 6 | QDialog(parent), 7 | ui(new Ui::BackUp) 8 | { 9 | ui->setupUi(this); 10 | this->dbms = dbms; 11 | this->parent = parent; 12 | } 13 | 14 | BackUp::~BackUp() 15 | { 16 | delete ui; 17 | } 18 | 19 | // Get current date/time, format is YYYY-MM-DD.HH:mm:ss 20 | const std::string currentDateTime() { 21 | time_t now = time(0); 22 | struct tm tstruct; 23 | char buf[80]; 24 | tstruct = *localtime(&now); 25 | // Visit http://en.cppreference.com/w/cpp/chrono/c/strftime 26 | // for more information about date/time format 27 | strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct); 28 | 29 | return buf; 30 | } 31 | 32 | void BackUp::on_pushButton_clicked() 33 | { 34 | QString name = ui->lineEdit->text(); 35 | int index = this->dbms->databaseExist(name.toStdString()); 36 | if (index >= 0){ 37 | std::string data = currentDateTime(); 38 | const std::string find = ":"; 39 | const std::string repl = "\\"; 40 | 41 | size_t pos = 0; 42 | for (;;) 43 | { 44 | pos = data.find(find, pos); 45 | if (pos == std::string::npos) 46 | break; 47 | 48 | data.replace(pos, find.size(), repl); 49 | pos += repl.size(); 50 | } 51 | std::string stringName = name.toStdString(); 52 | std::string backUpName = "backup_" +stringName + "_" + data; 53 | mkdir(("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + backUpName).c_str(), 0777);//create an empty database 54 | fs::copy("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + name.toStdString() + "/", "/Users/elinakarapetan/Desktop/DataBase/DataBases/" + backUpName + "/"); 55 | this->dbms->databases.push_back(backUpName); 56 | }else 57 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 58 | } 59 | 60 | 61 | void BackUp::on_pushButton_2_clicked() 62 | { 63 | hide(); 64 | parent->show(); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /backup.h: -------------------------------------------------------------------------------- 1 | #ifndef BACKUP_H 2 | #define BACKUP_H 3 | 4 | #include 5 | #include "dbms.h" 6 | 7 | namespace Ui { 8 | class BackUp; 9 | } 10 | 11 | class BackUp : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit BackUp(QWidget *parent, DBMS *dbms); 17 | ~BackUp(); 18 | 19 | private slots: 20 | void on_pushButton_clicked(); 21 | 22 | void on_pushButton_2_clicked(); 23 | 24 | private: 25 | Ui::BackUp *ui; 26 | DBMS *dbms; 27 | QWidget *parent; 28 | }; 29 | 30 | #endif // BACKUP_H 31 | -------------------------------------------------------------------------------- /backup.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | BackUp 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 400 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 40 20 | 30 21 | 311 22 | 51 23 | 24 | 25 | 26 | color: white; 27 | 28 | 29 | <html><head/><body><p align="center"><span style=" font-size:18pt;">Please, enter the name of the database<br/>you want to back-up</span></p></body></html> 30 | 31 | 32 | 33 | 34 | 35 | 50 36 | 90 37 | 291 38 | 21 39 | 40 | 41 | 42 | background-color: white; 43 | 44 | 45 | 46 | 47 | 48 | 140 49 | 120 50 | 100 51 | 32 52 | 53 | 54 | 55 | background-color: white; 56 | 57 | 58 | Enter 59 | 60 | 61 | 62 | 63 | 64 | 290 65 | 350 66 | 100 67 | 32 68 | 69 | 70 | 71 | background-color: white; 72 | 73 | 74 | Home 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /correct.cpp: -------------------------------------------------------------------------------- 1 | #include "correct.h" 2 | #include "ui_correct.h" 3 | 4 | Correct::Correct(QWidget *parent, DBMS *dbms, int index, std::string& file, std::string& type): 5 | QDialog(parent), 6 | ui(new Ui::Correct) 7 | { 8 | ui->setupUi(this); 9 | this->dbms = dbms; 10 | this->parent = parent; 11 | this->index = index; 12 | this->nameToCorrect = ""; 13 | this->correctedName = ""; 14 | this->canBeCorrected = false; 15 | this->type = type; 16 | this->file = file; 17 | this->id = -1; 18 | } 19 | 20 | Correct::~Correct() 21 | { 22 | delete ui; 23 | } 24 | 25 | void Correct::on_pushButton_clicked() 26 | { 27 | QString name = ui->lineEdit->text(); 28 | this->id = this->dbms->checkUp(this, index, name, file, type); 29 | if(id != -1) 30 | this->nameToCorrect = name; 31 | else 32 | QMessageBox::critical(parent, "Заголовок", "This name is not listed in the table\n"); 33 | } 34 | 35 | 36 | void Correct::on_pushButton_2_clicked() 37 | { 38 | QString name = ui->lineEdit_2->text(); 39 | if(name == ""){ 40 | QMessageBox::critical(parent, "Заголовок", "Please, enter the name you want to change to\n"); 41 | } 42 | else if(this->nameToCorrect == "") 43 | QMessageBox::critical(parent, "Заголовок", "Please, enter the name you want to correct\n"); 44 | else if(this->dbms->checkUp(this, index, name, file, type) != -1) 45 | { 46 | QMessageBox::critical(parent, "Заголовок", "This name is already listed in the table. Please, try another one.\n"); 47 | } 48 | else{ 49 | correctedName = name; 50 | } 51 | } 52 | 53 | 54 | void Correct::on_pushButton_4_clicked() 55 | { 56 | if(correctedName != "" && nameToCorrect != ""){ 57 | this->dbms->correction(this, id, nameToCorrect, correctedName, type, index); 58 | on_pushButton_3_clicked(); 59 | } 60 | else if(nameToCorrect == "") 61 | QMessageBox::critical(parent, "Заголовок", "Please, enter the name you want to correct\n"); 62 | else if(correctedName == "") 63 | QMessageBox::critical(parent, "Заголовок", "Please, enter the name you want to change to\n"); 64 | else if(this->dbms->checkUp(this, index, correctedName, file, type) != -1) 65 | QMessageBox::critical(parent, "Заголовок", "This name is already listed in the table. Please, try another one.\n"); 66 | } 67 | 68 | 69 | void Correct::on_pushButton_3_clicked() 70 | { 71 | hide(); 72 | parent->show(); 73 | } 74 | 75 | -------------------------------------------------------------------------------- /correct.h: -------------------------------------------------------------------------------- 1 | #ifndef CORRECT_H 2 | #define CORRECT_H 3 | 4 | #include 5 | #include "dbms.h" 6 | 7 | namespace Ui { 8 | class Correct; 9 | } 10 | 11 | class Correct : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Correct(QWidget *parent, DBMS *dbms, int index, std::string& file, std::string& type); 17 | ~Correct(); 18 | 19 | private slots: 20 | void on_pushButton_clicked(); 21 | 22 | void on_pushButton_2_clicked(); 23 | 24 | void on_pushButton_4_clicked(); 25 | 26 | void on_pushButton_3_clicked(); 27 | 28 | private: 29 | Ui::Correct *ui; 30 | DBMS *dbms; 31 | QWidget *parent; 32 | QString nameToCorrect; 33 | QString correctedName; 34 | int index; 35 | bool canBeCorrected; 36 | std::string type; 37 | int id; 38 | std::string file; 39 | }; 40 | 41 | #endif // CORRECT_H 42 | -------------------------------------------------------------------------------- /correct.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Correct 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 50 20 | 130 21 | 281 22 | 121 23 | 24 | 25 | 26 | 27 | 28 | 29 | Qt::Vertical 30 | 31 | 32 | 33 | 20 34 | 40 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | <html><head/><body><p align="center">Please, enter the name you want<br/>to change to</p></body></html> 47 | 48 | 49 | 50 | 51 | 52 | 53 | background-color: white; 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | Qt::Horizontal 67 | 68 | 69 | 70 | 40 71 | 20 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | background-color: white; 80 | 81 | 82 | PushButton 83 | 84 | 85 | 86 | 87 | 88 | 89 | Qt::Horizontal 90 | 91 | 92 | 93 | 40 94 | 20 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 340 107 | 260 108 | 51 109 | 32 110 | 111 | 112 | 113 | Home 114 | 115 | 116 | 117 | 118 | 119 | 50 120 | 0 121 | 281 122 | 121 123 | 124 | 125 | 126 | 127 | 128 | 129 | Qt::Vertical 130 | 131 | 132 | 133 | 20 134 | 40 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | <html><head/><body><p align="center">Please, enter the name <br/>you want to change</p></body></html> 147 | 148 | 149 | 150 | 151 | 152 | 153 | background-color: white; 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | Qt::Horizontal 167 | 168 | 169 | 170 | 40 171 | 20 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | background-color: white; 180 | 181 | 182 | PushButton 183 | 184 | 185 | 186 | 187 | 188 | 189 | Qt::Horizontal 190 | 191 | 192 | 193 | 40 194 | 20 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 50 207 | 260 208 | 281 209 | 32 210 | 211 | 212 | 213 | background-color: white; 214 | 215 | 216 | Correct 217 | 218 | 219 | 220 | 221 | 222 | 223 | -------------------------------------------------------------------------------- /create.cpp: -------------------------------------------------------------------------------- 1 | #include "create.h" 2 | #include "ui_create.h" 3 | #include "QMessageBox" 4 | 5 | Create::Create(QWidget *parent, DBMS *dbms) : 6 | QDialog(parent), 7 | ui(new Ui::Create) 8 | { 9 | ui->setupUi(this); 10 | setStyleSheet("background:rgb(102, 103, 171);"); 11 | this->dbms = dbms; 12 | this->parent = parent; 13 | } 14 | 15 | Create::~Create() 16 | { 17 | delete ui; 18 | } 19 | 20 | void Create::on_pushButton_clicked() 21 | { 22 | QString name = ui->lineEdit->text(); 23 | if(this->dbms->databaseExist(name.toStdString()) < 0){ 24 | this->dbms->databases.push_back(name.toStdString()); // add database name to DBSM 25 | mkdir(("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + name.toStdString()).c_str(), 0777);//create an empty database 26 | } 27 | else{ 28 | QMessageBox::critical(this,"Заголовок", "A database with the same name already exists\n"); 29 | } 30 | on_pushButton_2_clicked(); 31 | } 32 | 33 | 34 | void Create::on_pushButton_2_clicked() 35 | { 36 | hide(); 37 | parent->show(); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /create.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATE_H 2 | #define CREATE_H 3 | 4 | #include 5 | #include "dbms.h" 6 | 7 | namespace Ui { 8 | class Create; 9 | } 10 | 11 | class Create : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Create(QWidget *parent, DBMS *dbms); 17 | ~Create(); 18 | 19 | private slots: 20 | void on_pushButton_clicked(); 21 | 22 | void on_pushButton_2_clicked(); 23 | 24 | private: 25 | Ui::Create *ui; 26 | DBMS *dbms; 27 | QWidget *parent; 28 | }; 29 | 30 | #endif // CREATE_H 31 | -------------------------------------------------------------------------------- /create.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Create 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 400 11 | 12 | 13 | 14 | 15 | 400 16 | 400 17 | 18 | 19 | 20 | 21 | 400 22 | 400 23 | 24 | 25 | 26 | 27 | 400 28 | 400 29 | 30 | 31 | 32 | Create 33 | 34 | 35 | 36 | 37 | 20 38 | 20 39 | 361 40 | 31 41 | 42 | 43 | 44 | color: white; 45 | 46 | 47 | <html><head/><body><p><span style=" font-size:24pt;">Неу you! Enter the database name!</span></p></body></html> 48 | 49 | 50 | 51 | 52 | 53 | 160 54 | 120 55 | 231 56 | 211 57 | 58 | 59 | 60 | 61 | 62 | 63 | :/Resources/Images/png-clipart-homer-simpson-bart-simpson-marge-simpson-lisa-simpson-maggie-simpson-bart-simpson-vertebrate-smiley 1.png 64 | 65 | 66 | 67 | 68 | 69 | 20 70 | 120 71 | 171 72 | 291 73 | 74 | 75 | 76 | 77 | 78 | 79 | :/Resources/Images/image 1.png 80 | 81 | 82 | 83 | 84 | 85 | 120 86 | 60 87 | 151 88 | 58 89 | 90 | 91 | 92 | 93 | 94 | 95 | background-color: white; 96 | 97 | 98 | 99 | 100 | 101 | 102 | background-color: white; 103 | 104 | 105 | Create 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 290 115 | 370 116 | 100 117 | 21 118 | 119 | 120 | 121 | background-color: white; 122 | 123 | 124 | Home 125 | 126 | 127 | layoutWidget 128 | label_2 129 | label_3 130 | label 131 | pushButton_2 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /dbms.cpp: -------------------------------------------------------------------------------- 1 | #include "dbms.h" 2 | #include 3 | 4 | namespace fs = std::__fs::filesystem; 5 | DBMS::DBMS() { 6 | 7 | } 8 | 9 | void DBMS::generateID(int index) { 10 | int i = 0; 11 | std::ofstream f1; 12 | f1.open("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/students.txt"); 13 | std::ifstream f2("/Users/elinakarapetan/Desktop/DataBase/DataBases/names.txt"); 14 | for (std::string word; getline(f2, word);){ // add ID's 15 | word = std::to_string(i) + " " + word + '\n'; 16 | f1 << word; 17 | i+=1; 18 | } 19 | } 20 | 21 | void DBMS::transferInformation() { 22 | 23 | } 24 | 25 | int DBMS::databaseExist(std::string database) { 26 | for(int i = 0; i < databases.size(); i++){ // checking if a database with the given name exists 27 | if(QString::fromUtf8(databases[i].c_str()) == QString::fromUtf8(database.c_str())) 28 | return i; 29 | } 30 | return -1; 31 | } 32 | 33 | void DBMS::populateDatabase(int index) { 34 | generateID(index); 35 | copyInitData(index); 36 | testingTable(index); 37 | } 38 | 39 | void DBMS::copyInitData(int index) { 40 | fs::remove("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/names.txt"); 41 | fs::remove("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/variants.txt"); 42 | fs::copy("/Users/elinakarapetan/Desktop/DataBase/DataBases/names.txt", "/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/"); 43 | fs::copy("/Users/elinakarapetan/Desktop/DataBase/DataBases/variants.txt", "/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/"); 44 | } 45 | 46 | void DBMS::testingTable(int index) { 47 | std::vector variants(0); 48 | std::ofstream f1; 49 | std::ifstream f2("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/variants.txt"); 50 | std::ifstream f3("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/students.txt"); 51 | f1.open("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/testingTable.txt"); 52 | for(std::string word; getline(f2, word);){ 53 | if(word == "\n") 54 | break; 55 | word.erase(word.find_first_of(' ',0), word.size()-1); 56 | variants.push_back(word); 57 | } 58 | for(std::string word; getline(f3, word);){ 59 | word.erase(word.find_first_of(' ',0), word.size()-1); 60 | word += " " + variants[rand() % variants.size()] + "\n"; 61 | f1 << word; 62 | } 63 | } 64 | 65 | void DBMS::addStudent(int index, QString name, QWidget *parent){ 66 | std::string filename = "students.txt"; 67 | int lastID = checkString(index, name, &filename, "Add"); 68 | std::ofstream f1; 69 | f1.open("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/students.txt", std::ios::app); 70 | if(lastID < 0){ 71 | QMessageBox::critical(parent, "Заголовок", "This student is already listed in the table\n"); 72 | } 73 | else{ 74 | f1 << (lastID + 1); 75 | f1 << name.toStdString() + "\n"; 76 | } 77 | f1.close(); 78 | } 79 | 80 | int DBMS::checkString(int index, QString& str, std::string* s, std::string type) { 81 | std::string filename = *s; 82 | std::ifstream file("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/" + filename); 83 | std::string information; 84 | std::string name = ""; 85 | int lastId; 86 | int count = 0; 87 | str = " " + str; 88 | for(std::string id; file >> id;){ 89 | count++; 90 | if(*s == "students.txt"){ 91 | for(int j = 0; j < 3; j++){ 92 | file >> information; 93 | name += " " + information; 94 | } 95 | } 96 | else{ 97 | file >> information; 98 | name += " " + information; 99 | } 100 | if(QString::fromStdString(name) == str){ 101 | file.close(); 102 | if(type == "Add") 103 | return -1; 104 | else if(type == "Remove") 105 | return count; 106 | else if(type == "Correct" || type == "Print student" || type == "Print variant") 107 | return stoi(id); 108 | } 109 | lastId = stoi(id); 110 | name = ""; 111 | } 112 | file.close(); 113 | if(type == "Add") 114 | return lastId; 115 | else if(type == "Remove" || type == "Correct" || type == "Print student" || type == "Print variant") 116 | return -1; 117 | } 118 | 119 | void DBMS::addVariant(int index, QString name, QWidget *parent){ 120 | std::string filename = "variants.txt"; 121 | int lastID = checkString(index, name, &filename, "Add"); 122 | std::ofstream f1; 123 | f1.open("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/variants.txt", std::ios::app); 124 | if(lastID < 0){ 125 | QMessageBox::critical(parent, "Заголовок", "This variant is already listed in the table\n"); 126 | } 127 | else{ 128 | f1 << (lastID + 1); 129 | f1 << name.toStdString() + "\n"; 130 | } 131 | f1.close(); 132 | } 133 | 134 | void DBMS::remove(int index, QString name, QWidget *parent, std::string s){ 135 | std::string filename = s; 136 | int lineToRemove = checkString(index, name, &filename, "Remove"); 137 | if(lineToRemove == -1){ 138 | QMessageBox::critical(parent, "Заголовок", "There is no student/variant with this name\n"); 139 | return; 140 | } 141 | std::ifstream file("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/" + filename); 142 | std::string line; 143 | std::string text; 144 | int amountStr = 0; 145 | while(getline(file,line)) 146 | { 147 | amountStr++; 148 | 149 | if(!(amountStr == lineToRemove)) 150 | { 151 | text.insert(text.size(),line); 152 | text.insert(text.size(),"\n"); 153 | } 154 | } 155 | file.close(); 156 | std::ofstream file_out; 157 | 158 | file_out.open ("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/" + filename,std::ios::trunc | std::ios::binary); 159 | 160 | file_out.write(text.c_str(), text.size()); 161 | file_out.clear(); 162 | file_out.close(); 163 | } 164 | 165 | void DBMS::correction(QWidget *parent, int id, QString nameToCorrect, QString correctedName, std::string s, int index){ 166 | std::ifstream file("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/" + s); 167 | std::string line; 168 | std::string text = ""; 169 | int amountStr = 0; 170 | while(getline(file,line)) 171 | { 172 | std::string name = line; 173 | std::string id_from_line = line.erase(line.find_first_of(' ',0), line.size()-1); 174 | if(id_from_line == std::to_string(id)){ 175 | text.insert(text.size(),id_from_line + " " + correctedName.toStdString()); 176 | text.insert(text.size(),"\n"); 177 | } 178 | else{ 179 | text.insert(text.size(),name); 180 | text.insert(text.size(),"\n"); 181 | } 182 | } 183 | file.close(); 184 | std::ofstream file_out; 185 | 186 | file_out.open ("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/" + s,std::ios::trunc | std::ios::binary); 187 | 188 | file_out.write(text.c_str(), text.size()); 189 | file_out.clear(); 190 | file_out.close(); 191 | } 192 | 193 | int DBMS::checkUp(QWidget *parent, int index, QString nameToCorrect, std::string file, std::string type){ 194 | return checkString(index, nameToCorrect, &file, type); 195 | } 196 | 197 | 198 | void DBMS::print(int id, std::string type, int index, std::string& str){ 199 | std::ifstream file("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + databases[index] + "/" + type); 200 | std::string line; 201 | while(getline(file, line)) 202 | { 203 | std::string name = line; 204 | std::string id_from_line = line.erase(line.find_first_of(' ',0), line.size()-1); 205 | name.erase(name.cbegin(), name.cbegin() + name.find_first_of(' ', 0) + 1); 206 | if(id_from_line == std::to_string(id)){ 207 | str = name; 208 | } 209 | } 210 | } 211 | 212 | int DBMS::checkID(QWidget *parent, int index, QString ID, std::string filename, std::string type){ 213 | std::ifstream file("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + this->databases[index] + "/" + filename); 214 | for(std::string id; file >> id;){ 215 | if(ID.toStdString() == id) 216 | return stoi(id); 217 | } 218 | return -1; 219 | } 220 | -------------------------------------------------------------------------------- /dbms.h: -------------------------------------------------------------------------------- 1 | #ifndef DBMS_H 2 | #define DBMS_H 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | class DBMS { 15 | public: 16 | DBMS(); 17 | std::vector databases; 18 | void addVariant(int index, QString name, QWidget *parent); 19 | void addStudent(int index, QString name, QWidget *parent); 20 | void remove(int index, QString name, QWidget *parent, std::string s); 21 | void update(); 22 | void correction(QWidget *parent, int id, QString nameToCorrect, QString correctedName, std::string s, int index); 23 | int databaseExist(std::string database); 24 | void populateDatabase(int index); 25 | int checkUp(QWidget *parent, int index, QString nameToCorrect, std::string s, std::string type); 26 | void print(int id, std::string type, int index, std::string& str); 27 | int checkID(QWidget *parent, int index, QString nameToCorrect, std::string filename, std::string type); 28 | 29 | private: 30 | void generateID(int index); 31 | void testingTable(int index); 32 | void copyInitData(int index); 33 | int checkString(int index, QString& str, std::string* s, std::string type); 34 | void transferInformation(); 35 | int findID(); 36 | }; 37 | 38 | #endif // DBMS_H 39 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | #include 4 | #include 5 | #include "dbms.h" 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | DBMS dbms; 10 | QApplication a(argc, argv); 11 | MainWindow w(nullptr, &dbms); 12 | w.show(); 13 | return a.exec(); 14 | } 15 | -------------------------------------------------------------------------------- /mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | MainWindow::MainWindow(QWidget *parent, DBMS *dbms) 5 | : QMainWindow(parent) 6 | , ui(new Ui::MainWindow) 7 | { 8 | ui->setupUi(this); 9 | this->dbms = dbms; 10 | setStyleSheet("background:rgb(102, 103, 171);"); 11 | } 12 | 13 | MainWindow::~MainWindow() 14 | { 15 | delete ui; 16 | } 17 | 18 | 19 | void MainWindow::on_pushButton_2_clicked() 20 | { 21 | hide(); 22 | windowCreate = new Create(this, dbms); 23 | windowCreate->show(); 24 | } 25 | 26 | 27 | void MainWindow::on_pushButton_clicked() 28 | { 29 | hide(); 30 | windowPopulate = new Populate(this, dbms); 31 | windowPopulate->show(); 32 | } 33 | 34 | 35 | void MainWindow::on_pushButton_3_clicked() 36 | { 37 | hide(); 38 | windowChange = new AddInformation(this, dbms); 39 | windowChange->show(); 40 | } 41 | 42 | 43 | void MainWindow::on_pushButton_4_clicked() 44 | { 45 | hide(); 46 | windowPrint = new PrintMenu(this, dbms); 47 | windowPrint->show(); 48 | } 49 | 50 | 51 | void MainWindow::on_pushButton_5_clicked() 52 | { 53 | hide(); 54 | windowBackup = new BackUp(this, dbms); 55 | windowBackup->show(); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include "dbms.h" 6 | #include "create.h" 7 | #include "populate.h" 8 | #include "addinformation.h" 9 | #include "printmenu.h" 10 | #include "backup.h" 11 | 12 | QT_BEGIN_NAMESPACE 13 | namespace Ui { class MainWindow; } 14 | QT_END_NAMESPACE 15 | 16 | class MainWindow : public QMainWindow 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | MainWindow(QWidget *parent, DBMS *dbms); 22 | ~MainWindow(); 23 | 24 | private slots: 25 | void on_pushButton_2_clicked(); 26 | 27 | void on_pushButton_clicked(); 28 | 29 | void on_pushButton_3_clicked(); 30 | 31 | void on_pushButton_4_clicked(); 32 | 33 | void on_pushButton_5_clicked(); 34 | 35 | private: 36 | Ui::MainWindow *ui; 37 | DBMS *dbms; 38 | Create *windowCreate; 39 | Populate *windowPopulate; 40 | AddInformation *windowChange; 41 | PrintMenu *windowPrint; 42 | BackUp *windowBackup; 43 | }; 44 | #endif // MAINWINDOW_H 45 | -------------------------------------------------------------------------------- /mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | true 7 | 8 | 9 | 10 | 0 11 | 0 12 | 400 13 | 400 14 | 15 | 16 | 17 | 18 | 400 19 | 400 20 | 21 | 22 | 23 | 24 | 400 25 | 400 26 | 27 | 28 | 29 | Menu 30 | 31 | 32 | 33 | 34 | 35 | 50 36 | 10 37 | 301 38 | 31 39 | 40 | 41 | 42 | <html><head/><body><p><span style=" color:#ffffff;">What do you want from me?!</span></p></body></html> 43 | 44 | 45 | color: white; 46 | 47 | 48 | <html><head/><body><p><span style=" font-size:24pt;">What do you want from me?!</span></p></body></html> 49 | 50 | 51 | label 52 | 53 | 54 | 55 | 56 | 57 | 110 58 | 48 59 | 170 60 | 24 61 | 62 | 63 | 64 | background-color: white; 65 | 66 | 67 | Create a database 68 | 69 | 70 | 71 | 72 | 73 | 110 74 | 99 75 | 170 76 | 24 77 | 78 | 79 | 80 | background-color: white; 81 | 82 | 83 | Add information 84 | 85 | 86 | 87 | 88 | 89 | 110 90 | 125 91 | 170 92 | 23 93 | 94 | 95 | 96 | background-color: white; 97 | 98 | 99 | Print 100 | 101 | 102 | 103 | 104 | 105 | 110 106 | 150 107 | 171 108 | 21 109 | 110 | 111 | 112 | background-color: white; 113 | 114 | 115 | Create a back-up 116 | 117 | 118 | 119 | 120 | 121 | 40 122 | 170 123 | 431 124 | 231 125 | 126 | 127 | 128 | 129 | 130 | 131 | :/Resources/Images/image 2.png 132 | 133 | 134 | 135 | 136 | 137 | 110 138 | 74 139 | 170 140 | 23 141 | 142 | 143 | 144 | background-color: white; 145 | 146 | 147 | Populate the database 148 | 149 | 150 | pushButton_4 151 | pushButton_2 152 | pushButton 153 | pushButton_3 154 | pushButton_5 155 | label 156 | label_2 157 | 158 | 159 | 160 | 161 | 0 162 | 0 163 | 400 164 | 22 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /populate.cpp: -------------------------------------------------------------------------------- 1 | #include "populate.h" 2 | #include "ui_populate.h" 3 | #include "QMessageBox" 4 | 5 | Populate::Populate(QWidget *parent, DBMS *dbms) : 6 | QDialog(parent), 7 | ui(new Ui::Populate) 8 | { 9 | ui->setupUi(this); 10 | setStyleSheet("background:rgb(102, 103, 171);"); 11 | this->dbms = dbms; 12 | this->parent = parent; 13 | } 14 | 15 | Populate::~Populate() 16 | { 17 | delete ui; 18 | } 19 | 20 | void Populate::on_pushButton_clicked() 21 | { 22 | QString name = ui->lineEdit->text(); 23 | int index = this->dbms->databaseExist(name.toStdString()); 24 | if (index >= 0){ 25 | this->dbms->populateDatabase(index); 26 | }else 27 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 28 | on_pushButton_2_clicked(); 29 | } 30 | 31 | 32 | void Populate::on_pushButton_2_clicked() 33 | { 34 | parent->show(); 35 | hide(); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /populate.h: -------------------------------------------------------------------------------- 1 | #ifndef POPULATE_H 2 | #define POPULATE_H 3 | 4 | #include 5 | #include "dbms.h" 6 | 7 | namespace Ui { 8 | class Populate; 9 | } 10 | 11 | class Populate : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Populate(QWidget *parent, DBMS *dbms); 17 | ~Populate(); 18 | 19 | private slots: 20 | void on_pushButton_clicked(); 21 | 22 | void on_pushButton_2_clicked(); 23 | 24 | private: 25 | Ui::Populate *ui; 26 | DBMS *dbms; 27 | QWidget *parent; 28 | }; 29 | 30 | #endif // POPULATE_H 31 | -------------------------------------------------------------------------------- /populate.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Populate 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 400 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 30 20 | 0 21 | 331 22 | 111 23 | 24 | 25 | 26 | color: white; 27 | 28 | 29 | <html><head/><body><p align="center">Look, please, enter the name<br/>of the database you want to <br/>populate and no one gets <br/>hurt, okay?</p></body></html> 30 | 31 | 32 | 33 | 34 | 35 | 290 36 | 360 37 | 100 38 | 32 39 | 40 | 41 | 42 | background-color: white; 43 | 44 | 45 | Home 46 | 47 | 48 | 49 | 50 | 51 | 70 52 | 100 53 | 257 54 | 256 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | background-color: white; 64 | 65 | 66 | 67 | 68 | 69 | 70 | background-color: white; 71 | 72 | 73 | Enter 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | :/Resources/Images/image 5.png 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /print.cpp: -------------------------------------------------------------------------------- 1 | #include "print.h" 2 | #include "ui_print.h" 3 | 4 | Print::Print(QWidget *parent, int index, std::string type, DBMS *dbms, std::string text): 5 | QDialog(parent), 6 | ui(new Ui::Print) 7 | { 8 | ui->setupUi(this); 9 | this->parent = parent; 10 | this->index = index; 11 | this->type = type; 12 | this->dbms = dbms; 13 | if(type == "Print student" || type == "Print variant"){ 14 | QString output = QString::fromUtf8(text.c_str()); 15 | ui->listWidget->addItem(output); 16 | } 17 | else if(type == "Print students"){ 18 | std::string line; 19 | std::ifstream file("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + this->dbms->databases[index] + "/students.txt"); 20 | while(getline(file, line)){ 21 | QString output = QString::fromUtf8(line.c_str()); 22 | ui->listWidget->addItem(output); 23 | } 24 | } 25 | else if(type == "Print variants"){ 26 | std::string line; 27 | std::ifstream file("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + this->dbms->databases[index] + "/variants.txt"); 28 | while(getline(file, line)){ 29 | QString output = QString::fromUtf8(line.c_str()); 30 | ui->listWidget->addItem(output); 31 | } 32 | } 33 | else if(type == "Testing Table"){ 34 | QString output; 35 | std::string name; 36 | std::string surname; 37 | std::string patronymic; 38 | std::string variant; 39 | std::ifstream f1("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + this->dbms->databases[index] + "/testingTable.txt"); 40 | std::ifstream f2("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + this->dbms->databases[index] + "/variants.txt"); 41 | std::ifstream f3("/Users/elinakarapetan/Desktop/DataBase/DataBases/" + this->dbms->databases[index] + "/students.txt"); 42 | for(std::string word; f1 >> word;){ 43 | f3.clear(); 44 | f3.seekg(0, std::ios::beg); 45 | f2.clear(); 46 | f2.seekg(0, std::ios::beg); 47 | for(std::string student; f3 >> student;){ 48 | f3 >> surname; 49 | f3 >> name; 50 | f3 >> patronymic; 51 | if(word == student){ 52 | output = QString::fromUtf8((name + " " + surname + " " + patronymic + " ").c_str()); 53 | break; 54 | } 55 | } 56 | f1 >> word; 57 | for(std::string id; f2 >> id;){ 58 | f2 >> variant; 59 | if(word == id){ 60 | output += QString::fromUtf8(variant.c_str()); 61 | ui->listWidget->addItem(output); 62 | break; 63 | } 64 | } 65 | } 66 | } 67 | } 68 | 69 | Print::~Print() 70 | { 71 | delete ui; 72 | } 73 | 74 | void Print::on_pushButton_clicked() 75 | { 76 | parent->show(); 77 | hide(); 78 | } 79 | 80 | -------------------------------------------------------------------------------- /print.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINT_H 2 | #define PRINT_H 3 | 4 | #include 5 | #include "dbms.h" 6 | 7 | namespace Ui { 8 | class Print; 9 | } 10 | 11 | class Print : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit Print(QWidget *parent, int index, std::string type, DBMS *dbms, std::string text); 17 | ~Print(); 18 | 19 | private slots: 20 | void on_pushButton_clicked(); 21 | 22 | private: 23 | Ui::Print *ui; 24 | QWidget *parent; 25 | int index; 26 | std::string type; 27 | DBMS *dbms; 28 | std::string text; 29 | }; 30 | 31 | #endif // PRINT_H 32 | -------------------------------------------------------------------------------- /print.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Print 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 400 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 40 20 | 50 21 | 301 22 | 281 23 | 24 | 25 | 26 | background-color: white; 27 | 28 | 29 | 30 | 31 | 32 | 290 33 | 360 34 | 100 35 | 32 36 | 37 | 38 | 39 | background-color: white; 40 | 41 | 42 | Home 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /printmenu.cpp: -------------------------------------------------------------------------------- 1 | #include "printmenu.h" 2 | #include "ui_printmenu.h" 3 | 4 | PrintMenu::PrintMenu(QWidget *parent, DBMS *dbms): 5 | QDialog(parent), 6 | ui(new Ui::PrintMenu) 7 | { 8 | ui->setupUi(this); 9 | this->idStudent = ""; 10 | this->idVariant = ""; 11 | this->dbms = dbms; 12 | this->parent = parent; 13 | this->index = -1; 14 | } 15 | 16 | PrintMenu::~PrintMenu() 17 | { 18 | delete ui; 19 | } 20 | 21 | void PrintMenu::on_pushButton_clicked() 22 | { 23 | idStudent = ui->lineEdit->text(); 24 | if(name == "") 25 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 26 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 27 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 28 | else if(idStudent == "") 29 | QMessageBox::critical(this,"Заголовок", "Please, enter the student id"); 30 | else{ 31 | std::string type = "Print student"; 32 | int id = this->dbms->checkID(this, index, idStudent, "students.txt", type); 33 | if(id == -1) 34 | { 35 | QMessageBox::critical(parent, "Заголовок", "There is no name with this id.Please, enter another one.\n"); 36 | } 37 | else{ 38 | this->dbms->print(id, "students.txt", index, text); 39 | hide(); 40 | windowPrint = new Print(parent, index, type, dbms, text); 41 | windowPrint->show(); 42 | } 43 | } 44 | } 45 | 46 | 47 | void PrintMenu::on_pushButton_6_clicked() 48 | { 49 | name = ui->lineEdit_3->text(); 50 | std::string newName = name.toUtf8().constData(); 51 | this->index = this->dbms->databaseExist(newName); 52 | if (index < 0) 53 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 54 | } 55 | 56 | 57 | void PrintMenu::on_pushButton_2_clicked() 58 | { 59 | idVariant = ui->lineEdit_2->text(); 60 | if(name == "") 61 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 62 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 63 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 64 | else if(idVariant == "") 65 | QMessageBox::critical(this,"Заголовок", "Please, enter the student id"); 66 | else{ 67 | std::string type = "Print variant"; 68 | int id = this->dbms->checkID(this, index, idVariant, "variants.txt", type); 69 | if(id == -1) 70 | { 71 | QMessageBox::critical(parent, "Заголовок", "There is no name with this id.Please, enter another one.\n"); 72 | } 73 | else{ 74 | this->dbms->print(id, "variants.txt", index, text); 75 | hide(); 76 | windowPrint = new Print(parent, index, type, dbms, text); 77 | windowPrint->show(); 78 | } 79 | } 80 | } 81 | 82 | 83 | void PrintMenu::on_pushButton_3_clicked() 84 | { 85 | std::string type = "Print students"; 86 | if(name == "") 87 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 88 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 89 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 90 | else{ 91 | hide(); 92 | windowPrint = new Print(parent, index, type, dbms, text); 93 | windowPrint->show(); 94 | } 95 | } 96 | 97 | 98 | void PrintMenu::on_pushButton_4_clicked() 99 | { 100 | std::string type = "Print variants"; 101 | if(name == "") 102 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 103 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 104 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 105 | else{ 106 | hide(); 107 | windowPrint = new Print(parent, index, type, dbms, text); 108 | windowPrint->show(); 109 | } 110 | } 111 | 112 | 113 | void PrintMenu::on_pushButton_7_clicked() 114 | { 115 | std::string type = "Testing Table"; 116 | if(name == "") 117 | QMessageBox::critical(this,"Заголовок", "Please, enter the database name"); 118 | else if((this->dbms->databaseExist(name.toStdString())) < 0) 119 | QMessageBox::critical(this,"Заголовок", "There is no database with this name"); 120 | else{ 121 | hide(); 122 | windowPrint = new Print(parent, index, type, dbms, text); 123 | windowPrint->show(); 124 | } 125 | } 126 | 127 | -------------------------------------------------------------------------------- /printmenu.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTMENU_H 2 | #define PRINTMENU_H 3 | 4 | #include 5 | #include "dbms.h" 6 | #include "print.h" 7 | 8 | namespace Ui { 9 | class PrintMenu; 10 | } 11 | 12 | class PrintMenu : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit PrintMenu(QWidget *parent, DBMS *dbms); 18 | ~PrintMenu(); 19 | 20 | private slots: 21 | void on_pushButton_clicked(); 22 | 23 | void on_pushButton_6_clicked(); 24 | 25 | void on_pushButton_2_clicked(); 26 | 27 | void on_pushButton_3_clicked(); 28 | 29 | void on_pushButton_4_clicked(); 30 | 31 | void on_pushButton_7_clicked(); 32 | 33 | private: 34 | Ui::PrintMenu *ui; 35 | QString idStudent; 36 | QString idVariant; 37 | DBMS *dbms; 38 | QWidget *parent; 39 | int index; 40 | QString name; 41 | Print *windowPrint; 42 | std::string text; 43 | }; 44 | 45 | #endif // PRINTMENU_H 46 | -------------------------------------------------------------------------------- /printmenu.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | PrintMenu 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 400 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 50 20 | 40 21 | 281 22 | 41 23 | 24 | 25 | 26 | <html><head/><body><p align="center"><span style=" font-size:24pt;">What do you want to print?</span></p></body></html> 27 | 28 | 29 | 30 | 31 | 32 | 70 33 | 120 34 | 101 35 | 16 36 | 37 | 38 | 39 | Enter student id: 40 | 41 | 42 | 43 | 44 | 45 | 170 46 | 120 47 | 51 48 | 21 49 | 50 | 51 | 52 | background-color: white; 53 | 54 | 55 | 56 | 57 | 58 | 230 59 | 120 60 | 81 61 | 21 62 | 63 | 64 | 65 | background-color: white; 66 | 67 | 68 | Print 69 | 70 | 71 | 72 | 73 | 74 | 170 75 | 150 76 | 51 77 | 21 78 | 79 | 80 | 81 | background-color: white; 82 | 83 | 84 | 85 | 86 | 87 | 230 88 | 150 89 | 81 90 | 21 91 | 92 | 93 | 94 | background-color: white; 95 | 96 | 97 | Print 98 | 99 | 100 | 101 | 102 | 103 | 70 104 | 150 105 | 101 106 | 16 107 | 108 | 109 | 110 | Enter variant id: 111 | 112 | 113 | 114 | 115 | 116 | 70 117 | 180 118 | 241 119 | 32 120 | 121 | 122 | 123 | background-color: white; 124 | 125 | 126 | Print students 127 | 128 | 129 | 130 | 131 | 132 | 70 133 | 220 134 | 241 135 | 32 136 | 137 | 138 | 139 | background-color: white; 140 | 141 | 142 | Print variants 143 | 144 | 145 | 146 | 147 | 148 | 290 149 | 350 150 | 100 151 | 32 152 | 153 | 154 | 155 | background-color: white; 156 | 157 | 158 | Home 159 | 160 | 161 | 162 | 163 | 164 | 70 165 | 90 166 | 111 167 | 16 168 | 169 | 170 | 171 | DataBase name: 172 | 173 | 174 | 175 | 176 | 177 | 170 178 | 90 179 | 81 180 | 21 181 | 182 | 183 | 184 | background-color: white; 185 | 186 | 187 | 188 | 189 | 190 | 260 191 | 90 192 | 51 193 | 21 194 | 195 | 196 | 197 | background-color: white; 198 | 199 | 200 | Enter 201 | 202 | 203 | 204 | 205 | 206 | 70 207 | 260 208 | 241 209 | 32 210 | 211 | 212 | 213 | background-color: white; 214 | 215 | 216 | Print Testing Table 217 | 218 | 219 | 220 | 221 | 222 | 223 | -------------------------------------------------------------------------------- /resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Resources/Fonts/Roboto-Light.ttf 4 | Resources/Fonts/Roboto-Medium.ttf 5 | Resources/Fonts/Roboto-Regular.ttf 6 | Resources/Images/Homer-Simpson-Looking-Happy 1.png 7 | Resources/Images/image 1.png 8 | Resources/Images/image 2.png 9 | Resources/Images/image 5.png 10 | Resources/Images/image 6.png 11 | Resources/Images/image 7.png 12 | Resources/Images/image 8.png 13 | Resources/Images/image 9.png 14 | Resources/Images/png-clipart-homer-simpson-bart-simpson-marge-simpson-lisa-simpson-maggie-simpson-bart-simpson-vertebrate-smiley 1.png 15 | 16 | 17 | --------------------------------------------------------------------------------