public ActionResult Edit([Bind(Include = "MaKhoi,TenKhoi")] KHOILOP KHOILOP)
 {
     if (ModelState.IsValid)
     {
         db.Entry(KHOILOP).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(KHOILOP));
 }
 public ActionResult Create([Bind(Include = "TenKhoi")] KHOILOP KHOILOP)
 {
     if (ModelState.IsValid)
     {
         db.KHOILOPs.Add(KHOILOP);
         db.SaveChanges();
         return(RedirectToAction("index"));
     }
     return(View(KHOILOP));
 }
 public ActionResult Delete(int?id)
 {
     try
     {
         KHOILOP KHOILOP = db.KHOILOPs.Find(id);
         db.KHOILOPs.Remove(KHOILOP);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         return(View("Error"));
     }
 }
        // GET: TTNhom_QLNS/group_role/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            KHOILOP KHOILOPdg = db.KHOILOPs.Find(id);

            if (KHOILOPdg == null)
            {
                return(HttpNotFound());
            }
            return(View(KHOILOPdg));
        }
        public ActionResult Details(int?ID)
        {
            if (ID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            KHOILOP KHOILOP = db.KHOILOPs.Find(ID);

            if (KHOILOP == null)
            {
                return(HttpNotFound());
            }
            return(View(KHOILOP));
        }
        // Lấy khối theo năm học
        public static List <KHOILOP> LayKhoiTheoNamHoc(string maNamHoc)
        {
            List <KHOILOP> lst = new List <KHOILOP>();

            using (SQL_QLHSDataContext db = new SQL_QLHSDataContext())
            {
                var ds = db.KHOILOPs.Where(a => a.MANAM == maNamHoc).ToList();
                foreach (var x in ds)
                {
                    KHOILOP khoiLop = new KHOILOP();
                    {
                        khoiLop.MAKHOI  = x.MAKHOI;
                        khoiLop.TENKHOI = x.TENKHOI;
                        lst.Add(khoiLop);
                    }
                }
            }
            return(lst);
        }
Exemple #7
0
        public bool InsertKL(ClassDTO kl)
        {
            try
            {
                HocSinhDBDataContext hdb = new HocSinhDBDataContext();
                KHOILOP KL = new KHOILOP {
                    MaKhoiLop = kl.MaK1, TenKhoiLop = kl.TenK1
                };

                hdb.KHOILOPs.InsertOnSubmit(KL);
                hdb.SubmitChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        // Lấy tất cả các khối
        public static List <KHOILOP> LayTatCaKhoi()
        {
            List <KHOILOP> lst = new List <KHOILOP>();

            using (SQL_QLHSDataContext db = new SQL_QLHSDataContext())
            {
                var ds = db.KHOILOPs.ToList();
                foreach (var x in ds)
                {
                    KHOILOP kl = new KHOILOP();
                    {
                        kl.MAKHOI  = x.MAKHOI;
                        kl.TENKHOI = x.TENKHOI;
                        kl.SOLOP   = x.SOLOP;
                        kl.MANAM   = x.MANAM;
                        lst.Add(kl);
                    }
                }
            }
            return(lst);
        }