重庆大学实验报告
实验题目: 简单商品订购管理软件
学 院:专业班级: 年 级: 姓 名: 学 号: 完成时间:月日
指导教师:
重庆大学教务处制
实验项目指导教师评定成绩表
指导教师评定成绩:
指导教师签名: 年 月 日
重庆大学本科学生实验项目任务书
说明:学院、专业、年级均填全称,如:计算机学院、计算机科学与技术、2011。
实验报告正文
主要内容包括:
1 需求分析
1.1数据需求 :通过与商品库存管理系统用户交谈等方式以及对商品库存管理的分析,可以得到商品库存管理数据库系统的数据需求。管理员可以添加库存商品及查看出库及运送情况信息,可以对库存的商品进行出库和入库的管理, 由此分析可得:商品库存管理系统包括商品信息、商家信息、入库出库信息。商品由商品类别名称标识,入库出库根据商品信息来标识。 1.2功能需求: 管理员通过进入界面登录。 可以对信息进行查询和更新等操作,例如添加、查看等。 2 系统设计(类图、模块图等) 搭建程序框架图,其图如下所示:
3 关键代码描述
/ final_test1Dlg.cpp : implementation file //
#include "stdafx.h" #include "final_test1.h" #include "final_test1Dlg.h" #include "List.h" #include "queue.h"
#ifdef _DEBUG
#define new DEBUG_NEW #undef THIS_FILE
static char THIS_FILE[] = __FILE__; #endif
///////////////////////////////////////////////////////////////////////////// // CFinal_test1Dlg dialog List L1,L2,L3,L4,L5; queue Q1,Q2; int type=-1; int sub_flag=0; CString list;
CFinal_test1Dlg::CFinal_test1Dlg(CWnd* pParent /*=NULL*/) {
//{{AFX_DATA_INIT(CFinal_test1Dlg) m_qin = FALSE; m_guo = FALSE; m_cai = FALSE; m_gan = FALSE; m_shui = FALSE; m_name = _T(""); m_count = 0;
m_deliver_type = _T(""); m_deliver_name = _T(""); m_deliver_count = 0; m_sell_type = _T(""); m_sell_name = _T(""); m_sell_count = 0;
: CDialog(CFinal_test1Dlg::IDD, pParent)
}
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
void CFinal_test1Dlg::DoDataExchange(CDataExchange* pDX) { }
BEGIN_MESSAGE_MAP(CFinal_test1Dlg, CDialog)
//{{AFX_MSG_MAP(CFinal_test1Dlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_CHECK1, OnCheck1) ON_BN_CLICKED(IDC_CHECK2, OnCheck2) ON_BN_CLICKED(IDC_CHECK3, OnCheck3) ON_BN_CLICKED(IDC_CHECK4, OnCheck4) ON_BN_CLICKED(IDC_CHECK5, OnCheck5) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) ON_BN_CLICKED(IDC_BUTTON4, OnButton4) ON_BN_CLICKED(IDC_BUTTON5, OnButton5) ON_BN_CLICKED(IDC_BUTTON6, OnButton6) ON_BN_CLICKED(IDC_BUTTON7, OnButton7) CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFinal_test1Dlg)
DDX_Control(pDX, IDC_LIST3, m_sell_list); DDX_Control(pDX, IDC_LIST2, m_deliver_list); DDX_Control(pDX, IDC_LIST1, m_list); DDX_Check(pDX, IDC_CHECK2, m_qin); DDX_Check(pDX, IDC_CHECK4, m_guo); DDX_Check(pDX, IDC_CHECK3, m_cai); DDX_Check(pDX, IDC_CHECK5, m_gan); DDX_Check(pDX, IDC_CHECK1, m_shui); DDX_Text(pDX, IDC_EDIT1, m_name); DDX_Text(pDX, IDC_EDIT2, m_count); DDX_Text(pDX, IDC_EDIT3, m_deliver_type); DDX_Text(pDX, IDC_EDIT4, m_deliver_name); DDX_Text(pDX, IDC_EDIT5, m_deliver_count); DDX_Text(pDX, IDC_EDIT6, m_sell_type); DDX_Text(pDX, IDC_EDIT7, m_sell_name); DDX_Text(pDX, IDC_EDIT8, m_sell_count); //}}AFX_DATA_MAP
ON_BN_CLICKED(IDC_BUTTON9, OnButton9) //}}AFX_MSG_MAP
END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// // CFinal_test1Dlg message handlers
BOOL CFinal_test1Dlg::OnInitDialog() { }
// If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework.
void CFinal_test1Dlg::OnPaint() {
}
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
// Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2;
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); if (IsIconic()) {
CPaintDC dc(this); // device context for painting
// Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// Set big icon
SetIcon(m_hIcon, FALSE);
// Set small icon
CDialog::OnInitDialog();
}
{ }
CDialog::OnPaint();
// The system calls this to obtain the cursor to display while the user drags // the minimized window.
HCURSOR CFinal_test1Dlg::OnQueryDragIcon() { }
void CFinal_test1Dlg::OnButton1() { }
void CFinal_test1Dlg::OnCheck1() { }
// TODO: Add your control notification handler code here if(m_shui==FALSE)
m_shui=TRUE; m_shui=FALSE; else
// TODO: Add your control notification handler code here UpdateData(true); char temp[50]; if(m_shui==TRUE) else if(m_qin==TRUE)
L2.Add(temp,m_count); L3.Add(temp,m_count); L4.Add(temp,m_count); L5.Add(temp,m_count);
MessageBox("未′选?择?商Θ 品·种?类え !?","提 示?框í"); else if(m_cai==TRUE) else if(m_guo==TRUE) else if(m_gan==TRUE) else
UpdateData(false); return (HCURSOR) m_hIcon;
strcpy(temp,(LPSTR)(LPCTSTR)m_name); L1.Add(temp,m_count);
void CFinal_test1Dlg::OnCheck2() { }
void CFinal_test1Dlg::OnCheck3() { }
void CFinal_test1Dlg::OnCheck4() { }
void CFinal_test1Dlg::OnCheck5() { }
void CFinal_test1Dlg::OnButton2() {
// TODO: Add your control notification handler code here UpdateData(true); m_list.ResetContent(); char temp[50]; int itemp; L1.to_head();
// TODO: Add your control notification handler code here if(m_gan==FALSE)
m_gan=TRUE; m_gan=FALSE; else
// TODO: Add your control notification handler code here if(m_guo==FALSE)
m_guo=TRUE; m_guo=FALSE; else
// TODO: Add your control notification handler code here if(m_cai==FALSE)
m_cai=TRUE; m_cai=FALSE; else
// TODO: Add your control notification handler code here if(m_qin==FALSE)
m_qin=TRUE; m_qin=FALSE; else
L3.to_head(); L4.to_head(); L5.to_head();
m_list.InsertString(-1," 种?类え? 名?称? 数簓量?"); while(L1.to_next()) { strcpy(temp,L1.Display_name()); itemp=L1.Display_count(); list.Format(" 水?产ú %s %d" m_list.InsertString(-1,list);
} while(L2.to_next())
{ strcpy(temp,L2.Display_name());
itemp=L2.Display_count(); list.Format(" 禽Y肉╝ %s %d" m_list.InsertString(-1,list); } while(L3.to_next())
{ strcpy(temp,L3.Display_name()); itemp=L3.Display_count(); list.Format(" 蔬?菜? %s %d" m_list.InsertString(-1,list);
} while(L4.to_next())
{ strcpy(temp,L4.Display_name()); itemp=L4.Display_count(); list.Format(" 水?果? %s %d" m_list.InsertString(-1,list); } while(L5.to_next())
{ strcpy(temp,L5.Display_name()); itemp=L5.Display_count(); list.Format(" 干é货? %s %d" m_list.InsertString(-1,list); }
UpdateData(false);
}
void CFinal_test1Dlg::OnButton3()
,temp,itemp);
,temp,itemp); ,temp,itemp);
,temp,itemp);
,temp,itemp);
// TODO: Add your control notification handler code here UpdateData(true); int flag; char temp[50]; if(m_shui==TRUE) {
flag=L1.isempty(); if(flag==0)
strcpy(temp,(LPSTR)(LPCTSTR)m_name);
MessageBox("库a存?里?无T此?商Θ 品·!?","提 示?框í"); flag=L1.Check(temp,m_count);
switch(flag) {
case -1:MessageBox("库a存?里?无T此?商Θ 品·!?","提 示?框í"); }
break; break; type=1; sub_flag=1; break;
case 0:MessageBox("此?商Θ 品·库a存?数簓量?不?足?!?","提 示?框í"); case 1:L1.Sub(m_count);
default:break;
}
else if(m_qin==TRUE) {
if(flag==0)
flag=L2.isempty();
MessageBox("库a存?里?无T此?商Θ 品·!?","提 示?框í"); flag=L2.Check(temp,m_count);
}
switch(flag) {
case -1:MessageBox("库a存?里?无T此?商Θ 品·!?","提 示?框í"); }
break; break; type=2; sub_flag=1; break;
case 0:MessageBox("此?商Θ 品·库a存?数簓量?不?足?!?","提 示?框í");
case 1:L2.Sub(m_count);
default:break;
{ }
else if(m_guo==TRUE) { }
else if(m_gan==TRUE) {
if(flag==0)
flag=L5.Check(temp,m_count); if(flag==0)
flag=L4.Check(temp,m_count); switch(flag) {
case -1:MessageBox("库a存?里?无T此?商Θ 品·!?","提 示?框í"); }
break; break; type=4; sub_flag=1; break;
case 0:MessageBox("此?商Θ 品·库a存?数簓量?不?足?!?","提 示?框í"); if(flag==0)
flag=L3.Check(temp,m_count); switch(flag) {
case -1:MessageBox("库a存?里?无T此?商Θ 品·!?","提 示?框í"); }
break; break; type=3; sub_flag=1; break;
case 0:MessageBox("此?商Θ 品·库a存?数簓量?不?足?!?","提 示?框í");
flag=L3.isempty();
MessageBox("库a存?里?无T此?商Θ 品·!?","提 示?框í");
case 1:L3.Sub(m_count);
default:break;
flag=L4.isempty();
MessageBox("库a存?里?无T此?商Θ 品·!?","提 示?框í");
case 1:L4.Sub(m_count);
default:break;
flag=L5.isempty();
MessageBox("库a存?里?无T此?商Θ 品·!?","提 示?框í");
}
}
{
case -1:MessageBox("库a存?里?无T此?商Θ 品·!?","提 示?框í"); }
break; break; type=5; sub_flag=1; break;
case 0:MessageBox("此?商Θ 品·库a存?数簓量?不?足?!?","提 示?框í");
case 1:L5.Sub(m_count);
default:break;
else
MessageBox("未′选?择?商Θ 品·种?类え !?","提 示?框í"); UpdateData(false);
void CFinal_test1Dlg::OnButton4() {
// TODO: Add your control notification handler code here UpdateData(true);
if((type==1)&&(sub_flag==1)) {
m_deliver_type="水?产ú"; m_deliver_name=m_name;
m_deliver_count=m_count; }
else if((type==2)&&(sub_flag==1)) {
m_deliver_type="禽Y肉╝"; sub_flag=0;
m_deliver_name=m_name;
m_deliver_count=m_count; }
else if((type==3)&&(sub_flag==1)) {
m_deliver_type="蔬?菜?"; sub_flag=0;
m_deliver_name=m_name; m_deliver_count=m_count;
}
sub_flag=0;
}
{
m_deliver_type="水?果?";
m_deliver_name=m_name;
m_deliver_count=m_count; }
else if((type==5)&&(sub_flag==1)) {
m_deliver_type="干é货?"; m_deliver_name=m_name; } else
MessageBox("无T新?商Θ 品·出?库a!?","提 示?框í"); UpdateData(false);
sub_flag=0; sub_flag=0;
m_deliver_count=m_count;
void CFinal_test1Dlg::OnButton5() {
// TODO: Add your control notification handler code here char deliver_type[50]; char deliver_name[50];
strcpy(deliver_name,(LPSTR)(LPCTSTR)m_deliver_name); switch(type) {
case 1:strcpy(deliver_type,"水?产ú");
Q1.QInsert(deliver_type,deliver_name,m_deliver_count); break;
Q1.QInsert(deliver_type,deliver_name,m_deliver_count); break;
Q1.QInsert(deliver_type,deliver_name,m_deliver_count);
UpdateData(true);
case 2:strcpy(deliver_type,"禽Y肉╝");
case 3:strcpy(deliver_type,"蔬?菜?");
break;
case 4:strcpy(deliver_type,"水?果?");
Q1.QInsert(deliver_type,deliver_name,m_deliver_count); break;
Q1.QInsert(deliver_type,deliver_name,m_deliver_count); break;
case 5:strcpy(deliver_type,"干é货?");
default:MessageBox("无T可é运?输?商Θ 品·!?","提 示?框í");
}
}
UpdateData(false);
void CFinal_test1Dlg::OnButton6() { t); }
void CFinal_test1Dlg::OnButton7() {
// TODO: Add your control notification handler code here UpdateData(true); int num=Q1.QLength(); {
char sell_type[50]; Q1.to_front();
strcpy(sell_type,Q1.QRear_type()); char sell_name[50];
MessageBox("无T在ú运?输?商Θ 品·可é交?付?!?","提 示?框í"); }
m_deliver_list.InsertString(-1,list); Q1.to_next(); num--;
list.Format(" %s %s %d",deliver_type,deliver_name,deliver_coun// TODO: Add your control notification handler code here UpdateData(true);
m_deliver_list.ResetContent();
m_deliver_list.InsertString(-1," 种?类え? 名?称? 数簓量?"); char deliver_type[50]; char deliver_name[50]; int deliver_count; int num=Q1.QLength(); Q1.to_front(); while(num>0) {
strcpy(deliver_type,Q1.QRear_type()); strcpy(deliver_name,Q1.QRear_name()); deliver_count=Q1.QRear_count();
UpdateData(false);
if(num==0)
else
m_sell_count=Q1.QRear_count();
Q1.to_now();
m_sell_type.Format("%s",sell_type); }
void CFinal_test1Dlg::OnButton8() {
// TODO: Add your control notification handler code here char sell_type[50]; UpdateData(true); char sell_name[50];
strcpy(sell_type,(LPSTR)(LPCTSTR)m_sell_type); strcpy(sell_name,(LPSTR)(LPCTSTR)m_sell_name);
Q2.QInsert(sell_type,sell_name,m_sell_count); Q1.QDelete(); UpdateData(false); }
void CFinal_test1Dlg::OnButton9() {
// TODO: Add your control notification handler code here UpdateData(true);
m_sell_list.ResetContent();
m_sell_list.InsertString(-1," 种?类え? 名?称? 数簓量?"); char sell_type[50]; char sell_name[50]; int sell_count; int num=Q2.QLength(); Q2.to_front(); while(num>0) { }
strcpy(sell_type,Q2.QRear_type()); strcpy(sell_name,Q2.QRear_name()); sell_count=Q2.QRear_count();
list.Format(" %s %s %d",sell_type,sell_name,sell_count); m_sell_list.InsertString(-1,list); Q2.to_next(); num--;
m_sell_name.Format("%s",sell_name); }
UpdateData(false);
UpdateData(false);