www.pudn.com > FerrariSystem.rar > ConvertType.cs
using System;
using System.Data;
using System.Data.OleDb;
namespace Common
{
///
/// Convert 的摘要说明。
///
public class ConvertType
{
public ConvertType()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static String GetString(Object objValue)
{
if (objValue == System.DBNull.Value)
{
return "";
}
else
{
return objValue.ToString();
}
}
public static decimal GetDecimal(Object objValue)
{
try
{
if (objValue == DBNull.Value)
{
return -1;
}
else
{
return decimal.Parse(objValue.ToString());
}
}
catch
{
return -1;
}
}
public static int GetInt(Object objValue)
{
try
{
if (objValue == DBNull.Value)
{
return -1;
}
else
{
return int.Parse(objValue.ToString());
}
}
catch
{
return -1;
}
}
public static object GetNullableDBValue(object objValue)
{
if (objValue.ToString() == "")
{
return DBNull.Value;
}
else
{
return objValue;
}
}
}
}