WinOrganization.xaml.cs
12.3 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
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
using XingYe_ACS.BaseStruct;
using XingYe_ACS.Business;
using XingYe_ACS.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace XingYe_ACS.UI
{
/// <summary>
/// WinOrganization.xaml 的交互逻辑
/// </summary>
public partial class WinOrganization : Window
{
public WinOrganization()
{
InitializeComponent();
}
/// <summary>
/// 关闭按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
//重写Closing方法
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
this.Hide();
e.Cancel = true;
}
/// <summary>
/// 拖动事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
DGrid_AGV.ItemsSource = App.AgvList.OrderBy(a => a.strAgvNo);
DGrid_Charge.ItemsSource = App.StationList.Where(a => a.stationType == EnumMsg.StationType.充电桩).OrderBy(a => a.strStationNo);
DGrid_Station.ItemsSource = App.StationList.Where(a => a.stationType >= EnumMsg.StationType.回家位 || a.stationType == EnumMsg.StationType.临时输送线等待区).OrderBy(a => a.strStationNo);
DGrid_MatixManager.ItemsSource = App.PointList;
DGrid_Hoister.ItemsSource = App.HoisterList;
}
/// <summary>
/// 解锁站台事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MItem_Locked_Click(object sender, RoutedEventArgs e)
{
try
{
//if (DGrid_Station.SelectedItem == null) return;
//Station station = DGrid_Station.SelectedItem as Station;
//if (station == null) return;
//station.isLocked = false;
//bool updateResult = UpdateManage.UpdateStation(station);
//if (updateResult)
//{
// MessageBox.Show("解锁成功");
//}
//else
//{
// MessageBox.Show("解锁失败");
//}
}
catch (Exception Ex)
{
MessageBox.Show("操作失败:" + Ex.ToString());
}
}
private void MItem_AgvOnline_Click(object sender, RoutedEventArgs e)
{
Agv agv = DGrid_AGV.SelectedItem as Agv;
if (agv == null || agv.agvTask != null) return;
try
{
string sqlUpdate = string.Format("UPDATE T_Base_Agv SET isEnable = '1' WHERE strAgvNo = '{0}';", agv.strAgvNo);
int updateResult = DbHelperSQL.ExecuteSql(sqlUpdate);
if (updateResult == 1)
{
agv.isEnable = true;
MessageBox.Show(string.Format("{0}上线成功!", agv.strAgvNo));
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
private void MItem_AgvOut_Click(object sender, RoutedEventArgs e)
{
Agv agv = DGrid_AGV.SelectedItem as Agv;
if (agv == null || agv.agvTask != null) return;
try
{
string sqlUpdate = string.Format("UPDATE T_Base_Agv SET strBarcode = '0',strChooseStation = '', isEnable = '0' WHERE strAgvNo = '{0}';", agv.strAgvNo);
int updateResult = DbHelperSQL.ExecuteSql(sqlUpdate);
if (updateResult == 1)
{
agv.agvState = 0;
agv.strBarcode = "0";
agv.isEnable = false;
agv.isOnline = false;
agv.strChooseStation = "";
List<BaseStruct.Point> agvLockedList = App.PointList.FindAll(a => a.lockedAgv == agv);
foreach (BaseStruct.Point point in agvLockedList)
{
point.lockedAgv = null;
}
//更新界面小车位置
App.Sharp.AgvChange(agv);
MessageBox.Show(string.Format("{0}下线成功!", agv.strAgvNo));
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
/// <summary>
/// 禁用充电桩
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MItem_Cforbit_Click(object sender, RoutedEventArgs e)
{
try
{
Station chargeStation = DGrid_Charge.SelectedItem as Station;
if (chargeStation == null) return;
chargeStation.isEnable = false;
bool isResult = UpdateManage.UpdateStation(chargeStation);
if (isResult)
{
MessageBox.Show(string.Format("{0}充电桩禁用成功!", chargeStation.strStationNo));
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
/// <summary>
/// 启用充电桩
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MItem_CEnable_Click(object sender, RoutedEventArgs e)
{
try
{
Station chargeStation = DGrid_Charge.SelectedItem as Station;
if (chargeStation == null) return;
chargeStation.isEnable = true;
bool isResult = UpdateManage.UpdateStation(chargeStation);
if (isResult)
{
MessageBox.Show(string.Format("{0}充电桩启用成功!", chargeStation.strStationNo));
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
private void MItem_CUnLock_Click(object sender, RoutedEventArgs e)
{
try
{
Station chargeStation = DGrid_Charge.SelectedItem as Station;
if (chargeStation == null) return;
Agv agv = App.AgvList.FirstOrDefault(a => a.strBarcode == chargeStation.strBarcode);
if (agv!=null)
{
MessageBox.Show(string.Format("{0}占用当前充电桩无法解锁!",agv.strAgvNo));
return;
}
chargeStation.isLocked = false;
bool isResult = UpdateManage.UpdateStation(chargeStation);
if (isResult)
{
MessageBox.Show(string.Format("{0}充电桩解锁成功!", chargeStation.strStationNo));
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
/// <summary>
/// 更改站台的出入库类型
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MItem_ChangeStationType_Click(object sender, RoutedEventArgs e)
{
try
{
Station station = DGrid_Station.SelectedItem as Station;
if (station == null) return;
string stype = station.stationState.ToString() == "满" ? "空" : "满";
if (MessageBox.Show("确定将" + station.strRemark + "站台状态更改为" + stype, "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
//判断是否有前往人工分拣口的任务
FTask fTask = App.TaskList.FirstOrDefault(a => a.endPoint.strBarcode == station.strBarcode);
if (fTask != null)
{
MessageBox.Show("存在往当前工位的任务,不可以切换状态");
return;
}
string sqlUpdate = string.Format("UPDATE T_Base_Station SET stationState = '{1}' WHERE strStationNo = '{0}';", station.strStationNo, stype == "满" ? 1 : 2);
int intSqlResult = DbHelperSQL.ExecuteSql(sqlUpdate);
if (intSqlResult == 1)
{
station.stationState = Extends.ToEnum<EnumMsg.StationState>(stype);
MessageBox.Show(string.Format("切换{0}状态成功!", station.strRemark));
}
else
{
MessageBox.Show(string.Format("切换{0}状态失败!", station.strRemark));
}
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
/// <summary>
/// 启用站台
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MItem_OnEnable_Click(object sender, RoutedEventArgs e)
{
try
{
Station station = DGrid_Station.SelectedItem as Station;
if (station == null) return;
string sqlUpdate = string.Format("UPDATE T_Base_Station SET isEnable = 1 WHERE strStationNo = '{0}';", station.strStationNo);
int intSqlResult = DbHelperSQL.ExecuteSql(sqlUpdate);
if (intSqlResult == 1)
{
station.isEnable = true;
}
else
{
MessageBox.Show(string.Format("启用{0}站台失败!", station.strStationNo));
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
/// <summary>
/// 禁用站台
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MItem_OffEnable_Click(object sender, RoutedEventArgs e)
{
try
{
Station station = DGrid_Station.SelectedItem as Station;
if (station == null) return;
string sqlUpdate = string.Format("UPDATE T_Base_Station SET isEnable = 0 WHERE strStationNo = '{0}';", station.strStationNo);
int intSqlResult = DbHelperSQL.ExecuteSql(sqlUpdate);
if (intSqlResult == 1)
{
station.isEnable = false;
}
else
{
MessageBox.Show(string.Format("禁用{0}站台失败!", station.strStationNo));
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
/// <summary>
/// 更改货架信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MItem_ChangeShelf_Click(object sender, RoutedEventArgs e)
{
}
private void MItem_ShelfUnLock_Click(object sender, RoutedEventArgs e)
{
}
private void MItem_SelectShelf_Click(object sender, RoutedEventArgs e)
{
}
private void MItem_Hoister_Click(object sender, RoutedEventArgs e)
{
Hoister hositer = DGrid_Hoister.SelectedItem as Hoister;
if (hositer == null) return;
if (hositer.read_isFull) hositer.read_isFull = false;
else
{
hositer.read_isFull = true;
}
MessageBox.Show("清除成功");
}
}
}