Click here to Skip to main content
15,895,864 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
C#
protected void txt_fdbookamt_TextChanged(object sender, EventArgs e)
    {
        DataSet ds2 = obj.returndataset("select rd_min_book_amount,rd_multiple_of,rd_total_book_amount,rd_credit_value,term_type,increment,rd_total_entry,fd_min_book_amount,fd_multiple_of,fd_total_book_amount,fd_credit_value,fd_total_entry,mi_return_amount,mi_return_mode,total_dividends from term_master where scheme = '" + drp_plan.SelectedValue.ToString().Trim() + "' AND term='" + drp_term.SelectedItem.Text.ToString() + "' AND nplan = '" + DropDownList1.SelectedItem.Text.Trim() + "' AND status='0'");
        int rd_rbook_amt, mi_value, rd_rcredit_value, fd_rbookamt, rd_credit_value, fd_credit_value, fd_rcredit_value, rd_book_amt, fd_book_amt, rd_min_book_amount, rd_multiple_of, rd_total_book_amount, fd_min_book_amount, fd_total_book_amount, mi_return_amount;
        mi_value = fd_rcredit_value = rd_rbook_amt = rd_rcredit_value = rd_credit_value = fd_credit_value = fd_rbookamt = rd_book_amt = fd_book_amt = rd_min_book_amount = rd_multiple_of = rd_total_book_amount = fd_min_book_amount = fd_total_book_amount = mi_return_amount = 0;
        int fd_multiple_of, rd_total_entry, fd_total_entry, total_dividends;
        rd_multiple_of = fd_multiple_of = rd_total_entry = fd_total_entry = total_dividends = 0;

        string mi_returnmode;
        mi_returnmode = ds2.Tables[0].Rows[0]["mi_return_mode"].ToString();
        total_dividends = Convert.ToInt32(ds2.Tables[0].Rows[0]["total_dividends"].ToString());
        rd_min_book_amount = Convert.ToInt32(ds2.Tables[0].Rows[0]["rd_min_book_amount"].ToString());
        rd_multiple_of = Convert.ToInt32(ds2.Tables[0].Rows[0]["rd_multiple_of"].ToString());

        double rd_total_book_amount12 = Convert.ToDouble(ds2.Tables[0].Rows[0]["rd_total_book_amount"].ToString());
        rd_total_book_amount = Convert.ToInt32(rd_total_book_amount12);

        double rd_credit_value12 = Convert.ToDouble(ds2.Tables[0].Rows[0]["rd_credit_value"].ToString());
        rd_credit_value = Convert.ToInt32(rd_credit_value12);

        fd_credit_value = Convert.ToInt32(ds2.Tables[0].Rows[0]["fd_credit_value"].ToString());
        string term_type = ds2.Tables[0].Rows[0]["term_type"].ToString();
        rd_book_amt = Convert.ToInt32(txt_rdbookamt.Text.Trim());
        fd_book_amt = Convert.ToInt32(txt_fdbookamt.Text.Trim());
        fd_min_book_amount = Convert.ToInt32(ds2.Tables[0].Rows[0]["fd_min_book_amount"].ToString());
        int increment = Convert.ToInt32(ds2.Tables[0].Rows[0]["increment"].ToString());
        rd_total_entry = Convert.ToInt32(ds2.Tables[0].Rows[0]["rd_total_entry"].ToString());
        fd_total_entry = Convert.ToInt32(ds2.Tables[0].Rows[0]["fd_total_entry"].ToString());
        fd_multiple_of = Convert.ToInt32(ds2.Tables[0].Rows[0]["fd_multiple_of"].ToString());
        fd_total_book_amount = Convert.ToInt32(ds2.Tables[0].Rows[0]["fd_total_book_amount"].ToString());
        mi_return_amount = Convert.ToInt32(ds2.Tables[0].Rows[0]["mi_return_amount"].ToString());
        double ard, afd;
        int brd, bfd;
                
            if (fd_book_amt < fd_min_book_amount)
            {
                lbl_err.Text = "FD Booking Amount is very little";
            }
            else
            {
                ard = 0;
                afd = System.Math.DivRem(fd_book_amt, fd_multiple_of, out bfd);
                if (bfd == 0)
                {
                    lbl_err.Text = "";
                    fd_rbookamt = Convert.ToInt32(afd) * fd_total_book_amount;
                    fd_rcredit_value = Convert.ToInt32(afd) * fd_credit_value;
                    mi_value = Convert.ToInt32(afd) * mi_return_amount;

                    TextBox6.Text = fd_rbookamt.ToString().Trim();
                    TextBox7.Text = fd_rcredit_value.ToString().Trim();

                    if (Label2.Text == "MIS")
                    {
                        Label3.Text = "MIS Return Amount is : " + mi_value.ToString().Trim();
                    }
                    else
                    {
                        Label3.Text = "";
                    }
                }
                else
                {                  
                    lbl_err.Text = "Enter a correct Booking Amount !";
                }
            }
            TextBox8.Focus();
       
    }
    protected void txt_rdbookamt_TextChanged(object sender, EventArgs e)
    {
        DataSet ds2 = obj.returndataset("select rd_min_book_amount,rd_multiple_of,rd_total_book_amount,rd_credit_value,term_type,increment,rd_total_entry,fd_min_book_amount,fd_multiple_of,fd_total_book_amount,fd_credit_value,fd_total_entry,mi_return_amount,mi_return_mode,total_dividends from term_master where scheme = '" + drp_plan.SelectedValue.ToString().Trim() + "' AND term='" + drp_term.SelectedItem.Text.ToString() + "' AND nplan = '" + DropDownList1.SelectedItem.Text.Trim() + "' AND status='0'");
        int rd_rbook_amt, mi_value, rd_rcredit_value, fd_rbookamt, rd_credit_value, fd_credit_value, fd_rcredit_value, rd_book_amt, fd_book_amt, rd_min_book_amount, rd_multiple_of, rd_total_book_amount, fd_min_book_amount, fd_total_book_amount, mi_return_amount;
        mi_value = fd_rcredit_value = rd_rbook_amt = rd_rcredit_value = rd_credit_value = fd_credit_value = fd_rbookamt = rd_book_amt = fd_book_amt = rd_min_book_amount = rd_multiple_of = rd_total_book_amount = fd_min_book_amount = fd_total_book_amount = mi_return_amount = 0;
        int fd_multiple_of, rd_total_entry, fd_total_entry, total_dividends;
        rd_multiple_of = fd_multiple_of = rd_total_entry = fd_total_entry = total_dividends = 0;

        string mi_returnmode;
        mi_returnmode = ds2.Tables[0].Rows[0]["mi_return_mode"].ToString();
        total_dividends = Convert.ToInt32(ds2.Tables[0].Rows[0]["total_dividends"].ToString());
        rd_min_book_amount = Convert.ToInt32(ds2.Tables[0].Rows[0]["rd_min_book_amount"].ToString());
        rd_multiple_of = Convert.ToInt32(ds2.Tables[0].Rows[0]["rd_multiple_of"].ToString());

        double rd_total_book_amount12 = Convert.ToDouble(ds2.Tables[0].Rows[0]["rd_total_book_amount"].ToString());
        rd_total_book_amount = Convert.ToInt32(rd_total_book_amount12);

        double rd_credit_value12 = Convert.ToDouble(ds2.Tables[0].Rows[0]["rd_credit_value"].ToString());
        rd_credit_value = Convert.ToInt32(rd_credit_value12);

        fd_credit_value = Convert.ToInt32(ds2.Tables[0].Rows[0]["fd_credit_value"].ToString());
        string term_type = ds2.Tables[0].Rows[0]["term_type"].ToString();
        rd_book_amt = Convert.ToInt32(txt_rdbookamt.Text.Trim());
        fd_book_amt = Convert.ToInt32(txt_fdbookamt.Text.Trim());
        fd_min_book_amount = Convert.ToInt32(ds2.Tables[0].Rows[0]["fd_min_book_amount"].ToString());
        int increment = Convert.ToInt32(ds2.Tables[0].Rows[0]["increment"].ToString());
        rd_total_entry = Convert.ToInt32(ds2.Tables[0].Rows[0]["rd_total_entry"].ToString());
        fd_total_entry = Convert.ToInt32(ds2.Tables[0].Rows[0]["fd_total_entry"].ToString());
        fd_multiple_of = Convert.ToInt32(ds2.Tables[0].Rows[0]["fd_multiple_of"].ToString());
        fd_total_book_amount = Convert.ToInt32(ds2.Tables[0].Rows[0]["fd_total_book_amount"].ToString());
        mi_return_amount = Convert.ToInt32(ds2.Tables[0].Rows[0]["mi_return_amount"].ToString());
        double ard, afd;
        int brd, bfd;

        if (rd_min_book_amount > 0)
        {
            if (rd_book_amt < rd_min_book_amount)
            {
                lbl_err.Text = "RD Booking Amount is very little";
            }
            else
            {
                ard = System.Math.DivRem(rd_book_amt, rd_multiple_of, out brd);
                afd = 0;
                if (brd == 0)
                {
                    lbl_err.Text = "";
                    rd_rbook_amt = Convert.ToInt32(ard) * rd_total_book_amount;
                    rd_rcredit_value = Convert.ToInt32(ard) * rd_credit_value;

                    TextBox6.Text = rd_rbook_amt.ToString().Trim();
                    TextBox7.Text = rd_rcredit_value.ToString().Trim();
                }
                else
                {                    
                    lbl_err.Text = "Enter a correct Booking Amount !";
                }
            }
        }
        else
        {
           
        }
        TextBox8.Focus();
    }   
}
Posted
Updated 18-Jul-12 3:15am
v2
Comments
sandeep nagabhairava 18-Jul-12 8:59am    
hi no one give reply for this post, because you need to post question in short. no one as patience for understanding this much large question. please explore your question where exactly you facing the problem...
[no name] 18-Jul-12 9:16am    
This is just a code dump and not a question.

Obviously the line

mi_returnmode = ds2.Tables[0].Rows[0]["mi_return_mode"].ToString();

in either one/both of the methods accesses a table with no rows.
 
Share this answer
 
Check for the existence of rows in the table before looking for values on those rows. For example:

if (ds2.Tables[0].Rows.Count > 0) {
  mi_returnmode = ds2.Tables[0].Rows[0]["mi_return_mode"].ToString();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900