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
|
void Modify_Appointment(ifstream& in_app_file, ofstream& out_app_file)
{
string appointmentID2;
cout << "Enter the appointment ID that you would like to modify"<<endl;
cin >> appointmentID2;
string line;
while (in_app_file.good())
{
getline(in_app_file, line);
cout << line << endl;
int appointmentIDLength = appointmentID2.length();
string IDCheck = appointmentID2 + ";";
if (line.substr(0, appointmentIDLength + 1) == IDCheck)
{
int count_appointmentID = 0;
while (line[count_appointmentID] != ';')
{
count_appointmentID++;
}
/* cut out counter code here */
cout << "Please select from one of the following:"<<endl<<"W-to modify 'With' attribute"<<endl<<"D-to modify the 'Date' attribute"<<endl<<"T-to modify the 'timing' attribute"<<endl<<"L-to modify the 'location' attribute"<<endl;
string C_selection_screen;
cin >> C_selection_screen;
if (C_selection_screen == "W")
{
string appointmentWith2;
cout << "Enter the new name:"<<endl;
cin.ignore(1, 'n');
getline(cin, appointmentWith2);
//string name = line.substr(count_appointmentID, count_appointmentWith - count_appointmentID);
//string day =
cout << out_app_file.good() << endl;
cout << out_app_file.fail() << endl;
cout << line.substr(0, count_appointmentID) << "; "<< appointmentWith2 <<
line.substr(count_appointmentWith, count_day - count_appointmentWith) <<
line.substr(count_day, count_month - count_day) <<
line.substr(count_month, count_year - count_month) <<
line.substr(count_year, count_appointmentStartTime - count_year) <<
line.substr(count_appointmentStartTime, count_appointmentDuration - count_appointmentStartTime) <<
line.substr(count_appointmentDuration, count_appointmentLocation - count_appointmentDuration) << endl;
out_app_file << line.substr(0, count_appointmentID) << "; "<< appointmentWith2 <<
line.substr(count_appointmentWith, count_day - count_appointmentWith) <<
line.substr(count_day, count_month - count_day) <<
line.substr(count_month, count_year - count_month) <<
line.substr(count_year, count_appointmentStartTime - count_year) <<
line.substr(count_appointmentStartTime, count_appointmentDuration - count_appointmentStartTime) <<
line.substr(count_appointmentDuration, count_appointmentLocation - count_appointmentDuration) << endl;
}
else if (C_selection_screen == "D")
{
string day2;
string month2;
string year2;
cout << "Enter new appointment day of month:"<<endl;
cin >> day2;
cout << "Enter new appointment month of year:"<<endl;
cin >> month2;
cout << "Enter new appointment year:"<<endl;
cin >> year2;
out_app_file << line.substr(0, count_appointmentID) <<
line.substr(count_appointmentID, count_appointmentWith - count_appointmentID) <<
"; " << day2 << "; " << month2 << "; " << year2 <<
line.substr(count_year, count_appointmentStartTime - count_year) <<
line.substr(count_appointmentStartTime, count_appointmentDuration - count_appointmentStartTime) <<
line.substr(count_appointmentDuration, count_appointmentLocation - count_appointmentDuration) << endl;
}
else if (C_selection_screen == "T")
{
string appointmentStartTime2;
cout << "Enter the new start time:"<<endl;
cin >> appointmentStartTime2;
out_app_file << line.substr(0, count_appointmentID) <<
line.substr(count_appointmentID, count_appointmentWith - count_appointmentID) <<
line.substr(count_appointmentWith, count_day - count_appointmentWith) <<
line.substr(count_day, count_month - count_day) <<
line.substr(count_month, count_year - count_month) <<
"; " << appointmentStartTime2 <<
line.substr(count_appointmentStartTime, count_appointmentDuration - count_appointmentStartTime) <<
line.substr(count_appointmentDuration, count_appointmentLocation - count_appointmentDuration) << endl;
cout << "Would you like to change the duration as well? Enter 1 for yes, 0 for no"<<endl;
bool duration_change;
cin >> duration_change;
if (duration_change==1)
{
string appointmentDuration2;
cout << "Enter new duration:"<<endl;
cin >> appointmentDuration2;
out_app_file << line.substr(0, count_appointmentID) <<
line.substr(count_appointmentID, count_appointmentWith - count_appointmentID) <<
line.substr(count_appointmentWith, count_day - count_appointmentWith) <<
line.substr(count_day, count_month - count_day) <<
line.substr(count_month, count_year - count_month) <<
line.substr(count_year, count_appointmentStartTime - count_year) <<
"; " << appointmentDuration2 <<
line.substr(count_appointmentDuration, count_appointmentLocation - count_appointmentDuration) << endl;
}
else {}
}
else if (C_selection_screen == "L")
{
string appointmentLocation2;
cout << "Enter the new location:" << endl;
cin >> appointmentLocation2;
out_app_file << line.substr(0, count_appointmentID) <<
line.substr(count_appointmentID, count_appointmentWith - count_appointmentID) <<
line.substr(count_appointmentWith, count_day - count_appointmentWith) <<
line.substr(count_day, count_month - count_day) <<
line.substr(count_month, count_year - count_month) <<
line.substr(count_year, count_appointmentStartTime - count_year) <<
line.substr(count_appointmentStartTime, count_appointmentDuration - count_appointmentStartTime) <<
"; " << appointmentLocation2 << endl;
}
}
else
{
out_app_file << line << endl;
}
}
|