User talk:Vivek.balloo3

using namespace std;
 * 1) ifndef _dbhandler_pc
 * 2) define _dbhandler_pc
 * 3) include
 * 4) include
 * 5) include
 * 6) include"structs.h"
 * 7) include"book.h"
 * 8) include"customer.h"
 * 9) include"mybook.h"

/*        EXEC SQL BEGIN DECLARE SECTION; char con[30]="c275@oracle"; char pwd[30]; char uid[30],pswd[30]; int cid,age,num; char nm[15],addr[15]; char s;

int icount; EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE SQLCA;

class dbhandler { private: EXEC SQL BEGIN DECLARE SECTION; char con[30]; char pwd[30]; char uid[30],pswd[30],loginStatus[15]; int cid,age,num,adminId; unsigned long numbr; char nm[15],addr[15],userType[15]; char s;         char newstr[30]; int icount;

//---nandu,,,declaration of add book variables starts here-- char szbookName[20]; char szauthorName[20]; char szcategory[20]; float fprice; int iquantity; int ioutOfStockStatus; int ireserveCount; //---nandu,,,declaration of add book variables ends here--

//gunpreet search declaration begins- char ccon[30]; char cpwd[30]; char cbkname[20]; char caname[20]; char ccat[20]; int ibkid; int ibookid; int ibookId; char cbookName[20]; char cbookAuthor[20]; char cbookCategory[20]; float fbookPrice; int ibookQuantity; int ibookStockStatus; int ibookReserveCount; sql_cursor generalcursor;

//--gunpreet search declaration ends here- //-Gunpreet Customer Menu and add my bok declarations starts int customid; int custid; char custname[20]; int custage; char custsex; char custaddress[20]; int custphone; int mbkid; int paidstat; char purchdt[20]; char adddt[20]; int orderquant; int countingcustomers; //Gunpreet Purchase Sql Variables for transaction- int transactioncount; int tranid; int tbookid; int tcustomid; int tquant; char tpaymentmode[15]; float tamount; char tcarddetails[10]; char tpurchdate[20]; int tmybookid; // //---Gunpreet Customer menu and add my book declarations ends here EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE SQLCA;

public: dbhandler {} void connectToDB { strcpy(con,"c2724@oracle"); strcpy(pwd,"tcs"); EXEC SQL CONNECT :con IDENTIFIED BY :pwd; if(sqlca.sqlcode==0) cout<<"connected"; if(sqlca.sqlcode<0) cout<<"Error in connection"; }

int validateLoginDetails(vector vectorLoginDet) { connectToDB; char admin[]="admin"; char customer[]="custo"; // strcpy(loginStatus,"invalid"); int i=vectorLoginDet.size-1; bool boolloginFlag=false; strcpy(uid,vectorLoginDet[i].getUserId); strcpy(pswd,vectorLoginDet[i].getPassword); EXEC SQL SELECT usertype into :userType FROM login WHERE userid=:uid AND password=:pswd; //cout<<"\nInside select func\n"; if(sqlca.sqlcode==0) {    for(int i=0;i<=4;i++) if(userType[i]==admin[i]) {        //cout<<"\nLogin admin ka hai be........"; EXEC SQL SELECT adminid into :cid FROM login WHERE userid=:uid AND password=:pswd; }     else {      //cout<<"\ncustomer login hai be........"; EXEC SQL SELECT customerid into :cid FROM login WHERE userid=:uid AND password=:pswd; }     //cout<<"\n"<<strcmp(userType,"admin"); //cout<<"login details fetched\n"<<"id is: "<<cid<<"\npassword is: "<<pswd<<"\n"; //cout<<"login details fetched\n"<<"usertype is: "<<userType<<".....password is: "<<pswd<<"\n"; boolloginFlag=true; }else {    //cout<<"Error in selecting data from table"; cid=0; } return(cid); }

int addCustomerDetails(customer custObj) { int custId=0; connectToDB; icount=0; EXEC SQL SELECT count(*) into :icount FROM customer; cid=icount+2; cout<<"-count:"<<cid<<custObj.getCustomerName<<" "<<custObj.getAge;

age=custObj.getAge; numbr=custObj.getContactNumber; strcpy(nm,custObj.getCustomerName.c_str); strcpy(addr,custObj.getAddress.c_str); s=custObj.getSex; EXEC SQL INSERT into customer values(:cid,:nm,:age,:s,:addr,:numbr);

// EXEC SQL INSERT into customer values(:cid,custObj.getCustomerName,custObj.getAge,custObj.getSex,custObj.getAddress,custObj.getContactNumber); if(sqlca.sqlcode==0) {   custId=cid; //cout<<"\nData inserted\nCustomer id is="< vld) { connectToDB; int signUpFlag=0; strcpy(uid,vld[vld.size-1].getUserId); strcpy(pswd,vld[vld.size-1].getPassword); cid=vld[vld.size-1].getCustomerId; EXEC SQL INSERT into login values(:uid,:pswd,:cid,null,'custo'); if(sqlca.sqlcode==0) {   cout<<"\nSignUP details inserted....."; signUpFlag=1; } if(sqlca.sqlcode<0) {   cout<<"\nError in inserting Signup Details......"; signUpFlag=0; } EXEC SQL COMMIT WORK RELEASE;

}

//22 june,update admin detail--harpreet

int updateAdminDetails(vector vectorLoginDet) { connectToDB; int i=vectorLoginDet.size-1; bool boolupdateFlag=false; strcpy(pswd,vectorLoginDet[i].getPassword); cout<<"--"<<pswd; EXEC SQL UPDATE login SET password=:pswd WHERE adminid=1; //cout<<"\nInside select func\n"; if(sqlca.sqlcode==0) {    cout<<"\nAdmin Details updated..."; EXEC SQL COMMIT WORK RELEASE; }  else {    //cout<<"Error in selecting data from table"; cid=0; } return(cid); }

//end 22 june,update admin detail--harpreet

//22 june,update customer detail--harpreet int updateCustomerDetails(customer custObj) { connectToDB; age=custObj.getAge; numbr=custObj.getContactNumber;

cid=custObj.getCustomerId; strcpy(nm,custObj.getCustomerName.c_str); strcpy(addr,custObj.getAddress.c_str); s=custObj.getSex; custObj.display; EXEC SQL UPDATE customer SET customername=:nm,age=:age,sex=:s,address=:addr,contactno=:numbr WHERE customerid=:cid;

//cout<<"\nInside select func\n"; if(sqlca.sqlcode==0) {    cout<<"\nCustomer Details updated..."; EXEC SQL COMMIT WORK RELEASE; }  else {    cout<<"Error in updating customer details......"; cid=0; } return(cid); }

//end 22 june,update customer detail--harpreet

// 23 june, get a single book detail by admin--harpreeti book getSingleBookDetailsByAdmin(int bid) { connectToDB; ibookId=bid; EXEC SQL select AUTHORNAME,CATEGORY,BOOKNAME,PRICE,QUANTITY,STATUS,RESERVECOUNT into :cbookAuthor,:cbookCategory,:cbookName,:fbookPrice,:ibookQuantity,:ibookStockStatus,:ibookReserveCount FROM book WHERE bookid=:ibookId;

book bookObj(bid,cbookName,cbookAuthor,cbookCategory,fbookPrice,ibookQuantity,ibookReserveCount,ibookStockStatus); bookObj.setBookReserveCount(ibookReserveCount);

if(sqlca.sqlcode==0) {    cout<<"\nBook Details of a single book Fetched..."; EXEC SQL COMMIT WORK RELEASE; }  else {    cout<<"Error in fetching a single book details......"; cid=0; } return(bookObj); } //end 23 june, get a single book detail by admin--harpreet

int updateAdminBookDetails(book bookObj) { connectToDB;

ibookId=bookObj.getBookId; strcpy(cbookName,bookObj.getBookName.c_str); strcpy(cbookAuthor,bookObj.getBookAuthorName.c_str); strcpy(cbookCategory,bookObj.getBookCategory.c_str); fbookPrice=bookObj.getBookPrice; ibookQuantity=bookObj.getBookQuantity; ibookStockStatus=bookObj.getBookOutOfStockStatus; ibookReserveCount=bookObj.getBookReserveCount;

updateBook1(ibookId,cbookName,cbookAuthor,cbookCategory,fbookPrice,ibookQuantity,ibookReserveCount,ibookStockStatus);

//cout<<"\nInside select func\n"; if(sqlca.sqlcode==0) {    cout<<"\nBook Details updated..."; EXEC SQL COMMIT WORK RELEASE; }  else {    cout<<"Error in updating book details......"; cid=0; } return(ibookId); }

void updateBook1(int ibookId,char cbookName[],char cbookAuthor[],char cbookCategory[],float fbookPrice,int ibookQuantity,int ibookReserveCount,int ibookStockStatus) { EXEC SQL UPDATE book SET authorname=:cbookAuthor,category=:cbookCategory,bookname=:cbookName,price=:fbookPrice,quantity=:ibookQuantity,status=:ibookStockStatus,reservecount=:ibookReserveCount WHERE bookid=:ibookId;

}

//-nandu-23 june dbhandler functions start here-

void connection {		strcpy(con,"c2724@oracle"); strcpy(pwd,"tcs"); EXEC SQL CONNECT :con identified by :pwd; if(sqlca.sqlcode == 0) {		      	cout<<"Conneted \n"; }											if(sqlca.sqlcode < 0) {		cout<<"not connected :"; }       }

int addBook1(book e)  	{ connection; int rv; ibookId=e.getBookId; strcpy(szauthorName,e.getBookAuthorName.c_str); strcpy(szbookName,e.getBookName.c_str); strcpy(szcategory,e.getBookCategory.c_str); fprice=e.getBookPrice; iquantity=e.getBookQuantity; ioutOfStockStatus=e.getBookOutOfStockStatus; ireserveCount=e.getBookReserveCount; cout<<"the value of catagory :"<<ibookId<<szauthorName<<szcategory<<szbookName<<fprice<<iquantity<<ioutOfStockStatus<<ireserveCount; EXEC SQL INSERT INTO BOOK VALUES(:ibookId, :szauthorName, :szcategory, :szbookName, :fprice, :iquantity, :ioutOfStockStatus, :ireserveCount); if(sqlca.sqlcode==0) {     		rv=1; cout<<"\n inserted into the book table\n"; }		if(sqlca.sqlcode<0) {		rv=0; cout<<"\n not inserted in the book data base \n"; }		// EXEC SQL COMMIT WORK RELEASE; return rv; }	int addBook(book e1) {		 	  int j=addBook1(e1); EXEC SQL COMMIT WORK RELEASE; return j;		  }

//23 june, get a my book detail by customer--harpreet int addMyBookDetails(mybook mbObj) { int updateFlag=1; connectToDB; customer custObj=mbObj.getCustomerObject; book bookObj=mbObj.getBookObject;

cid=custObj.getCustomerId; mbkid=mbObj.getMyBookId; ibookId=bookObj.getBookId; paidstat=mbObj.getPaidStatus; strcpy(purchdt,mbObj.getPurchaseDate.c_str); strcpy(adddt,mbObj.getAddDate.c_str); orderquant=mbObj.getQuantityOrdered;

mbkid=0; EXEC SQL SELECT count(*) into :mbkid FROM mybook; mbkid=mbkid+1;

EXEC SQL INSERT into mybook values(:mbkid,:cid,:ibookId,0,sysdate,null,:orderquant);

if(sqlca.sqlcode==0) {   cout<<"\nMy Book details inserted....."; updateFlag=1; } if(sqlca.sqlcode<0) {   cout<<"\nError in inserting My Book Details......"; updateFlag=0; } EXEC SQL COMMIT WORK RELEASE;

return(updateFlag); } // end 23 june, get a my book detail by customer--harpreet

/* vector generateSalesDoneInLastOneMonthReport { vector transList; connectToDB; system("clear"); }



//-nandu dbhandler functions ends here-

//-gunpreet search-

int checkConnection {			int istatus=0; strcpy(ccon,"c2724@oracle"); strcpy(cpwd,"tcs"); EXEC SQL CONNECT :ccon identified BY :cpwd; if(sqlca.sqlcode==0) {					cout<<"\nConnected to the database"; istatus=1; }			if(sqlca.sqlcode<0) {					cout<<"\nNot connected to the database"; istatus=0; }			return istatus; }

vector getSearchListByBookName(string szname) {			system("clear"); //	cout<<"\nFinally inside the dbhandler serbookby name function"; //strcpy(cbkname,(szname).c_str); //cout<<"\ncheckpoint---"<"<<quote1; //cout<<"\nThe concatenated string is"<<cbkname; //getchar; int boolConnectStatus=checkConnection; if(boolConnectStatus==0) {					cout<<"\nError in Connecting"; }			else {					cout<<"\nInside else"; vector booknames; //EXEC SQL select count(*) into bookcount from book ; EXEC SQL ALLOCATE :generalcursor; EXEC ORACLE OPTION(select_error=no); EXEC SQL SELECT CURSOR(Select * from book where bookname like '%'||:cbkname||'%' ) into :generalcursor from dual; //EXEC SQL DECLARE searchbookcursor CURSOR FOR select * from book where bookname like :cbkname ;

//EXEC SQL OPEN searchbookcursor; EXEC ORACLE OPTION(select_error=yes); EXEC SQL WHENEVER NOT FOUND do break; for {							//cout<<"\nInside for"; book obj; //cout<<"\n Before fetch"; //getchar; //setbuf(stdout,NULL); EXEC SQL FETCH :generalcursor INTO :ibookId, :cbookAuthor, :cbookCategory, :cbookName, :fbookPrice, :ibookQuantity, :ibookStockStatus, :ibookReserveCount; //cout<<"\nbookcategory-->"<<cbookCategory; //getchar; //cout<<"\nAfter fetch statement"	; if(sqlca.sqlcode<0) {									cout<<"\n No record left in cursor "; break; }							if(sqlca.sqlcode==0) {									//cout<<"\nFectched a cursor and startin to store in an object"; //getchar; obj.setBookId(ibookId); //cout<<"\nStored the id in the object now storing the book name in the book object"; obj.setBookName(cbookName); //cout<<"\nStored the book name in the book object"; obj.setBookAuthorName( cbookAuthor); obj.setBookCategory(cbookCategory); obj.setBookPrice(fbookPrice); obj.setBookQuantity(ibookQuantity); obj.setBookOutOfStockStatus(ibookStockStatus); //obj.setReserveCount //cout<<"\nDisplayin the fetched values"; //cout<<"\n Id>"<"<"<<booknames.size; //getchar; }								EXEC SQL CLOSE :generalcursor;// searchbookcursor; EXEC SQL COMMIT WORK RELEASE; return booknames; }		}	void displayparticularobject(book obj) {			//cout<<"\nDisplaying the created object"; system("clear"); //	cout<<"\nBook Name:"<<obj.getBookName; //	cout<<"\nBookcategory="<<obj.getBookCategory; //	cout<<"\nQuantity"<<obj.getBookQuantity; //	cout<<"\nStatus="<<obj.getBookOutOfStockStatus; }	vector getSearchListByAuthorName(string author) {			vector booknames; system("clear"); //cout<<"\nInside the dbhandler"; //getchar; /*cout<<"\nconcatinating the % and ' singn--"; string quote1="'"; string quote2="'";*/ strcpy(caname,author.c_str); //cout<<"\ncheckpoint---"<<caname; //getchar; int boolConnectStatus=checkConnection; if(boolConnectStatus==0) {					cout<<"error in connecting"; }                        else {					//cout<<"\ninside else"; //getchar; //EXEC ORACLE OPTION(select_error=no); EXEC SQL DECLARE searchbookbyauthor CURSOR FOR select * from book where authorname like '%'||:caname||'%'; EXEC SQL OPEN searchbookbyauthor; //EXEC ORACLE OPTION(select_error=yes); //cout<<"\n Before the for loop"; EXEC SQL WHENEVER NOT FOUND do break; for {						book obj; //cout<<"\nInside for"; EXEC SQL FETCH searchbookbyauthor into :ibookId, :cbookAuthor, :cbookCategory, :cbookName, :fbookPrice, :ibookQuantity, :ibookStockStatus, :ibookReserveCount; if(sqlca.sqlcode<0) {								//cout<<"\nNo data in cursor"; //	cout<<"\nPress any ke to break from the loop"; //getchar; break; } 						if(sqlca.sqlcode==0) {								//cout<<"\nFetched the values"; //cout<<"\n "<<ibookId<<"\t"<<cbookName<<endl; //cout<<"\nInside Else"; //cout<<"\nFectched a cursor and startin to store in an object"; // getchar; obj.setBookId(ibookId); // cout<<"\nStored the id in the object now storing    the book name in the book object";

obj.setBookName(cbookName); //cout<<"\nStored the book name in the book object"   ;

obj.setBookAuthorName( cbookAuthor); obj.setBookCategory(cbookCategory); obj.setBookPrice(fbookPrice); obj.setBookQuantity(ibookQuantity); obj.setBookOutOfStockStatus(ibookStockStatus); //obj.setReserveCount //cout<<"\nDisplayin the fetched values"; //cout<<"\n Id>"<"<<cbookName; booknames.push_back(obj); //displayparticularobject(obj);

}					}					EXEC SQL CLOSE searchbookbyauthor; EXEC SQL COMMIT WORK RELEASE; return booknames; }		}	vector getSearchListByCategory(string szcat) {			vector booknames; strcpy(ccat,(szcat).c_str); //cout<<"\nInside the dbhandler"; //cout<<"\nThe Entered category is"<<ccat; int boolConnectStatus=checkConnection; if(boolConnectStatus==0) {               	                       cout<<"error in connecting"; }	                   else {

EXEC ORACLE OPTION(select_error=no); EXEC SQL DECLARE categorycursor CURSOR FOR select * from book where category like '%'||:ccat||'%'; EXEC SQL OPEN categorycursor; EXEC ORACLE OPTION(select_error=yes); EXEC SQL WHENEVER NOT FOUND do break; for {								book obj; EXEC SQL FETCH categorycursor INTO :ibookId, :cbookAuthor, :cbookCategory, :cbookName, :fbookPrice, :ibookQuantity, :ibookStockStatus, :ibookReserveCount; if(sqlca.sqlcode<0) {										cout<<"\nError in fetch \n Breaking from the for loop"; //getchar; break; }								if(sqlca.sqlcode==0) {						                               //    cout<<"\nInside Else"; //   getchar; obj.setBookId(ibookId); // cout<<"\nStored the id"<<ibookId<<" in the object now storing the book name in the book object"; obj.setBookName(cbookName); // cout<<"\nStored the book name"<"<"<<cbookName; booknames.push_back(obj); //cout<<"\nBefore displayiing"; //getchar; displayparticularobject(obj); //cout<<"\nAfter displaying"; //getchar;

}							}					EXEC SQL CLOSE categorycursor; }		EXEC SQL COMMIT WORK RELEASE; return booknames; }

//gunpreet search ends here0

//--Gunpreet Customer Menu And My Book Functionality Starts here- customer getCustomerDetails(int loginid) {		//cout<<"\nFetching the customer with the customer id"; customer object; customid=loginid; int constatus=checkConnection; if(constatus!=0) {			EXEC SQL DECLARE mycur CURSOR FOR select * from customer where customerid= :customid; EXEC SQL OPEN mycur; //cout<<"\ncursor opened"; //getchar; EXEC SQL WHENEVER NOT FOUND do break; for {				//	cout<<"\nInside for loop of getcustomer details"; //	getchar; EXEC SQL FETCH mycur INTO :custid, :custname, :custage, :custsex, :custaddress, :custphone; //	cout<<"\nAfter fetch"; //	getchar; if(sqlca.sqlcode<0) {							//cout<<"\nNo data fetched--Sql error"; //	getchar; break; }					if(sqlca.sqlcode==0) {							//cout<<"\nDisplayin the fetch details"; //cout<<"\nCUstomer id"<<custid; //cout<<"\n Customer name"<<custname; object.setCustomerId(custid)	; object.setCustomerName(custname); object.setAge(custage); object.setSex(custsex); object.setAddress(custaddress); object.setContactNumber(custphone); }

}			EXEC SQL CLOSE mycur; }		EXEC SQL COMMIT WORK RELEASE; return object; }     book getBookDetails(int idargument) {		book bkobj; ibkid=idargument; //int connectstat=checkConnection; if(true) {				EXEC SQL DECLARE bkcur CURSOR FOR select * from book where bookid= :ibkid; EXEC SQL OPEN bkcur; //select * into //:ibookid, :cbookAuthor, :cbookCategory, :cbookName, :fbookPrice, :ibookQuantity, :ibookStockStatus, :ibookReserveCount from book where bookid= :ibkid; EXEC SQL WHENEVER NOT FOUND do break; for {					EXEC SQL FETCH bkcur into :ibookid, :cbookAuthor, :cbookCategory, :cbookName, :fbookPrice, :ibookQuantity, :ibookStockStatus, :ibookReserveCount; if(sqlca.sqlcode<0) {						//cout<<"\nError in select statement"; break; }				else {						//cout<<"\nDisplayin the select values"; //cout<<"\nBookid \n"<<ibookid<<"\tBook Name"<<cbookName; bkobj.setBookId(ibookid); bkobj.setBookName(cbookName); bkobj.setBookAuthorName(cbookAuthor); bkobj.setBookCategory(cbookCategory); bkobj.setBookPrice(fbookPrice); bkobj.setBookQuantity(ibookQuantity); bkobj.setBookOutOfStockStatus(ibookStockStatus); bkobj.setBookReserveCount(ibookReserveCount); }				}

EXEC SQL CLOSE bkcur; //		cout<<"\nReturning bookdetails"; //		getchar; //                        return bkobj;

}		//EXEC SQL COMMIT WORK RELEASE; return bkobj; }	vector getCustomerMyBookList(int idarg) {			mybook mbkobj; //	book bkobj; customer custobj; vector mybooklist;

customid=idarg; //cout<<"\nCustomer id->"<"<<countingcustomers; //getchar; if(constatus) {					EXEC ORACLE OPTION(select_error=no); //EXEC SQL ALLOCATE :generalcursor; //EXEC ORACLE OPTION(select_error=no);

EXEC SQL DECLARE mybookcur CURSOR FOR select * from mybook where customerid= :customid and paidstatus=0; //mybookid,customerid,bookid,paidstatus,adddate,purchasedate,quantityordered from mybook; //where customerid= :customid and paidstatus=0; //EXEC SQL SELECT CURSOR (SELECT * FROM MYBOOK) INTO :generalcursor FROM DUAL; EXEC SQL OPEN mybookcur; EXEC ORACLE OPTION(select_error=yes); EXEC SQL WHENEVER NOT FOUND do break; for {							book bkobj; //int temp=checkConnection; //cout<<"\nInside For loop of my booklist"; //getchar; EXEC SQL FETCH mybookcur INTO :mbkid, :custid, :ibookId, :paidstat, :adddt, :purchdt, :orderquant; if(sqlca.sqlcode<0) {									//cout<<"\nError in fetching the data"; //getchar; break; }							if (sqlca.sqlcode==0) {									//cout<<"\nDisplayin the fethced details"; //cout<<"\nMybookid="<"<<adddt; //		cout<<"\nquantityordered"<<orderquant; bkobj=getBookDetails(ibookId); //	custobj=getCustomerDetails(custid); mbkobj.setMyBookId(mbkid); //mbkobj.setCustomerObject(custobj); mbkobj.setBookObject(bkobj); mbkobj.setPaidStatus(paidstat); mbkobj.setAddDate(adddt); mbkobj.setQuantityOrdered(orderquant); mybooklist.push_back(mbkobj); }						}					EXEC SQL CLOSE mybookcur; // EXEC SQL CLOSE :generalcursor; }			EXEC SQL COMMIT WORK RELEASE; return mybooklist; }	void performCustomerBookPurchase(mybook mkobj,int quantity,string carddetails,string paymentmode) {			//cout<<"\nReached the dbhandler class trying to purchase the book with the mybook id--"<<mkobj.getMyBookId<<"\t quantity"<<quantity; //	getchar; //storing the values in the variables for transaction entry; tcustomid=mkobj.getCustomerObject.getCustomerId; tbookid=mkobj.getBookObject.getBookId; tquant=quantity; strcpy(tpaymentmode,paymentmode.c_str); tamount=mkobj.getBookObject.getBookPrice*quantity; strcpy(tcarddetails,carddetails.c_str); //cout<<"\nDisplayin all the details before insertion"; //	cout<<"\n transaction id customer id book id quantity paymentmode amount card details purchase date"; //cout<<"\n"<"<<tranid; //	getchar; //EXEC SQL select to_char(sysdate,'dd-Mon-yyyy') into tpurchdate from dual; //cout<<"\nDisplaying the todays fetched date"<<tpurchdate; //getchar; EXEC SQL INSERT INTO transaction(transactionid,customerid,bookid,quantity,paymentmode,amount,purchasedate,carddetails) values(:tranid,:tcustomid,:tbookid,:tquant,:tpaymentmode,:tamount,sysdate,:tcarddetails); if(sqlca.sqlcode<0) {							cout<<"\nInsertion error"; }						else {								cout<<"\nInsertion Successfuul"; }					//making the changes in the mybook table...... int checkquantityordered=mkobj.getQuantityOrdered; tmybookid=mkobj.getMyBookId; if(quantity==checkquantityordered) {                                                EXEC SQL delete from mybook where mybookid=:tmybookid; }                                        else {						EXEC SQL update mybook set quantityordered= quantityordered- :tquant where mybookid=:tmybookid; }

// EXEC SQL INSERT INTO transaction values;

EXEC SQL COMMIT WORK RELEASE; }			else {					//cout<<"\nInside the performCustomerBookPurchase Function and unable to connect to the database"; //	getchar; }		} //Gunpreet Customer Menu and my book functionality ends here-

//--Tarzan reportst starts................

void generateReport(int option) {		int connectstat=checkConnection; if(option==2) {			string dtinput; cout<<"Enter the date for which the report is to be generated-DD-Mon-YYYY"; cin>>dtinput; strcpy(tpurchdate,dtinput.c_str); if(connectstat==1) {				//EXEC SQL DECLARE mycur CURSOR FOR select * from transaction where purchasedate=to_date(tpurchdate); EXEC SQL OPEN mycur; EXEC SQL WHENEVER NOT FOUND do break; for {						EXEC SQL FETCH mycur into :tranid, :tcustomid, :tbookid, :tquant, :tpaymentmode, :tamount, :tcarddetails; if(sqlca.sqlcode<0) {								cout<<"\nError in fetch"; }							else {								cout<<"\nDisplaying.....transactionid\tcustomerid\tbookid"<<tranid<<tcustomid<<tbookid;

}					}				Exec SQL CLOSE mycur; }			else {					cout<<"\nNot Connected"; }			EXEC SQL COMMIT WORK RELEASE; }	}

//-Tarzan reports ends here.............. };
 * 1) endif