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

📄 badialog.cpp

📁 学生成绩的管理系统,可作为本科毕业生的毕业设计.也可在此基础上进行一些改进,使之更加实用.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	  m_Set.m_column9=(float)(m_Set.m_column8/5);
      this->Equal();
	  m_Set.Update();//Update()一定放在Equal()后
      m_Set.MoveFirst();
	  if(m_Set.m_column1==0)
	  {
		  m_Set.Delete();
		  m_Set.Requery();
	  } 
      m_Set.Requery();
	  this->Xuan();

	 }
}
	


void CBaDialog::OnDelect() 
{
	// TODO: Add your control notification handler code here
    CDelectDialog dlg;
	Selec=FALSE;
	if(dlg.DoModal()==IDOK)
	{
	if(dlg.m_nPass!=1234)
	AfxMessageBox("密码不正确!你没有权限删除记录");
    else
	{
	this->Select();
    m_Set.MoveFirst();
	BOOL sel=FALSE;
	do
	{
	 if(m_Set.m_column1!=dlg.m_nxue)
	 m_Set.MoveNext();	 
	 else
	 {
     m_nRecordCount-=1;
	 sel=TRUE;
     m_bSet.MoveFirst();
     this->Equal();
      m_Set.Delete();
	  m_Set.Requery();
	  break;
	 }
	}while(!m_Set.IsEOF());
 	if(sel==FALSE)
	{
	AfxMessageBox("没有此记录");
	return;
	}
	else
	this->Xuan();
	}
	}
	
}

void CBaDialog::OnFind() 
{
	// TODO: Add your control notification handler code here
CFinDialog dlg;
if( dlg.DoModal()==IDOK)
{ 
this->Select();
m_bSet.Close();

if(dlg.m_Getstring2==">=")
m_Set.m_strFilter.Format("[%s]>=%.2f",dlg.m_Getstring1,dlg.m_find);
if(dlg.m_Getstring2=="=")
m_Set.m_strFilter.Format("[%s]=%.2f",dlg.m_Getstring1,dlg.m_find);
if(dlg.m_Getstring2=="<=")
m_Set.m_strFilter.Format("[%s]<=%.2f",dlg.m_Getstring1,dlg.m_find);
m_ListCtrlx.DeleteAllItems();
m_Set.Requery();
if(m_Set.IsEOF())
{ 
 AfxMessageBox("没有符合条件的记录");
 m_Set.Close();
 return ;
 }
else
this->Show();

}
}

void CBaDialog::OnAll() 
{
	// TODO: Add your control notification handler code here
    
	this->Select();
	m_bSet.Close();
	
	m_Set.m_strFilter.Empty();
	m_Set.Requery();
	m_ListCtrlx.DeleteAllItems();
	this->Show();
}

void CBaDialog::OnEdit() 
{
	// TODO: Add your control notification handler code here
    
	CEditDialog dlg;
	if(dlg.DoModal()==IDOK)
	{
    if(strcmp(dlg.m_pass,"1234")!=0)
	AfxMessageBox("你没有权限更改记录!请重输入密码:");
    else
	{
	 this->Select();
	 m_Set.m_strFilter.Format("[学号]=%d",dlg.m_xue);
	 m_Set.Requery();
	 if(m_Set.IsEOF())
	 AfxMessageBox("没有此记录");
	  else
	  {   
	  for(int i=0;i<5;i++)
	  {
	  float p=0,q=0;
	 if(i==0)
	 {
	  p=dlg.m_fmaths;
	  q=m_Set.m_column3;
	 }
     if(i==1)
	 {
	 p=dlg.m_fphysical;
	 q=m_Set.m_column4;
	 }
   if(i==2)
   {
   p=dlg.m_fchemistry;
   q=m_Set.m_column5;
   }
	if(i==3)
	{ 
	p=dlg.m_fenglish;
	 q=m_Set.m_column6;
	}
    if(i==4)
	{	
	p=dlg.m_fpolitic;
	q=m_Set.m_column7;
	}

	m_bSet.Edit();
    m_bSet.m_column2=m_bSet.m_column2+p-q;
	m_bSet.m_column3=m_bSet.m_column2/m_nRecordCount;
	if(p>=60 && q<60)
	m_bSet.m_column4+=1;
	if(p<60 && q>=60)
	m_bSet.m_column4-=1;

	if(p>=80 && q<80)
	m_bSet.m_column5+=1;
	if(p<80 && q>=80)
	m_bSet.m_column5-=1;

    m_bSet.Update();
   if(!m_bSet.IsEOF())
   m_bSet.MoveNext();
   else
  break;
	  }

      m_Set.Edit();
     m_Set.m_column2=dlg.m_strName;
      m_Set.m_column3=dlg.m_fmaths;
      m_Set.m_column4=dlg.m_fphysical;
      m_Set.m_column5=dlg.m_fchemistry;
	  m_Set.m_column6=dlg.m_fenglish;
	  m_Set.m_column7=dlg.m_fpolitic;
	  m_Set.m_column8=dlg.m_fmaths+dlg.m_fphysical+dlg.m_fchemistry+dlg.m_fenglish+dlg.m_fpolitic;
	  m_Set.m_column9=(float)(m_Set.m_column8/5);
      m_Set.Update();
	  
	  }
      m_Set.m_strFilter.Empty();
	  m_bSet.Close();
	  m_Set.Close();
	  m_ListCtrlx.DeleteAllItems();
	  m_ListCtrlb.DeleteAllItems();
	  this->Select();
	  this->Show();
	  this->display();
	 }
	}
}


void CBaDialog::Sort(BOOL isAsc,int secol)
{   
	if(m_Set.IsOpen())
      m_Set.Close();
	this->Select();
	m_bSet.Close();
	CODBCFieldInfo fieldInfo;
	m_Set.GetODBCFieldInfo(secol,fieldInfo);
	if(isAsc)
	{
		m_Set.m_strSort=fieldInfo.m_strName+" ASC";
       m_bIsAsc=TRUE;
	}
	else
	{
		m_Set.m_strSort=fieldInfo.m_strName+" DESC";
		m_bIsAsc=FALSE;
	}
	m_Set.Requery();	

}



void CBaDialog::OnColumnclickList3(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	// TODO: Add your control notification handler code here
	if(FALSE== m_bS)
	{
	  int k= pNMListView->iSubItem;
	  Sort(!m_bIsAsc,k);
	  m_ListCtrlx.DeleteAllItems();
	  this->Show();
	}
	*pResult = 0;
}
void CBaDialog::OnCreateTabel(WPARAM wParam)
{   
	switch (wParam)
	{
	case 3:
		  m_Three=_T("三班");
		  m_cob.AddString("三班");
	      break;
	case 4:
		  m_Four="四班";
		  m_cob.AddString("四班");
		 break;
	case 5:
		m_Five="五班";
		m_cob.AddString("五班");
		break;
	case 6:
		m_Six="六班";
		m_cob.AddString("六班");
		break;
	case 7:
		m_Seven="七班";
		m_cob.AddString("七班");
		break;
	case 8:
		m_Eight="八班";
		m_cob.AddString("八班");
		break;

	default:
		break;
	}
   Save();
}





void CBaDialog::Save() 
{
	// TODO: Add your control notification handler code here
    
  CFile bFile;
  try
  {bFile.Open( lpszFile,CFile::modeCreate | CFile::modeReadWrite);
  }
  catch(CFileException* e)
  { 
	  CString str;
	  str.Format("%s",e->m_cause);
	  AfxMessageBox(str);
  }

  CArchive art(&bFile,CArchive::store);
  art.m_pDocument=(CDocument *)&bFile;//重要
  if (art.m_pDocument != NULL)
  Serialize(art);
 
}

void CBaDialog::Serialize(CArchive& ar) 
{   
	if (ar.IsStoring())
	{	// storing code
    ar<<m_Three<<m_Four<<m_Five<<m_Six<<m_Seven<<m_Eight;
	}
	else
	{	// loading code
   ar>>m_Three>>m_Four>>m_Five>>m_Six>>m_Seven>>m_Eight;
	}
}
void CBaDialog::OnDelTabel(WPARAM wParam)
{  int nIndex;
	switch (wParam)
	{
	case 3:
	m_Three=_T("");
    nIndex = 0;
   while ((nIndex=m_cob.FindString(nIndex, "三班")) != CB_ERR)
	{
     m_cob.DeleteString( nIndex );
	}
     break;
	case 4:
		  m_Four="";
		  nIndex = 0;
   while ((nIndex=m_cob.FindString(nIndex, "四班")) != CB_ERR)
	{
     m_cob.DeleteString( nIndex );
	}
		break;
	case 5:
		m_Five="";
    nIndex = 0;
   while ((nIndex=m_cob.FindString(nIndex, "五班"))!= CB_ERR)
	{
     m_cob.DeleteString( nIndex );
	}
	break;
	case 6:
	
		m_Six="";
    nIndex = 0;
   while ((nIndex=m_cob.FindString(nIndex,"六班" )) != CB_ERR)
	{
     m_cob.DeleteString( nIndex );
	}
		break;
	case 7:
	
		m_Seven="";
		nIndex = 0;
   while ((nIndex=m_cob.FindString(nIndex,"七班" )) != CB_ERR)
	{
     m_cob.DeleteString( nIndex );
	}
		break;
	case 8:
		m_Eight="";
	nIndex = 0;
   while ((nIndex=m_cob.FindString(nIndex,"八班" )) != CB_ERR)
	{
	   

     m_cob.DeleteString( nIndex );
	}
		break;

	default:
		break;
	}
   Save();
   
}


void CBaDialog::OnSelchangeCombo1() 
{
	// TODO: Add your control notification handler code here
	
}

void CBaDialog::OnExport() 
{
	// TODO: Add your control notification handler code here
    CFile aFile;
    CFileFind  fFind;
	BOOL bSuccess;
	CString str;
	str.Format("\\%s.txt",m_Getstring);
	CString lFile= sPath+str;
	
	
	bSuccess=fFind.FindFile(lFile);
	
	if(!bSuccess)
	 aFile.Open(lFile,CFile::modeCreate);
	else
	{
	aFile.Open(lFile,CFile::modeReadWrite);
    CArchive arr(&aFile,CArchive::store);
	this->Select();
	m_bSet.Close();
   int i=0;
  if(m_Set.m_column1==0)
  {  
	m_Set.Close();
	return ;
  }
  m_Set.MoveFirst();
  do
  { 
   CString str1,str2,str3,str4,str5,str6,str7,str8,str9;
   str1.Format("%d",m_Set.m_column1);
   str2=m_Set.m_column2;
   str3.Format("%.1f",m_Set.m_column3);
   str4.Format("%.1f",m_Set.m_column4);
   str5.Format("%.1f",m_Set.m_column5);
   str6.Format("%.1f",m_Set.m_column6);
   str7.Format("%.1f",m_Set.m_column7);
   str8.Format("%.1f",m_Set.m_column8);
   str9.Format("%.2f",m_Set.m_column9);
  
  arr<<str1<<m_Set.m_column2<<str3<<str4<<str5<<str6<<str7<<str8<<str9;
		
  i++;
  m_Set.MoveNext();
		
  }  while(!m_Set.IsEOF());
  m_Set.Close();
 
	} 

	aFile.Close();
}

⌨️ 快捷键说明

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