schangxiang@126.com
2025-08-13 a97a624c1fb269a059f97629076433c46b4e8b4c
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
 
using Newtonsoft.Json;
using System.Threading;
using Newtonsoft.Json.Converters;
using System.Drawing.Drawing2D;
 
using iWareSql;
using iWareTestForm.Utility;
using iWareSql.Orm;
using iWareTestForm.iWareTest.DialogForm;
using iWareSql.DataAccess;
 
using iWareCommon.Utils;
using iWareModel;
using XiGang.Core.Model;
using iWareSql.DBModel;
 
 
namespace iWareTestForm
{
    public partial class tb_PlanNo : Form
    {
 
        delegate void Delegate_SetPostResult(string content);
        delegate void Delegate_SetButton(Button btn, bool enabled);
 
        AutoSizeFormClass asc = new AutoSizeFormClass();
 
 
        #region 配置
 
 
 
 
        #endregion
 
 
        public tb_PlanNo()
        {
            InitializeComponent();
 
 
            this.WindowState = FormWindowState.Maximized;
 
            InitButtonTooltip();
 
 
 
 
 
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            /*
            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.FillRectangle(Brushes.White, this.ClientRectangle);
 
            Pen p = new Pen(Color.Black, 10);
            p.StartCap = LineCap.Round;
            p.EndCap = LineCap.ArrowAnchor;
            g.DrawLine(p, 30, 30, 180, 130);
            p.Dispose();
            //*/
        }
 
        private void InitButtonTooltip()
        {
 
        }
 
        private void ECMTestForm_Load(object sender, EventArgs e)
        {
            asc.controllInitializeSize(this);
        }
 
        private void ECMTestForm_SizeChanged(object sender, EventArgs e)
        {
            asc.controlAutoSize(this);
        }
 
 
 
 
        private void btn_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
 
 
 
        #region  公共方法
 
        /// <summary>
        /// 显示请求结果
        /// </summary>
        /// <param name="content"></param>
        private void ShowResult(string content)
        {
 
            if (this.tb_Log.InvokeRequired)
            {
                Delegate_SetPostResult delegate_SetPostResult = new Delegate_SetPostResult(ShowResult);
                this.Invoke(delegate_SetPostResult, new object[] { content });
            }
            else
            {
                //content += "\r\n";
                this.tb_Log.Text = StringHelper.GetLog(content) + this.tb_Log.Text;
            }
        }
 
        private void ControlButton(Button btn, bool enabled)
        {
            if (btn.InvokeRequired)
            {
                Delegate_SetButton myDelegate = new Delegate_SetButton(ControlButton);
                this.Invoke(myDelegate, new object[] { btn, enabled });
            }
            else
            {
                btn.Enabled = enabled;
            }
        }
 
 
        /// <summary>
        /// 禁用所有button
        /// </summary>
        private void UnEabledAllButton()
        {
            foreach (Control ctr in this.Controls)
            {
                if (ctr is Button)
                {
                    ControlButton((Button)ctr, false);//禁用控件
                }
            }
        }
 
 
        #endregion
 
 
 
        private void button6_Click(object sender, EventArgs e)
        {
            //MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
            //DialogResult dr = MessageBox.Show("确定要清空所有的输送线任务吗?", "提示", messButton);
            //if (dr == DialogResult.OK)//如果点击“确定”按钮
            //{
            //    using (Edm edm = new Edm())
            //    {
            //        var taskList = edm.Conveyor_Task.ToList();
            //        foreach (var item in taskList)
            //        {
            //            item.IsReleased = 1;
            //            item.IsFinished = 1;
            //            item.TaskState = (int)DeviceTaskStatusEnum.已完成;
            //            item.Remark = "模拟器模拟删除任务";
            //            item.UpdateTime = DateTime.Now;
            //            item.UpdateUser = "模拟器-" + MachineHelper.GetHostName();
            //        }
            //        edm.SaveChanges();
            //    }
            //    ShowResult("清空所有的输送线任务成功!");
            //}
            //else//如果点击“取消”按钮
            //{
 
            //}
        }
 
        private void button7_Click(object sender, EventArgs e)
        {
            //MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
            //DialogResult dr = MessageBox.Show("确定要清空所有的堆垛机任务吗?", "提示", messButton);
            //if (dr == DialogResult.OK)//如果点击“确定”按钮
            //{
            //    using (Edm edm = new Edm())
            //    {
            //        var taskList = edm.Srm_Task.ToList();
            //        foreach (var item in taskList)
            //        {
            //            item.IsReleased = 1;
            //            item.IsFinished = 1;
            //            item.TaskState = (int)DeviceTaskStatusEnum.已完成;
            //            item.Remark = "模拟器模拟删除任务";
            //            item.UpdateTime = DateTime.Now;
            //            item.UpdateUser = "模拟器-" + MachineHelper.GetHostName();
            //        }
            //        edm.SaveChanges();
            //    }
            //    ShowResult("清空所有的堆垛机任务成功!");
            //}
            //else//如果点击“取消”按钮
            //{
 
            //}
        }
 
 
        private void button9_Click(object sender, EventArgs e)
        {
            //MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
            //DialogResult dr = MessageBox.Show("确定要清空所有的RGV任务吗?", "提示", messButton);
            //if (dr == DialogResult.OK)//如果点击“确定”按钮
            //{
            //    using (Edm edm = new Edm())
            //    {
            //        var taskList = edm.Rgv_Task.ToList();
            //        foreach (var item in taskList)
            //        {
            //            item.IsReleased = 1;
            //            item.IsFinished = 1;
            //            item.TaskState = (int)DeviceTaskStatusEnum.已完成;
            //            item.Remark = "模拟器模拟删除任务";
            //            item.UpdateTime = DateTime.Now;
            //            item.UpdateUser = "模拟器-" + MachineHelper.GetHostName();
            //        }
            //        edm.SaveChanges();
            //    }
            //    ShowResult("清空所有的RGV任务成功!");
            //}
            //else//如果点击“取消”按钮
            //{
 
            //}
        }
 
 
        private void button11_Click(object sender, EventArgs e)
        {
            AddInStoreTaskForm frm = new AddInStoreTaskForm();
            frm.Show();
        }
 
 
        private void btn_ClearLog_Click(object sender, EventArgs e)
        {
            this.tb_Log.Text = "";
        }
 
 
 
        private void button20_Click(object sender, EventArgs e)
        {
            using (DbModel context = new DbModel())
            {
                var bb = context.Base_Station.ToList();
                foreach (var item in bb)
                {
                    item.IsLock = false;
                    item.IsDeleted = false;
                    item.IsHasTaskDoing = false;
                    item.OperationRemark = "模拟器解锁等";
                }
                context.SaveChanges();
 
                ShowResult("模拟器解锁库位成功!");
            }
        }
 
 
        private void tb_PlanNo_FormClosed(object sender, FormClosedEventArgs e)
        {
            Environment.Exit(0);
        }
 
        private void button5_Click(object sender, EventArgs e)
        {
 
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            using (DbModel context = new DbModel())
            {
                var item = context.Base_Station.Where(x => x.RgvStationCode == "RGV01").First();
                item.IsLock = false;
                item.IsDeleted = false;
                item.IsHasTaskDoing = false;
                item.OperationRemark = "模拟器解锁等";
 
                context.SaveChanges();
 
                ShowResult("模拟器解锁库位RGV01成功!");
            }
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
 
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            var id = Convert.ToInt32(this.tb_MainID.Text);
            using (DbModel context = new DbModel())
            {
                var taskMain = context.Task_Main.Where(x => x.Id == id).First();
                MesService.UpdateIsNeedOnLineForMainTask(taskMain);
 
                context.SaveChanges();
            }
 
        }
    }
}