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) { 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 }
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(); }
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(); }