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

📄 orderctrl.cpp

📁 餐厅点菜系统
💻 CPP
字号:
// OrderCtrl.cpp: implementation of the COrderCtrl class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "OrderDishsSys.h"
#include "OrderCtrl.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

COrderCtrl::COrderCtrl()
{

}

COrderCtrl::~COrderCtrl()
{

}

void COrderCtrl::OrderDish(CString str1,CList<Dish,Dish&> &MList,CList<Dish,Dish&> &MList2,Dish d)
{

	POSITION pos = MList.GetHeadPosition();
	for(int i=0;i<MList.GetCount();i++)
	{
		if(str1==(MList.GetAt(pos).GetName()))
		{
			d.SetName((MList.GetAt(pos)).GetName());
			d.SetPrice((MList.GetAt(pos)).GetPrice());
			d.SetQuantity(1);
			MList2.AddHead(d);
			break;
		}
		MList.GetNext(pos);
	}
	pos = MList.GetHeadPosition();
	for(int i=0;i<MList.GetCount();i++)
	{
		if(str1==(MList.GetAt(pos).GetName()))
		{
			if((MList.GetAt(pos)).GetQuantity()-1>0)
			{
				d.SetName((MList.GetAt(pos)).GetName());
				d.SetPrice((MList.GetAt(pos)).GetPrice());
				d.SetQuantity((MList.GetAt(pos)).GetQuantity()-1);
				MList.SetAt(pos,d);
				break;
			}
			else
			{
				MList.RemoveAt(pos);
				break;
			}

		}
		MList.GetNext(pos);
	}
}

void COrderCtrl::Withdraw(CString str1,CString str2,CString str3,CList<Dish,Dish&> &MList,CList<Dish,Dish&> &MList2,Dish d)
{
	int s2=atoi(LPCTSTR(str2));
	int s3=atoi(LPCTSTR(str3));
	//
	d.SetName(str1);
	d.SetPrice(s2);
	d.SetQuantity(s3);
	int k=0;
	POSITION pos = MList2.GetHeadPosition();
	if(MList2.GetCount()==0)
		AfxMessageBox("无法撤消,你还没有真正点菜!!!");
	for(int i=0;i<MList2.GetCount();i++)
	{
		//AfxMessageBox((MList.GetAt(pos)).GetName());
		if(str1==(MList2.GetAt(pos).GetName()))
		{
			MList2.RemoveAt(pos);
			//k++;
			break;
		}
		MList2.GetNext(pos);
	}
	//修改原来的链表MList
	pos = MList.GetHeadPosition();
	for(int i=0;i<MList.GetCount();i++)
	{
		//AfxMessageBox((MList.GetAt(pos)).GetName());
		if(str1==(MList.GetAt(pos).GetName()))
		{
			d.SetName((MList.GetAt(pos)).GetName());
			d.SetPrice((MList.GetAt(pos)).GetPrice());
			d.SetQuantity((MList.GetAt(pos)).GetQuantity()+1);
			MList.SetAt(pos,d);
			k++;
			break;
		}
		MList.GetNext(pos);
	}
	//
	if(k==0&&str1!="总价")
	{
		MList.AddHead(d);
	}
	if(str1=="总价"&&MList2.GetCount()!=0)
	{
		AfxMessageBox("请选择要撤消的菜!");
	}

}

⌨️ 快捷键说明

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