├── .gitignore ├── screenshots ├── add_record.png ├── admin_menu.png ├── delete_record.png └── view_record.png ├── sdm.cpp ├── load.h ├── admin.h ├── README.md ├── load.cpp └── admin.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | data.cpp 2 | data.h 3 | menu.cpp 4 | tmp.dat 5 | .sdm_dat.dat 6 | sdm_dat.csv 7 | a.out 8 | sdm 9 | -------------------------------------------------------------------------------- /screenshots/add_record.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bishnukt/Student_Data_Manager/HEAD/screenshots/add_record.png -------------------------------------------------------------------------------- /screenshots/admin_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bishnukt/Student_Data_Manager/HEAD/screenshots/admin_menu.png -------------------------------------------------------------------------------- /screenshots/delete_record.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bishnukt/Student_Data_Manager/HEAD/screenshots/delete_record.png -------------------------------------------------------------------------------- /screenshots/view_record.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bishnukt/Student_Data_Manager/HEAD/screenshots/view_record.png -------------------------------------------------------------------------------- /sdm.cpp: -------------------------------------------------------------------------------- 1 | #include"admin.h" 2 | #include"load.h" 3 | 4 | int main(int argc,char *argv[]) 5 | { 6 | start_load(); 7 | Admin admin; 8 | end_load(); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /load.h: -------------------------------------------------------------------------------- 1 | #ifndef LOAD_H 2 | #define LOAD_H 3 | #include "admin.h" 4 | 5 | using namespace std; 6 | 7 | void start_load(void); 8 | void end_load(void); 9 | void print_label(int n); 10 | void load_view(int); 11 | #endif -------------------------------------------------------------------------------- /admin.h: -------------------------------------------------------------------------------- 1 | #ifndef ADMIN_H 2 | #define ADMIN_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | //#include 11 | #include"load.h" 12 | #define s1 10 13 | #define s2 8 14 | #define s3 11 15 | 16 | using namespace std; 17 | 18 | struct Student{ 19 | string id,name,course,dep,gender,age,ph_no; 20 | }; 21 | 22 | class Admin{ 23 | private: 24 | map> file; 25 | char choice; 26 | int tot; 27 | int sp[7] = {22, 24, 18,24, 15, 11, 0}; 28 | ifstream in; 29 | ofstream out; 30 | vector split(string str); 31 | void menu(); 32 | void load_dat(); 33 | void write_dat(); 34 | void print(vector &line); 35 | void add_data(); 36 | void delete_data(); 37 | void update_data(); 38 | void search(); 39 | public: 40 | Admin(); 41 | //~Admin(); 42 | static void adds(int t,int n=0); 43 | void view_data(); 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Student Data Manager 2 | 3 | ## A simple console program to manage student's official data. 4 | 5 | Store records like student_id, name, course, department, phone no. etc. 6 | It writes records into a .csv file that can be opened with any spreadsheet software like google sheets,microsoft excel,libreoffice calc. 7 | 8 | >**Note** 9 | > As I have used the linux/unix specific library *unistd.h* to use functions like `sleep()` and `system("clear")`, the cpp files will only compile on linux/unix based operating systems. Soon I'll be adding detailed steps on **changes to be made to compile these files on other operating system like Windows.** 10 | 11 | ### Why .csv file? 12 | As we all know, CSV(Comma Separated Values) files are easier to share as it can be opened with any spreadsheet software like Google Sheets, Microsoft Excel, Libreoffice calc etc. that makes it highly portable as you can share the datas for operation to anyone if needed. It doesn't need the same Student Manager Program to view the datas in easy table format, anyone can view it with other softwares mentioned. 13 | 14 | ### Features available- 15 | 1. Add Student Records 16 | >> Duplicate id won't be added. 17 | 1. View All Records 18 | >> Total Records Table View. 19 | 1. Update Records 20 | >> You can update student records and there's an option to cancel all changes while updating. 21 | 1. Delete Records 22 | >> Delete Any Student's Records by Id. 23 | 1. Search 24 | >> View any Student's Records by Id. 25 | 26 | ### Few screenshots of the program running in terminal- 27 | ![Admin's Menu](screenshots/admin_menu.png "Admin's Menu") 28 | ![Add Record](screenshots/add_record.png "Add Record") 29 | ![View Records](screenshots/view_record.png "View Records") 30 | ![Delete Record](screenshots/delete_record.png "Delete Record") 31 | 32 | ### To get and run this program, run these commands in your terminal: 33 | 34 | 1. git clone git@github.com:Bishnukt/Student_Data_Manager.git 35 | 1. cd Student_Data_Manager 36 | 1. g++ -o sdm sdm.cpp admin.cpp load.cpp 37 | 1. ./sdm 38 | -------------------------------------------------------------------------------- /load.cpp: -------------------------------------------------------------------------------- 1 | #include "load.h" 2 | 3 | void start_load() 4 | { 5 | // system("clear"); 6 | Admin::adds(5,5); 7 | cout << "|| WELCOME TO STUDENT DATA MANAGER ||" << endl; 8 | Admin::adds(5,1); 9 | cout << "Press Enter to proceed..." << endl; 10 | getchar(); 11 | system("clear"); 12 | } 13 | 14 | void end_load() 15 | { 16 | system("clear"); 17 | Admin::adds(5,5); 18 | cout << "|| CLOSING STUDENT DATA MANAGER ||" << endl; 19 | Admin::adds(5,1); 20 | cout<< "ADIOS, AMIGO "; 21 | fflush(stdout); 22 | sleep(1); 23 | cout<<":"; 24 | fflush(stdout); 25 | sleep(1); 26 | cout<<"-"; 27 | fflush(stdout); 28 | sleep(1); 29 | cout<<")"< temp; 14 | cin.ignore(); 15 | adds(5,5); 16 | cout << "ENTER STUDENT'S DETAILS-" << endl; 17 | adds(5); 18 | cout << "------------------------\n"<< endl; 19 | adds(5,1); 20 | cout << "STUDENT ID.: "; 21 | getline(cin, student.id); 22 | if (file.find(student.id) != file.end()) 23 | { 24 | adds(5, 1); 25 | cout << "ID " << student.id << " ALREADY EXISTS." << endl; 26 | return; 27 | } 28 | temp.push_back(student.id); 29 | adds(5,1); 30 | 31 | cout << "NAME: "; 32 | getline(cin, student.name); 33 | temp.push_back(student.name); 34 | adds(5,1); 35 | 36 | cout << "COURSE: "; 37 | getline(cin, student.course); 38 | temp.push_back(student.course); 39 | adds(5,1); 40 | 41 | cout << "DEPARTMENT: "; 42 | getline(cin, student.dep); 43 | temp.push_back(student.dep); 44 | adds(5,1); 45 | 46 | do{ 47 | cout << "GENDER[M/F/Other]: "; 48 | cin >> student.gender; 49 | adds(5,1); 50 | }while(student.gender!="M" && student.gender!="F" && student.gender!="Other" && student.gender!="m" && student.gender!="f" && student.gender!="other"); 51 | temp.push_back(student.gender); 52 | 53 | cout << "AGE: "; 54 | cin >> student.age; 55 | cin.ignore(); 56 | temp.push_back(student.age); 57 | adds(5,1); 58 | 59 | cout << "PHONE No.: "; 60 | cin >> student.ph_no; 61 | temp.push_back(student.ph_no); 62 | 63 | out << student.id << "," << student.name << "," << student.course << "," << student.dep << "," << student.gender << "," << student.age << "," << student.ph_no << endl; //Appending records into data file. 64 | out.close(); 65 | file.insert({temp[0], temp}); 66 | } 67 | else 68 | { 69 | cout << "Can't open file" << endl; 70 | exit(1); 71 | } 72 | } 73 | 74 | /* 75 | * Admin::delete_data() function deletes any student's records by searching student_id, 76 | * informs user if records of specified student id is not found. If student id found in records, it removes the records of the student from 77 | * the records, calls the function write_dat() to write modified datas into file, implementation can be found further below. 78 | */ 79 | void Admin::delete_data() 80 | { 81 | string str; 82 | adds(5, 5); 83 | cin.ignore(); 84 | cout << "ENTER THE STUDENT ID TO DELETE : "; 85 | getline(cin, str); 86 | if (file.find(str) == file.end()) 87 | { 88 | adds(5, 1); 89 | cout << "NO RECORD FOR STUDENT ID \"" << str << "\" EXISTS.\n" 90 | << endl; 91 | return; 92 | } 93 | if (file.erase(str)) 94 | { 95 | write_dat(); 96 | adds(5, 1); 97 | cout << "STUDENT ID \"" << str << "\" RECORDS DELETED SUCCESSFULLY.\n" 98 | << endl; 99 | return; 100 | } 101 | adds(5, 1); 102 | cout << "FACING SOME UNKNOWN PROBLEM, PLEASE TRY AGAIN.\n" 103 | << endl; 104 | } 105 | 106 | /* 107 | * Admin::update_data() function modifies and updates records by searching Id, informs if no such id found. 108 | * If found, provides multiple options to update records. User can perform multiple modifications of records, 109 | * as well as option to revert back to original state is also given so that wrong updation can be avoided. 110 | */ 111 | void Admin::update_data() 112 | { 113 | string id,val; 114 | vector temp; 115 | char ch; 116 | adds(5,5); 117 | cin.ignore(); 118 | cout<<"ENTER THE STUDENT ID TO UPDATE: "; 119 | getline(cin,id); 120 | if(file.find(id)==file.end()) 121 | { 122 | adds(5,1); 123 | cout<<"NO RECORD FOR STUDENT ID \""<"; 158 | adds(1);cout<<"1. NAME"; 159 | adds(1);cout<<"2. COURSE"; 160 | adds(1);cout<<"3. DEPARTMENT"; 161 | adds(1);cout<<"4. GENDER"; 162 | adds(1);cout<<"5. AGE"; 163 | adds(1);cout<<"6. PHONE No."; 164 | adds(5,2); 165 | cout<<"RETURN =>"; 166 | adds(1);cout << "7. UPDATE & RETURN";adds(1);cout << "8. ABORT ALL CHANGES & RETURN"<>choice; 170 | cin.ignore(); 171 | adds(5,2); 172 | if(choice>='1' && choice<='6') 173 | cout<<"ENTER NEW VALUE FOR- "<>val; 205 | cin.ignore(); 206 | temp[5]=val; 207 | break; 208 | 209 | case '6': 210 | cout<<"PHONE No.: "; 211 | cin>>val; 212 | cin.ignore(); 213 | temp[6]=val; 214 | break; 215 | 216 | case '7': 217 | break; 218 | 219 | case '8': 220 | adds(5,1); 221 | cout<<"ALL CHANGES ABORTED. RECORDS OF \""<>ch; 233 | cin.ignore(); 234 | }while(ch=='Y' || ch=='y'); 235 | file.at(id)=temp; 236 | write_dat(); 237 | adds(5,1); 238 | cout<<"\""< line; 262 | line = split(str); 263 | file.insert({line[0], line}); 264 | // for(auto it:file[line[0]]) 265 | // cout< line = it.second; 283 | string last = line.back(); 284 | for (auto str : line) 285 | { 286 | if(str == last) 287 | tmp << str << endl; 288 | else 289 | tmp << str << ","; 290 | } 291 | } 292 | tmp.close(); 293 | remove("sdm_dat.csv"); 294 | rename(".tmp_dat.csv", "sdm_dat.csv"); 295 | } 296 | 297 | /* 298 | * Admin::view_data function shows total data in a table format 299 | */ 300 | void Admin::view_data() 301 | { 302 | if(file.empty()) 303 | { 304 | adds(5, 5); 305 | cout << "NO RECORDS TO SHOW, DATAFILE IS EMPTY.\n" 306 | << endl; 307 | return; 308 | } 309 | adds(0, 5); 310 | cout << "ID"; 311 | adds(5); 312 | cout << "NAME"; 313 | adds(5); 314 | cout << "COURSE"; 315 | adds(3); 316 | cout << "DEPARTMENT"; 317 | adds(3); 318 | cout << "GENDER"; 319 | adds(2); 320 | cout << " AGE"; 321 | adds(2); 322 | cout << " PH_No." << endl; 323 | for (int i = 0; i < tot + 12; i++) cout << "-"; 324 | cout << "\n"<< endl; 325 | for (auto it : file) 326 | print(it.second); 327 | for (int i = 0; i < tot + 12; i++) cout << "-"; 328 | cout << "\n"<< endl; 329 | } 330 | 331 | /* 332 | * Admin::search() function searches a particular student's data by their ID. 333 | */ 334 | void Admin::search() 335 | { 336 | string id; 337 | adds(5,5); 338 | cin.ignore(); 339 | cout<<"ENTER THE STUDENT ID TO SEARCH: "; 340 | getline(cin,id); 341 | if(file.find(id)==file.end()) 342 | { 343 | adds(5,1); 344 | cout<<"STUDENT ID \""< &line) 360 | { 361 | for (int i = 0; i < line.size(); i++) 362 | { 363 | cout << line[i]; 364 | int n = abs(int(sp[i] - line[i].size())); 365 | for (int j = 0; j < n; j++) 366 | cout << " "; 367 | } 368 | cout << "\n" 369 | << endl; 370 | } 371 | 372 | /* 373 | * Admin::split() function receives string as parameter and returns a vector of strings by splitting the received string. Though there are functions for 374 | * splitting available in cpp, this function is implemented for learning and interest. 375 | */ 376 | vector Admin::split(string str) 377 | { 378 | string s; 379 | vector temp; 380 | for (int i = 0; i < str.length(); i++) 381 | { 382 | if(str[i] != ',') 383 | s.push_back(str[i]); 384 | else 385 | { 386 | temp.push_back(s); 387 | s.clear(); 388 | } 389 | } 390 | temp.push_back(s); 391 | return temp; 392 | } 393 | 394 | /* 395 | * Admin::menu() function shows the main menu 396 | */ 397 | void Admin::menu() 398 | { 399 | char ch; 400 | do 401 | { 402 | system("clear"); 403 | print_label(0); 404 | adds(s2, 2); 405 | cout << "1. ADD STUDENT RECORD\n\n"; 406 | adds(s2); 407 | cout << "2. VIEW RECORDS\n\n"; 408 | adds(s2); 409 | cout << "3. DELETE STUDENT RECORD\n\n"; 410 | adds(s2); 411 | cout << "4. UPDATE RECORD\n\n"; 412 | adds(s2); 413 | cout<<"5. SEARCH\n\n"; 414 | adds(s2); 415 | cout << "6. EXIT\n\n"<< endl; 416 | adds(s2); 417 | cout << "ENTER YOUR CHOICE: "; 418 | cin >> choice; 419 | 420 | switch (choice) 421 | { 422 | case '1': 423 | do 424 | { 425 | system("clear"); 426 | print_label(1); 427 | add_data(); 428 | adds(5, 2); 429 | cout << "ADD MORE RECORDS?(Y/N): "; 430 | cin >> ch; 431 | } while (ch != 'n' && ch != 'N'); 432 | // load_dat(); 433 | break; 434 | case '2': 435 | system("clear"); 436 | print_label(2); 437 | view_data(); 438 | break; 439 | case '3': 440 | system("clear"); 441 | print_label(3); 442 | delete_data(); 443 | break; 444 | case '4': 445 | system("clear"); 446 | print_label(4); 447 | adds(5, 1); 448 | update_data(); 449 | break; 450 | case '5': 451 | do{ 452 | system("clear"); 453 | print_label(5); 454 | adds(5,1); 455 | search(); 456 | adds(5,2); 457 | cout<<"SEARCH AGAIN?(Y/N): "; 458 | cin>>ch; 459 | }while(ch != 'n' && ch != 'N'); 460 | break; 461 | case '6': 462 | break; 463 | default: 464 | adds(s2, 1); 465 | cout << "INVALID CHOICE. " << endl; 466 | } 467 | if(choice == '6') 468 | break; 469 | // cin.ignore(); 470 | adds(5, 1); 471 | cout << "RETURN TO MAIN MENU?(Y/N) : "; 472 | cin >> ch; 473 | } while (ch != 'n' && ch != 'N'); 474 | } 475 | /* 476 | * Admin::Admin(), the constructor of the Admin class calls the function Admin::load_dat() to load all records in a map data structure. 477 | */ 478 | Admin::Admin() 479 | { 480 | load_dat(); 481 | tot = 0; 482 | for (auto it : sp) tot += it; 483 | menu(); 484 | } 485 | 486 | // Admin::~Admin() 487 | //{ 488 | // adds(5,1); 489 | // cout<<"ADMIN LOGGING OUT. "<