⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 report1dlg.cpp

📁 用VC++和SQL做的仓库管理系统
💻 CPP
字号:
// Report1Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "Stock.h"
#include "Report1Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CReport1Dlg dialog


CReport1Dlg::CReport1Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CReport1Dlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CReport1Dlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CReport1Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CReport1Dlg)
	DDX_Control(pDX, IDC_ADODC1, m_adodc1);
	DDX_Control(pDX, IDC_ADODC2, m_adodc2);
	DDX_Control(pDX, IDC_ADODC3, m_adodc3);
	DDX_Control(pDX, IDC_DATACOMBO1, m_datacombo1);
	DDX_Control(pDX, IDC_DATACOMBO2, m_datacombo2);
	DDX_Control(pDX, IDC_DATAGRID1, m_datagrid);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CReport1Dlg, CDialog)
	//{{AFX_MSG_MAP(CReport1Dlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CReport1Dlg message handlers
void CReport1Dlg::Refresh_Data()
{
	CString cTypeId;
	if (m_datacombo2.GetBoundText() == "")
		cTypeId = "0";
	else
		cTypeId = m_datacombo2.GetBoundText();
	//生成SELECT语句
	CString cSource;
	cSource = "SELECT p.Pname AS 产品名称,";
	cSource += " v1.SumNum AS 入库总量, v1.SumPrice AS 入库总金额,";
	cSource += " v2.SumNum AS 出库总量, v2.SumPrice AS 出库总金额,";
    cSource += " v3.SumNum AS 库存总量, p.PLow AS 库存下限, p.PHigh AS 库存上限";
    cSource += " FROM (((Product p LEFT JOIN v_StoreIn v1 ON p.Pid=v1.Pid)";
	cSource += " LEFT JOIN v_TakeOut v2 ON p.Pid=v2.Pid)";
    cSource += " LEFT JOIN v_ProInStore v3 ON p.Pid=v3.Pid)";
	cSource += " WHERE p.TypeId = " + cTypeId;
	//设置数据源
	m_adodc3.SetRecordSource(cSource);
	m_adodc3.Refresh();
}

BEGIN_EVENTSINK_MAP(CReport1Dlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CReport1Dlg)
	ON_EVENT(CReport1Dlg, IDC_DATACOMBO1, -600 /* Click */, OnClickDatacombo1, VTS_I2)
	ON_EVENT(CReport1Dlg, IDC_DATACOMBO2, -600 /* Click */, OnClickDatacombo2, VTS_I2)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CReport1Dlg::OnClickDatacombo1(short Area) 
{
	CString cUpper;
	cUpper = m_datacombo1.GetBoundText(); //读取选择类别的编号
	if (cUpper == "")
		cUpper = "0";
	m_datacombo2.SetText("");
	//设置二级类别的记录源
	m_adodc2.SetRecordSource("SELECT * FROM ProType WHERE UpperId=" + cUpper);
	m_adodc2.Refresh();	
	//刷新表格
	Refresh_Data();
}

void CReport1Dlg::OnClickDatacombo2(short Area) 
{
	//刷新表格
	Refresh_Data();	
}

BOOL CReport1Dlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	Refresh_Data();

	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 + -