diff --git a/FacOneZPStation/FrmZP.Designer.cs b/FacOneZPStation/FrmZP.Designer.cs index 1f153f2..6fbcc5d 100644 --- a/FacOneZPStation/FrmZP.Designer.cs +++ b/FacOneZPStation/FrmZP.Designer.cs @@ -77,7 +77,7 @@ this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.51529F)); this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.62445F)); this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 32.86026F)); - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 770F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 776F)); this.tableLayoutPanel3.Controls.Add(this.button6, 3, 0); this.tableLayoutPanel3.Controls.Add(this.button1, 0, 1); this.tableLayoutPanel3.Controls.Add(this.button5, 2, 1); @@ -102,10 +102,10 @@ this.button6.Dock = System.Windows.Forms.DockStyle.Fill; this.button6.Font = new System.Drawing.Font("黑体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.button6.ForeColor = System.Drawing.Color.Black; - this.button6.Location = new System.Drawing.Point(1789, 14); - this.button6.Margin = new System.Windows.Forms.Padding(14, 14, 14, 14); + this.button6.Location = new System.Drawing.Point(1783, 14); + this.button6.Margin = new System.Windows.Forms.Padding(14); this.button6.Name = "button6"; - this.button6.Size = new System.Drawing.Size(743, 183); + this.button6.Size = new System.Drawing.Size(749, 183); this.button6.TabIndex = 7; this.button6.Text = "手动打印箱单"; this.button6.UseVisualStyleBackColor = false; @@ -119,7 +119,7 @@ this.button1.Location = new System.Drawing.Point(7, 217); this.button1.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(581, 200); + this.button1.Size = new System.Drawing.Size(579, 200); this.button1.TabIndex = 6; this.button1.Text = "打印标签"; this.button1.UseVisualStyleBackColor = false; @@ -131,10 +131,10 @@ this.button5.Dock = System.Windows.Forms.DockStyle.Fill; this.button5.Font = new System.Drawing.Font("黑体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.button5.ForeColor = System.Drawing.Color.Black; - this.button5.Location = new System.Drawing.Point(1206, 225); - this.button5.Margin = new System.Windows.Forms.Padding(14, 14, 14, 14); + this.button5.Location = new System.Drawing.Point(1202, 225); + this.button5.Margin = new System.Windows.Forms.Padding(14); this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(555, 184); + this.button5.Size = new System.Drawing.Size(553, 184); this.button5.TabIndex = 5; this.button5.Text = "不合格"; this.button5.UseVisualStyleBackColor = false; @@ -145,10 +145,10 @@ this.button4.BackColor = System.Drawing.Color.RoyalBlue; this.button4.Dock = System.Windows.Forms.DockStyle.Fill; this.button4.Font = new System.Drawing.Font("黑体", 16F); - this.button4.Location = new System.Drawing.Point(602, 6); + this.button4.Location = new System.Drawing.Point(600, 6); this.button4.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6); this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(583, 199); + this.button4.Size = new System.Drawing.Size(581, 199); this.button4.TabIndex = 4; this.button4.Text = "下一计划"; this.button4.UseVisualStyleBackColor = false; @@ -162,7 +162,7 @@ this.button3.Location = new System.Drawing.Point(7, 6); this.button3.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6); this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(581, 199); + this.button3.Size = new System.Drawing.Size(579, 199); this.button3.TabIndex = 3; this.button3.Text = "上一计划"; this.button3.UseVisualStyleBackColor = false; @@ -174,10 +174,10 @@ this.button2.Dock = System.Windows.Forms.DockStyle.Fill; this.button2.Font = new System.Drawing.Font("黑体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.button2.ForeColor = System.Drawing.Color.Black; - this.button2.Location = new System.Drawing.Point(609, 225); - this.button2.Margin = new System.Windows.Forms.Padding(14, 14, 14, 14); + this.button2.Location = new System.Drawing.Point(607, 225); + this.button2.Margin = new System.Windows.Forms.Padding(14); this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(569, 184); + this.button2.Size = new System.Drawing.Size(567, 184); this.button2.TabIndex = 2; this.button2.Text = "补打标签"; this.button2.UseVisualStyleBackColor = false; @@ -188,10 +188,10 @@ this.button7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); this.button7.Dock = System.Windows.Forms.DockStyle.Fill; this.button7.Font = new System.Drawing.Font("黑体", 16F); - this.button7.Location = new System.Drawing.Point(1782, 217); + this.button7.Location = new System.Drawing.Point(1776, 217); this.button7.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6); this.button7.Name = "button7"; - this.button7.Size = new System.Drawing.Size(757, 200); + this.button7.Size = new System.Drawing.Size(763, 200); this.button7.TabIndex = 8; this.button7.Text = "补打箱单"; this.button7.UseVisualStyleBackColor = false; @@ -203,7 +203,7 @@ this.label7.Dock = System.Windows.Forms.DockStyle.Fill; this.label7.Font = new System.Drawing.Font("黑体", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label7.ForeColor = System.Drawing.Color.White; - this.label7.Location = new System.Drawing.Point(1436, 3); + this.label7.Location = new System.Drawing.Point(1428, 3); this.label7.Margin = new System.Windows.Forms.Padding(2); this.label7.Name = "label7"; this.tableLayoutPanel4.SetRowSpan(this.label7, 2); @@ -215,10 +215,10 @@ // this.textBox2.Dock = System.Windows.Forms.DockStyle.Fill; this.textBox2.Font = new System.Drawing.Font("黑体", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.textBox2.Location = new System.Drawing.Point(414, 127); + this.textBox2.Location = new System.Drawing.Point(412, 127); this.textBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(1015, 87); + this.textBox2.Size = new System.Drawing.Size(1009, 87); this.textBox2.TabIndex = 30; this.textBox2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox2_KeyDown); // @@ -230,7 +230,7 @@ this.label3.Location = new System.Drawing.Point(5, 122); this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(400, 124); + this.label3.Size = new System.Drawing.Size(398, 124); this.label3.TabIndex = 29; this.label3.Text = "扫描物料条码"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -240,10 +240,10 @@ this.labOrderNo.Dock = System.Windows.Forms.DockStyle.Fill; this.labOrderNo.Font = new System.Drawing.Font("黑体", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labOrderNo.ForeColor = System.Drawing.Color.White; - this.labOrderNo.Location = new System.Drawing.Point(1713, 249); + this.labOrderNo.Location = new System.Drawing.Point(1705, 249); this.labOrderNo.Margin = new System.Windows.Forms.Padding(2); this.labOrderNo.Name = "labOrderNo"; - this.labOrderNo.Size = new System.Drawing.Size(836, 174); + this.labOrderNo.Size = new System.Drawing.Size(844, 174); this.labOrderNo.TabIndex = 28; this.labOrderNo.Text = "A64654646464"; this.labOrderNo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -254,7 +254,7 @@ this.label4.Dock = System.Windows.Forms.DockStyle.Fill; this.label4.Font = new System.Drawing.Font("黑体", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label4.ForeColor = System.Drawing.Color.White; - this.label4.Location = new System.Drawing.Point(1436, 249); + this.label4.Location = new System.Drawing.Point(1428, 249); this.label4.Margin = new System.Windows.Forms.Padding(2); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(272, 174); @@ -268,10 +268,10 @@ this.labStationNo.Dock = System.Windows.Forms.DockStyle.Fill; this.labStationNo.Font = new System.Drawing.Font("黑体", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labStationNo.ForeColor = System.Drawing.Color.White; - this.labStationNo.Location = new System.Drawing.Point(412, 249); + this.labStationNo.Location = new System.Drawing.Point(410, 249); this.labStationNo.Margin = new System.Windows.Forms.Padding(2); this.labStationNo.Name = "labStationNo"; - this.labStationNo.Size = new System.Drawing.Size(1019, 174); + this.labStationNo.Size = new System.Drawing.Size(1013, 174); this.labStationNo.TabIndex = 26; this.labStationNo.Text = "V253-MF-S后保下部延伸焊接"; this.labStationNo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -285,7 +285,7 @@ this.label2.Location = new System.Drawing.Point(3, 249); this.label2.Margin = new System.Windows.Forms.Padding(2); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(404, 174); + this.label2.Size = new System.Drawing.Size(402, 174); this.label2.TabIndex = 25; this.label2.Text = "工位名称"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -295,10 +295,10 @@ this.labPName.Dock = System.Windows.Forms.DockStyle.Fill; this.labPName.Font = new System.Drawing.Font("黑体", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labPName.ForeColor = System.Drawing.Color.White; - this.labPName.Location = new System.Drawing.Point(1713, 428); + this.labPName.Location = new System.Drawing.Point(1705, 428); this.labPName.Margin = new System.Windows.Forms.Padding(2); this.labPName.Name = "labPName"; - this.labPName.Size = new System.Drawing.Size(836, 284); + this.labPName.Size = new System.Drawing.Size(844, 284); this.labPName.TabIndex = 24; this.labPName.Text = "MF253 MF S后保"; this.labPName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -309,7 +309,7 @@ this.label8.Dock = System.Windows.Forms.DockStyle.Fill; this.label8.Font = new System.Drawing.Font("黑体", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label8.ForeColor = System.Drawing.Color.White; - this.label8.Location = new System.Drawing.Point(1436, 428); + this.label8.Location = new System.Drawing.Point(1428, 428); this.label8.Margin = new System.Windows.Forms.Padding(2); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(272, 284); @@ -323,10 +323,10 @@ this.labPartNo.Dock = System.Windows.Forms.DockStyle.Fill; this.labPartNo.Font = new System.Drawing.Font("黑体", 42F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labPartNo.ForeColor = System.Drawing.Color.White; - this.labPartNo.Location = new System.Drawing.Point(412, 428); + this.labPartNo.Location = new System.Drawing.Point(410, 428); this.labPartNo.Margin = new System.Windows.Forms.Padding(2); this.labPartNo.Name = "labPartNo"; - this.labPartNo.Size = new System.Drawing.Size(1019, 284); + this.labPartNo.Size = new System.Drawing.Size(1013, 284); this.labPartNo.TabIndex = 22; this.labPartNo.Text = "A2530822665"; this.labPartNo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -345,7 +345,7 @@ this.label6.Location = new System.Drawing.Point(3, 428); this.label6.Margin = new System.Windows.Forms.Padding(2); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(404, 284); + this.label6.Size = new System.Drawing.Size(402, 284); this.label6.TabIndex = 21; this.label6.Text = "产品代码"; this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -356,10 +356,10 @@ this.labBadCount.Dock = System.Windows.Forms.DockStyle.Fill; this.labBadCount.Font = new System.Drawing.Font("黑体", 60F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labBadCount.ForeColor = System.Drawing.Color.Lime; - this.labBadCount.Location = new System.Drawing.Point(1713, 717); + this.labBadCount.Location = new System.Drawing.Point(1705, 717); this.labBadCount.Margin = new System.Windows.Forms.Padding(2); this.labBadCount.Name = "labBadCount"; - this.labBadCount.Size = new System.Drawing.Size(836, 515); + this.labBadCount.Size = new System.Drawing.Size(844, 515); this.labBadCount.TabIndex = 20; this.labBadCount.Text = "0"; this.labBadCount.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -370,10 +370,10 @@ this.labNum.Dock = System.Windows.Forms.DockStyle.Fill; this.labNum.Font = new System.Drawing.Font("黑体", 60F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labNum.ForeColor = System.Drawing.Color.Lime; - this.labNum.Location = new System.Drawing.Point(412, 717); + this.labNum.Location = new System.Drawing.Point(410, 717); this.labNum.Margin = new System.Windows.Forms.Padding(2); this.labNum.Name = "labNum"; - this.labNum.Size = new System.Drawing.Size(1019, 515); + this.labNum.Size = new System.Drawing.Size(1013, 515); this.labNum.TabIndex = 18; this.labNum.Text = "152/210"; this.labNum.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -387,7 +387,7 @@ this.label10.Location = new System.Drawing.Point(3, 717); this.label10.Margin = new System.Windows.Forms.Padding(2); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(404, 515); + this.label10.Size = new System.Drawing.Size(402, 515); this.label10.TabIndex = 17; this.label10.Text = "计划/完成数"; this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -400,7 +400,7 @@ this.label14.Location = new System.Drawing.Point(5, 1); this.label14.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(400, 120); + this.label14.Size = new System.Drawing.Size(398, 120); this.label14.TabIndex = 12; this.label14.Text = "扫描本体条码"; this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -409,10 +409,10 @@ // this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.textBox1.Font = new System.Drawing.Font("黑体", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.textBox1.Location = new System.Drawing.Point(414, 6); + this.textBox1.Location = new System.Drawing.Point(412, 6); this.textBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(1015, 87); + this.textBox1.Size = new System.Drawing.Size(1009, 87); this.textBox1.TabIndex = 13; this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown); // @@ -421,11 +421,11 @@ this.labErrMessage.Dock = System.Windows.Forms.DockStyle.Fill; this.labErrMessage.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labErrMessage.ForeColor = System.Drawing.Color.Red; - this.labErrMessage.Location = new System.Drawing.Point(1715, 1); + this.labErrMessage.Location = new System.Drawing.Point(1707, 1); this.labErrMessage.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labErrMessage.Name = "labErrMessage"; this.tableLayoutPanel4.SetRowSpan(this.labErrMessage, 2); - this.labErrMessage.Size = new System.Drawing.Size(832, 245); + this.labErrMessage.Size = new System.Drawing.Size(840, 245); this.labErrMessage.TabIndex = 16; this.labErrMessage.Text = "条码与产品不匹配,重新扫描"; this.labErrMessage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -438,7 +438,7 @@ this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 28.52292F)); this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 71.47708F)); this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 276F)); - this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 839F)); + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 847F)); this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F)); this.tableLayoutPanel4.Controls.Add(this.label7, 2, 0); this.tableLayoutPanel4.Controls.Add(this.textBox2, 1, 1); @@ -478,7 +478,7 @@ this.label12.Dock = System.Windows.Forms.DockStyle.Fill; this.label12.Font = new System.Drawing.Font("黑体", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label12.ForeColor = System.Drawing.Color.White; - this.label12.Location = new System.Drawing.Point(1436, 717); + this.label12.Location = new System.Drawing.Point(1428, 717); this.label12.Margin = new System.Windows.Forms.Padding(2); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(272, 515); @@ -491,10 +491,10 @@ this.labTime.BackColor = System.Drawing.Color.Transparent; this.labTime.Dock = System.Windows.Forms.DockStyle.Fill; this.labTime.Font = new System.Drawing.Font("微软雅黑", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.labTime.Location = new System.Drawing.Point(1924, 0); + this.labTime.Location = new System.Drawing.Point(1920, 0); this.labTime.Margin = new System.Windows.Forms.Padding(0); this.labTime.Name = "labTime"; - this.labTime.Size = new System.Drawing.Size(636, 149); + this.labTime.Size = new System.Drawing.Size(640, 149); this.labTime.TabIndex = 7; this.labTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.labTime.Click += new System.EventHandler(this.labTime_Click); @@ -508,7 +508,7 @@ this.pictureBox1.Location = new System.Drawing.Point(0, 0); this.pictureBox1.Margin = new System.Windows.Forms.Padding(0); this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(348, 149); + this.pictureBox1.Size = new System.Drawing.Size(347, 149); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; @@ -518,10 +518,10 @@ this.label1.BackColor = System.Drawing.Color.Transparent; this.label1.Dock = System.Windows.Forms.DockStyle.Fill; this.label1.Font = new System.Drawing.Font("黑体", 22F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label1.Location = new System.Drawing.Point(348, 0); + this.label1.Location = new System.Drawing.Point(347, 0); this.label1.Margin = new System.Windows.Forms.Padding(0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(1576, 149); + this.label1.Size = new System.Drawing.Size(1573, 149); this.label1.TabIndex = 1; this.label1.Text = "装配工位信息看板"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -532,7 +532,7 @@ this.tableLayoutPanel2.ColumnCount = 3; this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 18.10651F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 81.89349F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 635F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 639F)); this.tableLayoutPanel2.Controls.Add(this.labTime, 2, 0); this.tableLayoutPanel2.Controls.Add(this.pictureBox1, 0, 0); this.tableLayoutPanel2.Controls.Add(this.label1, 1, 0); diff --git a/InjectionPC/FrmMain2408.Designer.cs b/InjectionPC/FrmMain2408.Designer.cs index cd08e92..ced45c4 100644 --- a/InjectionPC/FrmMain2408.Designer.cs +++ b/InjectionPC/FrmMain2408.Designer.cs @@ -29,10 +29,10 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - GlacialComponents.Controls.GLColumn glColumn5 = new GlacialComponents.Controls.GLColumn(); - GlacialComponents.Controls.GLColumn glColumn6 = new GlacialComponents.Controls.GLColumn(); - GlacialComponents.Controls.GLColumn glColumn7 = new GlacialComponents.Controls.GLColumn(); - GlacialComponents.Controls.GLColumn glColumn8 = new GlacialComponents.Controls.GLColumn(); + GlacialComponents.Controls.GLColumn glColumn1 = new GlacialComponents.Controls.GLColumn(); + GlacialComponents.Controls.GLColumn glColumn2 = new GlacialComponents.Controls.GLColumn(); + GlacialComponents.Controls.GLColumn glColumn3 = new GlacialComponents.Controls.GLColumn(); + GlacialComponents.Controls.GLColumn glColumn4 = new GlacialComponents.Controls.GLColumn(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain2408)); this.panel1 = new System.Windows.Forms.Panel(); this.panel7 = new System.Windows.Forms.Panel(); @@ -781,43 +781,43 @@ this.glacialList1.AutoHeight = true; this.glacialList1.BackColor = System.Drawing.SystemColors.ControlLightLight; this.glacialList1.BackgroundStretchToFit = true; - glColumn5.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; - glColumn5.CheckBoxes = false; - glColumn5.ImageIndex = -1; - glColumn5.Name = "条码"; - glColumn5.NumericSort = false; - glColumn5.Text = "条码"; - glColumn5.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; - glColumn5.Width = 350; - glColumn6.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; - glColumn6.CheckBoxes = false; - glColumn6.ImageIndex = -1; - glColumn6.Name = "产品名称"; - glColumn6.NumericSort = false; - glColumn6.Text = "产品名称"; - glColumn6.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; - glColumn6.Width = 320; - glColumn7.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; - glColumn7.CheckBoxes = false; - glColumn7.ImageIndex = -1; - glColumn7.Name = "打印方式"; - glColumn7.NumericSort = false; - glColumn7.Text = "打印方式"; - glColumn7.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; - glColumn7.Width = 150; - glColumn8.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; - glColumn8.CheckBoxes = false; - glColumn8.ImageIndex = -1; - glColumn8.Name = "打印时间"; - glColumn8.NumericSort = false; - glColumn8.Text = "打印时间"; - glColumn8.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; - glColumn8.Width = 270; + glColumn1.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; + glColumn1.CheckBoxes = false; + glColumn1.ImageIndex = -1; + glColumn1.Name = "条码"; + glColumn1.NumericSort = false; + glColumn1.Text = "条码"; + glColumn1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + glColumn1.Width = 350; + glColumn2.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; + glColumn2.CheckBoxes = false; + glColumn2.ImageIndex = -1; + glColumn2.Name = "产品名称"; + glColumn2.NumericSort = false; + glColumn2.Text = "产品名称"; + glColumn2.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + glColumn2.Width = 320; + glColumn3.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; + glColumn3.CheckBoxes = false; + glColumn3.ImageIndex = -1; + glColumn3.Name = "打印方式"; + glColumn3.NumericSort = false; + glColumn3.Text = "打印方式"; + glColumn3.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + glColumn3.Width = 150; + glColumn4.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; + glColumn4.CheckBoxes = false; + glColumn4.ImageIndex = -1; + glColumn4.Name = "打印时间"; + glColumn4.NumericSort = false; + glColumn4.Text = "打印时间"; + glColumn4.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + glColumn4.Width = 270; this.glacialList1.Columns.AddRange(new GlacialComponents.Controls.GLColumn[] { - glColumn5, - glColumn6, - glColumn7, - glColumn8}); + glColumn1, + glColumn2, + glColumn3, + glColumn4}); this.glacialList1.ControlStyle = GlacialComponents.Controls.GLControlStyles.Normal; this.glacialList1.Dock = System.Windows.Forms.DockStyle.Fill; this.glacialList1.Font = new System.Drawing.Font("宋体", 15.75F); @@ -1734,12 +1734,9 @@ // this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // - // serialPort1 - // - this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived); - // // timer2 // + this.timer2.Enabled = true; this.timer2.Interval = 5000; this.timer2.Tick += new System.EventHandler(this.timer2_Tick); // diff --git a/InjectionPC/FrmMain2408.cs b/InjectionPC/FrmMain2408.cs index 0679af7..5115271 100644 --- a/InjectionPC/FrmMain2408.cs +++ b/InjectionPC/FrmMain2408.cs @@ -64,7 +64,9 @@ namespace InjectionPC private DateTime _loginTime = DateTime.Now; private string _lastBoxNoL = string.Empty; private string _lastBoxNoR = string.Empty; - private WmsBLL _wmsBll = new WmsBLL(); + private WmsBLL _wmsBll = new WmsBLL(); + private PLCMouldBLL _PLCbll = new PLCMouldBLL(); + private PLCBreakBLL _bbll = new PLCBreakBLL(); bool _isLoad = false; //零件用的打印机编号 <零件号+工位ID,打印机编号> private Dictionary _printNameDict = new Dictionary(); @@ -111,9 +113,9 @@ namespace InjectionPC comboBox1.Text = "A班"; //班次 Program.cc = comboBox1.Text; initProduct(); - textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + - Program.ProductDate.Substring(8, 2); //批次 - + //textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + + // Program.ProductDate.Substring(8, 2); //批次 + textBox1.Text = GetBatch(true); string devRate = ConfigurationManager.AppSettings["DevRate"]; if (!string.IsNullOrEmpty(devRate)) { @@ -147,7 +149,7 @@ namespace InjectionPC - InitPackageInfo(); + Ping p1 = new Ping(); PingReply reply = p1.Send("10.60.101.60"); //发送主机名或Ip地址 @@ -171,9 +173,10 @@ namespace InjectionPC initPlan(); + InitPackageInfo(); #endregion - + #region 连接PLC @@ -200,9 +203,9 @@ namespace InjectionPC opcItems1 = opcGroup1.OPCItems; opcItems1.DefaultIsActive = true; - PLCMouldBLL PLCbll = new PLCMouldBLL(); - PLCBreakBLL bbll = new PLCBreakBLL(); - DataTable PLCdt = PLCbll.SearchMould(Program.station); + //PLCMouldBLL PLCbll = new PLCMouldBLL(); + //PLCBreakBLL bbll = new PLCBreakBLL(); + DataTable PLCdt = _PLCbll.SearchMould(Program.station); if (PLCdt != null && PLCdt.Rows.Count > 0) { opcItemm1 = new OPCItem[PLCdt.Rows.Count]; @@ -408,6 +411,7 @@ namespace InjectionPC MessageBox.Show("连接服务器失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } + for (int i = 1; i <= NumItems; i++) { if ((ItemValues!=null && ItemValues.GetValue(i).ToString() == "True") || IsTest ==true) @@ -425,12 +429,14 @@ namespace InjectionPC { return; } + _bbll.SavePlcReceive(Program.station, TransactionID, NumItems, aa, planID, "2408"); #endregion //comboBox1.Text = "A班"; //班次 - textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + - Program.ProductDate.Substring(8, 2); //批次 + //textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + + // Program.ProductDate.Substring(8, 2); //批次 + textBox1.Text = GetBatch(true); #region 查找当前计划 DataTable dt = bll.SearchInfoByName(Program.station); if (dt != null && dt.Rows.Count > 0) @@ -462,7 +468,7 @@ namespace InjectionPC for (int j = 0; j < partNo.Length; j++) { #region 根据零件号查找存货代码 - + mould = j.ToString(); DataTable sdt = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); if (sdt != null && sdt.Rows.Count > 0) { @@ -501,58 +507,11 @@ namespace InjectionPC { if (ManufacturerName.Contains("蔚来")) { - //DataTable dts = brbll.SearchInfoByPartNo1(partNo[j].ToString().Trim()); - //if (dts != null && dts.Rows.Count > 0) - //{ - // code = dts.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + - // 1).ToString() - // .PadLeft(4, '0'); - //} - //else - //{ - // newcode = partNo[j].Trim() + "." + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "." + "0001"; - //} - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, NumItems+"_551" , ref NewOneCode, ref newcode); } else { - //dt2 = brbll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - //if (dt2 != null && dt2.Rows.Count > 0) - //{ - // code = dt2.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + - // 1).ToString() - // .PadLeft(4, '0'); - // OneCode = dt2.Rows[0]["OneBarCode"].ToString().Trim(); - // NewOneCode = - // OneCode.Substring(0, OneCode.Length - 4) + - // (Convert.ToInt32(OneCode.Substring(OneCode.Length - 4, - // 4)) + - // 1).ToString().PadLeft(4, '0'); - //} - //else - //{ - // newcode = partNo[j].ToString().Trim() + "." + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "." + - // "0001"; - // NewOneCode = - // stockNo[j].ToString().Trim() + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "0001"; - //} - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_584", ref NewOneCode, ref newcode); - } } @@ -562,23 +521,6 @@ namespace InjectionPC if (IsSupply == "1") { - //DataTable dts = brbll.SearchInfoByPartNo1(partNo[j].ToString().Trim()); - //if (dts != null && dts.Rows.Count > 0) - //{ - // code = dts.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(23, 3)) + - // 1).ToString() - // .PadLeft(3, '0')+"#"; - //} - //else - //{ - // newcode = partNo[j].ToString().Trim() + "#" + QLevel+"#"+ - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "#" + "001"+"#"; - //} - GetSupplyCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), QLevel, true, mould, PartName, ref NewOneCode, ref newcode); } @@ -596,42 +538,7 @@ namespace InjectionPC md.PlanID = planID; md.ProductNature = ProductNature; md.Des1 = PartName; - //DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString()); - //if (pdt != null && pdt.Rows.Count > 0) - //{ - // if (pdt.Rows[0]["isImport"].ToString() == "1") - // { - // md.Import = "国产料Kingfa"; - // } - // else - // { - // md.Import = ""; - // } - //} - - ////if (brbll.Add_Info_New(md, Program.tableName) == false) - //if (SaveBarCode(md, Program.tableName, true, mould) == false) - //{ - // int a = 0; - // for (int l = 0; l < 5; l++) - // { - // // if (brbll.Add_Info_New(md, Program.tableName)) - // if (SaveBarCode(md, Program.tableName, true, mould) == true) - // { - // break; - // } - - // a += 1; - // Thread.Sleep(200); - // } - - // if (a >= 4) - // { - // return; - // } - // //return; - //} - + string errMsg = string.Empty; bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); if (saveRst == false) @@ -663,13 +570,6 @@ namespace InjectionPC PrintMoudleName("1", "Print" + Program.station + "_684"); } - - //DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), - // dt.Rows[0]["StationID"].ToString()); - //if (dt4 != null && dt4.Rows.Count > 0) - //{ - // printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); - //} printName = "Printer" +_printNameDict[partNo[j].ToString().Trim()+ dt.Rows[0]["StationID"].ToString()]; string reportName = ConfigurationManager.AppSettings[printName] @@ -702,59 +602,12 @@ namespace InjectionPC if (ManufacturerName.Contains("蔚来")) { - //DataTable dts = brbll.SearchInfoByPartNo1(partNo[j].ToString().Trim()); - //if (dts != null && dts.Rows.Count > 0) - //{ - // code = dt2.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + - // 1).ToString() - // .PadLeft(4, '0') ; - //} - //else - //{ - // newcode = partNo[j].Trim() + "." + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "." + "0001"; - //} GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_743", ref NewOneCode, ref newcode); - } else { - //dt2 = brbll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - //if (dt2 != null && dt2.Rows.Count > 0) - //{ - // code = dt2.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + - // 1) - // .ToString() - // .PadLeft(4, '0'); - // OneCode = dt2.Rows[0]["OneBarCode"].ToString().Trim(); - // NewOneCode = - // OneCode.Substring(0, OneCode.Length - 4) + - // (Convert.ToInt32(OneCode.Substring(OneCode.Length - 4, 4)) + - // 1) - // .ToString().PadLeft(4, '0'); - //} - //else - //{ - // newcode = partNo[j].ToString().Trim() + "." + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "." + "0001"; - // NewOneCode = - // stockNo[j].ToString().Trim() + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "0001"; - //} - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_555", ref NewOneCode, ref newcode); - } #endregion @@ -762,22 +615,6 @@ namespace InjectionPC else { #region 直供件 - //DataTable dts = brbll.SearchInfoByPartNo1(partNo[j].ToString().Trim()); - //if (dts != null && dts.Rows.Count > 0) - //{ - // code = dt2.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(23, 3)) + - // 1).ToString() - // .PadLeft(3, '0') + "#"; - //} - //else - //{ - // newcode = partNo[j].ToString().Trim() + "#" + QLevel + "#" + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "#" + "001" + "#"; - //} GetSupplyCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), QLevel, true, mould, PartName, ref NewOneCode, ref newcode); #endregion @@ -808,29 +645,6 @@ namespace InjectionPC } } - //// if (brbll.Add_Info_New(md, Program.tableName) == false) - //if (SaveBarCode(md, Program.tableName, true, mould) == false) - //{ - // int a = 0; - // for (int l = 0; l < 5; l++) - // { - // //if (brbll.Add_Info_New(md, Program.tableName)) - // if (SaveBarCode(md, Program.tableName, true, mould) == true) - // { - // break; - // } - - // a += 1; - // Thread.Sleep(200); - // } - - // if (a >= 4) - // { - // return; - // } - // //return; - //} - string errMsg = string.Empty; bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); if (saveRst == false) @@ -985,68 +799,13 @@ namespace InjectionPC { if (ManufacturerName.Contains("蔚来")) { - #region 修改前,屏蔽 - - //DataTable dts = brbll.SearchInfoByPartNo1(partNo[j].ToString().Trim()); - //if (dts != null && dts.Rows.Count > 0) - //{ - // code = dts.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + - // 1).ToString() - // .PadLeft(4, '0'); - //} - //else - //{ - // newcode = partNo[j].Trim() + "." + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "." + "0001"; - //} - - #endregion GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_1017", ref NewOneCode, ref newcode); } else { - #region 修改前,屏蔽 - - //dt2 = brbll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - //if (dt2 != null && dt2.Rows.Count > 0) - //{ - // code = dt2.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(code.Length - 4, - // 4)) + 1) - // .ToString() - // .PadLeft(4, '0'); - // OneCode = dt2.Rows[0]["OneBarCode"].ToString().Trim(); - // NewOneCode = - // OneCode.Substring(0, OneCode.Length - 4) + - // (Convert.ToInt32(OneCode.Substring(OneCode.Length - 4, - // 4)) + 1) - // .ToString().PadLeft(4, '0'); - //} - //else - //{ - // newcode = partNo[j].ToString().Trim() + "." + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "." + - // "0001"; - // NewOneCode = - // stockNo[j].ToString().Trim() + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "0001"; - //} - - #endregion - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_1056", ref NewOneCode, ref newcode); - } } catch (Exception ex) @@ -1064,23 +823,7 @@ namespace InjectionPC try { - //DataTable dts = brbll.SearchInfoByPartNo1(partNo[j].ToString().Trim()); - //if (dts != null && dts.Rows.Count > 0) - //{ - // code = dt2.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(23, 3)) + - // 1).ToString() - // .PadLeft(3, '0') + "#"; - //} - //else - //{ - // newcode = partNo[j].ToString().Trim() + "#" + QLevel + "#" + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "#" + "001" + "#"; - //} - + GetSupplyCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), QLevel, true, mould, PartName, ref NewOneCode, ref newcode); } catch (Exception ex) @@ -1118,28 +861,6 @@ namespace InjectionPC } } - ////if (brbll.Add_Info_New(md, Program.tableName) == false) - //if (SaveBarCode(md, Program.tableName, true, mould) == false) - //{ - // int a = 0; - // for (int l = 0; l < 5; l++) - // { - // //if (brbll.Add_Info_New(md, Program.tableName)) - // if (SaveBarCode(md, Program.tableName, true, mould) == true) - // { - // break; - // } - - // a += 1; - // Thread.Sleep(200); - // } - - // if (a >= 4) - // { - // return; - // } - //} - string errMsg = string.Empty; bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); if (saveRst == false) @@ -1207,63 +928,11 @@ namespace InjectionPC { if (ManufacturerName.Contains("蔚来")) { - #region 修改前,屏蔽 - - //DataTable dts = brbll.SearchInfoByPartNo1(partNo[j].ToString().Trim()); - //if (dts != null && dts.Rows.Count > 0) - //{ - // code = dts.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + - // 1).ToString() - // .PadLeft(4, '0'); - //} - //else - //{ - // newcode = partNo[j].Trim() + "." + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "." + "0001"; - //} - - #endregion GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_1235", ref NewOneCode, ref newcode); } else { - #region 修改前,屏蔽 - - //dt2 = brbll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - //if (dt2 != null && dt2.Rows.Count > 0) - //{ - // code = dt2.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + - // 1) - // .ToString() - // .PadLeft(4, '0'); - // OneCode = dt2.Rows[0]["OneBarCode"].ToString().Trim(); - // NewOneCode = - // OneCode.Substring(0, OneCode.Length - 4) + - // (Convert.ToInt32(OneCode.Substring(OneCode.Length - 4, 4)) + - // 1) - // .ToString().PadLeft(4, '0'); - //} - //else - //{ - // newcode = partNo[j].ToString().Trim() + "." + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "." + "0001"; - // NewOneCode = - // stockNo[j].ToString().Trim() + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "0001"; - //} - - #endregion try { GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_1273", ref NewOneCode, ref newcode); @@ -1291,22 +960,6 @@ namespace InjectionPC try { - //DataTable dts = brbll.SearchInfoByPartNo1(partNo[j].ToString().Trim()); - //if (dts != null && dts.Rows.Count > 0) - //{ - // code = dts.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(23, 3)) + - // 1).ToString() - // .PadLeft(3, '0') + "#"; - //} - //else - //{ - // newcode = partNo[j].ToString().Trim() + "#" + QLevel + "#" + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "#" + "001" + "#"; - //} GetSupplyCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), QLevel, true, mould, PartName, ref NewOneCode, ref newcode); } catch (Exception ex) @@ -1345,28 +998,6 @@ namespace InjectionPC } } - ////if (brbll.Add_Info_New(md, Program.tableName) == false) - //if (SaveBarCode(md, Program.tableName, true, mould) == false) - //{ - // int a = 0; - // for (int l = 0; l < 5; l++) - // { - // //if (brbll.Add_Info_New(md, Program.tableName)) - // if (SaveBarCode(md, Program.tableName, true, mould) == true) - // { - // break; - // } - - // a += 1; - // Thread.Sleep(200); - // } - - // if (a >= 4) - // { - // return; - // } - //} - string errMsg = string.Empty; bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); if (saveRst == false) @@ -1529,20 +1160,6 @@ namespace InjectionPC #endregion - #region 查找称重数据库的最大ID - - //DataTable wdt = wbll.SearchInfo(Conn); - //if (wdt != null && wdt.Rows.Count > 0) - //{ - // wID = Convert.ToInt32(wdt.Rows[0]["ID"].ToString()); - //} - //else - //{ - // wID = 0; - //} - - #endregion - #region 如果称重数据库里的ID大于MES数据库中的ID,打印条码,并将称重数据库中的ID存入MES数据库 if (wID > ID) @@ -1599,27 +1216,8 @@ namespace InjectionPC { for (int k = 0; k < 2; k++) { - //dt2 = brbll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - //if (dt2 != null && dt2.Rows.Count > 0) - //{ - // code = dt2.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + 1).ToString() - // .PadLeft(4, '0'); - // OneCode = dt2.Rows[0]["OneBarCode"].ToString().Trim(); - // NewOneCode = OneCode.Substring(0, OneCode.Length - 4) + (Convert.ToInt32(OneCode.Substring(OneCode.Length - 4, 4)) + 1).ToString().PadLeft(4, '0'); - //} - //else - //{ - // newcode = partNo[j].ToString().Trim() + "." + Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2) + "." + "0001"; - // NewOneCode = stockNo[j].ToString().Trim() + Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2) + "0001"; - //} - - - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould.ToString(), PartName,"", ref NewOneCode, ref newcode); - #region 插入数据tb_barCode md.ID = Guid.NewGuid().ToString(); @@ -1645,28 +1243,6 @@ namespace InjectionPC } } - ////if (brbll.Add_Info_New(md, Program.tableName) == false) - //if (SaveBarCode(md, Program.tableName, true, same[j].ToString()) == false) - //{ - // int a = 0; - // for (int l = 0; l < 5; l++) - // { - // //if (brbll.Add_Info_New(md, Program.tableName)) - // if (SaveBarCode(md, Program.tableName, true, same[j].ToString()) == true) - // { - // break; - // } - - // a += 1; - // Thread.Sleep(200); - // } - - // if (a >= 4) - // { - // return; - // } - //} - string errMsg = string.Empty; bool saveRst = SaveInfo(md, true, same[j].ToString(), false, ref errMsg); if (saveRst == false) @@ -1736,121 +1312,11 @@ namespace InjectionPC #endregion - //DataTable dt5 = brbll.SearchBoxIsNull(partNo[j].ToString().Trim(), - // dt.Rows[0]["StationID"].ToString(), Program.tableName, ProductNature); - - //if (dt5 != null && dt5.Rows.Count > 0) - //{ - // CurrentCount = Convert.ToInt32(dt5.Rows[0]["SumCount"].ToString()); - //} - - //if (CurrentCount >= MaxCount) - //{ - // #region 判断是否满箱,满箱打印箱单 - - // DialogResult result = MessageBox.Show("是否打印装箱单?", "提示", MessageBoxButtons.OKCancel, - // MessageBoxIcon.Information); - // if (result == DialogResult.OK) - // { - // filename = System.AppDomain.CurrentDomain.BaseDirectory + "装箱单.grf"; - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("BoxNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("BatchNo"); - // headTable.Columns.Add("PackCount"); - // headTable.Columns.Add("QLevel"); - // DataRow row = headTable.NewRow(); - - // row["BatchNo"] = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); - - // #region 查询当前批次装箱单 - - // DataTable dt6 = boxbll.SeachInfoByBox(partNo[j].ToString().Trim(), Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2)); - // if (dt6 != null && dt6.Rows.Count > 0) - // { - // row["BoxNo"] = - // dt6.Rows[0]["BoxNo"].ToString().Substring(0, - // dt6.Rows[0]["BoxNo"].ToString().Length - 6) + - // (Convert.ToInt32(dt6.Rows[0]["BoxNo"].ToString() - // .Substring(dt6.Rows[0]["BoxNo"].ToString().Length - 6, 6)) + 1) - // .ToString().PadLeft(6, '0'); - // } - // else - // { - // row["BoxNo"] = - // partNo[j].ToString().Trim() + "." + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "." + "000001"; - // } - - // #endregion - - // row["PartNo"] = partNo[j].ToString().Trim(); - // row["PartName"] = PartName; - // row["PackCount"] = MaxCount.ToString() + " EA"; - // row["QLevel"] = QLevel; - - // #region 更新barCode表中BoxNo的绑定关系 - - // brbll.UpdateBoxNo(Program.tableName, row["BoxNo"].ToString(), - // partNo[j].ToString().Trim()); - - // #endregion - - // #region 保存箱单记录 - - // boxmd.ID = Guid.NewGuid().ToString(); - // boxmd.BoxNo = row["BoxNo"].ToString(); - // boxmd.IsFlag = 0; - // boxmd.BoxCount = MaxCount; - - // boxbll.AddInfo(boxmd); - - // #endregion - - // #region 打印箱单 - - // printBoxName = "Printer" + (Convert.ToInt32(printName.Substring(7, 1))+2).ToString(); - // string reportName = ConfigurationManager.AppSettings[printBoxName].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - - // rp.Report.Print(false); - - // #endregion - // } - // else - // { - - // } - - // #endregion - //} - #endregion } } else { - //dt2 = brbll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - //if (dt2 != null && dt2.Rows.Count > 0) - //{ - // code = dt2.Rows[0]["BarCode"].ToString().Trim(); - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + 1).ToString() - // .PadLeft(4, '0'); - // OneCode = dt2.Rows[0]["OneBarCode"].ToString().Trim(); - // NewOneCode = OneCode.Substring(0, OneCode.Length - 4) + (Convert.ToInt32(OneCode.Substring(OneCode.Length - 4, 4)) + 1).ToString().PadLeft(4, '0'); - //} - //else - //{ - // newcode = partNo[j].ToString().Trim() + "." + Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2) + "." + "0001"; - // NewOneCode = stockNo[j].ToString().Trim() + Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2) + "0001"; - //} - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould.ToString(), PartName,"", ref NewOneCode, ref newcode); #region 插入数据tb_barCode @@ -1878,28 +1344,7 @@ namespace InjectionPC } } - //// if (brbll.Add_Info_New(md, Program.tableName) == false) - //if (SaveBarCode(md, Program.tableName, true, same[j].ToString()) == false) - //{ - // int a = 0; - // for (int l = 0; l < 5; l++) - // { - // //if (brbll.Add_Info_New(md, Program.tableName)) - // if (SaveBarCode(md, Program.tableName, true, same[j].ToString()) == true) - // { - // break; - // } - - // a += 1; - // Thread.Sleep(200); - // } - - // if (a >= 4) - // { - // return; - // } - //} - + string errMsg = string.Empty; bool saveRst = SaveInfo(md, true, same[j].ToString(), false, ref errMsg); if (saveRst == false) @@ -1942,23 +1387,6 @@ namespace InjectionPC #region 打印条码,判断是否打印单个条码 - //DataTable dt3 = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - //if (dt3 != null && dt3.Rows.Count > 0) - //{ - // QLevel = dt3.Rows[0]["QLevel"].ToString(); - // IsOne = dt3.Rows[0]["IsPrintOneTag"].ToString(); - // IsPack = dt3.Rows[0]["IsPrintPackList"].ToString(); - // IsPaint = dt3.Rows[0]["IsPlating"].ToString(); - // PartName = dt3.Rows[0]["ProductName"].ToString(); - // MaxCount = Convert.ToInt32(dt3.Rows[0]["PackCount"].ToString()); - //} - - //DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), - // dt.Rows[0]["StationID"].ToString()); - //if (dt4 != null && dt4.Rows.Count > 0) - //{ - // printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); - //} printName = "Printer" + _printNameDict[partNo[j].ToString().Trim() + dt.Rows[0]["StationID"].ToString()]; #region 打印单个标签 @@ -1977,100 +1405,7 @@ namespace InjectionPC #endregion - //DataTable dt5 = brbll.SearchBoxIsNull(partNo[j].ToString().Trim(), - // dt.Rows[0]["StationID"].ToString(), Program.tableName, ProductNature); - - //if (dt5 != null && dt5.Rows.Count > 0) - //{ - // CurrentCount = Convert.ToInt32(dt5.Rows[0]["SumCount"].ToString()); - //} - - //if (CurrentCount >= MaxCount) - //{ - // #region 判断是否满箱,满箱打印箱单 - - // DialogResult result = MessageBox.Show("是否打印装箱单?", "提示", MessageBoxButtons.OKCancel, - // MessageBoxIcon.Information); - // if (result == DialogResult.OK) - // { - // filename = System.AppDomain.CurrentDomain.BaseDirectory + "装箱单.grf"; - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("BoxNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("BatchNo"); - // headTable.Columns.Add("PackCount"); - // headTable.Columns.Add("QLevel"); - // DataRow row = headTable.NewRow(); - - // row["BatchNo"] = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); - - // #region 查询当前批次装箱单 - - // DataTable dt6 = boxbll.SeachInfoByBox(partNo[j].ToString().Trim(), Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2)); - // if (dt6 != null && dt6.Rows.Count > 0) - // { - // row["BoxNo"] = - // dt6.Rows[0]["BoxNo"].ToString().Substring(0, - // dt6.Rows[0]["BoxNo"].ToString().Length - 6) + - // (Convert.ToInt32(dt6.Rows[0]["BoxNo"].ToString() - // .Substring(dt6.Rows[0]["BoxNo"].ToString().Length - 6, 6)) + 1) - // .ToString().PadLeft(6, '0'); - // } - // else - // { - // row["BoxNo"] = - // partNo[j].ToString().Trim() + "." + - // Program.ProductDate.Substring(2, 2) + - // Program.ProductDate.Substring(5, 2) + - // Program.ProductDate.Substring(8, 2) + "." + "000001"; - // } - - // #endregion - - // row["PartNo"] = partNo[j].ToString().Trim(); - // row["PartName"] = PartName; - // row["PackCount"] = MaxCount.ToString() + " EA"; - // row["QLevel"] = QLevel; - - // #region 更新barCode表中BoxNo的绑定关系 - - // brbll.UpdateBoxNo(Program.tableName, row["BoxNo"].ToString(), - // partNo[j].ToString().Trim()); - - // #endregion - - // #region 保存箱单记录 - - // boxmd.ID = Guid.NewGuid().ToString(); - // boxmd.BoxNo = row["BoxNo"].ToString(); - // boxmd.IsFlag = 0; - // boxmd.BoxCount = MaxCount; - - // boxbll.AddInfo(boxmd); - - // #endregion - - // #region 打印箱单 - - // printBoxName = "Printer" + (Convert.ToInt32(printName.Substring(7, 1)) + 2).ToString(); - // string reportName = ConfigurationManager.AppSettings[printBoxName].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - - // rp.Report.Print(false); - - // #endregion - // } - // else - // { - - // } - - // #endregion - //} - + #endregion } @@ -2345,10 +1680,10 @@ namespace InjectionPC { try { - if (serialPort1.IsOpen) - { - serialPort1.Close(); - } + //if (serialPort1.IsOpen) + //{ + // serialPort1.Close(); + //} Environment.Exit(0); } catch (Exception ex) @@ -2519,12 +1854,6 @@ namespace InjectionPC } } - ////if (bll.Add_Info_New(md, Program.tableName) == false) - //if (SaveBarCode(md, Program.tableName, false, "0",i== printCount) == false) - //{ - // return; - //} - string errMsg = string.Empty; bool saveRst = SaveInfo(md, false, "0", i == printCount, ref errMsg); if (saveRst == false) @@ -2572,191 +1901,6 @@ namespace InjectionPC } - #region 原来的 已注释 - //DataTable dt = bll.SearchSerialNoByBarCodeNew(partNo + "." + textBox1.Text.Trim(), Program.tableName); - //if (dt != null && dt.Rows.Count > 0) - //{ - // OneCode = dt.Rows[0]["OneBarCode"].ToString().Trim(); - // code = dt.Rows[0]["BarCode"].ToString().TrimEnd(); - // for (int i = 1; i <= Convert.ToInt32(textBox2.Text.Trim()); i++) - // { - // //newcode = code.Substring(0, code.Length - 4) + - // // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + i) - // // .ToString() - // // .PadLeft(4, '0'); - // ////86611-BU500.240826.0003 - // //if (OneCode != "") - // //{ - // // NewOneCode = OneCode.Substring(0, OneCode.Length - 4) + - // // (Convert.ToInt32(OneCode.Substring(OneCode.Length - 4, 4)) + i) - // // .ToString() - // // .PadLeft(4, '0'); - // //} - // //60000001942408260003 - // GetSjBarCode(stockNo, partNo, ref NewOneCode, ref newcode); - // string[] part = newcode.Split('.'); - - // #region 插入数据tb_barCode - - // md.ID = Guid.NewGuid().ToString(); - // md.StationID = stationID; - // md.OneBarCode = NewOneCode; - // md.BarCode = newcode; - // md.StockNo = stockNo; - // md.PartNo = partNo; - // md.PrintType = 1; - // md.PlanID = planID; - - // md.ProductNature = "正常件"; //第一次没有这个 - - // DataTable dt2 = pbll.SearchIsImportByPartNo(partNo); - // if (dt2 != null && dt2.Rows.Count > 0) - // { - // if (dt2.Rows[0]["isImport"].ToString() == "1") - // { - // md.Import = "国产料Kingfa"; - // } - // else - // { - // md.Import = ""; - // } - // } - - // if (bll.Add_Info_New(md, Program.tableName) == false) - // { - // return; - // } - - // #endregion - - // #region 打印单个标签 - - // if (IsOne == "1") - // { - // //filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码.grf"; - // filename = ManufacturerName.Contains("蔚来") - // ? System.AppDomain.CurrentDomain.BaseDirectory + - // "wl.grf" - // : System.AppDomain.CurrentDomain.BaseDirectory + - // "单个条码.grf"; - // if (partNo.Contains("A2146982300") || - // partNo.Contains("A2146982400")) - // { - // filename = AppDomain.CurrentDomain.BaseDirectory + - // "Sill.grf"; - // } - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("PrintTime"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("OneBarCode"); - // headTable.Columns.Add("BarCode"); - // DataRow row = headTable.NewRow(); - // row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss"); - // row["PartNo"] = partNo; - // row["PartName"] = PartName; - // row["OneBarCode"] = NewOneCode; - // row["BarCode"] = newcode; - - // DataTable dt4 = plbll.SearchInfo(partNo, stationID); - // if (dt4 != null && dt4.Rows.Count > 0) - // { - // printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); - // } - - // string reportName = ConfigurationManager.AppSettings[printName].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - // LogSysBLL.AddInfo(GetDateTime().ToString("yyyy/MM/dd HH:mm:ss") + NewOneCode, MethodBase.GetCurrentMethod()); - // rp.Report.Print(false); - // } - - // #endregion - // } - //} - //else - //{ - // for (int i = 1; i <= Convert.ToInt32(textBox2.Text.Trim()); i++) - // { - // //newcode = partNo + "." + textBox1.Text.Trim() + "." + i.ToString().PadLeft(4, '0'); - // //NewOneCode = stockNo + textBox1.Text.Trim() + i.ToString().PadLeft(4, '0'); - - // GetSjBarCode(stockNo, partNo,false, ref NewOneCode, ref newcode); - // string[] part = newcode.Split('.'); - - // #region 插入数据tb_barCode - - // md.ID = Guid.NewGuid().ToString(); - // md.StationID = stationID; - // md.OneBarCode = NewOneCode; - // md.BarCode = newcode; - // md.StockNo = stockNo; - // md.PartNo = partNo; - // md.PrintType = 1; - // md.PlanID = planID; - - // DataTable dt2 = pbll.SearchIsImportByPartNo(partNo); - // if (dt2 != null && dt2.Rows.Count > 0) - // { - // if (dt2.Rows[0]["isImport"].ToString() == "1") - // { - // md.Import = "国产料Kingfa"; - // } - // else - // { - // md.Import = ""; - // } - // } - - // if (bll.Add_Info_New(md, Program.tableName) == false) - // { - // return; - // } - - // #endregion - - // #region 打印单个标签 - - // if (IsOne == "1") - // { - // //filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码.grf"; - // filename = ManufacturerName.Contains("蔚来") - // ? System.AppDomain.CurrentDomain.BaseDirectory + - // "wl.grf" - // : System.AppDomain.CurrentDomain.BaseDirectory + - // "单个条码.grf"; - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("PrintTime"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("OneBarCode"); - // headTable.Columns.Add("BarCode"); - // DataRow row = headTable.NewRow(); - // row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss"); - // row["PartNo"] = partNo; - // row["PartName"] = PartName; - // row["OneBarCode"] = NewOneCode; - // row["BarCode"] = newcode; - - // DataTable dt4 = plbll.SearchInfo(partNo, stationID); - // if (dt4 != null && dt4.Rows.Count > 0) - // { - // printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); - // } - - // string reportName = ConfigurationManager.AppSettings[printName].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - // LogSysBLL.AddInfo(GetDateTime().ToString("yyyy/MM/dd HH:mm:ss") + NewOneCode, MethodBase.GetCurrentMethod()); - // rp.Report.Print(false); - // } - - // #endregion - // } - //} - #endregion #endregion } @@ -2836,160 +1980,7 @@ namespace InjectionPC #endregion } - - - //DataTable dts = bll.SearchInfoByPartNo1(partNo); - //if (dts != null && dts.Rows.Count > 0) - //{ - // code = dts.Rows[0]["BarCode"].ToString().Trim(); - // for (int i = 1; i <= Convert.ToInt32(textBox2.Text.Trim()); i++ ) - // { - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(23, 3)) + - // i).ToString() - // .PadLeft(3, '0') + "#"; - // 需要用GetSupplyCode新生成 - - // #region 插入数据tb_barCode - - // md.ID = Guid.NewGuid().ToString(); - // md.StationID = stationID; - // md.OneBarCode = NewOneCode; - // md.BarCode = newcode; - // md.StockNo = stockNo; - // md.PartNo = partNo; - // md.PrintType = 1; - // md.PlanID = planID; - - // DataTable dt2 = pbll.SearchIsImportByPartNo(partNo); - // if (dt2 != null && dt2.Rows.Count > 0) - // { - // if (dt2.Rows[0]["isImport"].ToString() == "1") - // { - // md.Import = "国产料Kingfa"; - // } - // else - // { - // md.Import = ""; - // } - // } - - // if (bll.Add_Info_New(md, Program.tableName) == false) - // { - // return; - // } - - // #endregion - - // #region 打印单个标签 - - // if (IsOne == "1") - // { - // filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码1.grf"; - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("PrintTime"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("OneBarCode"); - // headTable.Columns.Add("BarCode"); - // DataRow row = headTable.NewRow(); - // row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss"); - // row["PartNo"] = partNo; - // row["PartName"] = PartName; - // row["OneBarCode"] = NewOneCode; - // row["BarCode"] = newcode; - - // DataTable dt4 = plbll.SearchInfo(partNo, stationID); - // if (dt4 != null && dt4.Rows.Count > 0) - // { - // printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); - // } - - // string reportName = ConfigurationManager.AppSettings[printName].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - // LogSysBLL.AddInfo(GetDateTime().ToString("yyyy/MM/dd HH:mm:ss") + NewOneCode, MethodBase.GetCurrentMethod()); - // rp.Report.Print(false); - // } - - // #endregion - // } - //} - //else - //{ - // for (int i = 1; i <= Convert.ToInt32(textBox2.Text.Trim()); i++) - // { - // newcode = partNo + "#" + QLevel + "#" + - // textBox1.Text.Trim() + "#" + i.ToString().PadLeft(3, '0') + "#"; - // 需要用GetSupplyCode新写 - // #region 插入数据tb_barCode - - // md.ID = Guid.NewGuid().ToString(); - // md.StationID = stationID; - // md.OneBarCode = NewOneCode; - // md.BarCode = newcode; - // md.StockNo = stockNo; - // md.PartNo = partNo; - // md.PrintType = 1; - // md.PlanID = planID; - - // DataTable dt2 = pbll.SearchIsImportByPartNo(partNo); - // if (dt2 != null && dt2.Rows.Count > 0) - // { - // if (dt2.Rows[0]["isImport"].ToString() == "1") - // { - // md.Import = "国产料Kingfa"; - // } - // else - // { - // md.Import = ""; - // } - // } - - // if (bll.Add_Info_New(md, Program.tableName) == false) - // { - // return; - // } - - // #endregion - - // #region 打印单个标签 - - // if (IsOne == "1") - // { - // filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码1.grf"; - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("PrintTime"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("OneBarCode"); - // headTable.Columns.Add("BarCode"); - // DataRow row = headTable.NewRow(); - // row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss"); - // row["PartNo"] = partNo; - // row["PartName"] = PartName; - // row["OneBarCode"] = NewOneCode; - // row["BarCode"] = newcode; - - // DataTable dt4 = plbll.SearchInfo(partNo, stationID); - // if (dt4 != null && dt4.Rows.Count > 0) - // { - // printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); - // } - - // string reportName = ConfigurationManager.AppSettings[printName].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - // LogSysBLL.AddInfo(GetDateTime().ToString("yyyy/MM/dd HH:mm:ss") + NewOneCode, MethodBase.GetCurrentMethod()); - // rp.Report.Print(false); - // } - - // #endregion - // } - //} - + #endregion } @@ -3054,6 +2045,13 @@ namespace InjectionPC { ReAddBarCodeToBox(lbPackageCodeR, lbCurrentlQtyR, lbNeedQtyR, "右侧"); } + /// + /// 手动添加新箱码 + /// + /// + /// + /// + /// void ReAddBarCodeToBox(Label lbPackageCode, Label lbCurrentlQty, Label lbNeedQty,string hintTxt) { BarCodeBLL bll = new BarCodeBLL(); @@ -3166,8 +2164,8 @@ namespace InjectionPC ManufacturerName = pdt.Rows[0]["ManufacturerName"].ToString().Trim(); IsSupply = pdt.Rows[0]["IsSupply"].ToString(); } - - string msg = bll.ReprintSave(md, Program.tableName, "", "", Program.station); + //向箱码手动添加条码 + string msg = bll.ReprintSave(md, Program.tableName, "", "", Program.station, "2"); if (!string.IsNullOrEmpty(msg)) { MessageBox.Show($"补打失败,原因:" + msg); @@ -3299,8 +2297,8 @@ namespace InjectionPC } - - string msg = bll.ReprintSave(md, Program.tableName, dt.Rows[0]["OneBarCode"].ToString(), dt.Rows[0]["BarCode"].ToString(), Program.station); + //补打条码 + string msg = bll.ReprintSave(md, Program.tableName, dt.Rows[0]["OneBarCode"].ToString(), dt.Rows[0]["BarCode"].ToString(), Program.station,"3"); if (!string.IsNullOrEmpty(msg)) { MessageBox.Show($"补打失败,原因:" + msg); @@ -3527,7 +2525,7 @@ namespace InjectionPC printBoxName = "Printer" + (Convert.ToInt32(printName.Substring(7, 1)) + 2).ToString(); string reportName = ConfigurationManager.AppSettings[printBoxName].ToString(); headTable.Rows.Add(row); - + SaveLog3(Program.station + "打印箱单:" + textBox3.Text.Trim()); ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); rp.Report.Print(false); @@ -3570,6 +2568,7 @@ namespace InjectionPC { try { + if (UnCompletePrintBox("切换下一计划","all") == false) return; InjectionPlanBLL planbll=new InjectionPlanBLL(); @@ -3637,19 +2636,6 @@ namespace InjectionPC #endregion - #region 更新上一计划为完成模具条码不全暂时直接更新计划,后期需要屏蔽,打开下面的Region - - //StationBLL sbll = new StationBLL(); - //DataTable sdt = sbll.SearchInfoByNo(Program.station); - //if (sdt != null && sdt.Rows.Count > 0) - //{ - // md.StationID = sdt.Rows[0]["StationID"].ToString(); - //} - - //ibll.UpdateFinish(md); - - #endregion - #region 判断模具编号是否存在 模具条码不全暂时先屏蔽 DataTable dt5 = bll.SearchInfo(textBox4.Text.Trim()); @@ -3669,16 +2655,6 @@ namespace InjectionPC { #region 更新上一计划为完成 - //#region 获取工位编号 - - //StationBLL sbll1 = new StationBLL(); - //DataTable sdt1 = sbll1.SearchInfoByNo(Program.station); - //if (sdt1 != null && sdt1.Rows.Count > 0) - //{ - // md.StationID = sdt1.Rows[0]["StationID"].ToString(); - //} - - //#endregion md.InjectionPlanID = planID; ibll.UpdateFinish(md); if (!string.IsNullOrEmpty(nextPlanID) && nextPlanID != planID) @@ -3702,21 +2678,7 @@ namespace InjectionPC } else - { - #region 更新上一计划为完成 - - //StationBLL sbll1 = new StationBLL(); - //DataTable sdt1 = sbll1.SearchInfoByNo(Program.station); - //if (sdt1 != null && sdt1.Rows.Count > 0) - //{ - // md.StationID = sdt1.Rows[0]["StationID"].ToString(); - //} - - //md.InjectionPlanID = planID; - //ibll.UpdateFinish(md); - - #endregion - + { label12.Text = "暂无一下生产计划"; return; } @@ -3738,26 +2700,6 @@ namespace InjectionPC #region 获取当前生产信息 - //DataTable dt = ibll.SearchInfoByName(Program.station); - //if (dt != null && dt.Rows.Count > 0) - //{ - // planID = dt.Rows[0]["InjectionPlanID"].ToString(); - // string[] partNo1 = dt.Rows[0]["PartNo"].ToString().Split(','); - - // label12.Text = "当前生产计划为:"; - // for (int i = 0; i < partNo1.Length; i++) - // { - // DataTable dt2 = productBll.SearchInfoByPartNo(partNo1[i].ToString().Trim()); - // if (dt2 != null && dt2.Rows.Count > 0) - // { - // label12.Text += "零件号" + partNo1[i].ToString().Trim() + ",零件名称" + dt2.Rows[0]["ProductName"].ToString() + ";"; - // } - // } - //} - //else - //{ - // label12.Text = "暂无生产计划"; - //} initPlan(); #endregion @@ -3796,7 +2738,7 @@ namespace InjectionPC cboxHandBox.Enabled = true; opcServer.OPCGroups.RemoveAll(); opcServer.Disconnect(); - serialPort1.Close(); + //serialPort1.Close(); comboBox2.Enabled = true; label23.Enabled = true; label23.BackColor = System.Drawing.Color.DeepSkyBlue; @@ -3849,10 +2791,10 @@ namespace InjectionPC opcItems1 = opcGroup1.OPCItems; opcItems1.DefaultIsActive = true; - PLCMouldBLL PLCbll = new PLCMouldBLL(); - PLCBreakBLL bbll = new PLCBreakBLL(); + //PLCMouldBLL PLCbll = new PLCMouldBLL(); + //PLCBreakBLL bbll = new PLCBreakBLL(); - DataTable PLCdt = PLCbll.SearchMould(Program.station); + DataTable PLCdt = _PLCbll.SearchMould(Program.station); if (PLCdt != null && PLCdt.Rows.Count > 0) { opcItemm1 = new OPCItem[PLCdt.Rows.Count]; @@ -3898,24 +2840,6 @@ namespace InjectionPC #endregion - - //if (ConfigurationManager.AppSettings["StationMode"].ToString() == "1") - //{ - // timer1.Enabled = true; - //} - //if (ConfigurationManager.AppSettings["StationMode"].ToString() == "2") - //{ - // if (serialPort1.IsOpen) - // { - // serialPort1.Close(); - // serialPort1.Open(); - // } - // else - // { - // serialPort1.Open(); - // } - //} - label13.Text = "暂停打印"; label13.BackColor = System.Drawing.Color.DeepSkyBlue; label23.Enabled = false; @@ -3980,286 +2904,287 @@ namespace InjectionPC fr.Show(); } - private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) - { - try - { - base.Invoke(new EventHandler(this.Scan)); - } - catch (Exception ex) - { - LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); - } + //private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) + //{ + // try + // { + // base.Invoke(new EventHandler(this.Scan)); + // } + // catch (Exception ex) + // { + // LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + // } - } - - private void Scan(object sender, EventArgs e) - { - string _code_meca = "",printBoxName=""; - try - { - Thread.Sleep(1500); - char[] buffer = new char[serialPort1.BytesToRead]; - serialPort1.Read(buffer, 0, serialPort1.BytesToRead); - for (int i = 0; i < buffer.Length; i++) - { - _code_meca = _code_meca + buffer[i]; - } - - GetClass(); - - string aa = _code_meca; - - var result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\n\s*", ","); - result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\f\s*", ","); - result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\r\s*", ","); - result1 = result1.Remove(result1.LastIndexOf(","), 1); - result1 = result1.Remove(result1.LastIndexOf("g"), 1); - int idxStart = result1.LastIndexOf(" "); - string value = result1.Substring(idxStart, result1.Length - idxStart).Trim(); - string[] b = value.Split('.'); - string c = b[0]; - string d = b[1]; - int chengzhong = Convert.ToInt32(c); - int chengzhong1 = Convert.ToInt32(d); - if (chengzhong1 >= 5) - { - chengzhong = chengzhong + 1; //重量 - } - - InjectionPlanBLL bll = new InjectionPlanBLL(); - BarCodeBLL brbll = new BarCodeBLL(); - BarCodeModel md = new BarCodeModel(); - ProductBLL productBll = new ProductBLL(); - PlasticBLL pbll = _plasticBLL; - InjectionBoxBLL boxbll = new InjectionBoxBLL(); - InjectionBoxModel boxmd = new InjectionBoxModel(); - DataTable dt2 = null; - string code = "", OneCode = ""; - string newcode = "", newcode1 = "", NewOneCode = "", NewOneCode1 = ""; - string IsPack = "", IsOne = "", QLevel = "", IsPaint = "", PartName = "",IsSupply=""; - string filename = "", printName = ""; - int MaxCount = 0, CurrentCount = 0; - - #region 查找当前计划 - - DataTable dt = bll.SearchInfoByName(Program.station); - if (dt != null && dt.Rows.Count > 0) - { - planID = dt.Rows[0]["InjectionPlanID"].ToString(); - string[] partNo = dt.Rows[0]["PartNo"].ToString().Split(','); - string[] stockNo = new string [partNo.Length]; - //string[] stockNo = dt.Rows[0]["StockNo"].ToString().Split(','); - string ProductNature = dt.Rows[0]["ProductNature"].ToString(); - int IsSame = 0; - - #region 判断有几个零件号 - string mould = "0"; - for (int j = 0; j < partNo.Length; j++) - { - #region 根据零件号查找存货代码 - - DataTable sdt = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - if (sdt != null && sdt.Rows.Count > 0) - { - stockNo[j] = sdt.Rows[0]["StockNo"].ToString(); - IsSame=Convert.ToInt32(sdt.Rows[0]["IsSame"].ToString()); - } - else - { - stockNo[j] = ""; - IsSame = 0; - } - - #endregion - - DataTable dt3 = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - if (dt3 != null && dt3.Rows.Count > 0) - { - QLevel = dt3.Rows[0]["QLevel"].ToString(); - IsOne = dt3.Rows[0]["IsPrintOneTag"].ToString(); - IsPack = dt3.Rows[0]["IsPrintPackList"].ToString(); - IsPaint = dt3.Rows[0]["IsPlating"].ToString(); - PartName = dt3.Rows[0]["ProductName"].ToString(); - MaxCount = Convert.ToInt32(dt3.Rows[0]["PackCount"].ToString()); - IsSupply = dt3.Rows[0]["IsSupply"].ToString(); - } - - if (IsSame == 1) - { - for (int k = 0; k < 2; k++) - { + //} + + //private void Scan(object sender, EventArgs e) + //{ + // string _code_meca = "",printBoxName=""; + // try + // { + // Thread.Sleep(1500); + // char[] buffer = new char[serialPort1.BytesToRead]; + // serialPort1.Read(buffer, 0, serialPort1.BytesToRead); + // for (int i = 0; i < buffer.Length; i++) + // { + // _code_meca = _code_meca + buffer[i]; + // } + + // GetClass(); + + // string aa = _code_meca; + + // var result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\n\s*", ","); + // result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\f\s*", ","); + // result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\r\s*", ","); + // result1 = result1.Remove(result1.LastIndexOf(","), 1); + // result1 = result1.Remove(result1.LastIndexOf("g"), 1); + // int idxStart = result1.LastIndexOf(" "); + // string value = result1.Substring(idxStart, result1.Length - idxStart).Trim(); + // string[] b = value.Split('.'); + // string c = b[0]; + // string d = b[1]; + // int chengzhong = Convert.ToInt32(c); + // int chengzhong1 = Convert.ToInt32(d); + // if (chengzhong1 >= 5) + // { + // chengzhong = chengzhong + 1; //重量 + // } + + // InjectionPlanBLL bll = new InjectionPlanBLL(); + // BarCodeBLL brbll = new BarCodeBLL(); + // BarCodeModel md = new BarCodeModel(); + // ProductBLL productBll = new ProductBLL(); + // PlasticBLL pbll = _plasticBLL; + // InjectionBoxBLL boxbll = new InjectionBoxBLL(); + // InjectionBoxModel boxmd = new InjectionBoxModel(); + // DataTable dt2 = null; + // string code = "", OneCode = ""; + // string newcode = "", newcode1 = "", NewOneCode = "", NewOneCode1 = ""; + // string IsPack = "", IsOne = "", QLevel = "", IsPaint = "", PartName = "",IsSupply=""; + // string filename = "", printName = ""; + // int MaxCount = 0, CurrentCount = 0; + + // #region 查找当前计划 + + // DataTable dt = bll.SearchInfoByName(Program.station); + // if (dt != null && dt.Rows.Count > 0) + // { + // planID = dt.Rows[0]["InjectionPlanID"].ToString(); + // string[] partNo = dt.Rows[0]["PartNo"].ToString().Split(','); + // string[] stockNo = new string [partNo.Length]; + // //string[] stockNo = dt.Rows[0]["StockNo"].ToString().Split(','); + // string ProductNature = dt.Rows[0]["ProductNature"].ToString(); + // int IsSame = 0; + + // #region 判断有几个零件号 + // string mould = "0"; + // for (int j = 0; j < partNo.Length; j++) + // { + // #region 根据零件号查找存货代码 + + // DataTable sdt = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); + // if (sdt != null && sdt.Rows.Count > 0) + // { + // stockNo[j] = sdt.Rows[0]["StockNo"].ToString(); + // IsSame=Convert.ToInt32(sdt.Rows[0]["IsSame"].ToString()); + // } + // else + // { + // stockNo[j] = ""; + // IsSame = 0; + // } + + // #endregion + + // DataTable dt3 = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); + // if (dt3 != null && dt3.Rows.Count > 0) + // { + // QLevel = dt3.Rows[0]["QLevel"].ToString(); + // IsOne = dt3.Rows[0]["IsPrintOneTag"].ToString(); + // IsPack = dt3.Rows[0]["IsPrintPackList"].ToString(); + // IsPaint = dt3.Rows[0]["IsPlating"].ToString(); + // PartName = dt3.Rows[0]["ProductName"].ToString(); + // MaxCount = Convert.ToInt32(dt3.Rows[0]["PackCount"].ToString()); + // IsSupply = dt3.Rows[0]["IsSupply"].ToString(); + // } + + // if (IsSame == 1) + // { + // for (int k = 0; k < 2; k++) + // { - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, "", ref NewOneCode, ref newcode); - - #region 插入数据tb_barCode - - md.ID = Guid.NewGuid().ToString(); - md.StationID = dt.Rows[0]["StationID"].ToString(); - md.OneBarCode = NewOneCode; - md.BarCode = newcode; - md.StockNo = stockNo[j].ToString().Trim(); - md.PartNo = partNo[j].ToString().Trim(); - md.PrintType = 0; - md.PlanID = planID; - md.ProductNature = ProductNature; - md.Des1 = PartName; - DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString()); - if (pdt != null && pdt.Rows.Count > 0) - { - if (pdt.Rows[0]["isImport"].ToString() == "1") - { - md.Import = "国产料Kingfa"; - } - else - { - md.Import = ""; - } - } - - ////if (brbll.Add_Info_New(md, Program.tableName)==false) - //if (SaveBarCode(md, Program.tableName, true, mould) == false) - //{ - // return; - //} - - string errMsg = string.Empty; - bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); - if (saveRst == false) - { - MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); - return; - } - - #endregion - - #region 打印条码,判断是否打印单个条码 - - DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), - dt.Rows[0]["StationID"].ToString()); - if (dt4 != null && dt4.Rows.Count > 0) - { - printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); - } - - #region 打印单个标签 - - if (IsOne == "1") - { - if (IsSupply == "1") - { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply, "Print" + Program.station + "_3922"); - - string reportName = ConfigurationManager.AppSettings[printName].ToString(); - DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode); - - ReportHelper rp = new ReportHelper(filename, headTable, null, - (int) GRPaperOrientation.grpoDefault, 1, reportName); - - rp.Report.Print(false); - } - } - - #endregion + // GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, "", ref NewOneCode, ref newcode); + + // #region 插入数据tb_barCode + + // md.ID = Guid.NewGuid().ToString(); + // md.StationID = dt.Rows[0]["StationID"].ToString(); + // md.OneBarCode = NewOneCode; + // md.BarCode = newcode; + // md.StockNo = stockNo[j].ToString().Trim(); + // md.PartNo = partNo[j].ToString().Trim(); + // md.PrintType = 0; + // md.PlanID = planID; + // md.ProductNature = ProductNature; + // md.Des1 = PartName; + // DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString()); + // if (pdt != null && pdt.Rows.Count > 0) + // { + // if (pdt.Rows[0]["isImport"].ToString() == "1") + // { + // md.Import = "国产料Kingfa"; + // } + // else + // { + // md.Import = ""; + // } + // } + + // ////if (brbll.Add_Info_New(md, Program.tableName)==false) + // //if (SaveBarCode(md, Program.tableName, true, mould) == false) + // //{ + // // return; + // //} + + // string errMsg = string.Empty; + // bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); + // if (saveRst == false) + // { + // MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); + // return; + // } + + // #endregion + + // #region 打印条码,判断是否打印单个条码 + + // DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), + // dt.Rows[0]["StationID"].ToString()); + // if (dt4 != null && dt4.Rows.Count > 0) + // { + // printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); + // } + + // #region 打印单个标签 + + // if (IsOne == "1") + // { + // if (IsSupply == "1") + // { + // filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply, "Print" + Program.station + "_3922"); + + // string reportName = ConfigurationManager.AppSettings[printName].ToString(); + // DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode); + + // ReportHelper rp = new ReportHelper(filename, headTable, null, + // (int) GRPaperOrientation.grpoDefault, 1, reportName); + + // rp.Report.Print(false); + // } + // } + + // #endregion - #endregion - } - } - else - { - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, "", ref NewOneCode, ref newcode); - - #region 插入数据tb_barCode - - md.ID = Guid.NewGuid().ToString(); - md.StationID = dt.Rows[0]["StationID"].ToString(); - md.OneBarCode = NewOneCode; - md.BarCode = newcode; - md.StockNo = stockNo[j].ToString().Trim(); - md.PartNo = partNo[j].ToString().Trim(); - md.PrintType = 0; - md.PlanID = planID; - md.ProductNature = ProductNature; - md.Des1 = PartName; - DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString()); - if (pdt != null && pdt.Rows.Count > 0) - { - if (pdt.Rows[0]["isImport"].ToString() == "1") - { - md.Import = "国产料Kingfa"; - } - else - { - md.Import = ""; - } - } - - ////if (brbll.Add_Info_New(md, Program.tableName)==false) - //if (SaveBarCode(md, Program.tableName, true, mould) == false) - //{ - // return; - //} - - string errMsg = string.Empty; - bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); - if (saveRst == false) - { - MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); - return; - } - #endregion - - #region 打印条码,判断是否打印单个条码 - - DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), - dt.Rows[0]["StationID"].ToString()); - if (dt4 != null && dt4.Rows.Count > 0) - { - printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); - } - - #region 打印单个标签 - - if (IsOne == "1") - { - if (IsSupply == "1") - { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply, "Print" + Program.station + "_3993"); //new - - string reportName = ConfigurationManager.AppSettings[printName].ToString(); - DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode); - - LogHelper.WriteLog(printName + ";" + reportName + ";" + filename); - ReportHelper rp = new ReportHelper(filename, headTable, null, - (int) GRPaperOrientation.grpoDefault, 1, reportName); - - rp.Report.Print(false); - } - } - - #endregion + // #endregion + // } + // } + // else + // { + // GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, "", ref NewOneCode, ref newcode); + + // #region 插入数据tb_barCode + + // md.ID = Guid.NewGuid().ToString(); + // md.StationID = dt.Rows[0]["StationID"].ToString(); + // md.OneBarCode = NewOneCode; + // md.BarCode = newcode; + // md.StockNo = stockNo[j].ToString().Trim(); + // md.PartNo = partNo[j].ToString().Trim(); + // md.PrintType = 0; + // md.PlanID = planID; + // md.ProductNature = ProductNature; + // md.Des1 = PartName; + // DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString()); + // if (pdt != null && pdt.Rows.Count > 0) + // { + // if (pdt.Rows[0]["isImport"].ToString() == "1") + // { + // md.Import = "国产料Kingfa"; + // } + // else + // { + // md.Import = ""; + // } + // } + + // ////if (brbll.Add_Info_New(md, Program.tableName)==false) + // //if (SaveBarCode(md, Program.tableName, true, mould) == false) + // //{ + // // return; + // //} + + // string errMsg = string.Empty; + // bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); + // if (saveRst == false) + // { + // MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); + // return; + // } + // #endregion + + // #region 打印条码,判断是否打印单个条码 + + // DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), + // dt.Rows[0]["StationID"].ToString()); + // if (dt4 != null && dt4.Rows.Count > 0) + // { + // printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); + // } + + // #region 打印单个标签 + + // if (IsOne == "1") + // { + // if (IsSupply == "1") + // { + // filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply, "Print" + Program.station + "_3993"); //new + + // string reportName = ConfigurationManager.AppSettings[printName].ToString(); + // DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode); + + // LogHelper.WriteLog(printName + ";" + reportName + ";" + filename); + // ReportHelper rp = new ReportHelper(filename, headTable, null, + // (int) GRPaperOrientation.grpoDefault, 1, reportName); + + // rp.Report.Print(false); + // } + // } + + // #endregion - #endregion - } - initBarCode(); - } - - #endregion - } - - #endregion - } - catch (Exception ex) - { - LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); - } - } + // #endregion + // } + // initBarCode(); + // } + + // #endregion + // } + + // #endregion + // } + // catch (Exception ex) + // { + // LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + // } + //} private void timer2_Tick(object sender, EventArgs e) { - initPlan(); + Program.ProductDate = _barCodeBLL.GetServiceTime().ToString(); + //initPlan(); } private void comboBox2_TextChanged(object sender, EventArgs e) @@ -4310,10 +3235,10 @@ namespace InjectionPC label2.BackColor = Color.Red; } GetClass(); - textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + - Program.ProductDate.Substring(8, 2); //批次 - + //textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + + // Program.ProductDate.Substring(8, 2); //批次 + textBox1.Text = GetBatch(true); #region 获取当前生产信息 @@ -4475,7 +3400,7 @@ namespace InjectionPC if (isAutoPrint == true || (isAutoPrint==false && cboxHandBox.Checked ==true)) { bcm.BoxNo = lbPackageCode.Text.Trim(); - saveRst = _barCodeBLL.Add_Info_New(bcm, Program.tableName); + saveRst = _barCodeBLL.Add_Info_New(bcm, Program.tableName); if (saveRst == true) { @@ -4494,6 +3419,12 @@ namespace InjectionPC int sizeCount = 0; int.TryParse(realCountStr, out realCount); int.TryParse(sizeCountStr, out sizeCount); + + // if(Program.station == "IM18") + // { + SaveLog3($"{Program.station}装箱测试:realCount=[{realCount}],sizeCount=[{sizeCount}],isAutoPrint=[{isAutoPrint}],handPrint=[{handPrint}]"); + //} + if ((realCount != 0 && realCount == sizeCount) || (isAutoPrint == false && handPrint==true)) { lbPackageCode.Text = ""; @@ -4508,7 +3439,7 @@ namespace InjectionPC } else { - errorMsg = rst; + errorMsg = "插入接口表时异常-" +rst; MessageBox.Show(rst); } } @@ -4520,6 +3451,7 @@ namespace InjectionPC } else { + errorMsg = "插入表" + Program.tableName + "时发生异常"; saveRst = false; } } @@ -4556,6 +3488,7 @@ namespace InjectionPC /// private void PrintBoxCode(DataRow boxRow,int realCount,string mould) { + SaveLog3(Program.station + "箱单打印mould="+ mould); string filename = System.AppDomain.CurrentDomain.BaseDirectory + "装箱单.grf"; DataTable headTable = new DataTable(); headTable.Columns.Add("BoxNo"); @@ -4594,6 +3527,7 @@ namespace InjectionPC string reportName = ConfigurationManager.AppSettings[printBoxName].ToString(); headTable.Rows.Add(row); + SaveLog3(Program.station + "打印箱单:" + boxCode); ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); rp.Report.Print(false); @@ -4618,17 +3552,23 @@ namespace InjectionPC { Label lbPackageCode = lbPackageCodeL; Label lbNeedQty = lbNeedQtyL; + Label lbCurrentlQty = lbCurrentlQtyL; if (mould == _leftType) { lbPackageCode = lbPackageCodeL; lbNeedQty = lbNeedQtyL; + lbCurrentlQty = lbCurrentlQtyL; } else { lbPackageCode = lbPackageCodeR; lbNeedQty = lbNeedQtyR; + lbCurrentlQty = lbCurrentlQtyR; } string pkgCode = lbPackageCode.Text.Trim(); + + + if (string.IsNullOrEmpty(pkgCode)) { string packageCode = GetPackageCode(partCode, autoPrint); @@ -4648,6 +3588,34 @@ namespace InjectionPC lbPackageCode.Text = packageCode; } } + else + { + #region 如果零件号和箱码不匹配,重新生成箱码,打印前一箱并关闭 + if (!string.IsNullOrEmpty(pkgCode) && pkgCode.Contains(partCode) == false) + { + DataTable dt = _injectionBoxBLL.SearchBox(pkgCode); + MessageBox.Show($"箱码[{pkgCode}]产品与当前产品[{partCode}]不匹配,将会打印上一箱码,请知悉!"); + CompleteBoxAndPrint(dt.Rows[0], mould, lbPackageCode, lbCurrentlQty); + + string packageCode = GetPackageCode(partCode, autoPrint); + InjectionBoxModel boxmd = new InjectionBoxModel(); + boxmd.ID = Guid.NewGuid().ToString(); + boxmd.BoxNo = packageCode; + boxmd.BoxCount = 0; + boxmd.BoxType = 0; + boxmd.IsFlag = 0; + boxmd.StationNo = Program.station; + boxmd.PartName = partName; + + boxmd.Mould = mould; + boxmd.StandardQty = lbNeedQty.Text; + if (_injectionBoxBLL.AddInfo(boxmd)) + { + lbPackageCode.Text = packageCode; + } + } + #endregion + } } } @@ -4699,7 +3667,13 @@ namespace InjectionPC string batch = string.Empty; if (isAutoPrint) { - batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + DateTime dt = DateTime.Now; + if(DateTime.TryParse(Program.ProductDate, out dt) ==false) + { + dt = DateTime.Now; + } + batch = dt.ToString("yyMMdd"); + // batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); } else { @@ -4878,7 +3852,8 @@ namespace InjectionPC string batch = string.Empty; if (autoPrint) { - batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + // batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + batch = GetBatch(true); } else { @@ -4999,11 +3974,12 @@ namespace InjectionPC IsTest = true; bool bbb = true; //label23_Click(null, null); - textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + - Program.ProductDate.Substring(8, 2); + //textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + + // Program.ProductDate.Substring(8, 2); + textBox1.Text = GetBatch(true); if (bbb == true) { //自动 - opcGroup1_DataChange(1, 2, ref a, ref b, ref c, ref d); + opcGroup1_DataChange(1, 1, ref a, ref b, ref c, ref d); } else { //手动 @@ -5051,20 +4027,22 @@ namespace InjectionPC } } - lbPackageCodeL.Text = ""; - lbCurrentlQtyL.Text = "0"; + //lbPackageCodeL.Text = ""; + //lbCurrentlQtyL.Text = "0"; + + //string rst = _wmsBll.SaveInterface(dt.Rows[0]["BoxNo"].ToString(), "", "", MESClassLibrary.Enum.WmsInterfaceEnum.塑件箱码报工, Program.station); + //if (string.IsNullOrEmpty(rst)) + //{ + // PrintBoxCode(dt.Rows[0], int.Parse(dt.Rows[0]["BoxCount"].ToString()), "0"); + //} + //else + //{ + // MessageBox.Show(rst); + // return false; + //} + + CompleteBoxAndPrint(dt.Rows[0], "0", lbPackageCodeL, lbCurrentlQtyL); - string rst = _wmsBll.SaveInterface(dt.Rows[0]["BoxNo"].ToString(), "", "", MESClassLibrary.Enum.WmsInterfaceEnum.塑件箱码报工, Program.station); - if (string.IsNullOrEmpty(rst)) - { - PrintBoxCode(dt.Rows[0], int.Parse(dt.Rows[0]["BoxCount"].ToString()), "0"); - } - else - { - MessageBox.Show(rst); - return false; - } - } } } @@ -5083,17 +4061,46 @@ namespace InjectionPC } } - lbPackageCodeR.Text = ""; - lbCurrentlQtyR.Text = "0"; + //lbPackageCodeR.Text = ""; + //lbCurrentlQtyR.Text = "0"; - _wmsBll.SaveInterface(dt.Rows[0]["BoxNo"].ToString(), "", "", MESClassLibrary.Enum.WmsInterfaceEnum.塑件箱码报工, Program.station); - PrintBoxCode(dt.Rows[0], int.Parse(dt.Rows[0]["BoxCount"].ToString()), "1"); + //_wmsBll.SaveInterface(dt.Rows[0]["BoxNo"].ToString(), "", "", MESClassLibrary.Enum.WmsInterfaceEnum.塑件箱码报工, Program.station); + //PrintBoxCode(dt.Rows[0], int.Parse(dt.Rows[0]["BoxCount"].ToString()), "1"); + CompleteBoxAndPrint(dt.Rows[0], "1", lbPackageCodeR, lbCurrentlQtyR); } } } return true; } + /// + /// 完成箱单并打印箱单 + /// + bool CompleteBoxAndPrint( DataRow boxRow,string mould, Label lbPackageCode, Label lbCurrentlQty) + { + try + { + lbPackageCode.Text = ""; + lbCurrentlQty.Text = "0"; + + string rst = _wmsBll.SaveInterface(boxRow["BoxNo"].ToString(), "", "", MESClassLibrary.Enum.WmsInterfaceEnum.塑件箱码报工, Program.station); + if (string.IsNullOrEmpty(rst)) + { + PrintBoxCode(boxRow, int.Parse(boxRow["BoxCount"].ToString()), mould); + } + else + { + MessageBox.Show("CompleteBoxAndPrint" + rst); + return false; + } + return true; + } + catch(Exception ex) + { + LogErrBLL.AddInfo(Program.station + "完成箱单并打印箱单发生错误," + ex.ToString(), MethodBase.GetCurrentMethod()); + return false; + } + } private void btnChangeSizeL_Click(object sender, EventArgs e) { @@ -5150,6 +4157,12 @@ namespace InjectionPC if (MessageBox.Show("确定切换为单条码模式?", "切换确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; try { + if (UnCompletePrintBox("切换单条码模式", "all") == false) return; + + if(Program.station == "IM18") + { + SaveLog3($"IM18切换从箱码模式切换单条码模式,箱码[{ lbPackageCodeL.Text?.Trim()}],左实际数量[{lbCurrentlQtyL.Text?.Trim()}],右实际数量[{lbCurrentlQtyR.Text?.Trim()}]"); + } this.FormClosed += (arg1, arg2) => { opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange); @@ -5208,40 +4221,37 @@ namespace InjectionPC string PrintMoudleName(string isSupply = "0",string invokeInfo ="") { - //if (!string.IsNullOrEmpty(invokeInfo)) + return BussinessHelper.PrintMoudleName(Program.station, isSupply); + + //if("IM05,IM08,IM10".Contains(Program.station)) //二维小条码 //{ - // SaveLog2(invokeInfo); + // return "单个条码2.grf"; + //} + //else if ("IM06,IM07,IM09,IM11,IM12,".Contains(Program.station)) //一维条码 + //{ + // return "单个条码.grf"; //} - - if("IM05,IM08,IM10".Contains(Program.station)) //二维小条码 - { - return "单个条码2.grf"; - } - else if ("IM06,IM07,IM09,IM11,IM12,".Contains(Program.station)) //一维条码 - { - return "单个条码.grf"; - } - else if ("IM01,IM02,IM03,IM04,IM15,IM18,IM20".Contains(Program.station)) //小米大条码 - { - return "Sill.grf"; - } - else if ("IM13,IM14".Contains(Program.station)) //直供条码 - { - if(isSupply == "0") //13,14机台,直供件打二维码 非直供件打一维码 - { - return "单个条码.grf"; - } - else - { - return "单个条码2.grf"; - } + //else if ("IM01,IM02,IM03,IM04,IM15,IM18,IM20".Contains(Program.station)) //小米大条码 + //{ + // return "Sill.grf"; + //} + //else if ("IM13,IM14".Contains(Program.station)) //直供条码 + //{ + // if(isSupply == "0") //13,14机台,直供件打二维码 非直供件打一维码 + // { + // return "单个条码.grf"; + // } + // else + // { + // return "单个条码2.grf"; + // } - } - else - { - return "单个条码2.grf"; - } + //} + //else + //{ + // return "单个条码2.grf"; + //} } DataTable GetPrintLableModel() @@ -5395,10 +4405,10 @@ namespace InjectionPC opcItems1 = opcGroup1.OPCItems; opcItems1.DefaultIsActive = true; - PLCMouldBLL PLCbll = new PLCMouldBLL(); - PLCBreakBLL bbll = new PLCBreakBLL(); + //PLCMouldBLL PLCbll = new PLCMouldBLL(); + //PLCBreakBLL bbll = new PLCBreakBLL(); - DataTable PLCdt = PLCbll.SearchMould(Program.station); + DataTable PLCdt = _PLCbll.SearchMould(Program.station); if (PLCdt != null && PLCdt.Rows.Count > 0) { opcItemm1 = new OPCItem[PLCdt.Rows.Count]; diff --git a/InjectionPC/FrmMain2411.Designer.cs b/InjectionPC/FrmMain2411.Designer.cs index 1c2674b..4255b6f 100644 --- a/InjectionPC/FrmMain2411.Designer.cs +++ b/InjectionPC/FrmMain2411.Designer.cs @@ -28,7 +28,6 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); GlacialComponents.Controls.GLColumn glColumn1 = new GlacialComponents.Controls.GLColumn(); GlacialComponents.Controls.GLColumn glColumn2 = new GlacialComponents.Controls.GLColumn(); GlacialComponents.Controls.GLColumn glColumn3 = new GlacialComponents.Controls.GLColumn(); @@ -124,10 +123,10 @@ this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label35 = new System.Windows.Forms.Label(); this.label39 = new System.Windows.Forms.Label(); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.serialPort1 = new System.IO.Ports.SerialPort(this.components); - this.timer2 = new System.Windows.Forms.Timer(this.components); - this.timer3 = new System.Windows.Forms.Timer(this.components); + this.timer1 = new System.Windows.Forms.Timer(); + this.serialPort1 = new System.IO.Ports.SerialPort(); + this.timer2 = new System.Windows.Forms.Timer(); + this.timer3 = new System.Windows.Forms.Timer(); this.panel1.SuspendLayout(); this.panel7.SuspendLayout(); this.panel23.SuspendLayout(); @@ -1301,12 +1300,9 @@ // this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // - // serialPort1 - // - this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived); - // // timer2 // + this.timer2.Enabled = true; this.timer2.Interval = 5000; this.timer2.Tick += new System.EventHandler(this.timer2_Tick); // diff --git a/InjectionPC/FrmMain2411.cs b/InjectionPC/FrmMain2411.cs index 279439f..7292dc0 100644 --- a/InjectionPC/FrmMain2411.cs +++ b/InjectionPC/FrmMain2411.cs @@ -57,6 +57,8 @@ namespace InjectionPC private bool _isPrintPackage = true; private BarCodeBLL _barCodeBLL = new BarCodeBLL(); private InjectionBoxBLL _injectionBoxBLL = new InjectionBoxBLL(); + private PLCMouldBLL _PLCbll = new PLCMouldBLL(); + private PLCBreakBLL _bbll = new PLCBreakBLL(); private DataTable tb_Plastic = new DataTable(); private string _currentStationID = string.Empty; private const string _leftType = "0"; //模具1 @@ -109,8 +111,9 @@ namespace InjectionPC comboBox1.Text = "A班"; //班次 Program.cc = comboBox1.Text; initProduct(); - textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + - Program.ProductDate.Substring(8, 2); //批次 + //textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + + // Program.ProductDate.Substring(8, 2); //批次 + textBox1.Text = GetBatch(true); initBarCode(); label23.Enabled = false; label23.BackColor = System.Drawing.Color.Gray; @@ -194,10 +197,10 @@ namespace InjectionPC opcItems1 = opcGroup1.OPCItems; opcItems1.DefaultIsActive = true; - PLCMouldBLL PLCbll = new PLCMouldBLL(); - PLCBreakBLL bbll = new PLCBreakBLL(); + //PLCMouldBLL PLCbll = new PLCMouldBLL(); + //PLCBreakBLL bbll = new PLCBreakBLL(); - DataTable PLCdt = PLCbll.SearchMould(Program.station); + DataTable PLCdt = _PLCbll.SearchMould(Program.station); if (PLCdt != null && PLCdt.Rows.Count > 0) { opcItemm1 = new OPCItem[PLCdt.Rows.Count]; @@ -348,6 +351,7 @@ namespace InjectionPC string filename = "", printName = "", printBoxName=""; int MaxCount = 0, CurrentCount = 0; + if (status == false) { @@ -371,12 +375,13 @@ namespace InjectionPC { return; } - + _bbll.SavePlcReceive(Program.station, TransactionID, NumItems, aa, planID, "2411"); #endregion //comboBox1.Text = "A班"; //班次 - textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + - Program.ProductDate.Substring(8, 2); //批次 + //textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + + // Program.ProductDate.Substring(8, 2); //批次 + textBox1.Text = GetBatch(true); } catch(Exception ex) { @@ -2157,8 +2162,8 @@ namespace InjectionPC MessageBox.Show($"补打失败,条码[{code}]在表[{ Program.tableName}]中不存在!"); return; } - - string msg = bll.ReprintSave(md, Program.tableName, dt.Rows[0]["OneBarCode"].ToString(), dt.Rows[0]["BarCode"].ToString(),Program.station); + //补打条码 + string msg = bll.ReprintSave(md, Program.tableName, dt.Rows[0]["OneBarCode"].ToString(), dt.Rows[0]["BarCode"].ToString(),Program.station,"3"); if (!string.IsNullOrEmpty(msg)) { MessageBox.Show($"补打失败,原因:" + msg); @@ -2683,10 +2688,10 @@ namespace InjectionPC opcItems1 = opcGroup1.OPCItems; opcItems1.DefaultIsActive = true; - PLCMouldBLL PLCbll = new PLCMouldBLL(); - PLCBreakBLL bbll = new PLCBreakBLL(); + //PLCMouldBLL PLCbll = new PLCMouldBLL(); + //PLCBreakBLL bbll = new PLCBreakBLL(); - DataTable PLCdt = PLCbll.SearchMould(Program.station); + DataTable PLCdt = _PLCbll.SearchMould(Program.station); if (PLCdt != null && PLCdt.Rows.Count > 0) { opcItemm1 = new OPCItem[PLCdt.Rows.Count]; @@ -2802,286 +2807,289 @@ namespace InjectionPC fr.Show(); } - private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) - { - try - { - base.Invoke(new EventHandler(this.Scan)); - } - catch (Exception ex) - { - LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); - } - - } - - private void Scan(object sender, EventArgs e) - { - string _code_meca = "",printBoxName=""; - try - { - Thread.Sleep(1500); - char[] buffer = new char[serialPort1.BytesToRead]; - serialPort1.Read(buffer, 0, serialPort1.BytesToRead); - for (int i = 0; i < buffer.Length; i++) - { - _code_meca = _code_meca + buffer[i]; - } - - GetClass(); - - string aa = _code_meca; - - var result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\n\s*", ","); - result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\f\s*", ","); - result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\r\s*", ","); - result1 = result1.Remove(result1.LastIndexOf(","), 1); - result1 = result1.Remove(result1.LastIndexOf("g"), 1); - int idxStart = result1.LastIndexOf(" "); - string value = result1.Substring(idxStart, result1.Length - idxStart).Trim(); - string[] b = value.Split('.'); - string c = b[0]; - string d = b[1]; - int chengzhong = Convert.ToInt32(c); - int chengzhong1 = Convert.ToInt32(d); - if (chengzhong1 >= 5) - { - chengzhong = chengzhong + 1; //重量 - } - - InjectionPlanBLL bll = new InjectionPlanBLL(); - BarCodeBLL brbll = new BarCodeBLL(); - BarCodeModel md = new BarCodeModel(); - ProductBLL productBll = new ProductBLL(); - PlasticBLL pbll = _plasticBLL; - InjectionBoxBLL boxbll = new InjectionBoxBLL(); - InjectionBoxModel boxmd = new InjectionBoxModel(); - DataTable dt2 = null; - string code = "", OneCode = ""; - string newcode = "", newcode1 = "", NewOneCode = "", NewOneCode1 = ""; - string IsPack = "", IsOne = "", QLevel = "", IsPaint = "", PartName = "",IsSupply=""; - string filename = "", printName = ""; - int MaxCount = 0, CurrentCount = 0; - - #region 查找当前计划 - - DataTable dt = bll.SearchInfoByName(Program.station); - if (dt != null && dt.Rows.Count > 0) - { - planID = dt.Rows[0]["InjectionPlanID"].ToString(); - string[] partNo = dt.Rows[0]["PartNo"].ToString().Split(','); - string[] stockNo = new string [partNo.Length]; - //string[] stockNo = dt.Rows[0]["StockNo"].ToString().Split(','); - string ProductNature = dt.Rows[0]["ProductNature"].ToString(); - int IsSame = 0; - - #region 判断有几个零件号 - string mould = "0"; - for (int j = 0; j < partNo.Length; j++) - { - #region 根据零件号查找存货代码 - - DataTable sdt = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - if (sdt != null && sdt.Rows.Count > 0) - { - stockNo[j] = sdt.Rows[0]["StockNo"].ToString(); - IsSame=Convert.ToInt32(sdt.Rows[0]["IsSame"].ToString()); - } - else - { - stockNo[j] = ""; - IsSame = 0; - } - - #endregion - - DataTable dt3 = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - if (dt3 != null && dt3.Rows.Count > 0) - { - QLevel = dt3.Rows[0]["QLevel"].ToString(); - IsOne = dt3.Rows[0]["IsPrintOneTag"].ToString(); - IsPack = dt3.Rows[0]["IsPrintPackList"].ToString(); - IsPaint = dt3.Rows[0]["IsPlating"].ToString(); - PartName = dt3.Rows[0]["ProductName"].ToString(); - MaxCount = Convert.ToInt32(dt3.Rows[0]["PackCount"].ToString()); - IsSupply = dt3.Rows[0]["IsSupply"].ToString(); - } - - if (IsSame == 1) - { - for (int k = 0; k < 2; k++) - { - - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, ref NewOneCode, ref newcode); - - #region 插入数据tb_barCode - - md.ID = Guid.NewGuid().ToString(); - md.StationID = dt.Rows[0]["StationID"].ToString(); - md.OneBarCode = NewOneCode; - md.BarCode = newcode; - md.StockNo = stockNo[j].ToString().Trim(); - md.PartNo = partNo[j].ToString().Trim(); - md.PrintType = 0; - md.PlanID = planID; - md.ProductNature = ProductNature; - md.Des1 = PartName; - DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString()); - if (pdt != null && pdt.Rows.Count > 0) - { - if (pdt.Rows[0]["isImport"].ToString() == "1") - { - md.Import = "国产料Kingfa"; - } - else - { - md.Import = ""; - } - } - - ////if (brbll.Add_Info_New(md, Program.tableName)==false) - //if (SaveBarCode(md, Program.tableName, true, mould) == false) - //{ - // return; - //} - - string errMsg = string.Empty; - bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); - if (saveRst == false) - { - //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); - //return; - } - - #endregion - - #region 打印条码,判断是否打印单个条码 - - DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), - dt.Rows[0]["StationID"].ToString()); - if (dt4 != null && dt4.Rows.Count > 0) - { - printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); - } - - #region 打印单个标签 - - if (IsOne == "1") - { - if (IsSupply == "1") - { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply); - - string reportName = ConfigurationManager.AppSettings[printName].ToString(); - DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode); - - ReportHelper rp = new ReportHelper(filename, headTable, null, - (int) GRPaperOrientation.grpoDefault, 1, reportName); - - rp.Report.Print(false); - } - } - - #endregion - - - - #endregion - } - } - else - { - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, ref NewOneCode, ref newcode); - - #region 插入数据tb_barCode - - md.ID = Guid.NewGuid().ToString(); - md.StationID = dt.Rows[0]["StationID"].ToString(); - md.OneBarCode = NewOneCode; - md.BarCode = newcode; - md.StockNo = stockNo[j].ToString().Trim(); - md.PartNo = partNo[j].ToString().Trim(); - md.PrintType = 0; - md.PlanID = planID; - md.ProductNature = ProductNature; - md.Des1 = PartName; - DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString()); - if (pdt != null && pdt.Rows.Count > 0) - { - if (pdt.Rows[0]["isImport"].ToString() == "1") - { - md.Import = "国产料Kingfa"; - } - else - { - md.Import = ""; - } - } - - ////if (brbll.Add_Info_New(md, Program.tableName)==false) - //if (SaveBarCode(md, Program.tableName, true, mould) == false) - //{ - // return; - //} - - string errMsg = string.Empty; - bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); - if (saveRst == false) - { - //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); - //return; - } - #endregion - - #region 打印条码,判断是否打印单个条码 - - DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), - dt.Rows[0]["StationID"].ToString()); - if (dt4 != null && dt4.Rows.Count > 0) - { - printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); - } - - #region 打印单个标签 - - if (IsOne == "1") - { - if (IsSupply == "1") - { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply); //new - - string reportName = ConfigurationManager.AppSettings[printName].ToString(); - DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode); - - LogHelper.WriteLog(printName + ";" + reportName + ";" + filename); - ReportHelper rp = new ReportHelper(filename, headTable, null, - (int) GRPaperOrientation.grpoDefault, 1, reportName); - - rp.Report.Print(false); - } - } + //private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) + //{ + // try + // { + // base.Invoke(new EventHandler(this.Scan)); + // } + // catch (Exception ex) + // { + // LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + // } - #endregion + //} - - #endregion - } - initBarCode(); - } + //private void Scan(object sender, EventArgs e) + //{ + // string _code_meca = "",printBoxName=""; + // try + // { + // Thread.Sleep(1500); + // char[] buffer = new char[serialPort1.BytesToRead]; + // serialPort1.Read(buffer, 0, serialPort1.BytesToRead); + // for (int i = 0; i < buffer.Length; i++) + // { + // _code_meca = _code_meca + buffer[i]; + // } + + // GetClass(); + + // string aa = _code_meca; + + // var result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\n\s*", ","); + // result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\f\s*", ","); + // result1 = System.Text.RegularExpressions.Regex.Replace(aa, @"\s*\r\s*", ","); + // result1 = result1.Remove(result1.LastIndexOf(","), 1); + // result1 = result1.Remove(result1.LastIndexOf("g"), 1); + // int idxStart = result1.LastIndexOf(" "); + // string value = result1.Substring(idxStart, result1.Length - idxStart).Trim(); + // string[] b = value.Split('.'); + // string c = b[0]; + // string d = b[1]; + // int chengzhong = Convert.ToInt32(c); + // int chengzhong1 = Convert.ToInt32(d); + // if (chengzhong1 >= 5) + // { + // chengzhong = chengzhong + 1; //重量 + // } + + // InjectionPlanBLL bll = new InjectionPlanBLL(); + // BarCodeBLL brbll = new BarCodeBLL(); + // BarCodeModel md = new BarCodeModel(); + // ProductBLL productBll = new ProductBLL(); + // PlasticBLL pbll = _plasticBLL; + // InjectionBoxBLL boxbll = new InjectionBoxBLL(); + // InjectionBoxModel boxmd = new InjectionBoxModel(); + // DataTable dt2 = null; + // string code = "", OneCode = ""; + // string newcode = "", newcode1 = "", NewOneCode = "", NewOneCode1 = ""; + // string IsPack = "", IsOne = "", QLevel = "", IsPaint = "", PartName = "",IsSupply=""; + // string filename = "", printName = ""; + // int MaxCount = 0, CurrentCount = 0; + + // #region 查找当前计划 + + // DataTable dt = bll.SearchInfoByName(Program.station); + // if (dt != null && dt.Rows.Count > 0) + // { + // planID = dt.Rows[0]["InjectionPlanID"].ToString(); + // string[] partNo = dt.Rows[0]["PartNo"].ToString().Split(','); + // string[] stockNo = new string [partNo.Length]; + // //string[] stockNo = dt.Rows[0]["StockNo"].ToString().Split(','); + // string ProductNature = dt.Rows[0]["ProductNature"].ToString(); + // int IsSame = 0; + + // #region 判断有几个零件号 + // string mould = "0"; + // for (int j = 0; j < partNo.Length; j++) + // { + // #region 根据零件号查找存货代码 + + // DataTable sdt = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); + // if (sdt != null && sdt.Rows.Count > 0) + // { + // stockNo[j] = sdt.Rows[0]["StockNo"].ToString(); + // IsSame=Convert.ToInt32(sdt.Rows[0]["IsSame"].ToString()); + // } + // else + // { + // stockNo[j] = ""; + // IsSame = 0; + // } + + // #endregion + + // DataTable dt3 = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); + // if (dt3 != null && dt3.Rows.Count > 0) + // { + // QLevel = dt3.Rows[0]["QLevel"].ToString(); + // IsOne = dt3.Rows[0]["IsPrintOneTag"].ToString(); + // IsPack = dt3.Rows[0]["IsPrintPackList"].ToString(); + // IsPaint = dt3.Rows[0]["IsPlating"].ToString(); + // PartName = dt3.Rows[0]["ProductName"].ToString(); + // MaxCount = Convert.ToInt32(dt3.Rows[0]["PackCount"].ToString()); + // IsSupply = dt3.Rows[0]["IsSupply"].ToString(); + // } + + // if (IsSame == 1) + // { + // for (int k = 0; k < 2; k++) + // { + + // GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, ref NewOneCode, ref newcode); + + // #region 插入数据tb_barCode + + // md.ID = Guid.NewGuid().ToString(); + // md.StationID = dt.Rows[0]["StationID"].ToString(); + // md.OneBarCode = NewOneCode; + // md.BarCode = newcode; + // md.StockNo = stockNo[j].ToString().Trim(); + // md.PartNo = partNo[j].ToString().Trim(); + // md.PrintType = 0; + // md.PlanID = planID; + // md.ProductNature = ProductNature; + // md.Des1 = PartName; + // DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString()); + // if (pdt != null && pdt.Rows.Count > 0) + // { + // if (pdt.Rows[0]["isImport"].ToString() == "1") + // { + // md.Import = "国产料Kingfa"; + // } + // else + // { + // md.Import = ""; + // } + // } + + // ////if (brbll.Add_Info_New(md, Program.tableName)==false) + // //if (SaveBarCode(md, Program.tableName, true, mould) == false) + // //{ + // // return; + // //} + + // string errMsg = string.Empty; + // bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); + // if (saveRst == false) + // { + // //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); + // //return; + // } + + // #endregion + + // #region 打印条码,判断是否打印单个条码 + + // DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), + // dt.Rows[0]["StationID"].ToString()); + // if (dt4 != null && dt4.Rows.Count > 0) + // { + // printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); + // } + + // #region 打印单个标签 + + // if (IsOne == "1") + // { + // if (IsSupply == "1") + // { + // filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply); + + // string reportName = ConfigurationManager.AppSettings[printName].ToString(); + // DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode); + + // ReportHelper rp = new ReportHelper(filename, headTable, null, + // (int) GRPaperOrientation.grpoDefault, 1, reportName); + + // rp.Report.Print(false); + // } + // } + + // #endregion + + + + // #endregion + // } + // } + // else + // { + // GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, ref NewOneCode, ref newcode); + + // #region 插入数据tb_barCode + + // md.ID = Guid.NewGuid().ToString(); + // md.StationID = dt.Rows[0]["StationID"].ToString(); + // md.OneBarCode = NewOneCode; + // md.BarCode = newcode; + // md.StockNo = stockNo[j].ToString().Trim(); + // md.PartNo = partNo[j].ToString().Trim(); + // md.PrintType = 0; + // md.PlanID = planID; + // md.ProductNature = ProductNature; + // md.Des1 = PartName; + // DataTable pdt = productBll.SearchIsImportByPartNo(partNo[j].ToString()); + // if (pdt != null && pdt.Rows.Count > 0) + // { + // if (pdt.Rows[0]["isImport"].ToString() == "1") + // { + // md.Import = "国产料Kingfa"; + // } + // else + // { + // md.Import = ""; + // } + // } + + // ////if (brbll.Add_Info_New(md, Program.tableName)==false) + // //if (SaveBarCode(md, Program.tableName, true, mould) == false) + // //{ + // // return; + // //} + + // string errMsg = string.Empty; + // bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); + // if (saveRst == false) + // { + // //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); + // //return; + // } + // #endregion + + // #region 打印条码,判断是否打印单个条码 + + // DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), + // dt.Rows[0]["StationID"].ToString()); + // if (dt4 != null && dt4.Rows.Count > 0) + // { + // printName = "Printer" + dt4.Rows[0]["PrinterNo"].ToString(); + // } + + // #region 打印单个标签 + + // if (IsOne == "1") + // { + // if (IsSupply == "1") + // { + // filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply); //new + + // string reportName = ConfigurationManager.AppSettings[printName].ToString(); + // DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode); + + // LogHelper.WriteLog(printName + ";" + reportName + ";" + filename); + // ReportHelper rp = new ReportHelper(filename, headTable, null, + // (int) GRPaperOrientation.grpoDefault, 1, reportName); + + // rp.Report.Print(false); + // } + // } + + // #endregion + + + // #endregion + // } + // initBarCode(); + // } + + // #endregion + // } + + // #endregion + // } + // catch (Exception ex) + // { + // LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + // } + //} - #endregion - } - #endregion - } - catch (Exception ex) - { - LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); - } - } private void timer2_Tick(object sender, EventArgs e) { - initPlan(); + Program.ProductDate = _barCodeBLL.GetServiceTime().ToString(); + //initPlan(); } private void comboBox2_TextChanged(object sender, EventArgs e) @@ -3132,8 +3140,11 @@ namespace InjectionPC label2.BackColor = Color.Red; } GetClass(); - textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + - Program.ProductDate.Substring(8, 2); //批次 + + + //textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + + // Program.ProductDate.Substring(8, 2); //批次 + textBox1.Text = GetBatch(true); @@ -3157,130 +3168,127 @@ namespace InjectionPC - private DateTime GetPrintTime(string station) - { - try - { - DateTime time = DateTime.Now; - StationBLL bll = new StationBLL(); - - DataTable dt = bll.SearchInfoByNo(station); - if (dt != null && dt.Rows.Count > 0) - { - if (string.IsNullOrEmpty(dt.Rows[0]["PrintTime"].ToString())) - { - time = DateTime.Now; - } - else - { - time = Convert.ToDateTime(dt.Rows[0]["PrintTime"].ToString()); - } - } - - return time; - } - catch (Exception ex) - { - LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); - return DateTime.Now; - } - } - + //private DateTime GetPrintTime(string station) + //{ + // try + // { + // DateTime time = DateTime.Now; + // StationBLL bll = new StationBLL(); + + // DataTable dt = bll.SearchInfoByNo(station); + // if (dt != null && dt.Rows.Count > 0) + // { + // if (string.IsNullOrEmpty(dt.Rows[0]["PrintTime"].ToString())) + // { + // time = DateTime.Now; + // } + // else + // { + // time = Convert.ToDateTime(dt.Rows[0]["PrintTime"].ToString()); + // } + // } + + // return time; + // } + // catch (Exception ex) + // { + // LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + // return DateTime.Now; + // } + //} - private bool UpdatePrintTime(DateTime time, string station) - { - try - { - StationBLL bll = new StationBLL(); - return bll.UpdateTime(time, station); - } - catch (Exception ex) - { - LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); - return false; - } - } - private int GetSeconds(string station) - { - try - { - int seconds = 0; - StationBLL bll = new StationBLL(); - - DataTable dt = bll.SearchInfoByNo(station); - if (dt != null && dt.Rows.Count > 0) - { - if (string.IsNullOrEmpty(dt.Rows[0]["Seconds"].ToString())) - { - seconds = 0; - } - else - { - seconds = Convert.ToInt32(dt.Rows[0]["Seconds"].ToString()); - } - } - - return seconds; - } - catch (Exception ex) - { - LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); - return 0; - } - } + //private bool UpdatePrintTime(DateTime time, string station) + //{ + // try + // { + // StationBLL bll = new StationBLL(); + // return bll.UpdateTime(time, station); + // } + // catch (Exception ex) + // { + // LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + // return false; + // } + //} - /// - /// 计算时间差 - /// - /// 时间1 - /// 时间2 - /// 返回值:时间差(毫秒为单位) - private long TimeDiff(DateTime t, DateTime t2) - { - long lReturn = -1; - System.TimeSpan NowValue = new TimeSpan(t.Ticks); - System.TimeSpan TimeValue = new TimeSpan(t2.Ticks); - System.TimeSpan DateDiff = TimeSpan.Zero; - try - { - //计算时间差 - //DateDiff = TimeValue.Subtract(NowValue).Duration(); - DateDiff = TimeValue.Subtract(NowValue); - int hours = DateDiff.Hours; - int minutes = DateDiff.Minutes; - int seconds = DateDiff.Seconds; - int milliseconds = DateDiff.Milliseconds; - - string TimeDiff = hours.ToString() + ":" - + minutes.ToString() + ":" - + seconds.ToString() + "." - + milliseconds.ToString(); - //是否比现在的时间小,如果小就设置成第二天再启动,否则当天启动 - if (hours <= 0 && minutes <= 0 && seconds <= 0 && milliseconds <= 0) - hours += 24; - - lReturn = hours * 3600 - + minutes * 60 - + seconds; - } - catch (Exception ex) - { - LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); - } - return lReturn; - } + //private int GetSeconds(string station) + //{ + // try + // { + // int seconds = 0; + // StationBLL bll = new StationBLL(); + + // DataTable dt = bll.SearchInfoByNo(station); + // if (dt != null && dt.Rows.Count > 0) + // { + // if (string.IsNullOrEmpty(dt.Rows[0]["Seconds"].ToString())) + // { + // seconds = 0; + // } + // else + // { + // seconds = Convert.ToInt32(dt.Rows[0]["Seconds"].ToString()); + // } + // } + + // return seconds; + // } + // catch (Exception ex) + // { + // LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + // return 0; + // } + //} - //bool SaveBarCode(BarCodeModel bcm, string tableName, bool isAutoPrint, string mould, bool handPrint = false) + ///// + ///// 计算时间差 + ///// + ///// 时间1 + ///// 时间2 + ///// 返回值:时间差(毫秒为单位) + //private long TimeDiff(DateTime t, DateTime t2) //{ - // return true; + // long lReturn = -1; + // System.TimeSpan NowValue = new TimeSpan(t.Ticks); + // System.TimeSpan TimeValue = new TimeSpan(t2.Ticks); + // System.TimeSpan DateDiff = TimeSpan.Zero; + // try + // { + // //计算时间差 + // //DateDiff = TimeValue.Subtract(NowValue).Duration(); + // DateDiff = TimeValue.Subtract(NowValue); + // int hours = DateDiff.Hours; + // int minutes = DateDiff.Minutes; + // int seconds = DateDiff.Seconds; + // int milliseconds = DateDiff.Milliseconds; + + // string TimeDiff = hours.ToString() + ":" + // + minutes.ToString() + ":" + // + seconds.ToString() + "." + // + milliseconds.ToString(); + // //是否比现在的时间小,如果小就设置成第二天再启动,否则当天启动 + // if (hours <= 0 && minutes <= 0 && seconds <= 0 && milliseconds <= 0) + // hours += 24; + + // lReturn = hours * 3600 + // + minutes * 60 + // + seconds; + // } + // catch (Exception ex) + // { + // LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + // } + // return lReturn; //} + + bool SaveBarCode(BarCodeModel bcm,string tableName, bool isAutoPrint,string mould, ref string errorMsg ,bool handPrint = false ) { - string rst = _wmsBll.SaveRecordAndInterface(bcm, Program.tableName,"",Program.station); + string rst = _wmsBll.SaveRecordAndInterface(bcm, Program.tableName,"",Program.station,"4"); if (string.IsNullOrEmpty(rst)) { return true; @@ -3368,13 +3376,31 @@ namespace InjectionPC string batch = string.Empty; if (isAutoPrint) { - batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + DateTime dt = DateTime.Now; + if (DateTime.TryParse(Program.ProductDate, out dt) == false) + { + dt = DateTime.Now; + } + batch = dt.ToString("yyMMdd"); + // batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); } else { batch = textBox1.Text.Trim(); } return batch; + + //string batch = string.Empty; + //if (isAutoPrint) + //{ + + // batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + //} + //else + //{ + // batch = textBox1.Text.Trim(); + //} + //return batch; } //private object _selectItemL = null; //bool _isShowHintL = true; @@ -3394,7 +3420,8 @@ namespace InjectionPC string batch = string.Empty; if (autoPrint) { - batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + //batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + batch = GetBatch(true); } else { @@ -3429,8 +3456,9 @@ namespace InjectionPC IsTest = true; bool bbb = true; //label23_Click(null, null); - textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + - Program.ProductDate.Substring(8, 2); + //textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + + // Program.ProductDate.Substring(8, 2); + textBox1.Text = GetBatch(true); if (bbb == true) { //自动 opcGroup1_DataChange(1, 1, ref a, ref b, ref c, ref d); @@ -3520,10 +3548,10 @@ namespace InjectionPC opcItems1 = opcGroup1.OPCItems; opcItems1.DefaultIsActive = true; - PLCMouldBLL PLCbll = new PLCMouldBLL(); - PLCBreakBLL bbll = new PLCBreakBLL(); + //PLCMouldBLL PLCbll = new PLCMouldBLL(); + //PLCBreakBLL bbll = new PLCBreakBLL(); - DataTable PLCdt = PLCbll.SearchMould(Program.station); + DataTable PLCdt = _PLCbll.SearchMould(Program.station); if (PLCdt != null && PLCdt.Rows.Count > 0) { opcItemm1 = new OPCItem[PLCdt.Rows.Count]; @@ -3575,35 +3603,36 @@ namespace InjectionPC string PrintMoudleName(string isSupply = "0") { - if("IM05,IM08,IM10".Contains(Program.station)) //二维小条码 - { - return "单个条码2.grf"; - } - else if ("IM06,IM07,IM09,IM11,IM12,".Contains(Program.station)) //一维条码 - { - return "单个条码.grf"; - } + return BussinessHelper.PrintMoudleName(Program.station, isSupply); + //if ("IM05,IM08,IM10".Contains(Program.station)) //二维小条码 + //{ + // return "单个条码2.grf"; + //} + //else if ("IM06,IM07,IM09,IM11,IM12,".Contains(Program.station)) //一维条码 + //{ + // return "单个条码.grf"; + //} - else if ("IM01,IM02,IM03,IM04,IM15,IM18,IM20".Contains(Program.station)) //小米大条码 - { - return "Sill.grf"; - } - else if ("IM13,IM14".Contains(Program.station)) //直供条码 - { - //return "单个条码1.grf"; - if (isSupply == "0") //13,14机台,直供件打二维码 非直供件打一维码 - { - return "单个条码.grf"; - } - else - { - return "单个条码2.grf"; - } - } - else - { - return "单个条码2.grf"; - } + //else if ("IM01,IM02,IM03,IM04,IM15,IM18,IM20".Contains(Program.station)) //小米大条码 + //{ + // return "Sill.grf"; + //} + //else if ("IM13,IM14".Contains(Program.station)) //直供条码 + //{ + // //return "单个条码1.grf"; + // if (isSupply == "0") //13,14机台,直供件打二维码 非直供件打一维码 + // { + // return "单个条码.grf"; + // } + // else + // { + // return "单个条码2.grf"; + // } + //} + //else + //{ + // return "单个条码2.grf"; + //} } diff --git a/InjectionPC/FrmQuality.cs b/InjectionPC/FrmQuality.cs index b488772..de3f4d3 100644 --- a/InjectionPC/FrmQuality.cs +++ b/InjectionPC/FrmQuality.cs @@ -39,6 +39,7 @@ namespace InjectionPC private DataTable _boxDetailTable = null; private List _boxDelList = new List(); internal event Action> QualityViewClosed = null; + private StationBLL _stationBLL = new StationBLL(); public FrmQuality(bool isSingle = false) { InitializeComponent(); @@ -405,7 +406,7 @@ namespace InjectionPC private void SingleBadSave() { string isbox = ""; - + string stationNo = ""; #region 判断是否已做过报废 DataTable baddt = badBLL.SearchByCode(txtScanBarCode.Text.Trim()); //bad 表 @@ -446,11 +447,14 @@ namespace InjectionPC { badmd.OneBarCode = dt1.Rows[0]["OneBarCode"].ToString(); isbox = dt1.Rows[0]["BoxNo"].ToString(); + string stationID = dt1.Rows[0]["StationID"].ToString(); + stationNo = _stationBLL.SearchStationNameByID(stationID); + //扣减装箱表boxRecord中箱码对应的数量 //if (SubtrBoxCount(isbox) == false) // return; - - if (SaveBad(badmd,isbox) == false) + + if (SaveBad(badmd,isbox, stationNo) == false) { return; } @@ -474,7 +478,9 @@ namespace InjectionPC badmd.OneBarCode = dt.Rows[0]["OneBarCode"].ToString(); isbox = dt.Rows[0]["BoxNo"].ToString(); - if (SaveBad(badmd, isbox) == false) + string stationID = dt.Rows[0]["StationID"].ToString(); + stationNo = _stationBLL.SearchStationNameByID(stationID); + if (SaveBad(badmd, isbox, stationNo) == false) { return; } @@ -495,9 +501,10 @@ namespace InjectionPC if (dt1 != null && dt1.Rows.Count > 0) { badmd.BarCode = dt1.Rows[0]["BarCode"].ToString(); - isbox = dt1.Rows[0]["BoxNo"].ToString(); - - if (SaveBad(badmd, isbox) == false) + isbox = dt1.Rows[0]["BoxNo"].ToString(); + string stationID = dt1.Rows[0]["StationID"].ToString(); + stationNo = _stationBLL.SearchStationNameByID(stationID); + if (SaveBad(badmd, isbox, stationNo) == false) { return; } @@ -526,7 +533,7 @@ namespace InjectionPC GetBadCount(); } - bool SaveBad(BadInjectionModel badmd ,string boxCode) + bool SaveBad(BadInjectionModel badmd ,string boxCode,string stationNo) { if (!string.IsNullOrEmpty(boxCode)) { @@ -558,7 +565,7 @@ namespace InjectionPC return false; } - string msg = badBLL.SaveBad(badmd,boxCode, Program.tableName, Program.station); + string msg = badBLL.SaveBad(badmd,boxCode, Program.tableName, stationNo); if (!string.IsNullOrEmpty(msg)) { MessageBox.Show("报废操作失败,失败原因:" + msg); @@ -597,12 +604,12 @@ namespace InjectionPC } - bool SaveBadByBatch(DataTable boxDetailTable, string boxCode) + bool SaveBadByBatch(DataTable boxDetailTable, string boxCode,string stationNo) { if (!string.IsNullOrEmpty(boxCode)) { badmd.Desc = textBox4.Text?.Trim(); - string msg = badBLL.SaveBadByBatch(boxDetailTable, stationId, position, reason, boxCode, Program.tableName, textBox4.Text?.Trim(), Program.station); + string msg = badBLL.SaveBadByBatch(boxDetailTable, stationId, position, reason, boxCode, Program.tableName, textBox4.Text?.Trim(), stationNo); if (!string.IsNullOrEmpty(msg)) { @@ -626,6 +633,9 @@ namespace InjectionPC if (MessageBox.Show($"确认对箱码[{txtBoxCode.Text}]所含[{boxDetailTable.Rows.Count}]条数据做报废处理?", "", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; string boxCode = boxDetailTable.Rows[0]["BoxNo"].ToString(); + string stationID = boxDetailTable.Rows[0]["StationID"].ToString(); + string stationNo = _stationBLL.SearchStationNameByID(stationID); + if (string.IsNullOrEmpty(boxCode)) return; @@ -652,7 +662,7 @@ namespace InjectionPC } else { - SaveBadByBatch(boxDetailTable, boxCode); + SaveBadByBatch(boxDetailTable, boxCode, stationNo); } #endregion diff --git a/InjectionSearch/FrmBarCodeSearch2408.Designer.cs b/InjectionSearch/FrmBarCodeSearch2408.Designer.cs index b45b452..86c53d6 100644 --- a/InjectionSearch/FrmBarCodeSearch2408.Designer.cs +++ b/InjectionSearch/FrmBarCodeSearch2408.Designer.cs @@ -28,10 +28,11 @@ /// private void InitializeComponent() { - GlacialComponents.Controls.GLColumn glColumn1 = new GlacialComponents.Controls.GLColumn(); - GlacialComponents.Controls.GLColumn glColumn2 = new GlacialComponents.Controls.GLColumn(); - GlacialComponents.Controls.GLColumn glColumn3 = new GlacialComponents.Controls.GLColumn(); - GlacialComponents.Controls.GLColumn glColumn4 = new GlacialComponents.Controls.GLColumn(); + this.components = new System.ComponentModel.Container(); + GlacialComponents.Controls.GLColumn glColumn5 = new GlacialComponents.Controls.GLColumn(); + GlacialComponents.Controls.GLColumn glColumn6 = new GlacialComponents.Controls.GLColumn(); + GlacialComponents.Controls.GLColumn glColumn7 = new GlacialComponents.Controls.GLColumn(); + GlacialComponents.Controls.GLColumn glColumn8 = new GlacialComponents.Controls.GLColumn(); this.label1 = new System.Windows.Forms.Label(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.label2 = new System.Windows.Forms.Label(); @@ -70,6 +71,7 @@ this.btnRePrint = new System.Windows.Forms.Button(); this.txtRePrintBoxCode = new System.Windows.Forms.TextBox(); this.label24 = new System.Windows.Forms.Label(); + this.timer1 = new System.Windows.Forms.Timer(this.components); this.panel1.SuspendLayout(); this.panel3.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); @@ -169,8 +171,6 @@ // cboxHandBox // this.cboxHandBox.AutoSize = true; - this.cboxHandBox.Checked = true; - this.cboxHandBox.CheckState = System.Windows.Forms.CheckState.Checked; this.cboxHandBox.Font = new System.Drawing.Font("宋体", 21.75F, System.Drawing.FontStyle.Bold); this.cboxHandBox.Location = new System.Drawing.Point(1394, 32); this.cboxHandBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); @@ -375,43 +375,43 @@ this.glacialList1.AutoHeight = true; this.glacialList1.BackColor = System.Drawing.SystemColors.ControlLightLight; this.glacialList1.BackgroundStretchToFit = true; - glColumn1.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; - glColumn1.CheckBoxes = false; - glColumn1.ImageIndex = -1; - glColumn1.Name = "Column1"; - glColumn1.NumericSort = false; - glColumn1.Text = "条码"; - glColumn1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; - glColumn1.Width = 300; - glColumn2.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; - glColumn2.CheckBoxes = false; - glColumn2.ImageIndex = -1; - glColumn2.Name = "Column2"; - glColumn2.NumericSort = false; - glColumn2.Text = "产品名称"; - glColumn2.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; - glColumn2.Width = 450; - glColumn3.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; - glColumn3.CheckBoxes = false; - glColumn3.ImageIndex = -1; - glColumn3.Name = "Column3"; - glColumn3.NumericSort = false; - glColumn3.Text = "打印方式"; - glColumn3.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; - glColumn3.Width = 80; - glColumn4.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; - glColumn4.CheckBoxes = false; - glColumn4.ImageIndex = -1; - glColumn4.Name = "Column4"; - glColumn4.NumericSort = false; - glColumn4.Text = "打印时间"; - glColumn4.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; - glColumn4.Width = 220; + glColumn5.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; + glColumn5.CheckBoxes = false; + glColumn5.ImageIndex = -1; + glColumn5.Name = "Column1"; + glColumn5.NumericSort = false; + glColumn5.Text = "条码"; + glColumn5.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + glColumn5.Width = 300; + glColumn6.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; + glColumn6.CheckBoxes = false; + glColumn6.ImageIndex = -1; + glColumn6.Name = "Column2"; + glColumn6.NumericSort = false; + glColumn6.Text = "产品名称"; + glColumn6.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + glColumn6.Width = 450; + glColumn7.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; + glColumn7.CheckBoxes = false; + glColumn7.ImageIndex = -1; + glColumn7.Name = "Column3"; + glColumn7.NumericSort = false; + glColumn7.Text = "打印方式"; + glColumn7.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + glColumn7.Width = 80; + glColumn8.ActivatedEmbeddedType = GlacialComponents.Controls.GLActivatedEmbeddedTypes.None; + glColumn8.CheckBoxes = false; + glColumn8.ImageIndex = -1; + glColumn8.Name = "Column4"; + glColumn8.NumericSort = false; + glColumn8.Text = "打印时间"; + glColumn8.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + glColumn8.Width = 220; this.glacialList1.Columns.AddRange(new GlacialComponents.Controls.GLColumn[] { - glColumn1, - glColumn2, - glColumn3, - glColumn4}); + glColumn5, + glColumn6, + glColumn7, + glColumn8}); this.glacialList1.ControlStyle = GlacialComponents.Controls.GLControlStyles.Normal; this.glacialList1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.glacialList1.FullRowSelect = true; @@ -564,7 +564,7 @@ this.pnBoxReprint.Controls.Add(this.txtRePrintBoxCode); this.pnBoxReprint.Controls.Add(this.label24); this.pnBoxReprint.Location = new System.Drawing.Point(560, 426); - this.pnBoxReprint.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.pnBoxReprint.Margin = new System.Windows.Forms.Padding(5); this.pnBoxReprint.Name = "pnBoxReprint"; this.pnBoxReprint.Size = new System.Drawing.Size(1397, 151); this.pnBoxReprint.TabIndex = 25; @@ -574,7 +574,7 @@ // this.btnPrintCancel.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnPrintCancel.Location = new System.Drawing.Point(1197, 43); - this.btnPrintCancel.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.btnPrintCancel.Margin = new System.Windows.Forms.Padding(5); this.btnPrintCancel.Name = "btnPrintCancel"; this.btnPrintCancel.Size = new System.Drawing.Size(160, 59); this.btnPrintCancel.TabIndex = 3; @@ -586,7 +586,7 @@ // this.btnRePrint.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnRePrint.Location = new System.Drawing.Point(1027, 40); - this.btnRePrint.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.btnRePrint.Margin = new System.Windows.Forms.Padding(5); this.btnRePrint.Name = "btnRePrint"; this.btnRePrint.Size = new System.Drawing.Size(160, 59); this.btnRePrint.TabIndex = 2; @@ -598,7 +598,7 @@ // this.txtRePrintBoxCode.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.txtRePrintBoxCode.Location = new System.Drawing.Point(208, 43); - this.txtRePrintBoxCode.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.txtRePrintBoxCode.Margin = new System.Windows.Forms.Padding(5); this.txtRePrintBoxCode.Name = "txtRePrintBoxCode"; this.txtRePrintBoxCode.Size = new System.Drawing.Size(737, 55); this.txtRePrintBoxCode.TabIndex = 1; @@ -615,6 +615,12 @@ this.label24.Text = "箱单号:"; this.label24.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Interval = 5000; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // // FrmBarCodeSearch2408 // this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F); @@ -687,5 +693,6 @@ private System.Windows.Forms.Label label24; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Button btnChangeSizeR; + private System.Windows.Forms.Timer timer1; } } \ No newline at end of file diff --git a/InjectionSearch/FrmBarCodeSearch2408.cs b/InjectionSearch/FrmBarCodeSearch2408.cs index 42b0202..08fe593 100644 --- a/InjectionSearch/FrmBarCodeSearch2408.cs +++ b/InjectionSearch/FrmBarCodeSearch2408.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using grproLib; +using MESClassLibrary; using MESClassLibrary.BLL; using MESClassLibrary.BLL.BasicInfo; using MESClassLibrary.BLL.Injection; @@ -31,6 +32,7 @@ namespace InjectionSearch private BarCodeBLL _bll = new BarCodeBLL(); private WmsBLL _wmsBll = new WmsBLL(); private string _lastBoxNo = string.Empty; + private BarCodeBLL _barCodeBLL = new BarCodeBLL(); public FrmBarCodeSearch2408() { InitializeComponent(); @@ -138,9 +140,9 @@ namespace InjectionSearch comboBox2.Items.Add("IM19"); comboBox2.Items.Add("IM20"); GetClass(); - textBox3.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + - Program.ProductDate.Substring(8, 2); //批次 - + //textBox3.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + + // Program.ProductDate.Substring(8, 2); //批次 + textBox3.Text = GetBatch(true); //comBoxSizeL.DataSource = _basicBLL1.GetPackageSize(); //comBoxSizeL.DisplayMember = "describe"; //comBoxSizeL.ValueMember = "Count"; @@ -177,101 +179,7 @@ namespace InjectionSearch } } - //private void label18_Click(object sender, EventArgs e) - //{ - // string code = "",name=""; - // BarCodeModel md = new BarCodeModel(); - // BarCodeBLL bll = new BarCodeBLL(); - // ProductBLL pbll=new ProductBLL(); - // string filename = "", partNo = "", OneCode=""; - - // try - // { - // if (glacialList1.SelectedItems.Count == 0) - // { - // MessageBox.Show("请选择要补打的条码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); - // return; - // } - // else - // { - // GlacialComponents.Controls.GLItem gv; - // gv = glacialList1.SelectedItems[0] as GlacialComponents.Controls.GLItem; - // code = gv.Text; - - // string[] aa = code.Split('.'); - // partNo = aa[0]; - - // DataTable dt = bll.SearchInfoByBarCode(code); - // if (dt != null && dt.Rows.Count > 0) - // { - // name = dt.Rows[0]["ProductName"].ToString(); - // md.ID = Guid.NewGuid().ToString(); - // md.BarCode = code; - // md.StationID = Program.StationID; - // md.StockNo = dt.Rows[0]["StockNo"].ToString(); - // md.OneBarCode = dt.Rows[0]["OneBarCode"].ToString(); - // md.StationID2 = dt.Rows[0]["StationID"].ToString(); - // md.PrintType = 2; - - // DataTable pdt = pbll.SearchIsImportByStockNo(md.StockNo); - // if (pdt != null && pdt.Rows.Count > 0) - // { - // if (pdt.Rows[0]["isImport"].ToString() == "1") - // { - // md.Import = "国产料Kingfa"; - // } - // else - // { - // md.Import = ""; - // } - // } - // } - - // //if (bll.Add_Info_New(md, "tb_BarCode5") == false) - // //{ - // // return; - // //} - // if (SaveBarCode(md, "tb_BarCode5", false) == false) - // { - // return; - // } - // #region 打印条码 - // PlasticBLL plbll = new PlasticBLL(); - - // //filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码.grf"; - // filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("PrintTime"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("OneBarCode"); - // headTable.Columns.Add("BarCode"); - // DataRow row = headTable.NewRow(); - // row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss"); - // row["PartNo"] = partNo; - // row["PartName"] = name; - // row["OneBarCode"] = md.OneBarCode; - // row["BarCode"] = code; - - - // string reportName = ConfigurationManager.AppSettings["Printer1"].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - - // rp.Report.Print(false); - - // #endregion - - // initBarCode(); - // } - // } - // catch (Exception ex) - // { - // LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); - // } - - //} + public DateTime GetDateTime() { @@ -453,7 +361,7 @@ namespace InjectionSearch } else { - packageCode = lbPackageCodeL.Text.Trim(); + lbPackageCodeL.Text= packageCode; } if (string.IsNullOrEmpty(packageCode)) { @@ -506,12 +414,13 @@ namespace InjectionSearch //} if(SaveBarCode(md, "tb_BarCode5", i== Convert.ToInt32(textBox4.Text.Trim())) == false) { - return; + LogErrBLL.AddInfo("手动批量打印条码" + md.OneBarCode + "报错", MethodBase.GetCurrentMethod()); + //return; } #region 214TrunkBox存入质检表 - if (partNo == "A2146106203kz") + if (partNo == "A2146106203kz") { tb_Inspection_tx imd = new tb_Inspection_tx(); InspectionBLL ibll = new InspectionBLL(); @@ -530,7 +439,7 @@ namespace InjectionSearch #region 打印条码 //filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码.grf"; - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); + filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName("0"); DataTable headTable = new DataTable(); headTable.Columns.Add("PrintTime"); headTable.Columns.Add("PartNo"); @@ -556,183 +465,6 @@ namespace InjectionSearch } } - #region 原有打印代码 - //DataTable dt = bll.SearchSerialNoByBarCodeNew(partNo + "." + textBox3.Text.Trim(),""); - //if (dt != null && dt.Rows.Count > 0) - //{ - // OneCode = dt.Rows[0]["OneBarCode"].ToString().Trim(); - // code = dt.Rows[0]["BarCode"].ToString().TrimEnd(); - // for (int i = 1; i <= Convert.ToInt32(textBox4.Text.Trim()); i++) - // { - // //newcode = code.Substring(0, code.Length - 4) + - // // (Convert.ToInt32(code.Substring(code.Length - 4, 4)) + i) - // // .ToString() - // // .PadLeft(4, '0'); - // //NewOneCode = OneCode.Substring(0, OneCode.Length - 4) + - // // (Convert.ToInt32(OneCode.Substring(OneCode.Length - 4, 4)) + i).ToString() - // // .PadLeft(4, '0'); - - // GetSjBarCode(stockNo, partNo, ref NewOneCode, ref newcode); - // string[] part = newcode.Split('.'); - // //存入tb_BarCode表 - // md.ID = Guid.NewGuid().ToString(); - // md.StationID = Program.StationID; - // md.StationID2 = stationID; - // md.StockNo = stockNo; - // md.OneBarCode = NewOneCode; - // md.BarCode = newcode; - // md.PrintType = 1; - // md.PartNo = partNo; - // md.PlanID = planID; - // md.ProductNature = ProductNature; - - // DataTable pdt = pbll.SearchIsImportByStockNo(stockNo); - // if (pdt != null && pdt.Rows.Count > 0) - // { - // PartName = pdt.Rows[0]["ProductName"].ToString(); - // if (pdt.Rows[0]["isImport"].ToString() == "1") - // { - // md.Import = "国产料Kingfa"; - // } - // else - // { - // md.Import = ""; - // } - // } - - // if (bll.Add_Info_New(md, "tb_BarCode5") == false) - // { - // return; - // } - - // #region 214TrunkBox存入质检表 - - // if (partNo == "A2146106203kz") - // { - // tb_Inspection_tx imd = new tb_Inspection_tx(); - // InspectionBLL ibll = new InspectionBLL(); - - // imd.BarCode = NewOneCode; - // imd.IsOK =1; - // imd.Station = 1; - - // ibll.AddInfo(imd); - // } - - // #endregion - - // if (IsPrint == "1") - // { - // #region 打印条码 - - // filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码.grf"; - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("PrintTime"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("OneBarCode"); - // headTable.Columns.Add("BarCode"); - // DataRow row = headTable.NewRow(); - // row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss"); - // row["PartNo"] = partNo; - // row["PartName"] = PartName; - // row["OneBarCode"] = NewOneCode; - // row["BarCode"] = newcode; - // string reportName = ConfigurationManager.AppSettings["Printer1"].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - - // rp.Report.Print(false); - - // #endregion - // } - // } - //} - //else - //{ - // for (int i = 1; i <= Convert.ToInt32(textBox4.Text.Trim()); i++) - // { - // newcode = partNo + "." + textBox3.Text.Trim() + "." + i.ToString().PadLeft(4, '0'); - // NewOneCode = stockNo + textBox3.Text.Trim() + i.ToString().PadLeft(4, '0'); - // string[] part = newcode.Split('.'); - // //存入tb_BarCode表 - // md.ID = Guid.NewGuid().ToString(); - // md.StationID = Program.StationID; - // md.StationID2 = stationID; - // md.StockNo = stockNo; - // md.OneBarCode = NewOneCode; - // md.BarCode = newcode; - // md.PrintType = 1; - // md.PartNo = partNo; - // md.PlanID = planID; - // md.ProductNature = ProductNature; - - // DataTable pdt = pbll.SearchIsImportByStockNo(stockNo); - // if (pdt != null && pdt.Rows.Count > 0) - // { - // PartName = pdt.Rows[0]["ProductName"].ToString(); - // if (pdt.Rows[0]["isImport"].ToString() == "1") - // { - // md.Import = "国产料Kingfa"; - // } - // else - // { - // md.Import = ""; - // } - // } - - // if (bll.Add_Info_New(md, "tb_BarCode5") == false) - // { - // return; - // } - - // #region 214TrunkBox存入质检表 - - // if (partNo == "A2146106203kz") - // { - // tb_Inspection_tx imd = new tb_Inspection_tx(); - // InspectionBLL ibll = new InspectionBLL(); - - // imd.BarCode = NewOneCode; - // imd.IsOK = 1; - // imd.Station = 1; - - // ibll.AddInfo(imd); - // } - - // #endregion - - // if (IsPrint == "1") - // { - // #region 打印条码 - - // filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码.grf"; - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("PrintTime"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("OneBarCode"); - // headTable.Columns.Add("BarCode"); - // DataRow row = headTable.NewRow(); - // row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss"); - // row["PartNo"] = partNo; - // row["PartName"] = PartName; - // row["OneBarCode"] = NewOneCode; - // row["BarCode"] = newcode; - - // string reportName = ConfigurationManager.AppSettings["Printer1"].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - - // rp.Report.Print(false); - - // #endregion - // } - // } - //} - #endregion } #endregion @@ -760,6 +492,15 @@ namespace InjectionSearch MessageBox.Show("箱单生成失败,请重新操作!"); return; } + else + { + lbPackageCodeL.Text = packageCode; + } + if (string.IsNullOrEmpty(packageCode)) + { + MessageBox.Show("箱单生成失败,请重新操作!"); + return; + } } else { @@ -813,7 +554,8 @@ namespace InjectionSearch //} if (SaveBarCode(md, "tb_BarCode5", i == Convert.ToInt32(textBox4.Text.Trim())) == false) { - return; + LogErrBLL.AddInfo("手动批量打印条码" + md.OneBarCode + "报错", MethodBase.GetCurrentMethod()); + //return; } #endregion @@ -823,7 +565,7 @@ namespace InjectionSearch #region 打印条码 //filename = System.AppDomain.CurrentDomain.BaseDirectory + "单个条码1.grf"; - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); + filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName("1"); DataTable headTable = new DataTable(); headTable.Columns.Add("PrintTime"); @@ -850,156 +592,6 @@ namespace InjectionSearch } } - #region 原来打印代码 - //DataTable dt = bll.SearchSerialNoByBarCodeNew1(partNo + "#" + QLevel + "#" + textBox3.Text.Trim() + "#"); - //if (dt != null && dt.Rows.Count > 0) - //{ - // code = dt.Rows[0]["BarCode"].ToString().Trim(); - // for (int i = 1; i <= Convert.ToInt32(textBox2.Text.Trim()); i++) - // { - // newcode = code.Substring(0, code.Length - 4) + - // (Convert.ToInt32(code.Substring(23, 3)) + - // i).ToString() - // .PadLeft(3, '0') + "#"; - - // #region 插入数据tb_barCode - - // md.ID = Guid.NewGuid().ToString(); - // md.StationID = Program.StationID; - // md.StationID2 = stationID; - // md.StockNo = stockNo; - // md.OneBarCode = ""; - // md.BarCode = newcode; - // md.PrintType = 1; - // md.PartNo = partNo; - - // md.PlanID = planID; - // md.ProductNature = ProductNature; - - // DataTable dt2 = pbll.SearchIsImportByPartNo(partNo); - // if (dt2 != null && dt2.Rows.Count > 0) - // { - // if (dt2.Rows[0]["isImport"].ToString() == "1") - // { - // md.Import = "国产料Kingfa"; - // } - // else - // { - // md.Import = ""; - // } - // } - - // if (bll.Add_Info_New(md, "tb_BarCode5") == false) - // { - // return; - // } - - // #endregion - - // if (IsPrint == "1") - // { - // #region 打印条码 - - // filename = System.AppDomain.CurrentDomain.BaseDirectory + - // "单个条码1.grf"; - - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("PrintTime"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("OneBarCode"); - // headTable.Columns.Add("BarCode"); - // DataRow row = headTable.NewRow(); - // row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss"); - // row["PartNo"] = partNo; - // row["PartName"] = PartName; - // row["OneBarCode"] = NewOneCode; - // row["BarCode"] = newcode; - // string reportName = ConfigurationManager.AppSettings["Printer1"].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - - // rp.Report.Print(false); - - // #endregion - // } - // } - //} - //else - //{ - // for (int i = 1; i <= Convert.ToInt32(textBox4.Text.Trim()); i++) - // { - // newcode = partNo + "#" + QLevel + "#" + textBox3.Text.Trim() + "#" + - // i.ToString().PadLeft(3, '0') + "#"; - // NewOneCode = ""; - // string[] part = newcode.Split('.'); - - // #region 存入tb_BarCode表 - - // md.ID = Guid.NewGuid().ToString(); - // md.StationID = Program.StationID; - // md.StationID2 = stationID; - // md.StockNo = stockNo; - // md.OneBarCode = NewOneCode; - // md.BarCode = newcode; - // md.PrintType = 1; - // md.PartNo = partNo; - // md.PlanID = planID; - // md.ProductNature = ProductNature; - - // DataTable pdt = pbll.SearchIsImportByStockNo(stockNo); - // if (pdt != null && pdt.Rows.Count > 0) - // { - // if (pdt.Rows[0]["isImport"].ToString() == "1") - // { - // md.Import = "国产料Kingfa"; - // } - // else - // { - // md.Import = ""; - // } - // } - - // if (bll.Add_Info_New(md, "tb_BarCode5") == false) - // { - // return; - // } - - // #endregion - - - // if (IsPrint == "1") - // { - // #region 打印条码 - - // filename = System.AppDomain.CurrentDomain.BaseDirectory + - // "单个条码1.grf"; - - // DataTable headTable = new DataTable(); - // headTable.Columns.Add("PrintTime"); - // headTable.Columns.Add("PartNo"); - // headTable.Columns.Add("PartName"); - // headTable.Columns.Add("OneBarCode"); - // headTable.Columns.Add("BarCode"); - // DataRow row = headTable.NewRow(); - // row["PrintTime"] = GetDateTime().ToString("yyyy/MM/dd HH:mm:ss"); - // row["PartNo"] = partNo; - // row["PartName"] = PartName; - // row["OneBarCode"] = NewOneCode; - // row["BarCode"] = newcode; - // string reportName = ConfigurationManager.AppSettings["Printer1"].ToString(); - // headTable.Rows.Add(row); - - // ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoDefault, 1, reportName); - - // rp.Report.Print(false); - - // #endregion - // } - // } - //} - #endregion } #endregion @@ -1036,6 +628,7 @@ namespace InjectionSearch boxmd.Mould = "2"; boxmd.StandardQty = packageSize.ToString(); + //生成后先存上 if(_injectionBoxBLL.AddInfo(boxmd)) { this.lbPackageCodeL.Text = packageCode; @@ -1043,60 +636,178 @@ namespace InjectionSearch } return null; } - bool SaveBarCode(BarCodeModel bcm, string tableName , bool printBox) + private BarCodeModel _lastFailedModel = null; + + bool SaveBarCode(BarCodeModel bcm, string tableName, bool printBox) { + bool saveRst = false; + if (_lastFailedModel != null) + { + Save(_lastFailedModel, tableName, printBox); + _lastFailedModel = null; + } if (cboxHandBox.Checked) { - saveRst = _bll.Add_Info_New(bcm, "tb_BarCode5"); - if(saveRst == true) + Save(bcm, tableName, printBox); + //if (cboxHandBox.Checked) + //{ + // bool isSuccess = false; + // DataTable boxTable = null; + // int realCount = 0; + // int sizeCount = 0; + // LocalDBService local = new LocalDBService(SqlHelper.GetConnSting()); + // try + // { + // local.BeginTrans(); + // saveRst = _bll.Add_Info_New(local, bcm, "tb_BarCode5", "5"); + + // if (_injectionBoxBLL.UpdateBoxCount(local, bcm.BoxNo, 1)) + // { + // boxTable = _injectionBoxBLL.SearchBox(bcm.BoxNo); + // if (boxTable.Rows.Count > 0) + // { + // string realCountStr = boxTable.Rows[0]["BoxCount"].ToString(); + + // int.TryParse(realCountStr, out realCount); + // int.TryParse(comBoxSizeL.SelectedValue?.ToString(), out sizeCount); + // if ((realCount != 0 && realCount == sizeCount) || printBox == true) + // { + // _wmsBll.SaveInterface(local, bcm, "", comboBox2.Text.Trim()); + + // isSuccess = true; + // } + // } + // } + + // local.Commit(); + // } + // catch (Exception ex) + // { + // if (local != null) + // { + // local.Rollback(); + // } + // LogErrBLL.AddInfo("手动批量打印条码" + bcm.OneBarCode + "报错", MethodBase.GetCurrentMethod()); + // _lastFailedModel = bcm; + // } + // finally + // { + // if (local != null) + // { + // local.EndTrans(); + // } + // } + + // //保存后打印箱单 + // if (isSuccess) + // { + // //打印箱码 + // PrintBoxCode(boxTable.Rows[0], realCount, false); + // _lastBoxNo = lbPackageCodeL.Text; + // lbPackageCodeL.Text = ""; + // } + //} + } + else + { + try { - if (_injectionBoxBLL.UpdateBoxCount(bcm.BoxNo,1)) + saveRst = _bll.Add_Info_New(bcm, "tb_BarCode5", "5"); + if (saveRst == false) { - DataTable dt = _injectionBoxBLL.SearchBox(bcm.BoxNo); - if (dt.Rows.Count > 0) + _lastFailedModel = bcm; + } + + + } + catch(Exception ex) + { + _lastFailedModel = bcm; + } + + } + return saveRst; + } + void Save(BarCodeModel bcm, string tableName, bool printBox) + { + bool saveRst = false; + if (cboxHandBox.Checked) + { + bool isSuccess = false; + DataTable boxTable = null; + int realCount = 0; + int sizeCount = 0; + LocalDBService local = new LocalDBService(SqlHelper.GetConnSting()); + try + { + local.BeginTrans(); + saveRst = _bll.Add_Info_New(local, bcm, "tb_BarCode5", "5"); + + if (_injectionBoxBLL.UpdateBoxCount(local, bcm.BoxNo, 1)) + { + boxTable = _injectionBoxBLL.SearchBox(local,bcm.BoxNo); + if (boxTable.Rows.Count > 0) { - string realCountStr = dt.Rows[0]["BoxCount"].ToString(); + string realCountStr = boxTable.Rows[0]["BoxCount"].ToString(); - int realCount = 0; - int sizeCount = 0; int.TryParse(realCountStr, out realCount); int.TryParse(comBoxSizeL.SelectedValue?.ToString(), out sizeCount); - if ((realCount != 0 && realCount == sizeCount) || printBox ==true) + if ((realCount != 0 && realCount == sizeCount) || printBox == true) { - //检查上一个箱码是否给wms传成功了, 没成功重传一次. - //if (!string.IsNullOrEmpty(_lastBoxNo)) - //{ - // if(_wmsBll.IsSendPackageCode(_lastBoxNo) == false) - // { - // DataTable dt2 = _injectionBoxBLL.SearchBox(_lastBoxNo); - // if(dt2.Rows.Count >0) - // { - // _wmsBll.SaveInterface(dt2.Rows[0], MESClassLibrary.Enum.WmsInterfaceEnum.塑件箱码报工); - // } - // } - // _lastBoxNo = ""; - - //} - ////wms接口传递 - //_wmsBll.SaveInterface(dt.Rows[0], MESClassLibrary.Enum.WmsInterfaceEnum.塑件箱码报工); - - _wmsBll.SaveInterface(dt.Rows[0]["BoxNo"].ToString(), _lastBoxNo, "", MESClassLibrary.Enum.WmsInterfaceEnum.塑件箱码报工, comboBox2.Text.Trim()); - - //打印箱码 - PrintBoxCode(dt.Rows[0], realCount,false); - _lastBoxNo = lbPackageCodeL.Text; - lbPackageCodeL.Text = ""; + _wmsBll.SaveInterface(local, bcm, "", comboBox2.Text.Trim()); + + isSuccess = true; } } } + + local.Commit(); + } + catch (Exception ex) + { + if (local != null) + { + local.Rollback(); + } + LogErrBLL.AddInfo("手动批量打印条码" + bcm.OneBarCode + "报错", MethodBase.GetCurrentMethod()); + _lastFailedModel = bcm; + } + finally + { + if (local != null) + { + local.EndTrans(); + } + } + + //保存后打印箱单 + if (isSuccess) + { + //打印箱码 + PrintBoxCode(boxTable.Rows[0], realCount, false); + _lastBoxNo = lbPackageCodeL.Text; + lbPackageCodeL.Text = ""; } } else { - saveRst = _bll.Add_Info_New(bcm, "tb_BarCode5"); + try + { + bool rst = _bll.Add_Info_New(bcm, "tb_BarCode5", "5"); + if (rst == false) + { + _lastFailedModel = bcm; + } + + + } + catch (Exception ex) + { + _lastFailedModel = bcm; + } + } - return saveRst; } private void PrintBoxCode(DataRow boxRow, int realCount,bool isRePrint) { @@ -1146,9 +857,9 @@ namespace InjectionSearch // pnBoxReprint.Visible = true; //} } - private void UpdateBoxRecordPrintState(string UpdatePrinted) + private void UpdateBoxRecordPrintState(string boxCode) { - _injectionBoxBLL.UpdatePrinted(UpdatePrinted); + _injectionBoxBLL.UpdatePrinted(boxCode); } private void button1_Click(object sender, EventArgs e) @@ -1210,7 +921,8 @@ namespace InjectionSearch string batch = string.Empty; if (autoPrint) { - batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + // batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + batch = GetBatch(true); } else { @@ -1227,7 +939,8 @@ namespace InjectionSearch string batch = string.Empty; if (autoPrint) { - batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + // batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); + batch = GetBatch(true); } else { @@ -1384,32 +1097,55 @@ namespace InjectionSearch comBoxSizeL.Enabled = false; } - string PrintMoudleName() + string PrintMoudleName(string isSupply) { string stationName = comboBox2.Text.Trim(); + return BussinessHelper.PrintMoudleName(stationName, isSupply); + //if ("IM05,IM08,IM10".Contains(stationName)) //二维小条码 + //{ + // return "单个条码2.grf"; + //} + //else if ("IM06,IM07,IM09,IM11,IM12,".Contains(stationName)) //一维条码 + //{ + // return "单个条码.grf"; + //} - if ("IM05,IM08,IM10".Contains(stationName)) //二维小条码 - { - return "单个条码2.grf"; - } - else if ("IM06,IM07,IM09,IM11,IM12,".Contains(stationName)) //一维条码 - { - return "单个条码.grf"; - } + //else if ("IM01,IM02,IM03,IM04,IM15,IM18,IM20".Contains(stationName)) //小米大条码 + //{ + // return "Sill.grf"; + //} + //else if ("IM13,IM14".Contains(stationName)) //直供条码 + //{ + // return "单个条码1.grf"; + //} + //else + //{ + // return "单个条码2.grf"; + //} - else if ("IM01,IM02,IM03,IM04,IM15,IM18,IM20".Contains(stationName)) //小米大条码 - { - return "Sill.grf"; - } - else if ("IM13,IM14".Contains(stationName)) //直供条码 + } + string GetBatch(bool isAutoPrint) + { + string batch = string.Empty; + if (isAutoPrint) { - return "单个条码1.grf"; + DateTime dt = DateTime.Now; + if (DateTime.TryParse(Program.ProductDate, out dt) == false) + { + dt = DateTime.Now; + } + batch = dt.ToString("yyMMdd"); + // batch = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); } else { - return "单个条码2.grf"; + batch = textBox1.Text.Trim(); } - + return batch; + } + private void timer1_Tick(object sender, EventArgs e) + { + Program.ProductDate = _barCodeBLL.GetServiceTime().ToString(); } } } diff --git a/InjectionSearch/FrmBarCodeSearch2408.resx b/InjectionSearch/FrmBarCodeSearch2408.resx index 1af7de1..1f666f2 100644 --- a/InjectionSearch/FrmBarCodeSearch2408.resx +++ b/InjectionSearch/FrmBarCodeSearch2408.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/MESClassLibrary/BLL/BasicInfo/BarCodeBLL.cs b/MESClassLibrary/BLL/BasicInfo/BarCodeBLL.cs index 05823e1..bb88b38 100644 --- a/MESClassLibrary/BLL/BasicInfo/BarCodeBLL.cs +++ b/MESClassLibrary/BLL/BasicInfo/BarCodeBLL.cs @@ -88,11 +88,11 @@ namespace MESClassLibrary.BLL.BasicInfo } } - public bool Add_Info_New(BarCodeModel md,string tableName) + public bool Add_Info_New(BarCodeModel md,string tableName,string isNew="1") { try { - return db.AddInfoNew(md,tableName); + return db.AddInfoNew(md,tableName, isNew); } catch (Exception ex) { @@ -100,20 +100,23 @@ namespace MESClassLibrary.BLL.BasicInfo return false; } } - - - public bool Add_Info_New(LocalDBService local, BarCodeModel md, string tableName) + public bool Add_Info_New(LocalDBService local,BarCodeModel md, string tableName, string isNew = "1") { - try - { - return db.AddInfoNew(md, tableName); - } - catch (Exception ex) - { - LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); - return false; - } + return db.AddInfoNew(local, md, tableName, isNew); } + + //public bool Add_Info_New(LocalDBService local, BarCodeModel md, string tableName) + //{ + // try + // { + // return db.AddInfoNew(md, tableName); + // } + // catch (Exception ex) + // { + // LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + // return false; + // } + //} /// /// 补打 /// @@ -121,8 +124,9 @@ namespace MESClassLibrary.BLL.BasicInfo /// /// /// + /// 是否新的 0:老程序 1:新程序正常打印 2:手动箱箱码插入数据 /// - public string ReprintSave(BarCodeModel md, string tableName,string oldOneBarCode,string oldBarCode,string station) + public string ReprintSave(BarCodeModel md, string tableName,string oldOneBarCode,string oldBarCode,string station,string isNew) { LocalDBService local = new LocalDBService(SqlHelper.GetConnSting()); try @@ -136,7 +140,7 @@ namespace MESClassLibrary.BLL.BasicInfo //tb_barCode 插入 printType=2 补打 - db.AddInfoNew(local, md, tableName); + db.AddInfoNew(local, md, tableName, isNew); if (!string.IsNullOrEmpty(oldOneBarCode)) { if (!string.IsNullOrEmpty(md.BoxNo)) @@ -644,5 +648,10 @@ namespace MESClassLibrary.BLL.BasicInfo return false; } } + + public DateTime GetServiceTime() + { + return db.GetDateTime(); + } } } diff --git a/MESClassLibrary/BLL/Injection/PLCBreakBLL.cs b/MESClassLibrary/BLL/Injection/PLCBreakBLL.cs index 658541c..6787c55 100644 --- a/MESClassLibrary/BLL/Injection/PLCBreakBLL.cs +++ b/MESClassLibrary/BLL/Injection/PLCBreakBLL.cs @@ -26,5 +26,27 @@ namespace MESClassLibrary.BLL.Injection return null; } } + /// + /// 记录接收到PLC 信号的记录 + /// + /// + /// + /// + /// + /// + /// + /// + public bool SavePlcReceive(string stationNo, int TransactionID, int NumItems, string partCode1, string planCode, string pageType) + { + try + { + return da.SavePlcReceive(stationNo, TransactionID, NumItems, partCode1, planCode, pageType); + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return false ; + } + } } } diff --git a/MESClassLibrary/BLL/Inspection/InjectionBoxBLL.cs b/MESClassLibrary/BLL/Inspection/InjectionBoxBLL.cs index b7a5ea7..e224e93 100644 --- a/MESClassLibrary/BLL/Inspection/InjectionBoxBLL.cs +++ b/MESClassLibrary/BLL/Inspection/InjectionBoxBLL.cs @@ -80,6 +80,18 @@ namespace MESClassLibrary.BLL.Inspection return null; } } + public DataTable SearchBox(LocalDBService local, string BoxNo) + { + try + { + return db.SearchBox(local,BoxNo); + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return null; + } + } public DataTable SearchUnBox(string stationID, string mould) { try diff --git a/MESClassLibrary/BLL/Wms/WmsBLL.cs b/MESClassLibrary/BLL/Wms/WmsBLL.cs index 2637a69..7a725a5 100644 --- a/MESClassLibrary/BLL/Wms/WmsBLL.cs +++ b/MESClassLibrary/BLL/Wms/WmsBLL.cs @@ -18,14 +18,23 @@ namespace MESClassLibrary.BLL.Injection private WmsDAL da=new WmsDAL(); private BarCodeDAl barCodeDal = new BarCodeDAl(); - public string SaveRecordAndInterface(BarCodeModel bcm,string tableName,string badReason, string station) + /// + /// 单条码模式保存订单和接口数据 + /// + /// + /// + /// + /// + /// + /// + public string SaveRecordAndInterface(BarCodeModel bcm,string tableName,string badReason, string station,string isNew) { LocalDBService local = new LocalDBService(SqlHelper.GetConnSting()); try { local.BeginTrans(); - barCodeDal.AddInfoNew(local, bcm, tableName); + barCodeDal.AddInfoNew(local, bcm, tableName, isNew); da.SaveInterface(local, bcm, badReason, station); local.Commit(); } diff --git a/MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs b/MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs index cbfb920..5ca6130 100644 --- a/MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs +++ b/MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs @@ -266,14 +266,14 @@ namespace MESClassLibrary.DAL.BasicInfo } } - public bool AddInfoNew(BarCodeModel md,string tableName) + public bool AddInfoNew(BarCodeModel md,string tableName, string isNew) { try { #region 添加数据 string sql = ""; SqlParameter[] param = null; - sql = "INSERT INTO " + tableName + " (ID,StationID,OneBarCode,[BarCode],[StockNo],[PartNo],[PrintType],[CreateTime],[IsImport],StationID2,PlanID,ProductNature,Des1,Des2,Des3,Des4,Des5,BoxNo,Weight"; + sql = "INSERT INTO " + tableName + " (ID,StationID,OneBarCode,[BarCode],[StockNo],[PartNo],[PrintType],[CreateTime],[IsImport],StationID2,PlanID,ProductNature,Des1,Des2,Des3,Des4,Des5,BoxNo,IsNew,Weight"; sql += ") VALUES ("; sql += "@ID,"; sql += "@StationID,"; @@ -294,10 +294,11 @@ namespace MESClassLibrary.DAL.BasicInfo sql += "@Des4,"; sql += "@Des5,"; sql += "@BoxNo,"; + sql += "@IsNew,"; sql += "@Weight)"; #region 添加参数 - param = new SqlParameter[18]; + param = new SqlParameter[19]; param[0] = new SqlParameter("@ID", SqlDbType.VarChar); param[0].Value = md.ID; @@ -349,8 +350,11 @@ namespace MESClassLibrary.DAL.BasicInfo param[16] = new SqlParameter("@BoxNo", SqlDbType.VarChar); param[16].Value = md.BoxNo; - param[17] = new SqlParameter("@Weight", SqlDbType.Decimal); - param[17].Value = md.Weight; + param[17] = new SqlParameter("@IsNew", SqlDbType.VarChar); + param[17].Value = isNew; + + param[18] = new SqlParameter("@Weight", SqlDbType.Decimal); + param[18].Value = md.Weight; #endregion @@ -364,14 +368,14 @@ namespace MESClassLibrary.DAL.BasicInfo return false; } } - public bool AddInfoNew(LocalDBService local, BarCodeModel md, string tableName) + public bool AddInfoNew(LocalDBService local, BarCodeModel md, string tableName,string isNew) { string sql = ""; - sql = "INSERT INTO " + tableName + " (ID,StationID,OneBarCode,[BarCode],[StockNo],[PartNo],[PrintType],[CreateTime],[IsImport],StationID2,PlanID,ProductNature,Des1,Des2,Des3,Des4,Des5,BoxNo,Weight,BatchNo"; + sql = "INSERT INTO " + tableName + " (ID,StationID,OneBarCode,[BarCode],[StockNo],[PartNo],[PrintType],[CreateTime],[IsImport],StationID2,PlanID,ProductNature,Des1,Des2,Des3,Des4,Des5,BoxNo,Weight,BatchNo,IsNew"; sql += $") VALUES ('{md.ID}','{md.StationID}','{md.OneBarCode}','{md.BarCode}','{md.StockNo}','{md.PartNo}','{md.PrintType}',getdate(),'{md.Import}'," + - $"'{md.StationID2}','{md.PlanID}','{md.ProductNature}','{md.Des1}','{md.Des2}','{md.Des3}','{md.Des4}','{md.Des5}','{md.BoxNo}','{ md.Weight}','{ md.BatchNo}')"; + $"'{md.StationID2}','{md.PlanID}','{md.ProductNature}','{md.Des1}','{md.Des2}','{md.Des3}','{md.Des4}','{md.Des5}','{md.BoxNo}','{ md.Weight}','{ md.BatchNo}','{isNew}')"; return local.Exec_NonQuery(sql); diff --git a/MESClassLibrary/DAL/Injection/InjectionBoxDAL.cs b/MESClassLibrary/DAL/Injection/InjectionBoxDAL.cs index 7240637..ca94732 100644 --- a/MESClassLibrary/DAL/Injection/InjectionBoxDAL.cs +++ b/MESClassLibrary/DAL/Injection/InjectionBoxDAL.cs @@ -222,6 +222,12 @@ namespace MESClassLibrary.DAL.Injection return null; } } + public DataTable SearchBox(LocalDBService local, string BoxNo) + { + string sql = @"select * from " + TableName + $" with(nolock) where BoxNo='{BoxNo}'"; + + return local.Exec_DataSet(sql).Tables[0]; + } public DataTable SearchUnBox(string stationID,string mould) { try diff --git a/MESClassLibrary/DAL/Injection/PLCBreakDAL.cs b/MESClassLibrary/DAL/Injection/PLCBreakDAL.cs index 03fb967..6494f59 100644 --- a/MESClassLibrary/DAL/Injection/PLCBreakDAL.cs +++ b/MESClassLibrary/DAL/Injection/PLCBreakDAL.cs @@ -24,5 +24,21 @@ namespace MESClassLibrary.DAL.Injection return null; } } + + public bool SavePlcReceive(string stationNo,int TransactionID, int NumItems ,string partCode1,string planCode,string pageType ) + { + try + { + string sql2 = $"insert into tb_PlcReceiveRecords(StationNo,TransactionID,NumItems,PartCode1,PlanCode,PageType)" + + $" values ('{stationNo}','{TransactionID}','{NumItems}','{partCode1}','{planCode}','{pageType}' )"; + SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql2, null); + return true; + } + catch (Exception ex) + { + LogErrBLL.AddInfo(stationNo + "记录设备接收信号次数记录错误. " +ex.ToString(), MethodBase.GetCurrentMethod()); + return false; + } + } } } diff --git a/MESClassLibrary/MESClassLibrary.csproj b/MESClassLibrary/MESClassLibrary.csproj index c0fb74c..48b79b2 100644 --- a/MESClassLibrary/MESClassLibrary.csproj +++ b/MESClassLibrary/MESClassLibrary.csproj @@ -162,6 +162,7 @@ + diff --git a/PaintingPC/FrmQuality.cs b/PaintingPC/FrmQuality.cs index 6756345..fe2ad51 100644 --- a/PaintingPC/FrmQuality.cs +++ b/PaintingPC/FrmQuality.cs @@ -26,7 +26,10 @@ namespace PaintingPC private string _carType = string.Empty; private Dictionary _lastJustDict = new Dictionary(); private string _foreighColor = string.Empty; - + /// + /// 从tb_ForeignColorMap表得到的零件号 + /// + private string _foreignPartCode = string.Empty; public FrmQuality(bool isWmsQuality) { InitializeComponent(); @@ -674,6 +677,7 @@ namespace PaintingPC model1.damnPosition = position; model1.reason = reason; model1.remark3 = paintId; + model1.ForeignPartCode = _foreignPartCode; if (!string.IsNullOrEmpty(_carType)) { model1.CarType = _carType; @@ -782,7 +786,7 @@ namespace PaintingPC } } } - + private void LoadPage() { try @@ -1080,6 +1084,10 @@ namespace PaintingPC labProPosition.Tag = paintId; labProductInfo.Tag = Function.GetSide(barcode, paintId); labProPosition.Text = labTitle.Text.Trim() + " " + labProductInfo.Tag.ToString().Replace(';', ' '); + if (info.Length == 4) + { + _foreignPartCode = info[3]; + } } else { @@ -1170,7 +1178,7 @@ namespace PaintingPC lableFP.Text = ""; _foreighColor = ""; cboxAddColor.DataSource = null; - + _foreignPartCode = ""; _carType = string.Empty; } diff --git a/PaintingPC/Function.cs b/PaintingPC/Function.cs index 2a7b0f7..a480deb 100644 --- a/PaintingPC/Function.cs +++ b/PaintingPC/Function.cs @@ -1773,6 +1773,7 @@ namespace PaintingPC ,[remark3] ,[CarType] ,[AddMan] + ,[ForeignPartCode] ) VALUES ('" + model.barcode + @"' @@ -1791,7 +1792,8 @@ namespace PaintingPC ,'" + model.remark2 + @"' ,'" + model.remark3 + @"' ,'" + model.CarType + @"' - ,'" + model.AddMan + @"' + ,'" + model.AddMan + @"' + ,'" + model.ForeignPartCode + @"' );select @@Identity "; //res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null); DataTable dt= SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); @@ -1816,7 +1818,7 @@ namespace PaintingPC //string colorNo = ""; //string colorQQNo = ""; //string colorPRNo = ""; - string colorInfo = "", paintCode = "", paintID = ""; + string colorInfo = "", paintCode = "", paintID = "", typeCode = ""; string barCode1_1 = "", barCode1_2 = "", barCode1_3 = "", barCode1_4 = "", barCode1_5 = "", barCode1_6 = "", barCode2_1 = "", barCode2_2 = "", barCode2_3 = "", barCode2_4 = "", barCode2_5 = "", barCode2_6 = ""; string columnName = "", side = ""; @@ -1834,7 +1836,7 @@ namespace PaintingPC string sql = @" DECLARE @barcode varchar(30); SET @barcode = '" + barcode + @"'; - SELECT paintcode, + SELECT paintcode,TypeCode, LTrim(RTrim(Side1_Data1)) as Side1_Data1, LTrim(RTrim(Side1_Data2)) as Side1_Data2, LTrim(RTrim(Side1_Data3)) as Side1_Data3, @@ -1869,12 +1871,37 @@ namespace PaintingPC if (dtColor != null && dtColor.Rows.Count > 0) { paintCode = dtColor.Rows[0]["paintcode"].ToString(); + typeCode = dtColor.Rows[0]["TypeCode"].ToString(); } else { errorMsg = $"ForeignDB 没有条码[{barcode}]对应的数据"; } + if (!string.IsNullOrEmpty(typeCode) && paintCode.ToLower() != "na") + { + string sqlmap = @"select * from tb_ForeignColorMap where TypeCode='" + typeCode + @"'"; + + DataTable mapTable = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlmap, null); + if(mapTable.Rows.Count > 0) + { + DataRow mapRow = mapTable.Rows[0]; + string paintSql = @"select * from tb_PaintInfo where PaintCode='" + paintCode + @"'"; + DataTable paintTable = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlmap, null); + if(paintTable !=null && paintTable.Rows.Count > 0) + { + paintID = paintTable.Rows[0]["ID"].ToString(); + res = mapRow["Color"] + "," + mapRow["PartName"] + "," + paintID+ "," + mapRow["PartCode"]; + return res; + } + else + { + errorMsg = $"基础数据-油漆信息管理页面未配置油漆代码为{paintCode}的基础数据"; + } + } + + + } //根据颜色代码查颜色 if (!string.IsNullOrWhiteSpace(paintCode) && paintCode.ToLower() != "na") diff --git a/PaintingPC/Model/InspectModel.cs b/PaintingPC/Model/InspectModel.cs index b0daea1..c6f9588 100644 --- a/PaintingPC/Model/InspectModel.cs +++ b/PaintingPC/Model/InspectModel.cs @@ -78,5 +78,9 @@ namespace PaintingPC.Model /// 报废操作人 /// public string AddMan { get; set; } + /// + /// 老外系统取颜色后,从tb_ForeignColorMap表附加的零件号 + /// + public string ForeignPartCode { get; set; } } } diff --git a/WebService/Function.cs b/WebService/Function.cs index 3f2ba0d..7eaf78e 100644 --- a/WebService/Function.cs +++ b/WebService/Function.cs @@ -1139,8 +1139,18 @@ namespace Webservice colorName = inspectTable.Rows[0]["remark1"].ToString(); productName = inspectTable.Rows[0]["remark2"].ToString(); carType = inspectTable.Rows[0]["CarType"].ToString(); - //lu_Code = inspectTable.Rows[0]["remark1"].ToString(); - lu_Code = GetPaintLU(oneBarCode.Substring(0, 10), colorName); + + string foreignPartCode = inspectTable.Rows[0]["ForeignPartCode"].ToString(); + if (!string.IsNullOrEmpty(foreignPartCode)) + { + lu_Code = foreignPartCode; + } + else + { + //lu_Code = inspectTable.Rows[0]["remark1"].ToString(); + lu_Code = GetPaintLU(oneBarCode.Substring(0, 10), colorName); + } + string lastState = string.Empty; if (inspectTable.Rows.Count > 1) {