Exemplo n.º 1
0
        // GET: Cumdancu/Edit/5
        public ActionResult Edit(int id)
        {
            Cumdancu cumdancu = db.Cumdancus.Find(id);

            ViewBag._QuanhuyenID = new SelectList(db.Quanhuyens.Where(p => p.IsDelete == false || p.IsDelete == null), "QuanhuyenID", "Ten");
            ViewBag._PhuongXaID  = new SelectList(db.Phuongxas.Where(p => p.IsDelete == false || p.IsDelete == null), "PhuongXaID", "Ten", cumdancu.PhuongxaID);
            return(View(cumdancu));
        }
Exemplo n.º 2
0
        // GET: Cumdancu/Delete/5
        public ActionResult Delete(int id)
        {
            Cumdancu cumDanCu = db.Cumdancus.Find(id);

            cumDanCu.IsDelete = true;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit(int id, FormCollection form)
 {
     try
     {
         // TODO: Add update logic here
         int    quanHuyenID = form["QuanHuyenID"] == null ? 0 : Convert.ToInt32(form["QuanHuyenID"]);
         int    phuongXaID  = form["PhuongXaID"] == null ? 0 : Convert.ToInt32(form["PhuongXaID"]);
         String name        = form["Ten"] == null ? "" : form["Ten"].ToString();
         // TODO: Add insert logic here
         Cumdancu cumdancu = db.Cumdancus.Find(id);
         cumdancu.Ten             = name;
         cumdancu.PhuongxaID      = phuongXaID;
         cumdancu.IsDelete        = false;
         db.Entry(cumdancu).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 4
0
 public ActionResult Create(FormCollection form)
 {
     try
     {
         int    quanHuyenID = form["QuanHuyenID"] == null ? 0 : Convert.ToInt32(form["QuanHuyenID"]);
         int    phuongXaID  = form["PhuongXaID"] == null ? 0 : Convert.ToInt32(form["PhuongXaID"]);
         String name        = form["Ten"] == null ? "" : form["Ten"].ToString();
         // TODO: Add insert logic here
         Cumdancu cumdancu = new Cumdancu();
         cumdancu.Ten        = name;
         cumdancu.PhuongxaID = phuongXaID;
         cumdancu.IsDelete   = false;
         db.Cumdancus.Add(cumdancu);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         ViewBag.QuanhuyenID = new SelectList(db.Quanhuyens.Where(p => p.IsDelete == false || p.IsDelete == null), "QuanhuyenID", "Ten");
         ViewBag.PhuongXaID  = new SelectList(db.Phuongxas.Where(p => p.IsDelete == false || p.IsDelete == null), "PhuongXaID", "Ten");
         return(View());
     }
 }