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

📄 opctrl.cpp

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

#include "stdafx.h"
#include "OrderDishsSys.h"
#include "OpCtrl.h"

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

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

COpCtrl::COpCtrl()
{

}

COpCtrl::~COpCtrl()
{

}

void COpCtrl::addctrl(CString m_addname,int m_addprice,int m_addshu,CList<Dish,Dish&> &MList,Dish d)
{
	if(m_addname!=""&&m_addprice>0&&m_addshu>0)
	{
		POSITION pos = MList.GetHeadPosition();
		int k=0;
		for(int i=0;i<MList.GetCount();i++)
		{
			if(m_addname==(MList.GetAt(pos).GetName()))
			{
				//m_addprice=MList.GetAt(pos).GetPrice();
				d.SetQuantity((MList.GetAt(pos)).GetQuantity()+m_addshu);
				MList.SetAt(pos,d);
				k++;
				//m_addout.Format(_T("刚才输入的菜已入库品^-^\r\n菜名是:%s\r\n菜的数目是:%d\r\n菜的价格是:%d\r\n"),
				//	MList.GetAt(pos).GetName(),m_addshu,MList.GetAt(pos).GetPrice());
				break;
			}
			MList.GetNext(pos);
		}
		if(k==0)
		{
			d.SetName(m_addname);
	        d.SetPrice(m_addprice);
	        d.SetQuantity(m_addshu);
	        MList.AddHead(d);
	        POSITION pos = MList.GetHeadPosition();
	//
			//m_addout.Format(_T("刚才输入的菜已入库品^-^\r\n菜名是:%s\r\n菜的数目是:%d\r\n菜的价格是:%d\r\n"),MList.GetAt(pos).GetName(),MList.GetAt(pos).GetQuantity(),MList.GetAt(pos).GetPrice());
		}
	}
	else
	{
		AfxMessageBox("输入有误,请您重新输入!");
	}

}

void COpCtrl::modctrl(CList<Dish,Dish&> &MList,Dish d,POSITION pt,CString m_modname,int m_modprice,int m_modshu)
{
	d.SetName(m_modname);
	d.SetPrice(m_modprice);
	d.SetQuantity(m_modshu);
	MList.SetAt(pt,d);

}

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

void COpCtrl::DelCtrl(CString str1,CList<Dish,Dish&> &MList,Dish d)
{
	POSITION pos = MList.GetHeadPosition();
	for(int i=0;i<MList.GetCount();i++)
	{
		if(str1==(MList.GetAt(pos).GetName()))
		{
			MList.RemoveAt(pos);
			break;
		}
		MList.GetNext(pos);
	}

}

⌨️ 快捷键说明

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