//[ActionName("BeneficiaryOwnerView")]
 public ActionResult BeneficiaryOwnerView()
 {
     try
     {
         ViewData["Message"] = " ";
         BeneficiaryBusinessLayer boBL    = new BeneficiaryBusinessLayer();
         Beneficiary_ownership    boModel = new Beneficiary_ownership();
         UpdateModel(boModel);
         boBL.InsertBoData(boModel.first_name, boModel.last_name, boModel.email, boModel.phone, boModel.role, boModel.business_id);
         //Session["bname"] = buModel.business_name;
         ViewData["Message"] = "BeneficiaryOwner  Data is submitted Successfully";
         return(RedirectToRoute(new
         {
             controller = "Summary",
             action = "SummaryView",
             bid = Session["bid"]
         }));
         //return View(buModel);
     }
     catch
     {
         ViewData["Message"] = "Processing Failed";
         BeneficiaryDataAccess.sqlcon.Close();
         return(View());
     }
 }
        public ActionResult BeneficiaryOwnerView(string bid)
        {
            BeneficiaryBusinessLayer boBl    = new BeneficiaryBusinessLayer();
            Beneficiary_ownership    boModel = boBl.GetBodata(bid);

            return(View(boModel));
        }
        public Beneficiary_ownership GetBodata(string bid)
        {
            BeneficiaryDataAccess boDL    = new BeneficiaryDataAccess();
            SqlDataReader         sdr     = boDL.ReadBoDetail(bid);
            Beneficiary_ownership boModel = new Beneficiary_ownership();

            if (sdr.Read())
            {
                boModel.business_id = Convert.ToInt32(sdr["business_id"]);
            }
            BeneficiaryDataAccess.sqlcon.Close();
            return(boModel);
        }
 public ActionResult BeneficiaryOwnerView(Beneficiary_ownership BO)
 {
     if (ModelState.IsValid) //checking model is valid or not
     {
         DataAccessLayer objDB  = new DataAccessLayer();
         string          result = objDB.InsertBeneficiaryData(BO);
         ViewData["result"] = result;
         ModelState.Clear(); //clearing model
         //return View();
         return(RedirectToAction("SummaryView", "Summary", new { bid = @Session["b_id"] }));
     }
     else
     {
         ModelState.AddModelError("", "Error in saving data");
         return(View());
     }
 }
        public ActionResult BeneficiaryOwnerView(string bid)
        {
            Beneficiary_ownership boObj = new Beneficiary_ownership();

            using (SqlConnection con = new SqlConnection("Data Source=RAHUL\\SQLEXPRESS01;Initial Catalog=Commercial;Integrated Security=True"))
            {
                string sqlQuery = "select * from BUSINESS where business_id='" + bid + "'";
                con.Open();
                SqlCommand    sqlCmd = new SqlCommand(sqlQuery, con);
                SqlDataReader sdr    = sqlCmd.ExecuteReader();
                if (sdr.Read())
                {
                    boObj.business_id = Convert.ToInt32(sdr["business_id"]);
                }
                con.Close();
            }
            return(View(boObj));
        }
        public string InsertBeneficiaryData(Beneficiary_ownership bo)
        {
            string result = "";

            using (SqlConnection con = new SqlConnection("Data Source=RAHUL\\SQLEXPRESS01;Initial Catalog=Commercial;Integrated Security=True"))
            {
                string query = "INSERT INTO BENEFICIARY_OWNERSHIP(first_name,last_name,email,phone_number,role,business_id) VALUES(@fname, @lname, @email, @phone,@role,@business_id)";
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    cmd.Connection = con;
                    // opening connection
                    con.Open();
                    cmd.Parameters.AddWithValue("@fname", bo.first_name);
                    cmd.Parameters.AddWithValue("@lname", bo.last_name);
                    cmd.Parameters.AddWithValue("@email", bo.email);
                    cmd.Parameters.AddWithValue("@phone", bo.phone);
                    cmd.Parameters.AddWithValue("@role", bo.role);
                    cmd.Parameters.AddWithValue("@business_id", bo.business_id);
                    cmd.ExecuteNonQuery();
                }
                con.Close();
            }
            return(result);
        }