瀏覽代碼

调整了总结行的数据

章政 6 年之前
父節點
當前提交
ddb1b23195

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

@@ -27,6 +27,7 @@ namespace UAS_LabelMachine
         {
             ExportFileDialog.Description = "选择导出的路径";
             DialogResult result = ExportFileDialog.ShowDialog();
+            string custcode = dh.getFieldDataByCondition("prodinout", "pi_cardcode", "pi_inoutno='" + inoutno + "'").ToString();
             if (result == DialogResult.OK)
             {
                 StringBuilder sql = new StringBuilder();
@@ -66,7 +67,12 @@ namespace UAS_LabelMachine
                 {
                     SplitType = BoxCode.Name;
                 }
-                DataTable SQL1_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='DataPage' and es_enable=-1 order by es_detno", "select");
+                DataTable SQL1_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='DataPage' and es_enable=-1 and es_custcode='" + custcode + "' order by es_detno", "select");
+                //没有置顶客户的取空的
+                if (SQL1_.Rows.Count == 0)
+                {
+                    SQL1_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='DataPage' and es_enable=-1 and es_custcode is null order by es_detno", "select");
+                }
                 string es_field1 = "";
                 for (int i = 0; i < SQL1_.Rows.Count; i++)
                 {
@@ -74,7 +80,7 @@ namespace UAS_LabelMachine
                 }
                 //分页信息的DataTable
                 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("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");
                 DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
@@ -89,7 +95,11 @@ namespace UAS_LabelMachine
                 }
 
                 //获取首页需要展示的字段
-                DataTable SQL_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='First' and es_enable=-1 order by es_detno", "select");
+                DataTable SQL_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='First' and es_enable=-1 and es_custcode='" + custcode + "' order by es_detno", "select");
+                if (SQL_.Rows.Count == 0)
+                {
+                    SQL_ = (DataTable)dh.ExecuteSql("select es_filed,es_caption,es_prefix,es_suffix,es_filed1 from CS_EXPORTSETTING where es_type='First' and es_enable=-1 and es_custcode is null order by es_detno", "select");
+                }
                 string es_field = "";
                 for (int i = 0; i < SQL_.Rows.Count; i++)
                 {

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

@@ -56,8 +56,6 @@ namespace UAS_LabelMachine
             return filePath;
         }
 
-
-
         /// <summary>
         /// 导入Excel
         /// </summary>
@@ -188,7 +186,6 @@ namespace UAS_LabelMachine
             }
         }
 
-
         /// <summary>
         /// 将DataTable形式的数据转成Excel格式的,然后用字节流的形式写入文件
         /// </summary>
@@ -265,7 +262,6 @@ namespace UAS_LabelMachine
             return ms;
         }
 
-
         /// <summary>
         /// 将DataTable形式的数据转成Excel格式的,然后用字节流的形式写入文件
         /// </summary>
@@ -281,7 +277,6 @@ namespace UAS_LabelMachine
             HSSFWorkbook book = new HSSFWorkbook();
             //Excel中的Sheet
             ISheet sheet = book.CreateSheet("分页");
-         
 
             ICellStyle style = book.CreateCellStyle();
             style.VerticalAlignment = VerticalAlignment.Center;
@@ -303,7 +298,6 @@ namespace UAS_LabelMachine
                     {
                         if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_bluefilm"))
                         {
-                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
                             DataTable.Columns.RemoveAt(i);
                             break;
                         }
@@ -312,7 +306,6 @@ namespace UAS_LabelMachine
                     {
                         if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_code"))
                         {
-                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
                             DataTable.Columns.RemoveAt(i);
                             break;
                         }
@@ -321,7 +314,6 @@ namespace UAS_LabelMachine
                     {
                         if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_splitbatch"))
                         {
-                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
                             DataTable.Columns.RemoveAt(i);
                             break;
                         }
@@ -330,7 +322,6 @@ namespace UAS_LabelMachine
                     {
                         if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_waterid"))
                         {
-                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
                             DataTable.Columns.RemoveAt(i);
                             break;
                         }
@@ -339,7 +330,6 @@ namespace UAS_LabelMachine
                     {
                         if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_pbcode"))
                         {
-                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
                             DataTable.Columns.RemoveAt(i);
                             break;
                         }
@@ -348,7 +338,6 @@ namespace UAS_LabelMachine
                     {
                         if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_remark"))
                         {
-                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
                             DataTable.Columns.RemoveAt(i);
                             break;
                         }
@@ -357,7 +346,6 @@ namespace UAS_LabelMachine
                     {
                         if (DataTable.Columns[i].ColumnName.ToLower().Contains("chw_percent1") || DataTable.Columns[i].ColumnName.ToLower().Contains("chw_percent2") || DataTable.Columns[i].ColumnName.ToLower().Contains("chw_itemname1") || DataTable.Columns[i].ColumnName.ToLower().Contains("chw_itemname2"))
                         {
-                            Console.WriteLine(DataTable.Columns[i].ColumnName.ToLower());
                             DataTable.Columns.RemoveAt(i);
                             break;
                         }
@@ -372,7 +360,7 @@ namespace UAS_LabelMachine
                     }
                     if (box[j].Name.ToLower() == "bvceo" && !box[j].Checked)
                     {
-                        if (DataTable.Columns[i].ColumnName.ToLower()=="bvceo1" || DataTable.Columns[i].ColumnName.ToLower() == ("bvceo2") || DataTable.Columns[i].ColumnName.ToLower() == ("bvceo3"))
+                        if (DataTable.Columns[i].ColumnName.ToLower() == "bvceo1" || DataTable.Columns[i].ColumnName.ToLower() == ("bvceo2") || DataTable.Columns[i].ColumnName.ToLower() == ("bvceo3"))
                         {
                             DataTable.Columns.RemoveAt(i);
                             break;
@@ -493,7 +481,12 @@ namespace UAS_LabelMachine
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_title"].ToString());
                                     }
-                                    else if (j == columnNum - 4)
+                                    else if (j > 5 && j == columnNum - 5)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_inoutno"].ToString());
+                                    }
+                                    else if (columnNum > 5 && j == columnNum - 5)
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_inoutno"].ToString());
@@ -514,7 +507,12 @@ namespace UAS_LabelMachine
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Rows[i]["pr_spec"].ToString());
                                     }
-                                    else if (j == columnNum - 4)
+                                    else if (columnNum > 5 && j == columnNum - 5)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_date"].ToString());
+                                    }
+                                    else if (columnNum<=5&&j == columnNum - 4)
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_date"].ToString());
@@ -620,12 +618,17 @@ namespace UAS_LabelMachine
                                     row1.Cells[j].SetCellValue(totalCount);
                                 }
                                 //原本是j == columnNum - 5因为还有spec和order两列隐藏列,所以需要在往后移动
-                                else if (j == columnNum - 7)
+                                else if (j == columnNum - 6)
                                 {
                                     row1.CreateCell(j);
                                     row1.Cells[j].SetCellValue(rowNum);
                                 }
-                                else if (j == columnNum - 4)
+                                else if (j > 5 && j == columnNum - 5)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("片");
+                                }
+                                else if (columnNum > 5 && j == columnNum - 5)
                                 {
                                     row1.CreateCell(j);
                                     row1.Cells[j].SetCellValue("片");
@@ -790,7 +793,7 @@ namespace UAS_LabelMachine
                                 }
                                 row1.Cells[j].CellStyle = styleborder;
                             }
-
+                            //创建备注内容
                             row1 = sheet.CreateRow(PaintIndex);
                             PaintIndex = PaintIndex + 1;
                             for (int j = 0; j < columnNum - 3; j++)
@@ -805,12 +808,17 @@ namespace UAS_LabelMachine
                                     row1.CreateCell(j);
                                     row1.Cells[j].SetCellValue(totalCount);
                                 }
-                                else if (j == columnNum - 7)
+                                else if (j == columnNum - 6)
                                 {
                                     row1.CreateCell(j);
                                     row1.Cells[j].SetCellValue(rowNum);
                                 }
-                                else if (j == columnNum - 4)
+                                else if (j > 5 && j == columnNum - 5)
+                                {
+                                    row1.CreateCell(j);
+                                    row1.Cells[j].SetCellValue("片");
+                                }
+                                else if (columnNum > 5 && j == columnNum - 5)
                                 {
                                     row1.CreateCell(j);
                                     row1.Cells[j].SetCellValue("片");
@@ -879,7 +887,12 @@ namespace UAS_LabelMachine
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_title"].ToString());
                                     }
-                                    else if (j == columnNum - 4)
+                                    else if (j > 5 && j == columnNum - 5)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_inoutno"].ToString());
+                                    }
+                                    else if (columnNum > 5 && j == columnNum - 5)
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_inoutno"].ToString());
@@ -900,7 +913,12 @@ namespace UAS_LabelMachine
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Rows[i]["pr_spec"].ToString());
                                     }
-                                    else if (j == columnNum - 4)
+                                    else if (j > 5 && j == columnNum - 5)
+                                    {
+                                        row1.CreateCell(j);
+                                        row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_date"].ToString());
+                                    }
+                                    else if (columnNum > 5 && j == columnNum - 5)
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_date"].ToString());
@@ -1033,7 +1051,6 @@ namespace UAS_LabelMachine
             row.GetCell(0).CellStyle = style;
             rowNum = FirstDT.Rows.Count;
             //不需要显示的列移除
-
             for (int i = FirstDT.Columns.Count - 1; i > 0; i--)
             {
                 for (int j = 0; j < box.Length; j++)
@@ -1041,19 +1058,18 @@ namespace UAS_LabelMachine
                     if (box[j].Name == "FirstPage_WID" && !box[j].Checked)
                     {
                         if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_waterid"))
-
                         {
                             FirstDT.Columns.RemoveAt(i);
                         }
                     }
-                    if (box[j].Name == "FirstPage_YIELD")
+                    if (box[j].Name == "FirstPage_YIELD" && !box[j].Checked)
                     {
                         if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_yeild"))
                         {
                             FirstDT.Columns.RemoveAt(i);
                         }
                     }
-                    if (box[j].Name == "FirstPage_REMARK")
+                    if (box[j].Name == "FirstPage_REMARK" && !box[j].Checked)
                     {
                         if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_remark"))
                         {
@@ -1064,34 +1080,6 @@ namespace UAS_LabelMachine
             }
             columnNum = FirstDT.Columns.Count;
 
-            //for (int i = 0; i < columnNum; i++)
-            //{
-            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("pd_ordercode"))
-            //    {
-            //        FirstDT.Columns[i].ColumnName = "订单号";
-            //    }
-            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("pr_spec"))
-            //    {
-            //        FirstDT.Columns[i].ColumnName = "产品型号";
-            //    }
-            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_splitbatch"))
-            //    {
-            //        FirstDT.Columns[i].ColumnName = "批号";
-            //    }
-            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("ch_waterid"))
-            //    {
-            //        FirstDT.Columns[i].ColumnName = "片号";
-            //    }
-            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("num"))
-            //    {
-            //        FirstDT.Columns[i].ColumnName = "片数";
-            //    }
-            //    if (FirstDT.Columns[i].ColumnName.ToLower().Contains("io_qty"))
-            //    {
-            //        FirstDT.Columns[i].ColumnName = "管芯数";
-            //    }
-            //}
-
             for (int i = 0; i < rowNum; i++)
             {
                 IRow row1 = sheet2.CreateRow(PaintIndex);
@@ -1107,10 +1095,15 @@ namespace UAS_LabelMachine
                             row1.CreateCell(j);
                             row1.Cells[j].SetCellValue(FirstDT.Rows[i]["pi_title"].ToString());
                         }
-                        else if (j == columnNum - 4)
+                        else if (j > 5 && j == columnNum - 5)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["pi_inoutno"].ToString());
+                            row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_inoutno"].ToString());
+                        }
+                        else if (columnNum > 5 && j == columnNum - 5)
+                        {
+                            row1.CreateCell(j);
+                            row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_inoutno"].ToString());
                         }
                         else
                         {
@@ -1128,10 +1121,15 @@ namespace UAS_LabelMachine
                             row1.CreateCell(j);
                             row1.Cells[j].SetCellValue(FirstDT.Rows[i]["pr_spec"].ToString());
                         }
-                        else if (j == columnNum - 4)
+                        else if (j > 5 && j == columnNum - 5)
+                        {
+                            row1.CreateCell(j);
+                            row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_date"].ToString());
+                        }
+                        else if (columnNum > 5 && j == columnNum - 5)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Rows[i]["pi_date"].ToString());
+                            row1.Cells[j].SetCellValue(DataTable.Rows[i]["pi_date"].ToString());
                         }
                         else
                         {