예제 #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 "));
     }
 }
예제 #3
0
 public static IEnumerable <LoaiSanPham> DS()
 {
     {
         var db = new ShopOnlineConnectionDB();
         return(db.Query <LoaiSanPham>("select * from LoaiSanPham "));
     }
 }
예제 #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);
         }
     }
 }
예제 #5
0
 public static IEnumerable <NhaSanXuat> NhaSanXuat()
 {
     using (var db = new ShopOnlineConnectionDB())
     {
         return(db.Query <ShopOnlineConnection.NhaSanXuat>("select * from NhaSanXuat "));
     }
 }
예제 #6
0
 public static IEnumerable <LoaiSanPham> LoaiSanPham()
 {
     using (var db = new ShopOnlineConnectionDB())
     {
         return(db.Query <ShopOnlineConnection.LoaiSanPham>("select * from LoaiSanPham "));
     }
 }
예제 #7
0
 public static IEnumerable <GioHang> DanhSach(string mataikhoan)
 {
     using (var db = new ShopOnlineConnectionDB())
     {
         return(db.Query <GioHang>("select * from GioHang where MaTaiKhoan = '" + mataikhoan + "'"));
     }
 }
예제 #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);
     }
 }
예제 #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;
        }
예제 #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());
     }
 }
예제 #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);
     }
 }
예제 #12
0
        public static IEnumerable <SanPham> TimKiem(string TimKiem)
        {
            var db = new ShopOnlineConnectionDB();

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

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

            return(db.Query <SanPham>("select Top 8 * from SanPham where LuotView>0"));
        }
예제 #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"));
        }
예제 #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());
        }
예제 #17
0
        //------------ Khach hàng---------------------------
        public static IEnumerable <NhaSanXuat> DanhSach()
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <NhaSanXuat>("select * from NhaSanXuat where TinhTrang = '0         '"));
        }
예제 #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"));
        }
예제 #19
0
        public static IEnumerable <SanPham> TopHot()
        {
            var db = new ShopOnlineConnectionDB();

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

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

            return(db.Query <SanPham>("select * from SanPham where MaLoaiSanPham = '" + id + "'"));
        }
예제 #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         '"));
        }
예제 #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         '"));
        }
예제 #24
0
        public static IEnumerable <LoaiSanPham> DanhSach()
        {
            var db = new ShopOnlineConnectionDB();

            return(db.Query <LoaiSanPham>("select * from LoaiSanPham where TinhTrang = 0"));
        }
예제 #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));
        }