Esempio n. 1
0
        public ActionResult Create([Bind(Include = "ma,ky_hoc,bat_dau,ket_thuc")] KyHoc kyHoc)
        {
            if (ModelState.IsValid)
            {
                db.KyHocs.Add(kyHoc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(kyHoc));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "ma,ten")] MonHoc monHoc)
        {
            if (ModelState.IsValid)
            {
                db.MonHocs.Add(monHoc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(monHoc));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "ma,ten,ma_khoa,ma_gv_chu_nhiem")] LopOnDinh lopOnDinh)
        {
            if (ModelState.IsValid)
            {
                db.LopOnDinhs.Add(lopOnDinh);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ma_gv_chu_nhiem = new SelectList(db.GiaoViens, "ma", "ten", lopOnDinh.ma_gv_chu_nhiem);
            return(View(lopOnDinh));
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "tai_khoan,mat_khau,ten_hien_thi,url_anh,la_admin")] TaiKhoan taiKhoan)
        {
            if (ModelState.IsValid)
            {
                db.TaiKhoans.Add(taiKhoan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.tai_khoan = new SelectList(db.GiaoViens, "ma", "ten", taiKhoan.tai_khoan);
            return(View(taiKhoan));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "ma,ma_mon_hoc,ma_ky_hoc,ma_giao_vien,ma_lop_on_dinh")] LopHoc lopHoc)
        {
            if (ModelState.IsValid)
            {
                db.LopHocs.Add(lopHoc);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ma_giao_vien   = new SelectList(db.GiaoViens, "ma", "ten", lopHoc.ma_giao_vien);
            ViewBag.ma_ky_hoc      = new SelectList(db.KyHocs, "ma", "ky_hoc", lopHoc.ma_ky_hoc);
            ViewBag.ma_lop_on_dinh = new SelectList(db.LopOnDinhs, "ma", "ten", lopHoc.ma_lop_on_dinh);
            ViewBag.ma_mon_hoc     = new SelectList(db.MonHocs, "ma", "ten", lopHoc.ma_mon_hoc);



            return(View(lopHoc));
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "ma,ten,ngay_sinh,url_anh,so_dien_thoai,email,ngay_vao_truong")] GiaoVien giaoVien)
        {
            if (ModelState.IsValid)
            {
                if (Request.Files.Count > 0 && Request.Files[0].FileName.Trim() != "")
                {
                    string[] _arr = Request.Files[0].FileName.Split('.');
                    string   type = _arr[_arr.Length - 1];
                    giaoVien.url_anh = giaoVien.ma + "." + type;
                    Request.Files[0].SaveAs(Server.MapPath("~/Public/upload/teacher/") + giaoVien.url_anh);
                }
                db.GiaoViens.Add(giaoVien);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ma = new SelectList(db.TaiKhoans, "tai_khoan", "mat_khau", giaoVien.ma);
            return(View(giaoVien));
        }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "ma,ten,ngay_sinh,ma_lop_on_dinh,so_dien_thoai,email,url_anh,ngay_nhap_hoc")] HocSinh hocSinh)
        {
            if (ModelState.IsValid)
            {
                if (Request.Files.Count > 0 && Request.Files[0].FileName.Trim() != "")
                {
                    string[] _arr = Request.Files[0].FileName.Split('.');
                    string   type = _arr[_arr.Length - 1];

                    hocSinh.url_anh = hocSinh.ma + "." + type;
                    Request.Files[0].SaveAs(Server.MapPath("~/Public/upload/student/") + hocSinh.url_anh);
                }

                db.HocSinhs.Add(hocSinh);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hocSinh));
        }
Esempio n. 8
0
        public ActionResult Create([Bind(Include = "ma,noi_dung, tieu_de,do_uu_tien,tai_khoan,hinh_anh,ma_danh_muc")] BaiViet baiViet)
        {
            if (ModelState.IsValid)
            {
                baiViet.noi_dung = HttpUtility.HtmlDecode(baiViet.noi_dung.Replace(System.Environment.NewLine, ""));
                baiViet          = db.BaiViets.Add(baiViet);
                db.SaveChanges();

                if (Request.Files.Count > 0 && Request.Files[0].FileName.Trim() != "")
                {
                    string[] _arr = Request.Files[0].FileName.Split('.');
                    string   type = _arr[_arr.Length - 1];
                    baiViet.hinh_anh = baiViet.ma + "." + type;
                    Request.Files[0].SaveAs(Server.MapPath("~/Public/upload/post/") + baiViet.hinh_anh);
                }
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.ma_danh_muc = new SelectList(db.DanhMucs, "ma", "ten", baiViet.ma_danh_muc);
            ViewBag.tai_khoan   = new SelectList(db.TaiKhoans, "tai_khoan", "mat_khau", baiViet.tai_khoan);
            return(View(baiViet));
        }