Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <Windows.h>
- #include <fstream>
- #include <conio.h>
- #include <iomanip>
- using namespace std;
- struct Account {
- string log;
- string pas;
- int prava;
- };
- struct Project {
- string name_project;
- string vid_rab;
- string FIO;
- string kolvo_chas;
- string stoimost_chas;
- };
- struct IndvZad {
- string name_proj;
- int kolvo_sotrud;
- int stoimost_proekta;
- int perechen_rabot[5];
- int perechen_rabot_st[5] = { 0, 0, 0 ,0 ,0 };
- };
- int fillAccounts(Account*, int);
- int enter();
- string proverkaLogina(Account*, int);
- string proverkaRegisterPass(string);
- int fillFileAccount(Account*, int);
- string proverkaLogin(Account*, int);
- string proverkaParolya(Account*, int, string);
- string enterPassword();
- int menuAdmin(Account*, int, string);
- int vivodMenuAdmin(string);
- void menuUserAdmin(Account*, int);
- int vivodMenuAccounta();
- int vivodInfUser(Account*, int);
- int proverkaPravPolzovatelya();
- int editAccount(Account*, int);
- int viborEditAccount(Account*, int);
- void dataChangeMenu();
- void fillProj(Project*, int);
- int vivodMenuEdita();
- void vivodProj(Project*, int);
- int addProject(Project*, int);
- string enterFIO();
- string enterWords();
- string proverkaVidaRabot();
- string proverkaPricePerHour();
- int editProj(Project*, int);
- int viborEdita(Project*, int);
- void fillFileProj(Project*, int);
- void menuUser(string);
- int vivodMenuUser(string);
- int vivodSearchMenu();
- void searchMenu(Project*, int, int);
- void vivodProj1(Project*, int);
- int vivodSortMenu();
- void menuSort(Project*, int, int);
- void individualEx(Project*, int);
- int main() {
- setlocale(0, "rus");
- ifstream fin;
- ofstream fout;
- ifstream check;
- check.open("Project.txt");
- if (!check) {
- fout.open("Project.txt", ios::out);
- fout.close();
- }
- check.close();
- check.open("registr.txt");
- if (!check) {
- fout.open("registr.txt", ios::out);
- fout.close();
- }
- check.close();
- ifstream file("Project.txt", ios::in);
- file.seekg(0, ios::end);
- int file_size = file.tellg();
- if (file_size == 0) {
- ofstream file1("Project.txt", ios::out);
- file1 << "0" << endl;
- file1.close();
- }
- file.close();
- ifstream f("registr.txt", ios::in);
- f.seekg(0, ios::end);
- file_size = f.tellg();
- if (file_size == 0) {
- ofstream file1("registr.txt", ios::out);
- file1 << "0" << endl;
- file1 << "edgar" << endl;
- file1 << "12345" << endl;
- file1 << "1" << endl;
- file1 << "1" << endl;
- file1.close();
- }
- f.close();
- fin.open("registr.txt");
- fin.seekg(-3, ios::end);
- int n;
- fin >> n;
- fin.close();
- Account* Acc = new Account[n];
- fillAccounts(Acc, n);
- while (true) {
- string login, pass;
- int key = enter();
- if (key == 2) { cout << "Досвидания!!!"; return 0; }
- else
- if (key == 1) {
- Account* t = new Account[n + 1];
- copy(Acc, Acc + n, t);
- delete[]Acc;
- Acc = t;
- t = NULL;
- fillAccounts(Acc, n);
- login = proverkaLogina(Acc, n);
- pass = proverkaRegisterPass(login);
- fstream clear_file("registr.txt", ios::out);
- clear_file.close();
- Acc[n].log = login; Acc[n].pas = pass; Acc[n].prava = 0;
- fillFileAccount(Acc, n);
- n++;
- system("cls");
- }
- else
- if (key == 0) {
- login = proverkaLogin(Acc, n);
- pass = proverkaParolya(Acc, n, login);
- if (pass == "-666") continue;
- int nomer = -1;
- for (int i = 0; i < n; i++)
- if (Acc[i].log == login) { nomer = i; }
- if (Acc[nomer].prava == 1) {
- menuAdmin(Acc, n, login);
- }
- else {
- menuUser(login);
- }
- }
- }
- return 0;
- }
- int fillAccounts(Account* Acc, int n) {
- ifstream fi;
- fi.open("registr.txt", ios::in);
- int k, prav;
- string lo, pa;
- fi >> k;
- for (int i = 0; i < n; i++) {
- fi >> lo;
- fi >> pa;
- fi >> prav;
- Acc[i].log = lo;
- Acc[i].pas = pa;
- Acc[i].prava = prav;
- fi >> k;
- }
- fi.close();
- return 0;
- }
- int enter() {
- int kol = 0, key = 0;
- while (true) {
- cout << "Стрелками ВВЕРХ и ВНИЗ выберите меню" << endl;
- kol = (kol + 3) % 3;
- if (kol == 0) { cout << " -- Войти в уже существующий аккаунт" << endl; }
- else cout << " Войти в уже существующий аккаунт" << endl;
- if (kol == 1) { cout << " -- Создать новый аккаунт" << endl; }
- else cout << " Создать новый аккаунт" << endl;
- if (kol == 2) { cout << " -- Завершить программу" << endl; }
- else { cout << " Завершить программу" << endl; }
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) kol--;
- if (key == 80) kol++;
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- string proverkaLogina(Account* Acc, int n1) {
- cout << "Логин должне содержать только буквы латинского алфавита, цифры." << endl;
- cout << "Введите ваш логин: ";
- string s;
- while (true) {
- int prov = 0;
- getline(cin, s);
- int n = s.length();
- for (int i = 0; i < n; i++) {
- if ((s[i] < 'a' || s[i] > 'z') && (s[i] < 'A' || s[i] > 'Z') && (s[i] < '0' || s[i] > '9')) {
- prov = 1;
- }
- }
- for (int i = 0; i < n1; i++) {
- if (s == Acc[i].log) prov = 3;
- }
- if (prov == 3) {
- system("cls");
- cout << "Такой логин уже существует" << endl;
- cout << "Логин может содержать буквы латинского алфавита, цифры" << endl;
- cout << "Введите логин: ";
- }
- else
- if (prov == 0) { return s; }
- else {
- system("cls");
- cout << "Логин может содержать буквы латинского алфавита, цифры" << endl;
- cout << "Введите логин: ";
- }
- }
- }
- string proverkaRegisterPass(string login) {
- system("cls");
- cout << "Логин: " << login << endl;
- cout << "Пароль должен состоять из более цифр и латинских буквы." << endl;
- cout << "Введите пароль: ";
- string s;
- while (true) {
- int prov = 0, kolchi = 0, bol = 0, mal = 0;
- getline(cin, s);
- int n = s.length();
- for (int i = 0; i < n; i++) {
- if ((s[i] < 'a' || s[i] > 'z') && (s[i] < 'A' || s[i] > 'Z') && (s[i] < '0' || s[i] > '9')) {
- prov = 1;
- }
- if (s[i] >= '0' && s[i] <= '9') {
- kolchi++;
- }
- else
- if (s[i] >= 'a' && s[i] <= 'z') {
- mal = 1;
- }
- else
- if (s[i] >= 'A' && s[i] <= 'Z') {
- bol = 1;
- }
- }
- if (prov == 0) { return s; }
- else {
- system("cls");
- cout << "Логин: " << login << endl;
- cout << "Пароль должен состоять из цифр и латинской буквы." << endl;
- cout << "Введите пароль: ";
- }
- }
- }
- int fillFileAccount(Account* Acc, int n) {
- fstream clr_file("registr.txt", ios::out);
- clr_file.close();
- ofstream fo;
- fo.open("registr.txt", ios::out);
- for (int i = 0; i < n; i++) {
- fo << i << endl;
- fo << Acc[i].log << endl;
- fo << Acc[i].pas << endl;
- fo << Acc[i].prava << endl;
- }
- fo << n << endl;
- fo << Acc[n].log << endl;
- fo << Acc[n].pas << endl;
- fo << Acc[n].prava << endl;
- fo << n + 1 << endl;
- fo.close();
- return 0;
- }
- string proverkaLogin(Account* Acc, int n1) {
- cout << "Введите логин: ";
- string s;
- while (true) {
- int prov = 0;
- getline(cin, s);
- for (int i = 0; i < n1; i++) {
- if (s == Acc[i].log) prov = 3;
- }
- if (prov == 0) {
- system("cls");
- cout << "Такого логина не существует." << endl;
- cout << "Введите логин: ";
- }
- else
- if (prov == 3) { return s; }
- }
- }
- string proverkaParolya(Account* Acc, int n1, string login) {
- system("cls");
- cout << "Логин: " << login << endl;
- cout << "Введите ваш пароль: ";
- string s;
- int popitki = 4;
- while (true) {
- int check1 = 0;
- s = enterPassword();
- for (int i = 0; i < n1; i++) {
- if (Acc[i].log == login && Acc[i].pas == s) {
- check1 = 1;
- break;
- }
- }
- if (check1 == 1) { system("cls"); return s; }
- else {
- system("cls");
- cout << "Логин: " << login << endl;
- cout << "Вы ввели не верный пароль. Повторите попытку. У вас еще " << popitki - 1 << " попытки(а)" << endl;
- cout << "Введите пароль: ";
- }
- popitki--;
- s = "-666";
- if (popitki == 0) return s;
- }
- }
- string enterPassword() {
- string s;
- while (true) {
- int c;
- char cc;
- c = _getch();
- if (c == 224) {
- c = _getch();
- }
- else
- if (c == 8) {
- if (s.length() != 0) {
- cout << '\b' << " " << '\b';
- s.erase(s.length() - 1);
- }
- }
- else
- if (c == 13) break;
- else
- if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) {
- cc = (char)c;
- s = s + cc;
- cout << "*";
- }
- }
- return s;
- }
- int menuAdmin(Account* Acc, int n, string login) {
- while (true) {
- int mn = vivodMenuAdmin(login);
- if (mn == 3) {
- return 0;
- }
- else
- if (mn == 0) {
- menuUserAdmin(Acc, n);
- }
- else
- if (mn == 1) {
- dataChangeMenu();
- }
- else {
- menuUser("");
- }
- }
- }
- int vivodMenuAdmin(string login) {
- int kol = 0, key = 0;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выберите меню" << endl;
- kol = (kol + 4) % 4;
- cout << "Здраствуйте админ.: " << login << "." << endl;
- if (kol == 0) { cout << " -- Меню редактирования учетных записей" << endl; }
- else cout << " Меню редактирования учетных записей" << endl;
- if (kol == 1) { cout << " -- Меню редактирования информации" << endl; }
- else cout << " Меню редактирования информации" << endl;
- if (kol == 2) { cout << " -- Меню обработки информации" << endl; }
- else { cout << " Меню обработки информации" << endl; }
- if (kol == 3) { cout << " -- Выйти в главное меню" << endl; }
- else { cout << " Выйти в главное меню" << endl; }
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) kol--;
- if (key == 80) kol++;
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- void menuUserAdmin(Account* Acc, int n) {
- int key_acc;
- while (true) {
- key_acc = vivodMenuAccounta();
- if (key_acc == 4) {
- break;
- }
- else
- if (key_acc == 0) {
- system("cls");
- vivodInfUser(Acc, n);
- }
- else
- if (key_acc == 1) {
- system("cls");
- Account* t = new Account[n + 1];
- copy(Acc, Acc + n, t);
- delete[]Acc;
- Acc = t;
- t = NULL;
- Acc[n].log = proverkaLogina(Acc, n);
- Acc[n].pas = proverkaRegisterPass(Acc[n].log);
- Acc[n].prava = proverkaPravPolzovatelya();
- n = n + 1;
- system("cls");
- }
- else
- if (key_acc == 2) {
- system("cls");
- int vibr = editAccount(Acc, n);
- if (vibr == n) continue;
- int vibr1 = viborEditAccount(Acc, vibr);
- if (vibr1 == 0) Acc[vibr].log = proverkaLogina(Acc, n);
- else
- if (vibr1 == 1) Acc[vibr].pas = proverkaRegisterPass(Acc[vibr].log);
- else Acc[vibr].prava = proverkaPravPolzovatelya();
- system("cls");
- }
- else
- if (key_acc == 3) {
- int vibr = editAccount(Acc, n);
- if (vibr == n) continue;
- cout << "Аккаунт " << Acc[vibr].log << " удалён!!!" << endl;
- for (int i = vibr; i < n - 1; i++) {
- Acc[i] = Acc[i + 1];
- }
- n--;
- system("pause");
- system("cls");
- }
- }
- fillFileAccount(Acc, n - 1);
- }
- int vivodMenuAccounta() {
- int kol = 0, key = 0;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выберите меню" << endl;
- kol = (kol + 5) % 5;
- if (kol == 0) { cout << " -- Просмотр учетных записей" << endl; }
- else cout << " Просмотр учетных записей" << endl;
- if (kol == 1) { cout << " -- Добавление учетной записи" << endl; }
- else cout << " Добавление учетной записи" << endl;
- if (kol == 2) { cout << " -- Редактирование учетных записей" << endl; }
- else { cout << " Редактирование учетных записей" << endl; }
- if (kol == 3) { cout << " -- Удаление учетной записи" << endl; }
- else { cout << " Удаление учетной записи" << endl; }
- if (kol == 4) { cout << " -- Выйти в меню администратора" << endl; }
- else { cout << " Выйти в меню администратора" << endl; }
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) kol--;
- if (key == 80) kol++;
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- int vivodInfUser(Account* Acc, int n) {
- for (int i = 0; i < n; i++) {
- cout << setw(24) << " Пользователь №" << i + 1 << endl;
- cout << " Логин: " << Acc[i].log << endl;
- cout << " Пароль: " << Acc[i].pas << endl;
- if (Acc[i].prava == 1)
- cout << " Роль: Администратор" << endl;
- else
- cout << " Роль: Пользователь" << endl;
- }
- system("pause");
- system("cls");
- return 0;
- }
- int proverkaPravPolzovatelya() {
- string s;
- while (true) {
- system("cls");
- cout << "Введите 0 - если у пользоветля будут права администратора или 1 - если у пользователя будут обычные права: ";
- getline(cin, s);
- system("cls");
- if (s == "1") return 1;
- else
- if (s == "0") return 0;
- }
- }
- int editAccount(Account* Acc, int n) {
- int kol = 1, key;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выберите аккаунт " << endl;
- kol = (kol + (n + 1)) % (n + 1);
- for (int i = 1; i < n; i++) {
- if (i == kol) { cout << " -- " << i << " - " << Acc[i].log << endl; }
- else cout << " " << i << " - " << Acc[i].log << endl;
- }
- if (kol == n) { cout << " -- Выйти с выбора пользовтеля" << endl; }
- else cout << " Выйти с выбора пользовтеля" << endl;
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) { kol--; if (kol == 0) kol = n; }
- if (key == 80) { kol++; if (kol == n + 1) kol = 1; }
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- int viborEditAccount(Account* Acc, int vibr) {
- int kol = 0, key = 0;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выбериет меню" << endl;
- kol = (kol + 3) % 3;
- if (kol == 0) { cout << " -- Изменить логин: " << Acc[vibr].log << endl; }
- else cout << " Изменить логин: " << Acc[vibr].log << endl;
- if (kol == 1) { cout << " -- Изменить пароль: " << Acc[vibr].pas << endl; }
- else cout << " Изменить пароль: " << Acc[vibr].pas << endl;
- if (kol == 2) { cout << " -- Изменить права: " << Acc[vibr].prava << endl; }
- else { cout << " Изменить права: " << Acc[vibr].prava << endl; }
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) kol--;
- if (key == 80) kol++;
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- void dataChangeMenu() {
- ifstream fin;
- fin.open("Project.txt", ios::in);
- fin.seekg(-3, ios::end);
- int n = 0;
- fin >> n;
- fin.close();
- Project* Proj = new Project[n + 1];
- if (n != 0)
- fillProj(Proj, n);
- while (true) {
- int vibr = vivodMenuEdita();
- if (vibr == 4) break;
- else
- if (vibr == 0) {
- if (n == 0) { cout << "Проектов в базе данных нет!" << endl; system("pause"); system("cls"); }
- else {
- vivodProj(Proj, n);
- }
- }
- else
- if (vibr == 1) {
- Project* tt = new Project[n + 2];
- copy(Proj, Proj + n, tt);
- delete[]Proj;
- Proj = tt;
- tt = NULL;
- addProject(Proj, n);
- n++;
- }
- else
- if (vibr == 2) {
- int vibor = 0;
- int viborR = 0;
- while (true) {
- vibor = editProj(Proj, n);
- if (vibor == n) break;
- while (true) {
- viborR = viborEdita(Proj, vibor);
- if (viborR == 5) break;
- if (viborR == 0) { cout << "Введите наименование проекта: "; Proj[vibor].name_project = enterWords(); system("cls"); }
- else
- if (viborR == 1) { Proj[vibor].vid_rab = proverkaVidaRabot(); system("cls"); }
- else
- if (viborR == 2) { Proj[vibor].FIO = enterFIO(); system("cls"); }
- else
- if (viborR == 3) {
- cout << "Введите количество часов: ";
- Proj[vibor].kolvo_chas = proverkaPricePerHour();
- system("cls");
- }
- else
- if (viborR == 4) {
- cout << "Введите стоимость часа: ";
- Proj[vibor].stoimost_chas = proverkaPricePerHour();
- system("cls");
- }
- }
- }
- }
- else
- if (vibr == 3) {
- int udal = editProj(Proj, n);
- if (udal == n) continue;
- else {
- for (int i = udal; i < n - 1; i++) {
- Proj[i] = Proj[i + 1];
- }
- n--;
- }
- }
- else break;
- }
- if (n != 0) fillFileProj(Proj, n);
- }
- void fillProj(Project* Proj, int n) {
- ifstream fin;
- fin.open("Project.txt", ios::in);
- string s;
- getline(fin, s);
- for (int i = 0; i < n; i++) {
- getline(fin, Proj[i].name_project);
- getline(fin, Proj[i].vid_rab);
- getline(fin, Proj[i].FIO);
- getline(fin, Proj[i].kolvo_chas);
- getline(fin, Proj[i].stoimost_chas);
- getline(fin, s);
- }
- fin.close();
- }
- int vivodMenuEdita() {
- int kol = 0, key = 0;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выберите меню" << endl;
- kol = (kol + 5) % 5;
- if (kol == 0) { cout << " -- Просмотр списка проектов" << endl; }
- else cout << " Просмотр списка проектов" << endl;
- if (kol == 1) { cout << " -- Добавление проектов" << endl; }
- else cout << " Добавление проектов" << endl;
- if (kol == 2) { cout << " -- Редактирование проектов" << endl; }
- else { cout << " Редактирование проектов" << endl; }
- if (kol == 3) { cout << " -- Удаление проектов" << endl; }
- else { cout << " Удаление проектов" << endl; }
- if (kol == 4) { cout << " -- Выйти в меню администратора" << endl; }
- else { cout << " Выйти в меню администратора" << endl; }
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) kol--;
- if (key == 80) kol++;
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- void vivodProj(Project* Proj, int n) {//ask
- for (int i = 0; i < n; i++) {
- cout << " Проект №" << i + 1 << endl;
- cout << " Наименование проекта: " << Proj[i].name_project << endl;
- cout << " Вид работ: " << Proj[i].vid_rab << endl;
- cout << " Ф.И.О: " << Proj[i].FIO << endl;
- cout << " Количество часов: " << Proj[i].kolvo_chas << endl;
- cout << " Стоимость часа: " << Proj[i].stoimost_chas << endl;
- cout << endl;
- cout << endl;
- }
- system("pause");
- system("cls");
- }
- int addProject(Project* Proj, int n) {
- cout << "Введите наименование проекта: ";
- Proj[n].name_project = enterWords();
- system("cls");
- Proj[n].vid_rab = proverkaVidaRabot();
- system("cls");
- Proj[n].FIO = enterFIO();
- system("cls");
- cout << "Введите количество часов: ";
- Proj[n].kolvo_chas = proverkaPricePerHour();
- system("cls");
- cout << "Введите стоимость часа: ";
- Proj[n].stoimost_chas = proverkaPricePerHour();
- system("cls");
- return 0;
- }
- string enterFIO() {
- cout << "Введите имя: ";
- string name = enterWords();
- cout << endl;
- cout << "Введите фамилию: ";
- string fam = enterWords();
- cout << endl;
- cout << "Введите отчество: ";
- string otch = enterWords();
- system("cls");
- return fam + " " + name + " " + otch;
- }
- string enterWords() {
- string s;
- while (true) {
- int c;
- char cc;
- c = _getch();
- if (c == 224) {
- c = _getch();
- }
- else
- //backspace
- if (c == 8) {
- if (s.length() != 0) {
- cout << '\b' << " " << '\b';
- s.erase(s.length() - 1);
- }
- }
- else
- //enter
- if (c == 13) {
- break;
- }
- else {
- cc = (char)c;
- if ((cc >= 'a' && cc <= 'z') || (cc >= 'A' && cc <= 'Z')) {
- s = s + cc;
- cout << cc;
- }
- }
- }
- return s;
- }
- string proverkaVidaRabot() {
- int kol = 0, key = 0;
- string s;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выберите вид работы: " << endl;
- kol = (kol + 4) % 4;
- if (kol == 0) { cout << " -- Работа над требованиями" << endl; s = "Работа над требованиями"; }
- else cout << " Работа над требованиями" << endl;
- if (kol == 1) { cout << " -- Разработка архитектуры" << endl; s = "Разработка архитектуры"; }
- else cout << " Разработка архитектуры" << endl;
- if (kol == 2) { cout << " -- Реализация" << endl; s = "Реализация"; }
- else cout << " Реализация" << endl;
- if (kol == 3) { cout << " -- Тестирование" << endl; s = "Тестирование"; }
- else { cout << " Тестирование" << endl; }
- key = _getch();
- if (key == 224) {
- key = _getch(); //стрелки
- if (key == 72) kol--;
- if (key == 80) kol++;
- }//enter
- if (key == 13) { system("cls"); return s; }
- system("cls");
- }
- }
- string proverkaPricePerHour() {
- string s;
- while (true) {
- int c;
- char cc;
- c = _getch();
- if (c == 224) {
- c = _getch();
- }
- else
- if (c == 8) {
- if (s.length() != 0) {
- cout << '\b' << " " << '\b';
- s.erase(s.length() - 1);
- }
- }
- else
- if (c == 13) break;
- else
- if (s.length() == 8) continue;
- else
- if (c >= '0' && c <= '9') {
- cc = (char)c;
- s = s + cc;
- cout << cc;
- }
- }
- return s;
- }
- int editProj(Project* Proj, int n) {
- int kol = 0, key;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выберите проект " << endl;
- kol = (kol + (n + 1)) % (n + 1);
- for (int i = 0; i < n; i++) {
- if (i == kol) { cout << " -- " << i << " - " << Proj[i].name_project << " " << Proj[i].vid_rab << endl; }
- else cout << " " << i << " - " << Proj[i].name_project << " " << Proj[i].vid_rab << endl;
- }
- if (kol == n) { cout << " -- Выйти с выбора проекта" << endl; }
- else cout << " Выйти с выбора проекта" << endl;
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) kol--;
- if (key == 80) kol++;
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- int viborEdita(Project* Proj, int vibr) {
- int kol = 0, key = 0;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выбериет пункт редактирования" << endl;
- kol = (kol + 6) % 6;
- if (kol == 0) { cout << " -- Изменить наименование проекта: " << Proj[vibr].name_project << endl; }
- else cout << " Изменить наименование проекта: " << Proj[vibr].name_project << endl;
- if (kol == 1) { cout << " -- Изменить вид работы: " << Proj[vibr].vid_rab << endl; }
- else cout << " Изменить вид работы: " << Proj[vibr].vid_rab << endl;
- if (kol == 2) { cout << " -- Изменить Ф.И.О: " << Proj[vibr].FIO << endl; }
- else { cout << " Изменить Ф.И.О: " << Proj[vibr].FIO << endl; }
- if (kol == 3) { cout << " -- Изменить кол-во часов: " << Proj[vibr].kolvo_chas << endl; }
- else { cout << " Изменить кол-во часов: " << Proj[vibr].kolvo_chas << endl; }
- if (kol == 4) { cout << " -- Изменить стоимость часа: " << Proj[vibr].stoimost_chas << endl; }
- else { cout << " Изменить стоимость часа: " << Proj[vibr].stoimost_chas << endl; }
- if (kol == 5) { cout << " -- Выйти к выбору проекта." << endl; }
- else { cout << " Выйти к выбору проекта." << endl; }
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) kol--;
- if (key == 80) kol++;
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- void fillFileProj(Project* Proj, int n) {
- fstream clear_file("Project.txt", ios::out);
- clear_file.close();
- ofstream fout;
- fout.open("Project.txt", ios::out);
- for (int i = 0; i < n; i++) {
- fout << i << endl;
- fout << Proj[i].name_project << endl;
- fout << Proj[i].vid_rab << endl;
- fout << Proj[i].FIO << endl;
- fout << Proj[i].kolvo_chas << endl;
- fout << Proj[i].stoimost_chas << endl;
- }
- fout << n << endl;
- fout.close();
- }
- void menuUser(string login) {
- ifstream fin;
- fin.open("Project.txt", ios::in);
- fin.seekg(-3, ios::end);
- int n = 0;
- fin >> n;
- fin.close();
- Project* Proj = new Project[n + 1];
- if (n != 0)
- fillProj(Proj, n);
- else {
- cout << "Проектов в базе, нет" << endl;
- system("pause");
- system("cls");
- return;
- }
- while (true) {
- int menu = vivodMenuUser(login);
- if (menu == 0) {
- vivodProj(Proj, n);
- }
- else
- if (menu == 1) {
- individualEx(Proj, n);
- }
- else
- if (menu == 2) {
- int mn = vivodSearchMenu();
- searchMenu(Proj, mn, n);
- }
- else
- if (menu == 3) {
- int mn = vivodSortMenu();
- menuSort(Proj, mn, n);
- }
- else {
- break;
- }
- }
- fillFileProj(Proj, n);
- }
- int vivodMenuUser(string s) {
- int kol = 0, key = 0;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выберите пункт меню" << endl;
- kol = (kol + 5) % 5;
- if (s.length() != 0) {
- cout << "Здраствуйте пользователь, " << s << "!!!" << endl;
- }
- if (kol == 0) { cout << " -- Просмотр информации о проектах" << endl; }
- else cout << " Просмотр информации о проектах" << endl;
- if (kol == 1) { cout << " -- Индивидуальное задание" << endl; }
- else cout << " Индивидуальное задание" << endl;
- if (kol == 2) { cout << " -- Поиск" << endl; }
- else cout << " Поиск" << endl;
- if (kol == 3) { cout << " -- Сортировка" << endl; }
- else { cout << " Сортировка" << endl; }
- if (kol == 4) { cout << " -- Выйти в меню" << endl; }
- else { cout << " Выйти в меню" << endl; }
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) kol--;
- if (key == 80) kol++;
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- int vivodSearchMenu() {
- int kol = 0, key = 0;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выберите пункт меню" << endl;
- kol = (kol + 4) % 4;
- if (kol == 0) { cout << " -- Поиск по наименованию проекта" << endl; }
- else cout << " Поиск по наименованию проекта" << endl;
- if (kol == 1) { cout << " -- Поиск по количеству часов" << endl; }
- else cout << " Поиск по количеству часов" << endl;
- if (kol == 2) { cout << " -- Поиск по стоимости за час" << endl; }
- else cout << " Поиск по стоимости за час" << endl;
- if (kol == 3) { cout << " -- Выход в меню обработки" << endl; }
- else cout << " Выход в меню обработки" << endl;
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) kol--;
- if (key == 80) kol++;
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- void searchMenu(Project* Proj, int mn, int n) {
- if (mn == 0) {
- cout << "Введите наименование проекта который нужно искать: ";
- string nproj = enterWords();
- system("cls");
- int pop = 0;
- cout << endl;
- for (int i = 0; i < n; i++)
- if (Proj[i].name_project.length() >= nproj.length()) {
- int kol = -666;
- for (int j = 0; j < nproj.length(); j++)
- if (nproj[j] != tolower(Proj[i].name_project[j]) && nproj[j] != toupper(Proj[i].name_project[j])) kol = 0;
- if (kol == -666) {
- vivodProj1(Proj, i);
- pop++;
- }
- }
- if (pop == 0) {
- cout << "Проектов с таким наименование, нет." << endl;
- }
- system("pause");
- system("cls");
- }
- else
- if (mn == 1) {
- cout << "Введите количество часов: ";
- string kolchas = proverkaPricePerHour();
- system("cls");
- int pop = 0;
- for (int i = 0; i < n; i++)
- if (kolchas == Proj[i].kolvo_chas) {
- vivodProj1(Proj, i);
- pop++;
- }
- if (pop == 0) {
- cout << "Проектов с таким количеством часов, нет." << endl;
- }
- system("pause");
- system("cls");
- }
- else
- if (mn == 2) {
- cout << "Введите стоимость за час: ";
- string stchas = proverkaPricePerHour();
- int pop = 0;
- for (int i = 0; i < n; i++)
- if (stchas == Proj[i].stoimost_chas) {
- vivodProj1(Proj, i);
- pop++;
- }
- if (pop == 0) cout << "Проектов с такой стоимостью за час, нет!!!" << endl;
- system("pause");
- system("cls");
- }
- } //уточнить
- void vivodProj1(Project* Proj, int i) {
- cout << " Проект №" << i + 1 << endl;
- cout << " Наименование проекта: " << Proj[i].name_project << endl;
- cout << " Вид работ: " << Proj[i].vid_rab << endl;
- cout << " Ф.И.О: " << Proj[i].FIO << endl;
- cout << " Количество часов: " << Proj[i].kolvo_chas << endl;
- cout << " Стоимость часа: " << Proj[i].stoimost_chas << endl;
- cout << endl;
- cout << endl;
- }
- int vivodSortMenu() {
- int kol = 0, key = 0;
- while (true) {
- cout << "Стрелочками ВВЕРХ и ВНИЗ выберите пункт меню" << endl;
- kol = (kol + 4) % 4;
- if (kol == 0) { cout << " -- Сортировка по возрастанию стоимости за час" << endl; }
- else cout << " Сортировка по возрастанию стоимости за час" << endl;
- if (kol == 1) { cout << " -- Сортировка по убыванию стоимости за час" << endl; }
- else cout << " Сортировка по убыванию стоимости за час" << endl;
- if (kol == 2) { cout << " -- Сортировка по возростанию кол-во часов" << endl; }
- else cout << " Сортировка по возростанию кол-во часов" << endl;
- if (kol == 3) { cout << " -- Сортировка по убыванию кол-во часов" << endl; }
- else { cout << " Сортировка по убыванию кол-во часов" << endl; }
- if (kol == 4) { cout << " -- Выйти в меню обработки" << endl; }
- else { cout << " Выйти в меню обработки" << endl; }
- key = _getch();
- if (key == 224) {
- key = _getch();
- if (key == 72) kol--;
- if (key == 80) kol++;
- }
- if (key == 13) { system("cls"); return kol; }
- system("cls");
- }
- }
- void menuSort(Project* Proj, int mn, int n) {
- if (mn == 0) {
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n - 1; j++) {
- int s1, s2;
- s1 = stoi(Proj[j].stoimost_chas);
- s2 = stoi(Proj[j + 1].stoimost_chas);
- if (s1 > s2) {
- Project* Mas = new Project[1];
- Mas[0] = Proj[j];
- Proj[j] = Proj[j + 1];
- Proj[j + 1] = Mas[0];
- }
- }
- cout << "Проекты отсортированы по возрастанию стоимости за час." << endl;
- system("pause");
- system("cls");
- }
- else
- if (mn == 1) {
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n - 1; j++) {
- int s1, s2;
- s1 = stoi(Proj[j].stoimost_chas);
- s2 = stoi(Proj[j + 1].stoimost_chas);
- if (s1 < s2) {
- Project* Mas = new Project[1];
- Mas[0] = Proj[j];
- Proj[j] = Proj[j + 1];
- Proj[j + 1] = Mas[0];
- }
- }
- cout << "Проекты отсортированы по убыванию стоимости за час." << endl;
- system("pause");
- system("cls");
- }
- if (mn == 2) {
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n - 1; j++) {
- int s1, s2;
- s1 = stoi(Proj[j].kolvo_chas);
- s2 = stoi(Proj[j + 1].kolvo_chas);
- if (s1 > s2) {
- Project* Mas = new Project[1];
- Mas[0] = Proj[j];
- Proj[j] = Proj[j + 1];
- Proj[j + 1] = Mas[0];
- }
- }
- cout << "Проекты отсортированы по возрастанию кол-во часов." << endl;
- system("pause");
- system("cls");
- }
- if (mn == 3) {
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n - 1; j++) {
- int s1, s2;
- s1 = stoi(Proj[j].kolvo_chas);
- s2 = stoi(Proj[j + 1].kolvo_chas);
- if (s1 < s2) {
- Project* Mas = new Project[1];
- Mas[0] = Proj[j];
- Proj[j] = Proj[j + 1];
- Proj[j + 1] = Mas[0];
- }
- }
- cout << "Проекты отсортированы по убыванию кол-во часов." << endl;
- system("pause");
- system("cls");
- }
- }
- void individualEx(Project* Proj, int n) {
- IndvZad* Mas = new IndvZad[n];
- int kol = 0;
- for (int i = 0; i < n; i++) {
- int prov = 0, tot = 0, tot1 = 0;
- for (int j = 0; j < kol; j++)
- if (prov == 0) {
- if (Proj[i].name_project.length() == Mas[j].name_proj.length()) {
- for (int k = 0; k < Proj[i].name_project.length(); k++) {
- if (tolower(Proj[i].name_project[k]) == tolower(Mas[j].name_proj[k])) {
- prov = 1;
- tot = j;
- break;
- }
- }
- }
- }
- else break;
- if (prov == 0) {
- Mas[kol].name_proj = Proj[i].name_project;
- Mas[kol].kolvo_sotrud = 1;
- Mas[kol].stoimost_proekta = stoi(Proj[i].stoimost_chas) * stoi(Proj[i].kolvo_chas);
- if (Proj[i].vid_rab == "Работа над требованиями") { Mas[kol].perechen_rabot[0] = 1; Mas[kol].perechen_rabot_st[0] = (stoi(Proj[i].stoimost_chas) * stoi(Proj[i].kolvo_chas)); }
- else
- if (Proj[i].vid_rab == "Разработка архитектуры") { Mas[kol].perechen_rabot[1] = 1; Mas[kol].perechen_rabot_st[1] = (stoi(Proj[i].stoimost_chas) * stoi(Proj[i].kolvo_chas)); }
- else
- if (Proj[i].vid_rab == "Реализация") { Mas[kol].perechen_rabot[2] = 1; Mas[kol].perechen_rabot_st[2] = (stoi(Proj[i].stoimost_chas) * stoi(Proj[i].kolvo_chas)); }
- else
- if (Proj[i].vid_rab == "Тестирование") { Mas[kol].perechen_rabot[3] = 1; Mas[kol].perechen_rabot_st[3] = (stoi(Proj[i].stoimost_chas) * stoi(Proj[i].kolvo_chas)); }
- kol++;
- }
- else {
- Mas[tot].kolvo_sotrud++;
- Mas[tot].stoimost_proekta = Mas[tot].stoimost_proekta + (stoi(Proj[i].stoimost_chas) * stoi(Proj[i].kolvo_chas));
- if (Proj[i].vid_rab == "Работа над требованиями") { Mas[tot].perechen_rabot[0] = 1; Mas[tot].perechen_rabot_st[0] = Mas[tot].perechen_rabot_st[0] + (stoi(Proj[i].stoimost_chas) * stoi(Proj[i].kolvo_chas)); }
- else
- if (Proj[i].vid_rab == "Разработка архитектуры") { Mas[tot].perechen_rabot[1] = 1; Mas[tot].perechen_rabot_st[1] = Mas[tot].perechen_rabot_st[1] + (stoi(Proj[i].stoimost_chas) * stoi(Proj[i].kolvo_chas)); }
- else
- if (Proj[i].vid_rab == "Реализация") { Mas[tot].perechen_rabot[2] = 1; Mas[tot].perechen_rabot_st[2] = Mas[tot].perechen_rabot_st[2] + (stoi(Proj[i].stoimost_chas) * stoi(Proj[i].kolvo_chas)); }
- else
- if (Proj[i].vid_rab == "Тестирование") { Mas[tot].perechen_rabot[3] = 1; Mas[tot].perechen_rabot_st[3] = Mas[tot].perechen_rabot_st[3] + (stoi(Proj[i].stoimost_chas) * stoi(Proj[i].kolvo_chas)); }
- }
- }
- for (int i = 0; i < kol; i++) {
- cout << " Проект: " << Mas[i].name_proj << endl;
- cout << " Стоимость проекта: " << Mas[i].stoimost_proekta << "руб." << endl;
- cout << " Сотрудников: " << Mas[i].kolvo_sotrud << endl;
- cout << " Виды работ: " << endl;
- if (Mas[i].perechen_rabot[0] == 1) cout << " Работа над требованиями - " << Mas[i].perechen_rabot_st[0] << "руб." << endl;
- if (Mas[i].perechen_rabot[1] == 1) cout << " Разработка архитектуры - " << Mas[i].perechen_rabot_st[1] << "руб." << endl;
- if (Mas[i].perechen_rabot[2] == 1) cout << " Реализация - " << Mas[i].perechen_rabot_st[2] << "руб." << endl;
- if (Mas[i].perechen_rabot[3] == 1) cout << " Тестирование - " << Mas[i].perechen_rabot_st[3] << "руб." << endl;
- cout << endl;
- cout << endl;
- }
- system("pause");
- system("cls");
- }
Add Comment
Please, Sign In to add comment