Browse Source

勾选绑定箱单不出标签和箱单,点击开始打印不返回自动打印状态,装箱单零件号不变

master
ruoxing.wang 1 month ago
parent
commit
bb1cde7b79
  1. 80
      InjectionPC/FrmMain2408.Designer.cs
  2. 141
      InjectionPC/FrmMain2408.cs

80
InjectionPC/FrmMain2408.Designer.cs

@ -29,10 +29,10 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
GlacialComponents.Controls.GLColumn glColumn5 = new GlacialComponents.Controls.GLColumn(); GlacialComponents.Controls.GLColumn glColumn1 = new GlacialComponents.Controls.GLColumn();
GlacialComponents.Controls.GLColumn glColumn6 = new GlacialComponents.Controls.GLColumn(); GlacialComponents.Controls.GLColumn glColumn2 = new GlacialComponents.Controls.GLColumn();
GlacialComponents.Controls.GLColumn glColumn7 = new GlacialComponents.Controls.GLColumn(); GlacialComponents.Controls.GLColumn glColumn3 = new GlacialComponents.Controls.GLColumn();
GlacialComponents.Controls.GLColumn glColumn8 = new GlacialComponents.Controls.GLColumn(); GlacialComponents.Controls.GLColumn glColumn4 = new GlacialComponents.Controls.GLColumn();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain2408)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain2408));
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.panel7 = new System.Windows.Forms.Panel(); this.panel7 = new System.Windows.Forms.Panel();
@ -732,43 +732,43 @@
this.glacialList1.AutoHeight = true; this.glacialList1.AutoHeight = true;
this.glacialList1.BackColor = System.Drawing.SystemColors.ControlLightLight; this.glacialList1.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.glacialList1.BackgroundStretchToFit = true; this.glacialList1.BackgroundStretchToFit = true;
glColumn5.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; glColumn1.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None;
glColumn5.CheckBoxes = false; glColumn1.CheckBoxes = false;
glColumn5.ImageIndex = -1; glColumn1.ImageIndex = -1;
glColumn5.Name = "条码"; glColumn1.Name = "条码";
glColumn5.NumericSort = false; glColumn1.NumericSort = false;
glColumn5.Text = "条码"; glColumn1.Text = "条码";
glColumn5.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; glColumn1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
glColumn5.Width = 350; glColumn1.Width = 350;
glColumn6.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; glColumn2.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None;
glColumn6.CheckBoxes = false; glColumn2.CheckBoxes = false;
glColumn6.ImageIndex = -1; glColumn2.ImageIndex = -1;
glColumn6.Name = "产品名称"; glColumn2.Name = "产品名称";
glColumn6.NumericSort = false; glColumn2.NumericSort = false;
glColumn6.Text = "产品名称"; glColumn2.Text = "产品名称";
glColumn6.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; glColumn2.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
glColumn6.Width = 320; glColumn2.Width = 320;
glColumn7.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; glColumn3.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None;
glColumn7.CheckBoxes = false; glColumn3.CheckBoxes = false;
glColumn7.ImageIndex = -1; glColumn3.ImageIndex = -1;
glColumn7.Name = "打印方式"; glColumn3.Name = "打印方式";
glColumn7.NumericSort = false; glColumn3.NumericSort = false;
glColumn7.Text = "打印方式"; glColumn3.Text = "打印方式";
glColumn7.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; glColumn3.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
glColumn7.Width = 150; glColumn3.Width = 150;
glColumn8.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; glColumn4.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None;
glColumn8.CheckBoxes = false; glColumn4.CheckBoxes = false;
glColumn8.ImageIndex = -1; glColumn4.ImageIndex = -1;
glColumn8.Name = "打印时间"; glColumn4.Name = "打印时间";
glColumn8.NumericSort = false; glColumn4.NumericSort = false;
glColumn8.Text = "打印时间"; glColumn4.Text = "打印时间";
glColumn8.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; glColumn4.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
glColumn8.Width = 270; glColumn4.Width = 270;
this.glacialList1.Columns.AddRange(new GlacialComponents.Controls.GLColumn[] { this.glacialList1.Columns.AddRange(new GlacialComponents.Controls.GLColumn[] {
glColumn5, glColumn1,
glColumn6, glColumn2,
glColumn7, glColumn3,
glColumn8}); glColumn4});
this.glacialList1.ControlStyle = GlacialComponents.Controls.GLControlStyles.Normal; this.glacialList1.ControlStyle = GlacialComponents.Controls.GLControlStyles.Normal;
this.glacialList1.Dock = System.Windows.Forms.DockStyle.Fill; this.glacialList1.Dock = System.Windows.Forms.DockStyle.Fill;
this.glacialList1.Font = new System.Drawing.Font("宋体", 15.75F); this.glacialList1.Font = new System.Drawing.Font("宋体", 15.75F);

141
InjectionPC/FrmMain2408.cs

@ -182,62 +182,74 @@ namespace InjectionPC
#region 连接PLC #region 连接PLC
if (CreateServer()) try
{ {
if (ConnectServer(strHostIP, "Kepware.KEPServerEX.V6")) if (CreateServer())
{ {
Connected = true; if (ConnectServer(strHostIP, "Kepware.KEPServerEX.V6"))
{
Connected = true;
#region 创建组 #region 创建组
opcGroups = opcServer.OPCGroups; opcGroups = opcServer.OPCGroups;
opcGroup1 = opcGroups.Add("Mould"); opcGroup1 = opcGroups.Add("Mould");
SetGroupProperty(opcGroup1, 500); SetGroupProperty(opcGroup1, 500);
opcGroup2 = opcGroups.Add("Break"); opcGroup2 = opcGroups.Add("Break");
SetGroupProperty(opcGroup2, 500); SetGroupProperty(opcGroup2, 500);
#endregion #endregion
#region 创建项 #region 创建项
opcItems1 = opcGroup1.OPCItems; opcItems1 = opcGroup1.OPCItems;
opcItems1.DefaultIsActive = true; opcItems1.DefaultIsActive = true;
PLCMouldBLL PLCbll = new PLCMouldBLL(); PLCMouldBLL PLCbll = new PLCMouldBLL();
PLCBreakBLL bbll = new PLCBreakBLL(); PLCBreakBLL bbll = new PLCBreakBLL();
DataTable PLCdt = PLCbll.SearchMould(Program.station); DataTable PLCdt = PLCbll.SearchMould(Program.station);
if (PLCdt != null && PLCdt.Rows.Count > 0) if (PLCdt != null && PLCdt.Rows.Count > 0)
{
opcItemm1 = new OPCItem[PLCdt.Rows.Count];
for (int i = 0; i < PLCdt.Rows.Count; i++)
{ {
opcItemm1[i] = opcItems1.AddItem(PLCdt.Rows[i]["Address"].ToString(), i); opcItemm1 = new OPCItem[PLCdt.Rows.Count];
for (int i = 0; i < PLCdt.Rows.Count; i++)
{
opcItemm1[i] = opcItems1.AddItem(PLCdt.Rows[i]["Address"].ToString(), i);
}
} }
}
Thread.Sleep(200); Thread.Sleep(200);
opcGroup1.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange); opcGroup1.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange);
#endregion #endregion
}
else
{
MessageBox.Show("连接到OPC服务器失败!", "提示", MessageBoxButtons.OK);
Connected = false;
LogHelper.WriteLog("连接到OPC服务器失败!");
return;
}
} }
else else
{ {
MessageBox.Show("连接到OPC服务器失败!", "提示", MessageBoxButtons.OK); MessageBox.Show("创建OPC服务失败!", "提示", MessageBoxButtons.OK);
Connected = false; Connected = false;
LogHelper.WriteLog("连接到OPC服务器失败!"); LogHelper.WriteLog("创建OPC服务失败!");
return; return;
} }
} }
else catch(Exception ex)
{ {
MessageBox.Show("创建OPC服务失败!", "提示", MessageBoxButtons.OK); MessageBox.Show("创建OPC服务失败!", "提示", MessageBoxButtons.OK);
Connected = false; Connected = false;
LogHelper.WriteLog("创建OPC服务失败!"); LogHelper.WriteLog("创建OPC服务失败!");
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return; return;
} }
#endregion #endregion
} }
@ -2437,8 +2449,8 @@ namespace InjectionPC
} }
//if (bll.Add_Info_New(md, Program.tableName) == false) //if (bll.Add_Info_New(md, Program.tableName) == false)
if (SaveBarCode(md, Program.tableName,false, "1") == false) if (SaveBarCode(md, Program.tableName, false, "0") == false)
{ {
return; return;
} }
@ -3454,11 +3466,12 @@ namespace InjectionPC
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
if (UnCompletePrintBox("切换手动打印","all") == false) return; if (UnCompletePrintBox("切换手动打印","all") == false) return;
opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange);
cboxHandBox.Enabled = true; cboxHandBox.Enabled = true;
opcServer.OPCGroups.RemoveAll(); opcServer.OPCGroups.RemoveAll();
opcServer.Disconnect(); opcServer.Disconnect();
serialPort1.Close(); serialPort1.Close();
label23.Enabled = true; label23.Enabled = true;
label23.BackColor = System.Drawing.Color.DeepSkyBlue; label23.BackColor = System.Drawing.Color.DeepSkyBlue;
//if (ConfigurationManager.AppSettings["StationMode"].ToString() == "1") //if (ConfigurationManager.AppSettings["StationMode"].ToString() == "1")
@ -3488,62 +3501,73 @@ namespace InjectionPC
cboxHandBox.Enabled = false; cboxHandBox.Enabled = false;
#region 连接PLC #region 连接PLC
try
if (CreateServer())
{ {
if (ConnectServer(strHostIP, "Kepware.KEPServerEX.V6")) if (CreateServer())
{ {
Connected = true; if (ConnectServer(strHostIP, "Kepware.KEPServerEX.V6"))
{
Connected = true;
#region 创建组 #region 创建组
opcGroups = opcServer.OPCGroups; opcGroups = opcServer.OPCGroups;
opcGroup1 = opcGroups.Add("Mould"); opcGroup1 = opcGroups.Add("Mould");
SetGroupProperty(opcGroup1, 500); SetGroupProperty(opcGroup1, 500);
#endregion #endregion
#region 创建项 #region 创建项
opcItems1 = opcGroup1.OPCItems; opcItems1 = opcGroup1.OPCItems;
opcItems1.DefaultIsActive = true; opcItems1.DefaultIsActive = true;
PLCMouldBLL PLCbll = new PLCMouldBLL(); PLCMouldBLL PLCbll = new PLCMouldBLL();
PLCBreakBLL bbll = new PLCBreakBLL(); PLCBreakBLL bbll = new PLCBreakBLL();
DataTable PLCdt = PLCbll.SearchMould(Program.station); DataTable PLCdt = PLCbll.SearchMould(Program.station);
if (PLCdt != null && PLCdt.Rows.Count > 0) if (PLCdt != null && PLCdt.Rows.Count > 0)
{
opcItemm1 = new OPCItem[PLCdt.Rows.Count];
for (int i = 0; i < PLCdt.Rows.Count; i++)
{ {
opcItemm1[i] = opcItems1.AddItem(PLCdt.Rows[i]["Address"].ToString(), i); opcItemm1 = new OPCItem[PLCdt.Rows.Count];
for (int i = 0; i < PLCdt.Rows.Count; i++)
{
opcItemm1[i] = opcItems1.AddItem(PLCdt.Rows[i]["Address"].ToString(), i);
}
} }
}
Thread.Sleep(200); Thread.Sleep(200);
opcGroup1.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange); opcGroup1.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange);
#endregion #endregion
}
else
{
MessageBox.Show("连接到OPC服务器失败!", "提示", MessageBoxButtons.OK);
Connected = false;
LogHelper.WriteLog("连接到OPC服务器失败!");
return;
}
} }
else else
{ {
MessageBox.Show("连接到OPC服务器失败!", "提示", MessageBoxButtons.OK); MessageBox.Show("创建OPC服务失败!", "提示", MessageBoxButtons.OK);
Connected = false; Connected = false;
LogHelper.WriteLog("连接到OPC服务器失败!"); LogHelper.WriteLog("创建OPC服务失败!");
return; return;
} }
} }
else catch(Exception ex)
{ {
MessageBox.Show("创建OPC服务失败!", "提示", MessageBoxButtons.OK); MessageBox.Show("创建OPC服务失败!", "提示", MessageBoxButtons.OK);
Connected = false; Connected = false;
LogHelper.WriteLog("创建OPC服务失败!"); LogHelper.WriteLog("创建OPC服务失败!");
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return; return;
} }
#endregion #endregion
@ -3568,6 +3592,7 @@ namespace InjectionPC
label13.BackColor = System.Drawing.Color.DeepSkyBlue; label13.BackColor = System.Drawing.Color.DeepSkyBlue;
label23.Enabled = false; label23.Enabled = false;
label23.BackColor = System.Drawing.Color.Gray; label23.BackColor = System.Drawing.Color.Gray;
textBox2.Text = "";
} }
else else
{ {

Loading…
Cancel
Save