User talk:Calmdownxyz

booksystem.cpp

using namespace std; class bookSystem {	public: bool add_Book(book *b) {		bool bol; bol=insertBookinDB(b); return bol; }	bool add_Customer(customer *c) {		bool bol; bol=insertCustomerinDB(c); return bol; }
 * 1) include
 * 2) include"dbHandler.cpp"
 * 3) include"bookmodel.cpp"
 * 4) include"customermodel.cpp"

};

bookcontroller.cpp

using namespace std;
 * 1) include
 * 2) include"bookmodel.cpp"
 * 3) include"bookUI.cpp"
 * 4) include"booksystem.cpp"

class bookcontroller {	booksystem bs; public: void deletebook {		string message; bool success; bookUI ui; book *b1=ui.getBookDetails; success=bs.add_Book(b1); if(success=true) {			ui.notifySuccess(b1); }		else ui.notifyfailure; } };

bookmodel.cpp

using namespace std; class book { private: string name; string authorname,category; int quantity; float price;
 * 1) include

public: string get_name { return name; } string get_aname { return authorname; } string get_category { return category; } int get_quantity { return quantity; } float get_price { return price; } void set_name(string name) { this->name=name; } void set_aname(string aname) { authorname=aname; } void set_category(string cat) { category=cat; } void set_quantity(int q) { quantity=q; } void set_price(float p) { price=p; } book { name=""; authorname=""; category=""; price=0.0; quantity=0; } book(string name,string aname,string cat,float p, int q) { this->name=name; authorname=aname; category=cat; price=p; quantity=q; } };



bookui.cpp

using namespace std;
 * 1) include
 * 2) include"bookmodel.cpp"

class bookUI {	private: int bookid;

public: int getbookid {		bool valid; char ch; book *b; valid=validate_details; do {			if(valid==true) {				b=new book(bname,aname,cat,price,quant); }			else {				cout<<"\nThe details are incorrect please enter again"; valid=validate_details; b=new book(bname,aname,cat,price,quant); }		}while(valid==false); return b;	}

bool validate_details {		bool b=false; cout<<"\nEnter book name: "; cin>>bname; cout<<"\nEnter book authorname: "; cin>>aname; cout<<"\nEnter category: "; cin>>cat; cout<<"\nEnter price: "; cin>>price; cout<<"\nEnter quantity: "; cin>>quant; if((cat=="C++"||cat=="c++"||cat=="DB"||cat=="db"||cat=="UNIX"||cat=="unix")&&(quant>0)&&(price>0)) {			b=true; }			else {			cout<<"\nEnter valid category, Price should be greater than 0, Quantity should be atleast 1"; b=false; }		return b;		//cout<<"\n"<get_name<<"\nBook Authorname: "<get_authorname<<"\n Category: "<get_category<<"\nQuantity: "<get_quantity<<"\nPrice: "<get_price; displayMenu; }		void notifyfailure {			cout<<"	Failed to add book, Maybe you have entered duplicate data"; displayMenu; } };

int main { bookUI b; book *b1; b1=b.getBookDetails; }


 * 8

bookui1

using namespace std;
 * 1) include
 * 2) include"bookmodel.cpp"

class bookUI {	private: int bookid; public: int getbookid(int bid) { 		int id=bid;

valid=validatedetails(int id); if(valid=true) {	}

bool validate_details {		bool b=false; cout<<"\nEnter book name: "; cin>>bname; cout<<"\nEnter book authorname: "; cin>>aname; cout<<"\nEnter category: "; cin>>cat; cout<<"\nEnter price: "; cin>>price; cout<<"\nEnter quantity: "; cin>>quant; if((cat=="C++"||cat=="c++"||cat=="DB"||cat=="db"||cat=="UNIX"||cat=="unix")&&(quant>0)&&(price>0)) {			b=true; }			else {			cout<<"\nEnter valid category, Price should be greater than 0, Quantity should be atleast 1"; b=false; }		return b;		//cout<<"\n"<get_name<<"\nBook Authorname: "<get_authorname<<"\n Category: "<get_category<<"\nQuantity: "<get_quantity<<"\nPrice: "<get_price; displayMenu; }		void notifyfailure {			cout<<"	Failed to add book, Maybe you have entered duplicate data"; displayMenu; } };

int main { bookUI b; book *b1; b1=b.getBookDetails; }



dbhandler.pc

using namespace std; EXEC SQL BEGIN DECLARE SECTION; char con[30]="c2710@oracle"; char pwd[30]; //book variables int bookid=0; char bname[30],aname[30],cat[20]; int quant; float price; //customer variables int id=101; char cname[30],csex[30],caddress[30],cpwd[30]; int cage,cphone; EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE SQLCA; class dbHandler { public: void connectCheck {       strcpy(pwd,"tcs"); EXEC SQL CONNECT :con IDENTIFIED BY :pwd; if(sqlca.sqlcode==0) {               cout<<"connected"; }       if(sqlca.sqlcode<0) {               cout<<"Error in connect"; } } bool insertBookinDB(book *obj) {		bool b;       bookid++; price=obj->get_price; quant=obj->get_quantity; strcpy(bname,(obj->get_name).c_str); strcpy(aname,(obj->get_aname).c_str); strcpy(cat,(obj->get_category).c_str); EXEC SQL INSERT into BOOK values(:bookid,:bname,:aname,:cat,:price,:quant); if(sqlca.sqlcode==0) {               cout<<"Data inserted"; }       if(sqlca.sqlcode<0) {               cout<<"Error in Insert"; } } bool insertCustomerinDB(customer *obj) {	bool b;	id++; strcpy(cname,(obj->get_name).c_str); cage=obj->get_age; strcpy(csex,(obj->get_sex).c_str); strcpy(caddress,(obj->get_address).c_str); cphone=obj->get_contact; strcpy(cpwd,(obj->get_pwd).c_str); EXEC SQL INSERT into CUSTOMER values(:id,:cname,:cage,:csex,:caddress,:cphone,:cpwd); if(sqlca.sqlcode==0) {		cout<<"data inserted"; }	if(sqlca.sqlcode<0) {		cout<<"error in insert"; } }
 * 1) include
 * 2) include"bookmodel.cpp"
 * 3) include"customermodel.cpp"

}; int main { book *b=new book("learning in c++","robert lafore","c++",120.00,3); customer *c=new customer("deeksha",20,"female","delhi",23456712,"manali"); dbHandler d; d.connectCheck; d.insertBookinDB(b); d.insertCustomerinDB(c); EXEC SQL COMMIT WORK RELEASE; }

DBC
connectionChk.pc

using namespace std; EXEC SQL BEGIN DECLARE SECTION; char con[30]="c2706@oracle"; char pwd[30]; EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE SQLCA; void connectionCheck { strcpy(pwd,"tcs"); EXEC SQL CONNECT:con IDENTIFIED BY:pwd; if(sqlca.sqlcode==0) { cout<<"connected"; cout<<"Chk for mak"; } if(sqlca.sqlcode<0) { cout<<"Error in connect"; } } void insertCheck { EXEC SQL INSERT into Empc values(1,'Shashi'); if(sqlca.sqlcode==0) {  cout<<"Data inserted"; } if(sqlca.sqlcode<0) { cout<<"Data not inserted"; } } int main { connectionCheck; insertCheck; EXEC SQL COMMIT WORK RELEASE; }
 * 1) include
 * 2) include

Employee.pc

using namespace std; class Employee { private: int id; char *name; public: Employee {} Employee(int id,char *name) { this->id=id; int l=strlen(name); this->name=new char[l+1]; strcpy(this->name,name); } void setID(int id) { this->id=id; } void setName(char *name) { int l=strlen(name); this->name=new char[l+1]; strcpy(this->name,name); } int getID { return id; } char* getName { return name; } }; EXEC SQL BEGIN DECLARE SECTION; char con[30]="c2706@oracle"; char pwd[30]; int id; char name[30]; EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE SQLCA; void connectionCheck { strcpy(pwd,"tcs"); EXEC SQL CONNECT:con IDENTIFIED BY:pwd; if(sqlca.sqlcode==0) {  cout<<"connected"; } if(sqlca.sqlcode<0) { cout<<"Error in connect"; } } void insertCheck(Employee obj) // to insert the data into table { id=obj.getID; strcpy(name,obj.getName); EXEC SQL INSERT into Empc values(:id,:name);//use ":" before variables if(sqlca.sqlcode==0) { cout<<"Data inserted"; } if(sqlca.sqlcode<0) { cout<<"Data not inserted"; } } void updateCheck(int ids) { id=ids; // strcpy(name,obj.getName); EXEC SQL UPDATE Empc SET name='Shashi Kumar' where id=:id; if(sqlca.sqlcode==0) { cout<<"Data updated"; } if(sqlca.sqlcode<0) { cout<<"Data not updated"; } } int main { connectionCheck; int id; char name[30]; cout<<"Enter id: "; cin>>id; cout<<"Enter Name: "; cin>>name; Employee e1(id,name); insertCheck(e1); cout<<"Enter the ID to be updated: "; cin>>id; updateCheck(id); EXEC SQL COMMIT WORK RELEASE; }
 * 1) include
 * 2) include



EmployeeEdit.pc

using namespace std; class Employee { private: int id; string name; public: Employee {} Employee(int id,string name) { this->id=id; this->name=name; /* int l=strlen(name); this->name=new char[l+1]; strcpy(this->name,name); */ } void setID(int id) { this->id=id; } void setName(string name) { this->name=name; /* int l=strlen(name); this->name=new char[l+1]; strcpy(this->name,name);*/ } int getID { return id; } string getName { return name; } }; EXEC SQL BEGIN DECLARE SECTION; char con[30]="c2706@oracle"; char pwd[30]; int id; char name[30]; EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE SQLCA; void connectionCheck { strcpy(pwd,"tcs"); EXEC SQL CONNECT:con IDENTIFIED BY:pwd; if(sqlca.sqlcode==0) {  cout<<"connected"; } if(sqlca.sqlcode<0) { cout<<"Error in connect"; } } void insertCheck(Employee obj) // to insert the data into table { id=obj.getID; strcpy(name,(obj.getName).c_str); EXEC SQL INSERT into Empc values(:id,:name);//use ":" before variables if(sqlca.sqlcode==0) { cout<<"Data inserted"; } if(sqlca.sqlcode<0) { cout<<"Data not inserted"; } } void updateCheck(int ids) { id=ids; // strcpy(name,obj.getName); EXEC SQL UPDATE Empc SET name='Shashi Kumar' where id=:id; if(sqlca.sqlcode==0) { cout<<"Data updated"; } if(sqlca.sqlcode<0) { cout<<"Data not updated"; } } int main { connectionCheck; int id; char name[30]; cout<<"Enter id: "; cin>>id; cout<<"Enter Name: "; cin>>name; Employee e1(id,name); insertCheck(e1); cout<<"Enter the ID to be updated: "; cin>>id; updateCheck(id); EXEC SQL COMMIT WORK RELEASE; }
 * 1) include
 * 2) include



EmpVector.pc

using namespace std; class Employee { private: int id; char *name; public: Employee {} Employee(int id,char *name) { this->id=id; int l=strlen(name); this->name=new char[l+1]; strcpy(this->name,name); } void setID(int id) { this->id=id; } void setName(char *name) { int l=strlen(name); this->name=new char[l+1]; strcpy(this->name,name); } int getID { return id; } char* getName { return name; } void display { cout<<"\n"< selectAll { vector employees; EXEC SQL SELECT COUNT(*) INTO :empcount FROM Empc; cout<<"\n Total no of employee are : "< vlist=selectAll; for(int i=0;iname=name; this->voterid=voterid; setAge(age); } void setAge(int age) {  try {    if(age<18) throw (new InvalidAgeException("Age has to be > 18 ")); }  catch(InvalidAgeException *ageex) {   cout<getMessage; } } }; int main { // Voter v(1,"Shashi",6); Voter v(1,"Shashi",22); }
 * 1) include



Excpt.pc

using namespace std; class InvalidAgeException { private: string message; public: InvalidAgeException(string msg) {  message=msg; } string getMessage {  return message; } }; class Voter { private: int voterid; string name; int age; public: Voter(int id,string name,int age) {  this->name=name; this->id=id; setAge(age); } void setAge(int age) {  try {    if(age<18) throw(new InvalidAgeException("Age has to be > 18 ")); }  catch(InvalidAgeException ageex) {   cout<<ageex.getMessage; } } }; int main { Voter v(1,"Shashi",22); }
 * 1) include



makeEmp

out: connectionChk.o	g++ -o out connectionChk.o -lclntsh -L /oracle/oracle/oracle/product/10.2.0/db_1/lib connectionChk.o: connectionChk.cc	cc -w -c connectionChk.cc connectionChk.cc: connectionChk.pc	proc CODE=cpp PARSE=none CPP_SUFFIX=cc connectionChk.pc



makefile

out: connectionChk.o	g++ -o out connectionChk.o -lclntsh -L /oracle/oracle/oracle/product/10.2.0/db_1/lib connectionChk.o: connectionChk.cc	cc -w -c connectionChk.cc connectionChk.cc: connectionChk.pc	proc CODE=cpp PARSE=none CPP_SUFFIX=cc connectionChk.pc



link to dnload
https://mysite.knowmax.ultimatix.net/personal/tcsknowmax_479007/Personal%20Documents/Forms/AllItems.aspx