/ Published in: C++
mizi
Expand |
Embed | Plain Text
/******************************************************************** * Filename : Car.pc * Author : Muhamad Tarmizi Bin Adnan (B031110178) * Date created: Nov-2011 * Description : Page for car registration and information ********************************************************************/ /* Include files */ #include <iostream> #include <string> #include <limits> #include <iomanip> #define SQLCA_STORAGE_CLASS extern #include <sqlca.h> using namespace std; /* Getting All function */ #include "SMS_connection.h" /* Oracle host variable declare section */ EXEC SQL BEGIN DECLARE SECTION; char CAR_NO[11]; char IC_NUMBER[12]; char CAR_TYPE[20]; char YEAR_RELEASE[10]; int car; EXEC SQL END DECLARE SECTION; /* Normal Variable declaration */ int iExisted = 0; int type; //int ichooice; //int iTotalOwner = 0; //int iDChoice = 0; /******************************************************************** * Function : fnCarMenu * Description : Function to register a car * Input Parameters : None ********************************************************************/ void fnRegisterCar() { iExisted = 0; /* Calling connection to oracle function */ fnConnectDB(); do{ system("cls"); /* Calling printing header function */ fnPrintHeader(); cout<<"\t Register Vehicle"; cout<<"\n\t ===================="; cout<<"\n\n\n"; cout<<"\tPlease fill the Vehicle information.\n"; if(iExisted > 0) cout<<"\n\tVehicle number already existed,\ Please try again.\n"; /* Getting owner information to register */ cout<<"\n\tCAR_NO (M121): "; cin.getline(CAR_NO,11); /* Find owner based on ic number */ EXEC SQL SELECT COUNT(CAR_NO) INTO:car FROM OWNER WHERE CAR_NO = :CAR_NO; if(car > 0) iExisted++; else iExisted = 0; }while(iExisted > 0); cout<<"\n\tIC_NUMBER(870926115143): "; cin.getline(IC_NUMBER,12); cout<<"\n\t1 = CAR"; cout<<"\n\t2 = MPV"; cout<<"\n\t3 = TRUCK"; cout<<"\n\t4 = VAN"; cout<<"\n\t5 = BUS"; cout<<"\n\tVEHICLE_TYPE: "; /* { if(type == 1) strcpy_s(CAR_TYPE,"CAR"); else if(type == 2) strcpy_s(CAR_TYPE,"MPV"); else if(type == 3) strcpy_s(CAR_TYPE,"TRUCK"); else if(type == 4) strcpy_s(CAR_TYPE,"VAN"); else if(type == 5) strcpy_s(CAR_TYPE,"BUS"); }*/ cin>>type; cin.getline(CAR_TYPE ,20); { if(type == 1) strcpy_s(CAR_TYPE,"CAR"); else if(type == 2) strcpy_s(CAR_TYPE,"MPV"); else if(type == 3) strcpy_s(CAR_TYPE,"TRUCK"); else if(type == 4) strcpy_s(CAR_TYPE,"VAN"); else if(type == 5) strcpy_s(CAR_TYPE,"BUS"); } cout<<"\n\tYEAR_RELEASE : "; cin.getline(YEAR_RELEASE,10); /* Save owner information in database */ EXEC SQL INSERT INTO CAR VALUES(:CAR_NO,:IC_NUMBER,:CAR_TYPE,:YEAR_RELEASE); cout<<"\n\tVehicle record has been registered\n"; cout<<"\n\tPress any key to return to menu.."; //cin.ignore(numeric_limits<streamsize>::max(),'\n'); cin.get(); system("cls"); /* Closing database connection */ fnCloseDBConnection(); /* Go back to owner Menu */ fnCarMenu(); } /******************************************************************** * End of SMS_Car.pc ********************************************************************/
You need to login to post a comment.
