Ejemplo n.º 1
0
 public static bool SuaTheLoai(TheLoaiDTO tl)
 {
     if (TheLoaiDAO.GetTheLoaiByMa(tl.MaTheLoai) != null)
     {
         TheLoaiDAO.Update(tl);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public ActionResult Update(TheLoai obj, HttpPostedFileBase file)
        {
            try
            {
                TheLoaiDAO dao = new TheLoaiDAO();
                if (file != null && file.ContentLength > 0)
                {
                    string fileName = Path.GetFileNameWithoutExtension(file.FileName);
                    fileName += "_" + obj.IdTheLoai;
                    fileName += Path.GetExtension(file.FileName);

                    string folderPath = Server.MapPath("~") + @"\Assets\images\genrs";

                    if (!Directory.Exists(folderPath))
                    {
                        Directory.CreateDirectory(folderPath);
                    }

                    string path = Path.Combine(folderPath, fileName);

                    file.SaveAs(path);
                    obj.AnhTheLoai = fileName;
                    if (dao.Update(obj))
                    {
                        return(RedirectToAction("Index", "TheLoai"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Error");
                        return(View(obj.IdTheLoai));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Bạn phải nhập vào trường này");
                }
            }
            catch
            {
            }
            return(View());
        }
Ejemplo n.º 3
0
 public void Update(TheLoai info)
 {
     data.Update(info);
 }
Ejemplo n.º 4
0
 public int Update(TheLoai obj)
 {
     return(DAO.Update(obj));
 }