Please HELP! :(

I can't do the edit function, delete and transaction. and something's problem in my view function.. NEED HELP PLEASE
#include<iostream>
#include<cstdlib>
#include<string.h>
#include<fstream>
#include<iostream>
#include<conio.h>

using namespace std;

void addrecord();
void editrecord();
void viewrecord();
void deleterecord();
void transaction();
string employee;
string customer;
string product;
double empcode;

int main(int argc, char*argv[]){


int choice;
while (choice !=0){
system("cls");
system("color 03");
cout<<"***Main Window***"<<endl;
cout<<"1.Add Record"<<endl;
cout<<"2.Edit Record"<<endl;
cout<<"3.View Record"<<endl;
cout<<"4.Delete Record"<<endl;
cout<<"5.Transaction"<<endl;
cout<<"0.Exit"<<endl;
cout<<"Enter your choice:";
cin>>choice;
if (choice>5 || choice<0) return 0;
else
switch (choice){
case 1:addrecord();
break;
case 2:editrecord();
break;
case 3:viewrecord();
break;
case 4:deleterecord();
break;

system("PAUSE");
return EXIT_SUCCESS;

}}}

void addrecord(){


string empcode,fname,pos,bpay,cuscode,emprecord;
int choice;
string cat;
int connum;
string procode;
string d;
int p;

while (choice !=0){
system("cls");
if (choice==1)
cout<<"***Add Record***"<<endl;
cout<<"1.Employee"<<endl;
cout<<"2.Customer"<<endl;
cout<<"3.Product"<<endl;
cout<<"0.Back to Main Window"<<endl;
cout<<"Enter your choice:";
cin>>choice;

if (choice==1){

switch (choice){
case 1:employee;
system("cls");
cout<<"1.Employee Code:";
cin>>empcode;
cout<<"Fullname:";
getline(cin,fname);
getline(cin,fname);
cout<<"Position:";
getline(cin,pos);
cout<<"Basic Pay:";
getline(cin,bpay);
ofstream newemp;
newemp.open("emprecord.txt",ios::app);
if (newemp.is_open())
newemp<<empcode<<","<<fname<<","<<pos<<","<<bpay<<endl;
else{
cout<<"Error! Writing to a file failed.";
exit(1);}
newemp.close();
break;}}



if (choice==2){

switch (choice){
case 2:customer;
system("cls");
cout<<"1.Customer Code:";
cin>>cuscode;
cout<<"Fullname:";
getline(cin,fname);
getline(cin,fname);
cout<<"Category:";
cin>>cat;
cout<<"Contact Number:";
cin>>connum;
ofstream newcus;
newcus.open("cusrecord.txt",ios::app);
if (newcus.is_open())
newcus<<cuscode<<","<<fname<<","<<cat<<","<<connum<<endl;
else{
cout<<"Error! Writing to a file failed.";
exit(1);}
newcus.close();
break;}}

if (choice==3){

switch (choice){
case 3:product;
system("cls");
cout<<"1.Product Code:";
cin>>procode;
cout<<"Description:";
getline(cin,d);
getline(cin,d);
cout<<"Price:";
cin>>p;
ofstream newpro;
newpro.open("prorecord.txt",ios::app);
if (newpro.is_open())
newpro<<procode<<","<<d<<","<<p<<endl;
else{
cout<<"Error! Writing to a file failed.";
exit(1);}
newpro.close();
break;}}

}system("pause");}


void editrecord(){
ofstream newemp;
newemp.open("emprecord.txt");
string empcode,fname,pos,bpay,cuscode;
int choice;
string cat;
int connum;
string procode;
string d;
int p;

while (choice !=0){
system("cls");
if (choice==2)
cout<<"***Edit Record***"<<endl;
cout<<"1.Employee"<<endl;
cout<<"2.Customer"<<endl;
cout<<"3.Product"<<endl;
cout<<"0.Back to Main Window"<<endl;
cout<<"Enter your choice:";
cin>>choice;
if (choice==1){

system("cls");
cout<<"1.Employee Code:";
cin>>empcode;

ifstream eeditrecord;

eeditrecord.open("emprecord.txt");
while (!eeditrecord.eof() && employee!=empcode)



cout<<"Fullname: "<<endl;
cin>>fname;

cout<<"Position:"<<endl;
cin>>p;

cout<<"Basic Pay:"<<endl;
cin>>bpay;

newemp<<fname<<endl;
newemp<<pos<<endl;
newemp<<bpay<<endl<<endl<<endl;



}
if (choice==2)
switch (choice){

case 2:customer;
system("cls");
cout<<"2.Customer Code:";
cin>>cuscode;
cout<<"Fullname:";
cin>>fname;
cout<<"Category:";
cin>>cat;
cout<<"Contact number:";
cin>>connum;
break;}

if (choice==3)
switch (choice){

case 3:product;
system("cls");
cout<<"3.Product Code:";
cin>>procode;
cout<<"Description:";
cin>>d;
cout<<"Price:";
cin>>p;
break;}

}}

void viewrecord(){

int choice;


string empcode,empname,pos, bpay;
string cuscode,cusname,cat,connum;
string procode,d,p;

system("cls");
cout<<"***View Record***"<<endl;
cout<<"1.Employee"<<endl;
cout<<"2.Customer"<<endl;
cout<<"3.Product"<<endl;
cout<<"0.Back to main window"<<endl;
cout<<"Enter your choice:";
cin>>choice;
if (choice==1){
system("cls");
cout<<"Employee Code:";
cin>>empcode;
system("cls");

ifstream ereadrec;
ereadrec.open("emprecord.txt");
while(!ereadrec.eof() && ereadrec != '\0')

ereadrec>>empcode;
ereadrec>>empname;
ereadrec>>pos;
ereadrec>>bpay;


if( empcode == empcode)
{
cout<<"*************************************"<<endl;
cout << "Employee Code : ";
cout << empcode<<endl;
cout << "Fullname : ";
cout << empname<<endl;
cout << "Position : ";
cout << pos<<endl;
cout << "Basic Pay : ";
cout << bpay<<endl;}}
cout<<"*************************************"<<endl;



if (choice==2){


system("cls");
cout<<"Customer Code:";
cin>>cuscode;
system("cls");

ifstream creadrec;
creadrec.open("cusrecord.txt");
while(!creadrec.eof() && creadrec != '\0')
creadrec >>cuscode;
creadrec >>cusname;
creadrec >>cat;
creadrec >>connum;



if( cuscode == cuscode)
{cout<<"*************************************"<<endl;
cout << "Customer Code : ";
cout << cuscode<<endl;
cout << "Fullname : ";
cout << cusname<<endl;
cout << "Category : ";
cout << cat<<endl;
cout << "Contact Number : ";
cout << connum<<endl;}}
cout<<"*************************************"<<endl;



if (choice==3){

system("cls");
cout<<"Product Code:";
cin>>procode;
system("cls");

ifstream preadrec;
preadrec.open("prorecord.txt");
while(!preadrec.eof() && preadrec != '\0')

preadrec >>procode;
preadrec >>d;
preadrec >>p;


if( procode == procode)
{cout<<"*************************************"<<endl;
cout << "Product Code : ";
cout << procode<<endl;
cout << "Description : ";
cout << d<<endl;
cout << "Price : ";
cout << p<<endl;

}}cout<<"*************************************"<<endl;
system("pause");}







void deleterecord()
{

int temp_empcode;
int temp_cuscode;
int temp_procode;
int choice;
system("cls");
cout<<"***Delete Record***"<<endl;
cout<<"1.Employee"<<endl;
cout<<"2.Customer"<<endl;
cout<<"3.Product"<<endl;
cout<<"0.Back to main window"<<endl;
cout<<"Enter your choice:";
cin>>choice;
system("cls");
if (choice==1)
switch(choice){
case 1: employee;
cout<<"Enter employee code to be deleted: ";
cin>>temp_empcode;
break;}


system("cls");
if (choice==2)
switch(choice){
case 2: customer;
cout<<"Enter customer code to be deleted: ";
cin>>temp_cuscode;
break;}
system("cls");
if (choice==3)
switch(choice){
case 3: product;
cout<<"Enter product code to be deleted: ";
cin>>temp_procode;
break;}


}
Topic archived. No new replies allowed.