?? adduser.cpp
字號:
// AddUser.cpp : implementation file
//
#include "stdafx.h"
#include "短信群發.h"
#include "AddUser.h"
#include "UserDialog.h"
#include "into.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAddUser dialog
CAddUser::CAddUser(CWnd* pParent /*=NULL*/)
: CDialog(CAddUser::IDD, pParent)
{
//{{AFX_DATA_INIT(CAddUser)
m_authority = 1;
m_pwd = _T("");
m_userName = _T("");
//}}AFX_DATA_INIT
}
void CAddUser::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAddUser)
DDX_CBIndex(pDX, IDC_AUTHORITY, m_authority);
DDX_Text(pDX, IDC_PWD1, m_pwd);
DDX_Text(pDX, IDC_USERNAME, m_userName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAddUser, CDialog)
//{{AFX_MSG_MAP(CAddUser)
ON_BN_CLICKED(IDC_ADDUSER_BUTTON, OnAdduserButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAddUser message handlers
void CAddUser::OnAdduserButton()
{
COleDateTime t3;
CString strSql;
CADORecordset record;
int id;
int maxid=-1;
BOOL ret;
BOOL flag=TRUE;
t3 = COleDateTime::GetCurrentTime();
strSql=_T("select * from USERS");
UpdateData(TRUE);
ret=pub.userNameCheck1(m_userName,12);
if(!ret)
{
m_userName.Empty();
m_pwd.Empty();
UpdateData(false);
return;
}
if (m_pwd.IsEmpty())
{
m_pwd="123456";
}
else
{
ret=pub.pwdCheck(m_pwd,12);
if (!ret)
{
m_pwd.Empty();
UpdateData(false);
flag=FALSE;
return;
}
}
ret=record.Open(db.m_pConnection,strSql,0);
if (ret && flag)
{
id=pub.GetMaxID("USERS")+1;
record.AddNew();
record.SetFieldValue("ID",id);
record.SetFieldValue("USERNAME",m_userName);
record.SetFieldValue("PASSWD",m_pwd);
record.SetFieldValue("AUTHORITY",m_authority);
record.SetFieldValue("CREATETIME",t3);
if (record.Update())
{
CUserDialog * theUser = (CUserDialog *)(GetParent()->GetParent());
theUser->printList();
AfxMessageBox("用戶添加成功!");
m_userName=_T("");
m_pwd=_T("");
UpdateData(false);
}
else
{
AfxMessageBox("添加用戶失敗!");
}
}
record.Close();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -