界面BUG(第一次写东西,手足无措~~~ 急救!)
我第一次写程序(学校项目考试练习) 是一个商店内部货物管理系统。
但是现在我做的界面出现问题了。
我的系统菜单只能往下选择而不能返回上级菜单~~~~~~~
注:我的系统是用DEV-C编写 在LINUX(redhat)环境下编译 并要求连接SQL2000。
问题点数:50、回复次数:9Top
1 楼yisijie(犀骨指环)回复于 2005-07-29 20:59:17 得分 6
我的头文件(部分功能暂时没有实现)
//头文件定义类和全局变量
#include "iostream.h"
#include "unistd.h"
#include "sys/param.h"
#include "sybfront.h"
#include "sybdb.h"
#include "syberror.h"
#include "stdio.h"
#include "string.h"
#define UID "sa"
#define PWD ""
#define DBSERVER "192.168.0.1:1433"
#define DBNAME "GoodsStorage"
//连接数据库的类
class Connection
{
LOGINREC *login;
DBPROCESS *dbconn;
public:
int openDB();
int execSelect(char* statement);
int execMerchandiseSelect(char* statement);
// int execdisplay(char* statement);
void execUpdate(char* statement);
void execDelete(char* statement);
void execInsert(char* statement);
void closeDB();
};
//供应商类
class Supplier
{
char number[5];
char name[30];
char kindName[20];
char address[50];
char phone[15];
char fax[15];
char email[50];
char zipCode[8];
char memo[100];
public:
void acceptSupplierInfo();
void updateSupplierInfo();
void deleteSupplierInfo();
void displaySupplierInfo();
void selectSupplierInfo();
};
class Merchandise
{
char number[5];
char name[30];
char kindName[20];
float price;
char level[3];
float weight;
int qty;
public:
void acceptMerchandiseInfo();
void updateMerchandiseInfo();
void deleteMerchandiseInfo();
// void displayMerchandiseInfo();
void selectMerchandiseInfo();
};Top
2 楼yisijie(犀骨指环)回复于 2005-07-29 21:01:36 得分 6
我的 界面代码(主界面)
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "iostream.h"
#include <stdlib.h>
#include "all.cpp"
int SupplierMenu();
int MerchandiseMenu();
int OrderBlankMenu();
int ConsignmentMenu();
int main()
{
system("cls");
char ch;
while(1)
{
cout << endl << "\t\t**************************************************" << endl;
cout << endl << "\t\t* WELCOME YOW TO USE STOCK MENAGE SYSTEM *" << endl;
cout << endl << "\t\t**************************************************" << endl;
cout << endl << "\t\t********* 1> Supplier Main Menu **********" << endl;
cout << endl << "\t\t********* 2> Merchandise Main Menu **********" << endl;
cout << endl << "\t\t********* 3> OrderBlank Main Menu **********" << endl;
cout << endl << "\t\t********* 4> Consignment Main Menu **********" << endl;
cout << endl << "\t\t********* 5> Exit **********" << endl;
cout << endl << "\t\t**************************************************" << endl;
cout << endl << "\t\t**************************************************" << endl;
cout << endl << "\t\tPlease Enter your choice : ";
cin >> ch;
switch (ch)
{
case '1':
{
SupplierMenu();
break;
}
case '2':
{
MerchandiseMenu();
break;
}
case '3':
{
OrderBlankMenu();
break;
}
case '4':
{
ConsignmentMenu();
break;
}
case '5':
{
system("clear");
return 0;
break;
}
}
cin >> ch;
}
return 0;
}
Top
3 楼yisijie(犀骨指环)回复于 2005-07-29 21:06:14 得分 6
我的界面(模块界面)
#include "iostream.h"
#include <stdlib.h>
#include "function.cpp"
int choice;
int SupplierMenu()
{
system("clear");
char ch[5];
choice = 0;
do
{
cout << endl << "\t\t****************************************************" << endl;
cout << endl << "\t\t* Supplier Main Menu *" << endl;
cout << endl << "\t\t****************************************************" << endl;
cout << endl << "\t\t******* 1> Add Supplier Details ******" << endl;
cout << endl << "\t\t******* 2> Update Supplier Details ******" << endl;
cout << endl << "\t\t******* 3> Delete Supplier Details ******" << endl;
cout << endl << "\t\t******* 4> Find Supplier Details ******" << endl;
cout << endl << "\t\t******* 5> Display All Supplier Details ******" << endl;
cout << endl << "\t\t******* 6> Exit Supplier Menu ******" << endl;
cout << endl << "\t\t****************************************************" << endl;
cout << endl << "\t\t****************************************************" << endl;
cout << endl << "\t\tPlease Enter your choice : ";
cin >> choice;
switch (choice)
{
case 1:
{
Supplier obj;
obj.acceptSupplierInfo();
break;
}
case 2:
{
Supplier obj;
obj.updateSupplierInfo();
break;
}
case 3:
{
Supplier obj;
obj.deleteSupplierInfo();
break;
}
case 4:
{
Supplier obj;
obj.selectSupplierInfo();
break;
}
case 5:
{
Supplier obj;
obj.displaySupplierInfo();
break;
}
case 6:
{
system("clear");
return 0;
break;
}
}
cout<<endl<<"Enter Y or y continue: ";
cin>>ch;
}while(*ch=='y' || *ch=='Y');
}
int MerchandiseMenu()
{
system("clear");
char ch[5];
choice = 0;
do
{
cout << endl << "\t\t***************************************************" << endl;
cout << endl << "\t\t* Merchandise Main Menu *" << endl;
cout << endl << "\t\t***************************************************" << endl;
cout << endl << "\t\t****** 1> Add Merchandise Details ******" << endl;
cout << endl << "\t\t****** 2> Update Merchandise Details ******" << endl;
cout << endl << "\t\t****** 3> Delete Merchandise Details ******" << endl;
cout << endl << "\t\t****** 4> Find Merchandise Details ******" << endl;
cout << endl << "\t\t****** 5> Display All Merchandise Details ******" << endl;
cout << endl << "\t\t****** 6> Exit Merchandise Menu ******" << endl;
cout << endl << "\t\t***************************************************" << endl;
cout << endl << "\t\t***************************************************" << endl;
cout << endl << "\t\tPlease Enter your choice : ";
cin >> choice;
switch (choice)
{
case 1:
{
Merchandise obj;
obj.acceptMerchandiseInfo();
break;
}
case 2:
{
Merchandise obj;
obj.updateMerchandiseInfo();
break;
}
case 3:
{
Merchandise obj;
obj.deleteMerchandiseInfo();
break;
}
case 4:
{
Merchandise obj;
obj.selectMerchandiseInfo();
break;
}
case 6:
{
system("clear");
return 0;
break;
}
}
cout<<endl<<"Enter Y or y continue: ";
cin>>ch;
}while(*ch=='y' || *ch=='Y');
}Top
4 楼xjp6688(大平/要做必须最好)回复于 2005-07-30 08:19:48 得分 6
菜单界面都作成一个相互独立的模块,每个界面中的一个选项调用一个或者多个向上返回的函数,注意清屏!Top
5 楼yisijie(犀骨指环)回复于 2005-07-30 20:33:20 得分 6
请问我的这段代码 在主体不改变的情况下 有什么办法解决我的 菜单无法向上返回的问题吗Top
6 楼defyer007(深入浅出)回复于 2005-07-30 23:59:43 得分 5
每次进入一个菜单前进行清屏,比如在子菜单中设置一个返回上级菜单选项,按相应键就调用上一级菜单的显示界面代码Top
7 楼yisijie(犀骨指环)回复于 2005-07-31 01:40:06 得分 5
我的好像有 调用上级菜单的代码啊 ~~~~~~~~~~Top
8 楼various(娃哈哈)回复于 2005-07-31 21:58:15 得分 5
你把主界面的代码独立成一个函数,这样就可以在模块界面中调用,也应该可以解决你的问题Top
9 楼defyer007(深入浅出)回复于 2005-07-31 22:11:14 得分 5
不好意思,没有仔细看你的代码Top




