📄 addr.cpp
字号:
// Addr.cpp : implementation file
//
#include "stdafx.h"
#include "library.h"
#include "Addr.h"
#include "UserSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAddr dialog
extern CDatabase db;
CAddr::CAddr(CWnd* pParent /*=NULL*/)
: CDialog(CAddr::IDD, pParent)
{
//{{AFX_DATA_INIT(CAddr)
m_class = _T("");
m_rid = _T("");
m_name = _T("");
m_sex = 1;
//}}AFX_DATA_INIT
}
void CAddr::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAddr)
DDX_Text(pDX, IDC_EDIT_RCLASS, m_class);
DDV_MaxChars(pDX, m_class, 10);
DDX_Text(pDX, IDC_EDIT_RID, m_rid);
DDV_MaxChars(pDX, m_rid, 10);
DDX_Text(pDX, IDC_EDIT_RNAME, m_name);
DDV_MaxChars(pDX, m_name, 10);
DDX_Radio(pDX, IDC_RADIO_SEXFEMAL, m_sex);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAddr, CDialog)
//{{AFX_MSG_MAP(CAddr)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAddr message handlers
void CAddr::OnOK()
{
// TODO: Add extra validation here
UpdateData();
CUserSet *user=new CUserSet(&db);
user->Open();
if(user->CanAppend())
{
if(m_class.IsEmpty() || m_name.IsEmpty()||m_rid.IsEmpty() ||(m_sex==-1))
{
MessageBox("以上各项不能为空!");
return;
}
user->AddNew();
user->m_Authority=0;
user->m_Class=m_class;
user->m_UserID=m_rid;
user->m_Name=m_name;
user->m_Password=m_rid;
user->m_Sex=m_sex;
user->Update();
pview->RefreshReaderList();
MessageBox("添加成功!");
}
else
{
MessageBox("添加失败!");
return;
}
user->Close();
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -