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

📄 pipei.cpp

📁 零件交易系统 零件交易中心管理系统主要提供顾客和供应商之间完成零件交易的功能
💻 CPP
字号:
// PiPei.cpp : implementation file
//

#include "stdafx.h"
#include "Toolmangne.h"
#include "PiPei.h"

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

/////////////////////////////////////////////////////////////////////////////
// PiPei dialog

extern CToolmangneApp theApp;
PiPei::PiPei(CWnd* pParent /*=NULL*/)
	: CDialog(PiPei::IDD, pParent)
{
	//{{AFX_DATA_INIT(PiPei)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void PiPei::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(PiPei)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(PiPei, CDialog)
	//{{AFX_MSG_MAP(PiPei)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// PiPei message handlers

void PiPei::OnOK() 
{
	// TODO: Add extra validation here
	//CDialog::OnOK();
	CString sql = "SELECT OfferTobuy.CustomerID, Supply.ProviderID, Supply.PartID, OfferTobuy.Price, OfferTobuy.QUantity FROM OfferTobuy, Supply WHERE OfferTobuy.PartID = Supply.PartID and Supply.QUantity >= OfferToBuy.QUantity and OfferTobuy.Price = Supply.Price";
     //CString sql = "UPDATE  Provider Set PassWord ='"+m_pass+"',Address='"+m_addr+"',Tel='"+m_tell+"',Intro='"+m_info+"' WHERE  ID="+UserId;
	 
	 _RecordsetPtr	m_pRecordset;
	 m_pRecordset.CreateInstance(__uuidof(Recordset));
	 _variant_t RecordsAffected;
	 try
	 {
		 m_pRecordset->Open(_variant_t(sql),                // 查询DemoTable表中所有字段
			 theApp.m_pConnection.GetInterfacePtr(),	  // 获取库接库的IDispatch指针
			 adOpenDynamic,
			 adLockOptimistic,
			 adCmdText);
		 _variant_t var;
		 if(!m_pRecordset->BOF)
			 m_pRecordset->MoveFirst();
		 else
		 {
			 AfxMessageBox("没有交易信息");
			 return ;
		 }			
		 // 读入库中各字段并加入列表框中
		 CString tmp[5];
		 while(!m_pRecordset->adoEOF)
		 {
			 var = m_pRecordset->GetCollect("CustomerID");
			 if(var.vt != VT_NULL)
				 tmp[0] = (LPCSTR)_bstr_t(var);
			 var = m_pRecordset->GetCollect("ProviderID");
			 if(var.vt != VT_NULL)
				 tmp[1] = (LPCSTR)_bstr_t(var);
			 var = m_pRecordset->GetCollect("PartID");
			 if(var.vt != VT_NULL)
				 tmp[2] = (LPCSTR)_bstr_t(var);
			 var = m_pRecordset->GetCollect("Price");
			 if(var.vt != VT_NULL)
				 tmp[3] = (LPCSTR)_bstr_t(var);
			 var = m_pRecordset->GetCollect("Quantity");
			 if(var.vt != VT_NULL)
				 tmp[4] = (LPCSTR)_bstr_t(var);
			 //adddata(tmp[1],tmp[2],tmp[3],tmp[0],tmp[4]);
			 insert(tmp);
			 m_pRecordset->MoveNext();	 
		 }
	 }
	 catch(...)
	 {
		 AfxMessageBox("交易失败");
		 return ;
	 }
	 AfxMessageBox("交易成功");
}

void PiPei::insert(CString tmp[])
{
	CString sql = "insert into Business values('"+tmp[0]+"','"+tmp[1]+"','"+tmp[2]+"','"+tmp[3]+"','"+tmp[4]+"')";
	_RecordsetPtr	m_pRecordset;
	 m_pRecordset.CreateInstance(__uuidof(Recordset));
	 try
	 {
		 m_pRecordset->Open(_variant_t(sql),                // 查询DemoTable表中所有字段
			 theApp.m_pConnection.GetInterfacePtr(),	  // 获取库接库的IDispatch指针
			 adOpenDynamic,
			 adLockOptimistic,
			 adCmdText);
	 }
	 catch(...)
	 {
		 AfxMessageBox("交易失败");
		 return ;
	 }
}

⌨️ 快捷键说明

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