⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 useradddlg.cpp

📁 自己编写的迷你图书馆的完整程序.VC6MFC编写的,Windows界面.数据采用了Sqlserver2000.压缩包中已包括了数据库.先附加数据库再运行.
💻 CPP
字号:
// UserAddDlg.cpp : implementation file
//

#include "stdafx.h"
#include "BookLib.h"
#include "UserAddDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CUserAddDlg dialog


CUserAddDlg::CUserAddDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CUserAddDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CUserAddDlg)
	m_pwd = _T("");
	m_user = _T("");
	m_type = _T("");
	//}}AFX_DATA_INIT
	
}


void CUserAddDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUserAddDlg)
	DDX_Control(pDX, IDC_COMBO_TYPE, m_cmb_type);
	DDX_Text(pDX, IDC_EDIT_PWD, m_pwd);
	DDV_MaxChars(pDX, m_pwd, 20);
	DDX_Text(pDX, IDC_EDIT_USER, m_user);
	DDV_MaxChars(pDX, m_user, 10);
	DDX_CBString(pDX, IDC_COMBO_TYPE, m_type);
	DDV_MaxChars(pDX, m_type, 10);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUserAddDlg, CDialog)
	//{{AFX_MSG_MAP(CUserAddDlg)
	ON_BN_CLICKED(IDC_BTN_ADD, OnBtnAdd)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUserAddDlg message handlers


void CUserAddDlg::OnBtnAdd() 
{
	if(!UpdateData()) return;
	if(m_user.IsEmpty())
	{
		MessageBox("请输入用户名!","错误");
		return;
	}
	if(m_pwd.IsEmpty())
	{
		MessageBox("请输入密码!","错误");
		return;
	}
	if(m_type.IsEmpty())
	{
		MessageBox("请选择用户级别!","错误");
		return;
	}
	CString sql,user;
	sql.Format("Select * from 用户表 where userID='%s'",m_user);
	g_adoDB.ExecuteQueryValue(sql,user);//查询该用户名是否已经存在
	if(!user.IsEmpty())	//如果已经存在
	{
		MessageBox("该用户名已经存在!","错误");
		return;
	}

	sql.Format("Insert into 用户表 values('%s','%s','%s')",m_user,m_pwd,m_type);
	g_adoDB.Execute(sql);
	
	OnCancel();

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -