Example #1
0
    protected void ConvertToWord(string numericvalue)
    {
        try
        {
            MultiCurrency OMultiCurrency = new MultiCurrency(Criteria.Indian);

            string   digit        = numericvalue.Trim();
            string   FinalValue   = string.Empty;
            string[] decimlacount = digit.Split('.');
            if (decimlacount.Length > 2)
            {
                FinalValue = "Only one decimal point allowed";
            }
            else if (decimlacount.Length == 1)
            {
                FinalValue = OMultiCurrency.ConvertToWord(digit, System.Drawing.Color.Black);
            }
            else
            {
                if (decimlacount[1].ToString() == "00")
                {
                    FinalValue = OMultiCurrency.ConvertToWord(digit.Substring(0, digit.IndexOf('.')), System.Drawing.Color.Black) + "Rupees Only";
                }
                else
                {
                    FinalValue     = OMultiCurrency.ConvertToWord(digit.Substring(0, digit.IndexOf('.')), System.Drawing.Color.Black);
                    FinalValue     = FinalValue + "Rupees and ";
                    OMultiCurrency = new MultiCurrency(Criteria.Indian);
                    FinalValue     = FinalValue + OMultiCurrency.ConvertToWord(digit.Substring(digit.IndexOf('.') + 1), System.Drawing.Color.Black);
                    FinalValue     = FinalValue + "Paisa Only";
                }
            }
            lblnumericstring.Text += FinalValue;
        }
        catch (Exception ex)
        {
        }
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Contents.Count == 0)
        {
            Response.Redirect("ShowMessage.aspx?msg=" + GlobalConstants.msg);
        }
        else
        {
            if (!IsPostBack)
            {
                if (Session["table"] != null)
                {
                    DataTable dtnew = new DataTable();
                    dtnew = (DataTable)Session["table"];
                    int sno = 1;
                    for (int j = 0; j < dtnew.Rows.Count; j++)
                    {
                        dtnew.Rows[j]["Sno"] = sno++;
                        double amt = Convert.ToDouble(dtnew.Rows[j]["TRND_AMOUNT"]);
                        dtnew.Rows[j]["TRND_AMOUNT"] = String.Format("{0:0.00}", Convert.ToDouble(dtnew.Rows[j]["TRND_AMOUNT"]));
                    }
                    DataRow row    = dtnew.NewRow();
                    string  stramt = String.Format("{0:0.00}", Convert.ToDouble(dtnew.Compute("Sum(TRND_AMOUNT)", "")));
                    row["TRND_AMOUNT"]           = String.Format("{0:0.00}", Convert.ToDouble(dtnew.Compute("Sum(TRND_AMOUNT)", "")));
                    row["TRND_INSTRUMENTNUMBER"] = "T O T A L";
                    dtnew.Rows.Add(row);
                    //*******total*******

                    //********amount conversion***********

                    MultiCurrency currenc = new MultiCurrency(Criteria.Indian);
                    string        number  = stramt;
                    string[]      ss      = number.Split('.');
                    if (ss.Length == 1)
                    {
                        number = number + ".00";
                    }
                    string[] amount        = number.Split('.');
                    string   AmountInWords = currenc.ConvertToWord(amount[0]);
                    string   paises;
                    AmountInWords = AmountInWords + " Rupees";
                    if (int.Parse(amount[1]) == 0)
                    {
                        amount[1] = "00";
                        paises    = "";
                    }
                    else
                    {
                        paises = currenc.ConvertToWord(amount[1]);
                        paises = " And " + paises + " Paises";
                    }
                    AmountInWords = AmountInWords + paises;
                    //****************


                    lblManager.Text      = Session["Manager"].ToString();
                    Label1.Text          = global.BankName();
                    Label6.Text          = Label1.Text;
                    Label5.Text          = DateTime.Now.ToString();
                    lblAmount.Text       = AmountInWords.ToString();
                    Label2.Text          = Session["branch"].ToString();
                    Label3.Text          = Session["frmdate"].ToString();
                    Label4.Text          = Session["todate"].ToString();
                    lblFrmDate.Text      = Session["frmdate"].ToString();
                    lblToDate.Text       = Session["todate"].ToString();
                    GridView1.DataSource = dtnew;
                    GridView1.DataBind();
                    objfrmpt.FormatGridView(GridView1);
                }
            }
        }
    }