using System;
using System.Data;
using System.Collections;
using Core.Mes.ServerFrameWork;
using Core.Mes.IBaseInterface;
namespace Core.XgMes.Server.JGKC.RollManager
{
///
/// Common 的摘要说明。
///
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;
}
///
/// 对目标对象进行字符串的转换
///
///
///
public static string ObjToStr(object obj)
{
if(obj == null || obj.GetType() == typeof(System.DBNull))
{
return "";
}
else
{
return Convert.ToString(obj);
}
}
///
/// 对目标对象进行数字(小数)的转换
///
///
///
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);
}
}
}
}