Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <conio.h>
- #include <string>
- #include <windows.h>
- using namespace std;
- #define size 30
- struct kniga
- {
- string naz;
- string famA;
- string zhanr;
- string years;
- }books;
- struct otd
- {
- char nazvanie[30];
- char kb[20];
- char time[30];
- }otdell;
- struct sotrudnik
- {
- string name;
- string dolzhnost;
- string bday;
- string telephone;
- }strud;
- struct chitatel
- {
- string famil;
- string namee;
- string otchestvo;
- string bdayy;
- string dolzhnost;
- string telephonee;
- string pasport;
- string datar;
- }chit;
- void Antipova();
- void Sobolev();
- void Bogdanova();
- void sel();
- void vxod();
- void book();
- void otdel();
- void sotrudniki();
- void vvodchitatela();
- void vivodchitatela();
- void sozd();
- void vivod();
- void dobav();
- void poisk();
- void sozd1();
- void vivod1();
- void dobav1();
- void correct1();
- void sozd2();
- void vivod2();
- void dobav2();
- void poisk2();
- void udalen2();
- void poiskkk();
- void vivodkk();
- void removeBookFromLibrary(string bookName);
- void gotoxy(int x, int y)
- {
- HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
- COORD coord = { x,y };
- SetConsoleCursorPosition(hStdOut, coord);
- }
- int main()
- {
- int nom;
- system("cls");
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- do
- {
- system("cls");
- HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
- WORD wColour = FOREGROUND_RED;
- SetConsoleTextAttribute(hStdOut, wColour | FOREGROUND_INTENSITY);
- gotoxy(20, 4);
- cout << " Курсовая работа по дисциплине: ";
- gotoxy(20, 6);
- cout << " Языки и методы программирования";
- gotoxy(20, 8);
- cout << "по теме: Работа с файлами.";
- gotoxy(30, 9);
- cout << " Автоматизированная информационная система Библиотека ";
- gotoxy(20, 11);
- cout << "Выполнила:\t Антипова П.Р.";
- gotoxy(20, 12);
- cout << " \t Группа: ПМ-27Д";
- gotoxy(30, 14);
- cout << "\t 1-Вход в библиотеку\n";
- gotoxy(30, 15);
- cout << "\t 2-Выход из библиотеки\n";
- gotoxy(30, 16);
- cout << "Введите номер пункта: ";
- cin >> nom;
- cin.get();
- switch (nom)
- {
- case 1: vxod(); break;
- case 2: break;
- }
- } while (nom != 2);
- }
- void vxod()
- {
- unsigned short nNumber = 0;
- do
- {
- system("cls");
- cout << "1. Войти как администратор. \n" << endl;
- cout << "2. Войти как пользователь. \n" << endl << endl;
- cout << "Введите номер: ";
- cin >> nNumber;
- cin.clear();
- cin.get();
- } while (nNumber != 1 & nNumber != 2);
- switch (nNumber)
- {
- case 1:
- {
- cout << "Вы попытались войти как администратор." << endl;
- const unsigned short cnPassword = 11;
- unsigned short nPassword = 0;
- do
- {
- cout << "Введите пароль для получения прав администратора: ";
- cin >> nPassword;
- cin.clear();
- cin.sync();
- if (nPassword != cnPassword)
- cout << endl << endl << L"\t\t\t\t Пароль введен неверно! \n\t\t\t\t Повторите попытку." << endl;
- if (nPassword == cnPassword)
- {
- cout << "\n\t\t\tПароль введен верно!\r" << endl;
- unsigned short npunkt = 0;
- do
- {
- system("cls");
- cout << "\t\t Библиотека\n Добро пожаловать!\n";
- cout << "1. Книги\n";
- cout << "2. Отделы\n";
- cout << "3. Сотрудники\n";
- cout << "4. Ввод данных о читателях\n";
- cout << "5. Вывод формуляра читателя\n";
- cout << "6. Выход\n";
- cout << "Введите номер:";
- cin >> npunkt;
- cin.get();
- switch (npunkt)
- {
- case 1: book(); break;
- case 2: otdel(); break;
- case 3: sotrudniki(); break;
- case 4: vvodchitatela(); break;
- case 5: vivodchitatela(); break;
- case 6: break;
- }
- } while (npunkt != 6);
- }
- _getch();
- system("cls");
- } while (cnPassword != nPassword);
- break;
- }
- case 2:
- {
- system("cls");
- int npunktt;
- do
- {
- cout << "\t\t Выберите фамилию:\n";
- cout << "1. Антипова П.Р.\n";
- cout << "2. Соболевская К.А.\n";
- cout << "3. Богданова Т.П.\n";
- cout << "4. Селиверстова Д.В.\n";
- cout << "5. Выход\n";
- cout << "Введите номер:";
- cin >> npunktt;
- cin.get();
- switch
- (npunktt)
- {
- case 1: Antipova(); break;
- case 2: Sobolev(); break;
- case 3: Bogdanova(); break;
- case 4: sel(); break;
- case 5: break;
- }
- } while (npunktt != 5);
- }
- case 0: break;
- }while (nNumber != 0);
- }
- void Antipova()
- {
- system("cls");
- cout << "\t\t Антипова П.Р." <<
- endl;
- const unsigned short cnPasswords = 1234;
- unsigned short nPasswords = 0;
- do
- {
- cout << "Введите пароль : ";
- cin >> nPasswords;
- cin.clear();
- cin.sync();
- if (nPasswords != cnPasswords)
- cout << endl << endl << L"\t\t\t\t Пароль введен неверно! \n\t\t\t\t Повторите попытку." << endl;
- if (nPasswords == cnPasswords)
- {
- cout << "\n\t\t\tПароль введен верно!\r" << endl;
- unsigned short nomer = 0;
- do
- {
- system("cls");
- cout << "\t\t Библиотека\n Добро пожаловать!\n";
- cout << "1. Книги\n";
- cout << "2.Поиск книги\n";
- cout << "3.Мои книги\n";
- cout << "4. Отделы\n";
- cout << "5. Сотрудники\n";
- cout << "6. Выход\n";
- cout << "Введите номер:";
- cin >> nomer;
- cin.clear();
- cin.get();
- switch (nomer)
- {
- case 1: vivod(); break;
- case 2: poiskkk(); break;
- case 3: vivodkk(); break;
- case 4: vivod1(); break;
- case 5: vivod2(); break;
- case 6: break;
- }
- } while (nomer != 6);
- break;
- }
- } while (cnPasswords != nPasswords);
- }
- void poiskkk()
- {
- system("cls");
- string f;
- char sym;
- int pos;
- fstream f3;
- f3.open("f.txt");
- ofstream Q;
- Q.open("Ant.txt");
- cout << "Введите книгу, которую желаете взять: ";
- getline(cin, f);
- string helper = "";
- bool isTook = false;
- kniga temp;
- do
- {
- getline(f3, helper);
- if (helper == "") {
- break;
- }
- pos = f3.tellg();
- books.naz = helper;
- getline(f3, books.famA);
- getline(f3, books.zhanr);
- getline(f3, books.years);
- if (books.naz == f)
- {
- cout << "<Будете брать книгу?";
- cin >> sym;
- cin.get();
- if (sym == 'y')
- {
- system("cls");
- /**
- * Если пользователь решил взять книгу то
- * записываем в файл Ant.txt
- */
- Q << books.naz << endl;
- Q << books.famA << endl;
- Q << books.zhanr << endl;
- Q << books.years << endl;
- temp = books;
- /** так же здесь логично сразу
- * удалить книгу из нашей библиотеки
- * простой способ использовать функцию
- * удаления как и у сотрудников но я так
- * понимаю для книг такой нет
- *
- * Если книгу взяли значит надо
- * переделать записи в библиотеке
- * тут нельзя потому что файл еще не закрыт
- * поэтому необходима эта вспомогательная
- * переменная
- */
- isTook = true;
- }
- }
- } while (f3);
- f3.close();
- if (isTook) {
- removeBookFromLibrary(temp.naz);
- remove("f.txt");
- rename("U.txt", "f.txt");
- }
- _getch();
- }
- void vivodkk()
- {
- }
- void Sobolev()
- {
- system("cls");
- cout << "\t\t Соболевская К.А." << endl;
- const unsigned short cnpPasswords = 12345;
- unsigned short nnPasswords = 0;
- do
- {
- cout << "Введите пароль : ";
- cin >> nnPasswords;
- cin.clear();
- cin.sync();
- if (nnPasswords != cnpPasswords)
- cout << endl << endl << L"\t\t\t\t Пароль введен неверно! \n\t\t\t\t Повторите попытку." << endl;
- if (nnPasswords == cnpPasswords)
- {
- cout << "\n\t\t\tПароль введен верно!\r" << endl;
- unsigned short nomer = 0;
- do
- {
- system("cls");
- cout << "\t\t Библиотека\n Добро пожаловать!\n";
- cout << "1. Книги\n";
- cout << "2. Отделы\n";
- cout << "3. Сотрудники\n";
- cout << "4. Выход\n";
- cout << "Введите номер:";
- cin >> nomer;
- cin.clear();
- cin.get();
- switch (nomer)
- {
- case 1: vivod(); break;
- case 2: vivod1(); break;
- case 3: vivod2(); break;
- case 4: break;
- }
- } while (nomer != 4);
- break;
- }
- } while (cnpPasswords != nnPasswords);
- }
- void Bogdanova()
- {
- system("cls");
- cout << "\t\t Богданова Татьяна" << endl;
- const unsigned short cnPasswordss = 1112;
- unsigned short nPPasswords = 0;
- do
- {
- cout << "Введите пароль : ";
- cin >> nPPasswords;
- cin.clear();
- cin.sync();
- if (nPPasswords != cnPasswordss)
- cout << endl << endl << L"\t\t\t\t Пароль введен неверно! \n\t\t\t\t Повторите попытку." << endl;
- if (nPPasswords == cnPasswordss)
- {
- cout << "\n\t\t\tПароль введен верно!\r" << endl;
- unsigned short nomer = 0;
- do
- {
- system("cls");
- cout << "\t\t Библиотека\n Добро пожаловать!\n";
- cout << "1. Книги\n";
- cout << "2. Отделы\n";
- cout << "3. Сотрудники\n";
- cout << "4. Выход\n";
- cout << "Введите номер:";
- cin >> nomer;
- cin.clear();
- cin.get();
- switch (nomer)
- {
- case 1: vivod(); break;
- case 2: vivod1(); break;
- case 3: vivod2(); break;
- case 4: break;
- }
- } while (nomer != 4);
- break;
- }
- } while (cnPasswordss != nPPasswords);
- }
- void sel()
- {
- system("cls");
- cout << "\t\t Селиверстова Дарья " << endl;
- const unsigned short cnPassWwords = 2111;
- unsigned short nNPasswords = 0;
- do
- {
- cout << "Введите пароль : ";
- cin >> nNPasswords;
- cin.clear();
- cin.sync();
- if (nNPasswords != cnPassWwords)
- cout << endl << endl << L"\t\t\t\t Пароль введен неверно! \n\t\t\t\t Повторите попытку." << endl;
- if (nNPasswords == cnPassWwords)
- {
- cout << "\n\t\t\tПароль введен верно!\r" << endl;
- unsigned short nomer = 0;
- do
- {
- system("cls");
- cout << "\t\t Библиотека\n Добро пожаловать!\n";
- cout << "1. Книги\n";
- cout << "2. Отделы\n";
- cout << "3. Сотрудники\n";
- cout << "4. Выход\n";
- cout << "Введите номер:";
- cin >> nomer;
- cin.clear();
- cin.get();
- switch (nomer)
- {
- case 1: vivod(); break;
- case 2: vivod1(); break;
- case 3: vivod2(); break;
- case 4: break;
- }
- } while (nomer != 4);
- break;
- }
- } while (cnPassWwords != nNPasswords);
- }
- void book()
- {
- int nnomer;
- system("cls");
- struct kniga mas[50];
- do
- {
- system("cls");
- cout << "\t\tКниги !\n";
- cout << "1. Создание книги\n";
- cout << "2. Просмотр книги\n";
- cout << "3. Добавление\n";
- cout << "4. Поиск компоненты\n";
- cout << "5. назад\n";
- cout << "Введите номер пункта:";
- cin >> nnomer;
- cin.clear();
- cin.get();
- switch (nnomer)
- {
- case 1: sozd(); break;
- case 2: vivod(); break;
- case 3: dobav(); break;
- case 4: poisk(); break;
- case 5: break;
- }
- } while (nnomer != 5);
- }
- void otdel()
- {
- int n;
- system("cls");
- do
- {
- system("cls");
- cout << "\t\t Отделы\n";
- cout << "1. Отделы \n";
- cout << "2. Названия отделов\n";
- cout << "3. Отделы корректировка\n";
- cout << "4. назад\n";
- cout << "Введите номер пункта:";
- cin >> n;
- cin.clear();
- cin.get();
- switch (n)
- {
- case 1: sozd1(); break;
- case 2: vivod1(); break;
- case 3: correct1(); break;
- case 4: break;
- }
- } while (n != 4);
- }
- void sotrudniki()
- {
- system("cls");
- int n;
- do
- {
- system("cls");
- cout << "\t\tСотрудники\n";
- cout << "1.Ф.И.О. \n";
- cout << "2.Просмотр сотрудников\n";
- cout << "3.Добавление сотрудников\n";
- cout << "4.Поиск сотрудника\n";
- cout << "5.Удаление сотрудников\n";
- cout << "6. назад\n";
- cout << "Введите номер пункта:";
- cin >> n;
- cin.clear();
- cin.get();
- switch (n)
- {
- case 1: sozd2(); break;
- case 2: vivod2(); break;
- case 3: dobav2(); break;
- case 4: poisk2(); break;
- case 5: udalen2(); break;
- case 6: break;
- }
- } while (n != 6);
- }
- void sozd2()
- {
- ofstream f2;
- f2.open("f2.txt");
- do
- {
- system("cls");
- cout << "Ф.И.О.: \n";
- getline(cin, strud.name);
- cout << "Должность: \n";
- getline(cin, strud.dolzhnost);
- cout << "Дата рождения: \n";
- getline(cin, strud.bday);
- cin.get();
- cout << "Телефон: \n";
- getline(cin, strud.telephone);
- cin.get();
- cout << "Для продолжения нажмите -Enter, иначе 'n':" << endl;
- f2 << strud.name << endl;
- f2 << strud.dolzhnost << endl;
- f2 << strud.bday << endl;
- f2 << strud.telephone << endl;
- } while (_getche() != 'n');
- f2.close();
- _getch();
- }
- void vivod2()
- {
- ifstream f2;
- f2.open("f2.txt");
- string helper = "";
- do
- {
- getline(f2, helper);
- if (helper == "") {
- break;
- }
- system("cls");
- cout << "Наши Сотрудники: \n";
- //getline(f2, strud.name);
- strud.name = helper;
- getline(f2, strud.dolzhnost);
- getline(f2, strud.bday);
- getline(f2, strud.telephone);
- if (f2) {
- cout << "Ф.И.О.: \n" << strud.name << endl;
- cout << "Должность: \n" << strud.dolzhnost << endl;
- cout << "Дата рождения: \n" << strud.bday << endl;
- cout << "Телефон: \n" << strud.telephone << endl;
- _getch();
- }
- } while (f2);
- f2.close();
- }
- void dobav2()
- {
- //Открыть файл для добавления
- fstream f2;
- f2.open("f2.txt", ios::app);
- do
- {
- system("cls");
- cout << "Ф.И.О: \n";
- getline(cin, strud.name);
- cout << "Должность: \n";
- getline(cin, strud.dolzhnost);
- cout << "Дата рождения: \n";
- getline(cin, strud.bday);
- cin.get();
- cout << "Телефон: \n";
- getline(cin, strud.telephone);
- cin.get();
- cout << "Для продолжения нажмите -Enter, иначе 'n':" << endl;
- f2 << strud.name << endl;
- f2 << strud.dolzhnost << endl;
- f2 << strud.bday << endl;
- f2 << strud.telephone << endl;
- } while (_getche() != 'n');
- f2.close();
- _getch();
- }
- void poisk2()
- {
- //Открыть файл для поиска
- system("cls");
- char namesotr[40];
- int f3 = 0;
- string g;
- ifstream f2;
- f2.open("f2.txt");
- cout << "\n Введите фамилию сотрудника, которого желаете найти:";
- getline(cin, g);
- do
- {
- system("cls");
- cout << " Сотрудники: \n";
- getline(f2, strud.name);
- getline(f2, strud.dolzhnost);
- getline(f2, strud.bday);
- getline(f2, strud.telephone);
- if (strud.name == g)
- {
- f3 = 1;
- cout << "Ф.И.О.: \n" << strud.name << endl;
- cout << "Должность: \n" << strud.dolzhnost << endl;
- cout << "Дата рождения: \n" << strud.bday << endl;
- cout << "Телефон: \n" << strud.telephone << endl;
- _getch();
- }
- } while (f2);
- if (f3 == 0)
- {
- cout << "Извините, в списке нет такой фамилии!";
- }
- f2.close();
- _getch();
- }
- //void udalen2()
- //{
- // system("cls");
- // int i = 0;
- // string k;
- // ifstream f2;
- // f2.open("f2.txt");
- // ofstream U;
- // U.open("U.txt");
- // cout << "Сотрудники:\n";
- //
- // do
- // {
- // getline(f2, strud.name);
- // getline(f2, strud.dolzhnost);
- // getline(f2, strud.bday);
- // getline(f2, strud.telephone);
- //
- // cout << "Ф.И.О.: \n" << strud.name << endl;
- // cout << "Должность: \n" << strud.dolzhnost << endl;
- // cout << "Дата рождения: \n" << strud.bday << endl;
- // cout << "Телефон: \n" << strud.telephone << endl;
- // } while (f2);
- // f2.close();
- // ifstream a;
- // a.open("f2.txt");
- // cout << "\n Введите Фамилию и инициалы сотрудника, которого нужно удалить из списка:";
- // getline(cin, k);
- // do
- // {
- // getline(a, strud.name);
- // getline(a, strud.dolzhnost);
- // getline(a, strud.bday);
- // getline(a, strud.telephone);
- // if (strud.name != k)
- // {
- // U << strud.name << endl;
- // U << strud.dolzhnost << endl;
- // U << strud.bday << endl;
- // U << strud.telephone << endl;
- // }
- // } while (a);
- // U.close(); a.close();
- // remove("f2.txt");
- // rename("U.txt", "f2.txt");
- //}
- void udalen2()
- {
- system("cls");
- int i = 0;
- string k, helper = "";
- ifstream f2;
- f2.open("f2.txt");
- ofstream U;
- U.open("U.txt");
- cout << "Сотрудники:\n";
- do
- {
- getline(f2, helper);
- if (helper == "") {
- break;
- }
- strud.name = helper;
- getline(f2, strud.dolzhnost);
- getline(f2, strud.bday);
- getline(f2, strud.telephone);
- cout << "Ф.И.О.: \n" << strud.name << endl;
- cout << "Должность: \n" << strud.dolzhnost << endl;
- cout << "Дата рождения: \n" << strud.bday << endl;
- cout << "Телефон: \n" << strud.telephone << endl;
- } while (f2);
- f2.close();
- ifstream a;
- a.open("f2.txt");
- cout << "\n Введите Фамилию и инициалы сотрудника, которого нужно удалить из списка:";
- getline(cin, k);
- do
- {
- getline(a, helper);
- if (helper == "") {
- break;
- }
- strud.name = helper;
- getline(a, strud.dolzhnost);
- getline(a, strud.bday);
- getline(a, strud.telephone);
- if (strud.name != k)
- {
- U << strud.name << endl;
- U << strud.dolzhnost << endl;
- U << strud.bday << endl;
- U << strud.telephone << endl;
- }
- } while (a);
- U.close(); a.close();
- remove("f2.txt");
- rename("U.txt", "f2.txt");
- }
- void sozd()
- {
- ofstream f;
- f.open("f.txt");
- do
- {
- system("cls");
- cout << "Название книги: \n";
- getline(cin, books.naz);
- cout << "Автор: \n";
- getline(cin, books.famA);
- cout << "Жанр: \n";
- getline(cin, books.zhanr);
- cout << "Год издания: \n";
- getline(cin, books.years);
- cin.get();
- cout << "Для продолжения нажмите -Enter, иначе 'n':" << endl;
- f << books.naz << endl;
- f << books.famA << endl;
- f << books.zhanr << endl;
- f << books.years << endl;
- } while (_getche() != 'n');
- f.close();
- _getch();
- }
- void vivod()
- {
- struct kniga books[size];
- kniga temp;
- int i = 0, j, o, n;
- ifstream f;
- f.open("f.txt");
- system("cls");
- gotoxy(30, 0);
- cout << "Список книг:";
- do
- {
- getline(f, books[i].naz);
- getline(f, books[i].famA);
- getline(f, books[i].zhanr);
- getline(f, books[i].years);
- i++;
- } while (f);
- for (j = 0; j < i - 1; j++)
- for (o = j + 1; o < i; o++)
- if (books[j].naz.compare(books[o].naz) > 0)
- {
- temp = books[j];
- books[j] = books[o];
- books[o] = temp;
- }
- for (j = 1; j < i; j++)
- {
- cout << "\nНазвание книги: " << books[j].naz << endl;
- cout << "Автор: " << books[j].famA << endl;
- cout << "Жанр: " << books[j].zhanr << endl;
- cout << "Год издания: "<< books[j].years << endl;
- _getch();
- }
- f.close();
- }
- void dobav()
- {
- //Открыть файл для добавления
- fstream f;
- f.open("f.txt", ios::app);
- do
- {
- system("cls");
- cout << "Название книги: \n";
- getline(cin, books.naz);
- cout << "Автор: \n";
- getline(cin, books.famA);
- cout << "Жанр: \n";
- getline(cin, books.zhanr);
- cout << "Год издания: \n";
- getline(cin, books.years);
- cin.get();
- cout << "Для продолжения нажмите -Enter, иначе 'n':" << endl;
- f << books.naz << endl;
- f << books.famA << endl;
- f << books.zhanr << endl;
- f << books.years << endl;
- } while (_getche() != 'n');
- f.close();
- _getch();
- }
- void poisk()
- {
- //Открыть файл для поиска
- system("cls");
- string n;
- int f1 = 0;
- ifstream f;
- f.open("f.txt");
- cout << "\n Введите название книги, которую хотите найти:";
- getline(cin, n);
- do
- {
- system("cls");
- cout << " книги: \n";
- getline(f, books.naz);
- getline(f, books.famA);
- getline(f, books.zhanr);
- getline(f, books.years);
- cout << "Название книги: \n" << books.naz << endl;
- if (books.naz == n)
- {
- f1 = 1;
- cout << "Название книги: \n" << books.naz << endl;
- cout << "Автор: \n" << books.famA << endl;
- cout << "Жанр: \n" << books.zhanr << endl;
- cout << "Год издания: \n" << books.years << endl;
- _getch();
- }
- } while (f);
- if (f1 == 0)
- {
- cout << "Извините, в списке нет такой книги!";
- }
- f.close();
- _getch();
- }
- void vvodchitatela()
- {
- ofstream H;
- H.open("читатель.txt");
- cout << "Данные о читателях";
- do
- {
- system("cls");
- cout << "Фамилия: \n";
- getline(cin, chit.famil);
- cout << "Имя: \n";
- getline(cin, chit.namee);
- cout << "Отчество: \n";
- getline(cin, chit.otchestvo);
- cout << "Год рождения: \n";
- getline(cin, chit.bdayy);
- cin.get();
- cout << "Должность: \n";
- getline(cin, chit.dolzhnost);
- cout << "Телефон: \n";
- getline(cin, chit.telephonee);
- cin.get();
- cout << "Паспотные данные: \n";
- getline(cin, chit.pasport);
- cout << "Дата регистрации в библиотеки: \n";
- getline(cin, chit.datar);
- cin.get();
- cout << "Для продолжения нажмите -Enter, иначе 'n':" <<
- endl;
- H << chit.famil << endl;
- H << chit.namee << endl;
- H << chit.otchestvo << endl;
- H << chit.bdayy << endl;
- H << chit.dolzhnost << endl;
- H << chit.telephonee << endl;
- H << chit.pasport << endl;
- H << chit.datar << endl;
- } while (_getche() != 'n');
- H.close();
- _getch();
- }
- void vivodchitatela()
- {
- ifstream H;
- H.open("читатель.txt");
- do
- {
- system("cls");
- cout << "Формуляр читателя: \n";
- getline(H, chit.famil);
- getline(H, chit.namee);
- getline(H, chit.otchestvo);
- getline(H, chit.bdayy);
- getline(H, chit.dolzhnost);
- getline(H, chit.telephonee);
- getline(H, chit.pasport);
- getline(H, chit.datar);
- if (H)
- {
- cout << "Фамилия: \n" << chit.famil << endl;
- cout << "Имя: \n" << chit.namee << endl;
- cout << "Отчество: \n" << chit.otchestvo << endl;
- cout << "Год рождения: \n" << chit.bdayy << endl;
- cout << "Должность: \n" << chit.dolzhnost << endl;
- cout << "Телефон: \n" << chit.telephonee << endl;
- cout << "Паспортные данные: \n" << chit.pasport << endl;
- cout << "Дата регистрации: \n" << chit.datar << endl;
- _getch();
- }
- } while (H);
- H.close();
- _getch();
- }
- void sozd1()
- {
- ofstream f1;
- f1.open("f1.txt");
- do
- {
- system("cls");
- cout << "Наименование: \n";
- cin.getline(otdell.nazvanie, 30);
- cout << "Кабинет: \n";
- cin.getline(otdell.kb, 20);
- cout << "Время работы: \n";
- cin.getline(otdell.time, 30);
- cout << "Для продолжения нажмите -Enter, иначе 'n':" << endl;
- f1.width(29);
- f1 << otdell.nazvanie << endl;
- f1.width(19);
- f1 << otdell.kb << endl;
- f1.width(29);
- f1 << otdell.time << endl;
- } while (_getche() != 'n');
- f1.close();
- _getch();
- }
- void vivod1()
- {
- ifstream f1;
- f1.open("f1.txt");
- do
- {
- system("cls");
- cout << " Отделы: \n";
- f1.getline(otdell.nazvanie, 30); f1.get();
- f1.getline(otdell.kb, 20); f1.get();
- f1.getline(otdell.time, 30); f1.get();
- cout << "Наименование: \n" << otdell.nazvanie << endl;
- cout << "Кабинет: \n" << otdell.kb << endl;
- cout << "Время работы: \n" << otdell.time << endl;
- _getch();
- } while (f1);
- f1.close();
- _getch();
- }
- void dobav1()
- {
- //Открыть файл для добавления
- fstream f1;
- f1.open("f1.txt", ios::app);
- do
- {
- system("cls");
- cout << "Наименование: \n";
- cin.getline(otdell.nazvanie, 30);
- cout << "Кабинет: \n";
- cin.getline(otdell.kb, 20);
- cout << "Время работы: \n";
- cin.getline(otdell.time, 30); cin.get();
- cout << "Для продолжения нажмите -Enter, иначе 'n':" << endl;
- f1.width(29);
- f1 << otdell.nazvanie << endl;
- f1.width(19);
- f1 << otdell.kb << endl;
- f1.width(29);
- f1 << otdell.time << endl;
- } while (_getche() != 'n');
- f1.close();
- _getch();
- }
- void correct1()
- {
- system("cls");
- char nazv[30];
- char sym;
- int pos;
- fstream f1;
- f1.open("f1.txt", ios::in | ios::out);
- cout << "Введите искомый кабинет: ";
- cin.getline(nazv, 30);
- do
- {
- pos = f1.tellg();
- f1.getline(otdell.nazvanie, 30); f1.get();
- f1.getline(otdell.kb, 20); f1.get();
- f1.getline(otdell.time, 30); f1.get();
- cout << otdell.nazvanie;
- _getch();
- if (f1)
- {
- if (strstr(otdell.nazvanie, nazv) != 0)
- {
- cout << "Корректируем запись!!";
- cout << "Название кабинета меняем?";
- cin >> sym;
- cin.get();
- if (sym == 'y')
- {
- cout << "Введите новый кабинет:";
- cin.getline(otdell.nazvanie, 30);
- cin.get();
- }
- cout << "Номер кабинета меняем?";
- cin >> sym;
- cin.get();
- if (sym == 'y')
- {
- cout << "Введите новый номер кабинета:";
- cin.getline(otdell.kb, 20);
- cin.get();
- }
- cout << "Время работы меняем?";
- cin >> sym;
- cin.get();
- if (sym == 'y')
- {
- cout << "Введите новое время работы кабинета:";
- cin.getline(otdell.time, 30);
- cin.get();
- }
- f1.seekg(pos);
- if (f1)
- {
- f1.width(29);
- f1 << otdell.nazvanie << "\n";
- f1.width(19);
- f1 << otdell.kb << "\n";
- f1.width(29);
- f1 << otdell.time << "\n";
- }
- }
- }
- } while (f1);
- f1.close();
- _getch();
- }
- void removeBookFromLibrary(string bookName) {
- /**
- * В принциципе удаление будет как
- * и у сотрудников, необходим темп(временный)
- * файл куда сольем только нужный книги, а
- * по итогу переименуем
- */
- int i = 0;
- string helper = "";
- ifstream f2;
- f2.open("f.txt");
- ofstream U;
- U.open("U.txt");
- do
- {
- getline(f2, helper);
- if (helper == "") {
- break;
- }
- books.naz = helper;
- getline(f2, books.famA);
- getline(f2, books.zhanr);
- getline(f2, books.years);
- if (books.naz != bookName)
- {
- U << books.naz << endl;
- U << books.famA << endl;
- U << books.zhanr << endl;
- U << books.years << endl;
- }
- } while (f2);
- U.close();
- f2.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement