-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllOrder.cs
199 lines (188 loc) · 6.46 KB
/
AllOrder.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
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
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 System.Web.Script.Serialization;
using System.Text.RegularExpressions;//正则表达式的引用
using Business;
namespace Client
{
public partial class AllOrder : Form
{
private string orderConsumptionid;
private HttpAskfor httpReq = new HttpAskfor();
public AllOrder(string _consumptionid)
{
InitializeComponent();
orderConsumptionid = _consumptionid;
}
#region 取消按钮
/// <summary>
/// 取消
/// </summary>
private void Btn_Canel_Click(object sender, EventArgs e)
{
Member mb = new Member();
mb = (Member)this.Owner;
mb.KeyPreview = true;
mb.panelChildren.Controls.Remove(this);
mb.panelInfor.Visible = true;
mb.lbTitle.Text = "支付信息";
mb.SetUp();
mb.Btn_Part.Enabled = mb.Btn_Plan.Enabled = mb.Btn_Fixed.Enabled = true;
mb.AddInformation();//重新加载打折信息
}
/// <summary>
/// 取消按钮的悬停
/// </summary>
private void Btn_Canel_MouseMove(object sender, MouseEventArgs e)
{
this.Btn_Canel.Image = Properties.Resources.取消2;
}
private void Btn_Canel_MouseLeave(object sender, EventArgs e)
{
this.Btn_Canel.Image = Properties.Resources.取消;
}
#endregion
#region 输入框的变化
/// <summary>
/// 输入框文本变化事件
/// </summary>
private void TxtDiscount_TextChanged(object sender, EventArgs e)
{
if (!Regex.Match(this.TxtDiscount.Text.Trim(), "^\\d+$").Success)//利用正则表达式控制只能输入数字
{
this.TxtDiscount.Text = "";
}
else
{
if (this.TxtDiscount.Text != "" && this.TxtDiscount.Text != null && Int32.Parse(this.TxtDiscount.Text) > 0 && Int32.Parse(this.TxtDiscount.Text) < 100)
{
this.Btn_Ok.Image = Properties.Resources.确定2;
}
}
if (string.IsNullOrEmpty(this.TxtDiscount.Text))
{
this.Btn_Ok.Image = Properties.Resources.确定3;
this.Btn_Ok.Enabled = false;
}
else
{
this.Btn_Ok.Image = Properties.Resources.确定2;
this.Btn_Ok.Enabled = true;
}
}
/// <summary>
/// 解除快捷键
/// </summary>
private void TxtDiscount_Enter(object sender, EventArgs e)
{
//Member mb = new Member();
//mb = (Member)this.Owner;
//mb.KeyPreview = false;
}
#endregion
#region 确认按钮
/// <summary>
/// 确认
/// </summary>
private void Btn_Ok_Click(object sender, EventArgs e)
{
button_ok();
}
/// <summary>
/// 确认按钮鼠标悬停
/// </summary>
private void Btn_Ok_MouseMove(object sender, MouseEventArgs e)
{
if (this.TxtDiscount.Text.Trim() != "" && this.TxtDiscount.Text != null)
{
this.Btn_Ok.Image = Properties.Resources.确定;
}
}
private void Btn_Ok_MouseLeave(object sender, EventArgs e)
{
if (this.TxtDiscount.Text.Trim() != "" && this.TxtDiscount.Text != null)
{
this.Btn_Ok.Image = Properties.Resources.确定2;
}
}
/// <summary>
/// 确认提交方法
/// </summary>
public void button_ok()
{
if (this.TxtDiscount.Text != null && this.TxtDiscount.Text != "")
{
PassValue.Percent = Int32.Parse(this.TxtDiscount.Text);
if (PassValue.Percent != 0)
{
Discount ds = new Discount();
ds.type = "whole";
ds.percent = PassValue.Percent;
PassValue.discounts.Add(ds);
}
PassValue.Infor_payment.discounts = new Discount[PassValue.discounts.Count];
int i = 0;
foreach (Discount ds in PassValue.discounts)
{
PassValue.Infor_payment.discounts[i++] = ds;
}
HttpResult httpResult = httpReq.HttpPatch(string.Format("consumptions/{0}", orderConsumptionid), PassValue.Infor_payment);
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;
}
Form_Esc();
}
}
#endregion
#region 窗体操作和控件的设置
/// <summary>
/// 窗体加载
/// </summary>
private void AllOrder_Load(object sender, EventArgs e)
{
this.TxtDiscount.Focus();
this.lbConsumption.Text = PassValue.Price_All + "元";
this.Btn_Ok.Image = Properties.Resources.确定3;
this.Btn_Ok.Enabled = false;
this.Btn_Canel.Image = Properties.Resources.取消;
}
/// <summary>
/// 退出后的刷新
/// </summary>
public void Form_Esc()
{
Member mb = new Member();
mb = (Member)this.Owner;
mb.KeyPreview = true;
mb.panelChildren.Controls.Remove(this);
mb.panelInfor.Visible = true;
mb.lbTitle.Text = "支付信息";
mb.SetUp();
PassValue.discounts.Clear();
mb.AddInformation();//重新加载打折信息
this.Close();
}
#endregion
private void TxtDiscount_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
button_ok();
}
}
}
}