MANEESH AN

MANEESH AN

  • NA
  • 110
  • 47.3k

combo add the collection select display grid but amount

Jul 18 2013 6:22 AM
form combo and button and grid add****** (PLESE CORECT THE STORE PROCEDURE)


   public partial class frmCustomerDisplay : Form
    {
       
        public frmCustomerDisplay( )
        {
          
            InitializeComponent();
        }

        decimal dcLoan_Amt ;

        LoanEntryBL objLoanEntryBL = new LoanEntryBL();
        private void btnExit_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void frmCustomerDisplay_Load(object sender, EventArgs e)
        {
     
          
        }
        decimal start;
        decimal last;
        private void button1_Click(object sender, EventArgs e)
        {

            if (comboBox1. Text== " 0 - 5000")
            {

                start = 0;
                last = 5000;
            }
            else if (comboBox1.Text == "5000 - 10000")
            {
                start = 5000;
                last = 10000;
            }
            else if (comboBox1.Text == "10000 - 25000")
            {
                start=10000;
                last=25000;
            }
            else if(comboBox1.Text=="25000 - 100000")
            {
                start=25000;
                last=100000;
            }
              
                DataTable dt = new DataTable();
                dt = objLoanEntryBL.fnLoanAmountDisplay(dcLoan_Amt,start,last);
                dataGridView1.DataSource = dt;

                dataGridView1.Columns[0].Width = 80;
                dataGridView1.Columns[1].Width = 280;
                dataGridView1.Columns[2].Width = 71;
                dataGridView1.Columns[3].Width = 148;

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            fndisplay(dcLoan_Amt, start, last);

        }
         
   
        private void fndisplay(decimal dcLoan_Amt, decimal start, decimal last)
        {
            DataTable dt = new DataTable();
            dt = null;
            dt = objLoanEntryBL.fnLoanAmountDisplay(dcLoan_Amt, start, last);
        }
      
    }

BL**********

    public DataTable fnLoanAmountDisplay(decimal dcLoan_Amt, decimal start, decimal last)
      {
            DataTable dt = new DataTable();
            dt = objLoanEntryDL.fnLoanAmountDisplay(dcLoan_Amt,start,last);
            return dt;
        }
 
DL***********

      public DataTable fnLoanAmountDisplay(decimal dcLoan_Amt,decimal start,decimal last)
        {
            Connection con = new Connection();
            con.OpenConnection();          
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con.conSql;
            cmd.CommandText = "sp_loans ";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@dcLoan_Amt", dcLoan_Amt);
            cmd.Parameters.AddWithValue("@start", start);
            cmd.Parameters.AddWithValue("@last", last);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            //da.SelectCommand = cmd;
            da.Fill(dt);
            con.CloseConnection();
            return dt;
        }


STORE PROCEDURE
********************

Alter PROCEDURE sp_loans              
 (             
 @dcLoan_Amt decimal(18,2)
,             
@start decimal ,
@last decimal     
--      
 )             
AS             
 begin         
 select  vLoan_No as LoanNumber ,vParty_Id as CustomerName,dIssue_Date as DissueDate,dcLoan_Amt as LoanAmount from tbl_LoanMaster             
where  @dcLoan_Amt between @start and  @last
END



Answers (3)