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哈哈~

發佈了162 篇原創文章 · 獲贊 112 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章