Lesson title
Restaurant order system
Class setting requirements
- user management
- Membership registration
- Restaurant food category management
- Input, delete, modify and save the basic information (No., name, category, unit price) of dishes to a text file
- Fuzzy query based on dish category and name
- Customer ordering information (time, table number, dish number, quantity) management
- Customer checkout (discount for members)
- Count the sales volume of a dish one day
- Statistics of restaurant turnover by month, quarter and year
- System announcement management
Program operation interface
Core source code
// 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; //get SysTime 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("The sales volume of the day is:%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)) //If the file is opened successfully { fscanf(file,"%s%s",&date,&money); //Input file contents into memory CString d = date; //Give date value to d if(strcmp(d.Left(7),"2019-12")==0) //Judge whether it is December 2019 { m = m+atof(money); //Statistics of monthly income } } fclose(file); //Close file CString aaa; aaa.Format("The sales volume of the current month is:%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("Sales in the current quarter:%f",m); MessageBox(aaa); }Sea bombardment 155 original articles published, praised 103, visited 50000+ Private letter follow