📄 computes.cpp
字号:
// ComputeS.cpp : implementation file
//
#include "stdafx.h"
#include "aomanage.h"
#include "ComputeS.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
void Drawf3(CDC* pDC,CPrintInfo* pInfo,void* pVoid);
/////////////////////////////////////////////////////////////////////////////
// CComputeS dialog
CComputeS::CComputeS(CWnd* pParent /*=NULL*/)
: CParentDlg(CComputeS::IDD, pParent)
{
//{{AFX_DATA_INIT(CComputeS)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pStorage=new CDaoRecordset(&((CMainFrame*)AfxGetMainWnd())->m_db);
m_bFirst=TRUE;
}
void CComputeS::DoDataExchange(CDataExchange* pDX)
{
CParentDlg::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CComputeS)
DDX_Control(pDX, IDC_LIST1, m_ctlList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CComputeS, CParentDlg)
//{{AFX_MSG_MAP(CComputeS)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_CLOSE()
ON_MESSAGE(WM_PRINTEND,OnPrintEnd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CComputeS message handlers
BOOL CComputeS::OnInitDialog()
{
CParentDlg::OnInitDialog();
CDaoDatabase *db=&((CMainFrame*)AfxGetMainWnd())->m_db;
/*db->Execute("delete from stortemp");
db->Execute("delete from stortemp1");
db->Execute("delete from stortemp2");
db->Execute("insert into stortemp1 select code,sum(count) as scount from storage where ifin=true and left(code,1)='3' group by code");
db->Execute("insert into stortemp2 select code,sum(count) as scount from storage where ifin=false and left(code,1)='3' group by code");
db->Execute("INSERT INTO stortemp SELECT a.code, (a.scount - b.scount) AS scount FROM stortemp1 AS a, stortemp2 AS b WHERE a.code = b.code");
m_pStorage->Open(AFX_DAO_USE_DEFAULT_TYPE,"select right(code,6) as serial,pname,scount,demo from stortemp,product where stortemp.code=product.pcode order by serial");*/
db->Execute("delete from stortemp1");
db->Execute("delete from stortemp2");
db->Execute("insert into stortemp1 select code,count,ifin from storage where left(code,1)='3'");
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 left(right(code,8),4) as serial,pname,unit,scount,demo from stortemp2,product where stortemp2.code=product.pcode order by serial");
FIELD2 fdValue[4]={{"序号","serial"},\
{"品名","pname"},{"库存数","scount"},{"备注","demo"}
};
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 CComputeS::OnButton1()
{
m_PreFrame = new CMainFrameS(Drawf3,AfxGetMainWnd(),this,TRUE);
}
void CComputeS::OnButton5()
{
m_PreFrame = new CMainFrameS(Drawf3,AfxGetMainWnd(),this,FALSE);
m_PreFrame->ShowWindow(SW_SHOW);
m_PreFrame->UpdateWindow();
}
void CComputeS::OnPrint(CDC* pDC,CPrintInfo* pInfo)
{
CString strCaption="成品库存表";
int nWidth=pDC->GetDeviceCaps(HORZRES);
int nHeight=pDC->GetDeviceCaps(VERTRES);
int ghdf=pDC->GetDeviceCaps(LOGPIXELSY);
CRect rcClient(0,0,nWidth,nHeight);
if (m_bFirst)
{
CFont *pFt,*pFtOld;
pFt=new CFont;
pFt->CreateFont(-MulDiv(24,-pDC->GetDeviceCaps(LOGPIXELSY),72),
0,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,
OUT_STROKE_PRECIS,CLIP_STROKE_PRECIS,DRAFT_QUALITY,
VARIABLE_PITCH|FF_SWISS,_T("黑体"));
pFtOld=pDC->SelectObject(pFt);
rcClient.DeflateRect(0,100,0,0);
pDC->DrawText(strCaption,&rcClient,DT_CENTER|DT_SINGLELINE);
pDC->SelectObject(pFtOld);
m_pStorage->MoveFirst();
}
rcClient.DeflateRect(100,75,100,150);
int yDelta=rcClient.Height()%50;
rcClient.DeflateRect(0,0,0,yDelta);
pDC->Rectangle(&rcClient);
int nMarginX,nMarginY;
nMarginX=rcClient.left;
nMarginY=rcClient.top;
pDC->TextOut(nMarginX+50,nMarginY+20,"序号");
pDC->MoveTo(nMarginX+150,rcClient.top);
pDC->LineTo(nMarginX+150,rcClient.bottom);
pDC->TextOut(nMarginX+150+70,nMarginY+20,"名称、规格、型号");
pDC->MoveTo(nMarginX+600,rcClient.top);
pDC->LineTo(nMarginX+600,rcClient.bottom);
pDC->TextOut(nMarginX+600+50,nMarginY+20,"单位");
pDC->MoveTo(nMarginX+750,rcClient.top);
pDC->LineTo(nMarginX+750,rcClient.bottom);
pDC->TextOut(nMarginX+750+50,nMarginY+20,"库存数");
pDC->MoveTo(nMarginX+950,rcClient.top);
pDC->LineTo(nMarginX+950,rcClient.bottom);
pDC->TextOut(nMarginX+950+70,nMarginY+20,"备注");
int nDis=50;
COleVariant vVal;
CString strCount;
int i=1;
while (!m_pStorage->IsEOF())
{
if (nMarginY+nDis*i>=rcClient.bottom)
return;
pDC->MoveTo(nMarginX,nMarginY+nDis*i);
pDC->LineTo(rcClient.right,nMarginY+nDis*i);
m_pStorage->GetFieldValue("serial",vVal);
pDC->TextOut(nMarginX+50,nMarginY+nDis*i+10,(LPCTSTR)vVal.bstrVal);
m_pStorage->GetFieldValue("pname",vVal);
pDC->TextOut(nMarginX+150+30,nMarginY+nDis*i+10,(LPCTSTR)vVal.bstrVal);
m_pStorage->GetFieldValue("unit",vVal);
pDC->TextOut(nMarginX+600+62,nMarginY+nDis*i+10,(LPCTSTR)vVal.bstrVal);
m_pStorage->GetFieldValue("scount",vVal);
strCount.Format("%d",vVal.iVal);
pDC->TextOut(nMarginX+750+50,nMarginY+nDis*i+10,strCount);
m_pStorage->GetFieldValue("demo",vVal);
pDC->TextOut(nMarginX+950+50,nMarginY+nDis*(i++)+10,(LPCTSTR)vVal.bstrVal);
m_pStorage->MoveNext();
}
pDC->MoveTo(nMarginX,nMarginY+nDis*i);
pDC->LineTo(rcClient.right,nMarginY+nDis*i);
}
void Drawf3(CDC* pDC,CPrintInfo* pInfo,void* pVoid)
{
((CComputeS*)pVoid)->OnPrint(pDC,pInfo);
}
void CComputeS::OnButton2()
{
OnCancel();
}
void CComputeS::OnClose()
{
if (m_pStorage->IsOpen())
m_pStorage->Close();
CParentDlg::OnClose();
}
void CComputeS::OnPrintEnd(WPARAM wParam,LPARAM lParam)
{
if (wParam)
if (!m_pStorage->IsEOF())
{
m_bFirst=FALSE;
OnButton1();
}
else
m_bFirst=TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -