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

📄 usereditdlg.cpp

📁 这是一个功能相对完善的电脑报价管理系统 的一个例子
💻 CPP
字号:
// UserEditDlg.cpp : implementation file
//

#include "stdafx.h"
#include "QuoteManage.h"
#include "UserEditDlg.h"
#include "UserInfo.h"

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

/////////////////////////////////////////////////////////////////////////////
// CUserEditDlg dialog


CUserEditDlg::CUserEditDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CUserEditDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CUserEditDlg)
	m_user = _T("");
	m_confirm = _T("");
	m_passwd = _T("");
	//}}AFX_DATA_INIT
}


void CUserEditDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUserEditDlg)
	DDX_Control(pDX, IDC_TYPE_COMBO, m_type);
	DDX_Text(pDX, IDC_USER_EDIT, m_user);
	DDX_Text(pDX, IDC_CONFIRM_EDIT, m_confirm);
	DDX_Text(pDX, IDC_PASSWD_EDIT, m_passwd);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUserEditDlg, CDialog)
	//{{AFX_MSG_MAP(CUserEditDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUserEditDlg message handlers

BOOL CUserEditDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	if(cId == "")
	{
		m_type.SetCurSel(1);
	}
	else
	{
		GetDlgItem(IDC_USER_EDIT)->EnableWindow(FALSE);
		GetDlgItem(IDC_PASSWD_EDIT)->EnableWindow(FALSE);
		GetDlgItem(IDC_CONFIRM_EDIT)->EnableWindow(FALSE);
		if(cType == "系统管理员")
			m_type.SetCurSel(0);
		else
			m_type.SetCurSel(1);
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

// 确定按钮
void CUserEditDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);

	CUserInfo cur;
	// 用户名有效性操作
	if(cId == "")
	{
		// 密码一致性
		if(m_passwd != m_confirm)
		{
			MessageBox("请确认密码输入是否正确,请重新输入");
			m_passwd = "";
			m_confirm = "";
			UpdateData(FALSE);
			GetDlgItem(IDC_PASSWD_EDIT)->SetFocus();
			return;
		}
		// 用户名为空
		if(m_user == "")
		{
			MessageBox("请输入用户名");
			GetDlgItem(IDC_USER_EDIT)->SetFocus();
			return;
		}
		// 用户名是否存在
		if(cur.IsExistUser(m_user))
		{
			MessageBox("此用户名已经存在,请换个密码来注册");
			m_user = "";
			UpdateData(FALSE);
			GetDlgItem(IDC_USER_EDIT)->SetFocus();
			return;
		}
	}
	else
	{
		if(m_user == "admin")
		{
			MessageBox("此用户为默认用户,不能修改");
			m_user = "";
			UpdateData(FALSE);
			GetDlgItem(IDC_USER_EDIT)->SetFocus();
			return;
		}
	}

	// 给cur赋值
	cur.UserName = m_user;
	cur.Passwd = m_passwd;
	cur.UserType = m_type.GetCurSel() + 1;

	// 添加
	if(cId == "")
	{
		cur.SqlInsert();
	}
	else
	{
		cur.SqlUpdate(m_user);
	}

	CDialog::OnOK();
}

⌨️ 快捷键说明

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