/***********************************
* 模块名称:clsProduct.cpp *
* 模块功能: clsProduct 类 类体 *
* 作者:刘鑫锐 *
* 撰写日期:2005-9-15 *
***********************************/
#include <iostream.h>
#include <stdlib.h>
#include "head/clsProduct.h" //调用 clsProduct类声明 头文件
#include "head/clsTrade.h" //调用 clsTrade 类声明 头文件
#include "head/clsConn.h" //调用 clsConn 类声明 头文件
#include "head/clsMain.h" //调用 clsMain 类声明 头文件
void clsProduct::dispProdMenu() //Product 信息管理 主菜单
{
system("clear");
char choice; //定义接收选择的变量
while(1)
{
system("clear");
cout << endl << "\t\t ********************************************" << endl;
cout << endl << "\t\t * PRODUCT MIS MAIN MENU *" << endl;
cout << endl << "\t\t ********************************************" << endl;
cout << endl << "\t\t *** 1) PROUCT INFORMATION LIST ***" << endl;
cout << endl << "\t\t *** 2) PROUCT INFO FOR NEED STORAGE ***" << endl;
cout << endl << "\t\t *** 3) PROUCT INFORMATION INSERT ***" << endl;
cout << endl << "\t\t *** 4) PROUCT INFORMATION UPDATE/DELETE ***" << endl;
cout << endl << "\t\t *** 5) RETURN MAIN MENU ***" << endl;
cout << endl << "\t\t ********************************************" << endl;
cout << endl << "\t\t ********************************************" << endl;
cout << endl << "\t\t Please enter your choice : ";
cin >> choice; //输入选择
switch(choice) //根据选择,执行相关的操作
{
case '1':
{
system("clear");
clsProduct obj; //创建对象
obj.listProdInfo(); //列表显示产品信息
break;
}
case '2':
{
system("clear");
clsProduct obj; //创建对象
obj.NeedOrder(); //列表显示需要定货的产品信息
break;
}
case '3':
{
system("clear");
clsProduct obj; //创建对象
obj.addProdInfo(); //添加产品信息
break;
}
case '4':
{
system("clear");
clsProduct obj; //创建对象
obj.queryProdInfo(); //先查询产品信息 ,再进行修改和删除操作
break;
}
case '5':
{
system("clear");
clsMain obj;
obj.mainlist(); //返回主菜单
break;
}
default:
{
system("clear");
clsMain obj;
obj.error(); //显示错误信息
break;
}
}
}
}
void clsProduct::listProdInfo() //产品信息列表
{
clsConn obj;
char ListString[1024];
sprintf(ListString,"select * from Product ");
obj.ClistInfo(ListString);
}
void clsProduct::NeedOrder() //需要定货的产品信息列表
{
char choice;
system("clear");
cout << "\n\n\n\n";
cout << endl << "\t\t *****************************************";
cout << endl << "\t\t * QUERY STORAGE BEGIN *";
cout << endl << "\t\t *****************************************";
cout << endl << "\t\t ASK:" << endl;
cout << endl << "\t\t Your can query storage all and need order!\n";
cout << endl << "\t\t --Query all Product storage,please enter A: \n"; //查询全部产品的库存列表
cout << endl << "\t\t --Query need order product storage,please enter B:\n"; //查询要定货的产品库存列表
cout << endl << "\t\t --Other key will begin stock product: \n"; //按其他键 则直接开始采购
cout << endl << "\t\t ANSWER:";
cin >> choice;
cout << endl;
if(choice=='A' || choice=='a')
{
clsConn obj;
char ListString[1024];
sprintf(ListString,"exec proc_ProductInfo");
obj.ClistInfo(ListString);
}
else if(choice=='B' || choice=='b')
{
clsConn obj;
char ListString[1024];
sprintf(ListString,"exec proc_NeedOrder");
obj.ClistInfo(ListString);
}
else
{
clsTrade obj;
obj.addTradeInfo();
}
}
void clsProduct::addProdInfo() //添加产品信息
{
system("clear");
cout << "\n\n";
clsConn obj;
char InsertString[1024];
cout << endl << "\t\t *****************************************";
cout << endl << "\t\t * INSERT BEGIN *"; //向数据库写入产品信息
cout << endl << "\t\t *****************************************";
cout << endl << "\t\t Please enter ProductName:";
cin >> ProductName;
cout << endl << "\t\t Please enter ProductMetric:";
cin >> Metric;
cout << endl << "\t\t Please enter Product safe value:";
cin >> SafeValue;
sprintf(InsertString,"insert into Product (vProductName,cMetric,fSafeValue) values ('%s','%s',%f)",ProductName,Metric,SafeValue);
obj.Cwork(InsertString);
}
void clsProduct::queryProdInfo() //查询产品信息
{
char choice;
system("clear");
cout << "\n\n\n\n";
cout << endl << "\t\t *****************************************";
cout << endl << "\t\t * QUERY,UPDATE,DELETE BEGIN *";
cout << endl << "\t\t *****************************************";
cout << endl << "\t\t ASK:" << endl;
cout << endl << "\t\t Your can use ProductId or ProductName for Query Product!\n";
cout << endl << "\t\t --Use ProductId Query,please enter A: \n"; //根据产品的Id查询
cout << endl << "\t\t --Use ProductName Query,please enter B:\n"; //根据产品的Name查询
cout << endl << "\t\t --Other key will begin delete/update: \n"; //按其他键 则直接开始修改、删除操作
cout << endl << "\t\t ANSWER:";
cin >> choice;
cout << endl;
if(choice=='A' || choice=='a')
{
cout << "\t\t Please enter Product Id :";
cin >> ProductId; //按产品ID查询
clsConn obj;
char QueryString[1024];
sprintf(QueryString,"select * from Product where iProductId = '%d'",ProductId);
obj.ClistInfo(QueryString);
}
else if(choice=='B' || choice=='b')
{
cout << "\t\t Please enter Product Name :";
cin >> ProductName; //按产品名称查询
clsConn obj;
char QueryString[1024];
sprintf(QueryString,"select * from Product where vProductName = '%s'",ProductName);
obj.ClistInfo(QueryString);
}
else
{
clsMain obj;
obj.error(); //错误提示
}
cout << endl << "\t\t Will your begin Delete or Updat