-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderManager.cs
More file actions
145 lines (131 loc) · 5.79 KB
/
Copy pathOrderManager.cs
File metadata and controls
145 lines (131 loc) · 5.79 KB
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
using System;
using System.Data;
using System.Windows.Forms;
namespace OrderSystem
{
public partial class OrderManager : Form
{
BasicInfo.Order order = new BasicInfo.Order();
public OrderManager()
{
InitializeComponent();
}
private void orderManagerPage_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = order.SearchOrders("All").Tables[0].DefaultView;//展示订单信息
SetdataGridView1HeadText();
}
private void SetdataGridView1HeadText()
{
dataGridView1.Columns[0].HeaderText = "桌号";
dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns[1].HeaderText = "顾客帐号";
dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns[2].HeaderText = "订单详情";
dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns[3].HeaderText = "订单总价";
dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns[4].HeaderText = "订单时间";
dataGridView1.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns[5].HeaderText = "结账状态";
dataGridView1.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
private void searchButton_Click(object sender, EventArgs e)
{
if (ComboBox.Text == string.Empty)
{
MessageBox.Show("查询类别不能为空!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
ComboBox.Focus();
return;
}
if (ComboBox.Text.Length == 1 && int.Parse(ComboBox.Text) >= 1 && int.Parse(ComboBox.Text) <= 10)
{
order.SerialNumber = int.Parse(ComboBox.Text);
DataSet dataSet = order.SearchOrders("SerialNumber");
dataGridView1.DataSource = dataSet.Tables[0].DefaultView;
this.SetdataGridView1HeadText();
if (dataSet == null || dataSet.Tables.Count == 0 || (dataSet.Tables.Count == 1 && dataSet.Tables[0].Rows.Count == 0))
{
orderDetailTextBox.Text = "";
}
else
{
orderDetailTextBox.Text = dataSet.Tables[0].Rows[0][2].ToString().Trim();
}
}
else
{
order.Customer = ComboBox.Text;
DataSet dataSet = order.SearchOrders("Customer");
dataGridView1.DataSource = dataSet.Tables[0].DefaultView;
this.SetdataGridView1HeadText();
if (dataSet == null || dataSet.Tables.Count == 0 || (dataSet.Tables.Count == 1 && dataSet.Tables[0].Rows.Count == 0))
{
orderDetailTextBox.Text = "";
}
else
{
orderDetailTextBox.Text = dataSet.Tables[0].Rows[0][2].ToString().Trim();
}
}
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
ComboBox.Text = dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();
orderDetailTextBox.Text = dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value.ToString();
totalCostLabel.Text = "本次消费总价为:" + dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value.ToString();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
if (ComboBox.Text.Trim() != "")
{
order.SerialNumber = int.Parse(ComboBox.Text.Trim());
order.Customer = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();
order.Details = dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value.ToString();
order.TotalCost = float.Parse(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value.ToString());
order.Time = dataGridView1[4, dataGridView1.CurrentCell.RowIndex].Value.ToString();
order.Settle();
MessageBox.Show("结账完成!");
dataGridView1.DataSource = order.SearchOrders("All").Tables[0].DefaultView;
SetdataGridView1HeadText();
}
else
{
MessageBox.Show("请选择正确的桌号!");
return;
}
}
private void ComboBoxzh_Click(object sender, EventArgs e)
{
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void orderDetailTextBox_TextChanged(object sender, EventArgs e)
{
}
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (ComboBox.Text.Trim() == "全部")
{
dataGridView1.DataSource = order.SearchOrders("All").Tables[0].DefaultView;
return;
}
if (ComboBox.Text.Trim() == "已结账订单")
{
dataGridView1.DataSource = order.SearchOrders("Settled").Tables[0].DefaultView;
return;
}
if (ComboBox.Text.Trim() == "未结账订单")
{
dataGridView1.DataSource = order.SearchOrders("Unsettled").Tables[0].DefaultView;
return;
}
}
private void OrderManager_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
Hide();
}
}
}