// GET: DeTais/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DeTai deTai = await db.DeTais.FindAsync(id);

            if (deTai == null)
            {
                return(HttpNotFound());
            }

            var lstAllNKH = db.NhaKhoaHocs.Where(p => p.MaNKH != 1).Select(p => new
            {
                p.MaNKH,
                TenNKH = p.HoNKH + " " + p.TenNKH
            }).ToList();

            var lstNKH = db.NhaKhoaHocs.Where(p => p.DSNguoiThamGiaDeTais.Any(d => d.MaDeTai == deTai.MaDeTai && d.LaChuNhiem == false)).Select(p => p.MaNKH).ToList();

            ViewBag.MaCapDeTai          = new SelectList(db.CapDeTais, "MaCapDeTai", "TenCapDeTai", deTai.MaCapDeTai);
            ViewBag.MaLoaiDeTai         = new SelectList(db.LoaiHinhDeTais, "MaLoaiDT", "TenLoaiDT", deTai.MaLoaiDeTai);
            ViewBag.MaDVChuTri          = new SelectList(db.DonViChuTris, "MaDVChuTri", "TenDVChuTri", deTai.MaDVChuTri);
            ViewBag.MaDonViQLThucHien   = new SelectList(db.DonViQLs, "MaDonVi", "TenDonVI", deTai.MaDonViQLThucHien);
            ViewBag.MaLinhVuc           = new SelectList(db.LinhVucs, "MaLinhVuc", "TenLinhVuc", deTai.MaLinhVuc);
            ViewBag.MaXepLoai           = new SelectList(db.XepLoais, "MaXepLoai", "TenXepLoai", deTai.MaXepLoai);
            ViewBag.MaTinhTrang         = new SelectList(db.TinhTrangDeTais, "MaTinhTrang", "TenTinhTrang", deTai.MaTinhTrang);
            ViewBag.MaPhanLoaiSP        = new SelectList(db.PhanLoaiSPs, "MaPhanLoai", "TenPhanLoai", deTai.MaPhanLoaiSP);
            ViewBag.DSNguoiThamGiaDeTai = new MultiSelectList(lstAllNKH, "MaNKH", "TenNKH", lstNKH);
            return(View(deTai));
        }
        public async Task <ActionResult> Create(HttpPostedFileBase linkUpload, [Bind(Include = "MaDeTai,MaDeTaiHoSo,TenDeTai,MaLoaiDeTai,MaCapDeTai,MaDVChuTri,MaDonViQLThucHien,MaLinhVuc,MucTieuDeTai,NoiDungDeTai,KetQuaDeTai,NamBD,NamKT,MaXepLoai,MaTinhTrang,MaPhanLoaiSP,LienKetWeb")] DeTai deTai)
        {
            if (ModelState.IsValid)
            {
                db.DeTais.Add(deTai);
                await db.SaveChangesAsync();

                db.DeTais.Attach(deTai);
                if (linkUpload != null && linkUpload.ContentLength > 0)
                {
                    string filename = Path.GetFileNameWithoutExtension(linkUpload.FileName) + "_" + deTai.MaDeTai.ToString() + Path.GetExtension(linkUpload.FileName);
                    string path     = Path.Combine(Server.MapPath("~/App_Data/uploads/detai_file"), filename);
                    linkUpload.SaveAs(path);
                    deTai.LinkFileUpload = filename;
                }
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.MaCapDeTai        = new SelectList(db.CapDeTais, "MaCapDeTai", "TenCapDeTai", deTai.MaCapDeTai);
            ViewBag.MaLoaiDeTai       = new SelectList(db.LoaiHinhDeTais, "MaLoaiDT", "TenLoaiDT", deTai.MaLoaiDeTai);
            ViewBag.MaDVChuTri        = new SelectList(db.DonViChuTris, "MaDVChuTri", "TenDVChuTri", deTai.MaDVChuTri);
            ViewBag.MaDonViQLThucHien = new SelectList(db.DonViQLs, "MaDonVi", "TenDonVI", deTai.MaDonViQLThucHien);
            ViewBag.MaLinhVuc         = new SelectList(db.LinhVucs, "MaLinhVuc", "TenLinhVuc", deTai.MaLinhVuc);
            ViewBag.MaXepLoai         = new SelectList(db.XepLoais, "MaXepLoai", "TenXepLoai", deTai.MaXepLoai);
            ViewBag.MaTinhTrang       = new SelectList(db.TinhTrangDeTais, "MaTinhTrang", "TenTinhTrang", deTai.MaTinhTrang);
            ViewBag.MaPhanLoaiSP      = new SelectList(db.PhanLoaiSPs, "MaPhanLoai", "TenPhanLoai", deTai.MaPhanLoaiSP);
            return(View(deTai));
        }
        private void btnradt_Click(object sender, EventArgs e)
        {
            try
            {
                DeTai DT = new DeTai();
                DT.MaDeTai   = tbxmadt.Text.Trim();
                DT.TenDeTai  = tbxtendt.Text.Trim();
                DT.NgayRaDT  = dptngayraDT.Value;
                DT.LoaiDeTai = tbxloaidt.Text.Trim();
                DT.MaGV      = tbxmaGV.Text.Trim();
                DeTaiBLL DTBLL = new DeTaiBLL();

                string _MaDeTai = tbxmadt.Text.Trim();
                if (!(DTBLL.CheckID(_MaDeTai)))
                {
                    DTBLL.Insert(DT);
                    LoadData();
                }
                else
                {
                    MessageBox.Show("Mã lớp " + _MaDeTai.ToString() + "đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }



            catch (Exception ex)
            {
                MessageBox.Show("Thêm bị lỗi: " + ex.Message.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #4
0
        public ActionResult DeleteConfirmed(decimal id)
        {
            DeTai deTai = db.DeTais.Find(id);

            db.DeTais.Remove(deTai);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
        // Hiển thị đề tài theo ID
        public ViewResult DeTai(string deTaiId)
        {
            DeTai deTai = thesisRepository
                          .DeTai
                          .FirstOrDefault(x => x.DeTaiId == deTaiId);

            return(View(deTai));
        }
        public int SLDeTai()
        {
            DeTai ndtkh = new DeTai();
            var   purch = from a in db.DeTai
                          select a;

            return(purch.Count());
        }
        public int Update(DeTai obj)
        {
            int        result   = 0;
            string     strQuery = "update DETAI set TenDeTai=N'" + obj.TenDeTai + "',LoaiDeTai=N'" + obj.LoaiDeTai + "',NgayRaDT='" + obj.NgayRaDT + "',FK_MaGV='" + obj.MaGV + "' where MaDeTai='" + obj.MaDeTai + "'";
            DataConfig config   = new DataConfig();

            result = config.excuteNoneQuery(strQuery);
            return(result); //tra ve so ghi nhan thuc hien
        }
Example #8
0
 public static bool updatedetai(DeTai dt)
 {
     using (var _context = new QuanlidoansinhvienEntities())
     {
         _context.DeTais.AddOrUpdate(dt);
         _context.SaveChanges();
         return(true);
     }
 }
        //them csdl
        public int Insert(DeTai obj)
        {
            int        result   = 0;
            string     strQuery = "insert into DETAI (MaDeTai,TenDeTai,LoaiDeTai,NgayRaDT,FK_MaGV) values ('" + obj.MaDeTai + "',N'" + obj.TenDeTai + "',N'" + obj.LoaiDeTai + "','" + obj.NgayRaDT + "','" + obj.MaGV + "')";
            DataConfig config   = new DataConfig();

            result = config.excuteNoneQuery(strQuery);
            return(result); //tra ve so ghi nhan thuc hien
        }
 public static bool UpdateDT(DeTai dt)
 {
     using (var _context = new ManagementTopicStudentEntities())
     {
         _context.DeTais.AddOrUpdate(dt);
         _context.SaveChanges();
         return(true);
     }
 }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            DeTai deTai = await db.DeTais.FindAsync(id);

            db.DeTais.Remove(deTai);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #12
0
 public ActionResult Edit([Bind(Include = "DeTaiId,TenDeTai,MoTa,SoLuongThanhVien,NgayTao,NgayDangKy")] DeTai deTai)
 {
     if (ModelState.IsValid)
     {
         db.Entry(deTai).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(deTai));
 }
Example #13
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     try
     {
         DeTai detai = DeTaiController.getExistDT(listDeTai.SelectedItems[0].SubItems[0].Text.Trim());
         this.listDeTai.SelectedItems[0].Remove();
         DeTaiController.DeleteDeTai(detai);
     }
     catch { }
 }
Example #14
0
 public IHttpActionResult PostThem(DeTai model)
 {
     if (!ModelState.IsValid)
     {
         return(Ok(new { status = false, message = "Sai dữ liệu đầu vào!" }));
     }
     db.DeTais.Add(model);
     db.SaveChanges();
     return(Ok(new { status = true, message = "Thêm mới Đề tài thành công!" }));
 }
Example #15
0
        public async Task <ActionResult> Edit([Bind(Include = "ID,TenDeTai,YeuCauDeTai,ThoiGianBatDau,ThoiGianKetThuc,SoTuanThucHien")] DeTai deTai)
        {
            if (ModelState.IsValid)
            {
                db.Entry(deTai).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(deTai));
        }
Example #16
0
        public ActionResult Create([Bind(Include = "DeTaiId,TenDeTai,MoTa,SoLuongThanhVien,NgayTao,NgayDangKy")] DeTai deTai)
        {
            if (ModelState.IsValid)
            {
                db.DeTais.Add(deTai);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(deTai));
        }
Example #17
0
 public void deleteDeTai_dal(string maDT)
 {
     using (Context m = new Context())
     {
         DeTai dt = m.DeTais.Find(maDT);
         if (dt != null)
         {
             m.DeTais.Remove(dt);
         }
         m.SaveChanges();
     }
 }
Example #18
0
 public void updateDeTai_dal(Entity.DeTai dt)
 {
     using (Context m = new Context()){
         DeTai dtUp = m.DeTais.Find(dt.MaDeTai);
         dtUp.TenDeTai      = dt.TenDeTai;
         dtUp.TinhTrang     = dt.TinhTrang;
         dtUp.NgayNhanDeTai = dt.NgayNhanDeTai;
         dtUp.ChuNhiem      = dt.ChuNhiem;
         dtUp.MaCapDeTai    = dt.MaCapDeTai;
         m.SaveChanges();
     }
 }
Example #19
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));
        }
Example #20
0
        public IHttpActionResult DeleteDeTai(int Id)
        {
            DeTai dbEntry = db.DeTais.Find(Id);

            if (dbEntry == null)
            {
                return(Ok(new { status = false, message = "Không tồn tại Đề tài!" }));
            }
            db.DeTais.Remove(dbEntry);
            db.SaveChanges();
            return(Ok(new { status = true, message = "Xóa Đề tài thành công!" }));
        }
        // GET: AdminDeTai/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DeTai deTai = await db.DeTais.FindAsync(id);

            if (deTai == null)
            {
                return(HttpNotFound());
            }
            return(View(deTai));
        }
 private void cboNhom_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         DeTai dt = TienDoController.layDeTai(cboNhom.Text.ToString());
         cboDeTai.Text = dt.ToString();
     }
     catch
     {
         MessageBox.Show("Nhóm này chưa có đề tài!");
         cboDeTai.Text = "";
         cboNhom.Text  = "";
         return;
     }
 }
 public bool Update(DeTai dt)
 {
     try
     {
         var id = context.DeTais.Find(dt.MaDeTai);
         id.MaDeTai  = dt.MaDeTai;
         id.TenDeTai = dt.TenDeTai;
         context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public static bool AddDT(DeTai dt)
 {
     try
     {
         using (var _context = new ManagementTopicStudentEntities())
         {
             _context.DeTais.Add(dt);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static bool ThemDT(DeTai detai)
 {
     using (var _context = new DoanLTWEntities())
     {
         foreach (var sinhvien in detai.SinhViens)
         {
             var dbsinhvien = (from u in _context.SinhViens
                               where u.MaSV == sinhvien.MaSV
                               select u).Single();
             dbsinhvien.DeTai = detai;
         }
         detai.SinhViens.Clear();
         _context.DeTais.Add(detai);
         _context.SaveChanges();
         return(true);
     }
 }
        private void btUpLoad_Click(object sender, EventArgs e)
        {
            DeTai detai1 = new DeTai();

            detai1.MaDT        = detai.MaDT;
            detai1.MaGV        = detai.MaGV;
            detai1.TenDT       = detai.TenDT;
            detai1.MoTaDT      = detai.MoTaDT;
            detai1.NgayBatDau  = detai.NgayBatDau;
            detai1.NgayKetThuc = detai.NgayKetThuc;
            detai1.NhanXet     = detai.NhanXet;
            detai1.TienDoDT    = detai.TienDoDT;
            detai1.FileDeTai   = txtUpLoad.Text;
            detai1.SinhViens   = DeTaiController.danhsach(detai.MaDT);
            DeTaiController.UpdateDeTai(detai1);
            MessageBox.Show("Upload Thành Công");
        }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("Hãy chọn dòng cần xóa!");
                return;
            }

            DeTai dt = DeTaiController.getDT(this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString());

            DeTaiController.DeleteDT(dt);
            //Hiển thị
            BindingSource source = new BindingSource();

            source.DataSource             = DeTaiController.getListDT();
            this.dataGridView1.DataSource = source;
        }
Example #28
0
        public async Task <ActionResult> Edit([Bind(Include = "ID,TenDeTai,YeuCauDeTai,ThoiGianBatDau,ThoiGianKetThuc,SoTuanThucHien")] DeTai deTai)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.Entry(deTai).State = EntityState.Modified;
                    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));
        }
 public static bool DeleteDT(DeTai dt)
 {
     using (var _context = new ManagementTopicStudentEntities())
     {
         try
         {
             var db = (from u in _context.DeTais
                       where u.MaDT == dt.MaDT
                       select u).SingleOrDefault();
             _context.DeTais.Remove(db);
             _context.SaveChanges();
         }
         catch
         {
             MessageBox.Show("Xóa đề tài này trong form Tiến độ rồi xóa lại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         return(true);
     }
 }
Example #30
0
        private void btnDeleteDeTai_Click(object sender, EventArgs e)
        {
            string       MaDT = this.dgvDeTai.CurrentRow.Cells[0].Value.ToString();
            DialogResult dr   = MessageBox.Show("Bạn chắc chắn muốn xóa?", "confirm", MessageBoxButtons.YesNo);

            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {
                    DeTai dt = sv.DeTais.Single(t => t.ID.Equals(MaDT));
                    sv.DeTais.Remove(dt);
                    sv.SaveChanges();
                    Load_data();
                    MessageBox.Show("Xóa thành công!");
                    clean();
                }
                catch
                { MessageBox.Show("Xóa thất bại"); }
            }
        }