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

📄 admin.cpp

📁 人事管理系统VC6
💻 CPP
字号:
// Admin.cpp:
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "../Renshi.h"
#include "Admin.h"

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


/************************************************************/
extern CRenshiApp theApp;
CAdmin g_curAdmin;		//定义一个全局变量
/************************************************************/

CAdmin::CAdmin()
{
	UserName = "";
	Pwd = "";
	UserType = 0;
}

CAdmin::~CAdmin()
{
}


/************************************************************/
CString CAdmin::GetUserName()
{
	return UserName;
}

void CAdmin::SetUserName(CString cUserName)
{
	UserName = cUserName;
}

CString CAdmin::GetPwd()
{
	return Pwd;
}

void CAdmin::SetPwd(CString cPwd)
{
	Pwd = cPwd;
}

int CAdmin::GetUserType()
{
	return UserType;
}

void CAdmin::SetUserType(int iUserType)
{
	UserType = iUserType;
}


/******************数据库操作******************************************/
BOOL CAdmin::HaveName(CString cUserName)
{	
	_RecordsetPtr m_pRecordset = theApp.m_ado.GetRS("SELECT * FROM Admin WHERE UserName='" + cUserName + "'");
	
	if (m_pRecordset->adoEOF)
		return false;
	else
		return true;
}

	
void CAdmin::sql_insert()		//插入记录
{	
	CString strType;
	strType.Format("%d", UserType);

	theApp.m_ado.Execute("INSERT INTO Admin VALUES('" + UserName + "','" + Pwd + "'," + strType + ")");	
}



//根据用户名修改用户密码
void CAdmin::sql_updatePwd(CString cUserName)
{
	CString strType;
	strType.Format("%d", UserType);

	theApp.m_ado.Execute("UPDATE Admin SET Pwd='" + Pwd + "' WHERE UserName='" + cUserName + "'");
}

//根据用户名删除该用户
void CAdmin::sql_delete(CString cUserName)
{
	theApp.m_ado.Execute("DELETE FROM Admin WHERE UserName='" + cUserName	+ "'");	
}

//根据用户编号读取用户的信息
void CAdmin::GetData(CString cUserName)
{
	_RecordsetPtr m_pRecordset = theApp.m_ado.GetRS("SELECT * FROM Admin WHERE UserName='" + cUserName + "'");

	if (m_pRecordset->adoEOF)
	{
		CAdmin();
	}
	else
	{
		UserName = cUserName;
		Pwd = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Pwd");
		UserType = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("UserType"));
	}

}

void CAdmin::LoadAdminInfo()
{
	_RecordsetPtr pRS = theApp.m_ado.GetRS("SELECT * FROM Admin");

	a_UserName.RemoveAll();
	a_UserType.RemoveAll();

	while (pRS->adoEOF == 0)
	{
		a_UserName.Add(  (LPCTSTR)(_bstr_t)pRS->GetCollect("UserName"));
		a_UserType.Add((LPCTSTR)(_bstr_t)pRS->GetCollect("UserType"));
		
		pRS->MoveNext();
	}
}

⌨️ 快捷键说明

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