Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "windows.h"
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <cstdlib>
- using namespace::std;
- int cls() {
- system("cls");
- return 0;
- }
- int addrecord() {
- string fname,lname,dob,inv,yn,mem,age;
- ofstream writerec,listrec;
- cls();
- cout << "::Add Record::\nEnter the scout's information.\nFirst Name: ";
- cin >> fname;
- if (fname=="q") goto end;
- cout << "Last Name: ";
- cin >> lname;
- if (lname=="q") goto end;
- cout << "Age: ";
- cin >> age;
- if (age=="q") goto end;
- cout << "Date of Birth: ";
- cin >> dob;
- if (dob=="q") goto end;
- cout << "Investiture Date: ";
- cin >> inv;
- if (inv=="q") goto end;
- cout << "Membership Number: ";
- cin >> mem;
- if (mem=="q") goto end;
- loop:
- cout << "\nCreate record? [y/n]\nResponse: ";
- cin >> yn;
- if (yn=="n") goto end;
- if (yn=="y") goto create;
- if (yn=="q") goto end;
- cls();
- cout << "ERROR: " << yn << " is not a recognised parameter.";
- Sleep(2000);
- goto loop;
- create:
- cls();
- cout << "Creating record...";
- writerec.open("data/" + fname + lname + ".record");
- if (writerec.is_open()) {
- writerec << "Scout: ";
- writerec << fname;
- writerec << " ";
- writerec << lname;
- writerec << " - Membership #";
- writerec << mem;
- writerec << " - Invested: ";
- writerec << inv;
- writerec << "\nDOB: ";
- writerec << dob;
- writerec << " - Age: ";
- writerec << age;
- writerec << "\n--------------------------------------------------------------------\n";
- writerec.close();
- listrec.open("data/recordlist/" + fname + lname);
- if (listrec.is_open()) {
- listrec << " ";
- listrec.close();
- goto finish;
- }
- cls();
- cout << "ERROR: Could not write to list file. Record could not be created. Please Seek help with this error.";
- goto end;
- finish:
- Sleep(500);
- cls();
- cout << "Record Successfully Created!";
- goto end;
- }
- cls();
- cout << "ERROR: Could not write to file";
- Sleep(2000);
- end:
- return 0;
- }
- int editrecord() {
- string edit;
- cout << "::Edit Record::\nPlease select a record to edit from the list below";
- system("dir/b data\recordlist");
- cout << "\nTo view a record, type it's name.\nResponse: ";
- cin >> edit;
- ifstream filecheck;
- filecheck.open("data/recordlist/" + edit);
- cout << "::Edit Record::\n1. Add Achievement\n2. Add Comment\n3. Manually Edit Record (not reccommended!)\n4. Return to Main Menu";
- return 0;
- }
- int viewrecord() {
- string view,line,path;
- int lines(0);
- view:
- cls();
- cout << "::View Record::\n";
- cout << "A list of all records in the system is below\n\n";
- system("dir/b data\\recordlist");
- cout << "\nTo view a record, type it's name.\nResponse: ";
- cin >> view;
- ifstream record;
- if (view=="q") goto end;
- record.open ("data/" + view + ".record");
- if (record.is_open()) {
- cls();
- cout << "Viewing Record: " << view << "\n\n";
- while (! record.eof())
- {
- getline (record,line);
- cout << line << endl;
- ++lines;
- }
- cout << "\n--End of Record--\n\nTotal Lines: " << lines << "\n\n";
- system("pause");
- record.close();
- } else {
- cls();
- system("color 47");
- cout << "ERROR: Record not found or cannot be opened.";
- Sleep(3000);
- system("color 17");
- }
- cls();
- end:
- return 0;
- }
- int main() {
- system("color 17");
- int menu;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement