📄 dabate.cpp
字号:
// DAbate.cpp : implementation file
//
#include "stdafx.h"
#include "商品库存管理系统.h"
#include "DAbate.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _ConnectionPtr cnn;
/////////////////////////////////////////////////////////////////////////////
// CDAbate dialog
extern CMyApp theApp;
CDAbate::CDAbate(CWnd* pParent /*=NULL*/)
: CDialog(CDAbate::IDD, pParent)
{
//{{AFX_DATA_INIT(CDAbate)
//}}AFX_DATA_INIT
}
void CDAbate::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDAbate)
DDX_Control(pDX, IDC_EDTSum, m_EdtSum);
DDX_Control(pDX, IDC_EDTNUM, m_EdtNum);
DDX_Control(pDX, IDC_BUTClear, m_ButClear);
DDX_Control(pDX, IDC_LIST, m_Grid);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDAbate, CDialog)
//{{AFX_MSG_MAP(CDAbate)
ON_BN_CLICKED(IDC_BUTClear, OnBUTClear)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDAbate message handlers
void CDAbate::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CDAbate::OnBUTClear()
{
CString sSQL,sTime,sStore,sWare,sWareID;
int nStoreID;
CTime time;
int a=MessageBox("确定要清理这些过期商品吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION);
if(a!=1)
return;
time=time.GetCurrentTime();
sTime=theApp.CTimeToCString(time);
for(int i=0;i<m_Grid.GetItemCount();i++)
{
sWare=m_Grid.GetItemText(i,0);
sStore=m_Grid.GetItemText(i,1);
sWareID=theApp.NumberTOName("商品信息表","编号","名称",sWare);
nStoreID=theApp.NumberTOName("仓库信息表","名称",sStore);
sSQL.Format("UPdate 库存信息表 set 库存数量=0 WHERE 商品编号='%s' and 仓库编号=%d",sWareID,nStoreID);
try{
cnn->Execute((_bstr_t)sSQL,NULL,adCmdText);
}
catch(...)
{
MessageBox("清理操作失败!","系统提示",MB_OK|MB_ICONSTOP);
return;
}
}
m_EdtSum.SetWindowText("0");
m_EdtNum.SetWindowText("0");
m_Grid.Refresh();
MessageBox("仓库清理完毕!","系统提示",MB_OK|MB_ICONINFORMATION);
}
BOOL CDAbate::OnInitDialog()
{
CDialog::OnInitDialog();
int ColWidth[]={110,60,60,40,90,90};
CString sSQL,sTime,sSum,sNum;
int nSum=0,nNum=0;
CTime time;
time=time.GetCurrentTime();
sTime=theApp.CTimeToCString(time);
sSQL.Format("SELECT 商品名称,仓库名称,库存数量,单价,出厂日期,保质期 from 库存查询 WHERE 保质期<=#%s#",sTime);
try{
rst=cnn->Execute((_bstr_t)sSQL,NULL,adCmdText);
}
catch(...)
{
theApp.ADOError(rst);
}
if(theApp.GetRecordCount(rst)>0)
{
this->m_Grid.SetRecordset(rst);
for(int n=0;n<m_Grid.GetItemCount();n++)
{
sNum=m_Grid.GetItemText(n,2);
sSum=m_Grid.GetItemText(n,3);
nNum=nNum+atoi(sNum);
nSum=nSum+atoi(sNum)*atoi(sSum);
}
sNum.Format("%d",nNum);
sSum.Format("%d",nSum);
this->m_EdtNum.SetWindowText(sNum);
this->m_EdtSum.SetWindowText(sSum);
}
else
m_Grid.Clear();
for(int i=0;i<6;i++)
m_Grid.SetColumnWidth(i,ColWidth[i]);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -