136 lines
4.2 KiB
C#
136 lines
4.2 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Text;
|
|||
|
|
|
|||
|
|
namespace APT.BaseData.Domain.ApiModel.Platform
|
|||
|
|
{
|
|||
|
|
public static class EChartsUnitConvertMethod
|
|||
|
|
{
|
|||
|
|
public static decimal ChangeDoubleToW(this decimal data)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data / 10000, 3, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static decimal ChangeDoubleToThree(this decimal data)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data, 3, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
public static decimal ChangeDoubleToW(this decimal data, int num)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data / 10000, num, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static decimal ChangeDoubleToThree(this decimal data, int num)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data, num, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
public static decimal ChangeDoubleToTwo(this decimal data)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data, 2, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static decimal ChangeDoubleToNum(this decimal data, int num)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data, num, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static decimal ChangeToDecimal(this string strData)
|
|||
|
|
{
|
|||
|
|
decimal dData = 0.0M;
|
|||
|
|
if (strData.Contains("E"))
|
|||
|
|
{
|
|||
|
|
dData = Convert.ToDecimal(decimal.Parse(strData.ToString(), System.Globalization.NumberStyles.Float));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
dData = Convert.ToDecimal(strData);
|
|||
|
|
}
|
|||
|
|
return dData;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static double ChangeDoubleToW(this double data)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data / 10000, 3, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static double ChangeDoubleToThree(this double data)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data, 3, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
public static double ChangeDoubleToW(this double data, int num)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data / 10000, num, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static double ChangeDoubleToThree(this double data, int num)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data, num, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
public static double ChangeDoubleToTwo(this double data)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data, 2, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static double ChangeDoubleToNum(this double data, int num)
|
|||
|
|
{
|
|||
|
|
return Math.Round(data, num, MidpointRounding.AwayFromZero);
|
|||
|
|
}
|
|||
|
|
public static double ChangeToDouble(this string strData)
|
|||
|
|
{
|
|||
|
|
double dData = 0d;
|
|||
|
|
if (strData.Contains("E"))
|
|||
|
|
{
|
|||
|
|
dData = Convert.ToDouble(double.Parse(strData.ToString(), System.Globalization.NumberStyles.Float));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
dData = Convert.ToDouble(strData);
|
|||
|
|
}
|
|||
|
|
return dData;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static double ChangeToDouble(this object strData)
|
|||
|
|
{
|
|||
|
|
double dData = 0;
|
|||
|
|
if (strData == null)
|
|||
|
|
return dData;
|
|||
|
|
dData = Convert.ToDouble(strData);
|
|||
|
|
return dData;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static decimal ChangeToDecimal(this object strData)
|
|||
|
|
{
|
|||
|
|
decimal dData = 0.0M;
|
|||
|
|
if (strData == null)
|
|||
|
|
return dData;
|
|||
|
|
dData = Convert.ToDecimal(strData);
|
|||
|
|
return dData;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 将“yyyy-MM-dd”格式的string值转换为日期值。
|
|||
|
|
/// </summary>
|
|||
|
|
public static DateTime FromIDate(this string date)
|
|||
|
|
{
|
|||
|
|
return DateTime.Parse(date);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 将“yyyy-MM”格式的string值转换为日期值。
|
|||
|
|
/// </summary>
|
|||
|
|
public static DateTime FromIMonth(this string date)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
return DateTime.Parse(date + "-01");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 将“yyyy”格式的string值转换为日期值。
|
|||
|
|
/// </summary>
|
|||
|
|
public static DateTime FromIYear(this string date)
|
|||
|
|
{
|
|||
|
|
return DateTime.Parse(date + "-01-01");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|