using System;

namespace Core.XgMes.Server.JGKC.SteelPlateManager
{
	/// <summary>
	/// FixDBManager 的摘要说明。
	/// </summary>
	public sealed class FixDBManager
	{
		public FixDBManager()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		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 CheckNullStr(object obj)
		{
			if(obj == null || obj.GetType() == typeof(System.DBNull))
			{
				return "";
			}
			else
			{
				return Convert.ToString(obj);
			}
		}
		public static int CheckNullInt(object obj)
		{
			if(obj == null || obj.GetType() == typeof(System.DBNull))
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		public static System.Decimal CheckNullDecimal(object obj)
		{
			if(obj == null || obj.GetType() == typeof(System.DBNull))
			{
				return 0;
			}
			else
			{
				return Convert.ToDecimal(obj);
			}
		}
	}
}
