From f138c79d4f419b67d5312fa945dde34e94676978 Mon Sep 17 00:00:00 2001 From: tejasbhimani <57887162+tejasbhimani@users.noreply.github.com> Date: Wed, 20 May 2020 12:33:50 +0530 Subject: [PATCH 1/6] Add files via upload --- CS_Management.cpp | 278 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 244 insertions(+), 34 deletions(-) diff --git a/CS_Management.cpp b/CS_Management.cpp index 4f953a7..6a8874c 100644 --- a/CS_Management.cpp +++ b/CS_Management.cpp @@ -1,46 +1,256 @@ -// CS_Management.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - #include +#include +#include +#include +#include +#include + + using namespace std; class CarService { - void CheckIn(); - void CheckOut(); - void Admin(); - void Employee(); - void AlreadyCust(); - void NewCust(); - void RTHP(); - void NewComplain(); - void ServiceHistory(); - void Submit(); +public: + string buffer; + void HomePage(); + void CheckIn(); + void CheckOut(); + void Admin(); + void Employee(); + void AlreadyCust(); + void NewCust(); + + void NewComplain(); + void ServiceHistory(); + void Submit(); + void Issues(string); + }; void CarService::CheckIn() { - - cout << "1. Already Customer\n2. New Customer\n3. Return to Home Page\n"; - cout << "Enter your choice: "; - int choice; - cin >> choice; - switch(choice) - { - case 1: AlreadyCust(); - break; - case 2: + + cout << "1. Already Customer\n2. New Customer\n3. Return to Home Page\n"; + cout << "Enter your choice: "; + int choice; + cin >> choice; + switch (choice) + { + case 1: AlreadyCust(); + break; + case 2: NewCust(); + break; + case 3: HomePage(); + break; + } +} + + +void CarService::HomePage() { + int choice; + cout << "1.Check In\n2. Check Out\n3. Admin\n4. Employee\n5. Exit" << endl; + cout << "Enter your choice" << endl; + cin >> choice; + switch (choice) { + case 1:CheckIn(); + break; + case 2:CheckOut(); + break; + case 3:Admin(); + break; + case 4:Employee(); + break; + case 5: exit; + } + +} + +void CarService::CheckOut() { + +} + +void CarService::Admin() { + fstream AdminFile; + AdminFile.open("Admin.txt", ios::in); + string userName, password, buffer, passw; + cout << "Enter Username: "; + cin >> userName; + cout << "Enter Password: "; + HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); + DWORD mode = 0; + GetConsoleMode(hStdin, &mode); + SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT)); + cin.ignore(); + getline(cin, password); + SetConsoleMode(hStdin, mode); + hash mystdhash; + password = mystdhash(password); + if (!AdminFile.is_open()) { + AdminFile.open("Admin.txt", ios::out); + AdminFile << userName << "|" << password << "$"; + cout << userName << password; + + } + else { + + buffer.erase(); + int i = 0; + getline(AdminFile, buffer); + while (buffer[i] != '|') + userName += buffer[i++]; + i++; + while (buffer[i] != '$') + passw += buffer[i++]; + if (passw == password) + { + cout << "login Successfull"; + } + else { + cout << "login not successfull"; + Admin(); + } + } +} + + + +void CarService::Employee() { + fstream EmployeeFile; + EmployeeFile.open("Employee.txt", ios::in); + string EmployeeID, Password; + cout << "Enter the Employee ID : "; + + +} + +void CarService::AlreadyCust() { + int flag = 0, pos = 0, choice; + string VehicleNo, name, key, confirm; + string PhoneNumber; + cout << "Enter your Vehicle Number: " << endl; + cin >> key; + ifstream CustomerDetails; + CustomerDetails.open("CustomerDetails.txt", ios::in); + while (!CustomerDetails.eof()) + { + buffer.erase(); + pos = CustomerDetails.tellg(); + getline(CustomerDetails, buffer); + int ch = 1, i = 0; + name.erase(); + while (buffer[i] != '|') + name += buffer[i++]; + + PhoneNumber.erase(); + i++; + while (buffer[i] != '|') + PhoneNumber += buffer[i++]; + VehicleNo.erase(); + i++; + while (buffer[i] != '$') + VehicleNo += buffer[i++]; + + + if (VehicleNo ==key ) + { + cout << "\nFound the Vehicle Number.\n" << buffer; + flag = 1; + cout << "Confirm the vehicle details.(Y/N)" << endl; + cin >> confirm; + if (confirm == "y" || "Y") { + cout << "1. New Complain\n2. View Service History\n3. Previous Page\n"; + cout << "Enter your choice: "; + cin >> choice; + switch (choice) { + case 1: Issues(VehicleNo); + break; + case 2: ServiceHistory(); + break; + case 3: AlreadyCust(); + break; + + } + + } + else{ + AlreadyCust(); + } + + } + else { + cout << "\nVehicle NOT FOUND"; + CheckIn(); + } + + } + +} +void CarService::NewCust() { + string confirm; + ofstream CustomerFile("CustomerDetails.txt", ios::app); + string name; + string phNumber; + string vehicleNo; + cout << "Enter your name: "; + cin >> name; + cout << "Enter your Phone Number: "; + cin >> phNumber; + cout << "Enter your Vehicle Number: "; + cin >> vehicleNo; + cout << name << " " << phNumber << " " << vehicleNo << endl; + cout << "Do you want to Confirm?(Y/N)"; + cin >> confirm; + + if (confirm == "y" || "Y") { + + CustomerFile << name << "|" << phNumber << "|" << vehicleNo <<"$"<< endl; + + CustomerFile.close(); + + Issues(vehicleNo); + } + else { + NewCust(); + } +} +void CarService::ServiceHistory() { + +} +void CarService::Issues(string vehicle_numb) { + int status=0; + string issues,wax_wash,confirm; + SYSTEMTIME st; + GetSystemTime(&st); + + + ofstream CarIssues("IssuesDetails.txt",ios::app); + cout << "Enter the Issues in your Vehicle:"; + cin.ignore(); + getline(cin, issues); + cout << "Do you want to add wax and wash to your service?(Y/N)" << endl; + cin >> wax_wash; + if (wax_wash == "y" || "Y") { + issues += " wax and wash"; + } + cout << issues << endl; + cout << "Confirm complains entered?(Y/N)"; + cin >> confirm; + if (confirm == "y" || "Y") { + + + CarIssues << st.wDay << "/" << st.wMonth << "/" << st.wYear << " " << st.wHour << ":" << st.wMinute << " " << vehicle_numb << " " << issues < Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file +} \ No newline at end of file From e36185277d14fe09b14c9524518283a1afe67ce3 Mon Sep 17 00:00:00 2001 From: tejasbhimani <57887162+tejasbhimani@users.noreply.github.com> Date: Sat, 23 May 2020 01:54:14 +0530 Subject: [PATCH 2/6] Add files via upload --- CS_Management.cpp | 304 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 272 insertions(+), 32 deletions(-) diff --git a/CS_Management.cpp b/CS_Management.cpp index 6a8874c..22b125c 100644 --- a/CS_Management.cpp +++ b/CS_Management.cpp @@ -18,12 +18,17 @@ class CarService { void Employee(); void AlreadyCust(); void NewCust(); - + string IssuesSearch(string); + void IssuesDelete(string); + void Pack(); + void Unpack(); + void StatusUpdate(string, int); void NewComplain(); void ServiceHistory(); void Submit(); void Issues(string); - + + }; void CarService::CheckIn() { @@ -38,15 +43,15 @@ void CarService::CheckIn() { break; case 2: NewCust(); break; - case 3: HomePage(); - break; + case 3: HomePage(); + break; } } void CarService::HomePage() { int choice; - cout << "1.Check In\n2. Check Out\n3. Admin\n4. Employee\n5. Exit" << endl; + cout << "1. Check In\n2. Check Out\n3. Admin\n4. Employee\n5. Exit" << endl; cout << "Enter your choice" << endl; cin >> choice; switch (choice) { @@ -85,19 +90,17 @@ void CarService::Admin() { password = mystdhash(password); if (!AdminFile.is_open()) { AdminFile.open("Admin.txt", ios::out); - AdminFile << userName << "|" << password << "$"; - cout << userName << password; + AdminFile << userName << "|" << password << "|" << "1" << "$"; } else { - buffer.erase(); int i = 0; getline(AdminFile, buffer); while (buffer[i] != '|') userName += buffer[i++]; i++; - while (buffer[i] != '$') + while (buffer[i] != '|') passw += buffer[i++]; if (passw == password) { @@ -113,10 +116,129 @@ void CarService::Admin() { void CarService::Employee() { - fstream EmployeeFile; - EmployeeFile.open("Employee.txt", ios::in); - string EmployeeID, Password; - cout << "Enter the Employee ID : "; + int pos = 0; + string date, time, VehicleNo, Issues, status1, key; + fstream AdminFile; + AdminFile.open("Admin.txt", ios::in); + string userName, usern_file, password, buffer, passw_file, status; + usern_file = "null"; + cout << "Enter Username: "; + cin >> userName; + cout << "Enter Password: "; + HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); + DWORD mode = 0; + GetConsoleMode(hStdin, &mode); + SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT)); + cin.ignore(); + getline(cin, password); + SetConsoleMode(hStdin, mode); + hash mystdhash; + password = mystdhash(password); + buffer.erase(); + int i = 0; + getline(AdminFile, buffer); + + while (usern_file != userName) + { + usern_file.erase(); + while (buffer[i] != '|') + usern_file += buffer[i++]; + i++; + cout << usern_file; + passw_file.erase(); + while (buffer[i] != '|') + passw_file += buffer[i++]; + i++; + status1.erase(); + while (buffer[i] != '$') + status1 += buffer[i++]; + if (AdminFile.eof()) { + break; + } + } + if (passw_file == password) + { + int i = 0; + fstream IssuesDetails; + cout << "login Successfull\n"; + IssuesDetails.open("IssuesDetails.txt", ios::in||ios::out); + while (!IssuesDetails.eof()) + { + + buffer.erase(); + pos = IssuesDetails.tellg(); + getline(IssuesDetails, buffer); + + + i = 0; + date.erase(); + if (IssuesDetails.eof()) + break; + + while (buffer[i] != '|') + date += buffer[i++]; + time.erase(); + i++; + while (buffer[i] != '|') + time += buffer[i++]; + VehicleNo.erase(); + i++; + while (buffer[i] != '|') + VehicleNo += buffer[i++]; + Issues.erase(); + i++; + while (buffer[i] != '|') + Issues += buffer[i++]; + status.erase(); + i++; + while (buffer[i] != '$') + status += buffer[i++]; + if (status == "0") + { + cout << date << "|" << time << "|" << VehicleNo << "|" << Issues << "$"<> key; + int pos1; + ifstream IssuesDetails; + IssuesDetails.open("IssuesDetails.txt", ios::in); + while (!IssuesDetails.eof()) + { + buffer.erase(); + pos1 = IssuesDetails.tellg(); + getline(IssuesDetails, buffer); + int j = 0; + date.erase(); + if (IssuesDetails.eof()) + break; + + while (buffer[j] != '|') + date += buffer[j++]; + time.erase(); + j++; + while (buffer[j] != '|') + time += buffer[j++]; + VehicleNo.erase(); + j++; + while (buffer[j] != '|') + VehicleNo += buffer[j++]; + Issues.erase(); + j++; + while (buffer[j] != '|') + Issues += buffer[j++]; + status.erase(); + j++; + while (buffer[j] != '$') + status += buffer[j++]; + } } @@ -134,22 +256,22 @@ void CarService::AlreadyCust() { buffer.erase(); pos = CustomerDetails.tellg(); getline(CustomerDetails, buffer); - int ch = 1, i = 0; + int i = 0; name.erase(); while (buffer[i] != '|') name += buffer[i++]; - - PhoneNumber.erase(); - i++; - while (buffer[i] != '|') + + PhoneNumber.erase(); + i++; + while (buffer[i] != '|') PhoneNumber += buffer[i++]; VehicleNo.erase(); i++; while (buffer[i] != '$') VehicleNo += buffer[i++]; - - if (VehicleNo ==key ) + + if (VehicleNo == key) { cout << "\nFound the Vehicle Number.\n" << buffer; flag = 1; @@ -170,7 +292,7 @@ void CarService::AlreadyCust() { } } - else{ + else { AlreadyCust(); } @@ -181,7 +303,7 @@ void CarService::AlreadyCust() { } } - + } void CarService::NewCust() { string confirm; @@ -198,10 +320,10 @@ void CarService::NewCust() { cout << name << " " << phNumber << " " << vehicleNo << endl; cout << "Do you want to Confirm?(Y/N)"; cin >> confirm; - + if (confirm == "y" || "Y") { - CustomerFile << name << "|" << phNumber << "|" << vehicleNo <<"$"<< endl; + CustomerFile << name << "|" << phNumber << "|" << vehicleNo << "$" << endl; CustomerFile.close(); @@ -215,13 +337,13 @@ void CarService::ServiceHistory() { } void CarService::Issues(string vehicle_numb) { - int status=0; - string issues,wax_wash,confirm; + string status = "0"; + string issues, wax_wash, confirm; SYSTEMTIME st; GetSystemTime(&st); - ofstream CarIssues("IssuesDetails.txt",ios::app); + ofstream CarIssues("IssuesDetails.txt", ios::app); cout << "Enter the Issues in your Vehicle:"; cin.ignore(); getline(cin, issues); @@ -235,10 +357,9 @@ void CarService::Issues(string vehicle_numb) { cin >> confirm; if (confirm == "y" || "Y") { + CarIssues << st.wDay << "/" << st.wMonth << "/" << st.wYear << "|" << st.wHour << ":" << st.wMinute << "|" << vehicle_numb << "|" << issues << "|" << status << "$" << endl; - CarIssues << st.wDay << "/" << st.wMonth << "/" << st.wYear << " " << st.wHour << ":" << st.wMinute << " " << vehicle_numb << " " << issues < Date: Sat, 23 May 2020 17:16:32 +0530 Subject: [PATCH 3/6] Add files via upload --- CS_Management.cpp | 117 +++++++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 53 deletions(-) diff --git a/CS_Management.cpp b/CS_Management.cpp index 22b125c..17fbb58 100644 --- a/CS_Management.cpp +++ b/CS_Management.cpp @@ -10,7 +10,6 @@ using namespace std; class CarService { public: - string buffer; void HomePage(); void CheckIn(); void CheckOut(); @@ -20,9 +19,7 @@ class CarService { void NewCust(); string IssuesSearch(string); void IssuesDelete(string); - void Pack(); - void Unpack(); - void StatusUpdate(string, int); + void StatusUpdate(string,string); void NewComplain(); void ServiceHistory(); void Submit(); @@ -172,7 +169,7 @@ void CarService::Employee() { i = 0; date.erase(); - if (IssuesDetails.eof()) + if (!getline(IssuesDetails, buffer)) break; while (buffer[i] != '|') @@ -196,6 +193,7 @@ void CarService::Employee() { if (status == "0") { cout << date << "|" << time << "|" << VehicleNo << "|" << Issues << "$"<> key; - int pos1; - ifstream IssuesDetails; - IssuesDetails.open("IssuesDetails.txt", ios::in); - while (!IssuesDetails.eof()) - { - buffer.erase(); - pos1 = IssuesDetails.tellg(); - getline(IssuesDetails, buffer); - int j = 0; - date.erase(); - if (IssuesDetails.eof()) - break; - - while (buffer[j] != '|') - date += buffer[j++]; - time.erase(); - j++; - while (buffer[j] != '|') - time += buffer[j++]; - VehicleNo.erase(); - j++; - while (buffer[j] != '|') - VehicleNo += buffer[j++]; - Issues.erase(); - j++; - while (buffer[j] != '|') - Issues += buffer[j++]; - status.erase(); - j++; - while (buffer[j] != '$') - status += buffer[j++]; - } - - + StatusUpdate(key, "1"); + } void CarService::AlreadyCust() { int flag = 0, pos = 0, choice; - string VehicleNo, name, key, confirm; + string VehicleNo, name, key, confirm,buffer; string PhoneNumber; cout << "Enter your Vehicle Number: " << endl; cin >> key; @@ -255,7 +221,8 @@ void CarService::AlreadyCust() { { buffer.erase(); pos = CustomerDetails.tellg(); - getline(CustomerDetails, buffer); + if (!getline(CustomerDetails, buffer)) + break; int i = 0; name.erase(); while (buffer[i] != '|') @@ -305,6 +272,47 @@ void CarService::AlreadyCust() { } } + +void CarService::StatusUpdate(string key, string status1) { + + string buffr,key1; + int flag = 0, pos = 0, i=0, choice; + string date, time, VehicleNo, Issues, status; + buffr.erase(); + buffr = IssuesSearch(key); + cout << buffr; + cout << "search buffer"; + if (buffr == "NULL") + { + cout << "Vehicle NOT FOUND \nEnter Vehicle Number again"; + cin >> key1; + StatusUpdate(key1, status1); + } + IssuesDelete(key); + while (buffr[i] != '|') + date += buffr[i++]; + time.erase(); + i++; + while (buffr[i] != '|') + time += buffr[i++]; + VehicleNo.erase(); + i++; + while (buffr[i] != '|') + VehicleNo += buffr[i++]; + Issues.erase(); + i++; + while (buffr[i] != '|') + Issues += buffr[i++]; + status.erase(); + i++; + while (buffr[i] != '$') + status += buffr[i++]; + status = status1; + fstream IssuesDetails("IssuesDetails.txt",ios::app); + IssuesDetails << date<< "|" << time<< "|" << VehicleNo << "|" << Issues <<"|"<< status << "$" << endl; + IssuesDetails.close(); +} + void CarService::NewCust() { string confirm; ofstream CustomerFile("CustomerDetails.txt", ios::app); @@ -369,7 +377,7 @@ void CarService::Issues(string vehicle_numb) { string CarService::IssuesSearch(string key) { int flag = 0, pos = 0, i, choice; - string date, time, VehicleNo, Issues, status; + string date, time, VehicleNo, Issues, status,buffer; string PhoneNumber; ifstream IssuesDetails; IssuesDetails.open("IssuesDetails.txt", ios::in); @@ -377,10 +385,9 @@ string CarService::IssuesSearch(string key) { { buffer.erase(); pos = IssuesDetails.tellg(); - getline(IssuesDetails, buffer); i = 0; date.erase(); - if (IssuesDetails.eof()) + if (!getline(IssuesDetails, buffer)) break; while (buffer[i] != '|') @@ -404,6 +411,7 @@ string CarService::IssuesSearch(string key) { if (VehicleNo == key) IssuesDetails.close(); + return buffer; } IssuesDetails.close(); @@ -413,7 +421,7 @@ string CarService::IssuesSearch(string key) { void CarService::IssuesDelete(string key) { string buff; int pos = 0,i=0; - string date, time, VehicleNo, Issues, status; + string date, time, VehicleNo, Issues, status, buffer; fstream temp("temp.txt", ios::out); buff = IssuesSearch(key); if (buff == "NULL") { @@ -426,13 +434,17 @@ void CarService::IssuesDelete(string key) { IssuesDetails.open("IssuesDetails.txt", ios::in); while (!IssuesDetails.eof()) { + cout << "INwhile"; buffer.erase(); + if (!getline(IssuesDetails, buffer)) + break; + + pos = IssuesDetails.tellg(); - getline(IssuesDetails, buffer); + i = 0; date.erase(); - while (buffer[i] != '|') date += buffer[i++]; time.erase(); @@ -456,7 +468,6 @@ void CarService::IssuesDelete(string key) { continue; else { temp << buffer << endl; - cout << buffer; } } IssuesDetails.close(); @@ -471,12 +482,10 @@ void CarService::IssuesDelete(string key) { getline(temp, buffer); cout << buffer; IssuesDetails1 << buffer << endl; - } IssuesDetails1.close(); temp.close(); - remove("temp.txt"); } else { cout << "file ainr open"; @@ -486,11 +495,13 @@ void CarService::IssuesDelete(string key) { } + int main() { CarService cs; //cs.HomePage(); - cs.IssuesDelete("ka30303"); - -} \ No newline at end of file + //cs.IssuesDelete("ka19"); + //cout< Date: Sun, 24 May 2020 00:16:42 +0530 Subject: [PATCH 4/6] Add files via upload --- CS_Management.cpp | 239 ++++++++++++++++++++++++++-------------------- 1 file changed, 133 insertions(+), 106 deletions(-) diff --git a/CS_Management.cpp b/CS_Management.cpp index 17fbb58..ae6659a 100644 --- a/CS_Management.cpp +++ b/CS_Management.cpp @@ -19,15 +19,15 @@ class CarService { void NewCust(); string IssuesSearch(string); void IssuesDelete(string); - void StatusUpdate(string,string); + void StatusUpdate(string, string); void NewComplain(); void ServiceHistory(); void Submit(); void Issues(string); +}; -}; void CarService::CheckIn() { cout << "1. Already Customer\n2. New Customer\n3. Return to Home Page\n"; @@ -62,6 +62,7 @@ void CarService::HomePage() { break; case 5: exit; } + } @@ -113,7 +114,7 @@ void CarService::Admin() { void CarService::Employee() { - int pos = 0; + int pos = 0, flag = 0; string date, time, VehicleNo, Issues, status1, key; fstream AdminFile; AdminFile.open("Admin.txt", ios::in); @@ -158,44 +159,65 @@ void CarService::Employee() { int i = 0; fstream IssuesDetails; cout << "login Successfull\n"; - IssuesDetails.open("IssuesDetails.txt", ios::in||ios::out); - while (!IssuesDetails.eof()) + IssuesDetails.open("IssuesDetails.txt", ios::in); + if (IssuesDetails.peek() == std::ifstream::traits_type::eof()) { - - buffer.erase(); - pos = IssuesDetails.tellg(); - getline(IssuesDetails, buffer); - - - i = 0; - date.erase(); - if (!getline(IssuesDetails, buffer)) - break; + cout << "There are no Vehicle for Service\n"; + HomePage(); - while (buffer[i] != '|') - date += buffer[i++]; - time.erase(); - i++; - while (buffer[i] != '|') - time += buffer[i++]; - VehicleNo.erase(); - i++; - while (buffer[i] != '|') - VehicleNo += buffer[i++]; - Issues.erase(); - i++; - while (buffer[i] != '|') - Issues += buffer[i++]; - status.erase(); - i++; - while (buffer[i] != '$') - status += buffer[i++]; - if (status == "0") + } + else + { + while (!IssuesDetails.eof()) { - cout << date << "|" << time << "|" << VehicleNo << "|" << Issues << "$"<> key; + StatusUpdate(key, "1"); + } + } else @@ -203,15 +225,13 @@ void CarService::Employee() { cout << "login not successfull "; Employee(); } - cout << "Enter the vehicle number to select the vehicle:"; - cin >> key; - StatusUpdate(key, "1"); - + + } void CarService::AlreadyCust() { int flag = 0, pos = 0, choice; - string VehicleNo, name, key, confirm,buffer; + string VehicleNo, name, key, confirm, buffer; string PhoneNumber; cout << "Enter your Vehicle Number: " << endl; cin >> key; @@ -228,6 +248,7 @@ void CarService::AlreadyCust() { while (buffer[i] != '|') name += buffer[i++]; + PhoneNumber.erase(); i++; while (buffer[i] != '|') @@ -273,45 +294,7 @@ void CarService::AlreadyCust() { } -void CarService::StatusUpdate(string key, string status1) { - string buffr,key1; - int flag = 0, pos = 0, i=0, choice; - string date, time, VehicleNo, Issues, status; - buffr.erase(); - buffr = IssuesSearch(key); - cout << buffr; - cout << "search buffer"; - if (buffr == "NULL") - { - cout << "Vehicle NOT FOUND \nEnter Vehicle Number again"; - cin >> key1; - StatusUpdate(key1, status1); - } - IssuesDelete(key); - while (buffr[i] != '|') - date += buffr[i++]; - time.erase(); - i++; - while (buffr[i] != '|') - time += buffr[i++]; - VehicleNo.erase(); - i++; - while (buffr[i] != '|') - VehicleNo += buffr[i++]; - Issues.erase(); - i++; - while (buffr[i] != '|') - Issues += buffr[i++]; - status.erase(); - i++; - while (buffr[i] != '$') - status += buffr[i++]; - status = status1; - fstream IssuesDetails("IssuesDetails.txt",ios::app); - IssuesDetails << date<< "|" << time<< "|" << VehicleNo << "|" << Issues <<"|"<< status << "$" << endl; - IssuesDetails.close(); -} void CarService::NewCust() { string confirm; @@ -367,7 +350,7 @@ void CarService::Issues(string vehicle_numb) { CarIssues << st.wDay << "/" << st.wMonth << "/" << st.wYear << "|" << st.wHour << ":" << st.wMinute << "|" << vehicle_numb << "|" << issues << "|" << status << "$" << endl; - CarIssues.close(); + CarIssues.close(); } else { Issues(vehicle_numb); @@ -377,7 +360,7 @@ void CarService::Issues(string vehicle_numb) { string CarService::IssuesSearch(string key) { int flag = 0, pos = 0, i, choice; - string date, time, VehicleNo, Issues, status,buffer; + string date, time, VehicleNo, Issues, status, buffer; string PhoneNumber; ifstream IssuesDetails; IssuesDetails.open("IssuesDetails.txt", ios::in); @@ -409,58 +392,104 @@ string CarService::IssuesSearch(string key) { while (buffer[i] != '$') status += buffer[i++]; - if (VehicleNo == key) + if (VehicleNo == key && status == "0") + { IssuesDetails.close(); - return buffer; + } } IssuesDetails.close(); return "NULL"; } +void CarService::StatusUpdate(string key, string status1) { + + string buffr, key1; + int flag = 0, pos = 0, i = 0, choice; + string date, time, VehicleNo, Issues, status; + buffr.erase(); + buffr = IssuesSearch(key); + + + if (buffr == "NULL") + { + cout << "Vehicle NOT FOUND \nEnter Vehicle Number again :"; + cin >> key1; + StatusUpdate(key1, status1); + } + else + { + IssuesDelete(key); + while (buffr[i] != '|') + date += buffr[i++]; + time.erase(); + i++; + while (buffr[i] != '|') + time += buffr[i++]; + VehicleNo.erase(); + i++; + while (buffr[i] != '|') + VehicleNo += buffr[i++]; + Issues.erase(); + i++; + while (buffr[i] != '|') + Issues += buffr[i++]; + status.erase(); + i++; + while (buffr[i] != '$') + status += buffr[i++]; + status.erase(); + status = status1; + + fstream IssuesDetails("IssuesDetails.txt", ios::app); + IssuesDetails.seekp(0, ios::beg); + IssuesDetails << date << "|" << time << "|" << VehicleNo << "|" << Issues << "|" << status << "$" << endl; + IssuesDetails.close(); + } +} + void CarService::IssuesDelete(string key) { - string buff; - int pos = 0,i=0; + + int pos = 0, i = 0; string date, time, VehicleNo, Issues, status, buffer; fstream temp("temp.txt", ios::out); - buff = IssuesSearch(key); - if (buff == "NULL") { + buffer = IssuesSearch(key); + if (buffer == "NULL") { cout << "Vehicle NOT FOUND"; } - else { - fstream IssuesDetails; IssuesDetails.open("IssuesDetails.txt", ios::in); while (!IssuesDetails.eof()) { - cout << "INwhile"; + buffer.erase(); if (!getline(IssuesDetails, buffer)) break; - - pos = IssuesDetails.tellg(); - i = 0; date.erase(); - + while (buffer[i] != '|') date += buffer[i++]; time.erase(); i++; + while (buffer[i] != '|') time += buffer[i++]; VehicleNo.erase(); i++; + while (buffer[i] != '|') VehicleNo += buffer[i++]; Issues.erase(); i++; + while (buffer[i] != '|') Issues += buffer[i++]; status.erase(); i++; + while (buffer[i] != '$') status += buffer[i++]; @@ -472,36 +501,34 @@ void CarService::IssuesDelete(string key) { } IssuesDetails.close(); temp.close(); - temp.open("temp.txt"); + temp.open("temp.txt", ios::in); remove("IssuesDetails.txt"); fstream IssuesDetails1; - IssuesDetails1.open("IssuesDetails.txt",ios::app); + IssuesDetails1.open("IssuesDetails.txt", ios::out); + string text; if (IssuesDetails1.is_open()) { while (!temp.eof()) { buffer.erase(); - getline(temp, buffer); - cout << buffer; - IssuesDetails1 << buffer << endl; + if (!getline(temp, buffer)) + break; + text += buffer + "\n"; } + IssuesDetails1 << text; IssuesDetails1.close(); - temp.close(); } else { - cout << "file ainr open"; + cout << "file aint open"; } - } - } int main() { - CarService cs; - //cs.HomePage(); + cs.HomePage(); //cs.IssuesDelete("ka19"); //cout< Date: Sun, 24 May 2020 15:58:26 +0530 Subject: [PATCH 5/6] Add files via upload --- CS_Management.cpp | 358 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 284 insertions(+), 74 deletions(-) diff --git a/CS_Management.cpp b/CS_Management.cpp index ae6659a..5ce1726 100644 --- a/CS_Management.cpp +++ b/CS_Management.cpp @@ -5,7 +5,6 @@ #include #include - using namespace std; class CarService { @@ -17,6 +16,8 @@ class CarService { void Employee(); void AlreadyCust(); void NewCust(); + void Employee_Delete(string); + string Employee_search(string); string IssuesSearch(string); void IssuesDelete(string); void StatusUpdate(string, string); @@ -24,6 +25,7 @@ class CarService { void ServiceHistory(); void Submit(); void Issues(string); + void Employee_Status_Update(string, string); }; @@ -62,7 +64,6 @@ void CarService::HomePage() { break; case 5: exit; } - } @@ -73,7 +74,10 @@ void CarService::CheckOut() { void CarService::Admin() { fstream AdminFile; AdminFile.open("Admin.txt", ios::in); + SYSTEMTIME st; + GetSystemTime(&st); string userName, password, buffer, passw; + int choice; cout << "Enter Username: "; cin >> userName; cout << "Enter Password: "; @@ -88,8 +92,8 @@ void CarService::Admin() { password = mystdhash(password); if (!AdminFile.is_open()) { AdminFile.open("Admin.txt", ios::out); - AdminFile << userName << "|" << password << "|" << "1" << "$"; - + AdminFile << userName << "|" << password << "$" << endl; + AdminFile.close(); } else { buffer.erase(); @@ -98,14 +102,60 @@ void CarService::Admin() { while (buffer[i] != '|') userName += buffer[i++]; i++; - while (buffer[i] != '|') + while (buffer[i] != '$') passw += buffer[i++]; if (passw == password) { - cout << "login Successfull"; + AdminFile.close(); + cout << "login Successfull" << endl; + cout << "\n"; + cout << "1. Add Employee" << endl; + cout << "2. Remove Employee" << endl; + + cin >> choice; + fstream Employee("Employee.txt", ios::app); + string employee_name, salary, employee_position, joining_date, employee_id, status2, pass, re_enterPass; + if (choice == 1) { + cout << "Enter Employee Name" << endl; + cin >> employee_name; + cout << "Enter Employee User id" << endl; + cin >> employee_id; + int flag = 0; + while (true) { + pass.erase(); + re_enterPass.erase(); + cout << "Enter Employee Password" << endl; + GetConsoleMode(hStdin, &mode); + SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT)); + cin.ignore(); + getline(cin, pass); + cout << "\n"; + SetConsoleMode(hStdin, mode); + cout << "Re-enter Password" << endl; + GetConsoleMode(hStdin, &mode); + SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT)); + getline(cin, re_enterPass); + SetConsoleMode(hStdin, mode); + cout << "\n"; + if (pass == re_enterPass) { + hash mystdhash; + pass = mystdhash(pass); + break; + } + } + cout << "Enter Employee Position" << endl; + cin >> employee_position; + cout << "Enter Employee Salary" << endl; + cin >> salary; + status2 = "0"; + Employee << st.wDay << "/" << st.wMonth << "/" << st.wYear << "|" << employee_name << "|" << employee_id << "|" << employee_position << "|" << salary << "|" << status2 <<"$"<< endl; + Employee.close(); + AdminFile.open("Admin.txt", ios::app); + AdminFile << employee_id << "|" << pass << "$" << endl; + } } else { - cout << "login not successfull"; + cout << "login not successfull" << endl; Admin(); } } @@ -114,7 +164,7 @@ void CarService::Admin() { void CarService::Employee() { - int pos = 0, flag = 0; + int pos = 0; string date, time, VehicleNo, Issues, status1, key; fstream AdminFile; AdminFile.open("Admin.txt", ios::in); @@ -129,104 +179,264 @@ void CarService::Employee() { SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT)); cin.ignore(); getline(cin, password); + cout << password; SetConsoleMode(hStdin, mode); hash mystdhash; password = mystdhash(password); buffer.erase(); int i = 0; - getline(AdminFile, buffer); - while (usern_file != userName) { usern_file.erase(); + buffer.erase(); + if (!getline(AdminFile, buffer)) + break; + i = 0; while (buffer[i] != '|') usern_file += buffer[i++]; i++; - cout << usern_file; + passw_file.erase(); - while (buffer[i] != '|') - passw_file += buffer[i++]; - i++; - status1.erase(); while (buffer[i] != '$') - status1 += buffer[i++]; + passw_file += buffer[i++]; if (AdminFile.eof()) { break; } } + if (passw_file == password) { int i = 0; fstream IssuesDetails; - cout << "login Successfull\n"; + cout << "\n"; + cout << "Login Successfull!!!....\n"; IssuesDetails.open("IssuesDetails.txt", ios::in); - if (IssuesDetails.peek() == std::ifstream::traits_type::eof()) + while (!IssuesDetails.eof()) { - cout << "There are no Vehicle for Service\n"; - HomePage(); + buffer.erase(); + pos = IssuesDetails.tellg(); + i = 0; + date.erase(); + if (!getline(IssuesDetails, buffer)) + break; + while (buffer[i] != '|') + date += buffer[i++]; + time.erase(); + i++; + while (buffer[i] != '|') + time += buffer[i++]; + VehicleNo.erase(); + i++; + while (buffer[i] != '|') + VehicleNo += buffer[i++]; + Issues.erase(); + i++; + while (buffer[i] != '|') + Issues += buffer[i++]; + status.erase(); + i++; + while (buffer[i] != '$') + status += buffer[i++]; + if (status == "0") + { + cout << date << "|" << time << "|" << VehicleNo << "|" << Issues << "$" << endl; + } + } + + } + else + { + cout << "login not successfull "; + Employee(); + } + cout << "Enter the vehicle number to select the vehicle:"; + cin >> key; + StatusUpdate(key, "1"); + Employee_Status_Update(userName, "1"); +} + +string CarService::Employee_search(string key) +{ + int flag = 0, pos = 0, i, choice; + string date, employee_name, employee_id, position, salary, status, buffer; + string PhoneNumber; + ifstream Employee; + Employee.open("Employee.txt", ios::in); + while (!Employee.eof()) + { + buffer.erase(); + if (!getline(Employee, buffer)) + break; + pos = Employee.tellg(); + i = 0; + date.erase(); + + while (buffer[i] != '|') + date += buffer[i++]; + employee_name.erase(); + i++; + while (buffer[i] != '|') + employee_name += buffer[i++]; + employee_id.erase(); + i++; + + while (buffer[i] != '|') + employee_id += buffer[i++]; + position.erase(); + i++; + + while (buffer[i] != '|') + position += buffer[i++]; + salary.erase(); + i++; + + while (buffer[i] != '|') + salary += buffer[i++]; + status.erase(); + i++; + while (buffer[i] != '$') + status += buffer[i++]; + + if (employee_id == key) + { + Employee.close(); + return buffer; } - else + } + Employee.close(); + return "NULL"; +} + +void CarService::Employee_Delete(string key) +{ + int pos = 0, i = 0; + string date, employee_name, employee_id, position, salary, status, buffer; + fstream temp("temp.txt", ios::out); + buffer = Employee_search(key); + if (buffer == "NULL") { + cout << "Vehicle NOT FOUND"; + } + else { + fstream Employee; + Employee.open("Employee.txt", ios::in); + while (!Employee.eof()) { - while (!IssuesDetails.eof()) - { - - buffer.erase(); - pos = IssuesDetails.tellg(); - i = 0; - date.erase(); - if (!getline(IssuesDetails, buffer)) - break; - while (buffer[i] != '|') - date += buffer[i++]; - time.erase(); - i++; - while (buffer[i] != '|') - time += buffer[i++]; - VehicleNo.erase(); - i++; - while (buffer[i] != '|') - VehicleNo += buffer[i++]; - Issues.erase(); - i++; - while (buffer[i] != '|') - Issues += buffer[i++]; - status.erase(); - i++; - while (buffer[i] != '$') - status += buffer[i++]; - if (status == "0") - { - cout << date << "|" << time << "|" << VehicleNo << "|" << Issues << "$" << endl; - flag = 1; - } + buffer.erase(); + if (!getline(Employee, buffer)) + break; + pos = Employee.tellg(); + i = 0; + date.erase(); + while (buffer[i] != '|') + date += buffer[i++]; + employee_name.erase(); + i++; + + while (buffer[i] != '|') + employee_name += buffer[i++]; + employee_id.erase(); + i++; + + while (buffer[i] != '|') + employee_id += buffer[i++]; + position.erase(); + i++; + + while (buffer[i] != '|') + position += buffer[i++]; + salary.erase(); + i++; + + while (buffer[i] != '|') + salary += buffer[i++]; + status.erase(); + i++; + while (buffer[i] != '$') + status += buffer[i++]; + + if (employee_id == key) + continue; + else { + temp << buffer << endl; } - - - - } - if (flag == 0) - { - cout<<"All the Vehicles are under Service"; + Employee.close(); + temp.close(); + temp.open("temp.txt", ios::in); + remove("Employee.txt"); + fstream IssuesDetails1; + IssuesDetails1.open("Employee.txt", ios::out); + string text; + if (IssuesDetails1.is_open()) { + while (!temp.eof()) { + buffer.erase(); + if (!getline(temp, buffer)) + break; + text += buffer + "\n"; + } + IssuesDetails1 << text; + IssuesDetails1.close(); + temp.close(); } - else - { - cout << "Enter the vehicle number to select the vehicle:"; - cin >> key; - StatusUpdate(key, "1"); + else { + cout << "file aint open"; } - + } +} +void CarService::Employee_Status_Update(string key, string status1) +{ + string buffr, key1; + int flag = 0, pos = 0, i = 0, choice; + string date, employee_name, employee_id, position, salary, status, buffer; + buffer.erase(); + buffer = Employee_search(key); + if (buffr == "NULL") + { + cout << "Employee NOT FOUND \nEnter Employee ID again :"; + cin >> key1; + Employee_Status_Update(key1, status1); } else { - cout << "login not successfull "; - Employee(); - } - + Employee_Delete(key); + date.erase(); + + while (buffer[i] != '|') + date += buffer[i++]; + employee_name.erase(); + i++; + + while (buffer[i] != '|') + employee_name += buffer[i++]; + employee_id.erase(); + i++; + + while (buffer[i] != '|') + employee_id += buffer[i++]; + position.erase(); + i++; + + while (buffer[i] != '|') + position += buffer[i++]; + salary.erase(); + i++; + while (buffer[i] != '|') + salary += buffer[i++]; + status.erase(); + i++; + while (buffer[i] != '$') + status += buffer[i++]; + status = status1; + + fstream Employee("Employee.txt", ios::app); + Employee.seekp(0, ios::beg); + Employee << date << "|" << employee_name << "|" << employee_id << "|" << position << "|" << salary << "|" << status << "$" << endl; + Employee.close(); + } } void CarService::AlreadyCust() { @@ -392,7 +602,7 @@ string CarService::IssuesSearch(string key) { while (buffer[i] != '$') status += buffer[i++]; - if (VehicleNo == key && status == "0") + if (VehicleNo == key) { IssuesDetails.close(); return buffer; @@ -409,8 +619,6 @@ void CarService::StatusUpdate(string key, string status1) { string date, time, VehicleNo, Issues, status; buffr.erase(); buffr = IssuesSearch(key); - - if (buffr == "NULL") { cout << "Vehicle NOT FOUND \nEnter Vehicle Number again :"; @@ -448,6 +656,8 @@ void CarService::StatusUpdate(string key, string status1) { } } + + void CarService::IssuesDelete(string key) { int pos = 0, i = 0; @@ -462,7 +672,6 @@ void CarService::IssuesDelete(string key) { IssuesDetails.open("IssuesDetails.txt", ios::in); while (!IssuesDetails.eof()) { - buffer.erase(); if (!getline(IssuesDetails, buffer)) break; @@ -531,4 +740,5 @@ int main() //cs.IssuesDelete("ka19"); //cout< Date: Mon, 25 May 2020 16:18:05 +0530 Subject: [PATCH 6/6] Add files via upload --- CS_Management.cpp | 97 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 12 deletions(-) diff --git a/CS_Management.cpp b/CS_Management.cpp index 5ce1726..f115870 100644 --- a/CS_Management.cpp +++ b/CS_Management.cpp @@ -22,10 +22,11 @@ class CarService { void IssuesDelete(string); void StatusUpdate(string, string); void NewComplain(); - void ServiceHistory(); + void ServiceHistory(string,string); void Submit(); void Issues(string); - void Employee_Status_Update(string, string); + void Employee_Status_Update(string,string); + string CustomerSearch(string); }; @@ -242,17 +243,19 @@ void CarService::Employee() { cout << date << "|" << time << "|" << VehicleNo << "|" << Issues << "$" << endl; } } - + cout << "Enter the vehicle number to select the vehicle:"; + cin >> key; + StatusUpdate(key, "1"); + cout << "status up"; + Employee_Status_Update(userName, "1"); + ServiceHistory(key,userName); } else { cout << "login not successfull "; Employee(); } - cout << "Enter the vehicle number to select the vehicle:"; - cin >> key; - StatusUpdate(key, "1"); - Employee_Status_Update(userName, "1"); + } string CarService::Employee_search(string key) @@ -468,7 +471,6 @@ void CarService::AlreadyCust() { while (buffer[i] != '$') VehicleNo += buffer[i++]; - if (VehicleNo == key) { cout << "\nFound the Vehicle Number.\n" << buffer; @@ -482,8 +484,8 @@ void CarService::AlreadyCust() { switch (choice) { case 1: Issues(VehicleNo); break; - case 2: ServiceHistory(); - break; + //case 2: View_ServiceHistory(); + //break; case 3: AlreadyCust(); break; @@ -534,16 +536,87 @@ void CarService::NewCust() { NewCust(); } } -void CarService::ServiceHistory() { +void CarService::ServiceHistory(string key,string employee_ID) +{ + string buffer, date, time, customerName, VehicleNo, Issues, status, amount, payment; + int pos = 0, i = 0; + fstream ServiceHistory("ServiceHistory.txt",ios::app); + fstream CustomerDetails; + CustomerDetails.open("CustomerDetails.txt", ios::in); + fstream IssuesDetails("IssueDetails.txt", ios::in); + buffer = IssuesSearch(key); + customerName = CustomerSearch(key); + if (buffer == "NULL" ||customerName=="NULL") { + cout << "not found" << endl; + } + else { + i = 0; + date.erase(); + while (buffer[i] != '|') + date += buffer[i++]; + time.erase(); + i++; + while (buffer[i] != '|') + time += buffer[i++]; + VehicleNo.erase(); + i++; + while (buffer[i] != '|') + VehicleNo += buffer[i++]; + Issues.erase(); + i++; + while (buffer[i] != '|') + Issues += buffer[i++]; + status.erase(); + i++; + while (buffer[i] != '$') + status += buffer[i++]; + payment = "0"; + ServiceHistory << date << "|" << time << "|" << VehicleNo << "|" << customerName << "|" << Issues <<"|"<