Browse Source

添加首页型号,调整数字内容均可以计数

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

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

@@ -698,8 +698,15 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                row1.Cells[j - 4].SetCellValue(Data);
-                                row1.GetCell(j - 4).CellStyle = styleborder;
+                                double Num = 0;
+                                if (double.TryParse(Data, out Num))
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Num);
+                                }
+                                else
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Data);
+                                }
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -935,8 +942,15 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                row1.Cells[j - 4].SetCellValue(Data);
-                                row1.GetCell(j - 4).CellStyle = styleborder;
+                                double Num = 0;
+                                if (double.TryParse(Data, out Num))
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Num);
+                                }
+                                else
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Data);
+                                }
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -1179,8 +1193,15 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                row1.Cells[j - 4].SetCellValue(Data);
-                                row1.GetCell(j - 4).CellStyle = styleborder;
+                                double Num = 0;
+                                if (double.TryParse(Data, out Num))
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Num);
+                                }
+                                else
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Data);
+                                }
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -1334,7 +1355,8 @@ namespace UAS_LabelMachine
                         if (j == 0)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Columns["pi_title"].Caption + ":" + FirstDT.Rows[i]["pi_title"].ToString());
+                            row1.Cells[j].SetCellValue(FirstDT.Columns["pi_title"].Caption + ":" + FirstDT.Rows[i]["pi_title"].ToString() + "  "
+                               + FirstDT.Columns["ch_level"].Caption + ":" + FirstDT.Rows[i]["ch_level"].ToString());
                         }
                         else if (j > 5 && j == columnNum - 5)
                         {
@@ -1358,9 +1380,14 @@ namespace UAS_LabelMachine
                     for (int j = 0; j < columnNum - 3; j++)
                     {
                         if (j == 0)
+                        {
+                            row1.CreateCell(j).SetCellValue(FirstDT.Columns["pr_orispeccode"].Caption + ":" + FirstDT.Rows[i]["pr_orispeccode"].ToString() + " "
+                    + "(" + FirstDT.Rows[i]["me_desc"].ToString() + ")" + FirstDT.Columns["pi_chipouttype"].Caption + ":" + FirstDT.Rows[i]["pi_chipouttype"].ToString());
+                        }
+                        else if (j == ShowSizeIndex)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Columns["pr_orispeccode"].Caption + ":" + FirstDT.Rows[i]["pr_orispeccode"].ToString());
+                            row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
                         }
                         else if (j > 5 && j == columnNum - 5)
                         {
@@ -1384,28 +1411,45 @@ namespace UAS_LabelMachine
                     for (int j = 4; j < columnNum; j++)
                     {
                         row1.CreateCell(j - 4);
-                        row1.Cells[j - 4].CellStyle = styleborder;
-                        row1.Cells[j - 4].SetCellValue(FirstDT.Columns[j].Caption);
+                        if (NotShowColumn.Contains(FirstDT.Columns[j].ColumnName.ToLower()))
+                        {
+
+                        }
+                        else
+                        {
+                            row1.Cells[j - 4].CellStyle = styleborder;
+                            row1.Cells[j - 4].SetCellValue(FirstDT.Columns[j].Caption);
+                        }
                     }
                     row1 = sheet2.CreateRow(PaintIndex);
                     PaintIndex = PaintIndex + 1;
                 }
                 //添加数据内容
+                ShowColumnCount = 0;
                 for (int j = 4; j < columnNum; j++)
                 {
-                    string Data = FirstDT.Rows[i][j].ToString();
                     row1.CreateCell(j - 4);
-                    row1.Cells[j - 4].SetCellValue(Data);
-                    row1.GetCell(j - 4).CellStyle = styleborder;
-                    if (FirstDT.Columns[j].ColumnName == "num")
+
+                    if (!NotShowColumn.Contains(FirstDT.Columns[j].ColumnName.ToLower()))
                     {
-                        row1.Cells[j - 4].SetCellValue(int.Parse(Data));
-                        sumCount += int.Parse(Data);
+                        string Data = FirstDT.Rows[i][j].ToString();
+                        row1.Cells[j - 4].SetCellValue(Data);
+                        row1.GetCell(j - 4).CellStyle = styleborder;
+                        if (FirstDT.Columns[j].ColumnName == "num")
+                        {
+                            row1.Cells[j - 4].SetCellValue(int.Parse(Data));
+                            sumCount += int.Parse(Data);
+                        }
+                        if (FirstDT.Columns[j].ColumnName == "io_qty")
+                        {
+                            totalCount += int.Parse(Data);
+                            row1.Cells[j - 4].SetCellValue(int.Parse(Data));
+                        }
+                        ShowColumnCount = ShowColumnCount + 1;
                     }
-                    if (FirstDT.Columns[j].ColumnName == "io_qty")
+                    else
                     {
-                        totalCount += int.Parse(Data);
-                        row1.Cells[j - 4].SetCellValue(int.Parse(Data));
+
                     }
                 }
                 //添加总计行
@@ -1413,7 +1457,7 @@ namespace UAS_LabelMachine
                 {
                     row1 = sheet2.CreateRow(PaintIndex);
                     PaintIndex = PaintIndex + 1;
-                    for (int j = 0; j < columnNum - 4; j++)
+                    for (int j = 0; j < ShowColumnCount; j++)
                     {
                         if (j == 0)
                         {
@@ -1421,13 +1465,13 @@ namespace UAS_LabelMachine
                             row1.Cells[j].CellStyle = styleborder;
                             row1.Cells[j].SetCellValue(总计);
                         }
-                        else if (j == columnNum - 6)
+                        else if (j == ShowColumnCount-2)
                         {
                             row1.CreateCell(j);
                             row1.Cells[j].CellStyle = styleborder;
                             row1.Cells[j].SetCellValue(sumCount);
                         }
-                        else if (j == columnNum - 5)
+                        else if (j == ShowColumnCount-1)
                         {
                             row1.CreateCell(j);
                             row1.Cells[j].CellStyle = styleborder;
@@ -1840,8 +1884,15 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                row1.Cells[j - 4].SetCellValue(Data);
-                                row1.GetCell(j - 4).CellStyle = styleborder;
+                                double Num = 0;
+                                if (double.TryParse(Data, out Num))
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Num);
+                                }
+                                else
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Data);
+                                }
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -2092,8 +2143,15 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                row1.Cells[j - 4].SetCellValue(Data);
-                                row1.GetCell(j - 4).CellStyle = styleborder;
+                                double Num = 0;
+                                if (double.TryParse(Data, out Num))
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Num);
+                                }
+                                else
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Data);
+                                }
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -2340,8 +2398,15 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                row1.Cells[j - 4].SetCellValue(Data);
-                                row1.GetCell(j - 4).CellStyle = styleborder;
+                                double Num = 0;
+                                if (double.TryParse(Data, out Num))
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Num);
+                                }
+                                else
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Data);
+                                }
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -2485,7 +2550,8 @@ namespace UAS_LabelMachine
                         if (j == 0)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Columns["pi_title"].Caption + ":" + FirstDT.Rows[i]["pi_title"].ToString());
+                            row1.Cells[j].SetCellValue(FirstDT.Columns["pi_title"].Caption + ":" + FirstDT.Rows[i]["pi_title"].ToString() + "  "
+                               + FirstDT.Columns["ch_level"].Caption + ":" + FirstDT.Rows[i]["ch_level"].ToString());
                         }
                         else if (j > 5 && j == columnNum - 5)
                         {
@@ -2509,9 +2575,14 @@ namespace UAS_LabelMachine
                     for (int j = 0; j < columnNum - 3; j++)
                     {
                         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());
+                        }
+                        else if (j == ShowSizeIndex)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Columns["pr_orispeccode"].Caption + ":" + FirstDT.Rows[i]["pr_orispeccode"].ToString());
+                            row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
                         }
                         else if (j > 5 && j == columnNum - 5)
                         {
@@ -2534,30 +2605,45 @@ namespace UAS_LabelMachine
                     //添加列名
                     for (int j = 4; j < columnNum; j++)
                     {
-
                         row1.CreateCell(j - 4);
-                        row1.Cells[j - 4].CellStyle = styleborder;
-                        row1.Cells[j - 4].SetCellValue(FirstDT.Columns[j].Caption);
+                        if (NotShowColumn.Contains(FirstDT.Columns[j].ColumnName.ToLower()))
+                        {
+                         
+                        }
+                        else
+                        {
+                            row1.Cells[j - 4].CellStyle = styleborder;
+                            row1.Cells[j - 4].SetCellValue(FirstDT.Columns[j].Caption);
+                        }
                     }
                     row1 = sheet2.CreateRow(PaintIndex);
                     PaintIndex = PaintIndex + 1;
                 }
                 //添加数据内容
+                ShowColumnCount = 0;
                 for (int j = 4; j < columnNum; j++)
                 {
-                    string Data = FirstDT.Rows[i][j].ToString();
                     row1.CreateCell(j - 4);
-                    row1.Cells[j - 4].SetCellValue(Data);
-                    row1.GetCell(j - 4).CellStyle = styleborder;
-                    if (FirstDT.Columns[j].ColumnName == "num")
+
+                    if (!NotShowColumn.Contains(FirstDT.Columns[j].ColumnName.ToLower()))
                     {
-                        row1.Cells[j - 4].SetCellValue(int.Parse(Data));
-                        sumCount += int.Parse(Data);
+                        string Data = FirstDT.Rows[i][j].ToString();
+                        row1.Cells[j - 4].SetCellValue(Data);
+                        row1.GetCell(j - 4).CellStyle = styleborder;
+                        if (FirstDT.Columns[j].ColumnName == "num")
+                        {
+                            row1.Cells[j - 4].SetCellValue(int.Parse(Data));
+                            sumCount += int.Parse(Data);
+                        }
+                        if (FirstDT.Columns[j].ColumnName == "io_qty")
+                        {
+                            totalCount += int.Parse(Data);
+                            row1.Cells[j - 4].SetCellValue(int.Parse(Data));
+                        }
+                        ShowColumnCount = ShowColumnCount + 1;
                     }
-                    if (FirstDT.Columns[j].ColumnName == "io_qty")
-                    {
-                        totalCount += int.Parse(Data);
-                        row1.Cells[j - 4].SetCellValue(int.Parse(Data));
+                    else {
+
                     }
                 }
                 //添加总计行
@@ -2565,7 +2651,7 @@ namespace UAS_LabelMachine
                 {
                     row1 = sheet2.CreateRow(PaintIndex);
                     PaintIndex = PaintIndex + 1;
-                    for (int j = 0; j < columnNum - 4; j++)
+                    for (int j = 0; j < ShowColumnCount; j++)
                     {
                         if (j == 0)
                         {
@@ -2573,13 +2659,13 @@ namespace UAS_LabelMachine
                             row1.Cells[j].CellStyle = styleborder;
                             row1.Cells[j].SetCellValue(总计);
                         }
-                        else if (j == 3)
+                        else if (j == ShowColumnCount - 2)
                         {
                             row1.CreateCell(j);
                             row1.Cells[j].CellStyle = styleborder;
                             row1.Cells[j].SetCellValue(sumCount);
                         }
-                        else if (j == columnNum - 5)
+                        else if (j == ShowColumnCount - 1)
                         {
                             row1.CreateCell(j);
                             row1.Cells[j].CellStyle = styleborder;
@@ -3013,7 +3099,15 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                row1.Cells[j - 4].SetCellValue(Data);
+                                double Num = 0;
+                                if (double.TryParse(Data, out Num))
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Num);
+                                }
+                                else
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Data);
+                                }
                                 row1.GetCell(j - 4).CellStyle = styleborder;
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
@@ -3333,8 +3427,15 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                row1.Cells[j - 4].SetCellValue(Data);
-                                row1.GetCell(j - 4).CellStyle = styleborder;
+                                double Num = 0;
+                                if (double.TryParse(Data, out Num))
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Num);
+                                }
+                                else
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Data);
+                                }
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -3640,8 +3741,15 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                row1.Cells[j - 4].SetCellValue(Data);
-                                row1.GetCell(j - 4).CellStyle = styleborder;
+                                double Num = 0;
+                                if (double.TryParse(Data, out Num))
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Num);
+                                }
+                                else
+                                {
+                                    row1.Cells[j - 4].SetCellValue(Data);
+                                }
                             }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
@@ -4144,7 +4252,8 @@ namespace UAS_LabelMachine
                         if (j == 0)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Columns["pi_title"].Caption + ":" + FirstDT.Rows[i]["pi_title"].ToString());
+                            row1.Cells[j].SetCellValue(FirstDT.Columns["pi_title"].Caption + ":" + FirstDT.Rows[i]["pi_title"].ToString() + "  "
+                               + FirstDT.Columns["ch_level"].Caption + ":" + FirstDT.Rows[i]["ch_level"].ToString());
                         }
                         else if (j > 5 && j == columnNum - 5)
                         {
@@ -4168,9 +4277,14 @@ namespace UAS_LabelMachine
                     for (int j = 0; j < columnNum - 3; j++)
                     {
                         if (j == 0)
+                        {
+                            row1.CreateCell(j).SetCellValue(FirstDT.Columns["pr_orispeccode"].Caption + ":" + FirstDT.Rows[i]["pr_orispeccode"].ToString() + "_"
+                             + "(" + FirstDT.Rows[i]["me_desc"].ToString() + ")" + FirstDT.Columns["pi_chipouttype"].Caption + ":" + FirstDT.Rows[i]["pi_chipouttype"].ToString());
+                        }
+                        else if (j == ShowSizeIndex)
                         {
                             row1.CreateCell(j);
-                            row1.Cells[j].SetCellValue(FirstDT.Columns["pr_orispeccode"].Caption + ":" + FirstDT.Rows[i]["pr_orispeccode"].ToString());
+                            row1.Cells[j].SetCellValue(DataTable.Columns["pr_size"].Caption + ":" + DataTable.Rows[i]["pr_size"].ToString());
                         }
                         else if (j > 5 && j == columnNum - 5)
                         {
@@ -4194,28 +4308,45 @@ namespace UAS_LabelMachine
                     for (int j = 4; j < columnNum; j++)
                     {
                         row1.CreateCell(j - 4);
-                        row1.Cells[j - 4].CellStyle = styleborder;
-                        row1.Cells[j - 4].SetCellValue(FirstDT.Columns[j].Caption);
+                        if (NotShowColumn.Contains(FirstDT.Columns[j].ColumnName.ToLower()))
+                        {
+
+                        }
+                        else
+                        {
+                            row1.Cells[j - 4].CellStyle = styleborder;
+                            row1.Cells[j - 4].SetCellValue(FirstDT.Columns[j].Caption);
+                        }
                     }
                     row1 = sheet2.CreateRow(PaintIndex);
                     PaintIndex = PaintIndex + 1;
                 }
                 //添加数据内容
+                ShowColumnCount = 0;
                 for (int j = 4; j < columnNum; j++)
                 {
-                    string Data = FirstDT.Rows[i][j].ToString();
                     row1.CreateCell(j - 4);
-                    row1.Cells[j - 4].SetCellValue(Data);
-                    row1.GetCell(j - 4).CellStyle = styleborder;
-                    if (FirstDT.Columns[j].ColumnName == "num")
+
+                    if (!NotShowColumn.Contains(FirstDT.Columns[j].ColumnName.ToLower()))
                     {
-                        row1.Cells[j - 4].SetCellValue(int.Parse(Data));
-                        sumCount += int.Parse(Data);
+                        string Data = FirstDT.Rows[i][j].ToString();
+                        row1.Cells[j - 4].SetCellValue(Data);
+                        row1.GetCell(j - 4).CellStyle = styleborder;
+                        if (FirstDT.Columns[j].ColumnName == "num")
+                        {
+                            row1.Cells[j - 4].SetCellValue(int.Parse(Data));
+                            sumCount += int.Parse(Data);
+                        }
+                        if (FirstDT.Columns[j].ColumnName == "io_qty")
+                        {
+                            totalCount += int.Parse(Data);
+                            row1.Cells[j - 4].SetCellValue(int.Parse(Data));
+                        }
+                        ShowColumnCount = ShowColumnCount + 1;
                     }
-                    if (FirstDT.Columns[j].ColumnName == "io_qty")
+                    else
                     {
-                        totalCount += int.Parse(Data);
-                        row1.Cells[j - 4].SetCellValue(int.Parse(Data));
+
                     }
                 }
                 //添加总计行
@@ -4223,7 +4354,7 @@ namespace UAS_LabelMachine
                 {
                     row1 = sheet2.CreateRow(PaintIndex);
                     PaintIndex = PaintIndex + 1;
-                    for (int j = 0; j < columnNum - 4; j++)
+                    for (int j = 0; j < ShowColumnCount; j++)
                     {
                         if (j == 0)
                         {
@@ -4231,13 +4362,13 @@ namespace UAS_LabelMachine
                             row1.Cells[j].CellStyle = styleborder;
                             row1.Cells[j].SetCellValue(总计);
                         }
-                        else if (j == columnNum - 6)
+                        else if (j == ShowColumnCount - 2)
                         {
                             row1.CreateCell(j);
                             row1.Cells[j].CellStyle = styleborder;
                             row1.Cells[j].SetCellValue(sumCount);
                         }
-                        else if (j == columnNum - 5)
+                        else if (j == ShowColumnCount - 1)
                         {
                             row1.CreateCell(j);
                             row1.Cells[j].CellStyle = styleborder;