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

📄 liulan.cpp

📁 这是用VC++编成的学生成绩管理系统
💻 CPP
字号:
// liulan.cpp : implementation file
//

#include "stdafx.h"
#include "chenggong.h"
#include "liulan.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include"liulan.h"

#include"caozuo1.h"


/////////////////////////////////////////////////////////////////////////////
// Cliulan dialog


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


void Cliulan::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cliulan)
	DDX_Control(pDX, IDC_LIST1, m_ScoreList);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Cliulan, CDialog)
	//{{AFX_MSG_MAP(Cliulan)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cliulan message handlers

void Cliulan::OnButton1() 
{
	// TODO: Add your control notification handler code hereDWORD dwStyle;
        DWORD dwStyle;
	dwStyle=::GetWindowLong(m_ScoreList.m_hWnd,GWL_STYLE);
	// 设置新风格
	dwStyle|=LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS;
	::SetWindowLong(m_ScoreList.m_hWnd,GWL_STYLE,dwStyle);
	dwStyle=m_ScoreList.GetExtendedStyle();
	dwStyle|=LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT;
	m_ScoreList.SetExtendedStyle(dwStyle);
	// 确定列名
	m_ScoreList.InsertColumn(0,"学号",LVCFMT_CENTER);
    m_ScoreList.InsertColumn(1,"姓名",LVCFMT_CENTER);
	m_ScoreList.InsertColumn(2,"性别",LVCFMT_CENTER);
	m_ScoreList.InsertColumn(3,"专业",LVCFMT_CENTER);
	m_ScoreList.InsertColumn(4,"语文",LVCFMT_CENTER);
	m_ScoreList.InsertColumn(5,"数学",LVCFMT_CENTER);
    m_ScoreList.InsertColumn(6,"英语",LVCFMT_CENTER);

   
        	CRect rectList;
	// 取得ListControl控件的宽并分配列宽
	m_ScoreList.GetWindowRect(&rectList); 
	int width=rectList.right-rectList.left;
        m_ScoreList.SetColumnWidth(0,width/7);
        m_ScoreList.SetColumnWidth(1,width/7);
        m_ScoreList.SetColumnWidth(2,width/7);
        m_ScoreList.SetColumnWidth(3,width/7);
        m_ScoreList.SetColumnWidth(4,width/7);
	    m_ScoreList.SetColumnWidth(5,width/7);
	    m_ScoreList.SetColumnWidth(6,width/7);
   //显示代码:(显示代码)
        CString strSQL;
	strSQL="select stuID,name,sex,subject,Chinese,Math,English from jxgl1";
	m_ScoreList.DeleteAllItems();
	// 创建记录集
       Ccaozuo1 m_ScoreSet;
	// 记录学生序号
	int i=0;
	CString strTemp;
	try
	{
		if ( m_ScoreSet.IsOpen() )
		m_ScoreSet.Close();
		 m_ScoreSet.Open(CRecordset::snapshot,strSQL);

		 
		while ( !m_ScoreSet.IsEOF() )
		{
                                     		    // 设置ListCtrl记录的Item值

			m_ScoreList.InsertItem(i,m_ScoreSet.m_stuID);
			this->m_ScoreList.SetItemText(i,1,m_ScoreSet.m_name);
            this->m_ScoreList.SetItemText(i,2,m_ScoreSet.m_sex);
			this->m_ScoreList.SetItemText(i,3,m_ScoreSet.m_subject);
			strTemp.Format("%d",m_ScoreSet.m_Chinese);
			this->m_ScoreList.SetItemText(i,4,strTemp);
			strTemp.Format("%d",m_ScoreSet.m_Math);
			this->m_ScoreList.SetItemText(i,5,strTemp);
			strTemp.Format("%d",m_ScoreSet.m_English);
			this->m_ScoreList.SetItemText(i,6,strTemp);
			
			// 移到下一条记录
			m_ScoreSet.MoveNext();
			i++;
		}
		// 关闭记录集
		if ( m_ScoreSet.IsOpen() )
			m_ScoreSet.Close();
	}
	// 异常捕获
	catch ( CDBException *e )
	{
		//e->ReportError();
		e->Delete();
		return;
	}


	
}

⌨️ 快捷键说明

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