Pages

Thursday, 9 February 2012

Retriving Fields From the DataBase Using Stored Procedure

SqlCommand cmd = new SqlCommand("Get_Ind_NewCarLoan", con);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter p1 = new SqlParameter("@pApplicationId", SqlDbType.Int);
        p1.Value = 1;
        cmd.Parameters.Add(p1);
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = cmd;
        con.Open();
        DataSet ds = new DataSet();
        da.Fill(ds, "Get_Ind_NewCarLoan");
        cmd.ExecuteNonQuery();
        if (ds.Tables[0].Rows.Count  > 0)
        {
            txtShowRoomName.Text=ds.Tables[0].Rows[0]["ShowRoomName"].ToString();
 txtVehicleName.Text=ds.Tables[0].Rows[0]["VehicleName"].ToString();
 txtVehicleNumber.Text=ds.Tables[0].Rows[0]["VehicleNumber"].ToString();
 txtYearOfManufacture.Text=ds.Tables[0].Rows[0]["YearOfManufacture"].ToString();
 txtExShowRoomPrice.Text=ds.Tables[0].Rows[0]["ExShowRoomPrice"].ToString();
 txtLifeTax.Text=ds.Tables[0].Rows[0]["LifeTax"].ToString();
 txtInsuranceVehicle.Text=ds.Tables[0].Rows[0]["InsuranceVehicle"].ToString();
 txtOnRoadPrice.Text=ds.Tables[0].Rows[0]["OnRoadPrice"].ToString();
 txtLoanAmount.Text=ds.Tables[0].Rows[0]["LoanAmount"].ToString();
 txtInsurance.Text=ds.Tables[0].Rows[0]["Insurance"].ToString();
 txtSuraksha.Text=ds.Tables[0].Rows[0]["Suraksha"].ToString();
txtOthers.Text=ds.Tables[0].Rows[0]["Others"].ToString();
 txtTotalLoanAmount.Text=ds.Tables[0].Rows[0]["TotalLoanAmount"].ToString();
 txtShowRoomAddress.Text=ds.Tables[0].Rows[0]["ShowRoomAddress"].ToString();
 txtProccesingFee.Text=ds.Tables[0].Rows[0]["ProccesingFee"].ToString();
 txtStampDuty.Text=ds.Tables[0].Rows[0]["StampDuty"].ToString();
 txtSuraksha1 .Text=ds.Tables[0].Rows[0]["SurakshaDeduction"].ToString();
 txtInsurance1 .Text=ds.Tables[0].Rows[0]["InsuranceDeduction"].ToString();
 txtAdvanceEmi.Text=ds.Tables[0].Rows[0]["AdvanceEmi"].ToString();
 txtOthers1 .Text=ds.Tables[0].Rows[0]["OthersDeduction"].ToString();
 txtNetDirsuburcementAmount.Text=ds.Tables[0].Rows[0]["NetDirsuburcementAmount"].ToString();
 txtLoanAmountDetails.Text=ds.Tables[0].Rows[0]["LoanAmountDetails"].ToString();
 txtTenure.Text=ds.Tables[0].Rows[0]["Tenure"].ToString();
 txtEmiAmount.Text=ds.Tables[0].Rows[0]["EmiAmount"].ToString();
 string s1 = ds.Tables[0].Rows[0]["Tenure1"].ToString();
 if (s1 == "ADVANCE"|| s1=="advance")
 {
     ddlTenure.SelectedIndex = 0;
 }
 else if(s1=="arears"||s1=="AREARS")
 {
     ddlTenure.SelectedIndex = 1;
 }
 txtRateOfInterest.Text=ds.Tables[0].Rows[0]["RateOfInterest"].ToString();
 txtLoadingAmount.Text=ds.Tables[0].Rows[0]["LoadingAmount"].ToString();
 txtNotepad.Text=ds.Tables[0].Rows[0]["Notepad"].ToString();
 con.Close();
 ImgBtnUpdate.Visible = false ;
 imgbtnSave.Visible = true;

        }

No comments:

Post a Comment