1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
| #include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <locale>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <cstring>
#include <iomanip>
#include "ConsoleApplication8.h"
using namespace std;
class Customers
{
public:
int PersonaCode;
string namecust, Surnamecust, MiddleNamecust, phonecust, emailcust, Settlementcust, Streetcust, PersHousecust, PersFlatcust, PostCodecust, DiscType;
public:
void setCustomers(int tPersonaCode, string tnamecust, string tSurnamecust, string tMiddleNamecust, string tphonecust, string temailcust, string tSettlementcust, string tStreetcust, string tPersHousecust, string tPersFlatcust, string tPostCodecust, string tDiscType)
{
PersonaCode = tPersonaCode;
namecust = tnamecust;
Surnamecust = tSurnamecust;
MiddleNamecust = tMiddleNamecust;
phonecust = tphonecust;
emailcust = temailcust;
Settlementcust = tSettlementcust;
Streetcust = tStreetcust;
PersHousecust = tPersHousecust;
PersFlatcust = tPersFlatcust;
PostCodecust = tPostCodecust;
DiscType = tDiscType;
}
void getCustomers()
{
cout << "\nКод клiєнта: " << PersonaCode << "\nIм'я: " << namecust << "\nПрізвище: " << Surnamecust << "\nПо-батькові: " << MiddleNamecust << "\nНомер телефону: " << phonecust << "\nEmail: " << emailcust << "\nПоселення: " << Settlementcust << "\nВулиця: " << Streetcust << "\nБудинок:" << PersHousecust << "\nКвартира: " << PersFlatcust << "\nПоштовий адрес: " << PostCodecust << "\nДисконт:" << DiscType << endl;
}
friend std::istream& operator >>(std::istream& in, Customers& obj)
{
in >> obj.PersonaCode >> obj.namecust >> obj.Surnamecust >> obj.MiddleNamecust
>> obj.phonecust >> obj.emailcust >> obj.Settlementcust
>> obj.Streetcust >> obj.PersHousecust >> obj.PersFlatcust
>> obj.PostCodecust >> obj.DiscType;
return in;
};
friend std::ostream& operator <<(std::ostream& out, const Customers& obj)
{
return out
<< "\nКод клiєнта:" << obj.PersonaCode
<< "\nІм'я:" << obj.namecust
<< "\nПрізвище:" << obj.Surnamecust
<< "\nПо батькові" << obj.MiddleNamecust
<< "\nНомер телефону:" << obj.phonecust
<< "\nEmail:" << obj.emailcust
<< "\nПоселення:" << obj.Settlementcust
<< "\nВулиця:" << obj.Streetcust
<< "\nБудинок:" << obj.PersHousecust
<< "\nКвартира:" << obj.PersFlatcust
<< "\nПоштова адреса:" << obj.PostCodecust
<< "\nДисконт:" << obj.DiscType;
}
};
class Employees
{
private:
int PersCode;
string name, Surname, MiddleName, phone, email, Settlement, Street, PersHouse, PersFlat, PostCode, StoreRel, DateStart, DateFinish;
public:
void setEmployees(int tPersCode, string tname, string tSurname, string tMiddleName, string tphone, string temail, string tSettlement, string tStreet, string tPersHouse, string tPersFlat, string tPostCode, string tStoreRel, string tDateStart, string tDateFinish)
{
PersCode = tPersCode;
name = tname;
Surname = tSurname;
MiddleName = tMiddleName;
phone = tphone;
email = temail;
Settlement = tSettlement;
Street = tStreet;
PersHouse = tPersHouse;
PersFlat = tPersFlat;
PostCode = tPostCode;
StoreRel = tStoreRel;
DateStart = tDateStart;
DateFinish = tDateFinish;
}
void getEmployees()
{
cout << "\nКод працiвника: " << PersCode << "\nIм'я: " << name << "\nПрізвище: " << Surname << "\nПо-батькові: " << MiddleName << "\nНомер телефону: " << phone << "\nEmail: " << email << "\nПоселення: " << Settlement << "\nВулиця: " << Street << "\nБудинок:" << PersHouse << "\nКвартира: " << PersFlat << "\nПоштовий адрес: " << PostCode << "\nПосада: " << StoreRel << "\nДата прийняття: " << DateStart << "\nДата звільнення: " << DateFinish << endl;
}
friend std::istream& operator >>(std::istream& in, Employees& obj)
{
in >> obj.PersCode >> obj.name >> obj.Surname >> obj.MiddleName
>> obj.phone >> obj.email >> obj.Settlement
>> obj.Street >> obj.PersHouse >> obj.PersFlat
>> obj.PostCode >> obj.StoreRel >> obj.DateStart
>> obj.DateFinish;
return in;
};
friend std::ostream& operator <<(std::ostream& out, const Employees& obj)
{
return out
<< "\nКод працівника: " << obj.PersCode
<< "\nІм'я: " << obj.name
<< "\nПрізвище: " << obj.Surname
<< "\nПо батькові: " << obj.MiddleName
<< "\nНомер телефону: " << obj.phone
<< "\nEmail: " << obj.email
<< "\nПоселенння: " << obj.Settlement
<< "\nВулиця: " << obj.Street
<< "\nБудинок: " << obj.PersHouse
<< "\nКвартира: " << obj.PersFlat
<< "\nПоштовий адрес: " << obj.PostCode
<< "\nПосада: " << obj.StoreRel
<< "\nДата прийняття: " << obj.DateStart
<< "\nДата звільнення: " << obj.DateFinish;
}
};
class Product //* Класс товар, тот для которого нужно сделать поиск по критерию минимальной цены
{
private:
int Product_Code, Product_amount;
string Title, Production, ProductType, Unit;
double Purch_price, Price;
public:
void setProduct(int TProduct_Code, int TProduct_amount, string Ttitle, string tProduction, string tProductType, string tUnit, double TPurch_Price, double TPrice)
{
Product_Code = TProduct_Code;
Product_amount = TProduct_amount;
Title = Ttitle;
Production = tProduction;
ProductType = tProductType;
Unit = tUnit;
Purch_price = TPurch_Price;
Price = TPrice;
}
void getProduct()
{
cout << "\nКод товару: " << Product_Code << "\nК-сть товару: " << Product_amount << "\nНазва товару: " << Title << "\nКраїна виробництва: " << Production << "\nТип товару: " << ProductType << "\nОдиниця вимiру: " << Unit << "\nЗакупiвельна цiна: " << Purch_price << "\nЦiна продажу: " << Price << endl;
}
friend std::istream& operator >>(std::istream& in, Product& obj)
{
in >> obj.Product_Code >> obj.Product_amount >> obj.Title
>> obj.Production >> obj.ProductType >> obj.Unit
>> obj.Purch_price >> obj.Price;
return in;
}
friend std::ostream& operator <<(std::ostream& out, const Product& obj)
{
return out
<< "Код товару: " << obj.Product_Code
<< "\nК-сть товару: " << obj.Product_amount
<< "\nНазва товару: " << obj.Title
<< "\nКраїна виробництва " << obj.Production
<< "\nТип товару " << obj.ProductType
<< "\nОдиниця виміру " << obj.Unit
<< "\nЗакупівельна ціна " << obj.Purch_price
<< "\nЦіна продажу " << obj.Price;
}
}; //* Класс товар, тот для которого нужно сделать поиск по критерию минимальной цены
void f1() {
std::vector<Customers> Customerss;
int PersonaCode;
string namecust, Surnamecust, MiddleNamecust, phonecust, emailcust, Settlementcust, Streetcust, PersHousecust, PersFlatcust, PostCodecust, DiscType;
int n = 1;
while (n == 1)
{
cout << "\nВведiть данi про клiєнта:\n";
cout << "\nКод клiєнта: "; cin >> PersonaCode;
cout << "\nIм'я: "; cin >> namecust;
cout << "\nПрізвище: "; cin >> Surnamecust;
cout << "\nПо-батькові: "; cin >> MiddleNamecust;
cout << "\nНомер телефону: "; cin >> phonecust;
cout << "\nEmail: "; cin >> emailcust;
cout << "\nПоселення: "; cin >> Settlementcust;
cout << "\nВулиця: "; cin >> Streetcust;
cout << "\nБудинок: "; cin >> PersHousecust;
cout << "\nКвартира: "; cin >> PersFlatcust;
cout << "\nПоштовий адрес: "; cin >> PostCodecust;
cout << "\nДисконт: "; cin >> DiscType;
Customers objCustomers;
objCustomers.setCustomers(PersonaCode, namecust, Surnamecust, MiddleNamecust, phonecust, emailcust, Settlementcust, Streetcust, PersHousecust, PersFlatcust, PostCodecust, DiscType);
objCustomers.getCustomers();
Customerss.push_back(objCustomers);
cout << "\nДодати ще один товар? (1 - Так)\n "; cin >> n;
}
for (auto& Customers : Customerss)
Customers.getCustomers();
ofstream fout("Customer.txt", std::ios_base::out | std::ios_base::app);
for (auto& Customers : Customerss)
fout << Customers << std::endl;
}
void show()
{
string fname = "Customer.txt";
fstream f;
f.open(fname.c_str(), ios_base::in);
if (f.is_open())
{
Customers tmp;
while (f >> tmp)
std::cout << tmp;
f.close();
}
else
cout << "ERROR: файл не знайдено" << endl << endl;
}
void f2() {
std::vector<Employees> Employeees;
int PersCode;
string name, Surname, MiddleName, phone, email, Settlement, Street, PersHouse, PersFlat, PostCode, StoreRel, DateStart, DateFinish;
int n = 1;
while (n == 1)
{
cout << "\nВведiть данi про працiвника:\n";
cout << "\nКод працівника: "; cin >> PersCode;
cout << "\nIм'я: "; cin >> name;
cout << "\nПрізвище: "; cin >> Surname;
cout << "\nПо-батькові: "; cin >> MiddleName;
cout << "\nНомер телефону: "; cin >> phone;
cout << "\nEmail: "; cin >> email;
cout << "\nПоселення: "; cin >> Settlement;
cout << "\nВулиця: "; cin >> Street;
cout << "\nБудинок: "; cin >> PersHouse;
cout << "\nКвартира: "; cin >> PersFlat;
cout << "\nПоштовий адрес: "; cin >> PostCode;
cout << "\nПосада: "; cin >> StoreRel;
cout << "\nДата прийняття: "; cin >> DateStart;
cout << "\nДата звільнення: "; cin >> DateFinish;
Employees objEmployees;
objEmployees.setEmployees(PersCode, name, Surname, MiddleName, phone, email, Settlement, Street, PersHouse, PersFlat, PostCode, StoreRel, DateStart, DateFinish);
Employeees.push_back(objEmployees);
cout << "\nДодати ще одного працiвника? (1 - Так)\n "; cin >> n;
}
for (auto& Employees : Employeees)
Employees.getEmployees();
ofstream fout("Employees.txt", std::ios_base::out | std::ios_base::app);
for (auto& Employees : Employeees)
fout << Employees << std::endl;
}
void showEmp()
{
string fname = "Employees.txt";
fstream f;
f.open(fname.c_str(), ios_base::in);
if (f.is_open())
{
Employees tmp;
while (f >> tmp)
std::cout << tmp;
f.close();
}
else
cout << "ERROR: файл не знайдено" << endl << endl;
}
void f3()
{
std::vector<Product> products;
int Product_Code, Product_amount;
string Title, Production, ProductType, Unit;
double Purch_price, Price;
int n = 1;
while (n == 1)
{
cout << "\nВведiть данi про товар:\n";
cout << "\nКод товару: "; cin >> Product_Code;
cout << "\nК-сть товару: "; cin >> Product_amount;
cout << "\nНазва товару: "; cin >> Title;
cout << "\nКраїна виробництва: "; cin >> Production;
cout << "\nТип товару: "; cin >> ProductType;
cout << "\nОдиниця вимiру: "; cin >> Unit;
cout << "\nЗакупiвельна цiна: "; cin >> Purch_price;
cout << "\nЦiна продажу: "; cin >> Price;
Product objProduct;
objProduct.setProduct(Product_Code, Product_amount, Title, Production, ProductType, Unit, Purch_price, Price);
products.push_back(objProduct);
cout << "\nДодати ще один товар? (1 - Так)\n "; cin >> n;
}
for (auto& product : products)
product.getProduct();
ofstream fout("Products.txt", std::ios_base::out | std::ios_base::app);
for (auto& product : products)
fout << product << std::endl;
}
void showProd()
{
string fname = "Products.txt";
fstream f;
f.open(fname.c_str(), ios_base::in);
if (f.is_open())
{
Product tmp;
while (f >> tmp)
std::cout << tmp;
f.close();
}
else
cout << "ERROR: файл не знайдено" << endl << endl;
}
void SearchProd()
{
int booksCount = 0;
string fname = "Products.txt";
cout << "Введіть мінімальну ціну товару: ";
int year;
cin >> year;
cout << endl << "Товар знайдено " << year << endl;
cout << "Код товару\tК-сть товару\tНазва товару\tКраїна виробництва\tТип товару\tОдиниця виміру\tЗакупівельна ціна\tЦіна продажу" << endl << endl;
for (int i = 0; i < booksCount; i++)
{
if (atoi(Product[i].Price.c_str()) > year)
cout << '.' << Product[i].Product_Code << '\t' << Product[i].Product_amount << '\t' << Product[i].Title << '\t' << Product[i].Production << '\t' << Product[i].ProductType << Product[i].Unit << Product[i].Purch_price << Product[i].Price << endl;
}
cout << endl;
break;
}
int main(int argc, char* argv[])
{
setlocale(LC_ALL, "Russian");
while (1) {
cout << "Виберiть роздiл" << endl;
cout << "0 - exit" << endl;
cout << "1 - Роздiл 'Клiєнти' " << endl;
cout << "2 - Роздiл 'Працiвники' " << endl;
cout << "3 - Роздiл 'Товар' " << endl;
cout << "4 - Список клієнт " << endl;
cout << "5 - Список працівників " << endl;
cout << "6 - Список товарів " << endl;
cout << "7 - Список товарів " << endl;
int mode = 0;
cin >> mode;
if (mode == 0) {
break;
}
else if (mode == 1) {
f1();
}
else if (mode == 2) {
f2();
}
else if (mode == 3) {
f3();
}
else if (mode == 4) {
show();
}
else if (mode == 5) {
showEmp();
}
else if (mode == 6) {
showProd();
}
else if (mode == 7) {
SearchProd();
}
else {
cout << "Такого номера немає у списку." << endl;
}
}
system("pause");
return 0;
}; |