コード例 #1
0
        public ActionResult EditDiemDanhHocSinh(int id, DateTime thoigian, string nguoiduadon, string trangthai, HttpPostedFileBase file)
        {
            DiemDanhHocSinh diemdanh = db.DiemDanhHocSinhs.Where(x => x.Id == id).FirstOrDefault();

            diemdanh.ThoiGian    = thoigian;
            diemdanh.NguoiDuaDon = nguoiduadon;
            diemdanh.DenVe       = trangthai;
            db.SaveChanges();

            string subPath = "~/Content/UserUpload/img/DiemDanhHocSinh/";
            bool   exists  = System.IO.Directory.Exists(Server.MapPath(subPath));

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(Server.MapPath(subPath));
            }
            try
            {
                if (file.ContentLength > 0)
                {
                    var path = Path.Combine(Server.MapPath(subPath), diemdanh.Id.ToString() + ".png");
                    file.SaveAs(path);
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("DiemDanhHocSinh"));
            }
            return(RedirectToAction("DiemDanhHocSinh"));
        }
コード例 #2
0
 public ActionResult DelDiemDanhHocSinh(int id)
 {
     try
     {
         DiemDanhHocSinh diemdanh = db.DiemDanhHocSinhs.Where(x => x.Id == id).FirstOrDefault();
         db.DiemDanhHocSinhs.Remove(diemdanh);
         db.SaveChanges();
         return(Json(new { Success = "true" }));
     }
     catch (Exception ex)
     {
         return(Json(new { Success = "false" }));
     }
 }
コード例 #3
0
        public ActionResult DiemDanhHocSinh(int HocSinh, DateTime thoigian, string nguoiduadon, string trangthai, HttpPostedFileBase file)
        {
            List <DiemDanhHocSinh> d = db.DiemDanhHocSinhs.Where(x => x.Id_HocSinh == HocSinh && EntityFunctions.TruncateTime(x.ThoiGian) == EntityFunctions.TruncateTime(thoigian)).ToList();

            if (d.Count() > 0)
            {
                foreach (var item in d)
                {
                    if (item.DenVe == trangthai)
                    {
                        return(View());
                    }
                }
            }
            DiemDanhHocSinh diemdanh = new DiemDanhHocSinh();

            diemdanh.Id_HocSinh       = HocSinh;
            diemdanh.ThoiGian         = thoigian;
            diemdanh.NguoiDuaDon      = nguoiduadon;
            diemdanh.DenVe            = trangthai;
            diemdanh.Id_NguoiDiemDanh = User.Identity.GetUserId();
            db.DiemDanhHocSinhs.Add(diemdanh);
            db.SaveChanges();

            string subPath = "~/Content/UserUpload/img/DiemDanhHocSinh/";
            bool   exists  = System.IO.Directory.Exists(Server.MapPath(subPath));

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(Server.MapPath(subPath));
            }
            try
            {
                if (file.ContentLength > 0)
                {
                    var path = Path.Combine(Server.MapPath(subPath), diemdanh.Id.ToString() + ".png");
                    file.SaveAs(path);
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("DiemDanhHocSinh"));
            }
            return(View());
        }
コード例 #4
0
        public int DiemDanhMotHocSinh(int HocSinh, DateTime thoigian, string nguoiduadon, string trangthai)
        {
            List <DiemDanhHocSinh> d = db.DiemDanhHocSinhs.Where(x => x.Id_HocSinh == HocSinh && EntityFunctions.TruncateTime(x.ThoiGian) == EntityFunctions.TruncateTime(thoigian)).ToList();

            if (d.Count() > 0)
            {
                foreach (var item in d)
                {
                    if (item.DenVe == trangthai)
                    {
                        return(1);
                    }
                }
            }
            DiemDanhHocSinh diemdanh = new DiemDanhHocSinh();

            diemdanh.Id_HocSinh       = HocSinh;
            diemdanh.ThoiGian         = thoigian;
            diemdanh.NguoiDuaDon      = nguoiduadon;
            diemdanh.DenVe            = trangthai;
            diemdanh.Id_NguoiDiemDanh = User.Identity.GetUserId();
            db.DiemDanhHocSinhs.Add(diemdanh);
            return(db.SaveChanges());
        }