FrmPosResult.cs
6.4 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
using OnlineStore.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.XLRStore
{
public partial class FrmPosResult : Form
{
public FrmPosResult()
{
CheckForIllegalCrossThreadCalls = false;
boxEquip = StoreManager.XLRStore.boxEquip;
DrawerResults = PosDebugResultManager.DrawerResults;
InitializeComponent();
LoadDrawerList();
timer1.Enabled = true;
}
List<DrawerResult> DrawerResults;
BoxEquip boxEquip;
protected Dictionary<string, UCStatusPanel> PosControlList = new Dictionary<string, UCStatusPanel>();
protected Dictionary<string, UCStatusPanel> DrawerControlList = new Dictionary<string, UCStatusPanel>();
private void LoadDrawerList()
{
this.tlpDrawerA.RowStyles.Clear();
this.tlpDrawerA.ColumnStyles.Clear();
this.tlpDrawerA.CellBorderStyle = TableLayoutPanelCellBorderStyle.OutsetPartial;
this.tlpDrawerA.RowCount = boxEquip.Config.Drawer_Rows;
this.tlpDrawerA.ColumnCount = boxEquip.Config.Drawer_Columns;
this.tlpDrawerA.Height = 40 * this.tlpDrawerA.RowCount;
this.tlpDrawerA.Width = 90 * this.tlpDrawerA.ColumnCount;
string cid = boxEquip.Config.CID;
selectedDrawer = $"{cid}AA{"01"}{"01"}";
for (int rowindex = 0; rowindex < boxEquip.Config.Drawer_Rows; rowindex++)
{
tlpDrawerA.RowStyles.Add(new RowStyle(SizeType.Absolute, 38));
for (int colindex = 0; colindex < boxEquip.Config.Drawer_Columns; colindex++)
{
tlpDrawerA.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 87));
UCStatusPanel control = new UCStatusPanel();
control.ControlName = $"{cid}AA{(rowindex + 1).ToString("00")}{(colindex + 1).ToString("00")}";
control.Click += Control_Click;
control.Dock = DockStyle.Fill;
this.tlpDrawerA.Controls.Add(control, colindex, rowindex);
DrawerControlList.Add(control.ControlName, control);
}
}
this.tlpDrawerB.RowStyles.Clear();
this.tlpDrawerB.ColumnStyles.Clear();
this.tlpDrawerB.CellBorderStyle = TableLayoutPanelCellBorderStyle.OutsetPartial;
this.tlpDrawerB.RowCount = boxEquip.Config.Drawer_Rows;
this.tlpDrawerB.ColumnCount = boxEquip.Config.Drawer_Columns;
this.tlpDrawerB.Height = 40 * this.tlpDrawerB.RowCount;
this.tlpDrawerB.Width = 90 * this.tlpDrawerB.ColumnCount;
for (int rowindex = 0; rowindex < boxEquip.Config.Drawer_Rows; rowindex++)
{
tlpDrawerB.RowStyles.Add(new RowStyle(SizeType.Absolute, 38));
for (int colindex = 0; colindex < boxEquip.Config.Drawer_Columns; colindex++)
{
tlpDrawerB.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 87));
UCStatusPanel control = new UCStatusPanel();
control.ControlName = $"{cid}BB{(rowindex + 1).ToString("00")}{(colindex + 1).ToString("00")}";
control.Click += Control_Click;
control.Dock = DockStyle.Fill;
this.tlpDrawerB.Controls.Add(control, colindex, rowindex);
DrawerControlList.Add(control.ControlName, control);
}
}
this.tlpPos.RowStyles.Clear();
this.tlpPos.ColumnStyles.Clear();
this.tlpPos.CellBorderStyle = TableLayoutPanelCellBorderStyle.OutsetPartial;
this.tlpPos.AutoScroll = true;
this.tlpPos.RowCount = boxEquip.Config.Cols_In_Drawer;
this.tlpPos.ColumnCount = boxEquip.Config.Rows_In_Drawer;
this.tlpPos.Height = 40 * this.tlpPos.RowCount;
this.tlpPos.Width = 90 * this.tlpPos.ColumnCount;
for (int rowindex = 0; rowindex < boxEquip.Config.Cols_In_Drawer; rowindex++)
{
tlpPos.RowStyles.Add(new RowStyle(SizeType.Absolute, 38));
for (int colindex = 0; colindex < boxEquip.Config.Rows_In_Drawer; colindex++)
{
tlpPos.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 87));
UCStatusPanel control = new UCStatusPanel();
control.ControlName = $"{(colindex + 1).ToString("00")}{(rowindex + 1).ToString("00")}";
control.Dock = DockStyle.Fill;
this.tlpPos.Controls.Add(control, colindex, rowindex);
PosControlList.Add(control.ControlName, control);
}
}
this.SuspendLayout();
}
private void Control_Click(object sender, EventArgs e)
{
UCStatusPanel statusPanel = sender as UCStatusPanel;
if (statusPanel != null)
{
selectedDrawer = statusPanel.ControlName;
UpdateInfosInDrawer(statusPanel.ControlName);
}
}
public string selectedDrawer = "";
private void UpdateInfosInDrawer(string drawername)
{
groupBox2.Text = $"{drawername}库位结果";
foreach (var item in PosControlList.Values)
{
StringBuilder sb = new StringBuilder();
sb.Append(drawername);
sb.Append(item.ControlName);
item.ResultCode = PosDebugResultManager.GetGridResult(sb.ToString());
item.ShowResult();
}
}
private void UpdateDrawerInfos()
{
foreach (var item in DrawerControlList.Values)
{
item.ResultCode = PosDebugResultManager.GetDrawerResult(item.ControlName);
item.ShowResult();
}
}
bool inUpdate = false;
private void timer1_Tick(object sender, EventArgs e)
{
if (inUpdate)
return;
inUpdate = true;
UpdateDrawerInfos();
if (!selectedDrawer.Equals(""))
UpdateInfosInDrawer(selectedDrawer);
inUpdate = false;
}
}
}