Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "Protection.h"
- using namespace std;
- /*шифрование. MODE 1 - шифрование, MODE 0 - дешифрование*/
- string Shifr(string shifr, bool mod)
- {
- for (int i = 0; i < shifr.size(); i++) {
- if (mod) {
- shifr[i] += 5;
- }
- else {
- shifr[i] -= 5;
- }
- }
- return shifr;
- }
- void family_filtr() {
- static vector<string> family;
- int VectorSize = 0;
- cout << "Фильтрация по фамилии" << endl;
- cout << "Список всех фамилий:" << endl;
- ifstream file1("info.txt", ios_base::app);
- while (file1 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- if (VectorSize == 0) {
- family.push_back(info.participant.family);
- VectorSize++;
- }
- else {
- int Check = 0;
- for (int i = 0; i < VectorSize; i++) {
- if (family[i] == info.participant.family) {
- Check++;
- }
- }
- if (Check == 0) {
- family.push_back(info.participant.family);
- VectorSize++;
- }
- }
- }
- for (int i = 0; i < VectorSize; i++) {
- cout << family[i] << endl;
- }
- bool exit = true;
- while (exit) {
- cout << "Введите фамилию из данного списка для поиска" << endl;
- string search;
- search = add_protect();
- int Check = 0;
- for (int i = 0; i < VectorSize; i++) {
- if (family[i] == search) {
- Check++;
- }
- }
- if (Check == 0) {
- cout << "Фамилия введена не верно, повторите ввод" << endl;
- }
- else {
- exit = false;
- char c;
- ifstream file("info.txt"); // открыли файл с текстом
- string s;
- int amount = 0;
- while (!file.eof()) { // прочитали его и заполнили им строку
- file.get(c);
- s.push_back(c);
- amount++;
- }
- file.close();
- string t;
- t = search;
- int i, j, k, x, size = t.size(), string = 1;
- bool check = false;
- for (i = 0; i <= amount - size - 1; i++) {
- if (s[i] == '\n') {
- string += 1;
- }
- if (s[i] == t[0]) {
- k = i;
- x = 0;
- for (j = 1; j < size + 1; j++) {
- if (s[k + j] != t[j]) {
- break;
- }
- else x++;
- }
- if (x + 1 == size) {
- ifstream f("info.txt", ios_base::app);
- if (f.peek() == EOF)
- {
- cout << "Файл пустой." << endl;
- }
- else {
- if (check == false) {
- cout << setw(84) << " " << "Дата выступления" << endl;
- cout << setw(12) << left << "Имя" << setw(12) << left << "Фамилия" << setw(12) << left << "Отчество" << setw(12) << left << "ID" << setw(12) << left << "Песня" << setw(12) << left << "Инструмент" << setw(12) << left << "Рейтинг" << setw(12) << left << "День" << setw(12) << left << "Месяц" << setw(12) << left << "Год" << endl;
- check = true;
- }
- while (f >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- if (string == info.participant.ID) {
- cout << "_______________________________________________________________________________________________________________________" << endl;
- cout << setw(12) << info.participant.name << setw(12) << info.participant.family << setw(12) << info.participant.patronymic << setw(12) << info.participant.ID << setw(12) << info.participant.kategory.song << setw(12) << info.participant.kategory.tool << setw(12) << left << info.rating << setw(12) << left << info.day << setw(12) << left << info.month << setw(12) << left << info.year << endl;
- }
- }
- while (s[i + 1] != '\n') {
- i++;
- }
- }
- f.close();
- }
- }
- }
- }
- system("pause");
- system("cls");
- }
- file1.close();
- }
- void filtr_menu() {
- int input;
- bool hod = true;
- while (hod) {
- cout << "Меню фильтрации" << endl;
- cout << "1. Фильтрация по фамилии" << endl;
- cout << "2. Фильтрация по дате" << endl;
- cout << "3. Фильтрация по id" << endl;
- cout << "4. Вывести информацию" << endl;
- cin >> input;
- proverka_na_chislo(input);
- system("cls");
- switch (input) {
- case 1: {
- family_filtr();
- system("cls");
- break;
- }
- case 2: {
- system("cls");
- break;
- }
- case 4: {
- hod = false;
- }
- default: {
- cout << "Неверный ввод повторите попытку" << endl;
- }
- }
- }
- }
- void files() {
- ifstream jury("jury.txt");
- if (!jury.is_open()) {
- ofstream jury("jury.txt");
- jury.close();
- }
- else jury.close();
- ifstream jury2("jury2.txt");
- if (!jury2.is_open()) {
- ofstream jury("jury2.txt");
- jury2.close();
- }
- else jury2.close();
- ifstream info("info.txt");
- if (!info.is_open()) {
- ofstream info("info.txt");
- info.close();
- }
- else info.close();
- ifstream info2("info2.txt");
- if (!info2.is_open()) {
- ofstream info2("info2.txt");
- info2.close();
- }
- else info2.close();
- ifstream users("users.txt");
- if (!users.is_open()) {
- ofstream users("users.txt");
- users.close();
- }
- else users.close();
- ifstream admin("admin.txt");
- if (!admin.is_open()) {
- ofstream admin("admin.txt");
- admin.close();
- }
- else admin.close();
- }
- void QuickSort(int *mass, int size, int left, int right) {
- int i = left;
- int j = right;
- int test = mass[(left + right) / 2];
- do {
- while (mass[i] < test)i++;
- while (mass[j] > test)j--;
- if (i <= j) {
- swap(mass[i++], mass[j--]);
- }
- } while (i <= j);
- if (i < right) {
- QuickSort(mass, size, i, right);
- }
- if (j > left) {
- QuickSort(mass, size, left, j);
- }
- }
- void sort_full_info_id() {
- ifstream f("info.txt", ios_base::app);
- if (f.peek() == EOF)
- {
- cout << "Файл пустой." << endl;
- f.close();
- }
- else {
- f.close();
- int count = 0;
- ifstream f1("info.txt", ios_base::app);
- while (f1 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- count++;
- }
- f1.close();
- ifstream p("info.txt", ios_base::app);
- int *mass = new int[count];
- int i = 0;
- while (p >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- mass[i] = info.participant.ID;
- i++;
- }
- p.close();
- QuickSort(mass, count, 0, count - 1);
- ofstream copy("info2.txt", ios_base::ate);
- for (int j = 0; j < count; j++) {
- ifstream file("info.txt", ios_base::app);
- while (file >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- if (mass[j] == info.participant.ID) {
- copy << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- }
- file.close();
- }
- copy.close();
- ofstream f11("info.txt", ios_base::ate);
- ifstream f12("info2.txt", ios_base::app);
- while (f12 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- f11 << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- f11.close();
- f12.close();
- }
- }
- void sort_full_info_family() {
- ifstream f("info.txt", ios_base::app);
- if (f.peek() == EOF)
- {
- cout << "Файл пустой." << endl;
- f.close();
- }
- else {
- f.close();
- int count = 0;
- ifstream f1("info.txt", ios_base::app);
- while (f1 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- count++;
- }
- f1.close();
- ifstream p("info.txt", ios_base::app);
- int *mass = new int[count];
- string *family = new string[count];
- int i = 0;
- while (p >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- mass[i] = info.participant.ID;
- family[i] = info.participant.family;
- i++;
- }
- p.close();
- for (int i = 0; i < count - 1; i++)
- {
- for (int j = 0; j < count - i - 1; j++)
- {
- if (family[j] > family[j+1])
- {
- swap(family[j], family[j + 1]);
- swap(mass[j], mass[j + 1]);
- }
- }
- }
- ofstream copy("info2.txt", ios_base::ate);
- for (int j = 0; j < count; j++) {
- ifstream file("info.txt", ios_base::app);
- while (file >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- if (mass[j] == info.participant.ID) {
- copy << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- }
- file.close();
- }
- copy.close();
- ofstream f11("info.txt", ios_base::ate);
- ifstream f12("info2.txt", ios_base::app);
- while (f12 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- f11 << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- f11.close();
- f12.close();
- }
- }
- void sort_full_info_date() {
- ifstream f("info.txt", ios_base::app);
- if (f.peek() == EOF)
- {
- cout << "Файл пустой." << endl;
- f.close();
- }
- else {
- f.close();
- int count = 0;
- ifstream f1("info.txt", ios_base::app);
- while (f1 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- count++;
- }
- f1.close();
- ifstream p("info.txt", ios_base::app);
- int *mass = new int[count];
- int *day = new int[count];
- int *month = new int[count];
- int *year = new int[count];
- int i = 0;
- while (p >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- mass[i] = info.participant.ID;
- day[i] = info.day;
- month[i] = info.month;
- year[i] = info.year;
- i++;
- }
- p.close();
- for (int i = 0; i < count - 1; i++)
- {
- for (int j = 0; j < count - i - 1; j++)
- {
- if (year[j] > year[j + 1] || (year[j] == year[j + 1] && (month[j] > month[j + 1] || (month[j] == month[j + 1] && day[j] > day[j + 1]))))
- {
- swap(year[j], year[j + 1]);
- swap(month[j], month[j + 1]);
- swap(day[j], day[j + 1]);
- swap(mass[j], mass[j + 1]);
- }
- }
- }
- ofstream copy("info2.txt", ios_base::ate);
- for (int j = 0; j < count; j++) {
- ifstream file("info.txt", ios_base::app);
- while (file >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- if (mass[j] == info.participant.ID) {
- copy << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- }
- file.close();
- }
- copy.close();
- ofstream f11("info.txt", ios_base::ate);
- ifstream f12("info2.txt", ios_base::app);
- while (f12 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- f11 << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- f11.close();
- f12.close();
- }
- }
- int admin_menu() {
- int input;
- do {
- fflush(stdin);
- cout << "МЕНЮ АДМИНИСТРАТОРА" << endl;
- cout << "=========================================" << endl;
- cout << "Сделайте выбор" << endl;
- cout << "1. Создание/открытие файла с данными" << endl;
- cout << "2. Добавление записи" << endl;
- cout << "3. Редактирование записи" << endl;
- cout << "4. Удаление записи" << endl;
- cout << "5. Просмотр всех данных в табличной форме" << endl;
- cout << "6. Поиск и фильтрация данных" << endl;
- cout << "7. Управление пользователями" << endl;
- cout << "8. Выход в меню 1-ого уровня" << endl;
- cin >> input;
- proverka_na_chislo(input);
- system("cls");
- } while (input > 8 || input < 1);
- return input;
- }
- int user_menu() {
- int input;
- do {
- fflush(stdin);
- cout << "МЕНЮ ПОЛЬЗОВАТЕЛЯ" << endl;
- cout << "=========================================" << endl;
- cout << "Сделайте выбор" << endl;
- cout << "1. Открытие файла с данными" << endl;
- cout << "2. Просмотр всех данных в табличной форме" << endl;
- cout << "3. Выполение задачи" << endl;
- cout << "4. Поиск и фильтрация данных" << endl;
- cout << "5. Выход в меню 1-ого уровня" << endl;
- cin >> input;
- proverka_na_chislo(input);
- system("cls");
- } while (input > 5 || input < 1);
- return input;
- }
- int sravnenie_s_tekushey_datoy(int day, int month, int year) {
- int check = 1;
- time_t seconds = time(NULL); //из интернета
- tm *timeinfo = localtime(&seconds);
- if (year > timeinfo->tm_year + 1900) {
- check = 0;
- }
- if (year == timeinfo->tm_year + 1900 && month > timeinfo->tm_mon + 1) {
- check = 0;
- }
- if (year == timeinfo->tm_year + 1900 && month == timeinfo->tm_mon + 1 && day > timeinfo->tm_mday) {
- check = 0;
- }
- return check;
- }
- int check_date(int day, int month, int year) {
- int check;
- bool visokosni_god = false;
- bool korrekt_data = true;
- check = sravnenie_s_tekushey_datoy(day, month, year);
- if (check == 0) {
- cout << "Будущая дата" << endl;
- cout << "Повторите ввод" << endl;
- return true;
- }
- else {
- if (year % 4 == 0) {
- visokosni_god = true;
- }
- if (year < 1900 || year > 2019) {
- korrekt_data = false;
- }
- if (day < 1 || day > 31) {
- korrekt_data = false;
- }
- if (month < 1 || month > 12) {
- korrekt_data = false;
- }
- if (month == 2 && day > 29 && visokosni_god == true) {
- korrekt_data = false;
- }
- if (month == 2 && day > 28 && visokosni_god == false) {
- korrekt_data = false;
- }
- if (month == 4 || month == 6 || month == 9 || month == 11) {
- if (day > 30) {
- korrekt_data = false;
- }
- }
- if (korrekt_data == true) {
- return false;
- }
- else {
- cout << "Неверный формат/такая дата не существует! Введите данные заново!" << endl;
- return true;
- }
- }
- }
- void add_jury() {
- ofstream file2("jury.txt", ios_base::app);
- if (!file2) {
- cout << "Невозможно открыть файл." << endl;
- system("pause");
- }
- cout << "Введите фамилию председателя жюри :";
- jury.surname = add_protect();
- cout << "Введите номер телефона председателя жюри :";
- cin >> jury.phone;
- ifstream check("jury.txt", ios_base::app);
- int ID = 1;
- while (check >> jury.surname >> jury.phone >> jury.id_jury) {
- ID++;
- }
- check.close();
- jury.id_jury = ID;
- file2 << jury.surname << ' ' << jury.phone << ' ' << jury.id_jury << endl;
- file2.close();
- }
- void read_jury() {
- ifstream file1("jury.txt", ios_base::app);
- cout << setw(12) << left << "Фамилия" << setw(12) << left << "Телефон" << setw(12) << left << "ID" << endl;
- while (file1 >> jury.surname >> jury.phone >> jury.id_jury) {
- cout << "___________________________________" << endl;
- cout << setw(12) << jury.surname << setw(12) << jury.phone << setw(12) << jury.id_jury << endl;
- }
- file1.close();
- }
- int kol_jury() {
- int kol = 0;
- ifstream file("jury.txt", ios_base::app);
- while (file >> jury.surname >> jury.phone >> jury.id_jury) {
- kol++;
- }
- file.close();
- return kol;
- }
- int add_participant() {
- ofstream f("info.txt", ios_base::app);
- if (!f) {
- cout << "Невозможно открыть файл." << endl;
- system("pause");
- }
- cout << "Введите имя :";
- info.participant.name = add_protect();
- cout << "Введите фамилию :";
- info.participant.family = add_protect();
- cout << "Введите отчество :";
- info.participant.patronymic = add_protect();
- ifstream check("info.txt", ios_base::app);
- int ID = 1;
- while (check >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- ID++;
- }
- check.close();
- info.participant.ID = ID;
- cout << "Введите название песни :";
- info.participant.kategory.song = add_protect();
- cout << "Введите инструмент :";
- info.participant.kategory.tool = add_protect();
- float sum = 0, grade, kol;
- kol = kol_jury();
- if (kol == 0) {
- system("cls");
- cout << "Не существует ни одного председателя жюри! Добавьте хотя бы одного" << endl;
- system("pause");
- return 0;
- }
- else {
- cout << "Необходимо расставить оценки жюри" << endl;
- read_jury();
- ifstream file("jury.txt", ios_base::app);
- while (file >> jury.surname >> jury.phone >> jury.id_jury) {
- cout << "Введите оценку члена жюри с индиф. номером " << jury.id_jury << ": ";
- cin >> grade;
- sum = sum + grade;
- }
- file.close();
- info.rating = sum / kol;
- cout << "Введите дату выступления" << endl;
- bool check = true;
- int day, month, year;
- while (check) {
- cout << "Введите день выступления" << endl;
- rewind(stdin);
- cin >> day;
- proverka_na_chislo(day);
- cout << "Введите месяц выступления" << endl;
- rewind(stdin);
- cin >> month;
- proverka_na_chislo(month);
- cout << "Введите год выступления" << endl;
- rewind(stdin);
- cin >> year;
- proverka_na_chislo(year);
- check = check_date(day, month, year);
- }
- info.day = day;
- info.month = month;
- info.year = year;
- f << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- f.close();
- return 0;
- system("cls");
- }
- void read_participant() {
- ifstream file1("info.txt", ios_base::app);
- if (!file1) {
- cout << "Невозможно открыть файл." << endl;
- system("pause");
- }
- cout << setw(12) << left << "Имя" << setw(12) << left << "Фамилия" << setw(12) << left << "Отчество" << setw(12) << left << "ID" << setw(12) << left << "Песня" << setw(12) << left << "Инструмент" << endl;
- while (file1 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- cout << "______________________________________________________________________" << endl;
- cout << setw(12) << info.participant.name << setw(12) << info.participant.family << setw(12) << info.participant.patronymic << setw(12) << info.participant.ID << setw(12) << info.participant.kategory.song << setw(12) << info.participant.kategory.tool << endl;
- }
- file1.close();
- }
- void redakt_participant()
- {
- ifstream red_f1("info.txt", ios_base::app);
- ofstream red_f2("info2.txt", ios_base::ate);
- int id_redakt;
- read_participant();
- cout << endl << endl;
- cout << "Введите ID участника, данные которого нужно изменить" << endl;
- cin >> id_redakt;
- proverka_na_chislo(id_redakt);
- while (red_f1 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year)
- {
- if (info.participant.ID != id_redakt)
- {
- red_f2 << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song << ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- else if (info.participant.ID == id_redakt) {
- cout << "Введите имя :";
- info.participant.name = add_protect();
- cout << "Введите фамилию :";
- info.participant.family = add_protect();
- cout << "Введите отчество :";
- info.participant.patronymic = add_protect();
- info.participant.ID = id_redakt;
- cout << "Введите название песни :";
- info.participant.kategory.song = add_protect();
- cout << "Введите инструмент(если таков имеется) :";
- info.participant.kategory.tool = add_protect();
- float sum = 0, grade, kol;
- kol = kol_jury();
- cout << "Необходимо расставить оценки жюри" << endl;
- read_jury();
- ifstream file("jury.txt", ios_base::app);
- while (file >> jury.surname >> jury.phone >> jury.id_jury) {
- cout << "Введите оценку члена жюри с индиф. номером " << jury.id_jury << ": ";
- cin >> grade;
- proverka_na_chislo(grade);
- sum = sum + grade;
- }
- file.close();
- info.rating = sum / kol;
- cout << "Введите дату выступления" << endl;
- bool check = true;
- int day, month, year;
- while (check) {
- cout << "Введите день" << endl;
- rewind(stdin);
- cin >> day;
- proverka_na_chislo(day);
- cout << "Введите месяц" << endl;
- rewind(stdin);
- cin >> month;
- proverka_na_chislo(month);
- cout << "Введите год" << endl;
- rewind(stdin);
- cin >> year;
- proverka_na_chislo(year);
- check = check_date(day, month, year);
- }
- info.day = day;
- info.month = month;
- info.year = year;
- red_f2 << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- }
- red_f1.close();
- red_f2.close();
- ofstream red_f3("info.txt", ios_base::ate);
- ifstream red_f4("info2.txt", ios_base::app);
- while (red_f4 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- red_f3 << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- red_f3.close();
- red_f4.close();
- system("pause");
- }
- void redakt_jury()
- {
- ifstream red_f1("jury.txt", ios_base::app);
- ofstream red_f2("jury2.txt", ios_base::ate);
- int id_redakt;
- read_jury();
- cout << endl << endl;
- cout << "Введите ID председателя жюри, данные которого нужно изменить" << endl;
- cin >> id_redakt;
- proverka_na_chislo(id_redakt);
- while (red_f1 >> jury.surname >> jury.phone >> jury.id_jury)
- {
- if (jury.id_jury != id_redakt)
- {
- red_f2 << jury.surname << ' ' << jury.phone << ' ' << jury.id_jury << endl;
- }
- else if (jury.id_jury == id_redakt) {
- cout << "Введите фамилию :";
- jury.surname = add_protect();
- cout << "Введите номер телефона :";
- cin >> jury.phone;
- jury.id_jury = id_redakt;
- red_f2 << jury.surname << ' ' << jury.phone << ' ' << jury.id_jury << endl;
- }
- }
- red_f1.close();
- red_f2.close();
- ofstream red_f3("jury.txt", ios_base::ate);
- ifstream red_f4("jury2.txt", ios_base::app);
- while (red_f4 >> jury.surname >> jury.phone >> jury.id_jury)
- {
- red_f3 << jury.surname << ' ' << jury.phone << ' ' << jury.id_jury << endl;
- }
- red_f3.close();
- red_f4.close();
- system("pause");
- }
- void full_poisk() {
- char c;
- ifstream file("info.txt"); // открыли файл с текстом
- string s;
- int amount = 0;
- while (!file.eof()) { // прочитали его и заполнили им строку
- file.get(c);
- s.push_back(c);
- amount++;
- }
- file.close();
- string t;
- cout << "Общий файл" << endl;
- cout << "Введите запрос" << endl;
- cin >> t;
- int i, j, k, x, size = t.size(), string = 1;
- bool check = false;
- for (i = 0; i <= amount - size - 1; i++) {
- if (s[i] == '\n') {
- string += 1;
- }
- if (s[i] == t[0]) {
- k = i;
- x = 0;
- for (j = 1; j < size + 1; j++) {
- if (s[k + j] != t[j]) {
- break;
- }
- else x++;
- }
- if (x + 1 == size) {
- ifstream f("info.txt", ios_base::app);
- if (f.peek() == EOF)
- {
- cout << "Файл пустой." << endl;
- }
- else {
- if (check == false) {
- cout << setw(84) << " " << "Дата выступления" << endl;
- cout << setw(12) << left << "Имя" << setw(12) << left << "Фамилия" << setw(12) << left << "Отчество" << setw(12) << left << "ID" << setw(12) << left << "Песня" << setw(12) << left << "Инструмент" << setw(12) << left << "Рейтинг" << setw(12) << left << "День" << setw(12) << left << "Месяц" << setw(12) << left << "Год" << endl;
- check = true;
- }
- while (f >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- if (string == info.participant.ID) {
- cout << setw(12) << info.participant.name << setw(12) << info.participant.family << setw(12) << info.participant.patronymic << setw(12) << info.participant.ID << setw(12) << info.participant.kategory.song << setw(12) << info.participant.kategory.tool << setw(12) << left << info.rating << setw(12) << left << info.day << setw(12) << left << info.month << setw(12) << left << info.year << endl;
- cout << "_______________________________________________________________________________________________________________________" << endl;
- }
- }
- while (s[i + 1] != '\n') {
- i++;
- }
- }
- f.close();
- }
- }
- }
- if (check == false) {
- system("cls");
- cout << "Информация не найдена!" << endl;
- }
- system("pause");
- system("cls");
- }
- void jury_poisk() {
- char c;
- ifstream file("jury.txt"); // открыли файл с текстом
- string s;
- int amount = 0;
- while (!file.eof()) { // прочитали его и заполнили им строку
- file.get(c);
- s.push_back(c);
- amount++;
- }
- file.close();
- string t;
- cout << "Общий файл" << endl;
- cout << "Введите запрос" << endl;
- cin >> t;
- int i, j, k, x, size = t.size(), string = 1;
- bool check = false;
- for (i = 0; i <= amount - size - 1; i++) {
- if (s[i] == '\n') {
- string += 1;
- }
- if (s[i] == t[0]) {
- k = i;
- x = 0;
- for (j = 1; j < size + 1; j++) {
- if (s[k + j] != t[j]) {
- break;
- }
- else x++;
- }
- if (x + 1 == size) {
- ifstream f("jury.txt", ios_base::app);
- if (f.peek() == EOF)
- {
- cout << "Файл пустой." << endl;
- }
- else {
- if (check == false) {
- cout << setw(12) << left << "Фамилия" << setw(12) << left << "Телефон" << setw(12) << left << "ID" << endl;
- check = true;
- }
- while (f >> jury.surname >> jury.phone >> jury.id_jury) {
- if (string == jury.id_jury) {
- cout << setw(12) << jury.surname << setw(12) << jury.phone << setw(12) << jury.id_jury << endl;
- cout << "___________________________________" << endl;
- }
- }
- while (s[i + 1] != '\n') {
- i++;
- }
- }
- f.close();
- }
- }
- }
- if (check == false) {
- system("cls");
- cout << "Информация не найдена!" << endl;
- }
- system("pause");
- system("cls");
- }
- void poisk_menu() {
- int input;
- bool hod = true;
- while (hod) {
- cout << "Меню поиска" << endl;
- cout << "1. Поиск по файлу с полной информацией об участнике музыкального конкурса" << endl;
- cout << "2. Поиск по файлу с жюри" << endl;
- cout << "3. Шаг назад" << endl;
- cin >> input;
- proverka_na_chislo(input);
- system("cls");
- switch (input) {
- case 1: {
- full_poisk();
- system("cls");
- break;
- }
- case 2: {
- jury_poisk();
- system("cls");
- break;
- }
- case 3: {
- hod = false;
- }
- default: {
- cout << "Неверный ввод повторите попытку" << endl;
- }
- }
- }
- }
- void delete_participant() {
- ifstream del_f1("info.txt", ios_base::app);
- ofstream del_f2("info2.txt", ios_base::ate);
- int id_delete;
- read_participant();
- cout << endl << endl;
- cout << "Введите ID участника, которого нужно удалить" << endl;
- cin >> id_delete;
- proverka_na_chislo(id_delete);
- while (del_f1 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- if (info.participant.ID != id_delete) {
- del_f2 << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- }
- del_f1.close();
- del_f2.close();
- ofstream del_f3("info.txt", ios_base::ate);
- ifstream del_f4("info2.txt", ios_base::app);
- int ID = 1;
- while (del_f4 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- info.participant.ID = ID;
- ID++;
- del_f3 << info.participant.name << ' ' << info.participant.family << ' ' << info.participant.patronymic << ' ' << info.participant.ID << ' ' << info.participant.kategory.song <<
- ' ' << info.participant.kategory.tool << ' ' << info.rating << ' ' << info.day << ' ' << info.month << ' ' << info.year << endl;
- }
- del_f3.close();
- del_f4.close();
- system("pause");
- }
- void delete_jury()
- {
- ifstream del_f1("jury.txt", ios_base::app);
- ofstream del_f2("jury2.txt", ios_base::ate);
- int id_delete;
- read_jury();
- cout << endl << endl;
- cout << "Введите ID председателя жюри, которого нужно удалить" << endl;
- cin >> id_delete;
- proverka_na_chislo(id_delete);
- int ID = 1;
- while (del_f1 >> jury.surname >> jury.phone >> jury.id_jury) {
- if (jury.id_jury != id_delete) {
- jury.id_jury = ID;
- ID++;
- del_f2 << jury.surname << ' ' << jury.phone << ' ' << jury.id_jury << endl;
- }
- }
- del_f1.close();
- del_f2.close();
- ofstream del_f3("jury.txt", ios_base::ate);
- ifstream del_f4("jury2.txt", ios_base::app);
- while (del_f4 >> jury.surname >> jury.phone >> jury.id_jury) {
- del_f3 << jury.surname << ' ' << jury.phone << ' ' << jury.id_jury << endl;
- }
- del_f3.close();
- del_f4.close();
- }
- void read_full_info() {
- ifstream file1("info.txt", ios_base::app);
- cout << setw(84) << " " << "Дата выступления" << endl;
- cout << setw(12) << left << "Имя" << setw(12) << left << "Фамилия" << setw(12) << left << "Отчество" << setw(12) << left << "ID" << setw(12) << left << "Песня" << setw(12) << left << "Инструмент" << setw(12) << left << "Рейтинг" << setw(12) << left << "День" << setw(12) << left << "Месяц" << setw(12) << left << "Год" << endl;
- while (file1 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- cout << "_______________________________________________________________________________________________________________________" << endl;
- cout << setw(12) << info.participant.name << setw(12) << info.participant.family << setw(12) << info.participant.patronymic << setw(12) << info.participant.ID << setw(12) << info.participant.kategory.song << setw(12) << info.participant.kategory.tool << setw(12) << left << info.rating << setw(12) << left << info.day << setw(12) << left << info.month << setw(12) << left << info.year << endl;
- }
- file1.close();
- }
- void read_ocenki() {
- ifstream file1("info.txt", ios_base::app);
- if (!file1) {
- cout << "Невозможно открыть файл." << endl;
- system("pause");
- }
- cout << setw(12) << left << "Имя" << setw(12) << left << "Фамилия" << setw(12) << left << "Отчество" << setw(12) << left << "ID" << setw(12) << left << "Рейтинг" << endl;
- while (file1 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- cout << "______________________________________________________________________" << endl;
- cout << setw(12) << info.participant.name << setw(12) << info.participant.family << setw(12) << info.participant.patronymic << setw(12) << info.participant.ID << setw(12) << info.rating << endl;
- }
- file1.close();
- }
- void read_users() {
- ifstream file1("users.txt", ios_base::app);
- if (file1.peek() == EOF) {
- cout << "Зарегистрированных пользователей не существует!" << endl;
- }
- else {
- cout << setw(20) << left << "Логин" << setw(20) << "Пароль" << endl;
- while (file1 >> user.log >> user.pass) {
- cout << "___________________________________" << endl;
- user.log = Shifr(user.log, 0);
- user.pass = Shifr(user.pass, 0);
- cout << setw(20) << user.log << setw(20) << user.pass << endl;
- }
- }
- file1.close();
- }
- void delete_user() {
- bool check = false;
- read_users();
- ifstream file1("users.txt", ios_base::app);
- if (!file1.peek() == EOF) {
- cout << "Введите логин пользователя, которого вы хотите удалить" << endl;
- string login;
- cin >> login;
- login = Shifr(login, 1);
- while (file1 >> user.log >> user.pass) {
- if (user.log == login) {
- check = true;
- break;
- }
- }
- file1.close();
- if (check == false) {
- cout << "Пользователь с данным логином не найдем" << endl;
- }
- else {
- ifstream del_f1("users.txt", ios_base::app);
- ofstream del_f2("users2.txt", ios_base::ate);
- while (del_f1 >> user.log >> user.pass) {
- if (login != user.log) {
- del_f2 << user.log << ' ' << user.pass << endl;
- }
- }
- del_f1.close();
- del_f2.close();
- ofstream del_f3("users.txt", ios_base::ate);
- ifstream del_f4("users2.txt", ios_base::app);
- while (del_f4 >> user.log >> user.pass) {
- del_f3 << user.log << ' ' << user.pass << endl;
- }
- del_f3.close();
- del_f4.close();
- system("pause");
- }
- }
- }
- void sort_menu();
- int check_admin() {
- bool result = false;
- char new_login[20], new_password[20], new_password_2[20];
- FILE *f = fopen("admin.txt", "rb");
- char a;
- size_t readed = fread(&a, 1, 1, f);
- if (!readed) {
- cout << "Вы первый администратор! Зарегистрируйтесь" << endl;
- cout << "Введите новый логин: " << endl;
- fflush(stdin);
- cin >> new_login;
- while (strcmp(new_password, new_password_2)) {
- cout << "Введите новый пароль: " << endl;
- fflush(stdin);
- cin >> new_password;
- cout << "Введите новый пароль еще раз для подтвержения: " << endl;
- fflush(stdin);
- cin >> new_password_2;
- if (strcmp(new_password, new_password_2)) {
- cout << "Пароли не совпадают!" << endl;
- }
- }
- string new_log, new_pass;
- new_log = new_login;
- new_pass = new_password;
- new_log = Shifr(new_log, 1);
- new_pass = Shifr(new_pass, 1);
- ofstream fout("admin.txt"); // создаём объект класса ofstream для записи и связываем его с файлом admin.txt
- fout << new_log << " " << new_pass; // запись строки в файл
- fout.close();
- }
- else {
- char login[20], password[20], true_login[20], true_password[20];
- FILE *f;
- f = fopen("admin.txt", "rt"); //переписать эту муть через fstream
- fscanf(f, "%s%s", &true_login, &true_password);
- fclose(f);
- fflush(stdin);
- cout << "Введите логин и пароль для входа в учетную запись администратора" << endl;
- while (result == false) {
- cout << "Логин: " << endl;
- fflush(stdin); //убрать все вот эти штуки
- cin >> login;
- cout << "Пароль: " << endl;
- int i = 0;
- while (i < 20)
- {
- char c;
- if (!(c = _getch())) {
- c = _getch();
- if (c == 8) {
- system("cls");
- cout << "Введите логин и пароль для входа в учетную запись администратора" << endl;
- cout << "Логин: " << endl;
- cout << login << endl;
- cout << "Пароль: " << endl;
- i = -1;
- }
- if (c == 13)
- break;
- }
- if (i != -1) {
- password[i] = c;
- }
- i++;
- if (c != 8) {
- _putch('*');
- }
- }
- password[i] = '\0';
- string pass = password, log = login;
- pass = Shifr(pass, 1);
- log = Shifr(log, 1);
- fflush(stdin);
- if ((log == true_login) && (pass == true_password)) {
- result = true;
- }
- else {
- cout << "\nНеверный логин и/или пароль!" << endl;
- system("pause");
- system("cls");
- return 0;
- }
- }
- }
- if (result == true) {
- while (1) {
- system("cls");
- switch (admin_menu())
- {
- case 1: {
- cout << "1. Создание/открытие файла с данными" << endl;
- cout << "1 - Файл с участниками и оценками " << endl << "2 - Файл с председателями жюри." << endl << "3 - Назад в меню." << endl;
- int flag;
- cout << "Выберите действие :";
- cin >> flag;
- proverka_na_chislo(flag);
- rewind(stdin);
- switch (flag) {
- case 1: {
- ifstream person_file("info.txt");
- if (!person_file) {
- cout << "Создан новый файл!" << endl;
- }
- person_file.close();
- ofstream person_file_out("info.txt", ios_base::app);
- person_file_out.close();
- system("info.txt");
- break;
- }
- case 2:
- {
- ifstream jur_file("jury.txt");
- if (!jur_file) {
- cout << "Создан новый файл!" << endl;
- }
- jur_file.close();
- ofstream jur_file_out("jury.txt", ios_base::app);
- jur_file_out.close();
- system("jury.txt");
- break;
- }
- case 3:
- {
- break;
- }
- }
- break;
- }
- case 2: {
- cout << "2. Добавление записи" << endl;
- cout << "1 - Файл с участниками и оценками." << endl << "2 - Файл с председателями жюри." << endl << "3 - Назад в меню." << endl;
- int flag;
- cout << "Выберите действие :";
- cin >> flag;
- proverka_na_chislo(flag);
- switch (flag) {
- case 1: {
- add_participant();
- break;
- }
- case 2: {
- add_jury();
- break;
- }
- case 3: {
- break;
- }
- default: {
- cout << "Вы неверно выбрали действие, повторите попытку!" << endl;
- cin.clear();
- cin.sync();
- rewind(stdin);
- system("pause");
- break;
- }
- }
- break;
- }
- case 3: {
- cout << "3. Редактирование записи" << endl;
- cout << "1 - Файл с участниками и оценками." << endl << "2 - Файл с председателями жюри." << endl << "3 - Назад в меню." << endl;
- int flag;
- cout << "Выберите действие :";
- cin >> flag;
- proverka_na_chislo(flag);
- switch (flag) {
- case 1: {
- redakt_participant();
- break;
- }
- case 2: {
- redakt_jury();
- break;
- }
- case 3: {
- break;
- }
- default: {
- cout << "Вы неверно выбрали действие, повторите попытку!" << endl;
- cin.clear();
- cin.sync();
- rewind(stdin);
- system("pause");
- break;
- }
- }
- break;
- }
- case 4: {
- cout << "4. Удаление записи" << endl;
- cout << "1 - Файл с участниками и оценками." << endl << "2 - Файл с председателями жюри." << endl << "3 - Назад в меню." << endl;
- int flag;
- cout << "Выберите действие :";
- cin >> flag;
- proverka_na_chislo(flag);
- switch (flag) {
- case 1: {
- delete_participant();
- break;
- }
- case 2: {
- delete_jury();
- break;
- }
- case 3: {
- break;
- }
- default: {
- cout << "Вы неверно выбрали действие, повторите попытку!" << endl;
- cin.clear();
- cin.sync();
- rewind(stdin);
- system("pause");
- break;
- }
- }
- break;
- }
- case 5: {
- cout << "5. Просмотр всех данных в табличной форме" << endl;
- cout << "1 - Файл с участниками." << endl << "2 - Файл с председателями жюри." << endl << "3 - Файл с оценками" << endl << "4 - Файл с полной информацией" << endl << "5 - Назад в меню." << endl;
- int flag;
- cout << "Выберите действие :";
- cin >> flag;
- proverka_na_chislo(flag);
- switch (flag) {
- case 1: {
- read_participant();
- system("pause");
- system("cls");
- break;
- }
- case 2: {
- read_jury();
- system("pause");
- system("cls");
- break;
- }
- case 3: read_ocenki();
- system("pause");
- system("cls");
- break;
- case 4: {
- read_full_info();
- system("pause");
- system("cls");
- break;
- }
- case 5: {
- break;
- }
- default: {
- cout << "Вы неверно выбрали действие, повторите попытку!" << endl;
- cin.clear();
- cin.sync();
- rewind(stdin);
- system("pause");
- break;
- }
- }
- break;
- }
- case 6: {
- cout << "6. Поиск и фильтрация данных" << endl;
- cout << "1. Поиск данных" << endl;
- cout << "2. Фильтрация данных" << endl;
- cout << "3. Сортировка данных" << endl;
- cout << "4. Назад" << endl;
- cout << "Выберите действие :";
- int result;
- cin >> result;
- proverka_na_chislo(result);
- switch (result) {
- case 1: {
- poisk_menu();
- system("cls");
- break;
- }
- case 2: {
- filtr_menu();
- break;
- }
- case 3: {
- sort_menu();
- system("cls");
- break;
- }
- case 4: {
- break;
- }
- default: {
- cout << "Вы неверно выбрали действие, повторите попытку!" << endl;
- cin.clear();
- cin.sync();
- rewind(stdin);
- system("pause");
- break;
- }
- }
- break;
- }
- case 7: {
- cout << "7. Управление пользователями" << endl;
- cout << "1. Просмотр списка логинов и паролей учетных записей" << endl << "2. Удаление пользователя" << endl << "3. Шаг назад" << endl;
- int flag;
- cout << "Выберите действие :";
- cin >> flag;
- proverka_na_chislo(flag);
- switch (flag) {
- case 1: {
- read_users();
- system("pause");
- system("cls");
- break;
- }
- case 2: {
- delete_user();
- system("pause");
- system("cls");
- break;
- }
- case 3: {
- break;
- }
- default: {
- cout << "Вы неверно выбрали действие, повторите попытку!" << endl;
- cin.clear();
- cin.sync();
- rewind(stdin);
- system("pause");
- break;
- }
- }
- break;
- }
- case 8: {
- return 0;
- }
- }
- }
- }
- system("cls");
- return 0;
- }
- void user_registr() {
- string new_log, new_pass;
- bool flag = true;
- cout << "Регистрация нового пользователя" << endl;
- while (flag == true) {
- bool check = false;
- cout << "Введите новый логин для регистрации" << endl;
- rewind(stdin);
- cin >> new_log;
- cout << "Введите новый пароль для регистрации" << endl;
- rewind(stdin);
- cin >> new_pass;
- ifstream u("users.txt", ios_base::app);
- if (!u) {
- cout << "Файл не существует!" << endl;
- system("pause");
- }
- while (u >> user.log >> user.pass) {
- if (user.log == new_log) {
- check = true;
- break;
- }
- }
- u.close();
- if (check == true) {
- cout << "Пользователь с данным логином уже существует!" << endl;
- }
- else flag = false;
- }
- user.log = Shifr(new_log, 1);
- user.pass = Shifr(new_pass, 1);
- ofstream fout("users.txt", ios_base::app);
- fout << user.log << " " << user.pass << endl;
- fout.close();
- system("cls");
- cout << "Вы зарегистрированы." << endl;
- }
- void zadanie() {
- int max_day, max_month, max_year;
- ifstream f("info.txt", ios_base::app);
- if (f.peek() == EOF) {
- cout << "Участников нет" << endl;
- }
- else {
- while (f >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- max_day = info.day;
- max_month = info.month;
- max_year = info.year;
- break;
- }
- f.close();
- ifstream f1("info.txt", ios_base::app);
- while (f1 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- if (info.year > max_year) {
- max_year = info.year;
- }
- if (max_year == info.year && max_month < info.month) {
- max_month = info.month;
- }
- if (max_year == info.year && max_month == info.month && max_day < info.day) {
- max_day = info.day;
- }
- }
- f1.close();
- ifstream f2("info.txt", ios_base::app);
- float rating = 0, count = 0;
- while (f2 >> info.participant.name >> info.participant.family >> info.participant.patronymic >> info.participant.ID >> info.participant.kategory.song >> info.participant.kategory.tool >> info.rating >> info.day >> info.month >> info.year) {
- if (info.day == max_day && info.month == max_month && info.year == max_year) {
- count = count + 1;
- rating = rating + info.rating;
- }
- }
- f2.close();
- cout << "Средний балл участников за последнее выступление равен: " << rating / count << endl;
- }
- }
- int user_login() {
- int check = 0;
- ifstream u("users.txt", ios_base::app);
- if (u.peek() == EOF) {
- cout << "Зарегистрированных пользователей не существует!" << endl;
- return 0;
- }
- else {
- string login;
- char password[20];
- cout << "Авторизация" << endl;
- cout << "Введите логин" << endl;
- rewind(stdin);
- cin >> login;
- cout << "Введите пароль" << endl;
- rewind(stdin);
- int i = 0;
- while (i < 20)
- {
- char c;
- if (!(c = _getch())) {
- c = _getch();
- if (c == 8) {
- system("cls");
- cout << "Авторизация" << endl;
- cout << "Введите логин" << endl;
- cout << login << endl;
- cout << "Введите пароль " << endl;
- i = -1;
- }
- if (c == 13)
- break;
- }
- if (i != -1) {
- password[i] = c;
- }
- i++;
- if (c != 8) {
- _putch('*');
- }
- }
- password[i] = '\0';
- string str_password;
- str_password = password;
- str_password = Shifr(str_password, 1);
- login = Shifr(login, 1);
- cout << endl;
- while (u >> user.log >> user.pass) {
- if (user.log == login && user.pass == str_password) {
- check = 1;
- system("cls");
- break;
- }
- }
- u.close();
- if (check == 0) {
- system("cls");
- cout << "Данного пользователя не существует, либо неправильный пароль" << endl;
- return 0;
- }
- else
- {
- switch (user_menu())
- {
- case 1:
- {
- cout << "1. Создание/открытие файла с данными" << endl;
- cout << "1 - Файл с участниками и оценками " << endl << "2 - Файл с председателями жюри." << endl << "3 - Назад в меню." << endl;
- int flag;
- cout << "Выберите действие :";
- cin >> flag;
- proverka_na_chislo(flag);
- rewind(stdin);
- switch (flag) {
- case 1: {
- ifstream person_file("info.txt");
- if (!person_file) {
- cout << "Создан новый файл!" << endl;
- }
- person_file.close();
- ofstream person_file_out("info.txt", ios_base::app);
- person_file_out.close();
- system("info.txt");
- break;
- }
- case 2:
- {
- ifstream jur_file("jury.txt");
- if (!jur_file) {
- cout << "Создан новый файл!" << endl;
- }
- jur_file.close();
- ofstream jur_file_out("jury.txt", ios_base::app);
- jur_file_out.close();
- system("jury.txt");
- break;
- }
- case 3:
- {
- break;
- }
- }
- break;
- }
- case 2:
- {
- cout << "2. Просмотр всех данных в табличной форме" << endl;
- cout << "1 - Файл с участниками." << endl << "2 - Файл с председателями жюри." << endl << "3 - Файл с рейтингом участника" << endl << "4 - Файл с полной информацией " << endl << "5 - Назад в меню." << endl;
- int flag;
- cout << "Выберите действие :";
- cin >> flag;
- proverka_na_chislo(flag);
- switch (flag) {
- case 1: {
- read_participant();
- system("pause");
- system("cls");
- break;
- }
- case 2: {
- read_jury();
- system("pause");
- system("cls");
- break;
- }
- case 3: read_ocenki();
- system("pause");
- system("cls");
- break;
- case 4: {
- read_full_info();
- system("pause");
- system("cls");
- break;
- }
- case 5: {
- user_menu();
- break;
- }
- default: {
- cout << "Вы неверно выбрали действие, повторите попытку!" << endl;
- cin.clear();
- cin.sync();
- rewind(stdin);
- system("pause");
- break;
- }
- }
- break;
- system("cls");
- }
- case 3: {
- cout << "3. Выполнение задания" << endl;
- zadanie();
- system("pause");
- system("cls");
- break;
- }
- case 4: {
- cout << "4. Поиск и фильтрация данных" << endl;
- cout << "1. Поиск данных" << endl;
- cout << "2. Фильтрация данных" << endl;
- cout << "3. Сортировка данных" << endl;
- cout << "4. Назад" << endl;
- cout << "Выберите действие :";
- int result;
- cin >> result;
- system("cls");
- proverka_na_chislo(result);
- switch (result) {
- case 1: {
- poisk_menu();
- break;
- }
- case 2: {
- filtr_menu();
- break;
- }
- case 3: {
- sort_menu();
- break;
- }
- case 4: {
- user_menu();
- break;
- }
- default: {
- cout << "Вы неверно выбрали действие, повторите попытку!" << endl;
- cin.clear();
- cin.sync();
- rewind(stdin);
- system("pause");
- break;
- }
- }
- break;
- }
- case 8:
- {
- return 0;
- }
- }
- }
- }
- }
- void pre_user_menu() {
- int kol;
- do {
- fflush(stdin);
- cout << "1. Авторизация" << endl;
- cout << "2. Регистрация" << endl;
- cout << "3. Выход в меню 1-уровня" << endl;
- cin >> kol;
- proverka_na_chislo(kol);
- system("cls");
- switch (kol) {
- case 1: {
- user_login();
- break;
- }
- case 2: {
- user_registr();
- break;
- }
- }
- } while (kol != 3);
- }
- void sort_menu() {
- int res;
- bool exit = true;
- while (exit) {
- cout << "Меню сортировки информации" << endl;
- cout << "1. Вывести полную информацию" << endl;
- cout << "2. Сортировать по номеру записи" << endl;
- cout << "3. Сортировать по дате" << endl;
- cout << "4. Сортировка по фамилии" << endl;
- cout << "4. Шаг назад" << endl;
- cin >> res;
- proverka_na_chislo(res);
- system("cls");
- switch (res) {
- case 1: {
- read_full_info();
- system("pause");
- system("cls");
- break;
- }
- case 2: {
- sort_full_info_id();
- system("pause");
- system("cls");
- break;
- }
- case 3: {
- sort_full_info_date();
- system("pause");
- system("cls");
- break;
- }case 4: {
- sort_full_info_family();
- system("pause");
- system("cls");
- break;
- }
- case 5: {
- sort_full_info_id();
- exit = false;
- break;
- }
- default: {
- cout << "Такого пункта меню не существует! Повторите ввод" << endl;
- }
- }
- }
- }
- //язык, красивые таблицы
- //редактирование файла с оценками
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement