Browse Source

正常客户添加片提示

callm 5 years ago
parent
commit
50921878df
1 changed files with 159 additions and 107 deletions
  1. 159 107
      UAS-出货标签管理(贸易版)/PublicMethod/ExcelHandler.cs

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

@@ -483,9 +483,13 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j].SetCellValue("小计");
                                 }
-                                else if (DataTable.Columns[j].ColumnName == "io_qty")
+                                else if (j == 1)
                                 {
-                                    row1.Cells[NumIndex - 4].SetCellValue(sumCount);
+                                    row1.Cells[1].SetCellValue((i % PageSize == 0 ? PageSize : i) + "片");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.Cells[2].SetCellValue(sumCount);
                                 }
                                 row1.Cells[j].CellStyle = styleborder;
                             }
@@ -614,47 +618,51 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j].SetCellValue("小计");
                                 }
-                                else if (DataTable.Columns[j].ColumnName == "io_qty")
-                                {
-                                    row1.Cells[j - 4].SetCellValue(sumCount);
-                                }
-                                row1.Cells[j].CellStyle = styleborder;
-                            }
-                            row1 = sheet.CreateRow(PaintIndex);
-                            for (int j = 0; j < columnNum - 3; j++)
-                            {
-                                if (j == 0)
+                                else if (j == 1)
                                 {
-                                    row1.CreateCell(j);
-                                    row1.Cells[j].SetCellValue("备注");
+                                    row1.Cells[1].SetCellValue((i % PageSize == 0 ? PageSize : (i % PageSize + 1)) + "片");
                                 }
                                 else if (j == 2)
                                 {
-                                    row1.CreateCell(j);
-                                    row1.Cells[j].SetCellValue(totalCount);
-                                }
-                                //原本是j == columnNum - 5因为还有spec和order两列隐藏列,所以需要在往后移动
-                                else if (j == columnNum - 6)
-                                {
-                                    row1.CreateCell(j);
-                                    row1.Cells[j].SetCellValue(rowNum);
-                                }
-                                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("片");
-                                }
-                                else
-                                {
-                                    row1.CreateCell(j);
+                                    row1.Cells[2].SetCellValue(sumCount);
                                 }
-                                row1.Cells[j].CellStyle = style;
+                                row1.Cells[j].CellStyle = styleborder;
                             }
+                            row1 = sheet.CreateRow(PaintIndex);
+                            //for (int j = 0; j < columnNum - 3; j++)
+                            //{
+                            //    if (j == 0)
+                            //    {
+                            //        row1.CreateCell(j);
+                            //        row1.Cells[j].SetCellValue("备注");
+                            //    }
+                            //    else if (j == 2)
+                            //    {
+                            //        row1.CreateCell(j);
+                            //        row1.Cells[j].SetCellValue(totalCount);
+                            //    }
+                            //    //原本是j == columnNum - 5因为还有spec和order两列隐藏列,所以需要在往后移动
+                            //    else if (j == columnNum - 6)
+                            //    {
+                            //        row1.CreateCell(j);
+                            //        row1.Cells[j].SetCellValue(rowNum);
+                            //    }
+                            //    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("片");
+                            //    }
+                            //    else
+                            //    {
+                            //        row1.CreateCell(j);
+                            //    }
+                            //    row1.Cells[j].CellStyle = style;
+                            //}
                             sheet.SetRowBreak(PaintIndex);
                             sheet.Footer.Center = "第&P页,共&N页";
                             PaintIndex = PaintIndex + 1;
@@ -673,12 +681,14 @@ namespace UAS_LabelMachine
                     break;
                 case "BatchCode":
                     string LastBatchCode = "";
+                    int PageNum = 0;
                     for (int i = 0; i < rowNum; i++)
                     {
                         IRow row1 = sheet.CreateRow(PaintIndex);
                         PaintIndex = PaintIndex + 1;
                         row1.HeightInPoints = RowHeight;
                         //如果批号不相等的时候
+                        PageNum = PageNum + 1;
                         if (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["ch_splitbatch"].ToString())
                         {
                             BoxCode = BoxCode + 1;
@@ -688,18 +698,28 @@ namespace UAS_LabelMachine
                                 if (j == 0)
                                 {
                                     row1.Cells[j].SetCellValue("小计");
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
-                                else if (DataTable.Columns[j].ColumnName == "io_qty")
+                                else if (j == 1)
                                 {
-                                    row1.Cells[j - 4].SetCellValue(sumCount);
+                                    row1.Cells[1].SetCellValue(PageNum - 1 + "片");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.Cells[2].SetCellValue(sumCount);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else
+                                {
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
-                                row1.Cells[j].CellStyle = styleborder;
                             }
                             sumCount = 0;
                             row1 = sheet.CreateRow(PaintIndex);
                             sheet.SetRowBreak(PaintIndex - 1);
                             sheet.Footer.Center = "第&P页,共&N页";
                             PaintIndex = PaintIndex + 1;
+                            PageNum = 1;
                         }
                         //每次到了页数开始分页
                         if (LastBatchCode == "" || (LastBatchCode != "" && LastBatchCode != DataTable.Rows[i]["ch_splitbatch"].ToString()) || i == rowNum - 1)
@@ -800,51 +820,61 @@ namespace UAS_LabelMachine
                                 if (j == 0)
                                 {
                                     row1.Cells[j].SetCellValue("小计");
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
-                                else if (DataTable.Columns[j].ColumnName == "io_qty")
-                                {
-                                    row1.Cells[j - 4].SetCellValue(sumCount);
-                                }
-                                row1.Cells[j].CellStyle = styleborder;
-                            }
-                            //创建备注内容
-                            row1 = sheet.CreateRow(PaintIndex);
-                            for (int j = 0; j < columnNum - 3; j++)
-                            {
-                                if (j == 0)
+                                else if (j == 1)
                                 {
-                                    row1.CreateCell(j);
-                                    row1.Cells[j].SetCellValue("备注");
+                                    row1.Cells[1].SetCellValue(PageNum + "片");
                                 }
                                 else if (j == 2)
                                 {
-                                    row1.CreateCell(j);
-                                    row1.Cells[j].SetCellValue(totalCount);
-                                }
-                                else if (j == columnNum - 6)
-                                {
-                                    row1.CreateCell(j);
-                                    row1.Cells[j].SetCellValue(rowNum);
-                                }
-                                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("片");
+                                    row1.Cells[2].SetCellValue(sumCount);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else
                                 {
-                                    row1.CreateCell(j);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
-                                row1.Cells[j].CellStyle = style;
                             }
+                            //创建备注内容
+                            row1 = sheet.CreateRow(PaintIndex);
+                            //for (int j = 0; j < columnNum - 3; j++)
+                            //{
+                            //    if (j == 0)
+                            //    {
+                            //        row1.CreateCell(j);
+                            //        row1.Cells[j].SetCellValue("备注");
+                            //    }
+                            //    else if (j == 2)
+                            //    {
+                            //        row1.CreateCell(j);
+                            //        row1.Cells[j].SetCellValue(totalCount);
+                            //    }
+                            //    else if (j == columnNum - 6)
+                            //    {
+                            //        row1.CreateCell(j);
+                            //        row1.Cells[j].SetCellValue(rowNum);
+                            //    }
+                            //    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("片");
+                            //    }
+                            //    else
+                            //    {
+                            //        row1.CreateCell(j);
+                            //    }
+                            //    row1.Cells[j].CellStyle = style;
+                            //}
                             sheet.SetRowBreak(PaintIndex);
                             sheet.Footer.Center = "第&P页,共&N页";
                             PaintIndex = PaintIndex + 1;
+                            PageNum = 1;
                         }
                         pib_id.Add(DataTable.Rows[i]["pib_id"].ToString());
                         pib_outboxcode1.Add(BoxCode.ToString());
@@ -860,11 +890,14 @@ namespace UAS_LabelMachine
                     break;
                 case "BoxCode":
                     string LastBoxCode = "";
+                    int PageNum1 = 0;
+
                     for (int i = 0; i < rowNum; i++)
                     {
                         IRow row1 = sheet.CreateRow(PaintIndex);
                         PaintIndex = PaintIndex + 1;
                         row1.HeightInPoints = RowHeight;
+                        PageNum1 = PageNum1 + 1;
                         //如果批号不相等的时候
                         if (LastBoxCode != "" && LastBoxCode != DataTable.Rows[i]["CH_PBCODE"].ToString())
                         {
@@ -875,12 +908,21 @@ namespace UAS_LabelMachine
                                 if (j == 0)
                                 {
                                     row1.Cells[j].SetCellValue("小计");
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
-                                else if (DataTable.Columns[j].ColumnName == "io_qty")
+                                else if (j == 1)
                                 {
-                                    row1.Cells[j - 4].SetCellValue(sumCount);
+                                    row1.Cells[1].SetCellValue(PageNum1 + "片");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.Cells[2].SetCellValue(sumCount);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else
+                                {
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
-                                row1.Cells[j].CellStyle = styleborder;
                             }
                             sumCount = 0;
                             row1 = sheet.CreateRow(PaintIndex);
@@ -988,51 +1030,61 @@ namespace UAS_LabelMachine
                                 if (j == 0)
                                 {
                                     row1.Cells[j].SetCellValue("小计");
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
-                                else if (DataTable.Columns[j].ColumnName == "io_qty")
-                                {
-                                    row1.Cells[j - 4].SetCellValue(sumCount);
-                                }
-                                row1.Cells[j].CellStyle = styleborder;
-                            }
-                            row1 = sheet.CreateRow(PaintIndex);
-
-                            for (int j = 0; j < columnNum - 3; j++)
-                            {
-                                if (j == 0)
+                                else if (j == 1)
                                 {
-                                    row1.CreateCell(j);
-                                    row1.Cells[j].SetCellValue("备注");
+                                    row1.Cells[1].SetCellValue(PageNum1 + "片");
                                 }
                                 else if (j == 2)
                                 {
-                                    row1.CreateCell(j);
-                                    row1.Cells[j].SetCellValue(totalCount);
-                                }
-                                else if (j == columnNum - 6)
-                                {
-                                    row1.CreateCell(j);
-                                    row1.Cells[j].SetCellValue(rowNum);
-                                }
-                                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("片");
+                                    row1.Cells[2].SetCellValue(sumCount);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else
                                 {
-                                    row1.CreateCell(j);
+                                    row1.Cells[j].CellStyle = styleborder;
                                 }
-                                row1.Cells[j].CellStyle = style;
                             }
+                            row1 = sheet.CreateRow(PaintIndex);
+
+                            //for (int j = 0; j < columnNum - 3; j++)
+                            //{
+                            //    if (j == 0)
+                            //    {
+                            //        row1.CreateCell(j);
+                            //        row1.Cells[j].SetCellValue("备注");
+                            //    }
+                            //    else if (j == 2)
+                            //    {
+                            //        row1.CreateCell(j);
+                            //        row1.Cells[j].SetCellValue(totalCount);
+                            //    }
+                            //    else if (j == columnNum - 6)
+                            //    {
+                            //        row1.CreateCell(j);
+                            //        row1.Cells[j].SetCellValue(rowNum);
+                            //    }
+                            //    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("片");
+                            //    }
+                            //    else
+                            //    {
+                            //        row1.CreateCell(j);
+                            //    }
+                            //    row1.Cells[j].CellStyle = style;
+                            //}
                             sheet.SetRowBreak(PaintIndex);
                             sheet.Footer.Center = "第&P页,共&N页";
                             PaintIndex = PaintIndex + 1;
+                            PageNum1 = 1;
                         }
                         pib_id.Add(DataTable.Rows[i]["pib_id"].ToString());
                         pib_outboxcode1.Add(BoxCode.ToString());