From e199190045ebd2cffea678ab6c11ee3593dc7e83 Mon Sep 17 00:00:00 2001 From: "ruoxing.wang" <88384874@qq.com> Date: Sat, 4 Jan 2025 13:39:20 +0800 Subject: [PATCH] 1 --- FacOneZPStation/FrmZP.Designer.cs | 90 +-- InjectionPC/FrmLogin.cs | 19 +- InjectionPC/FrmMain2408.Designer.cs | 30 + InjectionPC/FrmMain2408.cs | 692 ++++++++++++------ InjectionPC/FrmMain2411.cs | 596 ++++++++------- InjectionPC/Properties/AssemblyInfo.cs | 4 +- .../BLL/Inspection/InjectionBoxBLL.cs | 21 + MESClassLibrary/BLL/Log/LogErrBLL.cs | 2 +- MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs | 6 +- .../DAL/Injection/InjectionBoxDAL.cs | 20 + MESClassLibrary/DAL/Injection/UniqueDal.cs | 1 + PaintingPC/FrmQuality.cs | 6 +- 12 files changed, 925 insertions(+), 562 deletions(-) diff --git a/FacOneZPStation/FrmZP.Designer.cs b/FacOneZPStation/FrmZP.Designer.cs index 9d92b5a..685f288 100644 --- a/FacOneZPStation/FrmZP.Designer.cs +++ b/FacOneZPStation/FrmZP.Designer.cs @@ -76,7 +76,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, 758F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 765F)); this.tableLayoutPanel3.Controls.Add(this.button6, 3, 0); this.tableLayoutPanel3.Controls.Add(this.button1, 0, 1); this.tableLayoutPanel3.Controls.Add(this.button5, 2, 1); @@ -101,10 +101,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(1801, 14); + this.button6.Location = new System.Drawing.Point(1793, 14); this.button6.Margin = new System.Windows.Forms.Padding(14); this.button6.Name = "button6"; - this.button6.Size = new System.Drawing.Size(731, 183); + this.button6.Size = new System.Drawing.Size(739, 183); this.button6.TabIndex = 7; this.button6.Text = "手动打印箱单"; this.button6.UseVisualStyleBackColor = false; @@ -118,7 +118,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(585, 200); + this.button1.Size = new System.Drawing.Size(582, 200); this.button1.TabIndex = 6; this.button1.Text = "打印标签"; this.button1.UseVisualStyleBackColor = false; @@ -130,10 +130,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(1214, 225); + this.button5.Location = new System.Drawing.Point(1208, 225); this.button5.Margin = new System.Windows.Forms.Padding(14); this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(559, 184); + this.button5.Size = new System.Drawing.Size(557, 184); this.button5.TabIndex = 5; this.button5.Text = "不合格"; this.button5.UseVisualStyleBackColor = false; @@ -144,10 +144,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(606, 6); + this.button4.Location = new System.Drawing.Point(603, 6); this.button4.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6); this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(587, 199); + this.button4.Size = new System.Drawing.Size(584, 199); this.button4.TabIndex = 4; this.button4.Text = "下一计划"; this.button4.UseVisualStyleBackColor = false; @@ -161,7 +161,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(585, 199); + this.button3.Size = new System.Drawing.Size(582, 199); this.button3.TabIndex = 3; this.button3.Text = "上一计划"; this.button3.UseVisualStyleBackColor = false; @@ -173,10 +173,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(613, 225); + this.button2.Location = new System.Drawing.Point(610, 225); this.button2.Margin = new System.Windows.Forms.Padding(14); this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(573, 184); + this.button2.Size = new System.Drawing.Size(570, 184); this.button2.TabIndex = 2; this.button2.Text = "补打标签"; this.button2.UseVisualStyleBackColor = false; @@ -187,10 +187,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(1794, 217); + this.button7.Location = new System.Drawing.Point(1786, 217); this.button7.Margin = new System.Windows.Forms.Padding(7, 6, 7, 6); this.button7.Name = "button7"; - this.button7.Size = new System.Drawing.Size(745, 200); + this.button7.Size = new System.Drawing.Size(753, 200); this.button7.TabIndex = 8; this.button7.Text = "补打箱单"; this.button7.UseVisualStyleBackColor = false; @@ -202,7 +202,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(1453, 3); + this.label7.Location = new System.Drawing.Point(1443, 3); this.label7.Margin = new System.Windows.Forms.Padding(2); this.label7.Name = "label7"; this.tableLayoutPanel4.SetRowSpan(this.label7, 2); @@ -214,10 +214,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(419, 127); + this.textBox2.Location = new System.Drawing.Point(416, 127); this.textBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(1027, 87); + this.textBox2.Size = new System.Drawing.Size(1020, 87); this.textBox2.TabIndex = 30; this.textBox2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox2_KeyDown); // @@ -229,7 +229,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(405, 124); + this.label3.Size = new System.Drawing.Size(402, 124); this.label3.TabIndex = 29; this.label3.Text = "扫描物料条码"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -239,10 +239,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(1730, 249); + this.labOrderNo.Location = new System.Drawing.Point(1720, 249); this.labOrderNo.Margin = new System.Windows.Forms.Padding(2); this.labOrderNo.Name = "labOrderNo"; - this.labOrderNo.Size = new System.Drawing.Size(819, 174); + this.labOrderNo.Size = new System.Drawing.Size(829, 174); this.labOrderNo.TabIndex = 28; this.labOrderNo.Text = "A64654646464"; this.labOrderNo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -253,7 +253,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(1453, 249); + this.label4.Location = new System.Drawing.Point(1443, 249); this.label4.Margin = new System.Windows.Forms.Padding(2); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(272, 174); @@ -267,10 +267,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(417, 249); + this.labStationNo.Location = new System.Drawing.Point(414, 249); this.labStationNo.Margin = new System.Windows.Forms.Padding(2); this.labStationNo.Name = "labStationNo"; - this.labStationNo.Size = new System.Drawing.Size(1031, 174); + this.labStationNo.Size = new System.Drawing.Size(1024, 174); this.labStationNo.TabIndex = 26; this.labStationNo.Text = "V253-MF-S后保下部延伸焊接"; this.labStationNo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -284,7 +284,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(409, 174); + this.label2.Size = new System.Drawing.Size(406, 174); this.label2.TabIndex = 25; this.label2.Text = "工位名称"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -294,10 +294,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(1730, 428); + this.labPName.Location = new System.Drawing.Point(1720, 428); this.labPName.Margin = new System.Windows.Forms.Padding(2); this.labPName.Name = "labPName"; - this.labPName.Size = new System.Drawing.Size(819, 285); + this.labPName.Size = new System.Drawing.Size(829, 285); this.labPName.TabIndex = 24; this.labPName.Text = "MF253 MF S后保"; this.labPName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -308,7 +308,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(1453, 428); + this.label8.Location = new System.Drawing.Point(1443, 428); this.label8.Margin = new System.Windows.Forms.Padding(2); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(272, 285); @@ -322,10 +322,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(417, 428); + this.labPartNo.Location = new System.Drawing.Point(414, 428); this.labPartNo.Margin = new System.Windows.Forms.Padding(2); this.labPartNo.Name = "labPartNo"; - this.labPartNo.Size = new System.Drawing.Size(1031, 285); + this.labPartNo.Size = new System.Drawing.Size(1024, 285); this.labPartNo.TabIndex = 22; this.labPartNo.Text = "A2530822665"; this.labPartNo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -344,7 +344,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(409, 285); + this.label6.Size = new System.Drawing.Size(406, 285); this.label6.TabIndex = 21; this.label6.Text = "产品代码"; this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -355,10 +355,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(1730, 718); + this.labBadCount.Location = new System.Drawing.Point(1720, 718); this.labBadCount.Margin = new System.Windows.Forms.Padding(2); this.labBadCount.Name = "labBadCount"; - this.labBadCount.Size = new System.Drawing.Size(819, 515); + this.labBadCount.Size = new System.Drawing.Size(829, 515); this.labBadCount.TabIndex = 20; this.labBadCount.Text = "0"; this.labBadCount.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -369,10 +369,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(417, 718); + this.labNum.Location = new System.Drawing.Point(414, 718); this.labNum.Margin = new System.Windows.Forms.Padding(2); this.labNum.Name = "labNum"; - this.labNum.Size = new System.Drawing.Size(1031, 515); + this.labNum.Size = new System.Drawing.Size(1024, 515); this.labNum.TabIndex = 18; this.labNum.Text = "152/210"; this.labNum.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -386,7 +386,7 @@ this.label10.Location = new System.Drawing.Point(3, 718); this.label10.Margin = new System.Windows.Forms.Padding(2); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(409, 515); + this.label10.Size = new System.Drawing.Size(406, 515); this.label10.TabIndex = 17; this.label10.Text = "计划/完成数"; this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -399,7 +399,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(405, 120); + this.label14.Size = new System.Drawing.Size(402, 120); this.label14.TabIndex = 12; this.label14.Text = "扫描本体条码"; this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -408,10 +408,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(419, 6); + this.textBox1.Location = new System.Drawing.Point(416, 6); this.textBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(1027, 87); + this.textBox1.Size = new System.Drawing.Size(1020, 87); this.textBox1.TabIndex = 13; this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown); // @@ -420,11 +420,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(1732, 1); + this.labErrMessage.Location = new System.Drawing.Point(1722, 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(815, 245); + this.labErrMessage.Size = new System.Drawing.Size(825, 245); this.labErrMessage.TabIndex = 16; this.labErrMessage.Text = "条码与产品不匹配,重新扫描"; this.labErrMessage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -437,7 +437,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, 822F)); + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 832F)); 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); @@ -477,7 +477,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(1453, 718); + this.label12.Location = new System.Drawing.Point(1443, 718); this.label12.Margin = new System.Windows.Forms.Padding(2); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(272, 515); @@ -490,10 +490,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(1932, 0); + this.labTime.Location = new System.Drawing.Point(1927, 0); this.labTime.Margin = new System.Windows.Forms.Padding(0); this.labTime.Name = "labTime"; - this.labTime.Size = new System.Drawing.Size(628, 149); + this.labTime.Size = new System.Drawing.Size(633, 149); this.labTime.TabIndex = 7; this.labTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.labTime.Click += new System.EventHandler(this.labTime_Click); @@ -520,7 +520,7 @@ this.label1.Location = new System.Drawing.Point(349, 0); this.label1.Margin = new System.Windows.Forms.Padding(0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(1583, 149); + this.label1.Size = new System.Drawing.Size(1578, 149); this.label1.TabIndex = 1; this.label1.Text = "装配工位信息看板"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -531,7 +531,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, 627F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 632F)); 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/FrmLogin.cs b/InjectionPC/FrmLogin.cs index ef7513b..5100926 100644 --- a/InjectionPC/FrmLogin.cs +++ b/InjectionPC/FrmLogin.cs @@ -19,10 +19,12 @@ namespace InjectionPC { public partial class FrmLogin : Form { + private string _defualtPage = string.Empty; public FrmLogin() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; + } private void button1_Click(object sender, EventArgs e) @@ -40,7 +42,7 @@ namespace InjectionPC //Program.WeightUser = ConfigurationManager.AppSettings["WeightUser"].ToString(); //Program.WeightPsw = ConfigurationManager.AppSettings["WeightPsw"].ToString(); Program.tableName = ConfigurationManager.AppSettings["tableName"].ToString(); - + _defualtPage = ConfigurationManager.AppSettings["DefualtPage"]?.ToString(); Program.interVal = Convert.ToInt32(ConfigurationManager.AppSettings["InterVal"].ToString()); if (DateTime.Now.Hour >= 8 && DateTime.Now.Hour < 20) { @@ -92,9 +94,20 @@ namespace InjectionPC { this.Visible = false; //Form fr = new FrmMain(); - Form fr = new FrmMain2408(); + + if(_defualtPage?.ToLower() == "frmmain2411") + { + Form fr = new FrmMain2411(); + fr.Show(); + } + else + { + Form fr = new FrmMain2408(); + fr.Show(); + } + //Form fr = new FrmMain2411(); - fr.Show(); + //if (ConfigurationManager.AppSettings["Mode"] == "0") //{ // Form fr = new FrmMain(); diff --git a/InjectionPC/FrmMain2408.Designer.cs b/InjectionPC/FrmMain2408.Designer.cs index 36071f5..b7da3b6 100644 --- a/InjectionPC/FrmMain2408.Designer.cs +++ b/InjectionPC/FrmMain2408.Designer.cs @@ -82,6 +82,8 @@ this.panel25 = new System.Windows.Forms.Panel(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.panel38 = new System.Windows.Forms.Panel(); + this.btn_lastBoxPrintR = new System.Windows.Forms.Button(); + this.btn_lastBoxPrintL = new System.Windows.Forms.Button(); this.label27 = new System.Windows.Forms.Label(); this.label26 = new System.Windows.Forms.Label(); this.label17 = new System.Windows.Forms.Label(); @@ -835,6 +837,8 @@ // panel38 // this.panel38.BackColor = System.Drawing.Color.DeepSkyBlue; + this.panel38.Controls.Add(this.btn_lastBoxPrintR); + this.panel38.Controls.Add(this.btn_lastBoxPrintL); this.panel38.Controls.Add(this.label27); this.panel38.Controls.Add(this.label26); this.panel38.Controls.Add(this.label17); @@ -845,6 +849,30 @@ this.panel38.Size = new System.Drawing.Size(404, 288); this.panel38.TabIndex = 1; // + // btn_lastBoxPrintR + // + this.btn_lastBoxPrintR.BackColor = System.Drawing.Color.Aquamarine; + this.btn_lastBoxPrintR.Font = new System.Drawing.Font("宋体", 14.14286F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_lastBoxPrintR.Location = new System.Drawing.Point(278, 147); + this.btn_lastBoxPrintR.Name = "btn_lastBoxPrintR"; + this.btn_lastBoxPrintR.Size = new System.Drawing.Size(126, 141); + this.btn_lastBoxPrintR.TabIndex = 4; + this.btn_lastBoxPrintR.Text = "右侧前一箱单"; + this.btn_lastBoxPrintR.UseVisualStyleBackColor = false; + this.btn_lastBoxPrintR.Click += new System.EventHandler(this.btn_lastBoxPrintR_Click); + // + // btn_lastBoxPrintL + // + this.btn_lastBoxPrintL.BackColor = System.Drawing.Color.Aquamarine; + this.btn_lastBoxPrintL.Font = new System.Drawing.Font("宋体", 14.14286F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_lastBoxPrintL.Location = new System.Drawing.Point(278, 0); + this.btn_lastBoxPrintL.Name = "btn_lastBoxPrintL"; + this.btn_lastBoxPrintL.Size = new System.Drawing.Size(126, 141); + this.btn_lastBoxPrintL.TabIndex = 2; + this.btn_lastBoxPrintL.Text = "左侧前一箱单"; + this.btn_lastBoxPrintL.UseVisualStyleBackColor = false; + this.btn_lastBoxPrintL.Click += new System.EventHandler(this.btn_lastBoxPrintL_Click); + // // label27 // this.label27.Font = new System.Drawing.Font("宋体", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -1875,5 +1903,7 @@ private System.Windows.Forms.Panel panel49; private System.Windows.Forms.Button btnChangeSizeR; private System.Windows.Forms.Button btnOnlyBarCode; + private System.Windows.Forms.Button btn_lastBoxPrintL; + private System.Windows.Forms.Button btn_lastBoxPrintR; } } \ No newline at end of file diff --git a/InjectionPC/FrmMain2408.cs b/InjectionPC/FrmMain2408.cs index 5d15bfd..22c69c3 100644 --- a/InjectionPC/FrmMain2408.cs +++ b/InjectionPC/FrmMain2408.cs @@ -125,9 +125,7 @@ namespace InjectionPC _printNameDict.Add(key, dr["PrinterNo"].ToString()); } } - InitPackageInfo(); - Ping p1 = new Ping(); PingReply reply = p1.Send("10.60.101.60"); //发送主机名或Ip地址 @@ -198,9 +196,9 @@ namespace InjectionPC try { if (CreateServer()) - { + { if (ConnectServer(strHostIP, "Kepware.KEPServerEX.V6")) - { + { Connected = true; #region 创建组 @@ -220,7 +218,6 @@ namespace InjectionPC PLCMouldBLL PLCbll = new PLCMouldBLL(); PLCBreakBLL bbll = new PLCBreakBLL(); - DataTable PLCdt = PLCbll.SearchMould(Program.station); if (PLCdt != null && PLCdt.Rows.Count > 0) { @@ -230,7 +227,6 @@ namespace InjectionPC opcItemm1[i] = opcItems1.AddItem(PLCdt.Rows[i]["Address"].ToString(), i); } } - Thread.Sleep(200); opcGroup1.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange); @@ -259,6 +255,7 @@ namespace InjectionPC Connected = false; LogHelper.WriteLog("创建OPC服务失败!"); LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return; } @@ -405,9 +402,8 @@ namespace InjectionPC void opcGroup1_DataChange(int TransactionID, int NumItems, ref Array ClientHandles, ref Array ItemValues,ref Array Qualities, ref Array TimeStamps) { try - { - - CheckPackageSelect(); + { + CheckPackageSelect(); InjectionPlanBLL bll = new InjectionPlanBLL(); BarCodeBLL brbll = new BarCodeBLL(); BarCodeModel md = new BarCodeModel(); @@ -429,10 +425,10 @@ namespace InjectionPC return; } for (int i = 1; i <= NumItems; i++) - { + { if ((ItemValues!=null && ItemValues.GetValue(i).ToString() == "True") || IsTest ==true) { - LogSysBLL.AddInfo("true" + label6.Text, MethodBase.GetCurrentMethod()); + //LogSysBLL.AddInfo("true" + label6.Text, MethodBase.GetCurrentMethod()); GetClass(); #region 增加时间差判定 @@ -451,14 +447,13 @@ namespace InjectionPC //comboBox1.Text = "A班"; //班次 textBox1.Text = Program.ProductDate.Substring(2, 2) + Program.ProductDate.Substring(5, 2) + Program.ProductDate.Substring(8, 2); //批次 - #region 查找当前计划 - + #region 查找当前计划 DataTable dt = bll.SearchInfoByName(Program.station); if (dt != null && dt.Rows.Count > 0) { if (aa != dt.Rows[0]["PartNo"].ToString()) - { + { DialogResult result=MessageBox.Show("计划有变更,请确认!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.OK) @@ -539,7 +534,7 @@ namespace InjectionPC // Program.ProductDate.Substring(8, 2) + "." + "0001"; //} - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, NumItems+"_551" , ref NewOneCode, ref newcode); } else { @@ -572,7 +567,7 @@ namespace InjectionPC // Program.ProductDate.Substring(8, 2) + "0001"; //} - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_584", ref NewOneCode, ref newcode); } } @@ -630,29 +625,38 @@ 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 (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; + // if (a >= 4) + // { + // return; + // } + // //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 打印条码,判断是否打印单个条码 @@ -667,12 +671,12 @@ namespace InjectionPC ? System.AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); //new + PrintMoudleName("0","Print"+Program.station+"_679"); //new } else { filename = System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); + PrintMoudleName("1", "Print" + Program.station + "_684"); } @@ -731,7 +735,7 @@ namespace InjectionPC // Program.ProductDate.Substring(8, 2) + "." + "0001"; //} - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_743", ref NewOneCode, ref newcode); } else @@ -765,7 +769,7 @@ namespace InjectionPC // Program.ProductDate.Substring(8, 2) + "0001"; //} - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_555", ref NewOneCode, ref newcode); } @@ -820,29 +824,36 @@ 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 (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; + //} - if (a >= 4) - { - return; - } - //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 打印条码,判断是否打印单个条码 @@ -870,18 +881,18 @@ namespace InjectionPC ? System.AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); //new + PrintMoudleName("0", "Print" + Program.station + "_882"); //new if (partNo[j].Contains("A2146982300") || partNo[j].Contains("A2146982400")) { filename = AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); + PrintMoudleName("0", "Print" + Program.station + "_887"); } } else { filename = System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); + PrintMoudleName("1", "Print" + Program.station + "_893"); } @@ -935,42 +946,49 @@ namespace InjectionPC { ManufacturerName = dtM.Rows[0]["ManufacturerName"].ToString(); } - #region 判断有几个零件号 string mould = "0"; 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) + try { - stockNo[j] = sdt.Rows[0]["StockNo"].ToString(); - IsSame = sdt.Rows[0]["IsSame"].ToString(); - } - else - { - stockNo[j] = ""; - } + #region 根据零件号查找存货代码 + mould = j.ToString(); + DataTable sdt = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); + if (sdt != null && sdt.Rows.Count > 0) + { + stockNo[j] = sdt.Rows[0]["StockNo"].ToString(); + IsSame = sdt.Rows[0]["IsSame"].ToString(); + } + else + { + stockNo[j] = ""; + } - #endregion + #endregion - #region 查询零件属性 + #region 查询零件属性 - DataTable dt10 = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); - if (dt10 != null && dt10.Rows.Count > 0) - { - QLevel = dt10.Rows[0]["QLevel"].ToString(); - IsOne = dt10.Rows[0]["IsPrintOneTag"].ToString(); - IsPack = dt10.Rows[0]["IsPrintPackList"].ToString(); - IsPaint = dt10.Rows[0]["IsPlating"].ToString(); - PartName = dt10.Rows[0]["ProductName"].ToString(); - //MaxCount = Convert.ToInt32(dt10.Rows[0]["PackCount"].ToString()); - IsSupply = dt10.Rows[0]["IsSupply"].ToString(); - } + DataTable dt10 = productBll.SearchInfoByPartNo(partNo[j].ToString().Trim()); + if (dt10 != null && dt10.Rows.Count > 0) + { + QLevel = dt10.Rows[0]["QLevel"].ToString(); + IsOne = dt10.Rows[0]["IsPrintOneTag"].ToString(); + IsPack = dt10.Rows[0]["IsPrintPackList"].ToString(); + IsPaint = dt10.Rows[0]["IsPlating"].ToString(); + PartName = dt10.Rows[0]["ProductName"].ToString(); + //MaxCount = Convert.ToInt32(dt10.Rows[0]["PackCount"].ToString()); + IsSupply = dt10.Rows[0]["IsSupply"].ToString(); + } - #endregion + #endregion + } + catch (Exception ex) + { + throw new Exception("p988" + ex.Message); + } + if (IsSame == "1") { for (int k = 0; k < 2; k++) @@ -1004,7 +1022,7 @@ namespace InjectionPC #endregion - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_1017", ref NewOneCode, ref newcode); } else @@ -1043,7 +1061,7 @@ namespace InjectionPC #endregion - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_1056", ref NewOneCode, ref newcode); } } @@ -1116,28 +1134,35 @@ 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 (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; + // } + //} - if (a >= 4) - { - 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 打印条码,判断是否打印单个条码 @@ -1152,12 +1177,12 @@ namespace InjectionPC ? System.AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); //new + PrintMoudleName("0", "Print" + Program.station + "_1167"); //new } else { filename = System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); + PrintMoudleName("1", "Print" + Program.station + "_1172"); } //DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), @@ -1194,7 +1219,6 @@ namespace InjectionPC if (IsSupply != "1") { #region 非直供件 - try { if (ManufacturerName.Contains("蔚来")) @@ -1219,8 +1243,7 @@ namespace InjectionPC //} #endregion - - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_1235", ref NewOneCode, ref newcode); } else @@ -1257,8 +1280,15 @@ namespace InjectionPC //} #endregion - - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); + try + { + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, NumItems + "_1273", ref NewOneCode, ref newcode); + + } + catch (Exception ex) + { + throw new Exception("p988" + ex.Message); + } } } @@ -1292,8 +1322,7 @@ namespace InjectionPC // 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) @@ -1307,52 +1336,66 @@ namespace InjectionPC } #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) + try { - 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++) + 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 (brbll.Add_Info_New(md, Program.tableName)) - if (SaveBarCode(md, Program.tableName, true, mould) == true) - { - break; + if (pdt.Rows[0]["isImport"].ToString() == "1") + { + md.Import = "国产料Kingfa"; + } + else + { + md.Import = ""; } - - a += 1; - Thread.Sleep(200); } - if (a >= 4) + ////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) { + MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); return; } } - + catch (Exception ex) + { + throw new Exception("p1396" + ex.Message); + } + #endregion #region 打印条码,判断是否打印单个条码 @@ -1368,7 +1411,7 @@ namespace InjectionPC ? System.AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName();//new + PrintMoudleName("0", "Print" + Program.station + "_1385");//new if (partNo[j].Contains("A2146982300") || partNo[j].Contains("A2146982400")) { @@ -1378,7 +1421,7 @@ namespace InjectionPC } else { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); + filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName("1", "Print" + Program.station + "_1395"); } //DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), @@ -1590,7 +1633,7 @@ namespace InjectionPC - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould.ToString(), PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould.ToString(), PartName,"", ref NewOneCode, ref newcode); #region 插入数据tb_barCode @@ -1618,29 +1661,35 @@ 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; - } + ////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); - } + // a += 1; + // Thread.Sleep(200); + // } - if (a >= 4) - { - return; - } - //return; - } + // if (a >= 4) + // { + // return; + // } + //} + string errMsg = string.Empty; + bool saveRst = SaveInfo(md, true, same[j].ToString(), false, ref errMsg); + if (saveRst == false) + { + MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); + return; + } #endregion #region 增加产量 @@ -1818,7 +1867,7 @@ namespace InjectionPC // 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); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould.ToString(), PartName,"", ref NewOneCode, ref newcode); #region 插入数据tb_barCode @@ -1845,29 +1894,35 @@ 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; - } + //// 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); - } + // a += 1; + // Thread.Sleep(200); + // } - if (a >= 4) - { - return; - } - //return; - } + // if (a >= 4) + // { + // return; + // } + //} + string errMsg = string.Empty; + bool saveRst = SaveInfo(md, true, same[j].ToString(), false, ref errMsg); + if (saveRst == false) + { + MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); + return; + } #endregion #region 增加产量 @@ -2450,7 +2505,7 @@ namespace InjectionPC int printCount = Convert.ToInt32(textBox2.Text.Trim()); for (int i = 1; i <= printCount; i++) { - GetSjBarCode(stockNo, partNo,false,"0", PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo, partNo,false,"0", PartName, "", ref NewOneCode, ref newcode); string[] part = newcode.Split('.'); @@ -2480,9 +2535,17 @@ namespace InjectionPC } } - //if (bll.Add_Info_New(md, Program.tableName) == false) - if (SaveBarCode(md, Program.tableName, false, "0",i== printCount) == false) + ////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) { + MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); return; } @@ -2497,7 +2560,7 @@ namespace InjectionPC ? System.AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); //new + PrintMoudleName("0", "Print" + Program.station + "_2514"); //new if (partNo.Contains("A2146982300") || partNo.Contains("A2146982400")) { @@ -2749,9 +2812,17 @@ namespace InjectionPC } } - //if (bll.Add_Info_New(md, Program.tableName) == false) - if (SaveBarCode(md, Program.tableName, false, "0") == false) - { + ////if (bll.Add_Info_New(md, Program.tableName) == false) + //if (SaveBarCode(md, Program.tableName, false, "0") == false) + //{ + // return; + //} + + string errMsg = string.Empty; + bool saveRst = SaveInfo(md, false, "0", false, ref errMsg); + if (saveRst == false) + { + MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); return; } @@ -2761,7 +2832,7 @@ namespace InjectionPC if (IsOne == "1") { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); + filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName("1", "Print" + Program.station + "_2778"); ; //DataTable dt4 = plbll.SearchInfo(partNo, stationID); //if (dt4 != null && dt4.Rows.Count > 0) @@ -2989,6 +3060,7 @@ namespace InjectionPC private void label22_Click(object sender, EventArgs e) { string code = "", filename = "", printName = "", ManufacturerName=""; + string IsSupply = "0"; BarCodeModel md = new BarCodeModel(); BarCodeBLL bll = new BarCodeBLL(); ProductBLL pbll = new ProductBLL(); @@ -3053,8 +3125,10 @@ namespace InjectionPC } ManufacturerName = pdt.Rows[0]["ManufacturerName"].ToString().Trim(); - + IsSupply = pdt.Rows[0]["IsSupply"].ToString(); } + + } else { @@ -3082,7 +3156,7 @@ namespace InjectionPC ? AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); //new + PrintMoudleName(IsSupply, "Print" + Program.station + "_3102"); //new if (md.PartNo.Contains("A2146982300") || md.PartNo.Contains("A2146982400")) { @@ -3852,7 +3926,7 @@ namespace InjectionPC for (int k = 0; k < 2; k++) { - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, "", ref NewOneCode, ref newcode); #region 插入数据tb_barCode @@ -3879,9 +3953,17 @@ namespace InjectionPC } } - //if (brbll.Add_Info_New(md, Program.tableName)==false) - if (SaveBarCode(md, Program.tableName, true, mould) == false) - { + ////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; } @@ -3902,8 +3984,8 @@ namespace InjectionPC { if (IsSupply == "1") { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); - + 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); @@ -3923,7 +4005,7 @@ namespace InjectionPC } else { - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, ref NewOneCode, ref newcode); + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(),true, mould, PartName, "", ref NewOneCode, ref newcode); #region 插入数据tb_barCode @@ -3950,12 +4032,19 @@ namespace InjectionPC } } - //if (brbll.Add_Info_New(md, Program.tableName)==false) - if (SaveBarCode(md, Program.tableName, true, mould) == false) - { + ////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 打印条码,判断是否打印单个条码 @@ -3973,8 +4062,8 @@ namespace InjectionPC { if (IsSupply == "1") { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); //new - + 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); @@ -4199,7 +4288,7 @@ namespace InjectionPC - bool SaveBarCode(BarCodeModel bcm,string tableName, bool isAutoPrint,string mould,bool handPrint = false) + bool SaveBarCode(BarCodeModel bcm,string tableName, bool isAutoPrint,string mould, ref string errorMsg, bool handPrint = false) { Label lbPackageCode = lbPackageCodeL; Label lbCurrentlQty = lbCurrentlQtyL; @@ -4223,6 +4312,7 @@ namespace InjectionPC { bcm.BoxNo = lbPackageCode.Text.Trim(); saveRst = _barCodeBLL.Add_Info_New(bcm, Program.tableName); + if (saveRst == true) { //更新箱单数量 @@ -4286,6 +4376,7 @@ namespace InjectionPC } else { + errorMsg = rst; MessageBox.Show(rst); } } @@ -4438,12 +4529,17 @@ namespace InjectionPC /// /// /// - void GetSjBarCode(string stockNo,string partNo, bool autoPrint,string mould,string partName, ref string newOneCode,ref string newCode) + void GetSjBarCode(string stockNo,string partNo, bool autoPrint,string mould,string partName,string printTest, ref string newOneCode,ref string newCode) { CheckPackageCode(partNo, autoPrint, mould, partName); string batch = GetBatch(autoPrint); GetBarCode(stockNo, batch, partNo, ref newOneCode, ref newCode); + + if (!string.IsNullOrEmpty(printTest)) + { + SaveLog3("BarCodePrint:"+ Program.station + ":" + printTest + "_" + newOneCode); + } // newOneCode = _uniqueBll.GetSjBarCodeSerialNo(stockNo, batch); //newCode = partNo + "." + batch + "." + newOneCode.Substring(newOneCode.Length - 4, 4); } @@ -4603,7 +4699,18 @@ namespace InjectionPC int.TryParse(txt, out i); if(i == 0) { - throw new Exception("未选择装箱规格,请选择. "); + List list = comBoxSizeL.DataSource as List; + if (list.Count > 0) + { + lbNeedQtyL.Text = list[0]; + } + else + { + lbNeedQtyL.Text = "30"; + MessageBox.Show("当前生产计划[未选择装箱规格],默认设置为30, 如果与实际不符合,请尽快作出选择. "); + + } + //throw new Exception("未选择装箱规格,请选择. "); //MessageBox.Show("未选择装箱规格,请选择. "); } } @@ -4766,7 +4873,7 @@ namespace InjectionPC Program.ProductDate.Substring(8, 2); if (bbb == true) { //自动 - opcGroup1_DataChange(1, 1, ref a, ref b, ref c, ref d); + opcGroup1_DataChange(1, 2, ref a, ref b, ref c, ref d); } else { //手动 @@ -4900,6 +5007,11 @@ namespace InjectionPC try { this.FormClosed += (arg1, arg2) => { + + opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange); + opcServer.OPCGroups.RemoveAll(); + opcServer.Disconnect(); + serialPort1.Close(); FrmMain2411 frm = new FrmMain2411(); frm.Show(); }; @@ -4950,8 +5062,13 @@ namespace InjectionPC } - string PrintMoudleName() + string PrintMoudleName(string isSupply = "0",string invokeInfo ="") { + if (!string.IsNullOrEmpty(invokeInfo)) + { + SaveLog2(invokeInfo); + } + if("IM05,IM08,IM10".Contains(Program.station)) //二维小条码 { return "单个条码2.grf"; @@ -4967,7 +5084,15 @@ namespace InjectionPC } else if ("IM13,IM14".Contains(Program.station)) //直供条码 { - return "单个条码1.grf"; + if(isSupply == "0") //13,14机台,直供件打二维码 非直供件打一维码 + { + return "单个条码.grf"; + } + else + { + return "单个条码2.grf"; + } + } else { @@ -5000,6 +5125,37 @@ namespace InjectionPC headTable.Rows.Add(row); return headTable; } + /// + /// 补打左侧上一箱单 + /// + /// + /// + private void btn_lastBoxPrintL_Click(object sender, EventArgs e) + { + InjectionBoxBLL boxbll = new InjectionBoxBLL(); + DataRow dr = boxbll.SearchNewPrintedBoxInfo(Program.station, "0"); + if(dr == null) + { + MessageBox.Show("没找到上一个箱码"); + return; + } + PrintBoxCode(dr, int.Parse(dr["StandardQty"].ToString()), "0"); + + + } + + private void btn_lastBoxPrintR_Click(object sender, EventArgs e) + { + InjectionBoxBLL boxbll = new InjectionBoxBLL(); + DataRow dr = boxbll.SearchNewPrintedBoxInfo(Program.station, "1"); + if (dr == null) + { + MessageBox.Show("没找到上一个箱码"); + return; + } + PrintBoxCode(dr, int.Parse(dr["StandardQty"].ToString()), "1"); + } + List GetProductBoxSize(string productCode,ref string currentSize) { try @@ -5008,14 +5164,14 @@ namespace InjectionPC DataTable dt = productBll.SearchInfoByPartNo(productCode); if (dt.Rows.Count == 0) { - currentSize = "24"; - MessageBox.Show("零件号{productCode}未设置标包,默认为24,请及时核对后进行配置."); + currentSize = "30"; + MessageBox.Show($"零件号{productCode}未设置标包,默认为30,请及时核对后进行配置."); return null; } currentSize = dt.Rows[0]["PackCount"].ToString(); string sizeStr = dt.Rows[0]["PackCountSize"].ToString(); List list = new List(); - if (string.IsNullOrEmpty(sizeStr)) + if (string.IsNullOrEmpty(sizeStr) || sizeStr =="0") { list.Add(currentSize); return list; @@ -5040,10 +5196,76 @@ namespace InjectionPC catch(Exception ex) { currentSize = "24"; + List list = new List(); + list.Add(currentSize); MessageBox.Show("零件号{productCode}未设置标包,默认为24,请及时核对后进行配置."); - return null; + return list; } } + void SaveLog(string txt) + { + //try + //{ + // LogSysBLL.AddInfo(txt, MethodBase.GetCurrentMethod()); + + //} + //catch (Exception ex) + //{ + // LogHelper.WriteLog("SaveLog:" + ex.Message); + //} + } + void SaveLog2(string txt) + { + try + { + LogSysBLL.AddInfo(txt, MethodBase.GetCurrentMethod()); + + } + catch (Exception ex) + { + LogHelper.WriteLog("SaveLog:" + ex.Message); + } + } + void SaveLog3(string txt) + { + try + { + LogSysBLL.AddInfo(txt, MethodBase.GetCurrentMethod()); + + } + catch (Exception ex) + { + LogHelper.WriteLog("SaveLog:" + ex.Message); + } + } + + bool SaveInfo(BarCodeModel md, bool isAutoPrint, string mould, bool handPrint, ref string errMsg) + { + if (SaveBarCode(md, Program.tableName, isAutoPrint, mould, ref errMsg, handPrint) == false) + { + int a = 0; + for (int l = 0; l < 3; l++) + { + // if (brbll.Add_Info_New(md, Program.tableName)) + if (SaveBarCode(md, Program.tableName, true, mould, ref errMsg, handPrint) == true) + { + break; + } + + a += 1; + //Thread.Sleep(200); + Thread.Sleep(200); + } + + if (a >= 2) + { + SaveLog3(Program.station + "保存3次失败,条码" + md.OneBarCode); + return false; + } + } + return true; + } + } } diff --git a/InjectionPC/FrmMain2411.cs b/InjectionPC/FrmMain2411.cs index 98fc576..2a791af 100644 --- a/InjectionPC/FrmMain2411.cs +++ b/InjectionPC/FrmMain2411.cs @@ -577,26 +577,32 @@ 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 (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; - } + // if (a >= 4) + // { + // return; + // } + //} + string errMsg = string.Empty; + bool saveRst = SaveInfo(md, true, mould,false,ref errMsg); + if(saveRst == false) + { + //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); //return; } @@ -614,12 +620,12 @@ namespace InjectionPC ? System.AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); //new + PrintMoudleName("0"); //new } else { filename = System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); + PrintMoudleName("1"); } @@ -767,26 +773,33 @@ 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 (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; + // } + //} - if (a >= 4) - { - return; - } + string errMsg = string.Empty; + bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); + if (saveRst == false) + { + //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); //return; } @@ -817,18 +830,18 @@ namespace InjectionPC ? System.AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); //new + PrintMoudleName("0"); //new if (partNo[j].Contains("A2146982300") || partNo[j].Contains("A2146982400")) { filename = AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); + PrintMoudleName("0"); } } else { filename = System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); + PrintMoudleName("1"); } @@ -1063,26 +1076,34 @@ 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 (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; + // } + //} - if (a >= 4) - { - return; - } + string errMsg = string.Empty; + bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); + if (saveRst == false) + { + //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); + //return; } #endregion @@ -1099,12 +1120,12 @@ namespace InjectionPC ? System.AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); //new + PrintMoudleName("0"); //new } else { filename = System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); + PrintMoudleName("1"); } //DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), @@ -1166,9 +1187,14 @@ namespace InjectionPC //} #endregion - - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); - + try + { + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); + } + catch (Exception ex) + { + throw new Exception("p1197" + ex.Message); + } } else { @@ -1204,9 +1230,15 @@ namespace InjectionPC //} #endregion - - GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); + try + { + GetSjBarCode(stockNo[j].ToString().Trim(), partNo[j].ToString().Trim(), true, mould, PartName, ref NewOneCode, ref newcode); + } + catch(Exception ex) + { + throw new Exception("p1235"+ex.Message); + } } } catch (Exception ex) @@ -1254,58 +1286,75 @@ namespace InjectionPC } #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) + try { - 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++) + 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 (brbll.Add_Info_New(md, Program.tableName)) - if (SaveBarCode(md, Program.tableName, true, mould) == true) - { - break; + if (pdt.Rows[0]["isImport"].ToString() == "1") + { + md.Import = "国产料Kingfa"; + } + else + { + md.Import = ""; } - - a += 1; - Thread.Sleep(200); } - if (a >= 4) + ////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; + // } + //} + + SaveLog3(Program.station + "测试保存条码" + md.OneBarCode); + string errMsg = string.Empty; + bool saveRst = SaveInfo(md, true, mould, false, ref errMsg); + if (saveRst == false) { - return; + SaveLog3(Program.station + "测试保存错误,异常信息:" + md.OneBarCode + errMsg); + //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); + //return; } } - + catch (Exception ex) + { + throw new Exception("p1348" + ex.Message); + } + #endregion #region 打印条码,判断是否打印单个条码 #region 打印单个标签 + SaveLog3(Program.station + "测试保存 ,IsOne:" + md.OneBarCode +":"+ IsOne); if (IsOne == "1") { @@ -1315,7 +1364,7 @@ namespace InjectionPC ? System.AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName();//new + PrintMoudleName("0");//new if (partNo[j].Contains("A2146982300") || partNo[j].Contains("A2146982400")) { @@ -1325,9 +1374,9 @@ namespace InjectionPC } else { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); + filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName("1"); } - + SaveLog3(Program.station + "测试保存 ,filename:" + md.OneBarCode + ":" + filename); //DataTable dt4 = pbll.SearchInfo(partNo[j].ToString().Trim(), // dt.Rows[0]["StationID"].ToString()); //if (dt4 != null && dt4.Rows.Count > 0) @@ -1565,29 +1614,35 @@ 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; - } + ////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); - } + // a += 1; + // Thread.Sleep(200); + // } - if (a >= 4) - { - return; - } + // if (a >= 4) + // { + // return; + // } + //} + + string errMsg = string.Empty; + bool saveRst = SaveInfo(md, true, same[j].ToString(), false, ref errMsg); + if (saveRst == false) + { + //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); //return; } - #endregion #region 增加产量 @@ -1792,29 +1847,34 @@ 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; - } + //// 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); - } + // a += 1; + // Thread.Sleep(200); + // } - if (a >= 4) - { - return; - } + // if (a >= 4) + // { + // return; + // } + //} + string errMsg = string.Empty; + bool saveRst = SaveInfo(md, true, same[j].ToString(), false, ref errMsg); + if (saveRst == false) + { + //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); //return; } - #endregion #region 增加产量 @@ -2133,6 +2193,7 @@ namespace InjectionPC catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + } } @@ -2425,12 +2486,21 @@ namespace InjectionPC } } - //if (bll.Add_Info_New(md, Program.tableName) == false) - if (SaveBarCode(md, Program.tableName, false, "0",i== printCount) == false) + ////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) { - return; + //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); + //return; } + #endregion #region 打印单个标签 @@ -2442,7 +2512,7 @@ namespace InjectionPC ? System.AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : System.AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); //new + PrintMoudleName("0"); //new if (partNo.Contains("A2146982300") || partNo.Contains("A2146982400")) { @@ -2694,10 +2764,18 @@ namespace InjectionPC } } - //if (bll.Add_Info_New(md, Program.tableName) == false) - if (SaveBarCode(md, Program.tableName, false, "0") == false) - { - return; + ////if (bll.Add_Info_New(md, Program.tableName) == false) + //if (SaveBarCode(md, Program.tableName, false, "0") == false) + //{ + // return; + //} + + string errMsg = string.Empty; + bool saveRst = SaveInfo(md, false, "0", false, ref errMsg); + if (saveRst == false) + { + //MessageBox.Show("条码" + md.OneBarCode + "存储时发生错误,原因:" + errMsg); + //return; } #endregion @@ -2706,7 +2784,7 @@ namespace InjectionPC if (IsOne == "1") { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); + filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName("1"); //DataTable dt4 = plbll.SearchInfo(partNo, stationID); //if (dt4 != null && dt4.Rows.Count > 0) @@ -2934,6 +3012,7 @@ namespace InjectionPC private void label22_Click(object sender, EventArgs e) { string code = "", filename = "", printName = "", ManufacturerName = ""; + string IsSupply = "0"; BarCodeModel md = new BarCodeModel(); BarCodeBLL bll = new BarCodeBLL(); ProductBLL pbll = new ProductBLL(); @@ -2998,7 +3077,7 @@ namespace InjectionPC } ManufacturerName = pdt.Rows[0]["ManufacturerName"].ToString().Trim(); - + IsSupply = pdt.Rows[0]["IsSupply"].ToString(); } } else @@ -3027,7 +3106,7 @@ namespace InjectionPC ? AppDomain.CurrentDomain.BaseDirectory + "wl.grf" : AppDomain.CurrentDomain.BaseDirectory + - PrintMoudleName(); //new + PrintMoudleName(IsSupply); //new if (md.PartNo.Contains("A2146982300") || md.PartNo.Contains("A2146982400")) { @@ -3788,10 +3867,18 @@ namespace InjectionPC } } - //if (brbll.Add_Info_New(md, Program.tableName)==false) - if (SaveBarCode(md, Program.tableName, true, mould) == false) - { - return; + ////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 @@ -3811,7 +3898,7 @@ namespace InjectionPC { if (IsSupply == "1") { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); + filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply); string reportName = ConfigurationManager.AppSettings[printName].ToString(); DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode); @@ -3859,12 +3946,19 @@ namespace InjectionPC } } - //if (brbll.Add_Info_New(md, Program.tableName)==false) - if (SaveBarCode(md, Program.tableName, true, mould) == false) - { - return; - } + ////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 打印条码,判断是否打印单个条码 @@ -3882,7 +3976,7 @@ namespace InjectionPC { if (IsSupply == "1") { - filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(); //new + filename = System.AppDomain.CurrentDomain.BaseDirectory + PrintMoudleName(IsSupply); //new string reportName = ConfigurationManager.AppSettings[printName].ToString(); DataTable headTable = GetPrintHeadTable(partNo[j].ToString().Trim(), PartName, NewOneCode, newcode); @@ -4106,9 +4200,12 @@ namespace InjectionPC return lReturn; } + //bool SaveBarCode(BarCodeModel bcm, string tableName, bool isAutoPrint, string mould, bool handPrint = false) + //{ + // return true; + //} - - bool SaveBarCode(BarCodeModel bcm,string tableName, bool isAutoPrint,string mould,bool handPrint = false) + 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); @@ -4118,73 +4215,50 @@ namespace InjectionPC } else { - LogErrBLL.AddInfo(rst, MethodBase.GetCurrentMethod()); + errorMsg = rst; + LogErrBLL.AddInfo(Program.station+"-"+ bcm.OneBarCode + ":" + rst, MethodBase.GetCurrentMethod()); return false; } } - - - - /// - /// 打印箱码 - /// - /// - /// - /// - private void PrintBoxCode(DataRow boxRow,int realCount,string mould) + private BarCodeModel _lastbarCodeModel =null; + bool SaveInfo(BarCodeModel md, bool isAutoPrint, string mould, bool handPrint, ref string errMsg) { - string 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("Line"); - DataRow row = headTable.NewRow(); - string boxCode = boxRow["BoxNo"].ToString(); - string[] boxes = boxCode.Split('.'); - if(boxes.Length != 4) + if (_lastbarCodeModel!=null) { - //新生成一个箱码 应该都有 - } - else - { - row["BoxNo"] = boxCode; - row["PartNo"] = boxes[0].Trim(); - row["PartName"] = boxRow["PartName"].ToString(); - row["BatchNo"] = boxes[1].Trim(); - row["PackCount"] = realCount; - row["Line"] = boxRow["StationNo"].ToString()+"注塑机"; - } - UpdateBoxRecordPrintState(boxCode); - string printBoxName = string.Empty; - if (mould == "1") - { - printBoxName = "Printer3"; - } - else - { - printBoxName = "Printer4"; + DataTable dt = _barCodeBLL.SeachInfoByOne(_lastbarCodeModel.OneBarCode, Program.tableName, 1); + if(dt.Rows.Count == 0) + { + SaveLog3("重发数据"+ Program.station + ",条码" + md.OneBarCode); + SaveBarCode(_lastbarCodeModel, Program.tableName, isAutoPrint, mould, ref errMsg, handPrint); + } } - - 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); + _lastbarCodeModel = md; + if (SaveBarCode(md, Program.tableName, isAutoPrint, mould, ref errMsg, handPrint) == false) + { + int a = 0; + for (int l = 0; l < 3; l++) + { + // if (brbll.Add_Info_New(md, Program.tableName)) + if (SaveBarCode(md, Program.tableName, true, mould, ref errMsg, handPrint) == true) + { + break; + } - } + a += 1; + //Thread.Sleep(200); + Thread.Sleep(200); + } - private void UpdateBoxRecordPrintState(string UpdatePrinted) - { - _injectionBoxBLL.UpdatePrinted(UpdatePrinted); + if (a >= 2) + { + SaveLog3(Program.station+"保存3次失败,条码" + md.OneBarCode); + return false; + } + } + return true; } - - /// /// 20位注塑条码 /// @@ -4299,6 +4373,12 @@ namespace InjectionPC try { this.FormClosed += (arg1, arg2) => { + + opcGroup1.DataChange -= new DIOPCGroupEvent_DataChangeEventHandler(opcGroup1_DataChange); + opcServer.OPCGroups.RemoveAll(); + opcServer.Disconnect(); + serialPort1.Close(); + FrmMain2408 frm = new FrmMain2408(); frm.Show(); }; @@ -4310,7 +4390,7 @@ namespace InjectionPC } } - string PrintMoudleName() + string PrintMoudleName(string isSupply = "0") { if("IM05,IM08,IM10".Contains(Program.station)) //二维小条码 { @@ -4327,14 +4407,24 @@ namespace InjectionPC } else if ("IM13,IM14".Contains(Program.station)) //直供条码 { - return "单个条码1.grf"; + //return "单个条码1.grf"; + if (isSupply == "0") //13,14机台,直供件打二维码 非直供件打一维码 + { + return "单个条码.grf"; + } + else + { + return "单个条码2.grf"; + } } else { return "单个条码2.grf"; } - } + } + + DataTable GetPrintLableModel() { DataTable headTable = new DataTable(); @@ -4360,50 +4450,18 @@ namespace InjectionPC headTable.Rows.Add(row); return headTable; } - List GetProductBoxSize(string productCode,ref string currentSize) + + void SaveLog3(string txt) { try { - ProductBLL productBll = new ProductBLL(); - DataTable dt = productBll.SearchInfoByPartNo(productCode); - if (dt.Rows.Count == 0) - { - currentSize = "24"; - MessageBox.Show("零件号{productCode}未设置标包,默认为24,请及时核对后进行配置."); - return null; - } - currentSize = dt.Rows[0]["PackCount"].ToString(); - string sizeStr = dt.Rows[0]["PackCountSize"].ToString(); - List list = new List(); - if (string.IsNullOrEmpty(sizeStr)) - { - list.Add(currentSize); - return list; - } - else - { - string[] array = sizeStr.Split(','); - foreach (string item in array) - { - if (!list.Contains(item)) - { - list.Add(item); - } - } - if (!list.Contains(currentSize)) - { - list.Add(currentSize); - } - } - return list; + LogSysBLL.AddInfo(txt, MethodBase.GetCurrentMethod()); + } - catch(Exception ex) + catch (Exception ex) { - currentSize = "24"; - MessageBox.Show("零件号{productCode}未设置标包,默认为24,请及时核对后进行配置."); - return null; + LogHelper.WriteLog("SaveLog:" + ex.Message); } - } } } diff --git a/InjectionPC/Properties/AssemblyInfo.cs b/InjectionPC/Properties/AssemblyInfo.cs index e4ff4a6..7aad544 100644 --- a/InjectionPC/Properties/AssemblyInfo.cs +++ b/InjectionPC/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.1.18")] -[assembly: AssemblyFileVersion("1.0.1.18")] +[assembly: AssemblyVersion("1.0.1.19")] +[assembly: AssemblyFileVersion("1.0.1.19")] diff --git a/MESClassLibrary/BLL/Inspection/InjectionBoxBLL.cs b/MESClassLibrary/BLL/Inspection/InjectionBoxBLL.cs index 97da25f..b7a5ea7 100644 --- a/MESClassLibrary/BLL/Inspection/InjectionBoxBLL.cs +++ b/MESClassLibrary/BLL/Inspection/InjectionBoxBLL.cs @@ -92,5 +92,26 @@ namespace MESClassLibrary.BLL.Inspection return null; } } + + public DataRow SearchNewPrintedBoxInfo(string stationNo, string mould) + { + try + { + DataTable dt = db.SearchNewPrintedBoxInfo(stationNo, mould); + if (dt.Rows.Count > 0) + { + return dt.Rows[0]; + } + else + { + return null; + } + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return null; + } + } } } diff --git a/MESClassLibrary/BLL/Log/LogErrBLL.cs b/MESClassLibrary/BLL/Log/LogErrBLL.cs index c234ecc..98a4182 100644 --- a/MESClassLibrary/BLL/Log/LogErrBLL.cs +++ b/MESClassLibrary/BLL/Log/LogErrBLL.cs @@ -51,7 +51,7 @@ namespace MESClassLibrary.BLL.Log LogErrModel md = new LogErrModel(); md.ID = Guid.NewGuid().ToString(); md.ErrContent = err; - md.ErrSource = mb.DeclaringType.Name + "." + mb.Name; + md.ErrSource =mb.DeclaringType.Name + "." + mb.Name; db.Add_Info(md); } diff --git a/MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs b/MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs index 12a9095..46d3e45 100644 --- a/MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs +++ b/MESClassLibrary/DAL/BasicInfo/BarCodeDAl.cs @@ -375,11 +375,9 @@ namespace MESClassLibrary.DAL.BasicInfo return local.Exec_NonQuery(sql); - - - - } + + public DataTable SearchInfo(string stationNo) { try diff --git a/MESClassLibrary/DAL/Injection/InjectionBoxDAL.cs b/MESClassLibrary/DAL/Injection/InjectionBoxDAL.cs index 921c1f0..7240637 100644 --- a/MESClassLibrary/DAL/Injection/InjectionBoxDAL.cs +++ b/MESClassLibrary/DAL/Injection/InjectionBoxDAL.cs @@ -242,5 +242,25 @@ namespace MESClassLibrary.DAL.Injection return null; } } + public DataTable SearchNewPrintedBoxInfo(string stationID, string mould) + { + try + { + string sql = @"select top 1 * from " + TableName + " where StationNo=@StationNo and Mould=@Mould and IsPrint=1 order by CreateTime desc "; + + SqlParameter[] param = new SqlParameter[2]; + param[0] = new SqlParameter("@StationNo", SqlDbType.VarChar); + param[0].Value = stationID; + param[1] = new SqlParameter("@Mould", SqlDbType.VarChar); + param[1].Value = mould; + + return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0]; + } + catch (Exception ex) + { + LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); + return null; + } + } } } diff --git a/MESClassLibrary/DAL/Injection/UniqueDal.cs b/MESClassLibrary/DAL/Injection/UniqueDal.cs index 0229025..fb2a818 100644 --- a/MESClassLibrary/DAL/Injection/UniqueDal.cs +++ b/MESClassLibrary/DAL/Injection/UniqueDal.cs @@ -66,6 +66,7 @@ namespace MESClassLibrary.DAL.Injection } catch (Exception ex) { + return GetPackageSerialNo(partNo, batch, packageSize); } } diff --git a/PaintingPC/FrmQuality.cs b/PaintingPC/FrmQuality.cs index 6c273f1..0a4854f 100644 --- a/PaintingPC/FrmQuality.cs +++ b/PaintingPC/FrmQuality.cs @@ -894,7 +894,7 @@ namespace PaintingPC catch (Exception ex) { LogHelper.WriteLogManager(ex); - LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + LogHelper.WriteErrLogBase("缺陷项-"+ex.ToString(), MethodBase.GetCurrentMethod().Name); throw ex; } @@ -936,7 +936,7 @@ namespace PaintingPC catch (Exception ex) { LogHelper.WriteLogManager(ex); - LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + LogHelper.WriteErrLogBase("图片项-" + ex.ToString(), MethodBase.GetCurrentMethod().Name); } #endregion @@ -1093,7 +1093,7 @@ namespace PaintingPC { MessageBox.Show("请查看网络是否与服务器连通,无法连通请联系网络管理员。" + ex.ToString()); LogHelper.WriteLogManager(ex); - LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + LogHelper.WriteErrLogBase("整体项-" + ex.ToString(), MethodBase.GetCurrentMethod().Name); } }