_Error.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace IControls_FireManager
  6. {
  7. // 에러 검증 함수는 여기 클래스에서 전담한다
  8. public static class _Error
  9. {
  10. public static char Blank = ' ';
  11. public static char Comma = ',';
  12. public static char SemiColon = ';';
  13. public static char Colon = ':';
  14. public static string Apostrophe = "'";
  15. public static char Minus = '-';
  16. // 스트링중 숫자가 아닌 다른값이 포함되어있는지 체크
  17. public static bool Check_All_Int(string Data)
  18. {
  19. for(int i=0;i<Data.Length;i++)
  20. {
  21. if (Data[i] == '0'
  22. || Data[i] == '1'
  23. || Data[i] == '2'
  24. || Data[i] == '3'
  25. || Data[i] == '4'
  26. || Data[i] == '5'
  27. || Data[i] == '6'
  28. || Data[i] == '7'
  29. || Data[i] == '8'
  30. || Data[i] == '9')
  31. {
  32. ;
  33. }
  34. else
  35. return false;
  36. }
  37. return true;
  38. }
  39. // 한단어안에 지정한 문자가 있다면 에러 문구 리턴, 없다면(정상이라면) null 리턴
  40. public static string Data_Check_NotDefineChar(string Data, char DefindChar)
  41. {
  42. string result = null;
  43. string[] words = Data.Split(DefindChar);
  44. if (words.Length != 1)
  45. {
  46. if (DefindChar == Blank) result = _Text.DontBlank;
  47. else if (DefindChar == Comma) result = _Text.DontComma;
  48. else if (DefindChar == SemiColon) result = _Text.DontSemiColon;
  49. else if (DefindChar == Colon) result = _Text.DontColon;
  50. return result;
  51. }
  52. return result;
  53. }
  54. // 여러단어들중에 지정한 문자가 있다면 에러 문구 리턴, 없다면(정상이라면) null 리턴
  55. public static string Datas_Check_NotDefineChar(string Data, char DefindChar, int AllCount)
  56. {
  57. string result = null;
  58. string[] words = Data.Split(DefindChar);
  59. if(words.Length!=AllCount)
  60. {
  61. if (DefindChar == Blank) result = _Text.DontBlank;
  62. else if (DefindChar == Comma) result = _Text.DontComma;
  63. else if (DefindChar == SemiColon) result = _Text.DontSemiColon;
  64. else if (DefindChar == Colon) result = _Text.DontColon;
  65. return result;
  66. }
  67. return result;
  68. }
  69. // 한단어안에 지정한 단어가 있다면 에러 문구 리턴, 없다면(정상이라면) null 리턴
  70. public static string Data_Check_NotDefineString(string Data, string DefindString)
  71. {
  72. string result = null;
  73. int OriginalLength = Data.Length;
  74. string TempString = Data.Replace(DefindString, ""); // 지정자가 속해있다면 Length 가 변경됨
  75. if (TempString.Length != OriginalLength)
  76. return DefindString + _Text.DontDefineString;
  77. return result;
  78. }
  79. // 주의! 여러단어 입력시 공백 추가
  80. // 여러단어안에 지정한 단어가 있다면 에러 문구 리턴, 없다면(정상이라면) null 리턴
  81. public static string Datas_Check_NotDefineString(string Data, string DefindString)
  82. {
  83. string result = null;
  84. string[] words = Data.Split(Blank);
  85. foreach (string word in words)
  86. {
  87. int OriginalLength = word.Length;
  88. string TempString = word.Replace(DefindString, ""); // 지정자가 속해있다면 Length 가 변경됨
  89. if (TempString.Length != OriginalLength)
  90. return DefindString + _Text.DontDefineString;
  91. }
  92. return result;
  93. }
  94. // 상위에 있는 에러 전부 검사
  95. public static string Data_Confirm_NotDefineString(string Data)
  96. {
  97. string ConfirmText = null;
  98. ConfirmText = Data_Check_NotDefineString(Data, _Error.Apostrophe);
  99. if (ConfirmText != null)
  100. {
  101. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, ConfirmText, 0);
  102. return ConfirmText;
  103. }
  104. ConfirmText = Data_Check_NotDefineString(Data, _Error.SemiColon.ToString());
  105. if (ConfirmText != null)
  106. {
  107. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, ConfirmText, 0);
  108. return ConfirmText;
  109. }
  110. ConfirmText = Data_Check_NotDefineString(Data, _Error.Colon.ToString());
  111. if (ConfirmText != null)
  112. {
  113. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, ConfirmText, 0);
  114. return ConfirmText;
  115. }
  116. ConfirmText = Data_Check_NotDefineString(Data, _Error.Comma.ToString());
  117. if (ConfirmText != null)
  118. {
  119. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, ConfirmText, 0);
  120. return ConfirmText;
  121. }
  122. ConfirmText = Data_Check_NotDefineString(Data, _Error.Minus.ToString());
  123. if (ConfirmText != null)
  124. {
  125. _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.Warnning, 250, 150, ConfirmText, 0);
  126. return ConfirmText;
  127. }
  128. return ConfirmText;
  129. }
  130. }
  131. }