/// <summary>
/// 實現數據的四捨五入
/// </summary>
/// <param name="colValue">四捨五入的值</param>
/// <param name="dataScale">小數點位數</param>
/// <returns></returns>
private static string DataRound(double colValue, int dataScale)
{
string res = string.Empty;
//實現四捨五入
colValue = Math.Round(colValue, Convert.ToInt32(dataScale), MidpointRounding.AwayFromZero);
res = colValue.ToString("G");
//按精度獲取準確值
if (res.Split('.').Length >= 2)
{
if (res.Split('.')[1].Length < dataScale)
{
res = res.PadRight(dataScale - res.Split('.').Length, '0');
}
else
{
res = res.Substring(2, dataScale);
}
}
else
{
res += ".";
res = res.PadRight(dataScale+2, '0');
}
return res;
}