Browse Source

根据导出的数据赋值中盒号打印

章政 6 years ago
parent
commit
fd74680ef9

+ 0 - 18
UAS-出货标签管理(贸易版)/ExportExcel.Designer.cs

@@ -69,8 +69,6 @@
             // CH_BLUEFILM
             // 
             this.CH_BLUEFILM.AutoSize = true;
-            this.CH_BLUEFILM.Checked = true;
-            this.CH_BLUEFILM.CheckState = System.Windows.Forms.CheckState.Checked;
             this.CH_BLUEFILM.Font = new System.Drawing.Font("宋体", 10F);
             this.CH_BLUEFILM.Location = new System.Drawing.Point(130, 58);
             this.CH_BLUEFILM.Margin = new System.Windows.Forms.Padding(2);
@@ -83,8 +81,6 @@
             // CH_SPLITBATCH
             // 
             this.CH_SPLITBATCH.AutoSize = true;
-            this.CH_SPLITBATCH.Checked = true;
-            this.CH_SPLITBATCH.CheckState = System.Windows.Forms.CheckState.Checked;
             this.CH_SPLITBATCH.Font = new System.Drawing.Font("宋体", 10F);
             this.CH_SPLITBATCH.Location = new System.Drawing.Point(350, 58);
             this.CH_SPLITBATCH.Margin = new System.Windows.Forms.Padding(2);
@@ -97,8 +93,6 @@
             // CH_PBCODE
             // 
             this.CH_PBCODE.AutoSize = true;
-            this.CH_PBCODE.Checked = true;
-            this.CH_PBCODE.CheckState = System.Windows.Forms.CheckState.Checked;
             this.CH_PBCODE.Font = new System.Drawing.Font("宋体", 10F);
             this.CH_PBCODE.Location = new System.Drawing.Point(130, 94);
             this.CH_PBCODE.Margin = new System.Windows.Forms.Padding(2);
@@ -111,8 +105,6 @@
             // CH_REMARK
             // 
             this.CH_REMARK.AutoSize = true;
-            this.CH_REMARK.Checked = true;
-            this.CH_REMARK.CheckState = System.Windows.Forms.CheckState.Checked;
             this.CH_REMARK.Font = new System.Drawing.Font("宋体", 10F);
             this.CH_REMARK.Location = new System.Drawing.Point(244, 94);
             this.CH_REMARK.Margin = new System.Windows.Forms.Padding(2);
@@ -139,8 +131,6 @@
             // CH_WATERID
             // 
             this.CH_WATERID.AutoSize = true;
-            this.CH_WATERID.Checked = true;
-            this.CH_WATERID.CheckState = System.Windows.Forms.CheckState.Checked;
             this.CH_WATERID.Font = new System.Drawing.Font("宋体", 10F);
             this.CH_WATERID.Location = new System.Drawing.Point(452, 58);
             this.CH_WATERID.Margin = new System.Windows.Forms.Padding(2);
@@ -197,8 +187,6 @@
             // BVCEO
             // 
             this.BVCEO.AutoSize = true;
-            this.BVCEO.Checked = true;
-            this.BVCEO.CheckState = System.Windows.Forms.CheckState.Checked;
             this.BVCEO.Font = new System.Drawing.Font("宋体", 10F);
             this.BVCEO.Location = new System.Drawing.Point(244, 174);
             this.BVCEO.Margin = new System.Windows.Forms.Padding(2);
@@ -211,8 +199,6 @@
             // TS
             // 
             this.TS.AutoSize = true;
-            this.TS.Checked = true;
-            this.TS.CheckState = System.Windows.Forms.CheckState.Checked;
             this.TS.Font = new System.Drawing.Font("宋体", 10F);
             this.TS.Location = new System.Drawing.Point(130, 174);
             this.TS.Margin = new System.Windows.Forms.Padding(2);
@@ -225,8 +211,6 @@
             // percent
             // 
             this.percent.AutoSize = true;
-            this.percent.Checked = true;
-            this.percent.CheckState = System.Windows.Forms.CheckState.Checked;
             this.percent.Font = new System.Drawing.Font("宋体", 10F);
             this.percent.Location = new System.Drawing.Point(130, 128);
             this.percent.Margin = new System.Windows.Forms.Padding(2);
@@ -310,8 +294,6 @@
             // FirstPage_WID
             // 
             this.FirstPage_WID.AutoSize = true;
-            this.FirstPage_WID.Checked = true;
-            this.FirstPage_WID.CheckState = System.Windows.Forms.CheckState.Checked;
             this.FirstPage_WID.Font = new System.Drawing.Font("宋体", 10F);
             this.FirstPage_WID.Location = new System.Drawing.Point(130, 254);
             this.FirstPage_WID.Margin = new System.Windows.Forms.Padding(2);

+ 2 - 1
UAS-出货标签管理(贸易版)/ExportExcel.cs

@@ -82,7 +82,8 @@ namespace UAS_LabelMachine
                 sql.Clear();
                 sql.Append("select " + es_field1.Substring(0, es_field1.Length - 1) + " from  prodinout left join prodiodetail on pi_id=pd_piid left join ");
                 sql.Append("chip_in_out on pd_id=io_pdid left join chip on ch_code=io_chipcode left join CHIP_WAFERTEST_VIEW on ch_code=chw_chipcode ");
-                sql.Append("left join CHIP_EDCDATA_VIEW on che_chipcode=ch_code left join product on pr_code=pd_prodcode where pi_inoutno='" + inoutno + "' order by io_detno");
+                sql.Append("left join CHIP_EDCDATA_VIEW on che_chipcode=ch_code left join product on pr_code=pd_prodcode left join prodiobarcode on ");
+                sql.Append("pib_piid=pi_id and pib_custbarcode=ch_code where pi_inoutno='" + inoutno + "' order by ch_code");
                 DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
 
                 for (int i = 0; i < dt.Columns.Count; i++)

+ 30 - 17
UAS-出货标签管理(贸易版)/PublicMethod/ExcelHandler.cs

@@ -9,6 +9,7 @@ using UAS_LabelMachine.Entity;
 using UAS_LabelMachine.PublicMethod;
 using System.Collections.Generic;
 using System.Windows.Forms;
+using System.Text.RegularExpressions;
 
 namespace UAS_LabelMachine
 {
@@ -43,7 +44,7 @@ namespace UAS_LabelMachine
         {
             //创建一个内存流,用来接收转换成Excel的内容
             MemoryStream ms;
-            ms = DataTableToExcel1(firstsdt, dt, Type, PageSize, conditionbox);
+            ms = DataTableToExcel1(firstsdt, dt, Type, FileName, PageSize, conditionbox);
             //以系统当前时间命名文件,FileMode.Create表示创建文件,FileAccess.Write表示拥有写的权限
             string filePath = @FolderPath + "\\" + FileName + ".xls";
             FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
@@ -228,10 +229,10 @@ namespace UAS_LabelMachine
             style.FillPattern = FillPattern.BigSpots;
             style.FillBackgroundColor = HSSFColor.LightGreen.Index;
             //设置边框
-            style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thick;
-            style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thick;
-            style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thick;
-            style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thick;
+            style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
+            style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
+            style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
+            style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
             row.HeightInPoints = 20;
             //固定第一行
             //row.RowStyle.IsLocked=true;
@@ -267,7 +268,7 @@ namespace UAS_LabelMachine
         /// </summary>
         /// <param name="DataTable"></param>
         /// <returns></returns>
-        public MemoryStream DataTableToExcel1(DataTable FirstDT, DataTable DataTable, string Type, int PageSize, List<CheckBox> conditionbox)
+        public MemoryStream DataTableToExcel1(DataTable FirstDT, DataTable DataTable, string Type,string Inoutno, int PageSize, List<CheckBox> conditionbox)
         {
             //转换为序列
             CheckBox[] box = conditionbox.ToArray();
@@ -278,17 +279,24 @@ namespace UAS_LabelMachine
             //Excel中的Sheet
             ISheet sheet = book.CreateSheet("分页");
 
+            //更新箱号
+            List<string> ch_code = new List<string>();
+            //系统打印箱号
+            List<string> pib_outboxcode1 = new List<string>();
+
+            int BoxCode = 1;
             ICellStyle style = book.CreateCellStyle();
             style.VerticalAlignment = VerticalAlignment.Center;
             style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
 
             ICellStyle styleborder = book.CreateCellStyle();
-            styleborder.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thick;
-            styleborder.BorderTop = NPOI.SS.UserModel.BorderStyle.Thick;
-            styleborder.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thick;
-            styleborder.BorderRight = NPOI.SS.UserModel.BorderStyle.Thick;
+            styleborder.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
+            styleborder.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
+            styleborder.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
+            styleborder.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
             styleborder.VerticalAlignment = VerticalAlignment.Center;
             styleborder.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
+            string pi_inoutno = "";
             //设置列的宽度,根据首行的列的内容的长度来设置
             for (int i = DataTable.Columns.Count - 1; i > 0; i--)
             {
@@ -375,13 +383,7 @@ namespace UAS_LabelMachine
             IRow row = sheet.CreateRow(0);
             //冻结第一行
             sheet.CreateFreezePane(0, 1, 0, 1);
-            //style.FillPattern = FillPattern.BigSpots;
-            //style.FillBackgroundColor = HSSFColor.LightGreen.Index;
-            //设置边框
-            //style.BorderBottom = BorderStyle.Thick;
-            //style.BorderLeft = BorderStyle.Thick;
-            //style.BorderRight = BorderStyle.Thick;
-            //style.BorderTop = BorderStyle.Thick;
+   
             row.HeightInPoints = 20;
             //固定第一行
             //row.RowStyle.IsLocked=true;
@@ -433,6 +435,7 @@ namespace UAS_LabelMachine
                             DataRow dr = FirstDT.NewRow();
                             dr["pr_spec"] = DataTable.Rows[i]["pr_spec"].ToString();
                             dr["pi_inoutno"] = DataTable.Rows[i]["pi_inoutno"].ToString();
+                            pi_inoutno = DataTable.Rows[i]["pi_inoutno"].ToString();
                             dr["pi_title"] = DataTable.Rows[i]["pi_title"].ToString();
                             dr["pi_date"] = DataTable.Rows[i]["pi_date"].ToString();
                             dr["pd_ordercode"] = First_OrderCode;
@@ -446,6 +449,7 @@ namespace UAS_LabelMachine
                             First_Prspec = "";
                             First_Batch = "";
                             First_WID.Clear();
+                            BoxCode = BoxCode + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
                                 if (j == 0)
@@ -640,6 +644,8 @@ namespace UAS_LabelMachine
                                 row1.Cells[j].CellStyle = style;
                             }
                         }
+                        ch_code.Add(DataTable.Rows[i]["ch_code"].ToString());
+                        pib_outboxcode1.Add(BoxCode.ToString());
                     }
                     for (int i = 0; i < sheet.LastRowNum; i++)
                     {
@@ -660,6 +666,7 @@ namespace UAS_LabelMachine
                         //如果批号不相等的时候
                         if (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["ch_splitbatch"].ToString())
                         {
+                            BoxCode = BoxCode + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
                                 if (j == 0)
@@ -830,6 +837,8 @@ namespace UAS_LabelMachine
                                 row1.Cells[j].CellStyle = style;
                             }
                         }
+                        ch_code.Add(DataTable.Rows[i]["ch_code"].ToString());
+                        pib_outboxcode1.Add(BoxCode.ToString());
                     }
                     for (int i = 0; i < sheet.LastRowNum; i++)
                     {
@@ -850,6 +859,7 @@ namespace UAS_LabelMachine
                         //如果批号不相等的时候
                         if (LastBoxCode != "" && LastBoxCode != DataTable.Rows[i]["CH_PBCODE"].ToString())
                         {
+                            BoxCode = BoxCode + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
                                 if (j == 0)
@@ -1031,6 +1041,8 @@ namespace UAS_LabelMachine
                                 row1.Cells[j].CellStyle = style;
                             }
                         }
+                        ch_code.Add(DataTable.Rows[i]["ch_code"].ToString());
+                        pib_outboxcode1.Add(BoxCode.ToString());
                     }
                     for (int i = 0; i < sheet.LastRowNum; i++)
                     {
@@ -1044,6 +1056,7 @@ namespace UAS_LabelMachine
                 default:
                     break;
             }
+            dh.BatchInsert("update prodiobarcode set pib_outboxcode1=:pib_outboxcode1 where pib_inoutno='"+ Inoutno + "' and pib_custbarcode=:pib_custbarcode",new string[] { "pib_outboxcode1", "pib_custbarcode" },pib_outboxcode1.ToArray(), ch_code.ToArray());
             //填充首页
             sumCount = 0;
             totalCount = 0;

+ 7 - 1
UAS-出货标签管理(贸易版)/UAS_出货标签管理.cs

@@ -1750,7 +1750,7 @@ namespace UAS_LabelMachine
                 sdh.BatchInsert("prodiobarcode", LabelInfDataTable);
             }
             sql.Clear();
-            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_id");
+            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by "+ (SystemInf.Master.Contains("SZSI")? "pib_custbarcode":"pib_id"));
             LabelInfDataTable = (DataTable)sdh.ExecuteSql(sql.ToString(), "select");
             bindingsource(LabelInf, LabelInfDataTable);
             //有数据的话默认取第一条的品牌去取采集策略
@@ -2383,6 +2383,7 @@ namespace UAS_LabelMachine
                     break;
                 case "导出数据":
                     ExportExcel ex = new ExportExcel(pi_inoutno.Text);
+                    ex.FormClosed += Ex_FormClosed;
                     switch (SystemInf.Master)
                     {
                         case "SZSI_TEST":
@@ -2486,6 +2487,11 @@ namespace UAS_LabelMachine
             }
         }
 
+        private void Ex_FormClosed(object sender, FormClosedEventArgs e)
+        {
+            LoadGridData(false);
+        }
+
         private void Att_FormClosed(object sender, FormClosedEventArgs e)
         {
             Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + cu_code.Text + "'", "select");