C + + Course Design -- the design of student examination quality analysis system (MFC)

Lesson title

The design of quality analysis system for students' examination

Class setting requirements

  1. user management
  2. Entry, deletion and modification of student information
  3. Save the information in the current system in a file, and read the information saved in the file into the current system for users to use
  4. Query according to the following keywords: Student ID, name, class, course name
  5. Rank by student number, single subject score, total score and average score respectively
  6. Query the highest and lowest score of each course and the student number, name and class of corresponding students
  7. Count the number and proportion of students in different grades in a class

Program operation interface


Core code

void pupil::OnButton4() 
{
	// TODO: Add your control notification handler code here
UpdateData(true);
	int sel = m_pupil.GetSelectionMark();
	if(sel ==-1)
	{
		MessageBox("Please select the ticket to be modified!");
	}
	else if(m_id==""&&m_name==""&&m_sex==""&&m_age==""&&m_class==""&&m_chinese==""&&m_math==""&&m_english=="")

	{
		MessageBox("There is an error in the modification information, please modify it again!");
	}
else
{

    stu[sel].student_id = m_id;
    stu[sel].name = m_name;
	stu[sel].sex =m_sex;
    stu[sel].age = m_age;
	stu[sel].class_id= m_class;
	stu[sel].chinese= m_chinese;
	stu[sel].math= m_math;
	stu[sel].english= m_english;

    m_pupil.SetItemText(sel,0,m_id); 
    m_pupil.SetItemText(sel,1,m_name);  
	m_pupil.SetItemText(sel,2,m_sex);  
	m_pupil.SetItemText(sel,3,m_age); 
	m_pupil.SetItemText(sel,4,m_class);
	m_pupil.SetItemText(sel,5,m_chinese);
	m_pupil.SetItemText(sel,6,m_math);
	m_pupil.SetItemText(sel,7,m_english);

    MessageBox("Information modified successfully!");
}
	
}

void pupil::OnButton5() 
{
	// TODO: Add your control notification handler code here
		int n = m_pupil.GetSelectionMark();

	if(n<0)
		MessageBox("Please select the information to delete!");
	else
	{ 

        stu.erase(stu.begin()+n);
		m_pupil.DeleteItem(n);
  //Clear edit box
	m_id="";
	m_name="";
	m_sex="";
	m_age="";
	m_class="";
	m_chinese="";
	m_math="";
	m_english="";
	UpdateData(false);
MessageBox("Delete successful!");
	}

}

void pupil::OnButton6() 
{
	// TODO: Add your control notification handler code here
		// TODO: Add your control notification handler code here
    UpdateData(true);
	int flag = 1;
	int i = 0;
	if (stu.size()==0){
		flag = 0;
		MessageBox("No student information in current system!");
	}
    else if( m_id==""&&
		     m_name==""&&
		     m_class==""
			 )
	{
		flag = 0;
		MessageBox("Please enter query information!");
	}

	if (flag==1) {

		for( i = 0;i < stu.size();i++)
	{
		if ( stu[i].student_id == m_id||stu[i].name == m_name||stu[i].class_id == m_class)	
		{   
			MessageBox("Student information found successfully!");
            m_id = stu[i].student_id;
            m_name = stu[i].name;
			m_sex = stu[i].sex;
			m_age = stu[i].age;
			m_class = stu[i].class_id;
			m_chinese = stu[i].chinese;
			m_math = stu[i].math;
            m_english = stu[i].english;
			UpdateData(false);
			break;
		}
	}
	}

	if (i==stu.size()&&flag==1)
	{
      MessageBox("Student information not found!");
	}
}

bool sort_id(Student &a,Student &b)
{

return _ttoi(a.student_id)>_ttoi(b.student_id);
}
void pupil::OnButton9() 
{
			int index = m_x.GetCurSel();
			CString choice;
  m_x.GetLBText(index,choice); 
  if(choice=="Average score")
  {
	  std::sort(stu.begin(),stu.end(),Student::sort_ave_nums);
  }
  else if(choice=="Chinese")
  {
  	  	std::sort(stu.begin(),stu.end(),Student::sort_chinese);

  }
  else if(choice=="Mathematics")
  {
  	  	std::sort(stu.begin(),stu.end(),Student::sort_math);

  }
  else if(choice=="English?")
  {
  	  	std::sort(stu.begin(),stu.end(),Student::sort_english);

  }
  else if(choice=="Student ID")
  {
	  	std::sort(stu.begin(),stu.end(),Student::sort_id);

  }
  else  // Ranking of total scores
  {	  	std::sort(stu.begin(),stu.end(),Student::sort_nums);

  }
 	m_pupil.DeleteAllItems(); // Empty all 
for (int i=0;i<stu.size();i++)
{
 		m_pupil.InsertItem(i,stu[i].student_id);
		m_pupil.SetItemText(i,1,stu[i].name);
		m_pupil.SetItemText(i,2,stu[i].sex);
		m_pupil.SetItemText(i,3,stu[i].age);
		m_pupil.SetItemText(i,4,stu[i].class_id);
		m_pupil.SetItemText(i,5,stu[i].chinese);
		m_pupil.SetItemText(i,6,stu[i].math);
		m_pupil.SetItemText(i,7,stu[i].english);
		m_pupil.SetItemText(i,8,stu[i].nums);
		m_pupil.SetItemText(i,9,stu[i].ave_nums);

}
}


void pupil::OnButton11() 
{
	// TODO: Add your control notification handler code here
	
			int index = m_y.GetCurSel();
			CString choice;
  m_y.GetLBText(index,choice); 
  if(choice=="English?")
  {
	  std::sort(stu.begin(),stu.end(),Student::sort_english);
  }
  else if(choice=="Chinese")
  {
  	  	std::sort(stu.begin(),stu.end(),Student::sort_chinese);

  }
  else  // Mathematics
  {
  	  	std::sort(stu.begin(),stu.end(),Student::sort_math);

  }
  
  m_pupil.DeleteAllItems(); // Empty all 

 		m_pupil.InsertItem(0,stu[0].student_id);
		m_pupil.SetItemText(0,1,stu[0].name);
		m_pupil.SetItemText(0,2,stu[0].sex);
		m_pupil.SetItemText(0,3,stu[0].age);
		m_pupil.SetItemText(0,4,stu[0].class_id);
		m_pupil.SetItemText(0,5,stu[0].chinese);
		m_pupil.SetItemText(0,6,stu[0].math);
		m_pupil.SetItemText(0,7,stu[0].english);
		m_pupil.SetItemText(0,8,stu[0].nums);
		m_pupil.SetItemText(0,9,stu[0].ave_nums);

}
155 original articles published, praised 103, visited 50000+
Private letter follow

Posted by staffanolin on Sat, 08 Feb 2020 06:15:20 -0800