Ejemplo n.º 1
0
        public ActionResult edit(DM_BaoCaoTieuChuan bctc)
        {
            if (String.IsNullOrEmpty(bctc.MoDau) || String.IsNullOrEmpty(bctc.MoDau))
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Missing info"
                }, JsonRequestBehavior.AllowGet));
            }

            var check = db.DM_BaoCaoTieuChuan.Where(p => p.NamHoc == NamHoc && p.IDTieuChuan == bctc.IDTieuChuan && p.MaTruong == MaTruong).FirstOrDefault();

            if (check == null)
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Không tìm thấy thông tin"
                }, JsonRequestBehavior.AllowGet));
            }

            check.IDTieuChuan = bctc.IDTieuChuan;
            check.MoDau       = bctc.MoDau;
            check.KetLuan     = bctc.KetLuan;

            db.Entry(check).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(Json(new ResultInfo()
            {
                error = 0, msg = "", data = check
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult create(DM_BaoCaoTieuChuan bctc)
        {
            if (String.IsNullOrEmpty(bctc.MoDau) || String.IsNullOrEmpty(bctc.MoDau))
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Missing info"
                }, JsonRequestBehavior.AllowGet));
            }

            var check = db.DM_BaoCaoTieuChuan.Where(p => p.NamHoc == NamHoc && p.IDTieuChuan == bctc.IDTieuChuan && p.MaTruong == MaTruong).FirstOrDefault();

            if (check != null)
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Đã tồn tại"
                }, JsonRequestBehavior.AllowGet));
            }

            //kiem tra neu  la nam hoc hien tai thi xoa nhưng cai con lai

            bctc.MaTruong = MaTruong;
            bctc.NamHoc   = NamHoc;
            db.DM_BaoCaoTieuChuan.Add(bctc);
            db.SaveChanges();

            return(Json(new ResultInfo()
            {
                error = 0, msg = "", data = bctc
            }, JsonRequestBehavior.AllowGet));
        }