TakeOut.cpp
资源名称:SQLVC.rar [点击查看]
上传用户:biney012
上传日期:2022-05-09
资源大小:4592k
文件大小:3k
源码类别:
数据库系统
开发平台:
Visual C++
- // TakeOut.cpp: implementation of the CTakeOut class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Stock.h"
- #include "TakeOut.h"
- #include "ADOConn.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CTakeOut::CTakeOut()
- {
- Ttype = "";
- Pid = 0;
- Pprice = 0;
- Pnum = 0;
- Cid = 0;
- Sid = 0;
- EmpName = "";
- OptDate = "";
- }
- CTakeOut::~CTakeOut()
- {
- }
- //设置和读取成员变量
- CString CTakeOut::GetTtype()
- {
- return Ttype;
- }
- void CTakeOut::SetTtype(CString cTtype)
- {
- Ttype = cTtype;
- }
- int CTakeOut::GetPid()
- {
- return Pid;
- }
- void CTakeOut::SetPid(int iPid)
- {
- Pid = iPid;
- }
- float CTakeOut::GetPprice()
- {
- return Pprice;
- }
- void CTakeOut::SetPprice(float fPprice)
- {
- Pprice = fPprice;
- }
- int CTakeOut::GetPnum()
- {
- return Pnum;
- }
- void CTakeOut::SetPnum(int iPnum)
- {
- Pnum = iPnum;
- }
- int CTakeOut::GetCid()
- {
- return Cid;
- }
- void CTakeOut::SetCid(int iCid)
- {
- Cid = iCid;
- }
- int CTakeOut::GetSid()
- {
- return Sid;
- }
- void CTakeOut::SetSid(int iSid)
- {
- Sid = iSid;
- }
- CString CTakeOut::GetEmpName()
- {
- return EmpName;
- }
- void CTakeOut::SetEmpName(CString cEmpName)
- {
- EmpName = cEmpName;
- }
- CString CTakeOut::GetOptDate()
- {
- return OptDate;
- }
- void CTakeOut::SetOptDate(CString cOptDate)
- {
- OptDate = cOptDate;
- }
- //数据库操作
- int CTakeOut::HaveClient(CString cCid)
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置SELECT语句
- _bstr_t vSQL;
- vSQL = "SELECT * FROM TakeOut 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 CTakeOut::HaveProduct(CString cPid)
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置SELECT语句
- _bstr_t vSQL;
- vSQL = "SELECT * FROM TakeOut 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 CTakeOut::HaveStore(CString cSid)
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置SELECT语句
- _bstr_t vSQL;
- vSQL = "SELECT * FROM TakeOut 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 CTakeOut::sql_insert()
- {
- //连接数据库
- ADOConn m_AdoConn;
- m_AdoConn.OnInitADOConn();
- //设置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);
- _bstr_t vSQL;
- vSQL = "INSERT INTO TakeOut VALUES('" + Ttype + "'," + strPid + ","
- + strPprice + "," + strPnum + "," + strCid + "," + strSid + ",'"
- + EmpName + "','" + OptDate + "')";
- //执行INSERT语句
- m_AdoConn.ExecuteSQL(vSQL);
- //断开与数据库的连接
- m_AdoConn.ExitConnect();
- }