📄 dtotal.cpp
字号:
// DTotal.cpp : implementation file
//
#include "stdafx.h"
#include "qpglxt.h"
#include "DTotal.h"
#include "ExternDllHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CQpglxtApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDTotal dialog
CDTotal::CDTotal(CWnd* pParent /*=NULL*/)
: CDialog(CDTotal::IDD, pParent)
{
//{{AFX_DATA_INIT(CDTotal)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDTotal::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDTotal)
DDX_Control(pDX, IDC_LIST1, m_Grid);
DDX_Control(pDX, IDC_DTDATE2, m_DTDATE2);
DDX_Control(pDX, IDC_DTDATE1, m_DTDATE1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDTotal, CDialog)
//{{AFX_MSG_MAP(CDTotal)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDTotal message handlers
void CDTotal::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CDTotal::OnButton1()
{
CString sSQL,sDate1,sDate2;
CTime tDate1,tDate2;
this->m_DTDATE1.GetTime(tDate1);
this->m_DTDATE2.GetTime(tDate2);
sDate1=CTimeToCString(tDate1);
sDate2=CTimeToCString(tDate2);
sSQL.Format("SELECT 名称, 适用车型, 规格, 产地, Sum(销售数量) AS 合计销售数量, Sum(合计金额) AS 合计销售金额 FROM 销售排行 WHERE 销售时间 BETWEEN #%s# AND #%s# GROUP BY 名称, 适用车型, 规格, 产地 ORDER BY Sum(销售数量) DESC ",sDate1,sDate2);
rst.Open(sSQL,adCmdText);
CString sName;
m_Grid.DeleteAllItems();
for(int i=0;i<rst.GetRecordCount();i++)
{
m_Grid.InsertItem(i,"");
}
for(i=0;i<rst.GetRecordCount();i++)
{
rst.Move(i);
for(int c=0;c<rst.GetFieldCount()+1;c++)
{
if(c==0)
{
sName.Format("%d",i+1);
m_Grid.SetItemText(i,c,sName);
continue;
}
sName=rst.GetFieldValue(rst.GetFieldName(c-1));
m_Grid.SetItemText(i,c,sName);
}
}
}
BOOL CDTotal::OnInitDialog()
{
CDialog::OnInitDialog();
CString sHeadText[7]={"名次","商品名称","适用车型","规格","产地","数量","金额"};
int nWidth[7]={40,124,80,80,130,60,60};
m_Grid.ReadOnly(true);
//显示标题
for(int i=0;i<7;i++)
{
m_Grid.InsertColumn(i,sHeadText[i]);
m_Grid.SetColumnWidth(i,nWidth[i]);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDTotal::OnButton2()
{
CString sName,sDate,sDate1,sDate2;;
CTime tDate1,tDate2;
RxRecordset brst;
brst.Open("系统设置表");
sName=brst.GetFieldValue("公司名称");
sName=sName+"商品销售排行报表";
m_ps.MainCaptionFontSize=400;
m_ps.DeckCaptionFontSize=180;
this->m_DTDATE1.GetTime(tDate1);
this->m_DTDATE2.GetTime(tDate2);
sDate1=CTimeToCString(tDate1);
sDate2=CTimeToCString(tDate2);
sDate="销售时间在 "+sDate1+" 与 "+sDate2+" 之间";
m_ps.MainCaptionFontSize=400;
m_ps.DeckCaptionFontSize=180;
m_ps.MainCaption=sName;
m_ps.DeckCaptionNumber=1;
m_ps.DeckCaptions[0]=sDate;
m_ps.Grid=&m_Grid;
theApp.Print();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -