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

📄 s2009072032view.cpp

📁 my-project-VC++学生信息系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
				break;																	
			}																			
			scoreSet.MoveNext();															
		}																				
		scoreSet.Close();																	
		this->OnSeldataStuscore();	
		break;																			
	case 3:	
		m_ListCtrl.GetItemText(nSelItem, 0, strSel, 8);								
		courseSet.Open();																
		while(!courseSet.IsEOF())
		{														
			if(!strcmp(courseSet.m_courseno, strSel))
			{								
				courseSet.Delete();														
				break;																	
			}																			
			courseSet.MoveNext();															
		}																				
		courseSet.Close();																	
		this->OnSeldataCourseinfo();	
		break;																			
	}		
}

void CS2009072032View::OnOpModify() 
{
	// TODO: Add your command handler code here
	CListCtrl &m_ListCtrl=this->GetListCtrl();											
	POSITION posSel=m_ListCtrl.GetFirstSelectedItemPosition();						
	int nSelItem=-1;																
	if(posSel==NULL)
	{																
		MessageBox("还没有选择一个记录!");											
		return;																			
	}																					
	else																			
		nSelItem=m_ListCtrl.GetNextSelectedItem(posSel);							
																	
	CStudentSet stuSet;																
	CStuInfoDlg stuDlg;	
	CScoreDlg scoreDlg;
	CScoreSet scoreSet;
	CCourseSet courseSet;
	CCourseDlg courseDlg;
	char strSel[80];																
	switch(this->m_nSelTable)
	{													
	case 1:																			
		stuDlg.m_strOKText="修改";													
		m_ListCtrl.GetItemText(nSelItem, 1, strSel, 11);							
		stuSet.Open();																
		while(!stuSet.IsEOF())
		{														
			if(!strcmp(stuSet.m_studentno, strSel))
			{								
				stuDlg.m_strName=stuSet.m_studentname;								
				stuDlg.m_strNO=stuSet.m_studentno;									
				stuDlg.m_strSex=stuSet.m_xb;										
				stuDlg.m_strSpec=stuSet.m_special;									
				stuDlg.m_tBirth=stuSet.m_birthday;									
				if(stuDlg.DoModal()==IDOK)
				{											
					stuSet.Edit();														
					if(stuDlg.m_strSex=="男")											
						stuSet.m_xb=1;													
					else if(stuDlg.m_strSex=="女")									
						stuSet.m_xb=0;												
					stuSet.m_special=stuDlg.m_strSpec;								
					stuSet.m_birthday=stuDlg.m_tBirth;								
					stuSet.Update();												
				}																	
				break;																
			}																		
			stuSet.MoveNext();														
		}																			
		stuSet.Close();																
		this->OnSeldataStuinfo();													
		break;																		
	case 2:	
		scoreDlg.m_strOKText="修改";													
		m_ListCtrl.GetItemText(nSelItem, 0, strSel, 9);							
		scoreSet.Open();																
		while(!scoreSet.IsEOF())
		{														
			if(!strcmp(scoreSet.m_studentno, strSel))
			{								
				scoreDlg.m_strStuNO=scoreSet.m_studentno;								
				scoreDlg.m_strCourseNO=scoreSet.m_course;									
				scoreDlg.m_fScore=scoreSet.m_score;										
				scoreDlg.m_fCredit=scoreSet.m_credit;	
				if(scoreDlg.DoModal()==IDOK)
				{											
					scoreSet.Edit();																	
					scoreSet.m_score=scoreDlg.m_fScore;								
					scoreSet.m_credit=scoreDlg.m_fCredit;								
					scoreSet.Update();												
				}																	
				break;																
			}																		
			scoreSet.MoveNext();														
		}																			
		scoreSet.Close();																
		this->OnSeldataStuscore();	
		break;																	
	case 3:	
		courseDlg.m_strOKText="修改";													
		m_ListCtrl.GetItemText(nSelItem, 0, strSel, 8);							
		courseSet.Open();																
		while(!courseSet.IsEOF())
		{														
			if(!strcmp(courseSet.m_courseno, strSel))
			{								
				courseDlg.m_coursetype=courseSet.m_coursetype;								
				courseDlg.m_credit=courseSet.m_credit;									
				courseDlg.m_studyhours=courseSet.m_hours;										
				courseDlg.m_term.Format("%d", courseSet.m_openterm);	//?courseDlg.m_term=courseSet.m_openterm;									
				courseDlg.m_major=courseSet.m_special;
				courseDlg.m_courseNO=courseSet.m_courseno;
				courseDlg.m_coursename=courseSet.m_coursename;
				if(courseDlg.DoModal()==IDOK)
				{											
					courseSet.Edit();														
					courseSet.m_coursetype=courseDlg.m_coursetype;
					courseSet.m_credit=courseDlg.m_credit;
					courseSet.m_hours=courseDlg.m_studyhours;								
					courseSet.m_openterm=(char)atoi(courseDlg.m_term);
		 			courseSet.m_special=courseDlg.m_major;								
					courseSet.Update();												
				}																	
				break;																
			}																		
			courseSet.MoveNext();														
		}																			
		courseSet.Close();																
		this->OnSeldataCourseinfo();
		break;																	
	}			
}

void CS2009072032View::OnOpQuery() 
{
	// TODO: Add your command handler code here
	if(this->m_nSelTable==0)
	{												
		MessageBox("请先选择数据!");									
		return;														
	}																	
	CString strFilter="";												
	CQueryDlg querydlg;	
//	CStudentSet stuSet;
	switch(this->m_nSelTable)
	{											
	case 1:																
		querydlg.m_strFilterText="请输入要查询的学号:";
		querydlg.m_strOKText="查询";
		if(querydlg.DoModal()==IDOK)
		{
			
			strFilter.Format("studentno='%s'", querydlg.m_strQuery);
			this->DispAllRec(1, 1, strFilter);  
//			if(!stuSet.IsEOF())
//			MessageBox("没有查到你要找的学号记录!");
		}
		break;																
	case 2:	
		querydlg.m_strFilterText="请输入要查询的学号:";
		querydlg.m_strOKText="查询";
		if(querydlg.DoModal()==IDOK)
		{
			strFilter.Format("studentno='%s'", querydlg.m_strQuery);
			this->DispAllRec(2, 0, strFilter);
		}
		break;
	case 3:																		
		querydlg.m_strFilterText="请输入要查询的课程号:";
		querydlg.m_strOKText="查询";
		if(querydlg.DoModal()==IDOK)
		{
			strFilter.Format("courseno='%s'", querydlg.m_strQuery);
			this->DispAllRec(3, 0, strFilter);
		}
		break;																
	}

}

void CS2009072032View::OnOpStatistic() 
{
	// TODO: Add your command handler code here
	CScoreSet scoreset;	
	CStatisticDlg statisticDlg;
	CDrawDlg drawdlg;
	CString statistic;

	this->DispAllRec(2, 0);	
	this->m_nSelTable=2;
	statisticDlg.m_strOKText="统计";
	int nStat[5]={0};
	if(statisticDlg.DoModal()==IDOK)
	{
		statisticDlg.m_statistic.TrimLeft();										
		statistic.Format("course='%s'", statisticDlg.m_statistic);				
		this->DispAllRec(2,0, statistic);										
		drawdlg.m_nMode=statisticDlg.m_graphtype;											
		if(statisticDlg.m_graphtype==0)											
			drawdlg.m_strTitle="示例: 这是一个直方图";									
		else																		
			drawdlg.m_strTitle="示例: 这是一个圆饼图";									
		scoreset.m_strFilter.Format("course='%s'", statisticDlg.m_statistic);				
		scoreset.Open();																	
		while(!scoreset.IsEOF())
		{													
			if(scoreset.m_score<60.0)												
				nStat[0]++;														
			else if(scoreset.m_score<70.0)										
				nStat[1]++;											
			else if(scoreset.m_score<80.0)									
				nStat[2]++;										
			else if(scoreset.m_score<90.0)											
				nStat[3]++;														
			else																
				nStat[4]++;													
			scoreset.MoveNext();														
		}																		
		scoreset.Close();																
		drawdlg.m_uData.RemoveAll();											
		for(int i=0; i<5; i++)										
			drawdlg.m_uData.Add(nStat[i]);							
		drawdlg.DoModal();      

	}
	
}

void CS2009072032View::OnSeldataCourseinfo() 
{
	// TODO: Add your command handler code here
	MessageBox("Hello, in OnSeldataCourseinfo()");					
	this->DispAllRec(3, 0);											
	this->m_nSelTable=3;
}

void CS2009072032View::OnSeldataStuinfo() 
{
	// TODO: Add your command handler code here
	MessageBox("Hello, in OnSeldataStuinfo()");						
	this->DispAllRec(1, 0);											
	this->m_nSelTable=1;
}

void CS2009072032View::OnSeldataStuscore() 
{
	// TODO: Add your command handler code here
	MessageBox("Hello, in OnSeldataStuscore()");					
	this->DispAllRec(2, 0);											
	this->m_nSelTable=2;
}

void CS2009072032View::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	// TODO: Add your message handler code here
	CMainFrame* pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;	//获得主窗口指针	
	CMenu* pSysMenu=pFrame->GetMenu();		//获得程序窗口菜单指针				
	int nCount=pSysMenu->GetMenuItemCount();	//获得顶层菜单个数				
	int nSubMenuPos=-1;															
	for(int i=0; i<nCount; i++)
	{			                               //查找“文件”菜单						
		CString str;															
		pSysMenu->GetMenuString(i, str, MF_BYPOSITION);								
		if(str.Left(4)=="文件")
		{												
			nSubMenuPos=i;		
			break;											
		}
	}
	if(nSubMenuPos<0)	
		return;													
	pSysMenu->GetSubMenu(nSubMenuPos)->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, point.x, point.y, this);
}

void CS2009072032View::OnUpdateSeldataCourseinfo(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(this->m_nSelTable==3)														
		pCmdUI->SetCheck(TRUE);														
	else																			
		pCmdUI->SetCheck(FALSE);
}

void CS2009072032View::OnUpdateSeldataStuinfo(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(this->m_nSelTable==1)														
		pCmdUI->SetCheck(TRUE);														
	else																			
		pCmdUI->SetCheck(FALSE);
}

void CS2009072032View::OnUpdateSeldataStuscore(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(this->m_nSelTable==2)														
		pCmdUI->SetCheck(TRUE);														
	else																			
		pCmdUI->SetCheck(FALSE);
}

void CS2009072032View::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// TODO: Add your specialized code here and/or call the base class
/*	if(lHint==2)
	{

		Invalidate();
	}  */
	
}

⌨️ 快捷键说明

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