コード例 #1
0
        public ActionResult SearchHospital()
        {
            ViewBag.searchresult = "";
            SearchHospital sd = new SearchHospital();

            sd.h_name   = "";
            sd.location = "";
            sd.contact  = "";
            sd.spec1    = "";
            sd.spec2    = "";
            sd.spec3    = "";
            return(View(sd));
        }
コード例 #2
0
        public ActionResult SearchHospital(String h_name)
        {
            SearchHospital sd      = new SearchHospital();
            String         mycon   = "Data Source=DESKTOP-QVFT4VM\\SQLEXPRESS; Initial Catalog=Doctors247; Integrated Security=True";
            String         myquery = "Select * from hospital where h_name='" + h_name + "'";
            SqlConnection  con     = new SqlConnection(mycon);
            SqlCommand     cmd     = new SqlCommand();

            cmd.CommandText = myquery;
            cmd.Connection  = con;
            SqlDataAdapter da = new SqlDataAdapter();

            da.SelectCommand = cmd;
            DataSet ds = new DataSet();

            da.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                ViewBag.searchresult = "The desired Hospital info Has Been Found";
                sd.h_name            = h_name;
                sd.location          = ds.Tables[0].Rows[0]["location"].ToString();
                sd.contact           = ds.Tables[0].Rows[0]["contact"].ToString();
                sd.spec1             = ds.Tables[0].Rows[0]["spec1"].ToString();
                sd.spec2             = ds.Tables[0].Rows[0]["spec2"].ToString();
                sd.spec3             = ds.Tables[0].Rows[0]["spec3"].ToString();
            }
            else
            {
                return(Redirect("Hospital"));

                ViewBag.searchresult = "The desired Hospital info Has Not Found";
            }
            con.Close();



            return(View(sd));
        }