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

📄 deteluser.cpp

📁 短信猫: 1确认短信Modem未连接电源
💻 CPP
字号:
// DetelUser.cpp : implementation file
//

#include "stdafx.h"
#include "短信群发.h"
#include "DetelUser.h"
#include "into.h"
#include "UserDialog.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDetelUser dialog


CDetelUser::CDetelUser(CWnd* pParent /*=NULL*/)
	: CDialog(CDetelUser::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDetelUser)
	m_userName = _T("");
	m_oldPwd = _T("");
	m_newPwd = _T("");
	m_authority = -1;
	//}}AFX_DATA_INIT
}


void CDetelUser::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDetelUser)
	DDX_Text(pDX, IDC_USERNAME1, m_userName);
	DDX_Text(pDX, IDC_OIDPWD, m_oldPwd);
	DDX_CBIndex(pDX, IDC_AUTHORITY1, m_authority);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDetelUser, CDialog)
	//{{AFX_MSG_MAP(CDetelUser)
	ON_BN_CLICKED(IDC_DELUSER_BUTTON, OnDeluserButton)
	ON_BN_CLICKED(IDC_MODIFYAUTH, OnModifyauth)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDetelUser message handlers

void CDetelUser::OnDeluserButton() 
{
	UpdateData();
	CADORecordset record;
	CString str;

	if (m_userName.IsEmpty())
	{
		AfxMessageBox("请选择一个帐户!");
		return;
	}

	if(m_userName==pub.m_strUserName)
	{
		AfxMessageBox("不能删除当前用户");
		return ;
	}

	record.Open(db.m_pConnection,"USERS",CADORecordset::openTable);
	while (!record.IsBOF())
	{
		record.GetFieldValue("USERNAME",str);
		if(str==m_userName)
		{
			record.Delete();
			if(record.Update())
			{
				CUserDialog * theUser = (CUserDialog *)(GetParent()->GetParent());
				theUser->printList();
				AfxMessageBox("用户删除成功!");
				m_userName.Empty();
				m_oldPwd.Empty();
				UpdateData(false);

				theUser->m_mdifyPwd->m_userName.Empty();
				theUser->m_mdifyPwd->m_oldPwd.Empty();
				
				theUser->m_mdifyPwd->UpdateData(false);

			}
			record.Close();
			return;
		}
		record.MoveNext();
	}
}

void CDetelUser::OnModifyauth() 
{
	UpdateData();
	CString strSql=_T("");
	BOOL ret;
	CADORecordset record;
	
	strSql.Format("update USERS set AUTHORITY = %d where USERNAME = '%s'",m_authority,m_userName);
	ret=record.Open(db.m_pConnection,strSql,0);
	if (ret)
	{
		CUserDialog * theUser = (CUserDialog *)(GetParent()->GetParent());
		theUser->printList();
		
	}
	else
	{
		AfxMessageBox("修改权限失败!");
	}
	record.Close();
	
}

⌨️ 快捷键说明

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