YGJCXXB.CPP
资源名称:gongzi.rar [点击查看]
上传用户:ghostdhl
上传日期:2018-06-14
资源大小:9728k
文件大小:3k
源码类别:
数据库编程
开发平台:
Visual C++
- // Ygjcxxb.cpp: implementation of the CYgjcxxb class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "GZGLXT.h"
- #include "Ygjcxxb.h"
- #include "ADOConn.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CYgjcxxb::CYgjcxxb()
- {
- }
- CYgjcxxb::~CYgjcxxb()
- {
- }
- CString CYgjcxxb::GetYGid()
- {
- return YGid;
- }
- void CYgjcxxb::SetYGid(CString cYGid)
- {
- YGid=cYGid;
- }
- CString CYgjcxxb::GetYGxm()
- {
- return YGxm;
- }
- void CYgjcxxb::SetYGxm(CString cYGxm)
- {
- YGxm=cYGxm;
- }
- CString CYgjcxxb::GetSex()
- {
- return Sex;
- }
- void CYgjcxxb::SetSex(CString cSex)
- {
- Sex=cSex;
- }
- CString CYgjcxxb::GetWHcd()
- {
- return WHcd;
- }
- void CYgjcxxb::SetWHcd(CString cWHcd)
- {
- WHcd=cWHcd;
- }
- void CYgjcxxb::sql_insert()
- {
- ADOConn m_AdoConn;
- _bstr_t vSQL;
- vSQL="INSERT INTO Ygjcxxb(YGid,YGxm,Sex,WHcd)VALUES('"+YGid+"','"+YGxm+"','"+Sex+"','"+WHcd+"')";
- m_AdoConn.ExecuteSQL(vSQL);
- m_AdoConn.ExitConnect();
- }
- void CYgjcxxb::sql_delete(CString cYGid)
- {
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- CString sql;
- sql.Format("delete from ygjcxxb where ygid='%s'",cYGid);
- m_AdoConn.ExecuteSQL((_bstr_t)sql);
- m_AdoConn.ExitConnect();
- }
- int CYgjcxxb::HaveId(CString cYGid)
- {
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- CString sql;
- sql.Format("SELECT*FROM Ygjcxxb WHERE YGid='%s'",cYGid);
- _RecordsetPtr m_pRecordset;
- m_pRecordset=m_AdoConn.GetRecordSet((_bstr_t)sql);
- if(m_pRecordset->adoEOF)
- return -1;
- else
- return 1;
- m_AdoConn.ExitConnect();
- }
- int CYgjcxxb::Havename(CString cYGid,CString cYGxm)
- {
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- CString sql;
- sql.Format("SELECT*FROM Ygjcxxb WHERE YGid='%s' and YGxm='%s'",cYGid,cYGxm);
- _RecordsetPtr m_pRecordset;
- m_pRecordset=m_AdoConn.GetRecordSet((_bstr_t)sql);
- if(m_pRecordset->adoEOF)
- return -1;
- else
- return 1;
- m_AdoConn.ExitConnect();
- }
- void CYgjcxxb::Load_dep()
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置SQL语句
- _bstr_t vSQL;
- vSQL="SELECT*FROM Ygjcxxb ORDER BY ygid desc";
- _RecordsetPtr m_pRecordset;
- m_pRecordset=m_AdoConn.GetRecordSet(vSQL);
- //初始化数组
- a_ygid.RemoveAll();
- a_name.RemoveAll();
- a_sex.RemoveAll();
- a_whcd.RemoveAll();
- while(m_pRecordset->adoEOF==0)
- {
- a_ygid.Add((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ygid"));
- a_name.Add((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("ygxm"));
- a_sex.Add((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("sex"));
- a_whcd.Add((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("whcd"));
- m_pRecordset->MoveNext();
- }
- m_AdoConn.ExitConnect();
- }