| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using System;
- using System.Data;
- using System.Collections;
- using Core.Mes.ServerFrameWork;
- using Core.Mes.IBaseInterface;
- namespace Core.XgMes.Server.JGKC.RollManager
- {
- /// <summary>
- /// Common 的摘要说明。
- /// </summary>
- public class Common : Core.Mes.ServerFrameWork.IComponent
- {
- public Common()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- public override int maxValue
- {
- get
- {
- return 100;
- }
- }
- public override int minValue
- {
- get
- {
- return 50;
- }
- }
- public static object[] FixValues(object[] values)
- {
- for ( int i = 0 ;i< values.Length ;i++)
- {
- if (values[i] == null)
- {
- values[i] = DBNull.Value ;
- }
- else if(values[i].GetType().FullName == "System.String")
- {
- values[i] = ((string)values[i]).Length != 0? values[i]: DBNull.Value;
- }
- }
- return values;
- }
- /// <summary>
- /// 对目标对象进行字符串的转换
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public static string ObjToStr(object obj)
- {
- if(obj == null || obj.GetType() == typeof(System.DBNull))
- {
- return "";
- }
- else
- {
- return Convert.ToString(obj);
- }
- }
- /// <summary>
- /// 对目标对象进行数字(小数)的转换
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public static System.Decimal ObjToDecimal(object obj)
- {
- try
- {
- if(obj == null || obj.GetType() == typeof(System.DBNull) || ObjToStr(obj).Length ==0)
- {
- return 0;
- }
- else
- {
- return Convert.ToDecimal(obj);
- }
- }
- catch(System.Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- return 0;
- }
- }
-
- public ReturnObject GetDataSet(string _sqlstr)
- {
- string strOut ="";
- DataSet ds = this.DBManager.ExecuteQuery(_sqlstr, out strOut);
- return new ReturnObject(ds,strOut);
-
- }
- //统计字符在字符串中出现的次数
- public static int CharInStrCount(string Str1, string Char1)
- {
- if(Str1.Length < Char1.Length)
- return 0;
- return (Str1.Length-Str1.Replace(Char1, "").Length) / Char1.Length;
- }
- public static string CheckNullStr(object obj)
- {
- if(obj == null || obj.GetType() == typeof(System.DBNull))
- {
- return "";
- }
- else
- {
- return Convert.ToString(obj);
- }
- }
- }
- }
|