Exemple #1
0
        public ActionResult Delete(bool confirm, int idKM)
        {
            if (Session["TaiKhoan"] != null)
            {
                var tk = Session["TaiKhoan"] as KhachHang;


                if (tk.LoaiTK == "Khách Hàng")
                {
                    return(View("../Home/Index"));
                }
                else
                {
                    KhuyenMaiDAO dao = new KhuyenMaiDAO();
                    if (confirm == true)
                    {
                        if (dao.DeleteKM(tk.MaKH, idKM) == false)
                        {
                            ViewBag.Alert = "Không thể xóa chương trình khuyến mãi này";
                        }
                        else
                        {
                            if (Session["UpdateKM"] != null)
                            {
                                var km = Session["UpdateKM"] as KhuyenMai;
                                if (km.MaKhuyenMai == idKM)
                                {
                                    Session["UpdateKM"] = null;
                                }
                            }
                            Session["ListKM"] = dao.GetList();
                        }
                    }
                    return(View("Index"));
                }
            }
            else
            {
                return(View("../DangNhap/Index"));
            }
        }
        public ActionResult Delete(long idKM)
        {
            var tk = Session["TaiKhoan"] as KhachHang;

            if (tk == null)
            {
                return(View("../Login/Index"));
            }
            else
            {
                if (tk.LoaiTK != "Admin")
                {
                    return(View("../Home/Index"));
                }
                else
                {
                    var db = new KhuyenMaiDAO();
                    db.DeleteKM(idKM);
                    Session["UpdateKM"] = null;
                    return(View("Index"));
                }
            }
        }