Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Users.cpp
Package: final.rar [view]
Upload User: fangwenmm
Upload Date: 2014-06-18
Package Size: 6955k
Code Size: 3k
Category:
ERP-EIP-OA-Portal
Development Platform:
Visual C++
- // Users.cpp: implementation of the CUsers class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Stock.h"
- #include "Users.h"
- #include "ADOConn.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CUsers::CUsers()
- {
- UserName = "";
- Pwd = "";
- User_type = 0;
- }
- CUsers::~CUsers()
- {
- }
- CString CUsers::GetUserName()
- {
- return UserName;
- }
- void CUsers::SetUserName(CString cUserName)
- {
- UserName = cUserName;
- }
- CString CUsers::GetPwd()
- {
- return Pwd;
- }
- void CUsers::SetPwd(CString cPwd)
- {
- Pwd = cPwd;
- }
- int CUsers::GetUser_type()
- {
- return User_type;
- }
- void CUsers::SetUser_type(int iUser_type)
- {
- User_type = iUser_type;
- }
- //数据库操作
- int CUsers::HaveName(CString cUserName)
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置SELECT语句
- _bstr_t vSQL;
- vSQL = "SELECT * FROM Users WHERE UserName='" + cUserName + "'";
- //执行SELECT语句
- _RecordsetPtr m_pRecordset;
- m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
- if (m_pRecordset->adoEOF)
- return -1;
- else
- return 1;
- //断开与数据库的连接
- m_AdoConn.ExitConnect();
- }
- void CUsers::sql_insert()
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置INSERT语句
- CString strType;
- strType.Format("%d", User_type);
- _bstr_t vSQL;
- vSQL = "INSERT INTO Users VALUES('" + UserName + "','" + Pwd + "',"
- + strType + ")";
- //执行INSERT语句
- m_AdoConn.ExecuteSQL(vSQL);
- //断开与数据库的连接
- m_AdoConn.ExitConnect();
- }
- void CUsers::sql_updatePwd(CString cUserName)
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置UPDATE语句
- CString strType;
- strType.Format("%d", User_type);
- _bstr_t vSQL;
- vSQL = "UPDATE Users SET Pwd='" + Pwd + "' WHERE UserName='" + cUserName + "'";
- //执行UPDATE语句
- m_AdoConn.ExecuteSQL(vSQL);
- //断开与数据库的连接
- m_AdoConn.ExitConnect();
- }
- void CUsers::sql_delete(CString cUserName)
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置DELETE语句
- _bstr_t vSQL;
- vSQL = "DELETE FROM Users WHERE UserName='" + cUserName + "'";
- //执行DELETE语句
- m_AdoConn.ExecuteSQL(vSQL);
- //断开与数据库的连接
- m_AdoConn.ExitConnect();
- }
- //根据员工编号读取所有字段值
- void CUsers::GetData(CString cUserName)
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置SELECT语句
- _bstr_t vSQL;
- vSQL = "SELECT * FROM Users WHERE UserName='" + cUserName + "'";
- //执行SELETE语句
- _RecordsetPtr m_pRecordset;
- m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
- //返回各列的值
- if (m_pRecordset->adoEOF)
- CUsers();
- else
- {
- UserName = cUserName;
- Pwd = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Pwd");
- User_type = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("User_type"));
- }
- //断开与数据库的连接
- m_AdoConn.ExitConnect();
- }