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
|
#include <iostream>
#include <string>
#include <iomanip>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
#include <ctype.h>
#include <cstring>
#include <cstdlib>
using namespace std;
class password{};
class choice{};
string PasswordMasking()
{
string password;
unsigned char p=0;
while((p=getch())!='\r')
{
if(p=='\b')
{
if(password.length()!=0)
{
if(true)
cout <<"\b \b";
password.resize(password.length()-1);
}
}
else if(p==0||p==224) // handle escape sequences
{
getch(); // ignore non printable chars
continue;
}
else
{
password+=p;
if(true)
cout <<'*';
}
}
return password;
}
// Set current cursor position.
void gotoxy( HANDLE StdOut, SHORT x, SHORT y )
{
// Set the cursor position.
COORD Cord;
Cord.X = x;
Cord.Y = y;
SetConsoleCursorPosition( StdOut, Cord );
}
struct Inventory
{
char product[25];
char name[25];
double price;
int stock;
int sold;
char left[30];
float total;
};
int m,n;
void main()
{
string username;
string default_password="070314"; //default password
string default_username="admin"; //default username
HANDLE StdOut = GetStdHandle( STD_OUTPUT_HANDLE );
int ctr=0;
cout<<"___________________________________"<<endl
<<"| PRODUCT INVENTORY SYSTEM CS127L |"<<endl
<<"| |"<<endl
<<"| USERNAME: |"<<endl
<<"___________________________________"<<endl;
for(ctr=0;ctr<1;ctr++)
{
gotoxy(StdOut,11,ctr+3);
cin>>username;
cout<<endl;
}
system("cls");
while(true)
{
for(ctr=0;ctr<3;ctr++)
{
cout<<"___________________________________"<<endl
<<"| PRODUCT INVENTORY SYSTEM CS127L |"<<endl
<<"| |"<<endl
<<"| PASSWORD: |"<<endl
<<"___________________________________"<<endl;
gotoxy(StdOut,11,3);
string password=PasswordMasking();
//incorrect username or password
try
{
if(password.compare(default_password) != 0)
throw password;
}
catch(string pass)
{
system("cls");
if(ctr>2)
exit(1);
continue;
}
}
system("cls");
cout<<"***** INVENTORY SYSTEM C++ *****"<<endl;
cout<<"ENTER NUMBER OF PRODUCTS FOR INVENTORY: ";
int * x=new int [m];
cin>>m;
Inventory data['m'];
int i,j;
HANDLE hStdout = GetStdHandle( STD_OUTPUT_HANDLE );
cout<<endl;
cout<<"ENTER "<<m<<" PRODUCTS"<<endl;
for(i=0;i<m;i++)
{
cout<<"Product"<<i+1<<":";
cin>>data[i].product;
cout<<endl;
cout<<"How many "<<data[i].product<<"?: ";
int * y=new int [n];
cin>>n;
for(j=0;j<n;j++)
{
cout<<data[i].product<<"["<<j+1<<"]: ";
cin>>data[i].name;
cout<<endl;
cout<<"Price: Php";
cin>>data[j].price;
cout<<"Stock: ";
cin>>data[j].stock;
cout<<"Sold: ";
cin>>data[j].sold;
cout<<endl;
}//end j loop
}//end i loop
system("cls");
cout<<" ***** INVENTORY SYSTEM C++ ***** "<<endl;
cout<<" ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"<<endl;
cout<<" º PROD NO. PRODUCT NAME PRICE STOCK SOLD LEFT TOTAL º"<<endl;
cout<<" ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"<<endl;
cout<<" ÉÍÍÍÍÍÍÍÍÍÍÍ»ÍÍÍÍÍÍÍÍÍÍÍÍÍ»ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»ÍÍÍÍÍÍÍÍÍÍÍ»ÍÍÍÍÍÍÍÍÍÍÍ»ÍÍÍÍÍÍÍÍÍÍÍ»ÍÍÍÍÍÍÍÍÍÍÍ»ÍÍÍÍÍÍÍÍÍÍÍ»"<<endl;
cout<<" º º º º º º º º º"<<endl;
cout<<" º º º º º º º º º"<<endl;
cout<<" º º º º º º º º º"<<endl;
cout<<" º º º º º º º º º"<<endl;
cout<<" º º º º º º º º º"<<endl;
cout<<" ÈÍÍÍÍÍÍÍÍÍÍͼÍÍÍÍÍÍÍÍÍÍÍÍͼÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼÍÍÍÍÍÍÍÍÍÍͼÍÍÍÍÍÍÍÍÍÍͼÍÍÍÍÍÍÍÍÍÍͼÍÍÍÍÍÍÍÍÍÍͼÍÍÍÍÍÍÍÍÍÍͼ"<<endl;
for(i=0;i<m;i++)
{
gotoxy(hStdout,9,i+5);
cout<<"["<<i+1<<"]";
for(j=0;j<n;j++)
{
gotoxy(hStdout,20,j+5);
cout<<data[j].product;
cout<<endl;
gotoxy(hStdout,35,j+5);
cout<<data[j].name;
cout<<endl;
gotoxy(hStdout,54,j+5);
cout<<"Php "<<data[j].price;
cout<<endl;
gotoxy(hStdout,69,j+5);
cout<<data[j].stock;
cout<<endl;
gotoxy(hStdout,81,j+5);
cout<<data[j].sold;
cout<<endl;
gotoxy(hStdout,93,j+5);
cout<<data[j].stock-data[j].sold;
cout<<endl;
gotoxy(hStdout,102,j+5);
cout<<"Php "<<data[j].price*data[j].sold;
cout<<endl;
}
}
// cout<<"\n\n\n PRESS ANY KEY TO EXIT.....";
// getch();
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
false;
exit(1);
}//end while
}//end main
|