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

📄 showscore.cpp

📁 应该会有很多漏洞的
💻 CPP
字号:
// ShowScore.cpp : implementation file
//

#include "stdafx.h"
#include "StuSys.h"
#include "ShowScore.h"

#include "StuSysDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CShowScore dialog


CShowScore::CShowScore(CWnd* pParent /*=NULL*/)
	: CDialog(CShowScore::IDD, pParent)
{
	//{{AFX_DATA_INIT(CShowScore)
	m_TotalScore_Show = 0.0f;
	m_AveScore_Show = 0.0f;
	m_ScoreNumberShow = _T("");
	m_ScoreNameShow = _T("");
	//}}AFX_DATA_INIT
}


void CShowScore::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CShowScore)
	DDX_Control(pDX, IDC_LIST1, m_ScoreShowList);
	DDX_Text(pDX, IDC_EDIT2, m_TotalScore_Show);
	DDX_Text(pDX, IDC_EDIT1, m_AveScore_Show);
	DDX_Text(pDX, IDC_NUMBER_SHOW, m_ScoreNumberShow);
	DDX_Text(pDX, IDC_NAME_SHOW, m_ScoreNameShow);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CShowScore, CDialog)
	//{{AFX_MSG_MAP(CShowScore)
	ON_BN_CLICKED(IDC_DELETE_BUTTON, OnDeleteButton)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CShowScore message handlers

BOOL CShowScore::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	//★★★★★★★★★★★★★★★★★★★★★★★
	CStuSysDlg* pMain=(CStuSysDlg*)AfxGetApp()->m_pMainWnd;
	POSITION pos=pMain->m_StuList.GetFirstSelectedItemPosition();
	int m_index=pMain->m_StuList.GetNextSelectedItem(pos);
	
	//初始化学生信息列表控件
	m_ScoreShowList.SetExtendedStyle(LVS_EX_TRACKSELECT|LVS_EX_ONECLICKACTIVATE|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
	//设置扩展属性(网格,一行全选……)
	m_ScoreShowList.SetBkColor(RGB(124,245,253));
	//设定背景色为RGB();
	//StuNums=0;
	m_ScoreShowList.InsertColumn(0,"课程",LVCFMT_RIGHT,165,0);
	m_ScoreShowList.InsertColumn(1,"教师",LVCFMT_CENTER,90,0);
	m_ScoreShowList.InsertColumn(2,"分数",LVCFMT_CENTER,90,0);

	int nCount = m_ScoreShowList.GetItemCount();
	for (int j=0;j < nCount;j++)
	{
		m_ScoreShowList.DeleteItem(0);
	}
	//将该学生的全部课程及分数显示
	float TotalScore=0;
	float AveScore=0;
	int trueindex=pMain->m_BaseInfo.m_StudentIndex[m_index];
	int max=pMain->m_Student[trueindex].SoreIndex;

	for(int i=0; i<max; i++)
	{
		m_ScoreShowList.InsertItem(i,pMain->m_Student[trueindex].m_ScoreName[i]);
		m_ScoreShowList.SetItemText(i,1,pMain->m_Student[trueindex].m_ScoreTeacher[i]);
		CString temp;
		temp.Format("%f",pMain->m_Student[trueindex].m_Score[i]);
		m_ScoreShowList.SetItemText(i,2,temp);
		TotalScore+=pMain->m_Student[trueindex].m_Score[i];
		//显示课程名和老师,分数
		if(pMain->m_Student[trueindex].m_ScoreName[i+1]=="")
			break;
	}
	if(max!=0)
	{
		AveScore=TotalScore/(float)(pMain->m_Student[trueindex].SoreIndex);
	}
	m_AveScore_Show=AveScore;
	m_TotalScore_Show=TotalScore;
	m_ScoreNameShow=pMain->m_Student[trueindex].m_StuName;
	m_ScoreNumberShow=pMain->m_Student[trueindex].m_StuNum;
	UpdateData(FALSE);
	//★★★★★★★★★★★★★★★★★★★★★★★
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CShowScore::OnDeleteButton() 
{
	// TODO: Add your control notification handler code here
	CStuSysDlg* pMain=(CStuSysDlg*)AfxGetApp()->m_pMainWnd;
	POSITION pos1=m_ScoreShowList.GetFirstSelectedItemPosition();
	int m_index1=m_ScoreShowList.GetNextSelectedItem(pos1);
	//显示列表中学生所选课程的索引
	POSITION pos2=pMain->m_StuList.GetFirstSelectedItemPosition();
	int m_index2=pMain->m_StuList.GetNextSelectedItem(pos2);
	//主框架列表中学生的索引
	if(m_index1==-1)
	{
		MessageBox("请选择要删除的课程!","提示");
		return;
	}
	if(MessageBox("是否确认删除?数据无法回复","提示",MB_OKCANCEL|MB_ICONWARNING)==IDOK)
	{
		m_ScoreShowList.DeleteItem(m_index1);
		int trueindex=pMain->m_BaseInfo.m_StudentIndex[m_index2];
		int StuCourIndex=pMain->m_Student[trueindex].SoreIndex;
		if(m_index2==StuCourIndex-1)
		{
			pMain->m_Student[trueindex].m_ScoreName[m_index2]="";
			pMain->m_Student[trueindex].m_ScoreTeacher[m_index2]="";
			pMain->m_Student[trueindex].m_Score[m_index2]=0;
			pMain->m_Student[trueindex].SoreIndex--;
		}
		else
		{
			pMain->m_Student[trueindex].SoreIndex--;
			StuCourIndex--;
			pMain->m_Student[trueindex].m_ScoreName[m_index2]=pMain->m_Student[trueindex].m_ScoreName[StuCourIndex];
			pMain->m_Student[trueindex].m_ScoreTeacher[m_index2]=pMain->m_Student[trueindex].m_ScoreTeacher[StuCourIndex];
			pMain->m_Student[trueindex].m_Score[m_index2]=pMain->m_Student[trueindex].m_Score[StuCourIndex];
			pMain->m_Student[trueindex].m_ScoreName[m_index2]="";
			pMain->m_Student[trueindex].m_ScoreTeacher[m_index2]="";
			pMain->m_Student[trueindex].m_Score[m_index2]=0;

		}
		//将记录真正的删除
		pMain->m_Course[m_index2].m_ToIndex++;
		MessageBox("请退出刷新成绩!","提示");
	}	
}

⌨️ 快捷键说明

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