示例#1
0
 //
 // GET: /Home/Details/5
 public ActionResult Details(int id)
 {
     SampleContext db = new SampleContext();
     tblEmployee emplo =  db.tblEmployee.Single(x => x.Id == id);
     //ViewData["EmployeeData"] = emplo;
     //@Html.Display("EmployeeData")
     return View(emplo);
 }
示例#2
0
        public ActionResult Edit(tblEmployee emplo)
        {
            try
            {
                SampleContext db = new SampleContext();
                if (ModelState.IsValid)
                {
                    db.tblEmployee.Attach(emplo);
                    db.ObjectStateManager.ChangeObjectState(emplo, EntityState.Modified);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                else
                {
                    return View();
                }

            }
            catch
            {
                return View();
            }
        }
示例#3
0
 //
 // GET: /Home/Edit/5
 public ActionResult Edit(int id)
 {
     SampleContext db = new SampleContext();
     tblEmployee employee = db.tblEmployee.Single(x => x.Id == id);
     return View(employee);
 }
示例#4
0
 //
 // GET: /Home/
 public ActionResult Index()
 {
     SampleContext db = new SampleContext();
     return View(db.tblEmployee.ToList());
 }