public ActionResult DeleteConfirmed(int id)
        {
            Detai detai = db.Detais.Find(id);

            db.Detais.Remove(detai);
            db.SaveChanges();
            return(RedirectToAction("DanhsachDetai", "Detai"));
        }
 public ActionResult Sua(Detai detai)
 {
     if (ModelState.IsValid)
     {
         db.Entry(detai).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("DanhsachDetai"));
     }
     ViewBag.MALDT = new SelectList(db.LoaiDTs, "MALDT", "TENLDT", detai.MALDT);
     return(View(detai));
 }
        public ActionResult Themmoi(Detai detai)
        {
            if (ModelState.IsValid)
            {
                db.Detais.Add(detai);
                db.SaveChanges();
                return(RedirectToAction("DanhsachDeTai", "Detai"));
            }

            ViewBag.MALDT = new SelectList(db.LoaiDTs, "MALDT", "TENLDT", detai.MALDT);
            return(View(detai));
        }
        // GET: Detai/Details/5
        public ActionResult Chitiet(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Detai detai = db.Detais.Find(id);

            if (detai == null)
            {
                return(HttpNotFound());
            }
            return(View(detai));
        }
예제 #5
0
        //Xử lý xóa đề tài
        private void btnXoa_Click(object sender, EventArgs e)
        {//Tạo detai để tạo DTO đóng gói dữ liệu
            Detai detai = new Detai(txtMadetai.Text, txtTendetai.Text, txtNguoihd.Text, txtThoigiandk.Text);

            if (bll_detai.Delete(detai))
            {
                MessageBox.Show("Đã xóa thành công");
                TableDetai.DataSource = bll_detai.GetDS();
            }
            else
            {
                MessageBox.Show("Đã xảy ra lỗi");
            }
        }
        // GET: Detai/Edit/5
        public ActionResult Sua(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Detai detai = db.Detais.Find(id);

            if (detai == null)
            {
                return(HttpNotFound());
            }
            ViewBag.MALDT = new SelectList(db.LoaiDTs, "MALDT", "TENLDT", detai.MALDT);
            return(View(detai));
        }
예제 #7
0
파일: DAL_Detai.cs 프로젝트: thoi96/QLDT
 //Hàm sửa nội dungđề tài
 public bool Update(Detai pdetai)
 {
     try
     {
         conn.Open();
         SqlCommand cmd = new SqlCommand("UPDATE Detai SET tendetai='" + pdetai.tendetai + "',nguoihd='" + pdetai.nguoihd + "',thoigiandk='" + pdetai.thoigiandk + "' WHERE madetai='" + pdetai.madetai + "'", conn);
         cmd.ExecuteNonQuery();
     }
     catch
     {
         return(false);
     }
     finally
     {
         conn.Close();
     }
     return(true);
 }
예제 #8
0
파일: DAL_Detai.cs 프로젝트: thoi96/QLDT
 //Hàm xóa đề tài
 public bool Delete(Detai pdetai)
 {
     try
     {
         conn.Open();
         SqlCommand cmd = new SqlCommand("DELETE Detai WHERE madetai='" + pdetai.madetai + "'", conn);
         cmd.ExecuteNonQuery();
     }
     catch
     {
         return(false);
     }
     finally
     {
         conn.Close();
     }
     return(true);
 }
예제 #9
0
파일: DAL_Detai.cs 프로젝트: thoi96/QLDT
 //Hàm thêm đề tài
 public bool Insert(Detai pdetai)
 {
     try
     {
         conn.Open();
         SqlCommand cmd = new SqlCommand("INSERT INTO Detai VALUES('" + pdetai.madetai + "','" + pdetai.tendetai + "','" + pdetai.nguoihd + "','" + pdetai.thoigiandk + "')", conn);
         cmd.ExecuteNonQuery();
     }
     catch
     {
         return(false);
     }
     finally
     {
         conn.Close();
     }
     return(true);
 }
예제 #10
0
파일: BLL_Detai.cs 프로젝트: thoi96/QLDT
 public bool Update(Detai pdetai)
 {//Trả về giá trị true nếu thành công hoặc false nếu thất bại
     return(dal_detai.Update(pdetai));
 }
예제 #11
0
파일: BLL_Detai.cs 프로젝트: thoi96/QLDT
 public bool Insert(Detai pdetai)
 {   //Trả về giá trị true nếu thành công hoặc false nếu thất bại
     return(dal_detai.Insert(pdetai));
 }