コード例 #1
0
        public ActionResult Save(GeosModel smodel)
        {
            GeosDBModel sdb = new GeosDBModel();

            if (smodel.id == 0)
            {
                // add logic
            }
            else
            {
                sdb.UpdateDetails(smodel);
            }
            return(RedirectToAction("index"));
        }
コード例 #2
0
        // GET: Geos
        public ActionResult Index(int?i, string search)
        {
            GeosDBModel   dbhandle   = new GeosDBModel();
            string        constring  = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            SqlConnection MySqlConn  = new SqlConnection(constring);
            string        MySqlQuery = "select * from tblEmployees  where Name Like '%" + search + "%'";
            SqlCommand    cmd        = new SqlCommand(MySqlQuery, MySqlConn);

            MySqlConn.Open();

            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet        ds  = new DataSet();

            sda.Fill(ds);
            List <GeosModel> gmodel = new List <GeosModel>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                gmodel.Add(
                    new GeosModel
                {
                    id       = Convert.ToInt32(dr["id"]),
                    Name     = Convert.ToString(dr["Name"]),
                    DeptName = Convert.ToString(dr["DeptName"]),
                    Gender   = Convert.ToString(dr["Gender"])
                });
            }
            if (gmodel.Count() == 0)
            {
                Response.Write("<script>alert('sorry no data foud')</script>");
            }
            MySqlConn.Close();
            ModelState.Clear();
            return(View(gmodel.ToList()));

            //return View(dbHandle.GetStudent());
        }