Exemplo n.º 1
0
 public ActionResult Create(TAIKHOANQUANTRIVIEN admin)
 {
     if (ModelState.IsValid)
     {
         try
         {
             // TODO: Add insert logic here
             if (admin.ImageUpload != null)
             {
                 string file      = Path.GetFileNameWithoutExtension(admin.ImageUpload.FileName);
                 string extension = Path.GetExtension(admin.ImageUpload.FileName);
                 file = file + extension;
                 admin.ANH_DAIDIEN = "/Content/Images/" + file;
                 //pro.MoreImages= "~/Contents/images/" + file;
                 admin.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/Content/Images/"), file));
             }
             admin.MATKHAU = GetMD5(admin.MATKHAU);
             db.Configuration.ValidateOnSaveEnabled = false;
             db.TAIKHOANQUANTRIVIENs.Add(admin);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (Exception)
         {
             return(View());
         }
     }
     return(View(admin));
 }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            TAIKHOANQUANTRIVIEN ad = db.TAIKHOANQUANTRIVIENs.Find(id);

            db.TAIKHOANQUANTRIVIENs.Remove(ad);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public RedirectToRouteResult Index(TAIKHOANQUANTRIVIEN tk)
        {
            var check = db.TAIKHOANQUANTRIVIENs.Where(temp => temp.TEN_DANGNHAP == tk.TEN_DANGNHAP && temp.MATKHAU == tk.MATKHAU).FirstOrDefault();

            if (check != null)
            {
                return(RedirectToRoute(new { controller = "Books", action = "Index" }));
            }
            return(RedirectToRoute(new { controller = "Login", action = "Index" }));
        }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "ID_QUANTRIVIEN,TEN_DANGNHAP,MATKHAU,TEN_QUANTRIVIEN,ANH_DAIDIEN")] TAIKHOANQUANTRIVIEN ad)
 {
     if (ModelState.IsValid)
     {
         ad.MATKHAU = GetMD5(ad.MATKHAU);
         db.Configuration.ValidateOnSaveEnabled = false;
         db.Entry(ad).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ad));
 }
Exemplo n.º 5
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TAIKHOANQUANTRIVIEN ad = db.TAIKHOANQUANTRIVIENs.Find(id);

            if (ad == null)
            {
                return(HttpNotFound());
            }
            return(View(ad));
        }
Exemplo n.º 6
0
        // GET: Administrator/USER/Create
        public ActionResult Create()
        {
            TAIKHOANQUANTRIVIEN t = new TAIKHOANQUANTRIVIEN();

            return(View(t));
        }