public ActionResult Create(Shopbridgedata1 shopbridgedata) { using (SqlConnection conn=new SqlConnection(myConnection)) { conn.Open(); string query = "Insert into ComponentsTable values(@product_name,@product_price,@product_description)"; SqlCommand cmd = new SqlCommand(query,conn); cmd.Parameters.AddWithValue("@product_name", shopbridgedata.product_name); cmd.Parameters.AddWithValue("@product_price", shopbridgedata.product_price); cmd.Parameters.AddWithValue("@product_description", shopbridgedata.product_description); cmd.ExecuteNonQuery(); } // TODO: Add insert logic here //Close the popup-window return Content(@"<body> <script type='text/javascript'> window.close(); </script> </body> "); }
// GET: ShopBridgeD/Details/5 public ActionResult Details(int id) //Display product Details passing Product_Id as parameters { Shopbridgedata1 shopBridgeData = new Shopbridgedata1(); DataTable dataTable = new DataTable(); using (SqlConnection conn = new SqlConnection(myConnection)) { conn.Open(); string query = "select * from ComponentsTable where product_id = @product_id"; SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(query, conn); sqlDataAdapter.SelectCommand.Parameters.AddWithValue("product_id", id); sqlDataAdapter.Fill(dataTable); } if (dataTable.Rows.Count == 1) { shopBridgeData.product_id = Convert.ToInt32(dataTable.Rows[0][0].ToString()); shopBridgeData.product_name = dataTable.Rows[0][1].ToString(); shopBridgeData.product_price = dataTable.Rows[0][2].ToString(); shopBridgeData.product_description = dataTable.Rows[0][3].ToString(); return View(shopBridgeData); } else return RedirectToAction("Index"); }