usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.Mvc;usingMvcApplication1.Models;namespaceMvcApplication1.Controllers

{public classHomeController : Controller

{//

//GET: /Home///主页视图

publicActionResult Index()

{

List list = newStudentDA().Select();//ViewBag.stu = new StudentDA().Select();

returnView(list);

}//修改页面视图

public ActionResult xiugai(string id)

{

// ViewBag.data = new StudentDA().Select(id);

student list = new StudentDA().Select(id);

return View(list);

}

//更新修改按钮动作

public ActionResult Update(string sno, string sname, string ssex, DateTime sbirthday, string class1)

{

try

{

new StudentDA().Update(sno, sname, ssex, sbirthday, class1);

return RedirectToAction("Index");

}

catch (Exception)

{

return RedirectToAction("chucuo", "Home");

}

}//删除动作

public ActionResult Delete(string id)

{

try

{

new StudentDA().Delete(id);

return RedirectToAction("Index");

}

catch (Exception)

{

return RedirectToAction("Decuowu", "Home");

}

}//增加页面视图

public ActionResult zengjia()

{

student a = new student();

return View(a);

}

//添加按钮动作

public ActionResult ADD(student a)

{

try

{

new StudentDA().Insert( a);

return RedirectToAction("Index");

}

catch (Exception)

{

return RedirectToAction("chucuo","Home");

}

}//错误页面视图

public ActionResult chucuo()

{

return View();

}//删除错误页面视图

publicActionResult Decuowu()

{returnView();

}//回到主页按钮动作

public ActionResult tiaozhuan()

{

return RedirectToAction("Index");

}

}

}

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐