zoukankan      html  css  js  c++  java
  • 数字金额转换大写

    ALTER FUNCTION [dbo].[FN_AmountConvertToRMB] (   @LowerAmount NUMERIC(16, 2),   @TransType INT ) RETURNS VARCHAR(200) AS BEGIN  DECLARE @LowerAmountStr NVARCHAR(200) -- 小写金额  Declare @UpperPart NVARCHAR(200)  Declare @UpperAmountStr NVARCHAR(200) -- 大写金额  DECLARE @i INT

     SET @LowerAmountStr = LTRIM(RTRIM(ROUND(@LowerAmount, 2))) --四舍五入为指定的精度并删除数据左右空格  SET @i = 1  SET @UpperAmountStr = ''

     WHILE ( @i <= len(@LowerAmountStr))  BEGIN   SELECT @UpperPart = CASE SUBSTRING(@LowerAmountStr, LEN(@LowerAmountStr) - @i + 1, 1)    WHEN '.' THEN '元' WHEN '0' THEN '零' WHEN '1' THEN '壹' WHEN '2' THEN '贰'    WHEN '3' THEN '叁' WHEN '4' THEN '肆' WHEN '5' THEN '伍' WHEN '6' THEN '陆'    WHEN '7' THEN '柒' WHEN '8' THEN '捌'WHEN '9' THEN '玖' END    +    CASE @i WHEN 1 THEN '分' WHEN 2 THEN '角' WHEN 3 THEN '' WHEN 4 THEN ''    WHEN 5 THEN '拾' WHEN 6 THEN '佰' WHEN 7 THEN '仟' WHEN 8 THEN '万'WHEN 9 THEN '拾'    WHEN 10 THEN '佰' WHEN 11 THEN '仟' WHEN 12 THEN '亿' WHEN 13 THEN '拾'    WHEN 14 THEN '佰' WHEN 15 THEN '仟' WHEN 16 THEN '万' ELSE '' END   SET @UpperAmountStr = @UpperPart + @UpperAmountStr   SET @i = @i + 1  END

     IF ( 0 = @TransType)  BEGIN   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零拾', '零')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零佰', '零')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零仟', '零')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零零零', '零')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零零', '零')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零角零分', '整')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零分', '整')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零角', '零')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零亿零万零元', '亿元')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '亿零万零元', '亿元')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零亿零万', '亿')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零万零元', '万元')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '万零元', '万元')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零亿', '亿')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零万', '万')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零元', '元')   SET @UpperAmountStr = REPLACE(@UpperAmountStr, '零零', '零')  END

     -- 对壹元以下的金额的处理  IF ( '元' = SUBSTRING(@UpperAmountStr, 1, 1))   SET @UpperAmountStr = SUBSTRING(@UpperAmountStr, 2, (LEN(@UpperAmountStr) - 1))

     IF ( '零' = SUBSTRING(@UpperAmountStr, 1, 1))   SET @UpperAmountStr = SUBSTRING(@UpperAmountStr, 2, (LEN(@UpperAmountStr) - 1)) 

     IF ( '角' = SUBSTRING(@UpperAmountStr, 1, 1))   SET @UpperAmountStr = substring(@UpperAmountStr, 2, (len(@UpperAmountStr) - 1))

     IF ( '分' = SUBSTRING(@UpperAmountStr, 1, 1))   SET @UpperAmountStr = substring(@UpperAmountStr, 2, (len(@UpperAmountStr) - 1))

     IF ('整' = SUBSTRING(@UpperAmountStr, 1, 1))   SET @UpperAmountStr = '零元整'  RETURN @UpperAmountStr END

  • 相关阅读:
    angularjs中的页面访问权限设置
    Html页面head标签元素的意义和应用场景
    脚本引用中的defer和async的用法和区别
    自适应页面中如何使用雪碧图
    网页颜色分辨测试小游戏的js化辨别及优化
    jQuery1.9及其以上版本中动态元素on绑定事件无效解决方案
    Data URL简介及Data URL的利弊
    浏览器调试:事件定位与源码查找
    简述ES5 ES6
    移动端中pagehide、pageshow的应用
  • 原文地址:https://www.cnblogs.com/heyiping/p/9584809.html
Copyright © 2011-2022 走看看