Pārlūkot izejas kodu

上料首件防呆,导出报表更新

callm 4 gadi atpakaļ
vecāks
revīzija
31b1829bbb

+ 91 - 0
UAS_MES_ODLF/DataOperate/ExcelHandler.cs

@@ -35,6 +35,26 @@ namespace UAS_MES_NEW.DataOperate
             return filePath;
             return filePath;
         }
         }
 
 
+        /// <summary>
+        /// 导出Excel,返回文件在客户端的路径
+        /// </summary>
+        public string ExportExcel(DataTable[] dt, string FolderPath)
+        {
+            //创建一个内存流,用来接收转换成Excel的内容
+            MemoryStream ms;
+            ms = DataTableToExcel(dt);
+            //以系统当前时间命名文件,FileMode.Create表示创建文件,FileAccess.Write表示拥有写的权限
+            string filePath = @FolderPath + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
+            FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
+            byte[] data = ms.ToArray();
+            fs.Write(data, 0, data.Length);
+            fs.Flush();
+            //释放当前Excel文件,否则打开文件的时候会显示文件被占用
+            ms.Dispose();
+            fs.Dispose();
+            return filePath;
+        }
+
         /// <summary>
         /// <summary>
         /// 导出Excel,返回文件在客户端的路径
         /// 导出Excel,返回文件在客户端的路径
         /// </summary>
         /// </summary>
@@ -261,6 +281,77 @@ namespace UAS_MES_NEW.DataOperate
             return ms;
             return ms;
         }
         }
 
 
+        /// <summary>
+        /// 将DataTable形式的数据转成Excel格式的,然后用字节流的形式写入文件
+        /// </summary>
+        /// <param name="DataTable"></param>
+        /// <returns></returns>
+        public MemoryStream DataTableToExcel(DataTable[] DataTable)
+        {
+
+            //创建内存流
+            MemoryStream ms = new MemoryStream();
+            //创建一个Book,相当于一个Excel文件
+            HSSFWorkbook book = new HSSFWorkbook();
+            for (int k = 0; k < DataTable.Length; k++)
+            {
+                DataTable dt = DataTable[k];
+                //Excel中的Sheet
+                ISheet sheet = book.CreateSheet("sheet" + k);
+                //获取行数量和列数量
+                int rowNum = dt.Rows.Count;
+                int columnNum = dt.Columns.Count;
+                //设置列的宽度,根据首行的列的内容的长度来设置
+                for (int i = 0; i < columnNum; i++)
+                {
+                    int dataLength = dt.Columns[i].ColumnName.Length;
+                    sheet.SetColumnWidth(i, dataLength * 700);
+                }
+                //首先画好第一行带颜色的,单独写出来,避免写在循环里面
+                IRow row = sheet.CreateRow(0);
+                //冻结第一行
+                sheet.CreateFreezePane(0, 1, 0, 1);
+                ICellStyle style = book.CreateCellStyle();
+                style.FillForegroundColor = HSSFColor.PALE_BLUE.index;
+                style.FillPattern = FillPatternType.BIG_SPOTS;
+                style.FillBackgroundColor = HSSFColor.LIGHT_GREEN.index;
+                //设置边框
+                style.BorderBottom = BorderStyle.THICK;
+                style.BorderLeft = BorderStyle.THICK;
+                style.BorderRight = BorderStyle.THICK;
+                style.BorderTop = BorderStyle.THICK;
+                row.HeightInPoints = 20;
+                //固定第一行
+                //row.RowStyle.IsLocked=true;
+                //给第一行的标签赋值样式和值
+                for (int j = 0; j < columnNum; j++)
+                {
+                    row.CreateCell(j);
+                    row.Cells[j].CellStyle = style;
+                    row.Cells[j].CellStyle.VerticalAlignment = VerticalAlignment.CENTER;
+                    row.Cells[j].CellStyle.Alignment = HorizontalAlignment.CENTER;
+                    row.Cells[j].SetCellValue(dt.Columns[j].ColumnName);
+                }
+
+                //将DataTable的值循环赋值给book,Aligment设置居中
+                //之前已经画了带颜色的第一行,所以从i=1开始画
+                for (int i = 0; i < rowNum; i++)
+                {
+                    IRow row1 = sheet.CreateRow(i + 1);
+                    row1.HeightInPoints = 20;
+                    for (int j = 0; j < columnNum; j++)
+                    {
+                        row1.CreateCell(j);
+                        row1.Cells[j].SetCellValue(dt.Rows[i][j].ToString());
+                        row1.GetCell(j).CellStyle.VerticalAlignment = VerticalAlignment.CENTER;
+                    }
+                }
+                //将book的内容写入内存流中返回
+            }
+            book.Write(ms);
+            return ms;
+        }
+
         /// <summary>
         /// <summary>
         /// 将DataTable形式的数据转成Excel格式的,然后用字节流的形式写入文件
         /// 将DataTable形式的数据转成Excel格式的,然后用字节流的形式写入文件
         /// </summary>
         /// </summary>

+ 8 - 3
UAS_MES_ODLF/FunctionCode/Make/Make_ColorBoxLoadPrintBZ.cs

@@ -507,9 +507,13 @@ namespace UAS_MES_NEW.Make
                     //刷新数据
                     //刷新数据
                     EventArgs e = new EventArgs();
                     EventArgs e = new EventArgs();
                     object sender = null;
                     object sender = null;
-                    if (!Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, ms_sncode, int.Parse(PrintNum.Text), ma_code, ma_prodcode.Text, "彩盒标", "0", out ErrorMessage))
+                    for (int i = 0; i < _dt.Rows.Count; i++)
                     {
                     {
-                        OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
+                        if (!Print.CodeSoft(Tag.ToString(), ref lbl, _dt.Rows[i]["la_url"].ToString(), _dt.Rows[i]["la_id"].ToString(), Printer.Text, ms_sncode, int.Parse(PrintNum.Text), ma_code, ma_prodcode.Text, "彩盒标", "0", out ErrorMessage))
+                        {
+                            //提示用户打印成功
+                            OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
+                        }
                     }
                     }
                     ma_code_UserControlTextChanged(sender, e);
                     ma_code_UserControlTextChanged(sender, e);
                 }
                 }
@@ -554,10 +558,11 @@ namespace UAS_MES_NEW.Make
                 }
                 }
             }
             }
         }
         }
+        DataTable _dt;
 
 
         private void ma_prodcode_TextChanged(object sender, EventArgs e)
         private void ma_prodcode_TextChanged(object sender, EventArgs e)
         {
         {
-            DataTable _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault from label where la_prodcode='" + ma_prodcode.Text + "' and la_templatetype='彩盒标' and la_statuscode='AUDITED' order by la_isdefault", "select");
+            _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault from label where la_prodcode='" + ma_prodcode.Text + "' and la_templatetype='彩盒标' and la_statuscode='AUDITED' order by la_isdefault", "select");
             PrintLabel.DataSource = _dt;
             PrintLabel.DataSource = _dt;
             PrintLabel.DisplayMember = "la_url";
             PrintLabel.DisplayMember = "la_url";
             PrintLabel.ValueMember = "la_id";
             PrintLabel.ValueMember = "la_id";

+ 81 - 66
UAS_MES_ODLF/FunctionCode/Make/Make_FeedingCollection.Designer.cs

@@ -50,12 +50,19 @@
             this.sir_remark_label = new System.Windows.Forms.CheckBox();
             this.sir_remark_label = new System.Windows.Forms.CheckBox();
             this.NoteForChange = new System.Windows.Forms.CheckBox();
             this.NoteForChange = new System.Windows.Forms.CheckBox();
             this.LabelDataGridView = new System.Windows.Forms.DataGridView();
             this.LabelDataGridView = new System.Windows.Forms.DataGridView();
+            this.CheckFirstSN = new System.Windows.Forms.CheckBox();
             this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.序号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.cm_makecode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_detail_ = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.cm_soncode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.cm_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.BarCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.sir_remark = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.sir_remark = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.StepCount = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SourceStepCount();
             this.StepCount = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SourceStepCount();
             this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
             this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
@@ -72,12 +79,6 @@
             this.Confirm = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.Confirm = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SnCollectionBox();
             this.code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SnCollectionBox();
             this.sn_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.sn_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.序号 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.cm_makecode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_detail_ = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.cm_soncode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.cm_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.BarCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.ClearSn_code)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.ClearSn_code)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.LabelDataGridView)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.LabelDataGridView)).BeginInit();
             this.SuspendLayout();
             this.SuspendLayout();
@@ -342,6 +343,18 @@
             this.LabelDataGridView.Size = new System.Drawing.Size(1282, 454);
             this.LabelDataGridView.Size = new System.Drawing.Size(1282, 454);
             this.LabelDataGridView.TabIndex = 193;
             this.LabelDataGridView.TabIndex = 193;
             // 
             // 
+            // CheckFirstSN
+            // 
+            this.CheckFirstSN.AutoSize = true;
+            this.CheckFirstSN.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.CheckFirstSN.Location = new System.Drawing.Point(354, 720);
+            this.CheckFirstSN.Margin = new System.Windows.Forms.Padding(6);
+            this.CheckFirstSN.Name = "CheckFirstSN";
+            this.CheckFirstSN.Size = new System.Drawing.Size(222, 45);
+            this.CheckFirstSN.TabIndex = 194;
+            this.CheckFirstSN.Text = "首件SN检测";
+            this.CheckFirstSN.UseVisualStyleBackColor = true;
+            // 
             // dataGridViewTextBoxColumn1
             // dataGridViewTextBoxColumn1
             // 
             // 
             this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
             this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
@@ -390,7 +403,7 @@
             this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
             this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
             this.dataGridViewTextBoxColumn5.ReadOnly = true;
             this.dataGridViewTextBoxColumn5.ReadOnly = true;
             this.dataGridViewTextBoxColumn5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             this.dataGridViewTextBoxColumn5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            this.dataGridViewTextBoxColumn5.Width = 5;
+            this.dataGridViewTextBoxColumn5.Width = 64;
             // 
             // 
             // dataGridViewTextBoxColumn6
             // dataGridViewTextBoxColumn6
             // 
             // 
@@ -402,6 +415,64 @@
             this.dataGridViewTextBoxColumn6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             this.dataGridViewTextBoxColumn6.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             this.dataGridViewTextBoxColumn6.Width = 300;
             this.dataGridViewTextBoxColumn6.Width = 300;
             // 
             // 
+            // 序号
+            // 
+            this.序号.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.序号.DataPropertyName = "sp_detno";
+            this.序号.HeaderText = "序号";
+            this.序号.Name = "序号";
+            this.序号.ReadOnly = true;
+            this.序号.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.序号.Width = 70;
+            // 
+            // cm_makecode
+            // 
+            this.cm_makecode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
+            this.cm_makecode.DataPropertyName = "sp_fsoncode";
+            this.cm_makecode.HeaderText = "上料料号";
+            this.cm_makecode.Name = "cm_makecode";
+            this.cm_makecode.ReadOnly = true;
+            this.cm_makecode.Width = 5;
+            // 
+            // pr_detail_
+            // 
+            this.pr_detail_.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
+            this.pr_detail_.DataPropertyName = "pr_spec";
+            this.pr_detail_.HeaderText = "上料名称";
+            this.pr_detail_.Name = "pr_detail_";
+            this.pr_detail_.ReadOnly = true;
+            this.pr_detail_.Width = 5;
+            // 
+            // cm_soncode
+            // 
+            this.cm_soncode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
+            this.cm_soncode.DataPropertyName = "sp_prefix";
+            this.cm_soncode.HeaderText = "前缀";
+            this.cm_soncode.Name = "cm_soncode";
+            this.cm_soncode.ReadOnly = true;
+            this.cm_soncode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.cm_soncode.Width = 5;
+            // 
+            // cm_barcode
+            // 
+            this.cm_barcode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
+            this.cm_barcode.DataPropertyName = "sp_length";
+            this.cm_barcode.HeaderText = "长度";
+            this.cm_barcode.Name = "cm_barcode";
+            this.cm_barcode.ReadOnly = true;
+            this.cm_barcode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.cm_barcode.Width = 64;
+            // 
+            // BarCode
+            // 
+            this.BarCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
+            this.BarCode.HeaderText = "条码号";
+            this.BarCode.MinimumWidth = 300;
+            this.BarCode.Name = "BarCode";
+            this.BarCode.ReadOnly = true;
+            this.BarCode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.BarCode.Width = 300;
+            // 
             // sir_remark
             // sir_remark
             // 
             // 
             this.sir_remark.AllPower = null;
             this.sir_remark.AllPower = null;
@@ -642,69 +713,12 @@
             this.sn_code.Str2 = null;
             this.sn_code.Str2 = null;
             this.sn_code.TabIndex = 65;
             this.sn_code.TabIndex = 65;
             // 
             // 
-            // 序号
-            // 
-            this.序号.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.序号.DataPropertyName = "sp_detno";
-            this.序号.HeaderText = "序号";
-            this.序号.Name = "序号";
-            this.序号.ReadOnly = true;
-            this.序号.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            this.序号.Width = 70;
-            // 
-            // cm_makecode
-            // 
-            this.cm_makecode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
-            this.cm_makecode.DataPropertyName = "sp_fsoncode";
-            this.cm_makecode.HeaderText = "上料料号";
-            this.cm_makecode.Name = "cm_makecode";
-            this.cm_makecode.ReadOnly = true;
-            this.cm_makecode.Width = 5;
-            // 
-            // pr_detail_
-            // 
-            this.pr_detail_.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
-            this.pr_detail_.DataPropertyName = "pr_spec";
-            this.pr_detail_.HeaderText = "上料名称";
-            this.pr_detail_.Name = "pr_detail_";
-            this.pr_detail_.ReadOnly = true;
-            this.pr_detail_.Width = 5;
-            // 
-            // cm_soncode
-            // 
-            this.cm_soncode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
-            this.cm_soncode.DataPropertyName = "sp_prefix";
-            this.cm_soncode.HeaderText = "前缀";
-            this.cm_soncode.Name = "cm_soncode";
-            this.cm_soncode.ReadOnly = true;
-            this.cm_soncode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            this.cm_soncode.Width = 5;
-            // 
-            // cm_barcode
-            // 
-            this.cm_barcode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
-            this.cm_barcode.DataPropertyName = "sp_length";
-            this.cm_barcode.HeaderText = "长度";
-            this.cm_barcode.Name = "cm_barcode";
-            this.cm_barcode.ReadOnly = true;
-            this.cm_barcode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            this.cm_barcode.Width = 64;
-            // 
-            // BarCode
-            // 
-            this.BarCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
-            this.BarCode.HeaderText = "条码号";
-            this.BarCode.MinimumWidth = 300;
-            this.BarCode.Name = "BarCode";
-            this.BarCode.ReadOnly = true;
-            this.BarCode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            this.BarCode.Width = 300;
-            // 
             // Make_FeedingCollection
             // Make_FeedingCollection
             // 
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1796, 974);
             this.ClientSize = new System.Drawing.Size(1796, 974);
+            this.Controls.Add(this.CheckFirstSN);
             this.Controls.Add(this.LabelDataGridView);
             this.Controls.Add(this.LabelDataGridView);
             this.Controls.Add(this.NoteForChange);
             this.Controls.Add(this.NoteForChange);
             this.Controls.Add(this.sir_remark);
             this.Controls.Add(this.sir_remark);
@@ -751,7 +765,7 @@
             this.SizeChanged += new System.EventHandler(this.Make_FeedingCollection_SizeChanged);
             this.SizeChanged += new System.EventHandler(this.Make_FeedingCollection_SizeChanged);
             ((System.ComponentModel.ISupportInitialize)(this.ClearSn_code)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.ClearSn_code)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.LabelDataGridView)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.LabelDataGridView)).EndInit();
-            this.ResumeLayout(false);
+            this.ResumeLayout(true);
             this.PerformLayout();
             this.PerformLayout();
 
 
         }
         }
@@ -806,5 +820,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn cm_soncode;
         private System.Windows.Forms.DataGridViewTextBoxColumn cm_soncode;
         private System.Windows.Forms.DataGridViewTextBoxColumn cm_barcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn cm_barcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn BarCode;
         private System.Windows.Forms.DataGridViewTextBoxColumn BarCode;
+        private System.Windows.Forms.CheckBox CheckFirstSN;
     }
     }
 }
 }

+ 10 - 0
UAS_MES_ODLF/FunctionCode/Make/Make_FeedingCollection.cs

@@ -159,6 +159,16 @@ namespace UAS_MES_NEW.Make
                             string sp_barcoderule = dt1.Rows[RemainIndex]["sp_barcoderule"].ToString();
                             string sp_barcoderule = dt1.Rows[RemainIndex]["sp_barcoderule"].ToString();
                             string sp_checkbarcode = dt1.Rows[RemainIndex]["sp_checkbarcode"].ToString();
                             string sp_checkbarcode = dt1.Rows[RemainIndex]["sp_checkbarcode"].ToString();
                             string sp_checksalecode = dt1.Rows[RemainIndex]["sp_checksalecode"].ToString();
                             string sp_checksalecode = dt1.Rows[RemainIndex]["sp_checksalecode"].ToString();
+                            //检测主板SN是否和传入的SN一致
+                            if (CheckFirstSN.Checked)
+                            {
+                                RemainIndex = 0;
+                                if (sn_code.Text != code.Text)
+                                {
+                                    OperateResult.AppendText(">>首件条码和SN号码不一致\n", Color.Red, code);
+                                    return;
+                                }
+                            }
                             if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_checksalecode, out ErrorMessage))
                             if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_checksalecode, out ErrorMessage))
                             {
                             {
                                 //判断采集的条码和本次采集的也不能重复
                                 //判断采集的条码和本次采集的也不能重复

+ 18 - 0
UAS_MES_ODLF/FunctionCode/Make/Make_FeedingCollection.resx

@@ -135,6 +135,24 @@
   <metadata name="BarCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
   <metadata name="BarCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
     <value>True</value>
   </metadata>
   </metadata>
+  <metadata name="序号.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="cm_makecode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="pr_detail_.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="cm_soncode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="cm_barcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="BarCode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="Clean.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
   <data name="Clean.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
     <value>

+ 23 - 1
UAS_MES_ODLF/FunctionCode/Query/Query_DateRate.Designer.cs

@@ -38,6 +38,7 @@
             this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             this.pr_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             this.pr_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             this.Export = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.Export = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
+            this.Miss_Test = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.SuspendLayout();
             this.SuspendLayout();
             // 
             // 
             // BeginDate
             // BeginDate
@@ -149,15 +150,35 @@
             this.Export.Power = null;
             this.Export.Power = null;
             this.Export.Size = new System.Drawing.Size(150, 56);
             this.Export.Size = new System.Drawing.Size(150, 56);
             this.Export.TabIndex = 0;
             this.Export.TabIndex = 0;
-            this.Export.Text = "导出";
+            this.Export.Text = "导出直通率";
             this.Export.UseVisualStyleBackColor = false;
             this.Export.UseVisualStyleBackColor = false;
             this.Export.Click += new System.EventHandler(this.Export_Click);
             this.Export.Click += new System.EventHandler(this.Export_Click);
             // 
             // 
+            // Miss_Test
+            // 
+            this.Miss_Test.AllPower = null;
+            this.Miss_Test.BackColor = System.Drawing.Color.Transparent;
+            this.Miss_Test.DownImage = ((System.Drawing.Image)(resources.GetObject("Miss_Test.DownImage")));
+            this.Miss_Test.Image = null;
+            this.Miss_Test.IsShowBorder = true;
+            this.Miss_Test.Location = new System.Drawing.Point(514, 515);
+            this.Miss_Test.Margin = new System.Windows.Forms.Padding(6);
+            this.Miss_Test.MoveImage = ((System.Drawing.Image)(resources.GetObject("Miss_Test.MoveImage")));
+            this.Miss_Test.Name = "Miss_Test";
+            this.Miss_Test.NormalImage = ((System.Drawing.Image)(resources.GetObject("Miss_Test.NormalImage")));
+            this.Miss_Test.Power = null;
+            this.Miss_Test.Size = new System.Drawing.Size(150, 56);
+            this.Miss_Test.TabIndex = 216;
+            this.Miss_Test.Text = "导出误测数据";
+            this.Miss_Test.UseVisualStyleBackColor = false;
+            this.Miss_Test.Click += new System.EventHandler(this.Miss_Test_Click);
+            // 
             // Query_DateRate
             // Query_DateRate
             // 
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1494, 1075);
             this.ClientSize = new System.Drawing.Size(1494, 1075);
+            this.Controls.Add(this.Miss_Test);
             this.Controls.Add(this.ma_code);
             this.Controls.Add(this.ma_code);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.pr_code);
             this.Controls.Add(this.pr_code);
@@ -188,5 +209,6 @@
         private System.Windows.Forms.Label ms_makecode_label;
         private System.Windows.Forms.Label ms_makecode_label;
         private CustomControl.TextBoxWithIcon.SearchTextBox ma_code;
         private CustomControl.TextBoxWithIcon.SearchTextBox ma_code;
         private System.Windows.Forms.Label label1;
         private System.Windows.Forms.Label label1;
+        private CustomControl.ButtonUtil.NormalButton Miss_Test;
     }
     }
 }
 }

+ 37 - 1
UAS_MES_ODLF/FunctionCode/Query/Query_DateRate.cs

@@ -18,6 +18,8 @@ namespace UAS_MES_NEW.Query
 
 
         DataTable Dbfind;
         DataTable Dbfind;
 
 
+        ExcelHandler eh = new ExcelHandler();
+
         public Query_DateRate()
         public Query_DateRate()
         {
         {
             InitializeComponent();
             InitializeComponent();
@@ -59,7 +61,7 @@ namespace UAS_MES_NEW.Query
 
 
                 DataTable dt = (DataTable)dh.ExecuteSql(v_sql + v_sql1, "select");
                 DataTable dt = (DataTable)dh.ExecuteSql(v_sql + v_sql1, "select");
                 string FolderPath = folderBrowserDialog1.SelectedPath;
                 string FolderPath = folderBrowserDialog1.SelectedPath;
-                ExcelHandler eh = new ExcelHandler();
+
 
 
                 string begindate = BeginDate.Value.ToString("yyyy-mm-dd");
                 string begindate = BeginDate.Value.ToString("yyyy-mm-dd");
                 string enddate = EndDate.Value.ToString("yyyy-mm-dd");
                 string enddate = EndDate.Value.ToString("yyyy-mm-dd");
@@ -93,5 +95,39 @@ namespace UAS_MES_NEW.Query
             Dbfind = pr_code.ReturnData;
             Dbfind = pr_code.ReturnData;
             BaseUtil.SetFormValue(this.Controls, Dbfind);
             BaseUtil.SetFormValue(this.Controls, Dbfind);
         }
         }
+
+        private void Miss_Test_Click(object sender, EventArgs e)
+        {
+            folderBrowserDialog1.Description = "选择导出的路径";
+            DialogResult result = folderBrowserDialog1.ShowDialog();
+            if (result == DialogResult.OK)
+            {
+                string v_sql = "";
+                string v_sql1 = "";
+                string condition = "sp_date between to_date('" + BeginDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss') and to_date('" + EndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss') ";
+                if (pr_code.Text != "")
+                {
+                    condition += " and sp_prodcode = '" + pr_code.Text + "'";
+                }
+                if (ma_code.Text != "")
+                {
+                    condition += " and sp_makecode = '" + ma_code.Text + "'";
+                }
+                LogicHandler.GetMissItemQuerySql(condition, out v_sql, out v_sql1);
+                DataTable dt = (DataTable)dh.ExecuteSql(v_sql, "select");
+                LogicHandler.GetMissFiveQuerySql(condition, out v_sql, out v_sql1);
+                DataTable dt1 = (DataTable)dh.ExecuteSql(v_sql, "select");
+                LogicHandler.GetBadFiveQuerySql(condition, out v_sql, out v_sql1);
+                DataTable dt2 = (DataTable)dh.ExecuteSql(v_sql, "select");
+                string FolderPath = folderBrowserDialog1.SelectedPath;
+                Console.WriteLine(dt.Rows.Count);
+                Console.WriteLine(dt1.Rows.Count);
+                Console.WriteLine(dt2.Rows.Count);
+                string path = eh.ExportExcel(new DataTable[] { dt, dt1, dt2 }, FolderPath);
+                string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+                if (close.ToString() == "Yes")
+                    System.Diagnostics.Process.Start(path);
+            }
+        }
     }
     }
 }
 }

+ 38 - 0
UAS_MES_ODLF/FunctionCode/Query/Query_DateRate.resx

@@ -157,6 +157,44 @@
         2azB52i13asPDvCgTCZjHGt5sdmqDw7woHQ6bRzX8ny1UR8c4EHJZNJc5fC7XKsPDvCgRCLR2x9Pzt9q
         2azB52i13asPDvCgTCZjHGt5sdmqDw7woHQ6bRzX8ny1UR8c4EHJZNJc5fC7XKsPDvCgRCLR2x9Pzt9q
         zT+Lpdqw/3A6W/HoUywWa32Nx8OL4zwffM8X6sJu7IcDPCgajaak7udoNNjsdgc81BZ2Yz8c4PH8cR2J
         zT+Lpdqw/3A6W/HoUywWa32Nx8OL4zwffM8X6sJu7IcDPCgajaak7udoNNjsdgc81BZ2Yz8c4PH8cR2J
         ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
         ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="Miss_Test.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFcSURBVFhH5di7UsJAFMbxtDT6QMI76IAFT0npIE0K
+        GcRORxHklpAIBHLfbILV8XxeNsMznJ35F5vu+82kWYuILD4N7oq75roCw27sb/x5WBdc27btntY64o/i
+        DnZjPxy4S6A0R6PHO1WUNHc9ep4uxIXd2D8eP/XZowWUThBG+n3p0stsKbbJ0qFDFFfscQuUbpzm9Pqx
+        Eh8c4PGLkuX0Nl+LDw4GJckUTRaO+OBQo+SKpitXfHAwKClfZuuN+OBgUDJV0NzxxAeHM5TFxhffGUpe
+        aFp5n+KDg0FRfHH8nfjgUKPoktztXnxwMCgFX7xdID441ChlRf7+ID44GBTNl21wFB8capSqot0xFB8c
+        /lE6Wa70IU5oH0Ziw/5cFebpoPUwHPbL04nCJKUgisWF3dgPB3gABc9v7fvBoBcnaVKdvkha2I39cPjx
+        oPrhusndcPinpIXd2N8gIusbTaFspKtR2SQAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="Miss_Test.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFzSURBVFhH5djNSgJRGMZxL2P2gTfQFbZvHSEZFBEW
+        CEIQBEIgVFiS9qXWoDmp4/fHzDmjM2a+vU/QqUVX0DvwXxxn9fwYXJwYEcXWNzIWt83dcq7AsBv7LXgA
+        ZI0r71/aaqjCJf8o7sFu7IcDFwdK4vimrv1oSZXRnArdQFzYjf3pQkOzRxIoVWc6X5X6M7ruBGIr9mbU
+        9MIVe9hAcXvBO125WnxwgMcXSpcPF20tPjgYlI5eUK6lxAcHg9Lmw3nTFx8cDEpLLSjr+OKDg0FpqojO
+        Gp744GBQ3vyITutT8cHBoDheRCe1ifjgYFBe+ZCxJ+KDg0GpT0NKv4zFBweDUpuEdFQdiQ8OBsXmw2Fl
+        JD44/KCM53TwNBQfHAzKMx/2Hgfig8M3SrXYUasUfz67DwOxYf9dV5urg+RWzta4aEnxn83OfV9c2I39
+        cIAHUOJceTNbUfmW94GX0sJu7IcDPH5fXCe4EvfXxe5/D7ux3yKi2CfkPhTy27lqkwAAAABJRU5ErkJg
+        gg==
+</value>
+  </data>
+  <data name="Miss_Test.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGVSURBVFhH5di7agJRFIXhDSKoYBQEC8FCECwEQRBE
+        4uUVEtTiPKVlom2wttM6IfF+15njXHRnL19jD/zFmanWV8zAEDNTp9OJS6/Sm2QUht3YH4cHtdvtF6k7
+        mUwG1tqd3FR3YTf2w0FKUVOu6XT68Xgw3+8PtWH/bDYbCkeLGo1Gz/d9JwzvrL0gCKx49KlerxtIBUGo
+        PjjAg2q1mqDc2fN99cEBHlStVk0oB+t56oMDPKhSqZggDNm1N/XBAR5ULpeNvGD46rrqgwM8qFQqGV8O
+        56ujPjjAg4rFosFL5ni5qA8O8KBCoWBuns/701l9cIAH5fN5QfF4dzipDw7woFwuZ+zN483+oD44wIOy
+        2azB52i13asPDvCgTCZjHGt5sdmqDw7woHQ6bRzX8ny1UR8c4EHJZNJc5fC7XKsPDvCgRCLR2x9Pzt9q
+        zT+Lpdqw/3A6W/HoUywWa32Nx8OL4zwffM8X6sJu7IcDPCgajaak7udoNNjsdgc81BZ2Yz8c4PH8cR2J
+        ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
 </value>
 </value>
   </data>
   </data>
 </root>
 </root>

+ 1 - 0
UAS_MES_ODLF/FunctionCode/Special/Special_CancelCollection.cs

@@ -62,6 +62,7 @@ namespace UAS_MES_NEW.Special
                     //送检数量-1
                     //送检数量-1
                     sqls.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1 where ob_checkno='" + ms_checkno + "'");
                     sqls.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1 where ob_checkno='" + ms_checkno + "'");
                 }
                 }
+                sqls.Add("delete from makebadcount where mbc_sncode='" + sn_code.Text + "'");
                 //清除上料数据
                 //清除上料数据
                 dt = (DataTable)dh.ExecuteSql("select cm_barcode,cm_materialtype,cm_makecode,cm_stepcode from craftmaterial where cm_sncode='" + sn_code.Text + "' and cm_makecode='" + ms_makecode + "'", "select");
                 dt = (DataTable)dh.ExecuteSql("select cm_barcode,cm_materialtype,cm_makecode,cm_stepcode from craftmaterial where cm_sncode='" + sn_code.Text + "' and cm_makecode='" + ms_makecode + "'", "select");
                 if (dt.Rows.Count > 0)
                 if (dt.Rows.Count > 0)

+ 30 - 0
UAS_MES_ODLF/PublicMethod/LogicHandler.cs

@@ -202,6 +202,36 @@ namespace UAS_MES_NEW.PublicMethod
             v_sql1 = param[2];
             v_sql1 = param[2];
         }
         }
 
 
+        public static void GetMissItemQuerySql(string iCondition, out string v_sql, out string v_sql1)
+        {
+            v_sql = "";
+            v_sql1 = "";
+            string[] param = new string[] { iCondition, v_sql, v_sql1 };
+            dh.CallProcedure("GetMissItemQuerySql", ref param);
+            v_sql = param[1];
+            v_sql1 = param[2];
+        }
+
+        public static void GetMissFiveQuerySql(string iCondition, out string v_sql, out string v_sql1)
+        {
+            v_sql = "";
+            v_sql1 = "";
+            string[] param = new string[] { iCondition, v_sql, v_sql1 };
+            dh.CallProcedure("GetMissFiveQuerySql", ref param);
+            v_sql = param[1];
+            v_sql1 = param[2];
+        }
+
+        public static void GetBadFiveQuerySql(string iCondition, out string v_sql, out string v_sql1)
+        {
+            v_sql = "";
+            v_sql1 = "";
+            string[] param = new string[] { iCondition, v_sql, v_sql1 };
+            dh.CallProcedure("GetBadFiveQuerySql", ref param);
+            v_sql = param[1];
+            v_sql1 = param[2];
+        }
+
         public static void DoCommandLog(string iCaller, string iUserCode, string iMakeCode, string iLineCode, string iSourceCode, string iOperate, string iResult, string iSncode, string iCheckno)
         public static void DoCommandLog(string iCaller, string iUserCode, string iMakeCode, string iLineCode, string iSourceCode, string iOperate, string iResult, string iSncode, string iCheckno)
         {
         {
             sql.Clear();
             sql.Clear();