Advertisement
Garusek

funkcje

May 27th, 2015
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.13 KB | None | 0 0
  1. #ifndef FUNC_H_INCLUDED
  2. #define FUNC_H_INCLUDED
  3. // added classes.h for all property for a project ..
  4. #include "classes.h"
  5. string temp ;
  6. void go_back();
  7. void show_header()
  8. {
  9.     cout <<"\t\t\t" << "UNIVERSITY MANAGEMNET SYSTEM"<<endl;
  10.     cout <<"\t\t" << "American Internation University Bangladesh" <<endl;
  11.     cout <<"\t\t\t" << "Programming Language 2 Project" <<endl<<endl<<endl<<endl;
  12. }
  13. void clear()
  14. {
  15.     system("CLS");
  16.     show_header();
  17. }
  18. void show_main_options()
  19. {
  20.  
  21.     cout << "1. Departments" <<endl ;
  22.     cout << "2. Teachers" <<endl;
  23.     cout << "3. Students" <<endl<<endl;
  24.     cout << "4. Change Login PIN" << endl << endl ;
  25. }
  26. void show_dept_options()
  27. {
  28.  
  29.     cout << "1. Add New Department" <<endl ;
  30.     cout << "2. View All Dept" <<endl;
  31.     cout << "3. Search Department" << endl;
  32.     go_back();
  33.  
  34.  
  35.  
  36. }
  37. void show_teacher_options()
  38. {
  39.  
  40.     cout << "1. Add New Teacher" <<endl ;
  41.     cout << "2. View All Teacher list" <<endl;
  42.     cout << "3. Search Teacher by ID" << endl;
  43.     go_back();
  44.  
  45.  
  46. }
  47. void show_student_options()
  48. {
  49.  
  50.     cout << "1. Add New Student" <<endl ;
  51.     cout << "2. View All Student list" <<endl;
  52.     cout << "3. Search Student by ID" << endl;
  53.     go_back();
  54.  
  55. }
  56.  
  57. int login(string pin)
  58. {
  59.     string pass ;
  60.     fstream log("./db/users.txt") ;
  61.     log >> pass ;
  62.     if (pin == pass)
  63.     {
  64.         return 4 ;
  65.     }
  66. }
  67.  
  68. void change_pin()
  69. {
  70.     fstream log("./db/users.txt");
  71.     cout << "Please Enter new PIN : ";
  72.     cin >> temp ;
  73.     log << temp ;
  74.     cout << "PIN has been changed ! " << endl << endl ;
  75.  
  76. }
  77. void go_back()
  78. {
  79.     cout << endl << "5. Back" << endl;
  80. }
  81.  
  82. void searcher (int choice , string query)
  83. {
  84.     switch(choice)
  85.     {
  86.         case 1:
  87.             //
  88.             if (choice == 1 )
  89.             {
  90.                 fstream finder("./db/dept.txt") , temp_ob("./db/dept.txt");
  91.                 string temp ;
  92.                 int count = 0;
  93.                 while (getline(temp_ob,temp))
  94.                 {
  95.                     count++;
  96.                 }
  97.                // cout << count ;
  98.                 string get_all[count];
  99.                 int i = 0 ;
  100.                 for(i = 0 ; i < count ; i++)
  101.                 {
  102.                     getline(finder,get_all[i]);
  103.                 }
  104.  
  105.                 for (i=0 ; i < count ; i++)
  106.                 {
  107.                 string::size_type pos = get_all[i].find(query);
  108.                 if(pos != string::npos)
  109.                 {
  110.                     cout << endl << endl ;
  111.                     cout << "DeptID" << "\t" << "DeptName"<<endl;
  112.                     cout <<"----------------" <<endl;
  113.                     cout << get_all[i] ;
  114.                     cout << endl << endl ;
  115.  
  116.                 }
  117.  
  118.                 }
  119.             }
  120.             break ;
  121.         case 2 :
  122.             //
  123.             if (choice == 2 )
  124.             {
  125.                 fstream finder("./db/teacher.txt") , temp_ob("./db/teacher.txt");
  126.                 string temp ;
  127.                 int count = 0;
  128.                 while (getline(temp_ob,temp))
  129.                 {
  130.                     count++;
  131.                 }
  132.                // cout << count ;
  133.                 string get_all[count];
  134.                 int i = 0 ;
  135.                 for(i = 0 ; i < count ; i++)
  136.                 {
  137.                     getline(finder,get_all[i]);
  138.                 }
  139.  
  140.                 for (i=0 ; i < count ; i++)
  141.                 {
  142.                 string::size_type pos = get_all[i].find(query);
  143.                 if(pos != string::npos)
  144.                 {
  145.                     cout << endl << endl ;
  146.                     cout << "DptID " << "DptNam  " << "TeachID  "  << "TeachName  " << "Courses" <<endl;
  147.                     cout <<"----------------------------------------------" <<endl;
  148.                     cout << get_all[i] ;
  149.                     cout << endl << endl ;
  150.                 }
  151.  
  152.                 }
  153.             }
  154.             break;
  155.         case 3 :
  156.             if (choice == 3 )
  157.             {
  158.                 fstream finder("./db/student.txt") , temp_ob("./db/student.txt");
  159.                 string temp ;
  160.                 int count = 0;
  161.                 while (getline(temp_ob,temp))
  162.                 {
  163.                     count++;
  164.                 }
  165.                // cout << count ;
  166.                 string get_all[count];
  167.                 int i = 0 ;
  168.                 for(i = 0 ; i < count ; i++)
  169.                 {
  170.                     getline(finder,get_all[i]);
  171.                 }
  172.  
  173.                 for (i=0 ; i < count ; i++)
  174.                 {
  175.                 string::size_type pos = get_all[i].find(query);
  176.                 if(pos != string::npos)
  177.                 {
  178.                     cout << endl << endl ;
  179.                     cout << "DptID  " << "DptNam " << "TeachID "  << "TeachName " << "Courses  " <<"StudID  " << "StudName" <<endl;
  180.                     cout <<"------------------------------------------------------" <<endl;
  181.                     cout << get_all[i] ;
  182.                     cout << endl << endl ;
  183.                 }
  184.  
  185.                 }
  186.             }
  187.             break ;
  188.         default:
  189.             cout << "Ooops ! 404 !" ;
  190.  
  191.  
  192.     }
  193. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement