-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.cpp
261 lines (215 loc) · 5.51 KB
/
order.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
// order.cpp : implementation file
//
#include "stdafx.h"
#include "restaurant.h"
#include "order.h"
#include"customer.h"
#include"table.h"
#include<fstream>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Corder dialog
Corder::Corder(CWnd* pParent /*=NULL*/)
: CDialog(Corder::IDD, pParent)
{
//{{AFX_DATA_INIT(Corder)
m_namecc = _T("");
m_notecc = _T("");
m_peoplecc = 0;
m_tablecc = 0;
m_timecc = _T("");
m_ordertime = _T("");
m_phones = _T("");
//}}AFX_DATA_INIT
}
void Corder::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Corder)
DDX_Text(pDX, IDC_cname, m_namecc);
DDX_Text(pDX, IDC_cnote, m_notecc);
DDX_Text(pDX, IDC_cpeople, m_peoplecc);
DDX_Text(pDX, IDC_ctable, m_tablecc);
DDX_Text(pDX, IDC_ctime, m_timecc);
DDX_Text(pDX, IDC_Eordertime, m_ordertime);
DDX_Text(pDX, IDC_cphone, m_phones);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Corder, CDialog)
//{{AFX_MSG_MAP(Corder)
ON_BN_CLICKED(IDC_BUTTON1, Onorderyes)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_Bs, OnBs)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Corder message handlers
void Corder::Onorderyes()
{
//导入餐桌数据
int i;
UpdateData(TRUE);
table T[50];
ifstream in("table.txt",ios_base::in);
for(i = 0;i<50;i++)
{
in>>T[i].tbnum;
in>>T[i].state;
in>>T[i].people;
}
in.close();
UpdateData(TRUE);
if(T[m_tablecc-1].state != 0)
{
AfxMessageBox("该餐桌不可预订!请重新输入!");
}
else
{
UpdateData(TRUE);//数据的读入
string str1(m_namecc.GetBuffer(10));
string str2(m_timecc.GetBuffer(10));
string str3(m_notecc.GetBuffer(100));
string str4(m_ordertime.GetBuffer(50));
string str5(m_phones.GetBuffer(100));
customer newc(str1,str4,str2,100,m_tablecc,str5,m_peoplecc,str3);
T[newc.tnum-1].state =1;//更改餐桌状态
ofstream outc("table.txt",ios_base::out);
for(i = 0;i<50;i++)
{
outc<<T[i].tbnum<<" "<<T[i].state<<" "<<T[i].people<<" "<<endl;
}
outc.close();
ofstream out;//保存客户信息到文件中
out.open("customer.txt",ios_base::app);
out<<newc.name<<" "<<newc.ordertime<<" "<<newc.time<<" "<<newc.money<<" "<<newc.tnum<<" "<<newc.phone<<" "<<newc.people<<" "<<newc.note<<endl;//将客户信息保存到文件中
out.close();
ifstream k("k.txt",ios_base::in);
int kk;
k>>kk;
kk += 1;
k.close();
ofstream k2("k.txt",ios_base::out);//更新客户信息数量
k2<<kk;
k2.close();
AfxMessageBox("预定成功!");
}
CDialog::OnCancel();
// TODO: Add your control notification handler code here
}
void Corder::OnButton2()
{
PostMessage(WM_CLOSE,0,0);
// TODO: Add your control notification handler code here
}
void Corder::OnBs()
{
int i =0;
CString s,q,temp;
string b,c,d,e,f,g,h;
table T[50];
ifstream in("table.txt",ios_base::in);//改变餐桌状态为不可预订
for(i = 0;i<50;i++)
{
in>>T[i].tbnum;
in>>T[i].state;
in>>T[i].people;
}
in.close();
temp +="空闲餐桌-可坐人数";
temp +="\r\n";
for(i = 0;i<50;i++)
{
if(T[i].state == 0)
{
s.Format (_T("%d"),T[i].tbnum,i+1);
q.Format (_T("%d"),T[i].people,i+1);
temp += "(";
temp +=s;
temp +=" ";
temp +=q;
temp +=")";
temp +=" ";
}
if((i+1)%10 == 0)
{
temp += "\r\n";
}
GetDlgItem(IDC_sunorder)->SetWindowText(temp);
}//UpdateData(FALSE);
}
void Corder::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{//防止调用重画函数
//CDialog::OnPaint();
CPaintDC dc(this);
CRect rect;
GetClientRect(&rect);//获取对话框长宽
CDC dcBmp;//定义并创建一个内存设备环境
dcBmp.CreateCompatibleDC(&dc);
CBitmap bmp11;
bmp11.LoadBitmap(IDB_BITMAP2);//载入资源中图片
BITMAP m_bitmap;
bmp11.GetBitmap(&m_bitmap);//将图片载入位图中
CBitmap *pbmpOld = dcBmp.SelectObject(&bmp11);
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcBmp,0,0,m_bitmap.bmWidth,m_bitmap.bmHeight,SRCCOPY);//使图像相形状可变
}
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
HBRUSH Corder::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
switch(pWnd->GetDlgCtrlID())
{
case IDC_STATIC1:
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
case IDC_STATIC2:
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
case IDC_STATIC3:
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
case IDC_STATIC4:
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
case IDC_STATIC5:
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
case IDC_STATIC6:
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
case IDC_STATIC7:
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
case IDC_STATIC8:
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,0));
return(HBRUSH)GetStockObject(HOLLOW_BRUSH);
default:break;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}