public ActionResult Add()
        {
            //check
            if (!this._nhanvien_permission.Contains("nhomsanpham_add"))
            {
                return this._fail_permission("nhomsanpham_add");
            }
            //get data
            int p_id = TextLibrary.ToInt(Request["cat_parent_id"]);
            //nên lấy instance của chính Controller đó để dùng sẽ không bị lỗi track changes
            NhomSanPhamController controller = new NhomSanPhamController();

            NhomSanPham obj = new NhomSanPham();
            obj.ten =  TextLibrary.ToString(Request["cat_name"]);
            obj.mota = TextLibrary.ToString(Request["cat_description"]);
            obj.active = TextLibrary.ToBoolean(Request["cat_active"]);
            if (obj.ten.Equals(""))
            {
                //lỗi
                Debug.WriteLine("Lỗi cat_name= rỗng");
                return RedirectToAction("Index", "AdminNhomSanPham");
            }
            NhomSanPham p_obj = controller._db.ds_nhomsanpham.Where(x => x.id == p_id).FirstOrDefault();
            if (p_obj != null)
            {
                obj.nhomcha = p_obj;
            }
            //call add
            controller.add(obj);
            Debug.WriteLine("Thêm Thành Công Nhóm Sản Phẩm");
            return RedirectToAction("Index","AdminNhomSanPham");
        }
 public ActionResult Index(int page=1)
 {
     ViewBag.id = 4;
     List<NhomSanPham> nhomsp = null;
     List<HangSX> hangsx = null;
     String orderby = TextLibrary.ToString(front_timkiem_sanpham["front_orderby"]);
     Boolean desc = TextLibrary.ToBoolean(front_timkiem_sanpham["front_desc"]);
     if(!front_timkiem_sanpham["front_nhomsanpham_id"].Equals(""))
     {
         nhomsp = new List<NhomSanPham>();
         NhomSanPhamController ctr2 = new NhomSanPhamController(ctr._db);
         NhomSanPham tmp = ctr2.get_by_id(TextLibrary.ToInt(front_timkiem_sanpham["front_nhomsanpham_id"]));
         nhomsp = ctr2.get_tree2(tmp);
     }
     if(!front_timkiem_sanpham["front_hangsx_ten"].Equals(""))
     {
         hangsx = new List<HangSX>();
         HangSXController ctr3 = new HangSXController(ctr._db);
         hangsx=ctr3.timkiem("",TextLibrary.ToString(front_timkiem_sanpham["front_hangsx_ten"]),"1","id",false,0,-1);
     }
     //calculate offset
     if (TextLibrary.ToString(Request["front_current_page"]) != "") page = int.Parse(TextLibrary.ToString(Request["front_current_page"]));
     int max_item_per_page = TextLibrary.ToInt(this.front_timkiem_sanpham["front_max_item_per_page"]);
         int start_point = (page - 1) * max_item_per_page;
         if (start_point <= 0) start_point = 0;
     //get list
         List<SanPham> listnew = ctr.timkiem("", "", this.front_timkiem_sanpham["front_ten"], front_timkiem_sanpham["front_mota"],  TextLibrary.ToInt(front_timkiem_sanpham["front_gia_from"]),
             TextLibrary.ToInt(front_timkiem_sanpham["front_gia_to"]), hangsx, nhomsp , "1", orderby,desc, start_point, max_item_per_page);
         ViewBag.SanPham_List = listnew;
         ViewBag.front_timkiem_sanpham = this.front_timkiem_sanpham;
     //pagination
         int Current_Page = page;
      //   int Result_Count = listnew.Count;
         int Result_Count = ctr.timkiem_count(
             "",
             front_timkiem_sanpham["front_masp"],
             front_timkiem_sanpham["front_ten"],
             front_timkiem_sanpham["front_mota"],
             TextLibrary.ToInt(front_timkiem_sanpham["front_gia_from"]),
             TextLibrary.ToInt(front_timkiem_sanpham["front_gia_to"]), hangsx, nhomsp, "1");
         int Total_Page = (int)(Math.Ceiling((double)Result_Count / max_item_per_page));
         Boolean CanNextPage = Current_Page >= Total_Page ? false : true;
         Boolean CanPrevPage = Current_Page == 1 ? false : true;
         ViewBag.Result_Count = Result_Count;
         ViewBag.CanNextPage = CanNextPage;
         ViewBag.CanPrevPage = CanPrevPage;
         ViewBag.Current_Page = Current_Page;
         ViewBag.Total_page = Total_Page;
     return View();
 }
예제 #3
0
 //
 // GET: /Test/
 public ActionResult Index()
 {
     List<NhomSanPham> list = new NhomSanPhamController().get_tree2(null);
     foreach (NhomSanPham item in list)
     {
         Debug.WriteLine(item.id);
         foreach (SanPham sp in item.ds_sanpham)
         {
             Debug.Write(sp.id+""+ sp.ten+"-");
         }
         Debug.WriteLine("");
     }
     return View();
 }
 public ActionResult Delete(int id=0)
 {
     //check
     if (!this._nhanvien_permission.Contains("nhomsanpham_delete"))
     {
         return this._fail_permission("nhomsanpham_delete");
     }
     NhomSanPhamController controller = new NhomSanPhamController();
     if (!controller.is_exist(id))
     {
         return RedirectToAction("Index", "AdminNhomSanPham");
     }
     try
     {
         controller.delete(id);
     }
     catch (Exception)
     {
         return _show_notification("Nhóm sản phẩm này có dính khóa ngoại với sản phẩm hoặc nhóm con hiện có nên không xóa được");
     }
     return RedirectToAction("Index", "AdminNhomSanPham");
 }
        public ActionResult Add()
        {
            //check
            if (!this._nhanvien_permission.Contains("sanpham_add"))
            {
                return this._fail_permission("sanpham_add");
            }
            //check nhom sanpham co it nhat 1
                NhomSanPhamController ctr_nhomsanpham = new NhomSanPhamController();
                if (ctr_nhomsanpham.timkiem_count("", "", "", "1") <= 0)
                {
                    return this._show_notification("Yêu cầu phải có ít nhất 1 nhóm sản phẩm active mới được thêm sản phẩm mới!");
                }
            //check hangsx co it nhat 1
                HangSXController ctr_hangsx = new HangSXController();
                if (ctr_hangsx.timkiem_count("", "", "1") <= 0)
                {
                    return this._show_notification("Yêu cầu phải có ít nhất 1 hãng sản xuất active mới được thêm sản phẩm mới!");
                }

            return RedirectToAction("Add", "AdminSanPham");
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            ViewBag.Title += " - Sản phẩm";
            //đặt activetab cố định cho controller này
            this._current_activetab();
            //load những dữ liệu common

                //active only
                NhomSanPhamController ctr_nhom = new NhomSanPhamController();
                ViewBag.NhomSanpham2_ListAll = ctr_nhom.timkiem();
                //active only
                HangSXController ctr_hangsx = new HangSXController();
                ViewBag.HangSX_ListAll = ctr_hangsx.timkiem();
                //
                KichThuocController ctr_kichthuoc = new KichThuocController();
                ViewBag.KichThuoc_ListAll = ctr_kichthuoc.timkiem();
                //
                MauSacController ctr_mausac = new MauSacController();
                ViewBag.MauSac_ListAll = ctr_mausac.timkiem();
                ViewBag.ChiTietSP = new ChiTietSP();//may be override by action
        }
        public ActionResult Submit()
        {
            //get obj id first
            int obj_id = TextLibrary.ToInt(Request["sanpham_id"]);
            //must use same dbcontext neu khong se bao loi (chi can thiet khi co cap nhat thao tac tren doi tuong sanpham trong session)
            SanPhamController ctr = new SanPhamController(this._get_current_dbcontext());

            SanPham obj = (SanPham)Session["sanpham_new_tmp"];
            Boolean un_save = false;
            if (obj != null)
            {
                //un save mode
                un_save = true;
                //add mode
                if (!this._nhanvien_permission.Contains("sanpham_add"))
                {
                    return _fail_permission("sanpham_add");
                }
            }
            else
            {
                //get obj from csdl
                obj = ctr.get_by_id(obj_id);
                //edit mode
                if (!this._nhanvien_permission.Contains("sanpham_edit"))
                {
                    return _fail_permission("sanpham_edit");
                }
                if (obj == null)
                {
                    return RedirectToAction("Index", "AdminSanPhams");
                }
            }

            //assign value
                obj.active = TextLibrary.ToBoolean(Request["sanpham_active"]);
                obj.gia = TextLibrary.ToInt(Request["sanpham_gia"]);
                obj.masp = TextLibrary.ToString(Request["sanpham_masp"]);
                obj.mota = TextLibrary.ToString(Request.Unvalidated["sanpham_mota"]);
                obj.ten = TextLibrary.ToString(Request["sanpham_ten"]);
                //get external object
                HangSXController ctr_hangsx = new HangSXController(ctr._db);
                obj.hangsx = ctr_hangsx.get_by_id(TextLibrary.ToInt(Request["sanpham_hangsx_id"]));

                NhomSanPhamController ctr_nhomsanpham = new NhomSanPhamController(ctr._db);
                obj.nhomsanpham = ctr_nhomsanpham.get_by_id(TextLibrary.ToInt(Request["sanpham_nhomsanpham_id"]));

            //validate properties
            List<String> validate = ctr.validate(obj);

            //action
            if (validate.Count == 0)
            {
                if (!un_save)
                {
                    //update properties first
                    ctr._db.SaveChanges();
                    this._state.Add("edit_ok");
                    this._add_state_tempdata("edit_ok");
                    //get image
                    if (!TextLibrary.ToString(Request["sanpham_upload_hinhanh"]).Equals(""))
                    {
                        HinhAnhController ctr_hinhanh = new HinhAnhController(ctr._db);
                        List<HinhAnh> hinhanh_list = ctr_hinhanh.upload(Server, Request.Files);
                        obj.ds_hinhanh.AddRange(hinhanh_list);
                        ctr._db.SaveChanges();
                    }

                    //successfull redirect
                    return RedirectToAction("Index", "AdminSanPham", new { id = obj.id });
                }
                else
                {
                    //người dùng bấm nút upload hình ảnh chứ không phải nút lưu
                    if (!TextLibrary.ToString(Request["sanpham_upload_hinhanh"]).Equals(""))
                    {
                        //khoan hãy lưu vào csdl
                        HinhAnhController ctr_hinhanh = new HinhAnhController(ctr._db);
                        List<HinhAnh> hinhanh_list = ctr_hinhanh.upload(Server, Request.Files);
                        obj.ds_hinhanh.AddRange(hinhanh_list);
                        //re assign to session
                        Session["sanpham_new_tmp"] = obj;
                        //successfull redirect
                        return RedirectToAction("Index", "AdminSanPham", new { id = 0 });
                    }
                    else
                    {
                        //call add
                        int maxid = ctr.add(obj);
                        //re assign id
                        obj.id = maxid;
                        this._state.Add("add_ok");
                        this._add_state_tempdata("add_ok");
                        //successfull redirect
                        return RedirectToAction("Index", "AdminSanPham", new { id = obj.id });
                    }

                }
            }
            else
            {
                //người dùng bấm nút upload hình ảnh chứ không phải nút lưu
                if (!TextLibrary.ToString(Request["sanpham_upload_hinhanh"]).Equals(""))
                {
                    //khoan hãy lưu vào csdl
                    HinhAnhController ctr_hinhanh = new HinhAnhController(ctr._db);
                    List<HinhAnh> hinhanh_list = ctr_hinhanh.upload(Server, Request.Files);
                    obj.ds_hinhanh.AddRange(hinhanh_list);
                    //re assign to session
                    Session["sanpham_new_tmp"] = obj;
                    //successfull redirect
                    this._add_state_tempdata(validate);
                    return RedirectToAction("Index", "AdminSanPham", new { id = 0 });
                }
            }

            //fail or redirect
            this._state.AddRange(validate);
            ViewBag.State = this._state;
            ViewBag.SanPham = obj;
            ViewBag.Title += " - Submit";
            return View("Index");
        }
 public List<SanPham> timkiem_dequy(NhomSanPham root = null, String active = "", int start_point = 0, int count = -1)
 {
     List<SanPham> re = new List<SanPham>();
     NhomSanPhamController ctr=new NhomSanPhamController();
     List<NhomSanPham> list = ctr.get_tree2(root);
     re.AddRange(this.timkiem("","","","",0,0,null,list,active,"id",true,start_point,count));
     return re;
 }
        public ActionResult Index(int page = 1,int id_loaisp=0,int level_loaisp=0)
        {
            ViewBag.id = 2;
            NhomSanPhamController ctr2 = new NhomSanPhamController(ctr._db);
            List<NhomSanPham> loaisp_list = new List<NhomSanPham>();
            NhomSanPham2 loaisp = new NhomSanPham2();
            List<List<SanPham>> splist = new List<List<SanPham>>();
            if (id_loaisp == 0 || level_loaisp == 0 )
            {
                NhomSanPham tmp;
                if (id_loaisp != 0)
                {
                    tmp = ctr2.get_by_id(id_loaisp);
                    loaisp.Load_From(tmp);
                    loaisp.level = level_loaisp;
                    if (tmp.ds_nhomcon.Count == 0)
                    {
                        loaisp_list.Add(tmp);
                        splist.Add(ctr.timkiem("","","","",0,0,null,loaisp_list,"1","id",true,0,-1));
                    }
                    else
                    {
                        foreach (NhomSanPham item in tmp.ds_nhomcon)
                        {
                            loaisp_list.Add(item);
                            splist.Add(ctr.timkiem_dequy(item, "1", 0, 3));
                        }
                    }
                }
                else
                {
                    tmp = null; loaisp = null;
                    List<NhomSanPham2> loaisp_l = ctr2.get_tree(tmp, 0);
                    foreach (NhomSanPham2 item in loaisp_l)
                    {
                       // if ((loaisp != null && loaisp.id != item.id && item.level == 1) || (loaisp == null && item.level == 0))
                        if(item.level==0&&item.active==true)
                        {
                            NhomSanPham a = ctr2.get_by_id(item.id);
                            loaisp_list.Add(a);
                            splist.Add(ctr.timkiem_dequy(a, "1", 0, 3));
                        }

                    }

                }
                ViewBag.splist = splist;
                ViewBag.loaisp = loaisp;
                ViewBag.loaisp_list = loaisp_list;
            }
            else
            {
                String orderby = TextLibrary.ToString(front_sanpham["front_orderby"]);
                Boolean desc = TextLibrary.ToBoolean(front_sanpham["front_desc"]);
                NhomSanPham tmp = ctr2.get_by_id(id_loaisp);
                loaisp.Load_From(tmp);
                loaisp.level = level_loaisp;
                foreach(var item in ctr2.get_tree2(tmp))
                {
                    if (item.active == true)
                        loaisp_list.Add(item);
                }
                //calculate offset
                if (TextLibrary.ToString(Request["front_current_page"]) != "") page = int.Parse(TextLibrary.ToString(Request["front_current_page"]));
                int max_item_per_page = TextLibrary.ToInt(this.front_sanpham["front_max_item_per_page"]);
                int start_point = (page - 1) * max_item_per_page;
                if (start_point <= 0) start_point = 0;
                //get list
                List<SanPham> listnew = ctr.timkiem("", "", "", "", -1, -1, null, loaisp_list, "1", orderby, desc, start_point, max_item_per_page);
                ViewBag.SanPham_List = listnew;
                ViewBag.front_sanpham = this.front_sanpham;
                ViewBag.loaisp = loaisp;
                //pagination
                int Current_Page = page;
                //   int Result_Count = listnew.Count;
                int Result_Count = ctr.timkiem_count("", "", "", "", -1, -1, null, loaisp_list, "1");
                int Total_Page = (int)(Math.Ceiling((double)Result_Count / max_item_per_page));
                Boolean CanNextPage = Current_Page >= Total_Page ? false : true;
                Boolean CanPrevPage = Current_Page == 1 ? false : true;
                ViewBag.Result_Count = Result_Count;
                ViewBag.CanNextPage = CanNextPage;
                ViewBag.CanPrevPage = CanPrevPage;
                ViewBag.Current_Page = Current_Page;
                ViewBag.Total_page = Total_Page;
            }
            return View();
        }
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     NhomSanPhamController ctr = new NhomSanPhamController();
     List<NhomSanPham2> list1 = ctr.timkiem("", "", "", "1");
     ViewBag.loaisp = list1;
     HangSXController ctr2 = new HangSXController(ctr._db);
     List<HangSX> list2 = ctr2.timkiem("", "", "1", "id", false, 0, -1);
     ViewBag.hangsx = list2;
     base.OnActionExecuting(filterContext);
     ViewBag.Title += " - Tìm kiếm sản phẩm";
     if (Request.Cookies.Get("front_sanpham") == null)
     {
         //chưa set cookies trước => tiến hành set cookies
         this.khoitao_cookie();
         this.luu_cookie();
     }
     else
     {
         try
         {
             this.front_sanpham = CookieLibrary.Base64Decode(Request.Cookies.Get("front_sanpham"));
         }
         catch (Exception)
         {
             this.khoitao_cookie();
             this.luu_cookie();
         }
     }
     ViewBag.front_sanpham = this.front_sanpham;
 }
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     NhomSanPhamController ctr = new NhomSanPhamController();
     List<NhomSanPham2> list1 = ctr.timkiem("", "", "", "1");
     ViewBag.loaisp = list1;
     HangSXController ctr2 = new HangSXController(ctr._db);
     List<HangSX> list2 = ctr2.timkiem("", "", "1", "id", false, 0, -1);
     ViewBag.hangsx = list2;
     base.OnActionExecuting(filterContext);
     ViewBag.Title += " - Tìm kiếm sản phẩm";
 }
 public ActionResult Edit(int id=0)
 {
     //check
     if (!this._nhanvien_permission.Contains("nhomsanpham_edit"))
     {
         return this._fail_permission("nhomsanpham_edit");
     }
     //get data
     NhomSanPhamController ctr = new NhomSanPhamController();
     if (!ctr.is_exist(id))
     {
         Debug.WriteLine("Mã nhóm sản phẩm không tồn tại, id="+id);
         return RedirectToAction("Index","AdminNhomSanPham");
     }
     ViewBag.nhom_san_pham = ctr.get_by_id(id);
     ViewBag.Title += " - Edit";
     ViewBag.NhomSanPham2_List_All = ctr.timkiem("","","","");
     return View();
 }
 //
 // GET: /AdminNhomSanPham/
 public ActionResult Index()
 {
     //check
     if (!this._nhanvien_permission.Contains("nhomsanpham_view"))
     {
         return this._fail_permission("nhomsanpham_view");
     }
     NhomSanPhamController ctr = new NhomSanPhamController();
     ViewBag.NhomSanPham2_List = ctr.timkiem(
         this.timkiem_nhomsanpham["id"],
         this.timkiem_nhomsanpham["ten"],
         this.timkiem_nhomsanpham["mota"],
         this.timkiem_nhomsanpham["active"]);
     ViewBag.NhomSanPham2_List_All = ctr.timkiem("","","","");
     ViewBag.Title += " - View";
     ViewBag.timkiem_nhomsanpham = this.timkiem_nhomsanpham;
     return View();
 }
        public ActionResult EditSubmit()
        {
            //check
            if (!this._nhanvien_permission.Contains("nhomsanpham_edit"))
            {
                return this._fail_permission("nhomsanpham_edit");
            }

            NhomSanPhamController ctr = new NhomSanPhamController();
            //get data
            int id = TextLibrary.ToInt(Request["cat_id"]);
            if (!ctr.is_exist(id))
            {
                Debug.WriteLine("Mã nhóm sản phẩm không tồn tại, id=" + id);
                return RedirectToAction("Index", "AdminNhomSanPham");
            }
            String cat_name = TextLibrary.ToString(Request["cat_name"]);
            Boolean cat_active = TextLibrary.ToBoolean(Request["cat_active"]);
            String cat_description =  TextLibrary.ToString(Request["cat_description"]);
            int cat_p_id = TextLibrary.ToInt(Request["cat_parent_id"]);
            //get curent cat object and pass update info
            NhomSanPham obj = ctr.get_by_id(id);
            obj.ten = cat_name;
            obj.mota = cat_description;
            obj.active = cat_active;
            //get parent cat info
            NhomSanPham p_nhom = ctr.get_by_id(cat_p_id);
            ctr.set_parent(obj, p_nhom);
            //call update
            ctr._db.SaveChanges();
            Debug.WriteLine("Cập nhật thành công Nhóm Sản phẩm");
            return RedirectToAction("Index", "AdminNhomSanPham");
        }
예제 #15
0
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     base.OnActionExecuting(filterContext);
     KhachHangController ctr_kh = new KhachHangController();
     NhomSanPhamController ctr = new NhomSanPhamController();
     List<NhomSanPham2> list1 = ctr.timkiem("", "", "", "1");
     SanPhamController ctr2 = new SanPhamController(ctr._db);
     List<SanPham>list2=ctr2.get_bestseller(4);
     if (list1 != null && list2 != null)
     {
         ViewBag.NhomSanPham2_List_All = list1;
         ViewBag.SanPham_BestSeller = list2;
     }
     else
     {
         ViewBag.NhomSanPham2_List_All = new List<NhomSanPham2>();
         ViewBag.SanPham_BestSeller = new List<SanPham>();
     }
     //tim kiem
     //build timkiem_sanpham
     if (Request.Cookies.Get("front_timkiem_sanpham") == null)
     {
         //chưa set cookies trước => tiến hành set cookies
         this._khoitao_cookie();
         this._luu_cookie();
     }
     else
     {
         try
         {
             this.front_timkiem_sanpham = CookieLibrary.Base64Decode(Request.Cookies.Get("front_timkiem_sanpham"));
         }
         catch (Exception)
         {
             this._khoitao_cookie();
             this._luu_cookie();
         }
     }
     ViewBag.front_timkiem_sanpham = this.front_timkiem_sanpham;
     //Load thong tin KhachHang
     if (!this._is_logged_in())
     {
         //Chưa có ai đăng nhập hệ thống
         if (Session["khachhang"] != null)
         {
             //nếu như KH đã đăng nhập rồi
             this._khachhang = ctr_kh.get_by_id(((KhachHang)Session["khachhang"]).id);
         }
         else
         {
             //lấy từ cookies lên
             //lay thong tin tu cookies
             HttpCookie _tmp = Request.Cookies.Get("khachhang");
             if (_tmp != null)
             {
                 int uid = TextLibrary.ToInt(_tmp["khachhang_id"].ToString());
                 string password = TextLibrary.ToString(_tmp["khachhang_password"].ToString());
                 //lay thong tin user theo yeu cau dang nhap
                 this._khachhang = ctr_kh.get_by_id_hash_password(uid, password);
             }
         }
     }
     //
     //
     ViewBag.nhanvien = this._nhanvien;
     ViewBag.khachhang = this._khachhang;
     //get cart
         if (Session["giohang"] != null)
         {
             try
             {
                 this._giohang = (DonHang)Session["giohang"];
             }
             catch (Exception)
             {
                 this._giohang = new DonHang();
             }
         }
         else
         {
             this._giohang = new DonHang();
         }
         //gán khach hang va nhan vien
         this._giohang.khachhang = this._khachhang;
         this._giohang.khachhang_nhanvien = this._nhanvien;
         //save cart
         this._save_cart_to_session();
     ViewBag.giohang = this._giohang;
 }
        public ActionResult Index(int page=1)
        {
            //check
            if (!this._nhanvien_permission.Contains("sanpham_view"))
            {
                return this._fail_permission("sanpham_view");
            }
            SanPhamController ctr = new SanPhamController();
            NhomSanPhamController ctr_nhom = new NhomSanPhamController();
            HangSXController ctr_hangsx = new HangSXController();
            List<HangSX> hangsx_list = ctr_hangsx.timkiem(timkiem_sanpham["hangsx_id"]);
            NhomSanPham nhom_obj = ctr_nhom.get_by_id(TextLibrary.ToInt(timkiem_sanpham["nhomsanpham_id"]));
            List<NhomSanPham> nhomsanpham_list = ctr_nhom.get_tree2(nhom_obj);
            //pagination
                int max_item_per_page = TextLibrary.ToInt(this.timkiem_sanpham["max_item_per_page"]);
                Pagination pg = new Pagination();
                pg.set_current_page(page);
                pg.set_max_item_per_page(max_item_per_page);
                pg.set_total_item(
                    ctr.timkiem_count(
                        timkiem_sanpham["id"],
                        timkiem_sanpham["masp"],
                        timkiem_sanpham["ten"],
                        "",
                        TextLibrary.ToInt(timkiem_sanpham["gia_from"]),
                        TextLibrary.ToInt(timkiem_sanpham["gia_to"]),
                        hangsx_list, nhomsanpham_list, timkiem_sanpham["active"]
                        )
                    );
                pg.update();
            //Chọn danh sách nhân viên để hiển thị theo cookies tìm kiếm

            ViewBag.SanPham_List = ctr.timkiem(
                timkiem_sanpham["id"],
                timkiem_sanpham["masp"],
                timkiem_sanpham["ten"],
                "",
                TextLibrary.ToInt( timkiem_sanpham["gia_from"]),
                TextLibrary.ToInt(timkiem_sanpham["gia_to"]),
                hangsx_list, nhomsanpham_list, timkiem_sanpham["active"], timkiem_sanpham["order_by"], TextLibrary.ToBoolean(timkiem_sanpham["order_desc"]), pg.start_point, max_item_per_page
                );
            //set search cookies
            ViewBag.timkiem_sanpham = this.timkiem_sanpham;
            ViewBag.Title += " - Quản lý";
            ViewBag.pagination = pg;
            ViewBag.NhomSanPham2_List = ctr_nhom.timkiem();
            ViewBag.HangSX_List = ctr_hangsx.timkiem();
            return View();
        }