-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.cpp
More file actions
134 lines (117 loc) · 3.25 KB
/
view.cpp
File metadata and controls
134 lines (117 loc) · 3.25 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
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
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<fstream>
#include<sstream>
#include<iomanip>
#include "class.h"
#include "search.h"
#include "title.h"
using namespace std;
void view(int indicator)
{
string currentTime;
system("cls");
display(VIEW WINDOW);
Account *ptr;
Array<BasicInfo> bdarr(100);
int i,j,choice,chosenId=indicator;
ptr=new Account;
ifstream bfile("files\\data");
if(bfile.is_open()) //if the file opening is successfull.
{
j=0;
while(!bfile.eof())
{
bdarr[j].loadBasic(bfile);
j++;
}
j--;
bfile.close();
}
else
{
cout<<"There is nothing on this server please input a new account first."<<endl;
return;
}
if(chosenId==-1)
{
cout<<"What do you want to be done?"<<endl
<<"1. View all the accounts."<<endl
<<"2. Detailed information of single account."<<endl
<<"3. Cancel."<<endl
<<endl<<"INPUT: ";
cin>>choice;
while(choice!=1 && choice!=2 && choice!=3)
{
cout<<"Invalid selection !! Try again : ";
cin>>choice;
}
if(choice==2)
{
cout<<"You need to find the account first.Choose a option below :"<<endl
<<"1. Go to SEARCH WINDOW to search by name."<<endl
<<"2. Enter the account ID."<<endl
<<endl<<"INPUT : ";
cin>>choice;
while(choice!=1 && choice!=2)
{
cout<<"Invalid selection !! Try again : ";
cin>>choice;
}
if(choice==1)
chosenId=search_();
else
{
cout<<"Enter the id you want to find : ";
cin>>choice;
for(i=0; i<j; i++)
{
if(bdarr[i].getId()==choice)
{
chosenId=choice;
break;
}
}
if(i==j)
{
cout<<"Id not found!"<<endl;
return;
}
}
}
else if(choice==1)
{
cout<<endl<<"There are "<<j<<" accounts stored in the server."<<endl<<endl;
if(j>0)
cout<<setw(10)<<"ID"<<setw(15)<<"NAME"<<endl;
for(i=0; i<j; i++)
{
cout<<i+1<<"."<<setw(10)<<bdarr[i].getId()<<setw(15)<<bdarr[i].name<<endl; //Formatted I/O
}
return;
}
else
{
cout<<"Process canceled."<<endl;
return;
}
}
if(chosenId==-1)
{
cout<<"Requested account couldnot be viewed!"<<endl;
}
else
{
system("cls");
display(VIEW WINDOW);
string path="files\\customers\\";
stringstream str(path);
str<<path<<chosenId;
path=str.str();
ifstream data(path.c_str());
ptr->loadData(data);
cout<<*ptr; //operator overloading
}
delete ptr;
}