❶ 急求c++實現MySQL資料庫圖書管理系統報告,只有源代碼也可以,萬分感謝
#include<iostream>
#include<fstream>
#include<windows.h>
#include<stdlib.h>
using namespace std;
void mainmenu();
void Manage_Book();
void input_Book();
void input_Reader();
void New_Book();
void Seek_Book();
void Borrow_Manage();
void Borrow_Book();
void Return_Book();
void Output_Message();
void Exit_System();
int u,v=3,k=0;
struct Book
{
char name[20];
int booknumber;
int num_present;
int num_all;
}book[1000];
struct Reader
{
char name[20];
int readernumber;
int card;
}reader[3];
void mainmenu()
{
int Num_Choice1,flag=1;
system("color E");
for(;k<=0;k++)
{
input_Book();
input_Reader();
}
while(flag==1)
{
system("cls");
cout<<"\t\t\t◆◆◆◆◆主菜單◆◆◆◆◆"<<endl
<<"\t\t\t☆ 1.圖書管理 ☆"<<endl
<<"\t\t\t☆ 2.借閱管理 ☆"<<endl
<<"\t\t\t☆ 3.輸出信息 ☆"<<endl
<<"\t\t\t☆ 4.退出系統 ☆"<<endl
<<"\t\t\t◆◆◆◆◆◆◆◆◆◆◆◆◆"<<endl;
cout<<"請輸入所需要的服務編碼"<<endl;
cin>>Num_Choice1;
switch(Num_Choice1)
{
case 1:
Manage_Book();
break;
case 2:
Borrow_Manage();
break;
case 3:
Output_Message();
break;
case 4:
Exit_System();
flag=0;
break;
default:
flag=0;
cout<<"輸入有誤!!"<<endl;
}
}
}
void Manage_Book()
{
int flag1=1,Num_Choice2;
system("cls"); while(flag1==1)
{
cout<<"\t\t\t◆◆◆◆◆◆◆◆◆◆◆◆◆"<<endl
<<"\t\t\t☆ 1.新書入庫 ☆"<<endl
<<"\t\t\t☆ 2.圖書查詢 ☆"<<endl
<<"\t\t\t☆ 3.返回主菜單 ☆"<<endl
<<"\t\t\t◆◆◆◆◆◆◆◆◆◆◆◆◆"<<endl;
cin>>Num_Choice2;
switch(Num_Choice2)
{
case 1:
flag1=2;
New_Book();
break;
case 2:
flag1=2;
Seek_Book();
break;
case 3:
mainmenu();
default:
flag1=1;
cout<<"輸入有誤!"<<endl;
system("pause");
system("cls");
}
}}
void input_Book()
{
cout<<"請依照提示輸入現有的三本圖書的信息:"<<endl;
for(int i=0;i<3;i++)
{
cout<<"書名:"<<endl;
cin>>book[i].name;
cout<<"書號:"<<endl;
cin>>book[i].booknumber;
cout<<"庫存量:"<<endl;
cin>>book[i].num_all;
cout<<"現存量:"<<endl;
cin>>book[i].num_present;
}
}
void New_Book()
{
system("cls");
int j;
char newbook_name[20];
cout<<"請輸入新書書名:"<<endl;
cin>>newbook_name;
for(j=0;j<1000;j++)
{
if(strcmp(newbook_name,book[j].name)==0)
{
book[j].num_all++;
book[j].num_present++;
break;
}
}
if(j==1000)
{
cout<<"請為此新書編號:"<<endl;
v++;
cin>>book[v].booknumber;
strcpy(book[v].name,newbook_name);
book[v].num_all=1;
book[v].num_present=1;
}
else cout<<"已有此書,庫存量加一"<<endl;
system("pause");
}
void Seek_Book()
{
system("cls");
int k,booknumber;
cout<<"請輸入所要查詢的書號:"<<endl;
cin>>booknumber;
for(k=0;k<1000;k++)
{
if(book[k].booknumber==booknumber)
{
cout<<"書號:"<<booknumber<<endl;
cout<<"書名:"<<book[k].name<<endl;
cout<<"庫存量:"<<book[k].num_all<<endl;
cout<<"現存量:"<<book[k].num_present<<endl;
system("pause");
break;
}
}
if(k==1000)
{
cout<<"未找到此書!!"<<endl;
system("pause");
}
}
void Borrow_Manage()
{
int flag=1;
system("cls");
int Num_Choice3;
while(flag==1)
{
cout<<"\t\t\t◆◆◆◆◆◆◆◆◆◆◆◆◆"<<endl
<<"\t\t\t☆ 1.借書登記 ☆"<<endl
<<"\t\t\t☆ 2.還書管理 ☆"<<endl
<<"\t\t\t☆ 3.返回主菜單 ☆"<<endl
<<"\t\t\t◆◆◆◆◆◆◆◆◆◆◆◆◆"<<endl;
cin>>Num_Choice3;
switch(Num_Choice3)
{
case 1:
flag=2;
Borrow_Book();
break;
case 2:
flag=2;
Return_Book();
break;
case 3:
mainmenu();
default:
flag=1;
cout<<"輸入有誤!!"<<endl;
system("pause");
}
system("cls");
}
}
void input_Reader()
{
system("cls");
cout<<"請依照提示輸入現有的三位讀者的信息:"<<endl;
for(int m=0;m<3;m++)
{
cout<<"姓名:"<<endl;
cin>>reader[m].name;
cout<<"編號:"<<endl;
cin>>reader[m].readernumber;
reader[m].card=0;
}
}
void Borrow_Book()
{
system("cls");
char reader_name[20];
int n,book_number;
cout<<"請輸入讀者姓名:"<<endl;
cin>>reader_name;
for(n=0;n<3;n++)
{
if(strcmp(reader_name,reader[n].name)==0)
{
if(reader[n].card!=0)
{
cout<<"已借書,不能再借,請按任意鍵返回"<<endl;
system("pause");
mainmenu();
}
else
break;
}
}
if(n==3)
{
cout<<"無此讀者!輸入有誤!!按任意鍵返回主菜單"<<endl;
system("pause");
mainmenu();
}
cout<<"請輸入所借圖書書號:"<<endl;
cin>>book_number;
for(n=0;n<v;n++)
{
if(strcmp(reader_name,reader[n].name)==0)
reader[n].card=book_number;
}
for(n=0;n<v;n++)
{
if(book[n].booknumber==book_number)
{
if(book[n].num_present==0)
{
cout<<"該書已經被借完,請按任意鍵返回"<<endl;
system("pause");
for(n=0;n<v;n++)
{
if(strcmp(reader_name,reader[n].name)==0)
reader[n].card=0;
}
mainmenu();
}
else
{
book[n].num_present--;
cout<<"借書成功,請按任意鍵返回"<<endl;
system("pause");
break;
}
}
}
if(n==v)
{
for(n=0;n<v;n++)
{
if(strcmp(reader_name,reader[n].name)==0)
reader[n].card=0;
}
cout<<"所輸入的書號不存在,請按任意鍵返回主菜單"<<endl;
system("pause");
mainmenu();
}
}void Return_Book()
{
system("cls");
int j;
char reader_name[20];
int book_number;
cout<<"請輸入讀者姓名:"<<endl;
cin>>reader_name;
for(j=0;j<3;j++)
{
if(strcmp(reader_name,reader[j].name)==0)
break;
}
if(j==3)
{
cout<<"無此讀者!輸入有誤!!按任意鍵返回主菜單"<<endl;
system("pause");
mainmenu();
}
cout<<"請輸入所還圖書書號:"<<endl;
cin>>book_number;
for(j=0;j<3;j++)
{
if(strcmp(reader_name,reader[j].name)==0)
{
if(book_number==reader[j].card)
{
reader[j].card=0;
for(j=0;j<v;j++)
{
if(book[j].booknumber==book_number)
{
book[j].num_present++;
cout<<"還書成功,請按任意鍵返回"<<endl;
system("pause");
break;
}
}
}
else
{
cout<<"該讀者未藉此書"<<endl;
system("pause");
}
}
if(j==v)
cout<<"所輸入的書號不存在:"<<endl;
}
}
void Output_Message()
{
system("cls");
int q;
cout<<"以下是圖書信息"<<endl<<endl;
for(q=0;q<v;q++)
{
cout<<"書號:"<<book[q].booknumber<<'\t';
cout<<"書名:"<<book[q].name<<'\t';
cout<<"庫存量:"<<book[q].num_all<<'\t';
cout<<"現存量:"<<book[q].num_present<<endl;
}
cout<<"以下是讀者信息"<<endl<<endl;
for(q=0;q<3;q++)
{
cout<<"姓名:"<<reader[q].name<<'\t'
<<"編號:"<<reader[q].readernumber<<'\t'
<<"所借書號:"<<reader[q].card<<endl;
}
system("pause");
}
void Exit_System()
{
system("cls");
cout<<"歡迎下次使用,謝謝"<<endl;
system("pause");
}
void main()
{
mainmenu();
}
❷ 在vc6.0中實現使用ADO連接SQL server資料庫的源代碼
#import "msado15.dll" no_namespace replace("EOF","adoEOF")
_ConnectionPtr m_Connection;
_RecordsetPtr m_Recordset;
兩個智能指針隨便用