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