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

📄 mainfrm.cpp

📁 学生管理系统数据库源码。很好用哦
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "school.h"

#include "MainFrm.h"

//系统管理
#include "UserDlg.h"
#include "LoginDlg.h"
//基础设置
#include "departmentdlg.h"
#include "majordlg.h"
#include "classdlg.h"

//学生管理
#include "studentdlg.h"
#include "scholarshipdlg.h"
#include "HonorDlg.h"

//成绩管理
#include "examsubjectdlg.h"
#include "examtimedlg.h"
#include "examtypedlg.h"
#include "scoreinputdlg.h"
#include "scorequerydlg.h"
#include "ScoreClassStatDlg.h"
#include "ScoreSingleDlg.h"
#include "ScoreTotalDlg.h"

//学籍变动管理
#include "ChangeInsideDlg.h"
#include "ChangeLeaveDlg.h"
#include "ChangeSuspandDlg.h"
#include "ChangeTranserDlg.h"
#include "ChangeDegradeDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(ID_APP_EXIT, OnAppExit)
	ON_WM_CLOSE()
	ON_COMMAND(ID_BASE_DEPARTMENT, OnBaseDepartment)
	ON_UPDATE_COMMAND_UI(ID_BASE_DEPARTMENT, OnUpdateBaseDepartment)
	ON_COMMAND(ID_BASE_MAJOR, OnBaseMajor)
	ON_UPDATE_COMMAND_UI(ID_BASE_MAJOR, OnUpdateBaseMajor)
	ON_COMMAND(ID_BASE_CLASS, OnBaseClass)
	ON_UPDATE_COMMAND_UI(ID_BASE_CLASS, OnUpdateBaseClass)
	ON_COMMAND(ID_STUDENT_INFO, OnStudentInfo)
	ON_UPDATE_COMMAND_UI(ID_STUDENT_INFO, OnUpdateStudentInfo)
	ON_COMMAND(ID_STUDENT_SCHOLARSHIP, OnStudentScholarship)
	ON_UPDATE_COMMAND_UI(ID_STUDENT_SCHOLARSHIP, OnUpdateStudentScholarship)
	ON_COMMAND(ID_DATABASE_BACKUP, OnDatabaseBackup)
	ON_UPDATE_COMMAND_UI(ID_DATABASE_BACKUP, OnUpdateDatabaseBackup)
	ON_COMMAND(ID_DATABASE_RECOVER, OnDatabaseRecover)
	ON_UPDATE_COMMAND_UI(ID_DATABASE_RECOVER, OnUpdateDatabaseRecover)
	ON_COMMAND(ID_SCORE_INPUT, OnScoreInput)
	ON_UPDATE_COMMAND_UI(ID_SCORE_INPUT, OnUpdateScoreInput)
	ON_COMMAND(ID_SCORE_QUERY, OnScoreQuery)
	ON_UPDATE_COMMAND_UI(ID_SCORE_QUERY, OnUpdateScoreQuery)
	ON_COMMAND(ID_SCORE_CLASS_STAT, OnScoreClassStat)
	ON_UPDATE_COMMAND_UI(ID_SCORE_CLASS_STAT, OnUpdateScoreClassStat)
	ON_COMMAND(ID_SCORE_SET_EXAM, OnScoreSetExam)
	ON_UPDATE_COMMAND_UI(ID_SCORE_SET_EXAM, OnUpdateScoreSetExam)
	ON_COMMAND(ID_SCORE_SET_SUBJECT, OnScoreSetSubject)
	ON_UPDATE_COMMAND_UI(ID_SCORE_SET_SUBJECT, OnUpdateScoreSetSubject)
	ON_COMMAND(ID_SCORE_SET_TIME, OnScoreSetTime)
	ON_UPDATE_COMMAND_UI(ID_SCORE_SET_TIME, OnUpdateScoreSetTime)
	ON_COMMAND(ID_SYSTEM_USER, OnSystemUser)
	ON_UPDATE_COMMAND_UI(ID_SYSTEM_USER, OnUpdateSystemUser)
	ON_COMMAND(ID_SYSTEM_RELOAD, OnSystemReload)
	ON_UPDATE_COMMAND_UI(ID_SYSTEM_RELOAD, OnUpdateSystemReload)
	ON_COMMAND(ID_SYSTEM_QUIT, OnSystemQuit)
	ON_COMMAND(ID_STUDENT_HONOR, OnStudentHonor)
	ON_UPDATE_COMMAND_UI(ID_STUDENT_HONOR, OnUpdateStudentHonor)
	ON_COMMAND(ID_SCORE_STUDENT_SINGLE, OnScoreStudentSingle)
	ON_UPDATE_COMMAND_UI(ID_SCORE_STUDENT_SINGLE, OnUpdateScoreStudentSingle)
	ON_COMMAND(ID_SCORE_STUDENT_TOTAL, OnScoreStudentTotal)
	ON_UPDATE_COMMAND_UI(ID_SCORE_STUDENT_TOTAL, OnUpdateScoreStudentTotal)
	ON_COMMAND(ID_CHANGE_INSIDE, OnChangeInside)
	ON_UPDATE_COMMAND_UI(ID_CHANGE_INSIDE, OnUpdateChangeInside)
	ON_COMMAND(ID_CHANGE_LEAVE, OnChangeLeave)
	ON_UPDATE_COMMAND_UI(ID_CHANGE_LEAVE, OnUpdateChangeLeave)
	ON_COMMAND(ID_CHANGE_SUSPAND, OnChangeSuspand)
	ON_UPDATE_COMMAND_UI(ID_CHANGE_SUSPAND, OnUpdateChangeSuspand)
	ON_COMMAND(ID_CHANGE_TRANSFER, OnChangeTransfer)
	ON_UPDATE_COMMAND_UI(ID_CHANGE_TRANSFER, OnUpdateChangeTransfer)
	ON_COMMAND(ID_CHANGE_DEGRADE, OnChangeDegrade)
	ON_UPDATE_COMMAND_UI(ID_CHANGE_DEGRADE, OnUpdateChangeDegrade)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
/*	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
*/
	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
//	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
//	DockControlBar(&m_wndToolBar);

	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers


void CMainFrame::OnAppExit() 
{
	// TODO: Add your command handler code here
	OnClose();
}

void CMainFrame::OnClose() 
{
    if(AfxMessageBox("您确定要退出系统吗?",MB_OKCANCEL)==IDCANCEL)
	{
		return;
	}			
	CFrameWnd::OnClose();
}

void CMainFrame::OnBaseDepartment() 
{
	// TODO: Add your command handler code here
	CDepartmentDlg Dlg;
	Dlg.DoModal();
}

void CMainFrame::OnUpdateBaseDepartment(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);
}

void CMainFrame::OnBaseMajor() 
{
	// TODO: Add your command handler code here
	CMajorDlg Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateBaseMajor(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

void CMainFrame::OnBaseClass() 
{
	// TODO: Add your command handler code here
	CClassDlg Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateBaseClass(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

void CMainFrame::OnStudentInfo() 
{
	// TODO: Add your command handler code here
	CStudentDlg Dlg;
	Dlg.DoModal();		
}

void CMainFrame::OnUpdateStudentInfo(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CMainFrame::OnStudentScholarship() 
{
	// TODO: Add your command handler code here
	CScholarshipDlg Dlg;
	Dlg.DoModal();			
}

void CMainFrame::OnUpdateStudentScholarship(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CMainFrame::OnDatabaseBackup() 
{
	// TODO: Add your command handler code here
	if(AfxMessageBox("您确定要备份数据库吗?",MB_OKCANCEL)==IDCANCEL) 
	{ 
		return; 
	}   
	if(CopyFile(".\\school.mdb",".\\backup\\school.bak",FALSE)) 
		AfxMessageBox("数据库备份成功!"); 
	else 
		AfxMessageBox("数据库备份失败!"); 	
}

void CMainFrame::OnUpdateDatabaseBackup(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

void CMainFrame::OnDatabaseRecover() 
{
	// TODO: Add your command handler code here
	if(AfxMessageBox("还原数据库将覆盖原来的数据库。您确定要还原吗?",MB_OKCANCEL)==IDCANCEL) 
	{ 
		return; 
	}   
	if(CopyFile(".\\backup\\school.bak",".\\school.mdb",FALSE)) 
		AfxMessageBox("数据库还原成功!"); 
	else 
		AfxMessageBox("数据库还原失败!");  	
}

void CMainFrame::OnUpdateDatabaseRecover(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

void CMainFrame::OnScoreInput() 
{
	// TODO: Add your command handler code here
	CScoreInputDlg  Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateScoreInput(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}
//成绩查询
void CMainFrame::OnScoreQuery() 
{
	CScoreQueryDlg 	Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateScoreQuery(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CMainFrame::OnScoreClassStat() 
{
	// TODO: Add your command handler code here
	CScoreClassStatDlg	Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateScoreClassStat(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}
//设置考试类型
void CMainFrame::OnScoreSetExam() 
{
	CExamtypeDlg Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateScoreSetExam(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}
//设置考试科目
void CMainFrame::OnScoreSetSubject() 
{
	CExamSubjectDlg Dlg;
	Dlg.DoModal();		
}

void CMainFrame::OnUpdateScoreSetSubject(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}
//设置考试时间段
void CMainFrame::OnScoreSetTime() 
{
	// TODO: Add your command handler code here
	CExamtimeDlg Dlg;
	Dlg.DoModal();		
}

void CMainFrame::OnUpdateScoreSetTime(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

void CMainFrame::OnSystemUser() 
{
	// TODO: Add your command handler code here
	CUserDlg	Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateSystemUser(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

void CMainFrame::OnSystemReload() 
{
	// TODO: Add your command handler code here
	CLoginDlg Dlg;
	int nRes=0;
	do
	{
		nRes=Dlg.DoModal();
		//回到主界面
		if(nRes==IDOK)
			return;
		//退出系统
		if(nRes==IDCANCEL)
		{
			if(AfxMessageBox("您确定要退出系统吗?",MB_OKCANCEL)==IDCANCEL)
			{
				return;
			}		
			CFrameWnd::OnClose();
			return;
		}
	}while(1);	
}

void CMainFrame::OnUpdateSystemReload(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CMainFrame::OnSystemQuit() 
{
	// TODO: Add your command handler code here
	OnClose();
}

void CMainFrame::OnStudentHonor() 
{
	// TODO: Add your command handler code here
	CHonorDlg	Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateStudentHonor(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CMainFrame::OnScoreStudentSingle() 
{
	// TODO: Add your command handler code here
	CScoreSingleDlg  Dlg;
	Dlg.DoModal();
}

void CMainFrame::OnUpdateScoreStudentSingle(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CMainFrame::OnScoreStudentTotal() 
{
	// TODO: Add your command handler code here
	CScoreTotalDlg	Dlg;
	Dlg.DoModal();
}

void CMainFrame::OnUpdateScoreStudentTotal(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CMainFrame::OnChangeInside() 
{
	// TODO: Add your command handler code here
	CChangeInsideDlg	 Dlg;
	Dlg.DoModal();
}

void CMainFrame::OnUpdateChangeInside(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

void CMainFrame::OnChangeLeave() 
{
	// TODO: Add your command handler code here
	CChangeLeaveDlg	 Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateChangeLeave(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

void CMainFrame::OnChangeSuspand() 
{
	// TODO: Add your command handler code here
	CChangeSuspandDlg	 Dlg;
	Dlg.DoModal();		
}

void CMainFrame::OnUpdateChangeSuspand(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

void CMainFrame::OnChangeTransfer() 
{
	// TODO: Add your command handler code here
	CChangeTranserDlg	 Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateChangeTransfer(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

void CMainFrame::OnChangeDegrade() 
{
	// TODO: Add your command handler code here
	CChangeDegradeDlg	 Dlg;
	Dlg.DoModal();	
}

void CMainFrame::OnUpdateChangeDegrade(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	CSchoolApp*  ptheApp = (CSchoolApp *) AfxGetApp();
	pCmdUI->Enable(ptheApp->m_bIsAdmin);	
}

⌨️ 快捷键说明

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