stsbugdlg.cpp

来自「一个基于vc++和SQLServer2000的数据库应用程序 是个完备的汽车销」· C++ 代码 · 共 78 行

CPP
78
字号
// StsBugDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CarService.h"
#include "StsBugDlg.h"
#include "COMDEF.H"
#include "Columns.h"
#include "Column.h"
#include "_Recordset.h"

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

/////////////////////////////////////////////////////////////////////////////
// CStsBugDlg dialog


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


void CStsBugDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStsBugDlg)
	DDX_Control(pDX, IDC_ADODC1, m_Adodc);
	DDX_Control(pDX, IDC_DATAGRID1, m_Datagrid);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CStsBugDlg message handlers

BOOL CStsBugDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	RefreshData();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
// 更新数据
void CStsBugDlg::RefreshData()
{
	UpdateData(TRUE);
	// 设置Select语句
	CString cSource = "SELECT b.BugName AS 故障名称, "
		"(Case  When Count(l.BugId) Is Null Then 0 Else Count(l.BugId) End) AS 故障数量"
		" FROM Bugs b Left Join ListBug l On b.BugId=l.BugId"
		" Group By b.BugName ";

	//刷新ADO Data控件的记录源
	m_Adodc.SetRecordSource(cSource);
	m_Adodc.Refresh();
	
	//设置列宽度
	_variant_t vIndex;
	vIndex = long(0);
	m_Datagrid.GetColumns().GetItem(vIndex).SetWidth(200);
	vIndex = long(1);
	m_Datagrid.GetColumns().GetItem(vIndex).SetWidth(100);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?