f5847d7f6a7021671104e1c21497ed7509ba2606.svn-base 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Data;
  3. using System.Collections;
  4. using Core.Mes.ServerFrameWork;
  5. using Core.Mes.IBaseInterface;
  6. namespace Core.XgMes.Server.JGKC.RollManager
  7. {
  8. /// <summary>
  9. /// Common 的摘要说明。
  10. /// </summary>
  11. public class Common : Core.Mes.ServerFrameWork.IComponent
  12. {
  13. public Common()
  14. {
  15. //
  16. // TODO: 在此处添加构造函数逻辑
  17. //
  18. }
  19. public override int maxValue
  20. {
  21. get
  22. {
  23. return 100;
  24. }
  25. }
  26. public override int minValue
  27. {
  28. get
  29. {
  30. return 50;
  31. }
  32. }
  33. public static object[] FixValues(object[] values)
  34. {
  35. for ( int i = 0 ;i< values.Length ;i++)
  36. {
  37. if (values[i] == null)
  38. {
  39. values[i] = DBNull.Value ;
  40. }
  41. else if(values[i].GetType().FullName == "System.String")
  42. {
  43. values[i] = ((string)values[i]).Length != 0? values[i]: DBNull.Value;
  44. }
  45. }
  46. return values;
  47. }
  48. /// <summary>
  49. /// 对目标对象进行字符串的转换
  50. /// </summary>
  51. /// <param name="obj"></param>
  52. /// <returns></returns>
  53. public static string ObjToStr(object obj)
  54. {
  55. if(obj == null || obj.GetType() == typeof(System.DBNull))
  56. {
  57. return "";
  58. }
  59. else
  60. {
  61. return Convert.ToString(obj);
  62. }
  63. }
  64. /// <summary>
  65. /// 对目标对象进行数字(小数)的转换
  66. /// </summary>
  67. /// <param name="obj"></param>
  68. /// <returns></returns>
  69. public static System.Decimal ObjToDecimal(object obj)
  70. {
  71. try
  72. {
  73. if(obj == null || obj.GetType() == typeof(System.DBNull) || ObjToStr(obj).Length ==0)
  74. {
  75. return 0;
  76. }
  77. else
  78. {
  79. return Convert.ToDecimal(obj);
  80. }
  81. }
  82. catch(System.Exception ex)
  83. {
  84. System.Diagnostics.Debug.WriteLine(ex.ToString());
  85. return 0;
  86. }
  87. }
  88. public ReturnObject GetDataSet(string _sqlstr)
  89. {
  90. string strOut ="";
  91. DataSet ds = this.DBManager.ExecuteQuery(_sqlstr, out strOut);
  92. return new ReturnObject(ds,strOut);
  93. }
  94. //统计字符在字符串中出现的次数
  95. public static int CharInStrCount(string Str1, string Char1)
  96. {
  97. if(Str1.Length < Char1.Length)
  98. return 0;
  99. return (Str1.Length-Str1.Replace(Char1, "").Length) / Char1.Length;
  100. }
  101. public static string CheckNullStr(object obj)
  102. {
  103. if(obj == null || obj.GetType() == typeof(System.DBNull))
  104. {
  105. return "";
  106. }
  107. else
  108. {
  109. return Convert.ToString(obj);
  110. }
  111. }
  112. }
  113. }