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

📄 viewstu_dlg.cpp

📁 数据库编程
💻 CPP
字号:
// ViewStu_dlg.cpp : implementation file
//

#include "stdafx.h"
#include "Course.h"
#include "ViewStu_dlg.h"
#include "Manager.h"

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

/////////////////////////////////////////////////////////////////////////////
// CViewStu_dlg dialog


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


void CViewStu_dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CViewStu_dlg)
	DDX_Control(pDX, IDC_VIEW_LIST, m_student_list);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CViewStu_dlg, CDialog)
	//{{AFX_MSG_MAP(CViewStu_dlg)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CViewStu_dlg message handlers

BOOL CViewStu_dlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_student_list.DeleteAllItems();
	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	m_student_list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
	//为了美观起见,显示纪录时需要表格线
	LV_COLUMN h;
	_RecordsetPtr m_recordset;
	CManager manager;
	h.mask=LVCF_FMT|LVCF_TEXT|LVCF_WIDTH;
	h.fmt=LVCFMT_CENTER;
	h.cx=90;

	m_recordset=manager.StudentView(course);
	h.pszText="学号";
	m_student_list.InsertColumn(0,&h);
	h.pszText="姓名";
	m_student_list.InsertColumn(1,&h);
	h.pszText="班级";
	m_student_list.InsertColumn(2,&h);
	
	CString s;
	_variant_t vnum,vname,vclass;
	while(!m_recordset->adoEOF)
	{
		vnum=m_recordset->GetCollect("学号");
		s=(LPCTSTR)_bstr_t(vnum);
		m_student_list.InsertItem(0,s);

		vname=m_recordset->GetCollect("姓名");
		s=(LPCTSTR)_bstr_t(vname);
		m_student_list.SetItemText(0,1,s);
				
		vclass=m_recordset->GetCollect("班级");
		s=(LPCTSTR)_bstr_t(vclass);
		m_student_list.SetItemText(0,2,s);

		m_recordset->MoveNext();
	}
	return TRUE;  // return TRUE  unless you set the focus to a control
}

⌨️ 快捷键说明

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