/
Alexandr_Pidkasisty
/
froma2
Обзор
Документация
Войти
/
Alexandr_Pidkasisty
/
froma2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
examples/CCStorage/main.cpp
282 строки
16 KB
Alexandr Pidkasisty
В файле main.cpp добавил переменную decimal _share, которую потом передаю параметром в функцию Stock_A->SetShare(i, _share) вместо подстановки значения
03 апр 2026, 14:55
Верифицирован
03 апр 2026, 14:55
0c8ee5a
Код
Авторство
О чём код?
#include <iostream> #include <clsCCStorageTest.h> #include <clsCostCenterStorage.h> /** ����� ������ ��� �������� ������ �� ������ **/ #define f_ws_volume "f_ws_volume.csv" // ������ �������� �� ������ � ����������� ��������� #define f_ws_price "f_ws_price.csv" // ���� �������� #define f_ws_value "f_ws_value.csv" // ��������� �������� #define f_wp_volume "f_wp_volume.csv" // ������ ������� �� ����� � ����������� ��������� #define f_wp_price "f_wp_price.csv" // ���� ������� #define f_wp_value "f_wp_value.csv" // ��������� ������� #define f_PCCs_volume "f_PCCs_volume.csv" // ����� �������� �� ��� � ��� � ����������� ��������� #define f_PCCs_price "f_PCCs_price.csv" // ���� �������� �� ��� � ��� #define f_PCCs_value "f_PCCs_value.csv" // ��������� �������� �� ��� � ��� #define f_RACp_volume "f_RACp_volume.csv" // ����� �������� � ��� �� ��� � ����������� ��������� #define f_RACp_price "f_RACp_price.csv" // ���� �������� � ��� �� ��� #define f_RACp_value "f_RACp_value.csv" // ��������� �������� � ��� �� ��� #define f_RACs_volume "f_RACs_volume.csv" // ����� �������� �� ��� � ��� � ����������� ��������� #define f_RACs_price "f_RACs_price.csv" // ���� �������� �� ��� � ��� #define f_RACs_value "f_RACs_value.csv" // ��������� �������� �� ��� � ��� #define f_SCCp_volume "f_SCCp_volume.csv" // ����� �������� � ��� �� ��� � ����������� ��������� #define f_SCCp_price "f_SCCp_price.csv" // ���� �������� � ��� �� ��� #define f_SCCp_value "f_SCCp_value.csv" // ��������� �������� � ��� �� ��� using namespace std; int main(int argc, char* argv[]) { setlocale(LC_ALL, "Russian"); // ��������� �������� ����� ��� ������ /** ����� ��������� �� ����� **/ string clogHead = "������������ ������ ������ clsCostCenterStorage"; nmRePrint::PrintHeader0(clog, nmRePrint::smblcunt+nmRePrint::uThree, clogHead); Currency Cur = RUR; // ������ ������� const AccountingMethod ac = AVG; // ������������� ������� ����� ������� /****************************************************************************************************/ /** ����������� �������� ������ � ������� �������� ������� **/ /****************************************************************************************************/ clsCCStorageTest* Test = new clsCCStorageTest();// ������� ������ � ��������� ������� if(!Test->Import_Data(Cur, AVG)) { cerr << "������ ������ ��������\n"; // ���� ������ ��������, �� delete Test; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� } /****************************************************************************************************/ /** ������� ����� � ��� � ��� **/ /****************************************************************************************************/ clsCostCenterStorage* Stock_A = new clsCostCenterStorage(Test->GetProjectCount(), Cur, ac, Test->GetOutCount(),\ Test->GetMidCount(), Test->GetInCount(), Test->GetNames()); /********************************* ����� ���������� �� ����� ****************************************/ cout << "���������� �������� �������:\t\t\t\t\t\t" << Stock_A->ProjectCount() << endl; cout << "����� �������� �� ����� ������ (������� ����������� � ������������)\t " << Stock_A->Counts(inStock) << endl; cout << "����� �������� �� ��������\t\t\t\t\t\t " << Stock_A->Counts(midStock) << endl; cout << "����� ����������� �� ������ ��������\t\t\t\t\t " << Stock_A->Counts(outStock) << endl << endl; clsTextField name(40); // ��������� ������� ������ ���� � ������� ������ clsTextField clsTextField meas(10); // ��������� ������� ������ ������ ��������� const strNameMeas *Resources = Stock_A->GetNameMeas(); // �������� ��������� �� ������ � ��������� nmRePrint::PrintHeader1(cout, nmRePrint::smblcunt+nmRePrint::uThree, \ "������� �� ������ (������� ����������� � ������������)"); nmRePrint::PrintUnderHeader(nmRePrint::smblcunt+nmRePrint::uThree, \ "������� ����������� �� ����� � ����������� �� ������"); for(size_t i{}; i<Stock_A->Counts(inStock); i++) { if(i==Stock_A->Counts(outStock)) nmRePrint::PrintUnderHeader(nmRePrint::smblcunt+nmRePrint::uThree, \ "�������, ������������ � ���"); if(i==Stock_A->Counts(midStock)) nmRePrint::PrintUnderHeader(nmRePrint::smblcunt+nmRePrint::uThree, \ "�������, ������������ � ���"); cout << name << (Resources+i)->name; cout << meas << (Resources+i)->measure << endl; } /****************************************************************************************************/ /** ������� ��������� ��������� **/ /****************************************************************************************************/ string Working = "Working"; type_progress* progress = new type_progress(std::clog, 75u, move(Working), '.', Test->GetOutCount()); clsProgress_shell<type_progress>* shell = new clsProgress_shell<type_progress>(progress, Test->GetOutCount(), 1); Stock_A->Set_progress_shell(shell); /** ���� �������� ���� ��������� ������������ ������� ������������ � �������������� **/ clog << endl; string temp_dir; // ��������� ����� (temp_dir.assign(V_DIR_TEMP)).append("CostCenterStorage.dat"); // ������ ���� �� ����� ��������� Stock_A->SaveToFile(temp_dir); delete Stock_A; Stock_A = new clsCostCenterStorage(); if(!Stock_A->ReadFromFile(temp_dir)) return EXIT_FAILURE; Stock_A->Set_progress_shell(shell); /** ������ � ����� �������� ������ � ������������ ����������� �������� **/ if(!Stock_A->SetStorage(Test->GetShip(), Test->GetPurch(),Test->GetOutRecipe(), Test->GetInRecipe())) { cout << "������ �������� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, delete Test; return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; delete Test; // ������� ������ � ��������� ������� �� ������������� decimal _share = 0.5; // �������� ������ �� ������ for(size_t i{}; i<Stock_A->Counts(outStock); i++) { // ��� ������� ������������ ������� ������������� Stock_A->SetShare(i, _share); // �������� ������ ������� ��������� � ����� �� ������ �������� }; /********************************* ����� ���������� �� ����� ****************************************/ cout << endl << endl; nmRePrint::PrintHeader1(cout, nmRePrint::smblcunt+nmRePrint::uThree, "��������� �������"); Stock_A->ViewSettings(); /** ������� ������� ��� �������� **/ // Stock_A->SetAutoPurchase(2, nocalc); /** ���� �������� ���� ��������� ������������ ������������� ����������� � ����������� � ���������� ���������� **/ clsCostCenterStorage* A = new clsCostCenterStorage(*Stock_A); // ������� ������ ������������ clsCostCenterStorage* B = new clsCostCenterStorage(move(*A)); // ������� ������ ������������ clsCostCenterStorage* C = new clsCostCenterStorage(); // ������� ������ ������ clsCostCenterStorage* D = new clsCostCenterStorage(); // ������� ������ ������ *C = *B; *D = move(*C); delete Stock_A; Stock_A = new clsCostCenterStorage(move(*D)); delete A; delete B; delete C; delete D; /** ���� �������� ���� ��������� ������������ ������� ������������ � �������������� **/ clog << endl; Stock_A->SaveToFile(temp_dir); delete Stock_A; Stock_A = new clsCostCenterStorage(); if(!Stock_A->ReadFromFile(temp_dir)) return EXIT_FAILURE; Stock_A->Set_progress_shell(shell); /** ������������ ����� **/ if(!Stock_A->Calculate()) { if(Stock_A->GetLack().lack > dZero) cerr << endl << "��������� ������� " << Stock_A->GetLack().lack << " ��� �������: " \ << Stock_A->GetLack().Name << endl; cerr << "������ �������" << endl; delete Stock_A; return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /****************************************************************************************************/ /** ������� csv-������ **/ /****************************************************************************************************/ string outdir = V_DIR_OUTPUTDATA; cout << endl << "������� CSV-������ � ����� " << outdir << endl; /** ����� �������� � ����������� ��������� **/ if(!Stock_A->Export_Data(outdir+f_ws_volume, outStock, shipment, volume)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /** ����� �������� � �������� ����������� ��������� **/ if(!Stock_A->Export_Data(outdir+f_ws_price, outStock, shipment, price)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� } /** ����� �������� � ������ ����������� ��������� **/ if(!Stock_A->Export_Data(outdir+f_ws_value, outStock, shipment, value)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� } /** ����� ������� � ����������� ��������� **/ if(!Stock_A->Export_Data(outdir+f_wp_volume, inStock, purchase, volume)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /** ����� ������� � �������� ����������� ��������� **/ if(!Stock_A->Export_Data(outdir+f_wp_price, inStock, purchase, price)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /** ����� ������� � ������ ����������� ��������� **/ if(!Stock_A->Export_Data(outdir+f_wp_value, inStock, purchase, value)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /** ����� �������� �� ��� � ��� � ����������� ��������� **/ if(!Stock_A->Export_Data(outdir+f_PCCs_volume, inStock, shipment, volume)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /** ���� �������� �� ��� � ��� **/ if(!Stock_A->Export_Data(outdir+f_PCCs_price, inStock, shipment, price)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /** ��������� �������� �� ��� � ��� **/ if(!Stock_A->Export_Data(outdir+f_PCCs_value, inStock, shipment, value)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /** ����� �������� � ��� �� ��� � ����������� ��������� **/ if(!Stock_A->Export_Data(outdir+f_RACp_volume, midStock, purchase, volume)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /** ���� �������� � ��� �� ��� **/ if(!Stock_A->Export_Data(outdir+f_RACp_price, midStock, purchase, price)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /** ��������� �������� � ��� �� ��� **/ if(!Stock_A->Export_Data(outdir+f_RACp_value, midStock, purchase, value)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� }; /** ����� �������� �� ��� � ��� � ����������� ��������� **/ if(!Stock_A->Export_Data(outdir+f_RACs_volume, midStock, shipment, volume)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� } /** ���� �������� �� ��� � ��� **/ if(!Stock_A->Export_Data(outdir+f_RACs_price, midStock, shipment, price)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� } /** ��������� �������� �� ��� � ��� **/ if(!Stock_A->Export_Data(outdir+f_RACs_value, midStock, shipment, value)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� } /** ����� �������� � ��� �� ��� � ����������� ��������� **/ if(!Stock_A->Export_Data(outdir+f_SCCp_volume, outStock, purchase, volume)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� } /** ���� �������� � ��� �� ���. ������ ����� �������, ������� ������� �� ��������� **/ if(!Stock_A->Export_Data(outdir+f_SCCp_price, outStock, purchase, price)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� } /** ��������� �������� � ��� �� ���. ������ ����� �������, ������� ������� �� ��������� **/ if(!Stock_A->Export_Data(outdir+f_SCCp_value, outStock, purchase, value)) { cout << "������� �������� ������ �� ������\n"; // ���� ������� ��������, �� delete Stock_A; // ������� �����, return EXIT_FAILURE; // ������� �� ��������� � ����� ���������� ���������� } cout << "������. ������ ��������������" << endl; cout << "Copyright (c) 2025 ����������� ��������� ��������"; delete Stock_A; delete progress; delete shell; return EXIT_SUCCESS; }