Browse Source

无边框BUG调整

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

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

@@ -549,6 +549,10 @@ namespace UAS_LabelMachine
                         if (i / PageSize >= 1 && i % PageSize == 0)
                         {
                             DataRow dr = FirstDT.NewRow();
+                            dr["me_desc"] = DataTable.Rows[i]["me_desc"].ToString();
+                            dr["pr_size"] = DataTable.Rows[i]["pr_size"].ToString();
+                            dr["pi_chipouttype"] = DataTable.Rows[i]["pi_chipouttype"].ToString();
+                            dr["ch_level"] = DataTable.Rows[i]["ch_level"].ToString();
                             dr["pr_orispeccode"] = DataTable.Rows[i]["pr_orispeccode"].ToString();
                             dr["pi_inoutno"] = DataTable.Rows[i]["pi_inoutno"].ToString();
                             pi_inoutno = DataTable.Rows[i]["pi_inoutno"].ToString();
@@ -575,7 +579,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue((i % PageSize == 0 ? PageSize : i) + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue((i % PageSize == 0 ? PageSize : i));
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
@@ -707,6 +711,7 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j - 4].SetCellValue(Data);
                                 }
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -728,6 +733,10 @@ namespace UAS_LabelMachine
                         if (i == rowNum - 1)
                         {
                             DataRow dr = FirstDT.NewRow();
+                            dr["me_desc"] = DataTable.Rows[i]["me_desc"].ToString();
+                            dr["pr_size"] = DataTable.Rows[i]["pr_size"].ToString();
+                            dr["pi_chipouttype"] = DataTable.Rows[i]["pi_chipouttype"].ToString();
+                            dr["ch_level"] = DataTable.Rows[i]["ch_level"].ToString();
                             dr["pr_orispeccode"] = DataTable.Rows[i]["pr_orispeccode"].ToString();
                             dr["pi_inoutno"] = DataTable.Rows[i]["pi_inoutno"].ToString();
                             dr["pi_title"] = DataTable.Rows[i]["pi_title"].ToString();
@@ -750,7 +759,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue((rowNum % PageSize == 0 ? PageSize : (rowNum % PageSize)) + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue((rowNum % PageSize == 0 ? PageSize : (rowNum % PageSize)));
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
@@ -814,7 +823,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum - 1 + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum - 1);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
@@ -951,6 +960,8 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j - 4].SetCellValue(Data);
                                 }
+                                row1.Cells[j - 4].CellStyle = styleborder;
+
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -982,7 +993,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
@@ -1065,7 +1076,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum1 + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum1);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
@@ -1202,6 +1213,7 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j - 4].SetCellValue(Data);
                                 }
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -1234,7 +1246,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum1 + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum1);
                                     row1.Cells[j].CellStyle = styleborder;
                                 }
                                 else if (j == ShowCountIndex)
@@ -1387,7 +1399,7 @@ namespace UAS_LabelMachine
                         else if (j == ShowSizeIndex)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
+                            row1.Cells[j].SetCellValue(FirstDT.Columns["pr_size"].Caption + ":" + FirstDT.Rows[i]["pr_size"].ToString());
                         }
                         else if (j > 5 && j == columnNum - 5)
                         {
@@ -1429,7 +1441,6 @@ namespace UAS_LabelMachine
                 for (int j = 4; j < columnNum; j++)
                 {
                     row1.CreateCell(j - 4);
-
                     if (!NotShowColumn.Contains(FirstDT.Columns[j].ColumnName.ToLower()))
                     {
                         string Data = FirstDT.Rows[i][j].ToString();
@@ -1465,13 +1476,13 @@ namespace UAS_LabelMachine
                             row1.Cells[j].CellStyle = styleborder;
                             row1.Cells[j].SetCellValue(总计);
                         }
-                        else if (j == ShowColumnCount-2)
+                        else if (j == ShowColumnCount - 2)
                         {
                             row1.CreateCell(j);
                             row1.Cells[j].CellStyle = styleborder;
                             row1.Cells[j].SetCellValue(sumCount);
                         }
-                        else if (j == ShowColumnCount-1)
+                        else if (j == ShowColumnCount - 1)
                         {
                             row1.CreateCell(j);
                             row1.Cells[j].CellStyle = styleborder;
@@ -1717,6 +1728,10 @@ namespace UAS_LabelMachine
                         if (i / PageSize >= 1 && i % PageSize == 0)
                         {
                             DataRow dr = FirstDT.NewRow();
+                            dr["me_desc"] = DataTable.Rows[i]["me_desc"].ToString();
+                            dr["pr_size"] = DataTable.Rows[i]["pr_size"].ToString();
+                            dr["pi_chipouttype"] = DataTable.Rows[i]["pi_chipouttype"].ToString();
+                            dr["ch_level"] = DataTable.Rows[i]["ch_level"].ToString();
                             dr["pr_orispeccode"] = DataTable.Rows[i]["pr_orispeccode"].ToString();
                             dr["pi_inoutno"] = DataTable.Rows[i]["pi_inoutno"].ToString();
                             pi_inoutno = DataTable.Rows[i]["pi_inoutno"].ToString();
@@ -1743,7 +1758,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue((i % PageSize == 0 ? PageSize : i) + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue((i % PageSize == 0 ? PageSize : i));
                                     row1.Cells[1].CellStyle = ColumnTitleStyle;
                                 }
                                 else if (j == ShowCountIndex)
@@ -1893,6 +1908,7 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j - 4].SetCellValue(Data);
                                 }
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -1909,11 +1925,16 @@ namespace UAS_LabelMachine
                                 sheet.AutoSizeColumn(j - 4);
                                 sheet.SetColumnWidth(j - 4, sheet.GetColumnWidth(j - 4) + 1000);
                             }
+                            row1.Cells[j - 4].CellStyle = styleborder;
                         }
                         //固定行号分组的时候自动拼接新的DataTable
                         if (i == rowNum - 1)
                         {
                             DataRow dr = FirstDT.NewRow();
+                            dr["me_desc"] = DataTable.Rows[i]["me_desc"].ToString();
+                            dr["pr_size"] = DataTable.Rows[i]["pr_size"].ToString();
+                            dr["pi_chipouttype"] = DataTable.Rows[i]["pi_chipouttype"].ToString();
+                            dr["ch_level"] = DataTable.Rows[i]["ch_level"].ToString();
                             dr["pr_orispeccode"] = DataTable.Rows[i]["pr_orispeccode"].ToString();
                             dr["pi_inoutno"] = DataTable.Rows[i]["pi_inoutno"].ToString();
                             dr["pi_title"] = DataTable.Rows[i]["pi_title"].ToString();
@@ -1999,7 +2020,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum);
                                     row1.Cells[1].CellStyle = ColumnTitleStyle;
                                 }
                                 else if (j == ShowCountIndex)
@@ -2152,6 +2173,7 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j - 4].SetCellValue(Data);
                                 }
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -2168,6 +2190,7 @@ namespace UAS_LabelMachine
                                 sheet.AutoSizeColumn(j - 4);
                                 sheet.SetColumnWidth(j - 4, sheet.GetColumnWidth(j - 4) + 1000);
                             }
+                            row1.Cells[j - 4].CellStyle = styleborder;
                         }
                         if (i == rowNum - 1)
                         {
@@ -2253,7 +2276,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum1 + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum1);
                                     row1.Cells[1].CellStyle = ColumnTitleStyle;
                                 }
                                 else if (j == ShowCountIndex)
@@ -2407,6 +2430,7 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j - 4].SetCellValue(Data);
                                 }
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -2423,6 +2447,7 @@ namespace UAS_LabelMachine
                                 sheet.AutoSizeColumn(j - 4);
                                 sheet.SetColumnWidth(j - 4, sheet.GetColumnWidth(j - 4) + 1000);
                             }
+                            row1.Cells[j - 4].CellStyle = styleborder;
                         }
                         if (i == rowNum - 1)
                         {
@@ -2439,7 +2464,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == ShowPieceIndex)
                                 {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum1 + 片);
+                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum1);
                                     row1.Cells[1].CellStyle = ColumnTitleStyle;
                                 }
                                 else if (j == ShowCountIndex)
@@ -2576,13 +2601,13 @@ namespace UAS_LabelMachine
                     {
                         if (j == 0)
                         {
-                                 row1.CreateCell(j).SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + " "
-                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ")" + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
+                            row1.CreateCell(j).SetCellValue(DataTable.Columns["pr_orispeccode"].Caption + ":" + DataTable.Rows[i]["pr_orispeccode"].ToString() + " "
+                             + "(" + DataTable.Rows[i]["me_desc"].ToString() + ")" + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
                         }
                         else if (j == ShowSizeIndex)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
+                            row1.Cells[j].SetCellValue(FirstDT.Columns["pr_size"].Caption + ":" + FirstDT.Rows[i]["pr_size"].ToString());
                         }
                         else if (j > 5 && j == columnNum - 5)
                         {
@@ -2608,7 +2633,7 @@ namespace UAS_LabelMachine
                         row1.CreateCell(j - 4);
                         if (NotShowColumn.Contains(FirstDT.Columns[j].ColumnName.ToLower()))
                         {
-                         
+
                         }
                         else
                         {
@@ -2642,7 +2667,8 @@ namespace UAS_LabelMachine
                         }
                         ShowColumnCount = ShowColumnCount + 1;
                     }
-                    else {
+                    else
+                    {
 
                     }
                 }
@@ -2909,6 +2935,10 @@ namespace UAS_LabelMachine
                         if (i / PageSize >= 1 && i % PageSize == 0)
                         {
                             DataRow dr = FirstDT.NewRow();
+                            dr["me_desc"] = DataTable.Rows[i]["me_desc"].ToString();
+                            dr["pr_size"] = DataTable.Rows[i]["pr_size"].ToString();
+                            dr["pi_chipouttype"] = DataTable.Rows[i]["pi_chipouttype"].ToString();
+                            dr["ch_level"] = DataTable.Rows[i]["ch_level"].ToString();
                             dr["pr_orispeccode"] = DataTable.Rows[i]["pr_orispeccode"].ToString();
                             dr["pi_inoutno"] = DataTable.Rows[i]["pi_inoutno"].ToString();
                             pi_inoutno = DataTable.Rows[i]["pi_inoutno"].ToString();
@@ -3115,10 +3145,12 @@ namespace UAS_LabelMachine
                                 row1.Cells[j - 4].SetCellValue(int.Parse(Data));
                                 sumCount += int.Parse(DataTable.Rows[i][j].ToString());
                                 totalCount += int.Parse(DataTable.Rows[i][j].ToString());
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "rownum")
                             {
                                 row1.Cells[j - 4].SetCellValue(i + 1);
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "ch_code")
                             {
@@ -3134,6 +3166,10 @@ namespace UAS_LabelMachine
                         if (i == rowNum - 1)
                         {
                             DataRow dr = FirstDT.NewRow();
+                            dr["me_desc"] = DataTable.Rows[i]["me_desc"].ToString();
+                            dr["pr_size"] = DataTable.Rows[i]["pr_size"].ToString();
+                            dr["pi_chipouttype"] = DataTable.Rows[i]["pi_chipouttype"].ToString();
+                            dr["ch_level"] = DataTable.Rows[i]["ch_level"].ToString();
                             dr["pr_orispeccode"] = DataTable.Rows[i]["pr_orispeccode"].ToString();
                             dr["pi_inoutno"] = DataTable.Rows[i]["pi_inoutno"].ToString();
                             dr["pi_title"] = DataTable.Rows[i]["pi_title"].ToString();
@@ -3436,6 +3472,7 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j - 4].SetCellValue(Data);
                                 }
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -3446,6 +3483,7 @@ namespace UAS_LabelMachine
                             if (DataTable.Columns[j].ColumnName == "rownum")
                             {
                                 row1.Cells[j - 4].SetCellValue(i + 1);
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "ch_code")
                             {
@@ -3750,16 +3788,19 @@ namespace UAS_LabelMachine
                                 {
                                     row1.Cells[j - 4].SetCellValue(Data);
                                 }
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
                                 row1.Cells[j - 4].SetCellValue(int.Parse(Data));
                                 sumCount += int.Parse(DataTable.Rows[i][j].ToString());
                                 totalCount += int.Parse(DataTable.Rows[i][j].ToString());
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "rownum")
                             {
                                 row1.Cells[j - 4].SetCellValue(i + 1);
+                                row1.Cells[j - 4].CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "ch_code")
                             {
@@ -3873,6 +3914,8 @@ namespace UAS_LabelMachine
                     string LastBoxCode1 = "";
                     int PageNum2 = 0;
                     string LastBatch = "";
+                    int MidCount = 0;
+                    int SerialNum = 1;
                     for (int i = 0; i < rowNum; i++)
                     {
                         IRow row1 = sheet.CreateRow(PaintIndex);
@@ -3947,6 +3990,38 @@ namespace UAS_LabelMachine
                             PaintIndex = PaintIndex + 1;
                             PageNum2 = 0;
                         }
+                        if (LastBatch == "" || (LastBatch != "" && LastBatch != DataTable.Rows[i]["ch_splitbatch"].ToString()))
+                        {
+                            LastBatch = DataTable.Rows[i]["ch_splitbatch"].ToString();
+                            for (int j = 0; j < ShowColumnCount; j++)
+                            {
+                                if (j == 0)
+                                {
+                                    row1.CreateCell(j).SetCellValue(SerialNum - 1);
+                                }
+                                else if (j == 1)
+                                {
+                                    row1.CreateCell(j).SetCellValue("批小计");
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.CreateCell(j).SetCellValue(MidCount);
+                                }
+                                else if (j == ShowBoxIndex - 4)
+                                {
+                                    row1.CreateCell(j).SetCellValue(LastBox);
+                                }
+                                else
+                                {
+                                    row1.CreateCell(j);
+                                }
+                                row1.Cells[j].CellStyle = styleborder;
+                            }
+                            SerialNum = 1;
+                            MidCount = 0;
+                            row1 = sheet.CreateRow(PaintIndex);
+                            PaintIndex = PaintIndex + 1;
+                        }
                         //每次到了页数开始分页
                         if (LastBoxCode1 == "" || (LastBoxCode1 != "" && LastBoxCode1 != DataTable.Rows[i]["ch_pbcode"].ToString()) || ((i == rowNum - 1) && (LastBoxCode1 != "" && LastBoxCode1 != DataTable.Rows[i]["ch_pbcode"].ToString())))
                         {
@@ -4074,10 +4149,11 @@ namespace UAS_LabelMachine
                                 row1.Cells[j - 4].SetCellValue(int.Parse(Data));
                                 sumCount += int.Parse(DataTable.Rows[i][j].ToString());
                                 totalCount += int.Parse(DataTable.Rows[i][j].ToString());
+                                MidCount += int.Parse(DataTable.Rows[i][j].ToString());
                             }
                             if (DataTable.Columns[j].ColumnName == "rownum")
                             {
-                                row1.Cells[j - 4].SetCellValue(i + 1);
+                                row1.Cells[j - 4].SetCellValue(SerialNum);
                             }
                             if (DataTable.Columns[j].ColumnName == "ch_code")
                             {
@@ -4088,6 +4164,7 @@ namespace UAS_LabelMachine
                             {
                                 LastBox = Data;
                             }
+                            row1.Cells[j - 4].CellStyle = styleborder;
                         }
                         if (i == rowNum - 1)
                         {
@@ -4095,36 +4172,6 @@ namespace UAS_LabelMachine
                             row1 = sheet.CreateRow(PaintIndex);
                             PaintIndex = PaintIndex + 1;
                             for (int j = 0; j < ShowColumnCount; j++)
-                            {
-                                row1.CreateCell(j);
-                                if (j == 0)
-                                {
-                                    row1.Cells[j].SetCellValue(批小计);
-                                    row1.Cells[j].CellStyle = styleborder;
-                                }
-                                else if (j == ShowPieceIndex)
-                                {
-                                    row1.Cells[ShowPieceIndex].SetCellValue(PageNum2 + 片);
-                                    row1.Cells[j].CellStyle = styleborder;
-                                }
-                                else if (j == ShowCountIndex)
-                                {
-                                    row1.Cells[j].SetCellValue(sumCount);
-                                    row1.Cells[j].CellStyle = styleborder;
-                                }
-                                else if (j == ShowBoxIndex - 4)
-                                {
-                                    row1.Cells[j].SetCellValue(LastBox);
-                                    row1.Cells[j].CellStyle = styleborder;
-                                }
-                                else
-                                {
-                                    row1.Cells[j].CellStyle = styleborder;
-                                }
-                            }
-                            row1 = sheet.CreateRow(PaintIndex);
-                            PaintIndex = PaintIndex + 1;
-                            for (int j = 0; j < ShowColumnCount; j++)
                             {
                                 row1.CreateCell(j);
                                 if (j == 0)
@@ -4185,6 +4232,7 @@ namespace UAS_LabelMachine
                         PageNum2 = PageNum2 + 1;
                         pib_id.Add(DataTable.Rows[i]["pib_id"].ToString());
                         pib_outboxcode1.Add(BoxCode.ToString());
+                        SerialNum = SerialNum + 1;
                     }
                     break;
                 default:
@@ -4284,7 +4332,7 @@ namespace UAS_LabelMachine
                         else if (j == ShowSizeIndex)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
+                            row1.Cells[j].SetCellValue(FirstDT.Columns["pr_size"].Caption + ":" + FirstDT.Rows[i]["pr_size"].ToString());
                         }
                         else if (j > 5 && j == columnNum - 5)
                         {