Browse Source

尾数计数BUG修改

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

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

@@ -375,6 +375,7 @@ namespace UAS_LabelMachine
             NotShowColumn.Add("pr_orispeccode");
             NotShowColumn.Add("pr_orispeccode1");
             NotShowColumn.Add("pi_title");
+            NotShowColumn.Add("pi_chipouttype");
             //展示的内容列
             int ShowColumnsCount = 0;
             //设置列的宽度,根据首行的列的内容的长度来设置
@@ -542,7 +543,7 @@ namespace UAS_LabelMachine
                         if (i % PageSize == 0 || i == rowNum - 1)
                         {
                             //第一行添加客户信息   rownum只有一行的情
-                            if (i != rowNum - 1 || rowNum == 1)
+                            if (i != rowNum - 1 || rowNum == 1 || (rowNum - i == rowNum % PageSize))
                             {
                                 for (int j = 0; j < columnNum - 3; j++)
                                 {
@@ -634,8 +635,16 @@ namespace UAS_LabelMachine
                         {
                             string Data = DataTable.Rows[i][j].ToString();
                             row1.CreateCell(j - 4);
-                            row1.Cells[j - 4].SetCellValue(Data);
-                            row1.GetCell(j - 4).CellStyle = styleborder;
+                            if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                             (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                            {
+
+                            }
+                            else
+                            {
+                                row1.Cells[j - 4].SetCellValue(Data);
+                                row1.GetCell(j - 4).CellStyle = styleborder;
+                            }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
                                 row1.Cells[j - 4].SetCellValue(int.Parse(Data));
@@ -666,21 +675,21 @@ namespace UAS_LabelMachine
                             PaintIndex = PaintIndex + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
-                                    row1.CreateCell(j);
-                                    if (j == 0)
-                                    {
-                                        row1.Cells[j].SetCellValue(小计);
-                                    }
-                                    else if (j == 1)
-                                    {
-                                        row1.Cells[1].SetCellValue((i % PageSize == 0 ? PageSize : (i % PageSize + 1)) + 片);
-                                    }
-                                    else if (j == 2)
-                                    {
-                                        row1.Cells[2].SetCellValue(sumCount);
-                                    }
+                                row1.CreateCell(j);
+                                if (j == 0)
+                                {
+                                    row1.Cells[j].SetCellValue(小计);
+                                }
+                                else if (j == 1)
+                                {
+                                    row1.Cells[1].SetCellValue(rowNum % PageSize + 片);
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.Cells[2].SetCellValue(sumCount);
+                                }
 
-                                    row1.Cells[j].CellStyle = styleborder;
+                                row1.Cells[j].CellStyle = styleborder;
                             }
                             row1 = sheet.CreateRow(PaintIndex);
                             for (int j = 0; j < columnNum - 3; j++)
@@ -742,26 +751,26 @@ namespace UAS_LabelMachine
                             BoxCode = BoxCode + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
-                                
-                                    row1.CreateCell(j);
-                                    if (j == 0)
-                                    {
-                                        row1.Cells[j].SetCellValue(小计);
-                                        row1.Cells[j].CellStyle = styleborder;
-                                    }
-                                    else if (j == 1)
-                                    {
-                                        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.CreateCell(j);
+                                if (j == 0)
+                                {
+                                    row1.Cells[j].SetCellValue(小计);
+                                    row1.Cells[j].CellStyle = styleborder;
+                                }
+                                else if (j == 1)
+                                {
+                                    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;
+                                }
                             }
                             sumCount = 0;
                             row1 = sheet.CreateRow(PaintIndex);
@@ -861,8 +870,16 @@ namespace UAS_LabelMachine
                         {
                             string Data = DataTable.Rows[i][j].ToString();
                             row1.CreateCell(j - 4);
-                            row1.Cells[j - 4].SetCellValue(Data);
-                            row1.GetCell(j - 4).CellStyle = styleborder;
+                            if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                             (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                            {
+
+                            }
+                            else
+                            {
+                                row1.Cells[j - 4].SetCellValue(Data);
+                                row1.GetCell(j - 4).CellStyle = styleborder;
+                            }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
                                 row1.Cells[j - 4].SetCellValue(int.Parse(Data));
@@ -1080,8 +1097,16 @@ namespace UAS_LabelMachine
                         {
                             string Data = DataTable.Rows[i][j].ToString();
                             row1.CreateCell(j - 4);
-                            row1.Cells[j - 4].SetCellValue(Data);
-                            row1.GetCell(j - 4).CellStyle = styleborder;
+                            if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                             (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                            {
+
+                            }
+                            else
+                            {
+                                row1.Cells[j - 4].SetCellValue(Data);
+                                row1.GetCell(j - 4).CellStyle = styleborder;
+                            }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
                                 row1.Cells[j - 4].SetCellValue(int.Parse(Data));
@@ -1415,6 +1440,8 @@ namespace UAS_LabelMachine
             NotShowColumn.Add("pr_orispeccode");
             NotShowColumn.Add("pr_orispeccode1");
             NotShowColumn.Add("pi_title");
+            NotShowColumn.Add("pi_chipouttype");
+
             //展示的内容列
             int ShowColumnsCount = 0;
             //设置列的宽度,根据首行的列的内容的长度来设置
@@ -1573,22 +1600,21 @@ namespace UAS_LabelMachine
                             BoxCode = BoxCode + 1;
                             for (int j = 0; j < columnNum - 4; j++)
                             {
-                             
-                                    row1.CreateCell(j);
-                                    if (j == 0)
-                                    {
-                                        row1.Cells[j].SetCellValue(小计);
-                                    }
-                                    else if (j == 1)
-                                    {
-                                        row1.Cells[1].SetCellValue((i % PageSize == 0 ? PageSize : i) + 片);
-                                        row1.Cells[1].CellStyle = ColumnTitleStyle;
-                                    }
-                                    else if (j == 2)
-                                    {
-                                        row1.Cells[2].SetCellValue(sumCount);
-                                    }
-                                    row1.Cells[j].CellStyle = styleborder;
+                                row1.CreateCell(j);
+                                if (j == 0)
+                                {
+                                    row1.Cells[j].SetCellValue(小计);
+                                }
+                                else if (j == 1)
+                                {
+                                    row1.Cells[1].SetCellValue((i % PageSize == 0 ? PageSize : i) + 片);
+                                    row1.Cells[1].CellStyle = ColumnTitleStyle;
+                                }
+                                else if (j == 2)
+                                {
+                                    row1.Cells[2].SetCellValue(sumCount);
+                                }
+                                row1.Cells[j].CellStyle = styleborder;
                             }
                             sumCount = 0;
                             row1 = sheet.CreateRow(PaintIndex);
@@ -1638,7 +1664,7 @@ namespace UAS_LabelMachine
                                     {
                                         row1.CreateCell(j);
                                         row1.Cells[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());
+                                  + "(" + DataTable.Rows[i]["me_desc"].ToString() + ") " + DataTable.Columns["pi_chipouttype"].Caption + ":" + DataTable.Rows[i]["pi_chipouttype"].ToString());
                                     }
                                     else if (j == 3)
                                     {
@@ -1656,7 +1682,6 @@ namespace UAS_LabelMachine
                                     }
                                     row1.GetCell(j).CellStyle = style;
                                 }
-
                                 //特殊客户添加一列空行
                                 row1 = sheet.CreateRow(PaintIndex);
                                 PaintIndex = PaintIndex + 1;
@@ -1750,7 +1775,7 @@ namespace UAS_LabelMachine
                                 }
                                 else if (j == 1)
                                 {
-                                    row1.Cells[1].SetCellValue((i % PageSize == 0 ? PageSize : (i % PageSize + 1)) + 片);
+                                    row1.Cells[1].SetCellValue(rowNum % PageSize + 片);
                                     row1.Cells[1].CellStyle = ColumnTitleStyle;
                                 }
                                 else if (j == 2)
@@ -1906,6 +1931,9 @@ namespace UAS_LabelMachine
                                     }
                                     row1.GetCell(j).CellStyle = style;
                                 }
+                                //特殊客户添加一列空行
+                                row1 = sheet.CreateRow(PaintIndex);
+                                PaintIndex = PaintIndex + 1;
                                 //添加列名
                                 row1 = sheet.CreateRow(PaintIndex);
                                 PaintIndex = PaintIndex + 1;
@@ -1944,8 +1972,16 @@ namespace UAS_LabelMachine
                         {
                             string Data = DataTable.Rows[i][j].ToString();
                             row1.CreateCell(j - 4);
-                            row1.Cells[j - 4].SetCellValue(Data);
-                            row1.GetCell(j - 4).CellStyle = styleborder;
+                            if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                             (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                            {
+
+                            }
+                            else
+                            {
+                                row1.Cells[j - 4].SetCellValue(Data);
+                                row1.GetCell(j - 4).CellStyle = styleborder;
+                            }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
                                 row1.Cells[j - 4].SetCellValue(int.Parse(Data));
@@ -2134,6 +2170,9 @@ namespace UAS_LabelMachine
                                     }
                                     row1.GetCell(j).CellStyle = style;
                                 }
+                                //特殊客户添加一列空行
+                                row1 = sheet.CreateRow(PaintIndex);
+                                PaintIndex = PaintIndex + 1;
                                 //添加列名
                                 row1 = sheet.CreateRow(PaintIndex);
                                 PaintIndex = PaintIndex + 1;
@@ -2172,8 +2211,16 @@ namespace UAS_LabelMachine
                         {
                             string Data = DataTable.Rows[i][j].ToString();
                             row1.CreateCell(j - 4);
-                            row1.Cells[j - 4].SetCellValue(Data);
-                            row1.GetCell(j - 4).CellStyle = styleborder;
+                            if ((DataTable.Rows[i]["chw_itemname1"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent1") ||
+                             (DataTable.Rows[i]["chw_itemname2"].ToString() == "" && DataTable.Columns[j].ColumnName.ToLower() == "chw_percent2") || (NotShowColumn.Contains(DataTable.Columns[j].ColumnName.ToLower())) || (!ShowChcode && DataTable.Columns[j].ColumnName.ToLower().Contains("ch_code")))
+                            {
+
+                            }
+                            else
+                            {
+                                row1.Cells[j - 4].SetCellValue(Data);
+                                row1.GetCell(j - 4).CellStyle = styleborder;
+                            }
                             if (DataTable.Columns[j].ColumnName == "io_qty")
                             {
                                 row1.Cells[j - 4].SetCellValue(int.Parse(Data));
@@ -2230,7 +2277,7 @@ namespace UAS_LabelMachine
                                     row1.CreateCell(j);
                                     row1.Cells[j].SetCellValue(rowNum);
                                 }
-                                else if (j ==4)
+                                else if (j == 4)
                                 {
                                     row1.CreateCell(j);
                                     row1.Cells[j].SetCellValue(片);