using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Security;
using System.Security.Cryptography;
using System.IO;
using System.Web;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Reflection;
using System.Data;
public static class DHelper
{
#region 常用处理
///
/// 检查DataTable 是否有数据行
///
/// DataTable
///
public static bool IsHaveRows(this System.Data.DataTable dt)
{
if (dt != null && dt.Rows.Count > 0)
return true;
return false;
}
///
/// 对象是否为NULL
///
/// 对象
/// 是否为NULL
public static bool IsNull(this object obj)
{
if ((Object.Equals(obj, null)) || (Object.Equals(obj, DBNull.Value)) || (obj == null))
{
return true;
}
if (obj is DateTime && obj.ToDateTime().Equals(DateTime.MinValue))
{
return true;
}
return false;
}
///
/// 是否包含str字符有true
///
///
///
///
public static bool IsIndexOf(this string strs, string str)
{
if (strs.ToLower().IndexOf(str.ToLower()) != -1)
return true;
return false;
}
///
/// 字符串是否为空true是空
///
/// 字符串
/// 是否为空
public static bool IsEmpty(this string str)
{
if (IsNull(str))
{
return true;
}
if (str.Equals(String.Empty))
{
return true;
}
return false;
}
///
/// 对象不为NULL
///
/// 字符串
/// 返回字符串
public static string IfNull(this object str)
{
if (str == null || Object.Equals(str, null))
{
return String.Empty;
}
return str.ToString();
}
///
/// 对象不为NULL
///
/// 字符串
/// 返回字符串
public static bool IfNotNull(this object str)
{
if ((Object.Equals(str, null)) || (Object.Equals(str, DBNull.Value)) || (str == null))
{
return false;
}
return true;
}
///
/// 有值?(与IsNullOrEmpty相反)
///
///
public static bool IsValuable(this IEnumerable