📄 register.cpp
字号:
// Register.cpp : implementation file
//
#include "stdafx.h"
#include "教学管理系统.h"
#include "Register.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Register dialog
Register::Register(CWnd* pParent /*=NULL*/)
: CDialog(Register::IDD, pParent)
{
//{{AFX_DATA_INIT(Register)
m_name = _T("");
m_password1 = _T("");
m_password2 = _T("");
//}}AFX_DATA_INIT
}
void Register::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Register)
DDX_Text(pDX, IDC_EDIT_ID, m_name);
DDX_Text(pDX, IDC_EDIT_PWD, m_password1);
DDX_Text(pDX, IDC_EDIT_REPWD, m_password2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Register, CDialog)
//{{AFX_MSG_MAP(Register)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Register message handlers
void Register::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
if(m_name.IsEmpty())
{
AfxMessageBox("请输入用户名");
return;
}
if(m_password1.IsEmpty())
{
AfxMessageBox("请输入密码");
return;
}
if(m_password1!=m_password2)
{
AfxMessageBox("输入的密码不一致");
return;
}
CString student;
CCONNECTION connection;
connection.Initialize();
student.Format("select * from 管理员 where 管理员id='%s'",m_name);
connection.Connect(student);
if(!(connection.m_pRecordset->adoEOF))
{
AfxMessageBox("已有该管理员的资料,注册失败");
connection.Unitialize();
return;
}
connection.m_pRecordset->AddNew();///添加新记录
connection.m_pRecordset->PutCollect("管理员id",_variant_t(m_name));
connection.m_pRecordset->PutCollect("密码",_variant_t(m_password1));
connection.m_pRecordset->Update();
connection.Unitialize();
MessageBox("注册用户成功!");
m_name="";
m_password1="";
m_password2="";
EndDialog(0);
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -