-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenTables.cs
129 lines (114 loc) · 4.29 KB
/
OpenTables.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Business;
using System.Net;
namespace Client
{
public partial class OpenTables : Form
{
private HttpAskfor httpReq = new HttpAskfor();
public OpenTables()
{
InitializeComponent();
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
this.pictureBox1.Image = Properties.Resources.downpre;
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
this.pictureBox1.Image = Properties.Resources.down;
}
//关闭按钮
private void pictureBox1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void OpenTables_Load(object sender, EventArgs e)
{
this.pictureBox1.Image = Properties.Resources.down;
this.button1.Image = Properties.Resources.确定2;
this.numericUpDown1.MaxLength = 4;
}
//开桌操作
private void button1_Click(object sender, EventArgs e)
{
OpenDesk();
}
public void OpenDesk()
{
if (!string.IsNullOrEmpty(this.numericUpDown1.Text))
{
if (Int32.Parse(this.numericUpDown1.Text) > 0)
{
Desk d;
d = (Desk)this.Owner;
string[] tables = PassValue.desk;
Consumption cp = new Consumption();
int count = tables.Count();
cp.tables = new Table[count];
for (int i = 0; i < count; i++)
{
cp.tables[i] = new Table();
cp.tables[i].id = tables[i];
}
cp.people = int.Parse(this.numericUpDown1.Text.ToString());
HttpResult httpResult = httpReq.HttpPost("consumptions", cp);
if ((int)httpResult.StatusCode == 409)
{
d.CurrentChooseDesk.Clear();
MessageBox.Show("有桌子已被操作,请重新选择!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
else if ((int)httpResult.StatusCode == 401)
{
LoginBusiness lg = new LoginBusiness();
lg.LoginAgain();
return;
}
else if ((int)httpResult.StatusCode == 0)
{
MessageBox.Show(string.Format("{0}{1}", httpResult.StatusDescription, httpResult.OtherDescription), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
d.Refresh_Method();
d.ChooseCurrent();
this.Close();
PassValue.count_select_idle = 0;//被选中的桌子数量为0
PassValue.count_select_ordering = count;
PassValue.selectedtableid.Clear();
this.DialogResult = DialogResult.OK;
}
else if (Int32.Parse(this.numericUpDown1.Text) == 0)
{
MessageBox.Show("开桌人数不能为0!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
}
private void button1_MouseMove(object sender, MouseEventArgs e)
{
this.button1.Image = Properties.Resources.确定;
}
private void button1_MouseLeave(object sender, EventArgs e)
{
this.button1.Image = Properties.Resources.确定2;
}
private void numericUpDown1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!((e.KeyChar >= '0' && e.KeyChar <= '9') || e.KeyChar == '.' || e.KeyChar == (char)Keys.Back))
{
e.Handled = true;
}
if (e.KeyChar == 13)
{
OpenDesk();
}
}
}
}