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

📄 bike.cpp

📁 网上购物.实现一个网上购物的程序.服务器通过Personal Web Server服务器软件在Internet上发布网上订购自行车的主业,用户可以通过该主页填写定单并发送给服务器,服务器获取用户定单并
💻 CPP
字号:
// BIKE.CPP - Implementation file for your Internet Server
//    bike Extension

#include "stdafx.h"
#include "bike.h"

///////////////////////////////////////////////////////////////////////
// The one and only CWinApp object
// NOTE: You may remove this object if you alter your project to no
// longer use MFC in a DLL.

CWinApp theApp;

///////////////////////////////////////////////////////////////////////
// command-parsing map

BEGIN_PARSE_MAP(CBikeExtension, CHttpServer)
	// TODO: insert your ON_PARSE_COMMAND() and 
	// ON_PARSE_COMMAND_PARAMS() here to hook up your commands.
	// For example:
	ON_PARSE_COMMAND(ConfirmOrder, CBikeExtension, ITS_PSTR)
	ON_PARSE_COMMAND_PARAMS("name") 
	ON_PARSE_COMMAND(ReturnBikeForm, CBikeExtension, ITS_PSTR ITS_PSTR ITS_I4 ITS_PSTR ITS_PSTR ITS_PSTR ITS_PSTR ITS_PSTR)
	ON_PARSE_COMMAND_PARAMS("name address quantity size top1=~ top2=~ top3=~ top4=~") 

	ON_PARSE_COMMAND(Default, CBikeExtension, ITS_EMPTY)
	DEFAULT_PARSE_COMMAND(Default, CBikeExtension)
END_PARSE_MAP(CBikeExtension)


///////////////////////////////////////////////////////////////////////
// The one and only CBikeExtension object

CBikeExtension theExtension;


///////////////////////////////////////////////////////////////////////
// CBikeExtension implementation

CBikeExtension::CBikeExtension()
{
}

CBikeExtension::~CBikeExtension()
{
}

BOOL CBikeExtension::GetExtensionVersion(HSE_VERSION_INFO* pVer)
{
	// Call default implementation for initialization
	CHttpServer::GetExtensionVersion(pVer);

	// Load description string
	TCHAR sz[HSE_MAX_EXT_DLL_NAME_LEN+1];
	ISAPIVERIFY(::LoadString(AfxGetResourceHandle(),
			IDS_SERVER, sz, HSE_MAX_EXT_DLL_NAME_LEN));
	_tcscpy(pVer->lpszExtensionDesc, sz);
	return TRUE;
}

BOOL CBikeExtension::TerminateExtension(DWORD dwFlags)
{
	// extension is being terminated
	//TODO: Clean up any per-instance resources
	return TRUE;
}

///////////////////////////////////////////////////////////////////////
// CBikeExtension command handlers

void CBikeExtension::Default(CHttpServerContext* pCtxt)
{
	StartContent(pCtxt);
	WriteTitle(pCtxt);

	*pCtxt << _T("This default message was produced by the Internet");
	*pCtxt << _T(" Server DLL Wizard. Edit your CBikeExtension::Default()");
	*pCtxt << _T(" implementation to change it.\r\n");

	EndContent(pCtxt);
}


void CBikeExtension::ConfirmOrder(CHttpServerContext* pCtxt, LPCTSTR pstrName)
{
	StartContent(pCtxt);
	WriteTitle(pCtxt);
	*pCtxt << "<p><center>订购成功</center>";
	*pCtxt << "<p> " << pstrName <<  ",您选购的货物将在一天之内送达.";
    *pCtxt << "<p>  谢谢光临网上车城, 欢迎下次再来.";
	// now retrieve the order from disk by name, then make the pizza
	// be prepared to delete the order after a while if the customer doesn't confirm
	m_cs.Lock(); // gotta be threadsafe
	  long int nTotal = ++m_nTotalPizzaOrders;
	m_cs.Unlock();
	*pCtxt << "<p>定单数量 = " << nTotal;
	EndContent(pCtxt);
}

 void CBikeExtension::ReturnBikeForm(CHttpServerContext* pCtxt, LPCTSTR pstrName,
				LPCTSTR pstrAddr, int nQuantity, LPCTSTR pstrSize,
				LPCTSTR pstrTop1, LPCTSTR pstrTop2,	LPCTSTR pstrTop3, LPCTSTR pstrTop4)
{

	StartContent(pCtxt);
	WriteTitle(pCtxt);
	if((strlen(pstrName) > 0) && (strlen(pstrAddr) > 0)) {
		*pCtxt << " 您填写的定单如下:";
		*pCtxt << "<p>姓名: " << pstrName;
		*pCtxt << "<p>地址: " << pstrAddr;
		*pCtxt << "<p>自行车数量: " <<(long int) nQuantity;
		*pCtxt << "<p>自行车种类: " << pstrSize;
		*pCtxt << "<p>附加商品: " << pstrTop1 << " " << pstrTop2 << " " << pstrTop3 << " " << pstrTop4;
		*pCtxt << "<p>价格共计(人民币): " << (long int) (nQuantity*200);
		*pCtxt << "<form action=\"bike.dll?ConfirmOrder\" method=POST>";
		*pCtxt << "<p><input type=\"hidden\" name=\"name\" value=\"" << pstrName << "\">"; // xref to original order
		*pCtxt << "<p><center><input type=\"submit\" value=\"  确认并提交  \"></center>";
		*pCtxt << "</form>";
		// store this order in a disk file or database, referenced by name
	}
	else {
		*pCtxt << " 请输入您的姓名和地址.";
	}
	EndContent(pCtxt);
}

// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CBikeExtension, CHttpServer)
	//{{AFX_MSG_MAP(CBikeExtension)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif	// 0



///////////////////////////////////////////////////////////////////////
// If your extension will not use MFC, you'll need this code to make
// sure the extension objects can find the resource handle for the
// module.  If you convert your extension to not be dependent on MFC,
// remove the comments arounn the following AfxGetResourceHandle()
// and DllMain() functions, as well as the g_hInstance global.

/****

static HINSTANCE g_hInstance;

HINSTANCE AFXISAPI AfxGetResourceHandle()
{
	return g_hInstance;
}

BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason,
					LPVOID lpReserved)
{
	if (ulReason == DLL_PROCESS_ATTACH)
	{
		g_hInstance = hInst;
	}

	return TRUE;
}

****/
LPCTSTR CBikeExtension::GetTitle() const
{
	return "Sample Extension";
}

⌨️ 快捷键说明

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