public FmQuanLyHangSanXuat()
 {
     InitializeComponent();
     dtgvHangSX.AutoGenerateColumns = false;
     HSXCtr = new HangSXController();
     LoadDTGV_HangSX();
 }
Ejemplo n.º 2
0
        public FmThongTinSanPham(SanPham sp = null, SanPhamController spc = null)
        {
            InitializeComponent();
            dtgvHinhAnh.AutoGenerateColumns = false;
            dtgvChiTietSanPham.AutoGenerateColumns = false;
            //set primary context
            if (spc != null) SPCtr = spc;
            else SPCtr = new SanPhamController();

            HSXCtr = new HangSXController(this.SPCtr._db);
            MSCtr = new MauSacController(this.SPCtr._db);
            HACtr = new HinhAnhController(this.SPCtr._db);
            SPCTCtr = new SanPham_ChiTietController(this.SPCtr._db);
            MSCtr.timkiem();
            LoadCb_HangSX();
            if (sp == null)
            {
                this.sp = new SanPham(SPCtr._db);
                this.Text = "Thêm Mới Sản Phẩm";
            }
            else
            {
                this.sp = sp;
                this.sp._set_context(SPCtr._db);
                EditMode = true;
                ThongTinFormSanPham = this.sp;
                LoadDTGV_HinhAnh();
                LoadDTGV_ChiTietSP();
            }
        }
 public ActionResult Index(int id=0)
 {
     HangSXController ctr_hangsx = new HangSXController();
     SanPhamController ctr = new SanPhamController();
     SanPham obj = ctr.get_by_id(id);
     if (obj == null)
     {
         return RedirectToAction("Index","FrontHome");
     }
     ViewBag.sanpham = obj;
     return View();
 }
        public ActionResult Index(int page=1)
        {
            //controller
            SanPhamController ctr=new SanPhamController();
            HangSXController ctr_hangsx = new HangSXController();
            //varibles
            int gia_from = TextLibrary.ToInt(_timkiem_sanpham["gia_from"]);
            int gia_to = TextLibrary.ToInt(_timkiem_sanpham["gia_to"]);
            Boolean order_desc = TextLibrary.ToBoolean(_timkiem_sanpham["order_desc"]);
            int max_item_per_page= TextLibrary.ToInt(_timkiem_sanpham["max_item_per_page"]);
            int hang_sx_id = TextLibrary.ToInt(_timkiem_sanpham["hangsx_id"]);
            HangSX hangsx = ctr_hangsx.get_by_id(
                hang_sx_id
            );
            //pagination
            PaginationLibrary pagination = new PaginationLibrary();
            pagination.set_current_page(page);
            pagination.set_max_item_per_page(
                max_item_per_page
            );

            pagination.set_total_item(
                ctr.timkiem_count(
                "",
                "",
                _timkiem_sanpham["ten"],
                "",
                gia_from,
                gia_to,
                hangsx,
                "1"
                )
            );
            pagination.update();
            //View data
            ViewBag.SanPham_List = ctr.timkiem(
                "",
                "",
                _timkiem_sanpham["ten"],
                "",
                gia_from,
                gia_to,
                hangsx,
                "1",
                _timkiem_sanpham["order_by"],
                order_desc,
                pagination.start_point,
                pagination.max_item_per_page
            );
            ViewBag.pagination = pagination;
            return View();
        }
Ejemplo n.º 5
0
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     base.OnActionExecuting(filterContext);
     ViewBag.Title = "Cửa hàng DTDD";
     //tim kiem
     //build timkiem_nhanvien
     if (Request.Cookies.Get("timkiem_sanpham") == null)
     {
         //chưa set cookies trước => tiến hành set cookies
         this._khoitao_timkiem_cookie();
         Response.Cookies.Add(CookieLibrary.Base64Encode(this._timkiem_sanpham));
     }
     else
     {
         try
         {
             this._timkiem_sanpham = CookieLibrary.Base64Decode(Request.Cookies.Get("timkiem_sanpham"));
         }
         catch (Exception)
         {
             this._khoitao_timkiem_cookie();
             Response.Cookies.Add(CookieLibrary.Base64Encode(this._timkiem_sanpham));
         }
     }
     ViewBag.timkiem_sanpham = this._timkiem_sanpham;
     HangSXController ctr = new HangSXController();
     ViewBag.HangSX_List = ctr.timkiem("", "", "1");
     //CART section
         try
         {
             if (Session["giohang"] != null)
             {
                 this._giohang = (DonHang)Session["giohang"];
             }
             else
             {
                 this._giohang = new DonHang();
             }
         }
         catch (Exception)
         {
             this._giohang = new DonHang();
         }
         //set session obj
         this._save_cart_to_session();
         ViewBag.giohang = this._giohang;
 }
 /*
  * Hiển thị danh sách sản phẩm theo hãng SX có phân trang
  * Có nút Add to Cart => redirect đến trang Sản phẩm chi tiết để chọn
  * SL và màu sắc cần đặt
  */
 public ActionResult Index(int hangsx_id=0, int page=1)
 {
     SanPhamController ctr = new SanPhamController();
     HangSXController ctr_hangsx = new HangSXController();
     HangSX hangsx = ctr_hangsx.get_by_id(hangsx_id);
     //check
     if (hangsx==null || hangsx.active==false)
     {
         return RedirectToAction("Index","FrontHome");
     }
     //pagination
     int max_item_per_page=4;//will get from setting
     //pagination
         PaginationLibrary pg = new PaginationLibrary();
         pg.set_current_page(page);
         pg.set_max_item_per_page(max_item_per_page);
         pg.set_total_item(
             ctr.timkiem_count(
             "",
             "",
             "",
             "",
             0,
             0,
             hangsx,
             "1")
         );
     pg.update();
     ViewBag.SanPham_List = ctr.timkiem(
         "",
         "",
         "",
         "",
         -1,
         -1,
         hangsx,
         "1",
         _timkiem_sanpham["order_by"],
         TextLibrary.ToBoolean(_timkiem_sanpham["order_desc"])
         ,pg.start_point,
         max_item_per_page);
     ViewBag.pagination = pg;
     ViewBag.hangsx = hangsx;
     return View();
 }
Ejemplo n.º 7
0
 public HangSX()
 {
     this._ctr = new HangSXController();
     this._Init();
 }
Ejemplo n.º 8
0
 public HangSX(DTDDDbContext context)
 {
     this._ctr = new HangSXController(context);
     this._Init();
 }