C++课程设计--餐厅点菜系统(MFC)

课设题目

餐厅点菜系统

课设要求

  1. 用户管理
  2. 会员注册
  3. 餐厅菜品类别管理
  4. 菜品基本信息 (编号、名称、类别、单价)的录入、删除、修改并将数据保存到文本文件中
  5. 按照菜品类别和菜名实现模糊查询
  6. 顾客点菜信息(时间、桌号、菜品编号、数量)管理
  7. 顾客消费结账(会员可打折)
  8. 统计某天某菜 品的销量
  9. 按月、季度、年统计餐厅营业额
  10. 系统公告管理

程序运行界面

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

核心源码

// TotalDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Order.h"
#include "TotalDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTotalDlg dialog


CTotalDlg::CTotalDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTotalDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTotalDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


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


BEGIN_MESSAGE_MAP(CTotalDlg, CDialog)
	//{{AFX_MSG_MAP(CTotalDlg)
	ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTotalDlg message handlers

void CTotalDlg::OnButton8() 
{
	// TODO: Add your control notification handler code here
	EndDialog(TRUE);
	
}

void CTotalDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	CString str; //获取系统时间
	CTime tm; tm=CTime::GetCurrentTime();
	str=tm.Format("%Y-%m-%d");

	FILE *file=fopen("sale.txt","r");
	int a=0;
	char date[20];char money[10];
	float m=0;
	while(!feof(file))
	{
		fscanf(file,"%s%s",&date,&money);
		if(strcmp(date,str)==0)
		{
			m = m+atof(money);
		}
	}
	fclose(file);

	CString aaa;
	aaa.Format("当天销售额为:%f",m);
	MessageBox(aaa);


	
}

void CTotalDlg::OnButton2() 
{
	// TODO: Add your control notification handler code here
	FILE *file=fopen("sale.txt","r");
	int a=0;
	char date[20];char money[10];
	float m=0;
	while(!feof(file))    //如果文件打开成功
	{
		fscanf(file,"%s%s",&date,&money);    //将文件内容输入到内存
		CString d = date;                      //把date值给d
		if(strcmp(d.Left(7),"2019-12")==0)      //判断是否为2019年12月
		{
			m = m+atof(money); //统计月收入
		}
	}
	fclose(file); //关闭文件

	CString aaa;
	aaa.Format("当月销售额为:%f",m);
	MessageBox(aaa);

	
}

void CTotalDlg::OnButton7() 
{
	FILE *file=fopen("sale.txt","r");
	int a=0;
	char date[20];char money[10];
	float m=0;
	while(!feof(file))
	{
		fscanf(file,"%s%s",&date,&money);
		CString d = date;
		if(strcmp(d.Left(7),"2019-10")==0||strcmp(d.Left(7),"2019-11")==0||strcmp(d.Left(7),"2019-12")==0)
		{
			m = m+atof(money);
		}
	}
	fclose(file);

	CString aaa;
	aaa.Format("当季销售额为:%f",m);
	MessageBox(aaa);
	
}

项目源码

需要源码的小伙伴请前往
微信公众号:海轰Pro
回复: 海轰
O(∩_∩)O哈哈~

发布了155 篇原创文章 · 获赞 110 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/weixin_44225182/article/details/103738105