📄 coursedlg.cpp
字号:
// CourseDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DataBase.h"
#include "CourseDlg.h"
#include "CourseSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCourseDlg dialog
CCourseDlg::CCourseDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCourseDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCourseDlg)
m_cname = _T("");
m_cno = 0;
m_cpno = 0;
m_credit = 0;
//}}AFX_DATA_INIT
}
void CCourseDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCourseDlg)
DDX_Text(pDX, IDC_EDIT_CNAME, m_cname);
DDX_Text(pDX, IDC_EDIT_CNO, m_cno);
DDX_Text(pDX, IDC_EDIT_CPNO, m_cpno);
DDX_Text(pDX, IDC_EDIT_CREDIT, m_credit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCourseDlg, CDialog)
//{{AFX_MSG_MAP(CCourseDlg)
ON_BN_CLICKED(IDC_RESTART, OnRestart)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCourseDlg message handlers
void CCourseDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
CString strSQL;
int flag=0;
while(!flag){
CCourseSet m_recordset(&m_database);
strSQL.Format("select * from Course where Cno=%d",m_cno);
m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
if(m_recordset.GetRecordCount()==0)
{
strSQL.Format("insert into Course values(%d,\'%s\',%d,%d)",
m_cno,m_cname,m_cpno,m_credit);
m_database.ExecuteSQL(strSQL);
m_database.Close();
CDialog::OnOK();
flag=1;
}
else
m_cno++;
}
CDialog::OnOK();
}
void CCourseDlg::OnRestart()
{
// TODO: Add your control notification handler code here
m_cno=0;
m_cname.Empty();
m_cpno=0;
m_credit=0;
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -