📄 detail.cpp
字号:
// Detail.cpp : implementation file
//
#include "stdafx.h"
#include "aomanage.h"
#include "Detail.h"
#include "SearchPs.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDetail dialog
CDetail::CDetail(CWnd* pParent /*=NULL*/)
: CParentDlg(CDetail::IDD, pParent)
{
//{{AFX_DATA_INIT(CDetail)
m_strPCode = _T("");
m_nCount = 0;
//}}AFX_DATA_INIT
m_pStorage=new CDaoRecordset(&((CMainFrame*)AfxGetMainWnd())->m_db);
}
void CDetail::DoDataExchange(CDataExchange* pDX)
{
CParentDlg::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDetail)
DDX_Control(pDX, IDC_LIST1, m_ctlList);
DDX_Text(pDX, IDC_EDIT1, m_strPCode);
DDX_Text(pDX, IDC_EDIT2, m_nCount);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDetail, CParentDlg)
//{{AFX_MSG_MAP(CDetail)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDetail message handlers
BOOL CDetail::OnInitDialog()
{
CParentDlg::OnInitDialog();
FIELD2 fdValue[6]={{"品号","pcode"},\
{"品名","pname"},\
{"规格,型号","ptype"},{"库存数","scount"},{"需数量","need"},{"剩/缺数量","remain"}
};
m_ctlList.SetField(6,fdValue,m_pStorage);
m_ctlList.SetHeader();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDetail::OnButton1()
{
CSearchPs *pDlg=new CSearchPs(this,1);
pDlg->DoModal();
}
void CDetail::OnButton2()
{
UpdateData(TRUE);
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");
CString strCount;
strCount.Format("%d",m_nCount);
CString strSQL="SELECT a.pcode, pname, ptype, scount,"+strCount+" * pcount AS need, scount - need AS remain FROM "+m_strPCode.Left(9)+" AS a, material AS b, stortemp2 AS c WHERE a.pcode = b.pcode AND a.pcode = c.code";
m_pStorage->Open(AFX_DAO_USE_DEFAULT_TYPE,strSQL);
m_ctlList.Refresh();
if (m_pStorage->IsOpen())
m_pStorage->Close();
}
void CDetail::OnButton3()
{
OnCancel();
}
void CDetail::OnClose()
{
if (m_pStorage->IsOpen())
m_pStorage->Close();
CParentDlg::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -