| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1044 人关注过本帖
标题:急啊!
只看楼主 加入收藏
李贤昌
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-12-15
收藏
 问题点数:0 回复次数:3 
急啊!
我们做软件件实习的一个代码为什么老是有一个错误啊!!大家看一下!
// 11.cpp : Defines the entry point for the console application.
//
#include <iostream.h>
#include <unistd.h>
#include <sys/param.h>
#include <sybfront.h>
#include <sybdb.h>
#include <syberror.h>
#include <stdio.h>

#define UID "sa"
#define PWD "123456"
#define DBSERVER "172.16.162.105:1433"
#define DBNAME "DepartmentalStore"

LOGINREC *login;
DBPROCESS *dbconn;

class Connection
{
public:
    void connectDB();
    void disconnectDB();
    void execStatement(char* statement);

};

class Base
{
        private:

        protected:
                void execSQL(char* mysql);

        public:
                void PrintStored();
               

};

class Goods:public Base
{
        private:

        public:
                int  GoodsID;
                char GoodsName[10];
                char Type[10];
                char Status[10];
                int Price;
                void addinfo();
                void updateinfo();
                void deleteinfo();


};

class Suppliers:public Base
{
        private:

        public:
                int  SupplierID;
                char SuppName[10];
                char City[10];
                char Tel[10];
                char Company[30];
                void addinfo();
                void updateinfo();
                void deleteinfo();
};

class Stocks:public Base
{
        private:

        public:
              int GoodsID;
              int Stocksum;
              char  StockDate[10];
                void addinfo();
                void updateinfo();
                void deleteinfo();

};
class Orders:public Base
{
        private:

        public:
              int OrderID;
              char GoodsName[10];
              int SupplierID;
              int Quanity;
            char  OrderDate[10];
                void addinfo();
                void updateinfo();
                void deleteinfo();

};



class App
{
        private:
                void insert();
                void menu();
                                void AddGoods();
                                void UpdateGoods ();
                                void DeleteGoods();
                                void AddSuppliers();
                                void UpdateSuppliers();
                                void DeleteSuppliers();
                                void AddStocks();
                                void UpdateStocks ();
                                void DeleteStocks();
                                void AddOrders();
                                void UpdateOrders();
                                void DeleteOrders();
                                void PrintTheMostShareList();
                                void PrintshareList();
                                void PrintDateShareList();
        public:

                void init();

};


void Connection::connectDB()
{
        char hostname[MAXHOSTNAMELEN];
        int max_len = MAXHOSTNAMELEN;

        if(dbinit() == FAIL)
        {
                cout<<"initialize DB error";
                cout<<endl;
        }

        if((login = dblogin())==FAIL)
        {
                cout<<"initialize dblogin() structure error";
        }

        DBSETLUSER(login, UID);
        DBSETLPWD(login, PWD);

        if(gethostname(hostname, max_len)==0)
        {
                DBSETLHOST(login,hostname);

        }

        if((dbconn=dbopen(login,DBSERVER))==NULL)
        {
                cout<<"connect to the DB server error: "<<DBSERVER<<endl;
        }

        if((dbuse(dbconn, DBNAME)) == FAIL)
        {
                cout<<"Open database error"<<DBNAME<<" in  "<< DBSERVER ;
                cout<<endl;
        }
        dbloginfree(login);
}

void Connection::disconnectDB()
{
        dbfreebuf(dbconn);
        dbclose(dbconn);
        dbexit();
}

void Connection::execStatement(char* statement)
{

        dbcmd(dbconn, statement);


        if (!dbsqlexec(dbconn)==FAIL)
        {
                cout<<"Query executed successfully"<<endl;
        }
        else
        {
                cout<<"Error in execution"<<endl;
        }

}

void App::init()
{
        menu();
}

void App::menu()
{
        char pOp;
        char cOp;
        system("clear");
        while (true)
        {
               //system("clear");
                cout<<"                ShareAccounting System\n";
                cout<<" \n";
                cout<<">>>>>>>>>>>>>>>>>MainMenu<<<<<<<<<<<<<<<<$n";
                cout<<"\n";
                cout<<"\n";
                cout<<"    1 Goods Information Management       \n";
                cout<<"    2 Server Information Management         \n";
                cout<<"    3 Stored Information Management         \n";
                cout<<"    4 Changedetail Information Management   \n";
                cout<<"   5 Reporter Print                        \n";
                cout<<"   6 Exit System                           \n";
                cout<<"----------------------------------------------------------\n";
                cout<<"\n";
                cout<<"Please Select Operate(1-6)$";
                cin>>pOp;
                cout<<"\n";
                switch (pOp)
                {
                case '1':
                        system("clear");
                        cout<<"---------------- ShareAccounting System---------------\n";
                        cout<<" \n";
                        cout<<"------------Goods Information Management-------------\n";
                        cout<<"\n";
                        cout<<"------------------------------------------------------------\n";
                        cout<<"       1 Add Goods Information             \n";
                        cout<<"       2 Update Goods Information          \n";
                        cout<<"       3 Delete Goods Information          \n";
                        cout<<"       4 Return MainMenu                      \n";
                        cout<<"------------------------------------------------------------\n";
                        cout<<"\n";
                        while(true)
                        {
                                cout<<">>>>>Goods Information Management<<<<<\n";
                                cout<<"Please Select Operate(1-4)-";
                                cin>>cOp;
                                cout<<"\n";
                                switch (cOp)
                                {
                                        case '1':
                                                                                        AddGoods();
                                            break;
                                        case '2':
                                                                                        UpdateGoods();
                                            break;
                                        case '3':
                                                                                        DeleteGoods();
                                            break;
                                        default:
                                                break;
                                }
                                if(cOp=='4')break;
                        }
                        break;
                case '2':
                        system("clear");
                        cout<<"########## ShareAccounting  System #########\n";
                        cout<<"#                                         #\n";
                        cout<<"#>>>>>>>Server Information Management<<<<<<#\n";
                        cout<<"#                                         #\n";
                        cout<<"###########################################\n";
                        cout<<"#  1 Add Suppliers Information                #\n";
                        cout<<"#  2 Update Suppliers Information             #\n";
                        cout<<"#  3 Delete Suppliers Information             #\n";
                        cout<<"#  4 Return MainMenu                      #\n";
                        cout<<"###########################################\n";
                        cout<<"\n";
                        while(true)
                        {
                                cout<<">>>>>Server Information Management<<<<<\n";
                                cout<<"Please Select Operate(1-4)#";
                                cin>>cOp;
                                cout<<"\n";
                                switch (cOp)
                                {
                                        case '1':
                                                                                        AddSuppliers();
                                            break;
                                        case '2':
                                                                                        UpdateSuppliers();
                                            break;
                                        case '3':
                                                                                        DeleteSuppliers();
                                            break;
                                        default:
                                                break;
                                }
                                if(cOp=='4')break;
                        }
                        break;
                case '3':
                        system("clear");
                        cout<<"########## ShareAccounting System #########\n";
                        cout<<"#                                         #\n";
                        cout<<"#>>>>StocksInformation Management<<<#\n";
                        cout<<"#                                         #\n";
                        cout<<"###########################################\n";
                        cout<<"#  1 Add Stocks Information          #\n";
                        cout<<"#  2 Update Stocks Information       #\n";
                        cout<<"#  3 Delete Stocks Information       #\n";
                        cout<<"#  4 Return MainMenu                      #\n";
                        cout<<"###########################################\n";
                        cout<<"\n";
                        while(true)
                        {
                                cout<<">>>>> Stocks Information Management<<<<<\n";
                                cout<<"Please Select Operate(1-4)#";
                                cin>>cOp;
                                cout<<"\n";
                                switch (cOp)
                                {
                                        case '1':
                                                                                        AddStocks();
                                            break;
                                        case '2':
                                                                                        UpdateStocks();
                                            break;
                                        case '3':
                                                                                        DeleteStocks();
                                            break;
                                        default:
                                                break;
                                }
                                if(cOp=='4')break;
                        }
                      break;
case '4':
                        system("clear");
                        cout<<"########## ShareAccounting System #########\n";
                        cout<<"#                                         #\n";
                        cout<<"#>>>>>>>Orders Information Management<<<<<<#\n";
                        cout<<"#                                         #\n";
                        cout<<"###########################################\n";
                        cout<<"# 1 Add Orders Information                #\n";
                        cout<<"# 2 Update Orders  Information             #\n";
                        cout<<"# 3 Delete Orders  Information             #\n";
                        cout<<"#  4 Return MainMenu                      #\n";
                        cout<<"###########################################\n";
                        cout<<"\n";
                        while(true)
                        {
                                cout<<">>>>>Orders Information Management<<<<<\n";
                                cout<<"Please Select Operate(1-4)#";
                                cin>>cOp;
                                cout<<"\n";
                                switch (cOp)
                                {
                                        case '1':
                                                                                        AddOrders();
                                            break;
                                        case '2':
                                                                                        UpdateOrders ();
                                            break;
                                        case '3':
                                                                                        DeleteOrders();
                                            break;
                                        default:
                                                break;
                                }
                                if(cOp=='4')break;
                        }
                        break;

                case '5':
                        system("clear");
                        cout<<"########## ShareAccounting System #########\n";
                        cout<<"#                                         #\n";
                        cout<<"#>>>>>>>>>>>>>>Reportor Print<<<<<<<<<<<<<#\n";
                        cout<<"#                                         #\n";
                        cout<<"###########################################\n";
                        cout<<"#  1 Print the stored List      #\n";

                        cout<<"#  2 Return MainMenu                      #\n";
                        cout<<"###########################################\n";
                        cout<<"\n";
                        while(true)
                        {
                                cout<<">>>>>>>>>Reportor Print<<<<<<<<<<<\n";
                                cout<<"Please Select Operate(1-2)#";
                                cin>>cOp;
                                cout<<"\n";
                                switch (cOp)
                                {
                                        case '1':
                                                                                        PrintTheMostShareList();
                                            break;

                                        default:
                                                break;
                                }
                                if(cOp=='2')break;
                        }
                        break;
                case '5':
                        return;
                default:
                        cout<<"OPerate Error,Please Input 1-5 Number to Select Operate.\n";
                        break;
                }
        }
}

void App::AddGoods()
{
        Goods goods;

        cout<<"Please input GoodsID:";
        cin>>goods.GoodsID;
        cout<<"\n";

        cout<<"Please input GoodsName:";
        cin>>goods.GoodsName;
        cout<<"\n";
        cout<<"Please input Type:";
        cin>>goods.Type;
        cout<<"\n";

        cout<<"Please input Status:";
        cin>>goods.Status;
        cout<<"\n";

        cout<<"Please input Price:";
        cin>>goods.Price;
        cout<<"\n";

       goods.addinfo();
}
void App::UpdateGoods()
{

        Goods goods;



        cout<<"Please input GoodsID:";
        cin>>goods.GoodsID;
        cout<<"\n";

        cout<<"Please input GoodsName:";
        cin>>goods.GoodsName;
        cout<<"\n";
        cout<<"Please input Type:";
        cin>>goods.Type;
        cout<<"\n";

        cout<<"Please input Status:";
        cin>>goods.Status;
        cout<<"\n";

        cout<<"Please input Price:";
        cin>>goods.Price;
        cout<<"\n";
       goods.updateinfo();

}
void App::DeleteGoods()
{
        Goods goods;

        cout<<"Please input GoodsID:";
        cin>>goods.GoodsID;
        cout<<"\n";

      goods.deleteinfo();


}
void App::AddSuppliers()
{
       Suppliers supplier;

        cout<<"Please input SupplierID:";
        cin>>supplier.SupplierID;
        cout<<"\n";

        cout<<"Please input SuppName:";
        cin>>supplier.SuppName;
        cout<<"\n";

        cout<<"Please input City:";
        cin>>supplier.City;
        cout<<"\n";

        cout<<"Please input Tel:";
        cin>>supplier.Tel;
        cout<<"\n";

cout<<"Please input Company:";
        cin>>
        cout<<"\n";

       supplier.addinfo();
}
void App::UpdateSuppliers()
{
       Suppliers supplier;

        cout<<"Please input SupplierID:";
        cin>>supplier.SupplierID;
        cout<<"\n";

        cout<<"Please input SuppName:";
        cin>>supplier.SuppName;
        cout<<"\n";

        cout<<"Please input City:";
        cin>>supplier.City;
        cout<<"\n";

        cout<<"Please input Tel:";
        cin>>supplier.Tel;
        cout<<"\n";

cout<<"Please input Company:";
        cin>>
        cout<<"\n";


       supplier.updateinfo();
}
void App::DeleteSuppliers()
{
        Suppliers supplier;

        cout<<"Please input SuppName:";
        cin>supplier.SuppName;
        cout<<"\n";

       supplier.deleteinfo();

}
void App::AddStocks()
{
        Stocks stocks;

        cout<<"Please input GoodsID:";
        cin>>stocks.GoodsID;
        cout<<"\n";

        cout<<"Please input Stocksum:";
        cin>>stocks.Stocksum;
        cout<<"\n";

        cout<<"Please input StockDate:";
        cin>>stocks.StockDate;
        cout<<"\n";

     stocks.addinfo();

}
void App::UpdateStocks()
{
        Stocks stocks;

        cout<<"Please input GoodsID:";
        cin>>stocks.GoodsID;
        cout<<"\n";

        cout<<"Please input Stocksum:";
        cin>>stocks.Stocksum;
        cout<<"\n";

        cout<<"Please input StockDate:";
        cin>>stocks.StockDate;
        cout<<"\n";

        stocks.updateinfo();
}
void App::DeleteStocks()
{
        Stocks stocks;

        cout<<"Please input StockDate:";
        cin>>stocks.StockDate;
        cout<<"\n";

       stocks.deleteinfo();

}
void App::AddOrders()
{ Orders orders;
  cout<<"Please input OrderID:";
        cin>>orders.OrderID;
        cout<<"\n";

        cout<<"Please input GoodsName:";
        cin>>orders.GoodsName;
        cout<<"\n";
 
         cout<<"Please input SupplierID:";
        cin>>orders.SupplierID;
        cout<<"\n";

        cout<<"Please input Quanity:";
        cin>>orders.Quanity;
        cout<<"\n";

        orders.addinfo();
}
void App::UpdateOrders()
{
          Orders orders;
  cout<<"Please input OrderID:";
        cin>>orders.OrderID;
        cout<<"\n";

        cout<<"Please input GoodsName:";
        cin>>orders.GoodsName;
        cout<<"\n";
 
         cout<<"Please input SupplierID:";
        cin>>orders.SupplierID;
        cout<<"\n";

        cout<<"Please input Quanity:";
        cin>>orders.Quanity;
        cout<<"\n";
        orders.updateinfo();
}
 void App::DeleteOrders()
{      Orders orders;

        cout<<"Please input OrderID:";
        cin>>orders.OrderID;
        cout<<"\n";

        cout<<"Please input Quanity:";
        cin>>orders.Quanity;
        cout<<"\n";
       orders.deleteinfo();
}
void App::PrintTheMostShareList()
{
        Base base;
        base.PrintTheMostShareList();
}
void App::PrintshareList()
{
        Base base;
        base.PrintshareList();
}
void App::PrintDateShareList()
{
        Base base;
        base.PrintDateShareList();
}


void Base::execSQL(char* mysql)
{
        Connection con;
        con.connectDB();
        con.execStatement(mysql);
        con.disconnectDB();
}

void Base::PrintTheMostShareList()
{
        Connection con;
        int GoodsID;
        int Stocksum;
        char StockDate[10];
        con.connectDB();
        con.execStatement("select GoodsID,Stocksum,StockDate  from  Stocks");
        dbresults(dbconn);
        dbbind(dbconn,1,INTBIND,0,(BYTE*)&GoodsID);
        dbbind(dbconn,2,INTBIND,0,(BYTE*)&Stocksum);
        dbbind(dbconn,3,CHARBIND,0,(BYTE*)&StockDate);
        cout<<"\tGoodsID\tStocksum\tStockDate"<<endl;
        while(dbnextrow(dbconn)!=NO_MORE_ROWS)
        {
                cout<<GoodsID<<"\t\t";
                cout<<Stocksum<<"\t\t";
                cout<<StockDate<<"\t\t";
                cout<<StartNO<<"\t";
                cout<<EndNO<<"\n";
        }
        con.disconnectDB();
}
void Base::PrintshareList()
{
        Connection con;
        int GoodsID;
        int Stocksum;
        char StockDate[10];
        con.connectDB();
        con.execStatement("select GoodsID,Stocksum,StockDate  from  Stocks");
        dbresults(dbconn);
        dbbind(dbconn,1,INTBIND,0,(BYTE*)&GoodsID);
        dbbind(dbconn,2,INTBIND,0,(BYTE*)&Stocksum);
        dbbind(dbconn,3,CHARBIND,0,(BYTE*)&StockDate);
        cout<<"\tGoodsID\tStocksum\tStockDate"<<endl;
        while(dbnextrow(dbconn)!=NO_MORE_ROWS)
        {
                cout<<GoodsID<<"\t\t";
                cout<<Stocksum<<"\t\t";
                cout<<StockDate<<"\t\t";
        }
        con.disconnectDB();
}
void Base::PrintDateShareList()
{
        Connection con;
         int GoodsID;
        int Stocksum;
        char StockDate[10];
        con.connectDB();
        con.execStatement("select GoodsID,Stocksum,StockDate  from  Stocks");
        dbresults(dbconn);
        dbbind(dbconn,1,INTBIND,0,(BYTE*)&GoodsID);
        dbbind(dbconn,2,INTBIND,0,(BYTE*)&Stocksum);
        dbbind(dbconn,3,CHARBIND,0,(BYTE*)&StockDate);
        cout<<"\tGoodsID\tStocksum\tStockDate"<<endl;
        while(dbnextrow(dbconn)!=NO_MORE_ROWS)
        {
                 cout<<GoodsID<<"\t\t";
                cout<<Stocksum<<"\t\t";
                cout<<StockDate<<"\t\t";
        }
        con.disconnectDB();
}

void Goods::addinfo()
{
        char mysql[800];
        sprintf(mysql,"insert into goods values('%d','%s','%s','%s','%s')",GoodsID,GoodsName,Type,Status,Price);
        execSQL(mysql);
}
void Goods::updateinfo()
{
        char mysql[800];
        sprintf(mysql,"update goods set GoodsID='%d',GoodsName='%s',Type='%s',Status='%s',Price='%d   where   GoodsID='%d'",GoodsID,GoodsName,Type,Status,Price);
        execSQL(mysql);
}
void Goods::deleteinfo()
{
        char mysql[800];
        sprintf(mysql,"delete from goods where GoodsID='%d'",GoodsID);
        execSQL(mysql);
}

void Suppliers::addinfo()
{
        char mysql[800];
        sprintf(mysql,"insert into suppliers values('%d','%s','%s','%s','%s')",SupplierID,SuppName,City,Tel,Company);
        execSQL(mysql);
}
void  Suppliers::updateinfo()
{
        char mysql[800];
        sprintf(mysql,"update server set SupplierID='%d',SuppName='%s',City='%s',Tel='%s',Company='%s' where SuppName='%s'",
        SupplierID,SuppName,City,Tel,Company);
        execSQL(mysql);
}
void Suppliers::deleteinfo()
{
        char mysql[800];
        sprintf(mysql,"delete from server where Sname='%s'",SuppName);
        execSQL(mysql);
}

void Stocks::addinfo()
{
        char mysql[800];
        sprintf(mysql,"insert into stocks values('%d','%d','%s')",GoodsID,Stocksum,StockDate);
        execSQL(mysql);
}
void Stocks::updateinfo()
{
        char mysql[800];
        sprintf(mysql,"update stocks set GoodsID='%d',Stocksum='%d' where  StockDate='%s'",GoodsID,Stocksum,StockDate);
        execSQL(mysql);
}
void Stocks::deleteinfo()
{
        char mysql[800];
        sprintf(mysql,"delete from Stocks where GoodsID='%d',Stocksum='%d'",GoodsID,Stocksum,StockDate);
        execSQL(mysql);
}
void Orders::addinfo()
{ char mysql[800];
 sprintf(mysql,"insert into orders values('%d','%s','%d','%d','%s')",OrderID,GoodsName,SupplierID,Quanity,OrderDate);
        execSQL(mysql);
}
void Orders::updateinfo()
{
        char mysql[800];
        sprintf(mysql,"update orders set Quanity='%d',OrderID='%d' where GoodsName='%s',SupplierID='%d'",OrderID,GoodsName,SupplierID,Quanity,OrderDate);
        execSQL(mysql);
}
void Orders::deleteinfo()
{
        char mysql[800];
        sprintf(mysql,"delete from orders  where OrderID='%d',OrderDate='%s'",OrderID,GoodsName,SupplierID,Quanity,OrderDate);
        execSQL(mysql);
}
int main()
{
        App app;
        app.init();
}


运行结果:
--------------------Configuration: 11 - Win32 Debug--------------------
Compiling...
11.cpp
e:\新建文件夹lxc\c语言\11\11.cpp(809) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

11.obj - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: include define 软件 entry 
2008-01-11 11:53
anthony634
Rank: 6Rank: 6
来 自:西南交大
等 级:贵宾
威 望:24
帖 子:653
专家分:10
注 册:2006-6-8
收藏
得分:0 
可能是漏了包含某头文件
2008-01-11 19:56
linsua
Rank: 1
等 级:新手上路
帖 子:275
专家分:0
注 册:2008-1-2
收藏
得分:0 
右键点工程名,选设置,然后选c/c++属性页,再选catagory选单中选 precompiled header ,将选项置成no use

如果你对我的话感到再明白不过 那恐怕你是误解了我的意思
2008-01-12 11:22
忘记喧嚣
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2007-10-7
收藏
得分:0 
哇 楼上好猛  偶像
2008-01-12 18:34
快速回复:急啊!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031423 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved