-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMANAGEME.CPP
More file actions
89 lines (87 loc) · 1.69 KB
/
MANAGEME.CPP
File metadata and controls
89 lines (87 loc) · 1.69 KB
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
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<stdlib.h>
struct product10{
int code;
char productname[30];
float price;
int quantity;
}search;
void status()
{
int scode;
char tryy='y';
char found = 'f';
ifstream fio("products.dat",ios::in);
while(tryy=='y')
{
cout<<"\n\nEnter the code of the product you wish to search for : ";
cin>>scode;
found = 'f';
while(!fio.eof())
{
fio.read((char*)&search,sizeof(product10));
if(scode==search.code)
{
cout<<"\n\nRequested record : \nCode : "<<search.code<<"\tName : "<<search.productname<<"\tPrice : "<<search.price<<"\tQuantity : "<<search.quantity;
found = 't';
getch();
break;
}
}
if(found!='t')
{
cout<<"Invalid product code entered ! Please recheck the values and try again ...";
}
cout<<"\n\nTry again ? <y/n> : ";
cin>>tryy;
fio.close();
}
fio.close();
}
void sort()
{
int desired;
clrscr();
cout<<"\n\nEnter the minimum desired quantity : ";
cin>>desired;
char found = 'f';
ifstream fio;
fio.open("products.dat",ios::in);
cout<<"Products with stock less than "<<desired<<" units : ";
while(!fio.eof())
{
fio.read((char*)&search,sizeof(product10));
if(search.quantity<desired)
{
cout<<"\n\n \nCode : "<<search.code<<"\tName : "<<search.productname<<"\tPrice : "<<search.price<<"\tQuantity : "<<search.quantity;
found = 't';
}
}
getch();
if(found!='t')
{
cout<<"No product's stock is below "<<desired<<" units";
}
fio.close();
}
void main()
{
int check;
clrscr();
cout<<"\t\t\t\tSTORE MANAGEMENT";
cout<<"\n\nPress : \n1.Check product status\n2.Check products with low stock\n\nYour Option : ";
cin>>check;
switch(check)
{
case 1: status();
break;
case 2: sort();
break;
default : cout<<"\nGet back to your senses idiot ...";
getch();
break;
};
}