예제 #1
0
        public IActionResult Delete(int id)
        {
            Loai loai   = LoaiDAO.GetLoai(id);
            bool result = false;

            if (loai != null)
            {
                result = LoaiDAO.DeleteLoai(id);
            }

            ViewBag.ThongBao = $"Xóa loại {id}-{loai.TenLoai} {(result ? "thành công" : "thất bại")}";

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult Delete(bool confirm, int idLoai)
        {
            if (Session["TaiKhoan"] != null)
            {
                var tk = Session["TaiKhoan"] as KhachHang;


                if (tk.LoaiTK == "Khách Hàng")
                {
                    return(View("../Home/Index"));
                }
                else
                {
                    if (confirm == true)
                    {
                        LoaiDAO dao = new LoaiDAO();
                        if (dao.DeleteLoai(idLoai, tk.MaKH) == false)
                        {
                            ViewBag.Alert = "Không thể xóa loại này";
                        }
                        else
                        {
                            if (Session["UpdateLoai"] != null)
                            {
                                var nsx = Session["UpdateLoai"] as Loai;
                                if (nsx.MaLoai == idLoai)
                                {
                                    Session["UpdateLoai"] = null;
                                }
                            }
                            Session["ListLoai"] = dao.GetList();
                        }
                    }
                    return(View("Index"));
                }
            }
            else
            {
                return(View("../DangNhap/Index"));
            }
        }