public static float Str2Money(string value)
{
if (string.IsNullOrEmpty(value))
{
return 0f;
}
else
{
value = value.Replace(",", "");
return float.Parse(value);
}
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string Money2Str(float value)
{
return value.ToString("N");
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static DateTime Str2Date(string value)
{
if (string.IsNullOrEmpty(value))
return DateTime.MinValue;
else
{
DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
dtFormat.ShortDatePattern = "dd-MM-yy";
return Convert.ToDateTime(value, dtFormat);
}
}
public static string Date2String(DateTime value)
{
if (value == DateTime.MinValue)
return string.Empty;
else
return value.ToString("dd-MM-yy");
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static int Str2Int(string value)
{
if (string.IsNullOrEmpty(value))
return 0;
else
return int.Parse(value);
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static Guid? Object2Guid(object value)
{
if (value == System.DBNull.Value)
{
return null;
}
else
{
return new Guid(value.ToString());
}
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string Object2Sting(object value)
{
if (value == System.DBNull.Value)
{
return string.Empty;
}
else
{
return value.ToString();
}
}