StoreIn.cpp
资源名称:SQLVC.rar [点击查看]
上传用户:biney012
上传日期:2022-05-09
资源大小:4592k
文件大小:4k
源码类别:
数据库系统
开发平台:
Visual C++
- // StoreIn.cpp: implementation of the StoreIn class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Stock.h"
- #include "StoreIn.h"
- #include "ADOConn.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CStoreIn::CStoreIn()
- {
- SiType = "";
- Pid = 0;
- MakeDate = "";
- Pprice = 0;
- Pnum = 0;
- Cid = 0;
- Sid = 0;
- EmpName = "";
- OptDate = "";
- }
- CStoreIn::~CStoreIn()
- {
- }
- CString CStoreIn::GetSiType()
- {
- return SiType;
- }
- void CStoreIn::SetSiType(CString cSiType)
- {
- SiType = cSiType;
- }
- int CStoreIn::GetPid()
- {
- return Pid;
- }
- void CStoreIn::SetPid(int iPid)
- {
- Pid = iPid;
- }
- CString CStoreIn::GetMakeDate()
- {
- return MakeDate;
- }
- void CStoreIn::SetMakeDate(CString cMakeDate)
- {
- MakeDate = cMakeDate;
- }
- float CStoreIn::GetPprice()
- {
- return Pprice;
- }
- void CStoreIn::SetPprice(float fPprice)
- {
- Pprice = fPprice;
- }
- int CStoreIn::GetPnum()
- {
- return Pnum;
- }
- void CStoreIn::SetPnum(int iPnum)
- {
- Pnum = iPnum;
- }
- int CStoreIn::GetCid()
- {
- return Cid;
- }
- void CStoreIn::SetCid(int iCid)
- {
- Cid = iCid;
- }
- int CStoreIn::GetSid()
- {
- return Sid;
- }
- void CStoreIn::SetSid(int iSid)
- {
- Sid = iSid;
- }
- CString CStoreIn::GetEmpName()
- {
- return EmpName;
- }
- void CStoreIn::SetEmpName(CString cEmpName)
- {
- EmpName = cEmpName;
- }
- CString CStoreIn::GetOptDate()
- {
- return OptDate;
- }
- void CStoreIn::SetOptDate(CString cOptDate)
- {
- OptDate = cOptDate;
- }
- //数据库操作
- int CStoreIn::HaveClient(CString cCid)
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置SELECT语句
- _bstr_t vSQL;
- vSQL = "SELECT * FROM StoreIn WHERE Cid=" + cCid;
- //执行SELETE语句
- _RecordsetPtr m_pRecordset;
- m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
- //返回各列的值
- if (m_pRecordset->adoEOF)
- return -1;
- else
- return 1;
- //断开与数据库的连接
- m_AdoConn.ExitConnect();
- }
- int CStoreIn::HaveProduct(CString cPid)
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置SELECT语句
- _bstr_t vSQL;
- vSQL = "SELECT * FROM StoreIn WHERE Pid=" + cPid;
- //执行SELETE语句
- _RecordsetPtr m_pRecordset;
- m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
- //返回各列的值
- if (m_pRecordset->adoEOF)
- return -1;
- else
- return 1;
- //断开与数据库的连接
- m_AdoConn.ExitConnect();
- }
- int CStoreIn::HaveStore(CString cSid)
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置SELECT语句
- _bstr_t vSQL;
- vSQL = "SELECT * FROM StoreIn WHERE Sid=" + cSid;
- //执行SELETE语句
- _RecordsetPtr m_pRecordset;
- m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
- //返回各列的值
- if (m_pRecordset->adoEOF)
- return -1;
- else
- return 1;
- //断开与数据库的连接
- m_AdoConn.ExitConnect();
- }
- void CStoreIn::sql_insert()
- {
- CString strPid;
- strPid.Format("%d", Pid);
- CString strPprice;
- strPprice.Format("%f", Pprice);
- CString strPnum;
- strPnum.Format("%d", Pnum);
- CString strCid;
- strCid.Format("%d", Cid);
- CString strSid;
- strSid.Format("%d", Sid);
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置INSERT语句
- _bstr_t vSQL;
- vSQL = "INSERT INTO StoreIn VALUES('" + SiType + "'," + strPid + ",'"
- + MakeDate + "'," + strPprice + "," + strPnum + "," + strCid + "," + strSid + ",'"
- + EmpName + "','" + OptDate + "')";
- //执行INSERT语句
- m_AdoConn.ExecuteSQL(vSQL);
- //断开与数据库的连接
- m_AdoConn.ExitConnect();
- }