Advertisement
freemorpheme

FUNCTION-Regex

Dec 12th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Text;
  6.  
  7. namespace WebPHSales.AppCode
  8. {
  9. public class Funtool
  10. {
  11. //共用method
  12.  
  13. //轉棟樓別格式
  14. public string changFloor(string beam, string floor, string Mode)
  15. {
  16. //0 轉菲國格式
  17. //1 轉台灣格式
  18.  
  19. string newString = "";
  20.  
  21. if (!string.IsNullOrEmpty(beam))
  22. {
  23. switch (Mode)
  24. {
  25. case "0":
  26. newString = beam.Substring(0, 1) + floor.Substring(0, 2) + "," + beam.Substring(1, 2);
  27. break;
  28. case "1":
  29. newString = beam.Substring(0, 1) + beam.Substring(3, 2) + "," + beam.Substring(1, 2) + "F";
  30. break;
  31. }
  32. }
  33.  
  34. return newString;
  35.  
  36. }
  37.  
  38. //三位一撇
  39. public string StyleAmt(string strAmt, string mode)
  40. {
  41. //0 數字三位一撇
  42. //1 去除三位一撇
  43.  
  44. string str = "0";
  45. if (!string.IsNullOrEmpty(strAmt))
  46. {
  47. if (mode == "0")
  48. {
  49. str = string.Format("{0:#,0.####}", Convert.ToDecimal(strAmt));
  50. }
  51. else if (mode == "1")
  52. {
  53. str = strAmt.Replace(",", "");
  54. }
  55. }
  56.  
  57. return str;
  58. }
  59.  
  60. //西元年YYYY/MM/DD
  61. public string StyleDate(string strdate, string mode)
  62. {
  63. //0 年加/
  64. //1 去/
  65.  
  66. string str = "";
  67.  
  68. if (!string.IsNullOrEmpty(strdate))
  69. {
  70.  
  71. if (mode == "0")
  72. {
  73. str = strdate.Substring(0, 4) + "/" + strdate.Substring(4, 2) + "/" + strdate.Substring(6, 2);
  74.  
  75. }
  76. else if (mode == "1")
  77. {
  78. str = strdate.Replace("/", "");
  79. }
  80. }
  81.  
  82. return str;
  83. }
  84.  
  85. //單引號變雙引號
  86. public string DQuotation(string oldStr)
  87. {
  88. string newStr = "";
  89.  
  90. if (!string.IsNullOrEmpty(oldStr))
  91. {
  92. newStr = oldStr.Replace("'", "''");
  93. }
  94.  
  95. return newStr;
  96. }
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement