From 8d4354ddac2aec04130416050e42f3487796e2be Mon Sep 17 00:00:00 2001 From: kamonwan taengsuk Date: Wed, 17 May 2023 12:38:25 +0700 Subject: [PATCH] update --- Controllers/RoFive.Controller.cs | 102 +++++++++++----------- Controllers/building_four.Controller.cs | 88 ++++++++++--------- wwwroot/reports/budget_summary_report.frx | 8 +- 3 files changed, 98 insertions(+), 100 deletions(-) diff --git a/Controllers/RoFive.Controller.cs b/Controllers/RoFive.Controller.cs index 84aa002..d564bed 100644 --- a/Controllers/RoFive.Controller.cs +++ b/Controllers/RoFive.Controller.cs @@ -113,59 +113,55 @@ namespace rmutr_report.Controllers } } - foreach (var boqPrice in building_fours.basic_information) - { - // string str = boqPrice.list; - if (boqPrice.list != null) - { - boqPrice.list.Split("."); - } - - if (boqPrice.list == "20000000.0000") - { - boqPrice.list = "20,000,000"; - } - // if (str.Length == 4) - // { - // for (int i = 1; i <= str.Length - 1; i += 4) - // { - // boqPrice.list = str.Insert(i, ","); - // } - // } - // if (str.Length == 5) - // { - // for (int i = 2; i <= str.Length - 1; i += 5) - // { - // boqPrice.list = str.Insert(i, ","); - // } - // } - // else if (str.Length == 6) - // { - // for (int i = 3; i <= str.Length - 1; i += 6) - // { - // boqPrice.list = str.Insert(i, ","); - // } - // } - // else if (str.Length == 7) - // { - // for (int i = 1,j=5; i <= str.Length -1 ;i +=7,j+=7) - // { - // boqPrice.list = str.Insert(i, ",").Insert(j,","); - // } - // - // } - // if (str.Length == 8) - // { for (int i = 2,j=6; i <= str.Length -1 ;i +=8,j+=8) - // { - // boqPrice.list = str.Insert(i, ",").Insert(j,","); - // } - // } - - if (boqPrice.list == "10000000") - { - boqPrice.list = "10,000,000"; - } - } + foreach (var boqPrice in building_fours.basic_information) + { + if (boqPrice.list != null) + { + string str = boqPrice.list; + string num = String.Concat(str.Where(c => c >= '0' && c <= '9')); + + if (num.Length == 4) + { + for (int i = 1; i <= num.Length - 1; i += 4) + { + boqPrice.list = num.Insert(i, ","); + } + } + else if (num.Length == 5) + { + for (int i = 2; i <= num.Length - 1; i += 5) + { + boqPrice.list = num.Insert(i, ","); + } + } + else if (num.Length == 6) + { + for (int i = 3; i <= num.Length - 1; i += 6) + { + boqPrice.list = num.Insert(i, ","); + } + } + else if (num.Length == 7) + { + for (int i = 1,j=5; i <= num.Length -1 ;i +=7,j+=7) + { + boqPrice.list = num.Insert(i, ",").Insert(j,","); + } + + } + else if (num.Length == 8) + { for (int i = 2,j=6; i <= num.Length -1 ;i +=8,j+=8) + { + boqPrice.list = num.Insert(i, ",").Insert(j,","); + } + } + + if (boqPrice.list=="20000000.0000") + { + boqPrice.list = "20,000,000"; + } + } + } foreach (var boqPrice in building_fours.boq) { diff --git a/Controllers/building_four.Controller.cs b/Controllers/building_four.Controller.cs index 08d357d..82a0d36 100644 --- a/Controllers/building_four.Controller.cs +++ b/Controllers/building_four.Controller.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using System.Text.RegularExpressions; using FastReport; using FastReport.Export.Csv; using FastReport.Export.Mht; @@ -116,51 +117,52 @@ namespace rmutr_report.Controllers foreach (var boqPrice in building_fours.basic_information) { - if (boqPrice.list == "20000000.0000") + if (boqPrice.list != null) { - boqPrice.list = "20,000,000"; - } - //string str = boqPrice.list.Split(".").ToString(); - // if (str.Length == 4) - // { - // for (int i = 1; i <= str.Length - 1; i += 4) - // { - // boqPrice.list = str.Insert(i, ","); - // } - // } - // else if (str.Length == 5) - // { - // for (int i = 2; i <= str.Length - 1; i += 5) - // { - // boqPrice.list = str.Insert(i, ","); - // } - // } - // else if (str.Length == 6) - // { - // for (int i = 3; i <= str.Length - 1; i += 6) - // { - // boqPrice.list = str.Insert(i, ","); - // } - // } - // else if (str.Length == 7) - // { - // for (int i = 1,j=5; i <= str.Length -1 ;i +=7,j+=7) - // { - // boqPrice.list = str.Insert(i, ",").Insert(j,","); - // } - // - // } - // else if (str.Length == 8) - // { for (int i = 2,j=6; i <= str.Length -1 ;i +=8,j+=8) - // { - // boqPrice.list = str.Insert(i, ",").Insert(j,","); - // } - // } + string str = boqPrice.list; + string num = String.Concat(str.Where(c => c >= '0' && c <= '9')); + + if (num.Length == 4) + { + for (int i = 1; i <= num.Length - 1; i += 4) + { + boqPrice.list = num.Insert(i, ","); + } + } + else if (num.Length == 5) + { + for (int i = 2; i <= num.Length - 1; i += 5) + { + boqPrice.list = num.Insert(i, ","); + } + } + else if (num.Length == 6) + { + for (int i = 3; i <= num.Length - 1; i += 6) + { + boqPrice.list = num.Insert(i, ","); + } + } + else if (num.Length == 7) + { + for (int i = 1,j=5; i <= num.Length -1 ;i +=7,j+=7) + { + boqPrice.list = num.Insert(i, ",").Insert(j,","); + } + + } + else if (num.Length == 8) + { for (int i = 2,j=6; i <= num.Length -1 ;i +=8,j+=8) + { + boqPrice.list = num.Insert(i, ",").Insert(j,","); + } + } - // if (boqPrice.list == "10000000") - // { - // boqPrice.list = "10,000,000"; - // } + if (boqPrice.list=="20000000.0000") + { + boqPrice.list = "20,000,000"; + } + } } foreach (var boqPrice in building_fours.boq) diff --git a/wwwroot/reports/budget_summary_report.frx b/wwwroot/reports/budget_summary_report.frx index a2dff96..24282c8 100644 --- a/wwwroot/reports/budget_summary_report.frx +++ b/wwwroot/reports/budget_summary_report.frx @@ -1,5 +1,5 @@  - + @@ -1204,13 +1204,13 @@ - + - + @@ -1761,7 +1761,7 @@ - +