callm 5 жил өмнө
parent
commit
311a5e78b3

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

@@ -53,11 +53,11 @@ namespace UAS_LabelMachine
                     MessageBox.Show("勾选盒号分页,打印内容请勾选盒号");
                     return;
                 }
-                if (!CH_SPLITBATCH.Checked && BatchCode.Checked)
-                {
-                    MessageBox.Show("勾选扩撒批分页,打印内容请勾选扩撒批号");
-                    return;
-                }
+                //if (!CH_SPLITBATCH.Checked && BatchCode.Checked)
+                //{
+                //    MessageBox.Show("勾选扩撒批分页,打印内容请勾选扩撒批号");
+                //    return;
+                //}
                 if ((!CH_SPLITBATCH.Checked || !CH_PBCODE.Checked) && BoxSplit.Checked)
                 {
                     MessageBox.Show("勾选盒号拆批,打印内容请勾选扩撒批号和盒号");

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

@@ -426,6 +426,8 @@ namespace UAS_LabelMachine
             NotShowColumn.Add("pi_date");
 
             int ShowColumnCount = 0;
+
+            bool ShowSplitBatch = true;
             //展示的内容列
             //设置列的宽度,根据首行的列的内容的长度来设置
             for (int i = DataTable.Columns.Count - 1; i > 0; i--)
@@ -450,11 +452,7 @@ namespace UAS_LabelMachine
                     }
                     if (box[j].Name.ToLower() == "ch_splitbatch" && !box[j].Checked)
                     {
-                        if (DataTable.Columns[i].ColumnName.ToLower().Contains("ch_splitbatch"))
-                        {
-                            DataTable.Columns.RemoveAt(i);
-                            break;
-                        }
+                        ShowSplitBatch = false;
                     }
                     if (box[j].Name.ToLower() == "ch_waterid" && !box[j].Checked)
                     {
@@ -843,7 +841,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum - 1);
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
@@ -863,8 +861,10 @@ namespace UAS_LabelMachine
                             PaintIndex = PaintIndex + 1;
                             PageNum = 0;
                         }
+                        int SplitBatchIndex = 0;
+
                         //每次到了页数开始分页
-                        if (LastBatchCode == "" || (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["ch_splitbatch"].ToString()) || i == rowNum - 1)
+                        if (LastBatchCode == "" || (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["ch_splitbatch"].ToString()) || (i == rowNum - 1 && (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["ch_splitbatch"].ToString())))
                         {
                             LastBatchCode = DataTable.Rows[i]["ch_splitbatch"].ToString();
                             //第一行添加客户信息
@@ -912,8 +912,13 @@ namespace UAS_LabelMachine
                                 row1 = sheet.CreateRow(PaintIndex);
                                 PaintIndex = PaintIndex + 1;
                                 int showcount = 0;
+
                                 for (int j = 4; j < columnNum; j++)
                                 {
+                                    if (DataTable.Columns[j].ColumnName.ToLower() == "ch_splitbatch")
+                                    {
+                                        SplitBatchIndex = j - 4;
+                                    }
                                     if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
                                     {
                                         showcount = showcount + 1;
@@ -969,6 +974,10 @@ namespace UAS_LabelMachine
                                         }
                                     }
                                 }
+                                //不展示扩散批
+                                if (!ShowSplitBatch)
+                                    sheet.SetColumnWidth(SplitBatchIndex, 0);
+
                                 ShowColumnCount = showcount;
                                 row1 = sheet.CreateRow(PaintIndex);
                                 PaintIndex = PaintIndex + 1;
@@ -1019,6 +1028,7 @@ namespace UAS_LabelMachine
                         }
                         if (i == rowNum - 1)
                         {
+                            PageNum = PageNum + 1;
                             row1 = sheet.CreateRow(PaintIndex);
                             PaintIndex = PaintIndex + 1;
                             for (int j = 0; j < ShowColumnCount; j++)
@@ -1036,8 +1046,16 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowCountIndex)
                                 {
-                                    row1.Cells[j].SetCellValue(sumCount);
-                                    row1.Cells[j].CellStyle = styleborder;
+                                    if (ShowCountIndex == SplitBatchIndex)
+                                    {
+                                        row1.Cells[j+1].SetCellValue(sumCount);
+                                        row1.Cells[j+1].CellStyle = styleborder;
+                                    }
+                                    else {
+                                        row1.Cells[j].SetCellValue(sumCount);
+                                        row1.Cells[j].CellStyle = styleborder;
+                                    }
+                             
                                 }
                                 else
                                 {
@@ -1183,9 +1201,11 @@ namespace UAS_LabelMachine
                                 row1 = sheet.CreateRow(PaintIndex);
                                 PaintIndex = PaintIndex + 1;
                                 int showcount = 0;
+                          
                                 for (int j = 4; j < columnNum; j++)
                                 {
-                                    if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
+                                  
+                                        if (DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1")
                                     {
                                         showcount = showcount + 1;
                                         row1.CreateCell(j - 4);
@@ -1240,6 +1260,8 @@ namespace UAS_LabelMachine
                                         }
                                     }
                                 }
+                              
+
                                 ShowColumnCount = showcount;
                                 row1 = sheet.CreateRow(PaintIndex);
                                 PaintIndex = PaintIndex + 1;