예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Gender,Age,Standard")] StudentTb studentTb)
        {
            if (id != studentTb.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(studentTb);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentTbExists(studentTb.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentTb));
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            StudentTb studentTb = db.StudentTbs.Find(id);

            db.StudentTbs.Remove(studentTb);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "StundentRegNo,StundentName")] StudentTb studentTb)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studentTb).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(studentTb));
 }
예제 #4
0
        public ActionResult Create([Bind(Include = "StundentRegNo,StundentName")] StudentTb studentTb)
        {
            if (ModelState.IsValid)
            {
                db.StudentTbs.Add(studentTb);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(studentTb));
        }
예제 #5
0
        public async Task <IActionResult> Create([Bind("Id,Name,Gender,Age,Standard")] StudentTb studentTb)
        {
            if (ModelState.IsValid)
            {
                _context.Add(studentTb);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentTb));
        }
예제 #6
0
        public ActionResult AddStudent(StudentTb s)
        {
            SqlParameter p1 = new SqlParameter("@fname", s.F_Name);
            SqlParameter p2 = new SqlParameter("@lname", s.L_Name);
            SqlParameter p3 = new SqlParameter("@father_name", s.Father_Name);
            SqlParameter p4 = new SqlParameter("@dob", s.DOB);
            SqlParameter p5 = new SqlParameter("@phone", s.Phone);
            SqlParameter p6 = new SqlParameter("@c_id", s.c_id);

            // ViewData["c_id"] = new SelectList(db.ClassTbs, "c_id", "Class_Name");
            db.Database.ExecuteSqlCommand("sp_insertStu @fname,@lname,@father_name,@dob,@phone,@c_id", p1, p2, p3, p4, p5, p6);
            // ViewBag.m = "data submit";
            return(RedirectToAction("Index"));
        }
예제 #7
0
        // GET: StudentTbs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentTb studentTb = db.StudentTbs.Find(id);

            if (studentTb == null)
            {
                return(HttpNotFound());
            }
            return(View(studentTb));
        }