Posted By

Trance on 12/04/11


Tagged

mizi


Versions (?)

mizi


 / Published in: C++
 

mizi

  1. /********************************************************************
  2. * Filename : Car.pc
  3. * Author : Muhamad Tarmizi Bin Adnan (B031110178)
  4. * Date created: Nov-2011
  5. * Description : Page for car registration and information
  6. ********************************************************************/
  7.  
  8. /* Include files */
  9. #include <iostream>
  10. #include <string>
  11. #include <limits>
  12. #include <iomanip>
  13.  
  14. #define SQLCA_STORAGE_CLASS extern
  15. #include <sqlca.h>
  16.  
  17. using namespace std;
  18.  
  19. /* Getting All function */
  20. #include "SMS_connection.h"
  21.  
  22. /* Oracle host variable declare section */
  23. EXEC SQL BEGIN DECLARE SECTION;
  24.  
  25. char CAR_NO[11];
  26. char IC_NUMBER[12];
  27. char CAR_TYPE[20];
  28. char YEAR_RELEASE[10];
  29. int car;
  30.  
  31.  
  32. EXEC SQL END DECLARE SECTION;
  33.  
  34. /* Normal Variable declaration */
  35. int iExisted = 0;
  36. int type;
  37. //int ichooice;
  38. //int iTotalOwner = 0;
  39. //int iDChoice = 0;
  40.  
  41. /********************************************************************
  42. * Function : fnCarMenu
  43. * Description : Function to register a car
  44. * Input Parameters : None
  45. ********************************************************************/
  46.  
  47. void fnRegisterCar()
  48. {
  49. iExisted = 0;
  50.  
  51. /* Calling connection to oracle function */
  52. fnConnectDB();
  53.  
  54. do{
  55.  
  56. system("cls");
  57.  
  58.  
  59. /* Calling printing header function */
  60. fnPrintHeader();
  61. cout<<"\t Register Vehicle";
  62. cout<<"\n\t ====================";
  63. cout<<"\n\n\n";
  64. cout<<"\tPlease fill the Vehicle information.\n";
  65.  
  66. if(iExisted > 0)
  67. cout<<"\n\tVehicle number already existed,\
  68. Please try again.\n";
  69.  
  70. /* Getting owner information to register */
  71. cout<<"\n\tCAR_NO (M121): ";
  72. cin.getline(CAR_NO,11);
  73.  
  74. /* Find owner based on ic number */
  75. EXEC SQL SELECT COUNT(CAR_NO)
  76. INTO:car
  77. FROM OWNER WHERE CAR_NO = :CAR_NO;
  78.  
  79. if(car > 0)
  80. iExisted++;
  81.  
  82. else
  83. iExisted = 0;
  84.  
  85. }while(iExisted > 0);
  86.  
  87. cout<<"\n\tIC_NUMBER(870926115143): ";
  88. cin.getline(IC_NUMBER,12);
  89. cout<<"\n\t1 = CAR";
  90. cout<<"\n\t2 = MPV";
  91. cout<<"\n\t3 = TRUCK";
  92. cout<<"\n\t4 = VAN";
  93. cout<<"\n\t5 = BUS";
  94. cout<<"\n\tVEHICLE_TYPE: ";
  95.  
  96. /* {
  97. if(type == 1)
  98. strcpy_s(CAR_TYPE,"CAR");
  99. else if(type == 2)
  100. strcpy_s(CAR_TYPE,"MPV");
  101. else if(type == 3)
  102. strcpy_s(CAR_TYPE,"TRUCK");
  103. else if(type == 4)
  104. strcpy_s(CAR_TYPE,"VAN");
  105. else if(type == 5)
  106. strcpy_s(CAR_TYPE,"BUS");
  107. }*/
  108.  
  109. cin>>type;
  110. cin.getline(CAR_TYPE ,20);
  111. {
  112. if(type == 1)
  113. strcpy_s(CAR_TYPE,"CAR");
  114. else if(type == 2)
  115. strcpy_s(CAR_TYPE,"MPV");
  116. else if(type == 3)
  117. strcpy_s(CAR_TYPE,"TRUCK");
  118. else if(type == 4)
  119. strcpy_s(CAR_TYPE,"VAN");
  120. else if(type == 5)
  121. strcpy_s(CAR_TYPE,"BUS");
  122. }
  123.  
  124.  
  125.  
  126.  
  127. cout<<"\n\tYEAR_RELEASE : ";
  128. cin.getline(YEAR_RELEASE,10);
  129.  
  130.  
  131. /* Save owner information in database */
  132. EXEC SQL INSERT INTO CAR
  133. VALUES(:CAR_NO,:IC_NUMBER,:CAR_TYPE,:YEAR_RELEASE);
  134.  
  135. cout<<"\n\tVehicle record has been registered\n";
  136. cout<<"\n\tPress any key to return to menu..";
  137. //cin.ignore(numeric_limits<streamsize>::max(),'\n');
  138. cin.get();
  139. system("cls");
  140.  
  141. /* Closing database connection */
  142. fnCloseDBConnection();
  143.  
  144. /* Go back to owner Menu */
  145. fnCarMenu();
  146.  
  147. }
  148.  
  149.  
  150. /********************************************************************
  151. * End of SMS_Car.pc
  152. ********************************************************************/

Report this snippet  

You need to login to post a comment.