説明:入力した数字の人民元金額を大文字にする

2747 ワード

/// 
        ///   :              
        /// 
        /// string         
        /// string         
        public static string ConvertToUpperMoney(string amount)
        {
            string SM = "          ";//      
            string DW = "               ";//      
            string DXJE;//        
            if (9999999999999.99 < Double.Parse(amount))
            {
                DXJE = "          ";
            }
            //>>           
            else
            {
                if (-1 == amount.IndexOf("."))
                {
                    amount = amount + "00";
                }
                //>>             
                else
                {
                    string XSBF = amount.Split(new char[] { '.' }, 2)[1];//    
                    if (0 == XSBF.Length)//       ,      
                    {
                        amount = amount + "00";
                    }
                    else if (1 == XSBF.Length)//        
                    {
                        amount = amount + "0";
                    }
                    //>>       3 ,    
                    else if (XSBF.Length > 2)
                    {
                        double dje = Double.Parse(amount);

                        //>>            5
                        if (Int32.Parse(XSBF.Substring(2, 1)) >= 5)
                        {
                            dje = dje + 0.01;
                            amount = dje.ToString();
                        }
                        //>>            5
                        amount = amount.Substring(0, amount.Length - (XSBF.Length - 2));//                 
                    }
                    //>>       3 ,    
                }
                //>>             

                amount = amount.Replace(".", "");//     
                DXJE = " ";
                int dw;//     
                int shu;//    

                //>>              
                for (shu = amount.Length - 1, dw = 0; shu >= 0; shu--, dw++)
                {
                    int w = Int32.Parse(amount.Substring(shu, 1));//      shu 
                    DXJE = DW.Substring(dw, 1) + DXJE;
                    DXJE = SM.Substring(w, 1) + DXJE;
                }
                //>>              
            }
            //>>           
            if (DXJE.Substring(0, 1) == " ")
            {
                DXJE = DXJE.Substring(1, DXJE.Length - 1);
            }
            return DXJE;
        }