Exemplo n.º 1
0
        public ActionResult Edit(int id, kythu collection)
        {
            if (ModelState.IsValid)
            {
                var dao = new KyThuDao();



                var result = dao.Update(collection, id);
                if (result)
                {
                    return(RedirectToAction("Index", "KyThu"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật không thành công");
                }
            }
            return(View("Index"));
        }
Exemplo n.º 2
0
        public ActionResult Create(kythu collection)
        {
            if (ModelState.IsValid)
            {
                var dao = new KyThuDao();



                long id = dao.Insert(collection);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "KyThu"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm Kỳ Thu không thành công");
                }
            }
            return(View("Index"));
        }
Exemplo n.º 3
0
        public bool Update(kythu entity, int id)
        {
            try
            {
                var thu = db.kythus.Find(id);
                thu.k_id         = entity.k_id;
                thu.kt_lanthu    = entity.kt_lanthu;
                thu.kt_ngaythu   = entity.kt_ngaythu;
                thu.kt_trangthai = entity.kt_trangthai;



                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                //logging
                return(false);
            }
        }
Exemplo n.º 4
0
 public long Insert(kythu entity)
 {
     db.kythus.Add(entity);
     db.SaveChanges();
     return(entity.kt_id);
 }
Exemplo n.º 5
0
        public ActionResult Delete(int id, kythu collection)
        {
            new KyThuDao().Delete(id);

            return(RedirectToAction("Index", "KyThu"));
        }