Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <tchar.h>
- #include <string>
- #include <vector>
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <algorithm>
- #include "commctrl.h"
- #include <ctime>
- static TCHAR szWindowClass[] = _T("win32app");
- static TCHAR szTitle[] = _T("Библиотека");
- HINSTANCE hInst;
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- HWND hWnd;
- HMENU hMenuBar;
- HMENU hSubMenu1;
- HMENU hSubMenu2;
- HMENU hSubMenu3;
- HMENU hSubMenu4;
- HWND hEdit;
- HWND hEdit2;
- HWND hEdit3;
- HWND hEdit4;
- HWND hEdit5;
- HWND hEdit6;
- HWND label1;
- HWND label2;
- HWND label3;
- HWND label4;
- HWND label5;
- HWND label6;
- HWND hButton1;
- HWND hButton2;
- HWND hWndList;
- HWND hEdit7; HWND hEdit8; HWND hEdit9; HWND hEdit10; HWND hEdit11; HWND hEdit12; HWND hEdit13;
- HWND label7; HWND label8; HWND label9; HWND label10; HWND label11; HWND label12; HWND label13;
- int CALLBACK WinMain(
- _In_ HINSTANCE hInstance,
- _In_ HINSTANCE hPrevInstance,
- _In_ LPSTR lpCmdLine,
- _In_ int nCmdShow
- )
- {
- WNDCLASSEX wcex;
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.style = CS_HREDRAW | CS_VREDRAW;
- wcex.lpfnWndProc = WndProc;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
- wcex.hInstance = hInstance;
- wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
- wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- wcex.lpszMenuName = NULL;
- wcex.lpszClassName = szWindowClass;
- wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
- if (!RegisterClassEx(&wcex))
- {
- MessageBox(NULL,
- _T("Call to RegisterClassEx failed!"),
- _T("Win32 Guided Tour"),
- NULL);
- return 1;
- }
- hInst = hInstance;
- hMenuBar = CreateMenu();
- hSubMenu3 = CreateMenu();
- AppendMenu(hMenuBar, MF_STRING, 6, "Библиотека");
- hSubMenu1 = CreateMenu();
- AppendMenu(hMenuBar, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu1, "Книга");
- AppendMenu(hSubMenu1, MF_STRING, 10, "Добавить");
- AppendMenu(hSubMenu1, MF_STRING, 2, "Удалить");
- AppendMenu(hSubMenu1, MF_STRING, 7, "Поменять местами");
- AppendMenu(hSubMenu1, MF_STRING, 3, "Найти");
- hSubMenu2 = CreateMenu();
- AppendMenu(hSubMenu2, MF_STRING, 4, "По стоимости");
- AppendMenu(hSubMenu2, MF_STRING, 5, "По жанру");
- AppendMenu(hSubMenu2, MF_STRING, 8, "Размешать");
- AppendMenu(hMenuBar, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu2, "Сортировка");
- hSubMenu4 = CreateMenu();
- AppendMenu(hMenuBar, MF_STRING | MF_POPUP, (UINT_PTR)hSubMenu4, "Особый поиск");
- AppendMenu(hSubMenu4, MF_STRING, 9, "5 самых старых книг по всем жанрам");
- hWnd = CreateWindow(
- szWindowClass,
- szTitle,
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT, CW_USEDEFAULT,
- 500, 475,
- NULL,
- hMenuBar,
- hInstance,
- NULL
- );
- SetMenu(hWnd, hMenuBar);
- if (!hWnd)
- {
- MessageBox(NULL,
- _T("Call to CreateWindow failed!"),
- _T("Win32 Guided Tour"),
- NULL);
- return 1;
- }
- ShowWindow(hWnd,
- nCmdShow);
- UpdateWindow(hWnd);
- MSG msg;
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return (int)msg.wParam;
- }
- int wmId;
- int wmEvent;
- bool isSetPanel = false;
- enum mode
- {
- ADD, DEL, FIND, SWAP, FFIVE, BASE
- };
- void setPanel(bool tie)
- {
- if (!isSetPanel)
- {
- hEdit = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 150,
- 75,
- 200,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label1 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 225, 50, 200, 20,
- hWnd, (HMENU)(501),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label1, "Автор");
- hEdit2 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 150,
- 125,
- 200,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label2 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 215, 100, 200, 20,
- hWnd, (HMENU)(502),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label2, "Название");
- if (!tie)
- {
- hEdit3 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 150,
- 175,
- 200,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label3 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 200, 150, 200, 20,
- hWnd, (HMENU)(503),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label3, "Издательство");
- hEdit4 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 150,
- 225,
- 200,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label4 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 228, 200, 200, 20,
- hWnd, (HMENU)(504),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label4, "Жанр");
- hEdit5 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 150,
- 275,
- 200,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label5 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 185, 250, 200, 20,
- hWnd, (HMENU)(505),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label5, "Дата поступления");
- hEdit6 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 150,
- 325,
- 200,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label6 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 215, 300, 200, 20,
- hWnd, (HMENU)(506),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label6, "Стоимость");
- }
- int y = 350;
- if (tie) y = 150;
- hButton1 = CreateWindow("BUTTON", "Выполнить", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
- 50, y, 400, 50, hWnd, (HMENU)200, hInst, NULL);
- }
- isSetPanel = true;
- ShowWindow(hEdit, 1);
- ShowWindow(label1, 1);
- ShowWindow(hEdit2, 1);
- ShowWindow(label2, 1);
- if (!tie)
- {
- ShowWindow(hEdit3, 1);
- ShowWindow(label3, 1);
- ShowWindow(hEdit4, 1);
- ShowWindow(label4, 1);
- ShowWindow(hEdit5, 1);
- ShowWindow(label5, 1);
- ShowWindow(hEdit6, 1);
- ShowWindow(label6, 1);
- }
- }
- void clearPanel()
- {
- if (hEdit != NULL) DestroyWindow(hEdit);
- if (hEdit2 != NULL) DestroyWindow(hEdit2);
- if (hEdit3 != NULL) DestroyWindow(hEdit3);
- if (hEdit4 != NULL) DestroyWindow(hEdit4);
- if (hEdit5 != NULL) DestroyWindow(hEdit5);
- if (hEdit6 != NULL) DestroyWindow(hEdit6);
- if (label1 != NULL) DestroyWindow(label1);
- if (label2 != NULL) DestroyWindow(label2);
- if (label3 != NULL) DestroyWindow(label3);
- if (label4 != NULL) DestroyWindow(label4);
- if (label5 != NULL) DestroyWindow(label5);
- if (label6 != NULL) DestroyWindow(label6);
- if (hButton1 != NULL) DestroyWindow(hButton1);
- isSetPanel = false;
- }
- void addBook(std::string msg1, std::string msg2, std::string msg3, std::string msg4, std::string msg5, std::string msg6)
- {
- std::ofstream File;
- try
- {
- File.open("library.txt", std::ios::app);
- File << msg1 << ";" << msg2 << ";" << msg3 << ";" << msg4 << ";" << msg5 << ";" << msg6 << ";" << std::endl;
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File.close();
- }
- void delBook(std::string msg1, std::string msg2)
- {
- std::ifstream File;
- std::string text;
- std::vector<std::string> books;
- try
- {
- File.open("library.txt");
- while (std::getline(File, text))
- {
- books.push_back(text);
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File.close();
- int number = -1;
- for (int i = 0; i < books.size(); i++)
- {
- int count = 0;
- std::string temp1 = "";
- std::string temp2 = "";
- for (int j = 0; j < books[i].size() && count < 2; j++)
- {
- if (books[i][j] == ';') count++;
- if (count == 0) temp1 += books[i][j];
- if (count == 1 && books[i][j] != ';') temp2 += books[i][j];
- }
- if (temp1 == msg1 && temp2 == msg2)
- {
- temp1 = "";
- temp2 = "";
- number = i;
- }
- temp1 = "";
- temp2 = "";
- }
- std::ofstream File2;
- try
- {
- File2.open("library.txt");
- for (int i = 0; i < books.size(); i++)
- {
- if (i != number) File2 << books[i] + "\n";
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File2.close();
- }
- void findBook(std::string msg1, std::string msg2)
- {
- std::ifstream File;
- std::string text;
- std::vector<std::string> books;
- try
- {
- File.open("library.txt", std::ios::app);
- while (std::getline(File, text))
- {
- books.push_back(text);
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File.close();
- int number = -1;
- for (int i = 0; i < books.size(); i++)
- {
- int count = 0;
- std::string temp1 = "";
- std::string temp2 = "";
- std::string temp3 = "";
- std::string temp4 = "";
- std::string temp5 = "";
- std::string temp6 = "";
- for (int j = 0; j < books[i].size(); j++)
- {
- if (books[i][j] == ';') count++;
- if (count == 0) temp1 += books[i][j];
- if (count == 1 && books[i][j] != ';') temp2 += books[i][j];
- if (count == 2 && books[i][j] != ';') temp3 += books[i][j];
- if (count == 3 && books[i][j] != ';') temp4 += books[i][j];
- if (count == 4 && books[i][j] != ';') temp5 += books[i][j];
- if (count == 5 && books[i][j] != ';') temp6 += books[i][j];
- }
- if (temp1 == msg1 && temp2 == msg2)
- {
- number = i;
- std::string tempstr = "Книга найдена!\nАвтор:" + temp1
- + " \nНазвание: " + temp2
- + " \nИздательство: " + temp3
- + " \nЖанр: " + temp4
- + " \nДата поступления: " + temp5
- + " \nСтоимость: " + temp6;
- MessageBox(NULL, tempstr.c_str(), "Поиск", MB_OK | MB_ICONASTERISK);
- }
- temp1 = "";
- temp2 = "";
- temp3 = "";
- temp4 = "";
- temp5 = "";
- temp6 = "";
- }
- }
- std::string getTextBoxValue(HWND control)
- {
- int length = SendMessage(control, WM_GETTEXTLENGTH, 0, 0);
- wchar_t *str;
- str = new wchar_t[length + 1];
- SendMessage(control, WM_GETTEXT, length + 1, LPARAM(str));
- LPCSTR temp = LPCSTR(str);
- return ((std::string)temp);
- }
- mode modeStatus = BASE;
- HANDLE handle;
- void clearEdits()
- {
- SendMessageA(hEdit, WM_SETTEXT, WPARAM(0), LPARAM(""));
- SendMessageA(hEdit2, WM_SETTEXT, WPARAM(0), LPARAM(""));
- SendMessageA(hEdit3, WM_SETTEXT, WPARAM(0), LPARAM(""));
- SendMessageA(hEdit4, WM_SETTEXT, WPARAM(0), LPARAM(""));
- SendMessageA(hEdit5, WM_SETTEXT, WPARAM(0), LPARAM(""));
- SendMessageA(hEdit6, WM_SETTEXT, WPARAM(0), LPARAM(""));
- }
- bool ishWndListCreated = false;
- int CreateColumn(HWND hwndLV, int iCol, LPSTR text, int width)
- {
- LVCOLUMN lvc;
- lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- lvc.fmt = LVCFMT_LEFT;
- lvc.cx = width;
- lvc.pszText = text;
- lvc.iSubItem = iCol;
- return ListView_InsertColumn(hwndLV, iCol, &lvc);
- }
- int CreateItems(HWND hwndList, LPSTR Text0, LPSTR Text1, LPSTR Text2, LPSTR Text3, LPSTR Text4, LPSTR Text5, LPSTR Text6)
- {
- LVITEMW lvi = { 0 };
- int Ret;
- lvi.mask = LVIF_TEXT;
- lvi.pszText = (LPWSTR)Text0;
- Ret = ListView_InsertItem(hwndList, &lvi);
- if (Ret >= 0)
- {
- ListView_SetItemText(hwndList, Ret, 1, Text1);
- ListView_SetItemText(hwndList, Ret, 2, Text2);
- ListView_SetItemText(hwndList, Ret, 3, Text3);
- ListView_SetItemText(hwndList, Ret, 4, Text4);
- ListView_SetItemText(hwndList, Ret, 5, Text5);
- ListView_SetItemText(hwndList, Ret, 6, Text6);
- }
- return Ret;
- }
- void sort1(bool tie)
- {
- std::ifstream File;
- std::string text;
- std::vector<std::string> books;
- try
- {
- File.open("library.txt");
- while (std::getline(File, text))
- {
- books.push_back(text);
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File.close();
- std::string *books_s;
- books_s = new std::string[books.size()];
- for (int i = 0; i < books.size(); i++)
- {
- books_s[i] = books[i];
- }
- if (!tie)
- {
- for (int i = 0; i < books.size(); i++)
- {
- for (int k = i; k < books.size(); k++)
- {
- int counter = 0;
- std::string tempik1 = "";
- for (int j = 0; j < books_s[i].size() - 1 && counter < 6; j++)
- {
- if (books_s[i][j] == ';') counter++;
- if (counter == 5 && books_s[i][j] != ';') tempik1 += books_s[i][j];
- }
- int counter2 = 0;
- std::string tempik2 = "";
- for (int j = 0; j < books_s[k].size() && counter2 < 6; j++)
- {
- if (books_s[k][j] == ';') counter2++;
- if (counter2 == 5 && books_s[k][j] != ';') tempik2 += books_s[k][j];
- }
- int cost1 = atoi(tempik1.c_str());
- int cost2 = atoi(tempik2.c_str());
- if (cost1 > cost2)
- {
- std::string temp = books_s[i];
- books_s[i] = books_s[k];
- books_s[k] = temp;
- }
- }
- }
- }
- else if (tie)
- {
- for (int i = 0; i < books.size(); i++)
- {
- for (int k = i; k < books.size(); k++)
- {
- int counter = 0;
- std::string tempik1 = "";
- for (int j = 0; j < books_s[i].size() - 1 && counter < 4; j++)
- {
- if (books_s[i][j] == ';') counter++;
- if (counter == 3 && books_s[i][j] != ';') tempik1 += books_s[i][j];
- }
- int counter2 = 0;
- std::string tempik2 = "";
- for (int j = 0; j < books_s[k].size() && counter2 < 4; j++)
- {
- if (books_s[k][j] == ';') counter2++;
- if (counter2 == 3 && books_s[k][j] != ';') tempik2 += books_s[k][j];
- }
- bool isMany = false;
- if (tempik1.size() > tempik2.size())
- {
- for (int p = 0; p < tempik2.size() && !isMany; p++)
- {
- if ((int)tempik1[p] >= (int)tempik2[p]) isMany = true;
- else break;
- }
- }
- else {
- for (int p = 0; p < tempik1.size() && !isMany; p++)
- {
- if ((int)tempik1[p] >= (int)tempik2[p]) isMany = true;
- else break;
- }
- }
- if (isMany)
- {
- std::string temp = books_s[i];
- books_s[i] = books_s[k];
- books_s[k] = temp;
- }
- }
- }
- }
- std::ofstream File2;
- try
- {
- File2.open("library.txt");
- for (int i = 0; i < books.size(); i++)
- {
- File2 << books_s[i] + "\n";
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File2.close();
- }
- bool isSetChangeBookPanel = false;
- void setChangeBookPanel()
- {
- if (!isSetChangeBookPanel)
- {
- hEdit7 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 75,
- 255,
- 100,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label7 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 105, 232, 100, 20,
- hWnd, (HMENU)(507),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label7, "Автор");
- hEdit8 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 200,
- 255,
- 100,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label8 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 215, 232, 100, 20,
- hWnd, (HMENU)(508),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label8, "Название");
- hEdit9 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 325,
- 255,
- 100,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label9 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 330, 232, 100, 20,
- hWnd, (HMENU)(509),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label9, "Издательство");
- hEdit10 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 75,
- 300,
- 100,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label10 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 105, 280, 100, 20,
- hWnd, (HMENU)(510),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label10, "Жанр");
- hEdit11 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 200,
- 300,
- 100,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label11 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 190, 280, 200, 20,
- hWnd, (HMENU)(511),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label11, "Дата поступления");
- hEdit12 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 325,
- 300,
- 100,
- 20,
- hWnd,
- NULL,
- hInst,
- 0);
- label12 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 340, 280, 200, 20,
- hWnd, (HMENU)(512),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label12, "Стоимость");
- hEdit13 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 10,
- 275,
- 50,
- 25,
- hWnd,
- NULL,
- hInst,
- 0);
- label13 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 28, 255, 20, 20,
- hWnd, (HMENU)(513),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label13, "№");
- hButton2 = CreateWindow("BUTTON", "Изменить", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
- 50, 325, 400, 75, hWnd, (HMENU)230, hInst, NULL);
- ShowWindow(hEdit7, 1);
- ShowWindow(hEdit8, 1);
- ShowWindow(hEdit9, 1);
- ShowWindow(hEdit10, 1);
- ShowWindow(hEdit11, 1);
- ShowWindow(hEdit12, 1);
- ShowWindow(hEdit13, 1);
- ShowWindow(label7, 1);
- ShowWindow(label8, 1);
- ShowWindow(label9, 1);
- ShowWindow(label10, 1);
- ShowWindow(label11, 1);
- ShowWindow(label12, 1);
- ShowWindow(label13, 1);
- isSetChangeBookPanel = true;
- }
- }
- void DestroySetChangeBookPanel()
- {
- if (isSetChangeBookPanel)
- {
- DestroyWindow(hEdit7);
- DestroyWindow(hEdit8);
- DestroyWindow(hEdit9);
- DestroyWindow(hEdit10);
- DestroyWindow(hEdit11);
- DestroyWindow(hEdit12);
- DestroyWindow(hEdit13);
- DestroyWindow(label7);
- DestroyWindow(label8);
- DestroyWindow(label9);
- DestroyWindow(label10);
- DestroyWindow(label11);
- DestroyWindow(label12);
- DestroyWindow(label13);
- DestroyWindow(hButton2);
- isSetChangeBookPanel = false;
- }
- }
- void changeBook(int number)
- {
- std::ifstream File;
- std::string text;
- std::vector<std::string> books;
- try
- {
- File.open("library.txt");
- while (std::getline(File, text))
- {
- books.push_back(text);
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File.close();
- std::string *books_s;
- books_s = new std::string[books.size()];
- for (int i = 0; i < books.size(); i++)
- {
- books_s[i] = books[i];
- }
- books_s[number] = "";
- books_s[number] = getTextBoxValue(hEdit7) + ";"
- + getTextBoxValue(hEdit8) + ";"
- + getTextBoxValue(hEdit9) + ";"
- + getTextBoxValue(hEdit10) + ";"
- + getTextBoxValue(hEdit11) + ";"
- + getTextBoxValue(hEdit12) + ";"
- ;
- std::ofstream File2;
- try
- {
- File2.open("library.txt");
- for (int i = 0; i < books.size(); i++)
- {
- File2 << books_s[i] + "\n";
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File2.close();
- }
- bool ishEdit13_Focused = false;
- void swapBook(int number1, int number2)
- {
- std::ifstream File;
- std::string text;
- std::vector<std::string> books;
- try
- {
- File.open("library.txt");
- while (std::getline(File, text))
- {
- books.push_back(text);
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File.close();
- std::string *books_s;
- books_s = new std::string[books.size()];
- for (int i = 0; i < books.size(); i++)
- {
- books_s[i] = books[i];
- }
- std::string temp = books_s[number1];
- books_s[number1] = books_s[number2];
- books_s[number2] = temp;
- std::ofstream File2;
- try
- {
- File2.open("library.txt");
- for (int i = 0; i < books.size(); i++)
- {
- File2 << books_s[i] + "\n";
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File2.close();
- }
- void deSort()
- {
- std::ifstream File;
- std::string text;
- std::vector<std::string> books;
- try
- {
- File.open("library.txt");
- while (std::getline(File, text))
- {
- books.push_back(text);
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File.close();
- std::string *books_s;
- books_s = new std::string[books.size()];
- for (int i = 0; i < books.size(); i++)
- {
- books_s[i] = books[i];
- }
- srand(time(0));
- for (int i = 0; i < books.size(); i++)
- {
- for (int j = 0; j < books.size(); j++)
- {
- std::string temp = books_s[i];
- int a = rand() % 2;
- if (a == 1)
- {
- books_s[i] = books_s[j];
- books_s[j] = temp;
- }
- }
- }
- std::ofstream File2;
- try
- {
- File2.open("library.txt");
- for (int i = 0; i < books.size(); i++)
- {
- File2 << books_s[i] + "\n";
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File2.close();
- }
- HWND hEdit14;
- HWND label14;
- HWND hEdit15;
- HWND label15;
- HWND hButton3;
- bool isSetSwapPanel = false;
- void setSwapPanel()
- {
- if (!isSetSwapPanel)
- {
- hEdit14 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 35,
- 65,
- 125,
- 25,
- hWnd,
- NULL,
- hInst,
- 0);
- label14 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 45, 40, 125, 20,
- hWnd, (HMENU)(513),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label14, "№ первой книги");
- hEdit15 = CreateWindow(
- "Edit",
- NULL,
- WS_CHILD |
- ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER,
- 325,
- 65,
- 125,
- 25,
- hWnd,
- NULL,
- hInst,
- 0);
- label15 = CreateWindow("static", "ST_U",
- WS_CHILD | WS_TABSTOP,
- 335, 40, 125, 20,
- hWnd, (HMENU)(513),
- (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
- SetWindowText(label15, "№ второй книги");
- hButton3 = CreateWindow("BUTTON", "Поменять местами", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
- 50, 100, 400, 75, hWnd, (HMENU)234, hInst, NULL);
- ShowWindow(hEdit15, 1);
- ShowWindow(hEdit14, 1);
- ShowWindow(label14, 1);
- ShowWindow(label15, 1);
- isSetSwapPanel = true;
- }
- }
- void DestroySwapPanel()
- {
- if (isSetSwapPanel)
- {
- DestroyWindow(label14);
- DestroyWindow(label15);
- DestroyWindow(hEdit14);
- DestroyWindow(hEdit15);
- DestroyWindow(hButton3);
- isSetSwapPanel = false;
- }
- }
- HWND hWndList2;
- bool ishWndList2Created = false;
- void setFindFiveBooksPanel()
- {
- if (!ishWndList2Created)
- {
- hWndList2 = CreateWindow(WC_LISTVIEW, "",
- WS_VISIBLE | WS_BORDER | WS_CHILD | LVS_REPORT | LVS_EDITLABELS,
- 50, 50, 400, 350,
- hWnd, (HMENU)101, hInst, 0);
- CreateColumn(hWndList2, 0, (LPSTR)"Стоимость", 100);
- CreateColumn(hWndList2, 0, (LPSTR)"Дата поступления", 100);
- CreateColumn(hWndList2, 0, (LPSTR)"Жанр", 100);
- CreateColumn(hWndList2, 0, (LPSTR)"Издательство", 100);
- CreateColumn(hWndList2, 0, (LPSTR)"Название", 100);
- CreateColumn(hWndList2, 0, (LPSTR)"Автор", 100);
- CreateColumn(hWndList2, 0, (LPSTR)"ID", 30);
- ishWndList2Created = true;
- }
- }
- void destroyFindFiveBooksPanel()
- {
- if (ishWndList2Created)
- {
- DestroyWindow(hWndList2);
- ishWndList2Created = false;
- }
- }
- bool isBookLate(std::string data1, std::string data2)
- {
- std::string days1;
- days1 += data1[0];
- days1 += data1[1];
- std::string days2;
- days2 += data2[0];
- days2 += data2[1];
- std::string mounths1;
- mounths1 += data1[3];
- mounths1 += data1[4];
- std::string mounths2;
- mounths2 += data2[3];
- mounths2 += data2[4];
- std::string years1;
- years1 += data1[6];
- years1 += data1[7];
- years1 += data1[8];
- years1 += data1[9];
- std::string years2;
- years2 += data2[6];
- years2 += data2[7];
- years2 += data2[8];
- years2 += data2[9];
- int day1 = atoi(days1.c_str());
- int day2 = atoi(days2.c_str());
- int mounth1 = atoi(mounths1.c_str());
- int mounth2 = atoi(mounths2.c_str());
- int year1 = atoi(years1.c_str());
- int year2 = atoi(years2.c_str());
- if (year1 > year2) return true;
- else
- {
- if (mounth1 > mounth2 && year1 >= year2) return true;
- else
- {
- if (day1 > day2 && mounth1 >= mounth2 && year1 >= year2) return true;
- else
- {
- return false;
- }
- }
- }
- }
- void findFiveBooks()
- {
- std::ifstream File;
- std::string text;
- std::vector<std::string> books;
- try
- {
- File.open("library.txt");
- while (std::getline(File, text))
- {
- books.push_back(text);
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File.close();
- std::string *books_s;
- books_s = new std::string[books.size()];
- for (int i = 0; i < books.size(); i++)
- {
- books_s[i] = books[i];
- }
- for (int i = 0; i < books.size(); i++)
- {
- for (int k = i; k < books.size(); k++)
- {
- int counter = 0;
- std::string tempik1 = "";
- for (int j = 0; j < books_s[i].size() - 1 && counter < 4; j++)
- {
- if (books_s[i][j] == ';') counter++;
- if (counter == 3 && books_s[i][j] != ';') tempik1 += books_s[i][j];
- }
- int counter2 = 0;
- std::string tempik2 = "";
- for (int j = 0; j < books_s[k].size() && counter2 < 4; j++)
- {
- if (books_s[k][j] == ';') counter2++;
- if (counter2 == 3 && books_s[k][j] != ';') tempik2 += books_s[k][j];
- }
- bool isMany = false;
- if (tempik1.size() > tempik2.size())
- {
- for (int p = 0; p < tempik2.size() && !isMany; p++)
- {
- if ((int)tempik1[p] >= (int)tempik2[p]) isMany = true;
- else break;
- }
- }
- else {
- for (int p = 0; p < tempik1.size() && !isMany; p++)
- {
- if ((int)tempik1[p] >= (int)tempik2[p]) isMany = true;
- else break;
- }
- }
- if (isMany)
- {
- std::string temp = books_s[i];
- books_s[i] = books_s[k];
- books_s[k] = temp;
- }
- }
- }
- std::vector <std::string> zhanr;
- bool current = false;
- for (int i = 0; i < books.size(); i++)
- {
- for (int k = i; k < books.size(); k++)
- {
- int counter = 0;
- std::string tempik1 = "";
- for (int j = 0; j < books_s[i].size() - 1 && counter < 5; j++)
- {
- if (books_s[i][j] == ';') counter++;
- if (counter == 4 && books_s[i][j] != ';') tempik1 += books_s[i][j];
- }
- int counter2 = 0;
- std::string tempik2 = "";
- for (int j = 0; j < books_s[k].size() && counter2 < 5; j++)
- {
- if (books_s[k][j] == ';') counter2++;
- if (counter2 == 4 && books_s[k][j] != ';') tempik2 += books_s[k][j];
- }
- if (isBookLate(tempik1, tempik2)) {
- std::string temp = books_s[i];
- books_s[i] = books_s[k];
- books_s[k] = temp;
- }
- }
- }
- std::vector<std::string> finded_Books;
- for (int i = 0; i < books.size(); i++)
- {
- int counter = 0;
- std::string tempik1 = "";
- for (int j = 0; j < books_s[i].size() - 1 && counter < 5; j++)
- {
- if (books_s[i][j] == ';') counter++;
- if (counter == 3 && books_s[i][j] != ';') tempik1 += books_s[i][j];
- }
- int counterZhanr = 0;
- for (int j = 0; j < zhanr.size(); j++)
- {
- if (zhanr[j] == tempik1) counterZhanr++;
- }
- if (counterZhanr < 5)
- {
- zhanr.push_back(tempik1);
- finded_Books.push_back(books_s[i]);
- }
- }
- std::string *booksDone = new std::string[finded_Books.size()];
- for (int i = 0; i < finded_Books.size(); i++)
- {
- booksDone[i] = finded_Books[i];
- }
- for (int i = 0; i < finded_Books.size(); i++)
- {
- for (int k = i; k < finded_Books.size(); k++)
- {
- int counter = 0;
- std::string tempik1 = "";
- for (int j = 0; j < booksDone[i].size() - 1 && counter < 4; j++)
- {
- if (booksDone[i][j] == ';') counter++;
- if (counter == 3 && booksDone[i][j] != ';') tempik1 += booksDone[i][j];
- }
- int counter2 = 0;
- std::string tempik2 = "";
- for (int j = 0; j < booksDone[k].size() && counter2 < 4; j++)
- {
- if (booksDone[k][j] == ';') counter2++;
- if (counter2 == 3 && booksDone[k][j] != ';') tempik2 += booksDone[k][j];
- }
- bool isMany = false;
- if (tempik1.size() > tempik2.size())
- {
- for (int p = 0; p < tempik2.size() && !isMany; p++)
- {
- if ((int)tempik1[p] >= (int)tempik2[p]) isMany = true;
- else break;
- }
- }
- else {
- for (int p = 0; p < tempik1.size() && !isMany; p++)
- {
- if ((int)tempik1[p] >= (int)tempik2[p]) isMany = true;
- else break;
- }
- }
- if (isMany)
- {
- std::string temp = booksDone[i];
- booksDone[i] = booksDone[k];
- booksDone[k] = temp;
- }
- }
- }
- for (int i = 0; i < finded_Books.size(); i++)
- {
- int counter = 0;
- std::string tempik1 = "";
- for (int j = 0; j < booksDone[i].size() - 1 && counter < 5; j++)
- {
- if (booksDone[i][j] == ';') counter++;
- if (counter == 3 && booksDone[i][j] != ';') tempik1 += booksDone[i][j];
- }
- int counter1 = 0;
- std::string tempik2 = "";
- for (int j = 0; j < booksDone[i].size() - 1 && counter1 < 1; j++)
- {
- if (booksDone[i][j] == ';') counter1++;
- if (counter1 == 0 && booksDone[i][j] != ';') tempik2 += booksDone[i][j];
- }
- int counter2 = 0;
- std::string tempik3 = "";
- for (int j = 0; j < booksDone[i].size() - 1 && counter2 < 2; j++)
- {
- if (booksDone[i][j] == ';') counter2++;
- if (counter2 == 1 && booksDone[i][j] != ';') tempik3 += booksDone[i][j];
- }
- int counter3 = 0;
- std::string tempik4 = "";
- for (int j = 0; j < booksDone[i].size() - 1 && counter3 < 3; j++)
- {
- if (booksDone[i][j] == ';') counter3++;
- if (counter3 == 2 && booksDone[i][j] != ';') tempik4 += booksDone[i][j];
- }
- int counter4 = 0;
- std::string tempik5 = "";
- for (int j = 0; j < booksDone[i].size() - 1 && counter4 < 5; j++)
- {
- if (booksDone[i][j] == ';') counter4++;
- if (counter4 == 4 && booksDone[i][j] != ';') tempik5 += booksDone[i][j];
- }
- int counter5 = 0;
- std::string tempik6 = "";
- for (int j = 0; j < booksDone[i].size() - 1 && counter5 < 6; j++)
- {
- if (booksDone[i][j] == ';') counter5++;
- if (counter5 == 5 && booksDone[i][j] != ';') tempik6 += booksDone[i][j];
- }
- CreateItems(hWndList2, (LPTSTR)std::to_string(finded_Books.size() - i).c_str(), (LPSTR)tempik2.c_str(), (LPSTR)tempik3.c_str(), (LPSTR)tempik4.c_str(), (LPSTR)tempik1.c_str(), (LPSTR)tempik5.c_str(), (LPSTR)tempik6.c_str());
- }
- }
- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- PAINTSTRUCT ps;
- HDC hdc;
- switch (message)
- {
- case WM_PAINT:
- hdc = BeginPaint(hWnd, &ps);
- if (modeStatus == ADD)
- {
- TextOut(hdc, 150, 15, "Библиотека - добавление книги", _tcslen("Библиотека - добавление книги"));
- if (ishWndListCreated)
- {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- }
- else if (modeStatus == DEL)
- {
- TextOut(hdc, 150, 15, "Библиотека - удаление книги", _tcslen("Библиотека - удаление книги"));
- if (ishWndListCreated)
- {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- }
- else if (modeStatus == FIND)
- {
- TextOut(hdc, 170, 15, "Библиотека - поиск книги", _tcslen("Библиотека - поиск книги"));
- if (ishWndListCreated)
- {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- }
- else if (modeStatus == SWAP)
- {
- TextOut(hdc, 170, 15, "Библиотека - замена книг", _tcslen("Библиотека - замена книг"));
- if (ishWndListCreated)
- {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- }
- else if (modeStatus == FFIVE)
- {
- TextOut(hdc, 170, 15, "Библиотека - особый поиск", _tcslen("Библиотека - особый поиск"));
- if (ishWndListCreated)
- {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- }
- else if (modeStatus == BASE)
- {
- TextOut(hdc, 210, 15, "Библиотека", _tcslen("Библиотека"));
- if (!ishWndListCreated)
- {
- std::ifstream File;
- std::string text;
- std::vector<std::string> books;
- try
- {
- File.open("library.txt");
- while (std::getline(File, text))
- {
- books.push_back(text);
- }
- }
- catch (int a)
- {
- std::cout << "Не удалось открыть файл!" << std::endl;
- }
- File.close();
- hWndList = CreateWindow(WC_LISTVIEW, "",
- WS_VISIBLE | WS_BORDER | WS_CHILD | LVS_REPORT | LVS_EDITLABELS,
- 50, 50, 400, 180,
- hWnd, (HMENU)100, hInst, 0);
- CreateColumn(hWndList, 0, (LPSTR)"Стоимость", 100);
- CreateColumn(hWndList, 0, (LPSTR)"Дата поступления", 100);
- CreateColumn(hWndList, 0, (LPSTR)"Жанр", 100);
- CreateColumn(hWndList, 0, (LPSTR)"Издательство", 100);
- CreateColumn(hWndList, 0, (LPSTR)"Название", 100);
- CreateColumn(hWndList, 0, (LPSTR)"Автор", 100);
- CreateColumn(hWndList, 0, (LPSTR)"ID", 30);
- std::reverse(books.begin(), books.end());
- for (int i = 0; i < books.size(); i++)
- {
- int counter = 0;
- std::string tempik1 = "";
- std::string tempik2 = "";
- std::string tempik3 = "";
- std::string tempik4 = "";
- std::string tempik5 = "";
- std::string tempik6 = "";
- for (int j = 0; j < books[i].size() && counter < 6; j++)
- {
- if (books[i][j] == ';') counter++;
- if (counter == 0) tempik1 += books[i][j];
- if (counter == 1 && books[i][j] != ';') tempik2 += books[i][j];
- if (counter == 2 && books[i][j] != ';') tempik3 += books[i][j];
- if (counter == 3 && books[i][j] != ';') tempik4 += books[i][j];
- if (counter == 4 && books[i][j] != ';') tempik5 += books[i][j];
- if (counter == 5 && books[i][j] != ';') tempik6 += books[i][j];
- }
- CreateItems(hWndList, (LPTSTR)std::to_string(books.size() - i).c_str(), (LPTSTR)(tempik1.c_str()), (LPSTR)tempik2.c_str(), (LPSTR)tempik3.c_str(), (LPSTR)tempik4.c_str(), (LPSTR)tempik5.c_str(), (LPSTR)tempik6.c_str());
- }
- books.clear();
- ishWndListCreated = true;
- }
- if (!isSetChangeBookPanel) setChangeBookPanel();
- }
- EndPaint(hWnd, &ps);
- break;
- case WM_CTLCOLORSTATIC:
- {
- SetBkMode((HDC)wParam, TRANSPARENT);
- return (LRESULT)CreateSolidBrush(RGB(255, 255, 255));
- }
- break;
- case WM_COMMAND:
- wmId = LOWORD(wParam);
- wmEvent = HIWORD(wParam);
- switch (wmId)
- {
- case 10:
- destroyFindFiveBooksPanel();
- DestroySetChangeBookPanel();
- DestroySwapPanel();
- InvalidateRect(hWnd, NULL, TRUE);
- modeStatus = ADD;
- clearPanel();
- setPanel(false);
- break;
- case 2:
- destroyFindFiveBooksPanel();
- DestroySetChangeBookPanel();
- DestroySwapPanel();
- InvalidateRect(hWnd, NULL, TRUE);
- modeStatus = DEL;
- clearPanel();
- setPanel(true);
- break;
- case 3:
- destroyFindFiveBooksPanel();
- DestroySwapPanel();
- DestroySetChangeBookPanel();
- InvalidateRect(hWnd, NULL, TRUE);
- modeStatus = FIND;
- clearPanel();
- setPanel(true);
- break;
- case 4:
- destroyFindFiveBooksPanel();
- DestroySwapPanel();
- if (ishWndListCreated) {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- clearPanel();
- sort1(false);
- modeStatus = BASE;
- InvalidateRect(hWnd, NULL, TRUE);
- break;
- case 5:
- destroyFindFiveBooksPanel();
- DestroySwapPanel();
- if (ishWndListCreated) {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- clearPanel();
- sort1(true);
- modeStatus = BASE;
- InvalidateRect(hWnd, NULL, TRUE);
- break;
- case 6:
- destroyFindFiveBooksPanel();
- DestroySwapPanel();
- if (ishWndListCreated) {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- clearPanel();
- InvalidateRect(hWnd, NULL, TRUE);
- modeStatus = BASE;
- break;
- case 7:
- destroyFindFiveBooksPanel();
- if (ishWndListCreated) {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- DestroySetChangeBookPanel();
- setSwapPanel();
- clearPanel();
- modeStatus = SWAP;
- InvalidateRect(hWnd, NULL, TRUE);
- break;
- case 8:
- destroyFindFiveBooksPanel();
- DestroySwapPanel();
- if (ishWndListCreated) {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- clearPanel();
- deSort();
- modeStatus = BASE;
- InvalidateRect(hWnd, NULL, TRUE);
- break;
- case 9:
- setFindFiveBooksPanel();
- findFiveBooks();
- DestroySetChangeBookPanel();
- DestroySwapPanel();
- if (ishWndListCreated) {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- clearPanel();
- modeStatus = FFIVE;
- InvalidateRect(hWnd, NULL, TRUE);
- break;
- case 200:
- if (modeStatus == ADD) addBook(
- getTextBoxValue(hEdit),
- getTextBoxValue(hEdit2),
- getTextBoxValue(hEdit3),
- getTextBoxValue(hEdit4),
- getTextBoxValue(hEdit5),
- getTextBoxValue(hEdit6)
- );
- else if (modeStatus == DEL) delBook(
- getTextBoxValue(hEdit),
- getTextBoxValue(hEdit2)
- );
- else if (modeStatus == FIND) findBook(
- getTextBoxValue(hEdit),
- getTextBoxValue(hEdit2)
- );
- clearEdits();
- break;
- case 230:
- if (ishWndListCreated) {
- DestroyWindow(hWndList);
- ishWndListCreated = false;
- }
- clearPanel();
- InvalidateRect(hWnd, NULL, TRUE);
- modeStatus = BASE;
- changeBook(atoi(getTextBoxValue(hEdit13).c_str()) - 1);
- break;
- case 234:
- swapBook(atoi((getTextBoxValue(hEdit14).c_str())) - 1, atoi((getTextBoxValue(hEdit15).c_str())) - 1);
- break;
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement