FrmDisableTray.cs
5.8 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
using OnlineStore.Common;
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.AssemblyLine
{
partial class FrmDisableTray : FrmBase
{
public FrmDisableTray()
{
InitializeComponent();
}
private void btnClose_Click(object sender, EventArgs e)
{
timer1.Stop();
this.Close();
}
private void FrmDisableTray_Load(object sender, EventArgs e)
{
LoadList();
timer1.Start();
lblMsg.Text = "勾选开始处理托盘,禁用的托盘到达出料4后,会等待托盘启用后再放行\r\n关闭当前界面后,自动退出托盘处理";
}
private void LoadList()
{
dataGridView1.Rows.Clear();
List<TrayDisableInfo> list = TrayDisableManager.GetDisableList();
foreach (TrayDisableInfo t in list)
{
DataGridViewRow view = new DataGridViewRow();
view.CreateCells(dataGridView1);
view.Cells[Column_trayNum.Index].Value = t.TrayCode;
view.Cells[Column_DeviceName.Index].Value = t.DDeviceName;
view.Cells[Column_describle.Index].Value = t.DDescribe;
view.Cells[Column_datetime.Index].Value =t.DisableTime.ToString("yyyy-MM-dd HH:mm:ss");
TrayInfo tray = TrayManager.GetTrayInfo(t.TrayCode);
string trayInfo = "";
if (tray.InOrOutStore.Equals(0))
{
trayInfo = "空托盘";
}
else if (tray.InOrOutStore.Equals(1))
{
if (tray.InoutPar.InStoreNg)
{
trayInfo = $"入库NG[{tray.InoutPar.NgMsg}][{tray.InoutPar.WareCode}][{tray.InoutPar.PosId}]";
}
else
{
trayInfo = $"入库[{tray.InoutPar.WareCode}][{tray.InoutPar.PosId}]";
}
}
else if (tray.InOrOutStore.Equals(2))
{
trayInfo = $"出库[{tray.InoutPar.WareCode}][{tray.InoutPar.PosId}]";
}
view.Cells[Column_TrayInfo.Index].Value = trayInfo;
dataGridView1.Rows.Add(view);
}
lblTrayInfo.Text = "";
}
private void btnrefresh_Click(object sender, EventArgs e)
{
LoadList();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex != -1 && e.ColumnIndex >= 0)
{
string name = this.dataGridView1.Columns[e.ColumnIndex].Name;
int num = Convert.ToInt32(this.dataGridView1.Rows[e.RowIndex].Cells[Column_trayNum.Index].Value);
int rowIndex = e.RowIndex;
if (name.Equals(this.Column_Del.Name))
{
TrayInfo tray = TrayManager.GetTrayInfo(num);
string msg = "启用托盘将清空托盘信息,确定启用托盘【" + num + "】?";
DialogResult dialogResult = MessageBox.Show(msg, "提示?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dialogResult.Equals(DialogResult.OK))
{
LogUtil.info("用户手动启用托盘【" + num + "】" + tray.ToStr());
if (tray.IsFull && tray.InOrOutStore.Equals(1))
{
TrayManager.ClearInstore(tray,"清理禁用托盘");
}
TrayDisableManager.RemoveDisable(num);
this.dataGridView1.Rows.RemoveAt(rowIndex);
lblTrayInfo.Text = "";
}
}
}
}
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count > 0)
{
DataGridViewRow row = dataGridView1.SelectedRows[0];
int num = Convert.ToInt32(row.Cells[Column_trayNum.Index].Value);
TrayInfo tray = TrayManager.GetTrayInfo(num);
lblTrayInfo.Text = tray.ToStr();
}
}
private void chbProTray_CheckedChanged(object sender, EventArgs e)
{
TrayDisableManager.ProcessTray = chbProTray.Checked;
LogUtil.info("用户更改" + chbProTray.Text + "=" + chbProTray.Checked);
}
private void timer1_Tick(object sender, EventArgs e)
{
if (this.Visible)
{
try
{
ProvidingEquip pro4 = LineManager.Line.ProvidingEquipMap[204];
if(pro4.WarnMsg.Contains( TrayDisableManager.ProWarnMsg))
{
lblPro4Warnmsg.Text = pro4.WarnMsg;
}else
{
lblPro4Warnmsg.Text = "";
}
}catch (Exception ex)
{
LogUtil.error("FrmDisableTray timer1_Tick error:" + ex.ToString());
}
}
}
private void group3_Enter(object sender, EventArgs e)
{
}
private void FrmDisableTray_FormClosed(object sender, FormClosedEventArgs e)
{
TrayDisableManager.ProcessTray = false;
LogUtil.info("退出禁用托盘处理界面," + chbProTray.Text + "=false" );
}
}
}