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

📄 pageaddaccount.cpp

📁 短信群发系统
💻 CPP
字号:
// PageAddAccount.cpp : implementation file
//

#include "stdafx.h"
#include "notesendsystem.h"
#include "PageAddAccount.h"
#include "AccountManager.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPageAddAccount dialog


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


void CPageAddAccount::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPageAddAccount)
	DDX_Control(pDX, IDC_COMBO, m_combo);
	DDX_Text(pDX, IDC_PWD, m_pwd);
	DDX_Text(pDX, IDC_USER, m_user);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPageAddAccount, CDialog)
	//{{AFX_MSG_MAP(CPageAddAccount)
	ON_BN_CLICKED(IDC_ADDACCOUNT_BTN, OnAddaccountBtn)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPageAddAccount message handlers


void CPageAddAccount::OnAddaccountBtn() 
{
	UpdateData();
	if (m_user.GetLength() == 0)
	{
		MessageBox("用户名不能为空","提示");
		m_user.Empty();
		m_pwd.Empty();
		UpdateData(FALSE);
		return;
	}
	//若密码位空,设置默认为123456
	if (m_pwd.GetLength() == 0)
	{
		m_pwd = "123456";
	}
	if (m_pwd.GetLength() == 0)
	{
		MessageBox("密码必须小于6位","提示");
		m_user.Empty();
		m_pwd.Empty();
		UpdateData(FALSE);
		return;
	}
	
	CNoteSendSystemApp *pApp = (CNoteSendSystemApp *)AfxGetApp();
	int len = pApp->AccountInfoVect.size();
	for (int i=0; i<len; i++)
	{
		if (m_user == pApp->AccountInfoVect[i].user)
		{
			MessageBox("用户名已存在,","提示");
			m_user.Empty();
			m_pwd.Empty();
			UpdateData(FALSE);
			return;
		}
	}

	CString			timestr;
	COleDateTime	time;
	int				account_type;
	time		= COleDateTime::GetCurrentTime();
	if (m_combo.GetCurSel() == 0)
	{
		account_type = 0;
	}
	else
	{
		account_type = 1;
	}

	if (pApp->m_pConnection.AddAccount(m_user, m_pwd, account_type, time))
	{
		//在列表控件中显示
		CAccountManager	*acc_man = (CAccountManager	*)GetParent()->GetParent();
// 		AccountInfo			userinfo;
// 		userinfo.account_type = account_type;
// 		userinfo.user = m_user;
// 		userinfo.pwd = m_pwd;
// 		pApp->AccountInfoVect.push_back(userinfo);
		acc_man->UpdateListView();
		
		MessageBox("添加帐户成功","提示");
	}
	else
	{
		MessageBox("添加帐户失败","提示");
	}
	m_user.Empty();
	m_pwd.Empty();
	UpdateData(FALSE);
}

BOOL CPageAddAccount::OnInitDialog() 
{
	CDialog::OnInitDialog();
	m_combo.SetCurSel(0);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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