コード例 #1
0
 public ActionResult Insert()
 {
     AdminGhiChuModel tnew = new AdminGhiChuModel();
     dbFirstStepDataContext db = new dbFirstStepDataContext();
     ViewBag.DanhMuc = db.EntityUsers.ToList();
     return View();
 }
コード例 #2
0
 public ActionResult Edit(AdminGhiChuModel DM, HttpPostedFileBase Image)
 {
     try
     {
         if (Image != null)
         {
             ImageHelper imgHelper = new ImageHelper();
             string encodestring = imgHelper.encodeImageFile(Image);
             if (encodestring == "!")
                 return RedirectToAction("Index", "Error", new { errorMsg = "Can't upload Images" });
             var path = Path.Combine(Server.MapPath("~/Content/Images/GhiChu"), encodestring);
             Image.SaveAs(path);
             DM.HinhAnh = encodestring;
             DM.IdUser = null;
         }
         else
         {
             DM.IdUser = DM.IdUser > 0 ? DM.IdUser : null;
         }
         AdminGhiChuModel.Edit(DM);
         return RedirectToAction("Index", "AdminGhiChu");
     }
     catch
     {
         return RedirectToAction("Index", "Error");
     }
 }
コード例 #3
0
 public ActionResult Edit(int Id)
 {
     AdminGhiChuModel tnew = new AdminGhiChuModel();
     dbFirstStepDataContext db = new dbFirstStepDataContext();
     ViewBag.DanhMuc = db.EntityUsers.ToList();
     return View(AdminGhiChuModel.LayModel(Id));
 }
コード例 #4
0
 public static void Edit(AdminGhiChuModel Banner)
 {
     dbFirstStepDataContext db = new dbFirstStepDataContext();
     EntityQuote Faq = db.EntityQuotes.Where(p => p.Id == Banner.Id).First();
     Faq.IdUser = Banner.IdUser;
     Faq.Image = Banner.HinhAnh;
     Faq.NoiDung = Banner.NoiDung;
     db.SubmitChanges();
 }
コード例 #5
0
 public static AdminGhiChuModel LayModel(int Id)
 {
     AdminGhiChuModel Ban = new AdminGhiChuModel();
     dbFirstStepDataContext db = new dbFirstStepDataContext();
     EntityQuote tnew = db.EntityQuotes.Where(p => p.Id == Id).First();
     Ban.Id = tnew.Id;
     Ban.IdUser = tnew.IdUser;
     Ban.HinhAnh = tnew.Image;
     Ban.NoiDung = tnew.NoiDung;
     return Ban;
 }
コード例 #6
0
        public ActionResult Insert(AdminGhiChuModel DM, HttpPostedFileBase Image)
        {
            try
            {
                dbFirstStepDataContext db = new dbFirstStepDataContext();
                EntityQuote ban = new EntityQuote();
                if (Image != null)
                {
                    ImageHelper imgHelper = new ImageHelper();
                    string encodestring = imgHelper.encodeImageFile(Image);
                    db.SubmitChanges();
                    if (encodestring == "!")
                        return RedirectToAction("Index", "Error", new { errorMsg = "Can't upload Images" });
                    var path = Path.Combine(Server.MapPath("~/Content/Images/GhiChu"), encodestring);
                    Image.SaveAs(path);
                    ban.Image = encodestring;
                    ban.IdUser = null;
                }
                else
                {
                    ban.IdUser = DM.IdUser>0?DM.IdUser:null;
                }
                ban.NoiDung = DM.NoiDung;
                db.EntityQuotes.InsertOnSubmit(ban);
                db.SubmitChanges();

                return RedirectToAction("Index", "AdminGhiChu");
            }
            catch
            {
                return RedirectToAction("Index", "Error");
            }
        }