/// <summary>
/// 将金额转换成大写
/// </summary>
/// <param name="moneys"></param>
/// <returns></returns>
public static string GetUpperMoney(float moneys)
{
const string UNIT = "分角元拾佰仟万拾佰仟亿拾佰仟万";
const string UPPER = "零壹贰叁肆伍陆柒捌玖";
string stResult = "", stLower = "";
stLower = moneys.ToString("0.00").Replace(".", "");//将点替换变成分角
if (stLower.Length <= UNIT.Length)
{
for (int i = 0, j = stLower.Length - 1; i <= j; i++)
{
stResult += UPPER[stLower[i] - 48].ToString() + UNIT[j - i].ToString();
}
}
else
{
stResult =stLower;
}
return stResult;
}
二、附加一个MD5加密函数/// 将金额转换成大写
/// </summary>
/// <param name="moneys"></param>
/// <returns></returns>
public static string GetUpperMoney(float moneys)
{
const string UNIT = "分角元拾佰仟万拾佰仟亿拾佰仟万";
const string UPPER = "零壹贰叁肆伍陆柒捌玖";
string stResult = "", stLower = "";
stLower = moneys.ToString("0.00").Replace(".", "");//将点替换变成分角
if (stLower.Length <= UNIT.Length)
{
for (int i = 0, j = stLower.Length - 1; i <= j; i++)
{
stResult += UPPER[stLower[i] - 48].ToString() + UNIT[j - i].ToString();
}
}
else
{
stResult =stLower;
}
return stResult;
}
/// <summary>
/// md5加密,code=16或32
/// </summary>
/// <param name="str"></param>
/// <param name="code"></param>
/// <returns></returns>
public string MD5(string str, int code)
{
if (code == 16) //16位MD5加密(取32位加密的9~25字符)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16);
}
else//32位加密
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower();
}
}
/// md5加密,code=16或32
/// </summary>
/// <param name="str"></param>
/// <param name="code"></param>
/// <returns></returns>
public string MD5(string str, int code)
{
if (code == 16) //16位MD5加密(取32位加密的9~25字符)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16);
}
else//32位加密
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower();
}
}