Beispiel #1
0
        public async Task <ActionResult> Create([Bind(Include = "ID,Tuan,Nhom_ID,TieuDe,NoiDung,ThoiGianBaoCao,FileUpload,FilePath,PhanHoi")] BaoCao baoCao, HttpPostedFileBase FileUpload)
        {
            var session = (Common.UserLogin)Session[Web.Common.CommonConstants.USER_SESSION];

            baoCao.Nhom_ID = session.NhomID;

            if (ModelState.IsValid)
            {
                if (FileUpload != null)
                {
                    string pic  = Path.GetFileName(DateTime.Now.ToString("yyyy_MM_dd-") + FileUpload.FileName);
                    string path = Path.Combine(Server.MapPath("~/UploadFiles/") + pic);
                    FileUpload.SaveAs(path);

                    baoCao.FileUpload = pic;
                    baoCao.FilePath   = "UploadFiles/" + pic;
                }
                try
                {
                    db.BaoCaos.Add(baoCao);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
                catch (Exception)
                {
                    ViewBag.BaoCao = "Mỗi nhóm mỗi tuần chỉ báo cáo 1 lần";
                }
            }

            ViewBag.Nhom_ID = new SelectList(db.Nhoms, "ID", "TenNhom", baoCao.Nhom_ID);
            return(View(baoCao));
        }
Beispiel #2
0
        public async Task <ActionResult> Feedback(BaoCao baoCao)
        {
            if (ModelState.IsValid)
            {
                db.Entry(baoCao).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.Nhom_ID = new SelectList(db.Nhoms, "ID", "TenNhom", baoCao.Nhom_ID);
            return(View(baoCao));
        }
Beispiel #3
0
        public async Task <ActionResult> Create([Bind(Include = "ID,TenDeTai,YeuCauDeTai,ThoiGianBatDau,ThoiGianKetThuc,SoTuanThucHien")] DeTai deTai)
        {
            if (ModelState.IsValid)
            {
                db.DeTais.Add(deTai);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(deTai));
        }
Beispiel #4
0
        public async Task <ActionResult> Create([Bind(Include = "ID,TenDangNhap,MatKhau,HoTen,Email,Nhom_ID,DeTai_ID,ChucVu_ID")] NguoiDung nguoiDung)
        {
            if (ModelState.IsValid)
            {
                nguoiDung.MatKhau = Encryptor.MD5Hash(nguoiDung.MatKhau);
                db.NguoiDungs.Add(nguoiDung);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ChucVu_ID = new SelectList(db.ChucVus, "ID", "TenChucVu", nguoiDung.ChucVu_ID);
            ViewBag.DeTai_ID  = new SelectList(db.DeTais, "ID", "TenDeTai", nguoiDung.DeTai_ID);
            ViewBag.Nhom_ID   = new SelectList(db.Nhoms, "ID", "TenNhom", nguoiDung.Nhom_ID);
            return(View(nguoiDung));
        }
Beispiel #5
0
        public async Task <ActionResult> Create([Bind(Include = "ID,TenDeTai,YeuCauDeTai,ThoiGianBatDau,ThoiGianKetThuc,SoTuanThucHien")] DeTai deTai)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.DeTais.Add(deTai);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    ViewBag.Alert = "Tên đề tài không được trùng nhau và thời gian bắt đầu phải nhỏ hơn thời gian kết thúc. Mời nhập lại!";
                }
            }



            return(View(deTai));
        }