如何将十进制卢比转换为asp.net中的单词c# [英] how to convert a decimal rupees into words in asp.net c#

查看:82
本文介绍了如何将十进制卢比转换为asp.net中的单词c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用gridview。它可以不访问整数值。



i将在一个页面中的查询字符串中用于另一个页面。



我的错误:输入字符串是格式不正确

i am using gridview. its can be not access the integer value.

i will be used in querystring in one page to another page.

my error: input string was not correct format

my code;


 <pre lang="c#">DataSet ds;
    MessageBox msg = new MessageBox();
    Bal_CashVoucherEntry obj = new Bal_CashVoucherEntry();
    SqlDataReader dr;
    string search = "";
    int result = 0;
    int count = 0;
   // Int64 Wrd = 0;
    string amount = "";
    string amount1 = "";
  

  
    protected void Page_Load(object sender, EventArgs e)
    {
       

        if (!IsPostBack)

        {
            
                        search = Request.QueryString["sr"];
              bind();
        }

    }

    public void bind()
    {
         
        
        try
        {
            obj.voucherno = search;
            obj.type = 13;
            //  obj.date = "DATE";


          //  string[] no = total1.Text.Split('.');
            
            ds = obj.exe_dataset();


            GridView1.DataSource = ds;
            GridView1.DataBind();

            //  amount = rupees(int.Parse());
        }

        catch (Exception ex)
        {
            throw ex;
        }


    }




    #region "rupees"
    public string rupees(Int64 rupees)
    {
        string result = "";
        Int64 res;
        if ((rupees / 10000000) > 0)
        {
            res = rupees / 10000000;
            rupees = rupees % 10000000;
            result = result + ' ' + rupeestowords(res) + " Crore";
        }
        if ((rupees / 100000) > 0)
        {
            res = rupees / 100000;
            rupees = rupees % 100000;
            result = result + ' ' + rupeestowords(res) + " Lakh";
        }
        if ((rupees / 1000) > 0)
        {
            res = rupees / 1000;
            rupees = rupees % 1000;
            result = result + ' ' + rupeestowords(res) + " Thousand";
        }
        if ((rupees / 100) > 0)
        {
            res = rupees / 100;
            rupees = rupees % 100;
            result = result + ' ' + rupeestowords(res) + " Hundred";
        }
        if ((rupees % 10) >= 0)
        {
            res = rupees % 100;
            result = result + " " + rupeestowords(res);
        }
        result = result + ' ' + "Rupees only";
        return result;
    }
    #endregion

    #region "rupeestowords"
    public string rupeestowords(Int64 rupees)
    {
        string result = "";
        if ((rupees >= 1) && (rupees <= 10))
        {
            if ((rupees % 10) == 1) result = "One";
            if ((rupees % 10) == 2) result = "Two";
            if ((rupees % 10) == 3) result = "Three";
            if ((rupees % 10) == 4) result = "Four";
            if ((rupees % 10) == 5) result = "Five";
            if ((rupees % 10) == 6) result = "Six";
            if ((rupees % 10) == 7) result = "Seven";
            if ((rupees % 10) == 8) result = "Eight";
            if ((rupees % 10) == 9) result = "Nine";
            if ((rupees % 10) == 0) result = "Ten";
        }
        if (rupees > 9 && rupees < 20)
        {
            if (rupees == 11) result = "Eleven";
            if (rupees == 12) result = "Twelve";
            if (rupees == 13) result = "Thirteen";
            if (rupees == 14) result = "Forteen";
            if (rupees == 15) result = "Fifteen";
            if (rupees == 16) result = "Sixteen";
            if (rupees == 17) result = "Seventeen";
            if (rupees == 18) result = "Eighteen";
            if (rupees == 19) result = "Nineteen";
        }
        if (rupees >= 20 && (rupees / 10) == 2 && (rupees % 10) == 0) result = "Twenty";
        if (rupees > 20 && (rupees / 10) == 3 && (rupees % 10) == 0) result = "Thirty";
        if (rupees > 20 && (rupees / 10) == 4 && (rupees % 10) == 0) result = "Forty";
        if (rupees > 20 && (rupees / 10) == 5 && (rupees % 10) == 0) result = "Fifty";
        if (rupees > 20 && (rupees / 10) == 6 && (rupees % 10) == 0) result = "Sixty";
        if (rupees > 20 && (rupees / 10) == 7 && (rupees % 10) == 0) result = "Seventy";
        if (rupees > 20 && (rupees / 10) == 8 && (rupees % 10) == 0) result = "Eighty";
        if (rupees > 20 && (rupees / 10) == 9 && (rupees % 10) == 0) result = "Ninety";

        if (rupees > 20 && (rupees / 10) == 2 && (rupees % 10) != 0)
        {
            if ((rupees % 10) == 1) result = "Twenty One";
            if ((rupees % 10) == 2) result = "Twenty Two";
            if ((rupees % 10) == 3) result = "Twenty Three";
            if ((rupees % 10) == 4) result = "Twenty Four";
            if ((rupees % 10) == 5) result = "Twenty Five";
            if ((rupees % 10) == 6) result = "Twenty Six";
            if ((rupees % 10) == 7) result = "Twenty Seven";
            if ((rupees % 10) == 8) result = "Twenty Eight";
            if ((rupees % 10) == 9) result = "Twenty Nine";
        }
        if (rupees > 20 && (rupees / 10) == 3 && (rupees % 10) != 0)
        {
            if ((rupees % 10) == 1) result = "Thirty One";
            if ((rupees % 10) == 2) result = "Thirty Two";
            if ((rupees % 10) == 3) result = "Thirty Three";
            if ((rupees % 10) == 4) result = "Thirty Four";
            if ((rupees % 10) == 5) result = "Thirty Five";
            if ((rupees % 10) == 6) result = "Thirty Six";
            if ((rupees % 10) == 7) result = "Thirty Seven";
            if ((rupees % 10) == 8) result = "Thirty Eight";
            if ((rupees % 10) == 9) result = "Thirty Nine";
        }
        if (rupees > 20 && (rupees / 10) == 4 && (rupees % 10) != 0)
        {
            if ((rupees % 10) == 1) result = "Forty One";
            if ((rupees % 10) == 2) result = "Forty Two";
            if ((rupees % 10) == 3) result = "Forty Three";
            if ((rupees % 10) == 4) result = "Forty Four";
            if ((rupees % 10) == 5) result = "Forty Five";
            if ((rupees % 10) == 6) result = "Forty Six";
            if ((rupees % 10) == 7) result = "Forty Seven";
            if ((rupees % 10) == 8) result = "Forty Eight";
            if ((rupees % 10) == 9) result = "Forty Nine";
        }
        if (rupees > 20 && (rupees / 10) == 5 && (rupees % 10) != 0)
        {
            if ((rupees % 10) == 1) result = "Fifty One";
            if ((rupees % 10) == 2) result = "Fifty Two";
            if ((rupees % 10) == 3) result = "Fifty Three";
            if ((rupees % 10) == 4) result = "Fifty Four";
            if ((rupees % 10) == 5) result = "Fifty Five";
            if ((rupees % 10) == 6) result = "Fifty Six";
            if ((rupees % 10) == 7) result = "Fifty Seven";
            if ((rupees % 10) == 8) result = "Fifty Eight";
            if ((rupees % 10) == 9) result = "Fifty Nine";
        }
        if (rupees > 20 && (rupees / 10) == 6 && (rupees % 10) != 0)
        {
            if ((rupees % 10) == 1) result = "Sixty One";
            if ((rupees % 10) == 2) result = "Sixty Two";
            if ((rupees % 10) == 3) result = "Sixty Three";
            if ((rupees % 10) == 4) result = "Sixty Four";
            if ((rupees % 10) == 5) result = "Sixty Five";
            if ((rupees % 10) == 6) result = "Sixty Six";
            if ((rupees % 10) == 7) result = "Sixty Seven";
            if ((rupees % 10) == 8) result = "Sixty Eight";
            if ((rupees % 10) == 9) result = "Sixty Nine";
        }
        if (rupees > 20 && (rupees / 10) == 7 && (rupees % 10) != 0)
        {
            if ((rupees % 10) == 1) result = "Seventy One";
            if ((rupees % 10) == 2) result = "Seventy Two";
            if ((rupees % 10) == 3) result = "Seventy Three";
            if ((rupees % 10) == 4) result = "Seventy Four";
            if ((rupees % 10) == 5) result = "Seventy Five";
            if ((rupees % 10) == 6) result = "Seventy Six";
            if ((rupees % 10) == 7) result = "Seventy Seven";
            if ((rupees % 10) == 8) result = "Seventy Eight";
            if ((rupees % 10) == 9) result = "Seventy Nine";
        }
        if (rupees > 20 && (rupees / 10) == 8 && (rupees % 10) != 0)
        {
            if ((rupees % 10) == 1) result = "Eighty One";
            if ((rupees % 10) == 2) result = "Eighty Two";
            if ((rupees % 10) == 3) result = "Eighty Three";
            if ((rupees % 10) == 4) result = "Eighty Four";
            if ((rupees % 10) == 5) result = "Eighty Five";
            if ((rupees % 10) == 6) result = "Eighty Six";
            if ((rupees % 10) == 7) result = "Eighty Seven";
            if ((rupees % 10) == 8) result = "Eighty Eight";
            if ((rupees % 10) == 9) result = "Eighty Nine";
        }
        if (rupees > 20 && (rupees / 10) == 9 && (rupees % 10) != 0)
        {
            if ((rupees % 10) == 1) result = "Ninety One";
            if ((rupees % 10) == 2) result = "Ninety Two";
            if ((rupees % 10) == 3) result = "Ninety Three";
            if ((rupees % 10) == 4) result = "Ninety Four";
            if ((rupees % 10) == 5) result = "Ninety Five";
            if ((rupees % 10) == 6) result = "Ninety Six";
            if ((rupees % 10) == 7) result = "Ninety Seven";
            if ((rupees % 10) == 8) result = "Ninety Eight";
            if ((rupees % 10) == 9) result = "Ninety Nine";
        }


        return result;
    }
    #endregion



    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
           
            GridView gv = (GridView)e.Row.FindControl("GridView1");

            Label tot = (Label)e.Row.FindControl("total1");
            int qty1 = Int32.Parse(tot.Text);

            amount = rupees(int.Parse(qty1.ToString()));



   
            Label lblprice = (Label)e.Row.FindControl("lblwords");
            lblprice.Text = amount.ToString();
            
        

       
        
<pre><pre lang="Delphi">

< br $>
}

}

}


}
}
}

推荐答案

protected void Page_Load(object sender, EventArgs e)
   {


       if (!IsPostBack)

       {

                       search = Request.QueryString["sr"];
             bind();
       }

   }

   public void bind()
   {


       try
       {
           obj.voucherno = search;
           obj.type = 13;
           //  obj.date = "DATE";


         //  string[] no = total1.Text.Split('.');

           ds = obj.exe_dataset();


           GridView1.DataSource = ds;
           GridView1.DataBind();

           //  amount = rupees(int.Parse());
       }

       catch (Exception ex)
       {
           throw ex;
       }


   }


这篇关于如何将十进制卢比转换为asp.net中的单词c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆