// GET: MonHocs/Create
        public ActionResult Create()
        {
            LoaiMonHoc lmh = new LoaiMonHoc();

            ViewBag.LoaiMonHoc = new SelectList(lmh.GetListLoaiMonHoc(), "LoaiMonHocID", "TenLoaiMonHoc");
            return(View());
        }
示例#2
0
        //Ham xu ly nhap loai mon hoc
        static LoaiMonHoc XuLyNhapLoaiMH()
        {
            LoaiMonHoc loaiMH = LoaiMonHoc.BatBuoc;

            while (!Enum.TryParse <LoaiMonHoc>(Console.ReadLine(), out loaiMH))
            {
                Console.WriteLine("Loai mon hoc ban nhap vao sai!");
                Console.WriteLine("Moi ban nhap lai: ");
            }
            return(loaiMH);
        }
        // GET: MonHocs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MonHoc monHoc = db.MonHocs.Find(id);

            if (monHoc == null)
            {
                return(HttpNotFound());
            }
            LoaiMonHoc lmh = new LoaiMonHoc();

            ViewBag.LoaiMonHoc = new SelectList(lmh.GetListLoaiMonHoc(), "LoaiMonHocID", "TenLoaiMonHoc", monHoc.LoaiMonHoc);
            return(View(monHoc));
        }
        public ActionResult Create([Bind(Include = "MonHocID,MaMonHoc,TenMonHoc,SoTinChi,LoaiMonHoc")] MonHoc monHoc)
        {
            MonHoc     mh  = db.MonHocs.FirstOrDefault(x => x.MaMonHoc == monHoc.MaMonHoc);
            LoaiMonHoc lmh = new LoaiMonHoc();

            ViewBag.LoaiMonHoc = new SelectList(lmh.GetListLoaiMonHoc(), "LoaiMonHocID", "TenLoaiMonHoc");
            if (mh != null)
            {
                ModelState.AddModelError("", "Mã môn học đã tồn tại trong hệ thống");
                return(View(monHoc));
            }
            if (ModelState.IsValid)
            {
                db.MonHocs.Add(monHoc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(monHoc));
        }
示例#5
0
 public static LoaiMonHoc CreateLoaiMonHoc(int maLoaiMonHoc)
 {
     LoaiMonHoc loaiMonHoc = new LoaiMonHoc();
     loaiMonHoc.MaLoaiMonHoc = maLoaiMonHoc;
     return loaiMonHoc;
 }
示例#6
0
 public void AddToLoaiMonHocs(LoaiMonHoc loaiMonHoc)
 {
     base.AddObject("LoaiMonHocs", loaiMonHoc);
 }