?? frmmain.cpp
字號:
// FrmMain.cpp : implementation file
//
#include "stdafx.h"
#include "Student.h"
#include "FrmMain.h"
#include "studentdlg.h"
#include "istudent.h"
#include "class.h"
#include "course.h"
#include "choice.h"
#include "teach.h"
#include "teaching.h"
#include "query.h"
#include "htmlhelp.h"
#include "about.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CStudentApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CFrmMain dialog
CFrmMain::CFrmMain(CWnd* pParent /*=NULL*/)
: CDialog(CFrmMain::IDD, pParent)
{
//{{AFX_DATA_INIT(CFrmMain)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CFrmMain::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFrmMain)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFrmMain, CDialog)
//{{AFX_MSG_MAP(CFrmMain)
ON_COMMAND(ID_ExpStudent, OnExpStudent)
ON_COMMAND(ID_ExpClass, OnExpClass)
ON_COMMAND(ID_ExpChoice, OnExpChoice)
ON_COMMAND(ID_ExpCourse, OnExpCourse)
ON_COMMAND(ID_ExpTeach, OnExpTeach)
ON_COMMAND(ID_ExpTeaching, OnExpTeaching)
ON_COMMAND(ID_ABOUT, OnAbout)
ON_COMMAND(ID_CONTENT, OnContent)
ON_COMMAND(ID_IChoice, OnIChoice)
ON_COMMAND(ID_IClass, OnIClass)
ON_COMMAND(ID_ICourse, OnICourse)
ON_COMMAND(ID_IStudent, OnIStudent)
ON_COMMAND(ID_ITeach, OnITeach)
ON_COMMAND(ID_ITeaching, OnITeaching)
ON_COMMAND(ID_QStudent, OnQStudent)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFrmMain message handlers
BOOL CFrmMain::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
CStudentDlg dlg;
dlg.DestroyWindow();
return CDialog::DestroyWindow();
}
void CFrmMain::OnExpStudent()
{
m_pRec->Open("select s_no as 學(xué)號,class_no as 班級號,s_name as 姓名,s_sex as 性別,s_birthday as 出生日期 from student",theApp.m_pConnect.GetInterfacePtr(),adOpenStatic,adLockOptimistic,adCmdText);
theApp.m_opt.ExportToExcel(m_pRec);
m_pRec->Close();
}
BOOL CFrmMain::OnInitDialog()
{
CDialog::OnInitDialog();
m_pRec.CreateInstance("ADODB.Recordset");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFrmMain::OnExpClass()
{
m_pRec->Open("select class_no as 班級號,class_name as 班級名稱,class_special as 所屬專業(yè),class_dept as 系別 from class",theApp.m_pConnect.GetInterfacePtr(),adOpenStatic,adLockOptimistic,adCmdText);
theApp.m_opt.ExportToExcel(m_pRec);
m_pRec->Close();
}
void CFrmMain::OnExpChoice()
{
m_pRec->Open("select s_no as 學(xué)號,course_no as 課程號,score as 成績 from choice",theApp.m_pConnect.GetInterfacePtr(),adOpenStatic,adLockOptimistic,adCmdText);
theApp.m_opt.ExportToExcel(m_pRec);
m_pRec->Close();
}
void CFrmMain::OnExpCourse()
{
m_pRec->Open("select course_no 課程號,course_name as 課程名稱,course_score as 學(xué)分 from course",theApp.m_pConnect.GetInterfacePtr(),adOpenStatic,adLockOptimistic,adCmdText);
theApp.m_opt.ExportToExcel(m_pRec);
m_pRec->Close();
}
void CFrmMain::OnExpTeach()
{
m_pRec->Open("select t_no as 教師號,t_name as 教師姓名,t_sex as 性別,t_birthday as 出生日期,t_title as 職稱 from teacher",theApp.m_pConnect.GetInterfacePtr(),adOpenStatic,adLockOptimistic,adCmdText);
theApp.m_opt.ExportToExcel(m_pRec);
m_pRec->Close();
}
void CFrmMain::OnExpTeaching()
{
m_pRec->Open("select course_no as 課程號,t_no as 教師號 from teaching",theApp.m_pConnect.GetInterfacePtr(),adOpenStatic,adLockOptimistic,adCmdText);
theApp.m_opt.ExportToExcel(m_pRec);
m_pRec->Close();
}
void CFrmMain::OnAbout()
{
CAbout dlg;
dlg.DoModal();
}
void CFrmMain::OnContent()
{
CString appPath;
GetModuleFileName(NULL, appPath.GetBuffer(MAX_PATH), MAX_PATH);
appPath.ReleaseBuffer();
int n = appPath.ReverseFind('\\');
CString helpFile;
helpFile = appPath.Left(n);
TCHAR c = helpFile.GetAt(n - 1);
if(c == '\\')
helpFile += "Help.chm";
else
helpFile += "\\Help.chm";
HtmlHelp(NULL, (LPCSTR)helpFile, HH_DISPLAY_TOPIC, 0);
}
void CFrmMain::OnIChoice()
{
CChoice IDlg;
IDlg.DoModal();
}
void CFrmMain::OnIClass()
{
CClass IDlg;
IDlg.DoModal();
}
void CFrmMain::OnICourse()
{
CCourse IDlg;
IDlg.DoModal();
}
void CFrmMain::OnIStudent()
{
CInput IDlg;
theApp.m_opt.m_iOptStatus=1;//addnew
theApp.m_opt.m_iTableFlag=1;//student
IDlg.DoModal();
}
void CFrmMain::OnITeach()
{
CTeach IDlg;
IDlg.DoModal();
}
void CFrmMain::OnITeaching()
{
CTeaching IDlg;
IDlg.DoModal();
}
void CFrmMain::OnQStudent()
{
CQuery dlg;
theApp.m_opt.m_iOptStatus=2;//update
theApp.m_opt.m_iTableFlag=1;//student
theApp.m_opt.m_sTableName="student";//student
dlg.DoModal();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -