📄 storage.cpp
字号:
// Storage.cpp : implementation file
//
#include "stdafx.h"
#include "aomanage.h"
#include "Storage.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStorage dialog
CStorage::CStorage(CWnd* pParent /*=NULL*/)
: CParentDlg(CStorage::IDD, pParent)
{
//{{AFX_DATA_INIT(CStorage)
m_strPName = _T("");
m_strPCode = _T("");
//}}AFX_DATA_INIT
m_pStorage=new CDaoRecordset(&((CMainFrame*)AfxGetMainWnd())->m_db);
}
void CStorage::DoDataExchange(CDataExchange* pDX)
{
CParentDlg::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStorage)
DDX_Control(pDX, IDC_LIST1, m_ctlList);
DDX_Text(pDX, IDC_EDIT1, m_strPName);
DDX_Text(pDX, IDC_EDIT2, m_strPCode);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStorage, CParentDlg)
//{{AFX_MSG_MAP(CStorage)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStorage message handlers
BOOL CStorage::OnInitDialog()
{
CParentDlg::OnInitDialog();
CDaoDatabase *db=&((CMainFrame*)AfxGetMainWnd())->m_db;
db->Execute("delete from stortemp1");
db->Execute("delete from stortemp2");
db->Execute("insert into stortemp1 select code,count,ifin from storage");
db->Execute("update stortemp1 set count=-count where ifin=false");
db->Execute("insert into stortemp2 select code,sum(count) as scount from stortemp1 group by code");
m_pStorage->Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT a.code, b.pname, a.scount, b.ptype FROM stortemp2 AS a, material AS b WHERE a.code = b.pcode UNION SELECT a.code, b.pname, a.scount, b.pname FROM stortemp2 AS a, product AS b WHERE a.code = b.pcode");
FIELD2 fdValue[4]={{"品号","code"},\
{"品名","pname"},{"型号","ptype"},{"数量","scount"}
};
m_ctlList.SetField(4,fdValue,m_pStorage);
m_ctlList.Init();
//double nWidth[6]={1,1,1.6,0.7,0.7,1};
//m_ctlList.SetWidth(nWidth);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CStorage::OnButton1()
{
UpdateData(TRUE);
CString strFltr;
if (m_strPName.GetLength()&&!m_strPCode.GetLength())
{
m_pStorage->Close();
CString strFltr="SELECT a.code, b.pname, a.scount, b.ptype FROM stortemp2 AS a, material AS b WHERE a.code = b.pcode and b.pname='"+m_strPName+"' UNION SELECT a.code, b.pname, a.scount, b.pname FROM stortemp2 AS a, product AS b WHERE a.code = b.pcode and pname='"+m_strPName+"'";
m_pStorage->Open(AFX_DAO_USE_DEFAULT_TYPE,strFltr);
m_ctlList.Refresh();
}
if (m_strPCode.GetLength()&&!m_strPName.GetLength())
{
m_pStorage->Close();
CString strFltr="SELECT a.code, b.pname, a.scount, b.ptype FROM stortemp2 AS a, material AS b WHERE a.code = b.pcode and a.code='"+m_strPCode+"' UNION SELECT a.code, b.pname, a.scount, b.pname FROM stortemp2 AS a, product AS b WHERE a.code = b.pcode and a.code='"+m_strPCode+"'";
m_pStorage->Open(AFX_DAO_USE_DEFAULT_TYPE,strFltr);
m_ctlList.Refresh();
}
if (m_strPCode.GetLength()&&m_strPName.GetLength())
{
m_pStorage->Close();
CString strFltr="SELECT a.code, b.pname, a.scount, b.ptype FROM stortemp2 AS a, material AS b WHERE a.code = b.pcode and a.code='"+m_strPCode+"' and b.pname='"+m_strPName+"' UNION SELECT a.code, b.pname, a.scount, b.pname FROM stortemp2 AS a, product AS b WHERE a.code = b.pcode and a.code='"+m_strPCode+"' and pname='"+m_strPName+"'";
m_pStorage->Open(AFX_DAO_USE_DEFAULT_TYPE,strFltr);
m_ctlList.Refresh();
}
}
void CStorage::OnButton2()
{
OnCancel();
}
void CStorage::OnClose()
{
if (m_pStorage->IsOpen())
m_pStorage->Close();
CParentDlg::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -