Ejemplo n.º 1
0
 public static IEnumerable <SanPham> DS()
 {
     {
         var db = new ShopOnlineConnectionDB();
         return(db.Query <SanPham>("select * from SanPham where TinhTrang='0'"));
     }
 }
 public static IEnumerable <NhaSanXuat> DS()
 {
     {
         var db = new ShopOnlineConnectionDB();
         return(db.Query <NhaSanXuat>("select * from NhaSanXuat "));
     }
 }
Ejemplo n.º 3
0
 public static IEnumerable <LoaiSanPham> DS()
 {
     {
         var db = new ShopOnlineConnectionDB();
         return(db.Query <LoaiSanPham>("select * from LoaiSanPham "));
     }
 }
Ejemplo n.º 4
0
 public static void Them(string masanpham, string mataikhoan, int soluong, int gia, string tensanpham)
 {
     using (var db = new ShopOnlineConnectionDB())
     {
         var x = db.Query <GioHang>("select * from GioHang Where MaTaiKhoan = '" + mataikhoan + "' and MaSanPham = '" + masanpham + "'").ToList();
         if (x.Count() > 0)
         {
             // gọi hàm update so lượng
             int a = (int)x.ElementAt(0).SoLuong + soluong;
             CapNhat(masanpham, mataikhoan, a, gia, tensanpham);
         }
         else
         {
             GioHang giohang = new GioHang()
             {
                 MaSanPham  = masanpham,
                 MaTaiKhoan = mataikhoan,
                 SoLuong    = soluong,
                 Gia        = gia,
                 TenSanPham = tensanpham,
                 TongTien   = gia * soluong
             };
             db.Insert(giohang);
         }
     }
 }
Ejemplo n.º 5
0
 public static IEnumerable <NhaSanXuat> NhaSanXuat()
 {
     using (var db = new ShopOnlineConnectionDB())
     {
         return(db.Query <ShopOnlineConnection.NhaSanXuat>("select * from NhaSanXuat "));
     }
 }
Ejemplo n.º 6
0
 public static IEnumerable <LoaiSanPham> LoaiSanPham()
 {
     using (var db = new ShopOnlineConnectionDB())
     {
         return(db.Query <ShopOnlineConnection.LoaiSanPham>("select * from LoaiSanPham "));
     }
 }
Ejemplo n.º 7
0
 public static IEnumerable <GioHang> DanhSach(string mataikhoan)
 {
     using (var db = new ShopOnlineConnectionDB())
     {
         return(db.Query <GioHang>("select * from GioHang where MaTaiKhoan = '" + mataikhoan + "'"));
     }
 }
Ejemplo n.º 8
0
 public static void Xoa(string masanpham, string mataikhoan)
 {
     using (var db = new ShopOnlineConnectionDB())
     {
         var a = db.Query <GioHang>("select * from GioHang where MaSanPham = '" + masanpham + "' and MaTaiKhoan ='" + mataikhoan + "'").FirstOrDefault();
         db.Delete(a);
     }
 }
Ejemplo n.º 9
0
        //----------------------------------------------admin----------
        public static IEnumerable <SanPham> DanhSachSP()
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <SanPham>("select * from SanPham"));
            //foreach (var item in ds)
            //{
            //    item.HinhChinh = LoadAvartaImg(item.MaSanPham);
            //}
            //return ds;
        }
Ejemplo n.º 10
0
 public static int TongTien(string mataikhoan)
 {
     using (var db = new ShopOnlineConnectionDB())
     {
         List <GioHang> a = DanhSach(mataikhoan).ToList();
         if (a.Count() == 0)
         {
             return(0);
         }
         return(db.Query <int>("select sum(Gia) from GioHang where MaTaiKhoan = '" + mataikhoan + "' ").FirstOrDefault());
     }
 }
Ejemplo n.º 11
0
 public static void CapNhat(string masanpham, string mataikhoan, int soluong, int gia, string tensanpham)
 {
     using (var db = new ShopOnlineConnectionDB())
     {
         GioHang giohang = new GioHang()
         {
             MaSanPham  = masanpham,
             MaTaiKhoan = mataikhoan,
             SoLuong    = soluong,
             Gia        = gia,
             TenSanPham = tensanpham,
             TongTien   = gia * soluong
         };
         var tamp = db.Query <GioHang>("Select idGH from GioHang Where MaTaiKhoan = '" + mataikhoan + "' and MaSanPham = '" + masanpham + "'").FirstOrDefault();
         db.Update(giohang, tamp.IdGH);
     }
 }
Ejemplo n.º 12
0
        public static IEnumerable <SanPham> TimKiem(string TimKiem)
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <SanPham>("select * from SanPham where TenSanPham like '%" + TimKiem + "%'"));
        }
Ejemplo n.º 13
0
        public static IEnumerable <SanPham> DanhSach()
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <SanPham>("select * from SanPham "));
        }
Ejemplo n.º 14
0
        public static IEnumerable <SanPham> HotItems()
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <SanPham>("select Top 8 * from SanPham where LuotView>0"));
        }
Ejemplo n.º 15
0
        //---------------------------------menu loại sản phẩm--------------------------------------//
        public static IEnumerable <LoaiSanPham> LoaiSanPham()
        {
            var sql = new ShopOnlineConnectionDB();

            return(sql.Query <LoaiSanPham>("select * from LoaiSanPham where TinhTrang=0"));
        }
Ejemplo n.º 16
0
        public static IEnumerable <SanPham> TatCaSLoaiSanPham(string id)
        {
            var sql = new ShopOnlineConnectionDB();

            return(sql.Query <SanPham>("select * from SanPham where Maloaisanpham = @0", id).ToList());
        }
Ejemplo n.º 17
0
        //------------ Khach hàng---------------------------
        public static IEnumerable <NhaSanXuat> DanhSach()
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <NhaSanXuat>("select * from NhaSanXuat where TinhTrang = '0         '"));
        }
Ejemplo n.º 18
0
        //---------------------------menu nhà sản xuất-----------------------------------------//
        public static IEnumerable <NhaSanXuat> NhaSanXuat()
        {
            var sql = new ShopOnlineConnectionDB();

            return(sql.Query <NhaSanXuat>("select * from NhaSanXuat where TinhTrang=0"));
        }
Ejemplo n.º 19
0
        public static IEnumerable <SanPham> TopHot()
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <SanPham>("select * from SanPham where LuotXem > 2"));
        }
Ejemplo n.º 20
0
        public static IEnumerable <SanPham> Top4New()
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <SanPham>("select * from SanPham where GhiChu = N'New'"));
        }
Ejemplo n.º 21
0
        public static IEnumerable <SanPham> ChiTiet(String id)
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <SanPham>("select * from SanPham where MaLoaiSanPham = '" + id + "'"));
        }
Ejemplo n.º 22
0
        public static IEnumerable <SanPham> ChiTiet(String id)
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <SanPham>("select * from SanPham where MaNHaSanXuat = '" + id + "' AND TinhTrang = '0         '"));
        }
Ejemplo n.º 23
0
        public static IEnumerable <SanPham> TopHot()
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <SanPham>("select Top 4 * from SanPham Where LuotView > '1000' AND TinhTrang = '0         '"));
        }
Ejemplo n.º 24
0
        public static IEnumerable <LoaiSanPham> DanhSach()
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <LoaiSanPham>("select * from LoaiSanPham where TinhTrang = 0"));
        }
Ejemplo n.º 25
0
        public static IEnumerable <BinhLuan> LoadBinhLuan(int page = 1, int pagesize = 1)
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <BinhLuan>("select * from BinhLuan ORDER BY Ngay desc").ToPagedList(page, pagesize));
        }