示例#1
0
 public static int TongTien(string mataikhoan)
 {
     using (var db = new ConnectDBShopDB())
     {
         return(db.Query <int>("SELECT sum(TongTien) FROM GioHang WHERE MaTaiKhoan= '" + mataikhoan + "'").FirstOrDefault());
     }
 }
示例#2
0
 public static void Them(string masanpham, string mataikhoan, string tensanpham, int soluong, int gia, string hinhchinh)
 {
     using (var db = new ConnectDBShopDB())
     {
         var listx = db.Query <GioHang>("SELECT * FROM GioHang WHERE MaTaiKhoan = '" + mataikhoan + "' AND MaSanPham = '" + masanpham + "'").ToList();
         if (listx.Count() > 0)
         {
             //tolist tao 1 bang,dem trong do neu > 0 thi da có sp. chi update len
             //Goi ham update so luong
             int sl = (int)listx.ElementAt(0).SoLuong + soluong;
             CapNhat(masanpham, mataikhoan, tensanpham, sl, gia, hinhchinh);
         }
         else//<0 thi tạo moi 1 gio hang
         {
             GioHang giohang = new GioHang()
             {
                 MaSanPham  = masanpham,
                 MaTaiKhoan = mataikhoan,
                 TenSanPham = tensanpham,
                 SoLuong    = soluong,
                 Gia        = gia,
                 HinhChinh  = hinhchinh,
                 TongTien   = gia * soluong
             };
             db.Insert(giohang);
         }
     }
 }
示例#3
0
 public static IEnumerable <GioHang> DanhSachGH(String mataikhoan)
 {
     using (var db = new ConnectDBShopDB())
     {
         return(db.Query <GioHang>("SELECT * FROM GioHang WHERE MaTaiKhoan = '" + mataikhoan + "'"));
     }
 }
示例#4
0
 public static void Xoa(string masanpham, string mataikhoan)
 {
     using (var db = new ConnectDBShopDB())
     {
         var sp = db.Query <GioHang>("SELECT * FROM GioHang WHERE MaTaiKhoan = '" + mataikhoan + "' AND MaSanPham = '" + masanpham + "'").FirstOrDefault();
         db.Delete(sp);
     }
 }
示例#5
0
 public static void CapNhat(string masanpham, string mataikhoan, string tensanpham, int soluong, int gia, string hinhchinh)
 {
     using (var db = new ConnectDBShopDB())
     {
         GioHang giohang = new GioHang()
         {
             MaSanPham  = masanpham,
             MaTaiKhoan = mataikhoan,
             TenSanPham = tensanpham,
             SoLuong    = soluong,
             Gia        = gia,
             HinhChinh  = hinhchinh,
             TongTien   = gia * soluong
         };
         var tamp = db.Query <GioHang>("SELECT IDGH FROM GioHang WHERE MaTaiKhoan = '" + mataikhoan + "' AND MaSanPham = '" + masanpham + "'").FirstOrDefault();
         db.Update(giohang, tamp.IDGH);
     }
 }
示例#6
0
        //ADMIN
        public static IEnumerable <LoaiSanPham> DanhSachAll()
        {
            var db = new ConnectDBShopDB();

            return(db.Query <LoaiSanPham>("SELECT * FROM LoaiSanPham"));
        }
示例#7
0
        public static IEnumerable <SanPham> Chitiet(String id)
        {
            var db = new ConnectDBShopDB();

            return(db.Query <SanPham>("SELECT * FROM SanPham WHERE MaLoaiSanPham = '" + id + "' AND TinhTrang = '0         '")); //cong chuoi
        }
示例#8
0
        // NGƯỜI DÙNG
        public static IEnumerable <LoaiSanPham> DanhSach()
        {
            var db = new ConnectDBShopDB();

            return(db.Query <LoaiSanPham>("SELECT * FROM LoaiSanPham WHERE TinhTrang = '0         '"));
        }
示例#9
0
        public static IEnumerable <SanPham> SanPhamHot()
        {
            var db = new ConnectDBShopDB();

            return(db.Query <SanPham>("SELECT Top 4 * FROM SanPham WHERE SoLuongDaBan > 0 AND TinhTrang = '0         '"));
        }
示例#10
0
        public static IEnumerable <SanPham> SanPhamMoi()
        {
            var db = new ConnectDBShopDB();

            return(db.Query <SanPham>("SELECT Top 4 * FROM SanPham WHERE LuotView < 50 AND TinhTrang = '0         '"));
        }
示例#11
0
        public static IEnumerable <AspNetUser> DanhSachKH()
        {
            var db = new ConnectDBShopDB();

            return(db.Query <AspNetUser>("SELECT * FROM AspNetUsers"));
        }
示例#12
0
        public static IEnumerable <GioHang> DonDatHang()
        {
            var db = new ConnectDBShopDB();

            return(db.Query <GioHang>("SELECT * FROM GioHang"));
        }
示例#13
0
        public static IEnumerable <NhaSanXuat> DanhSachAll()
        {
            var db = new ConnectDBShopDB();

            return(db.Query <NhaSanXuat>("SELECT * FROM NhaSanXuat"));
        }
示例#14
0
        // NGƯỜI DÙNG
        public static IEnumerable <NhaSanXuat> DanhSach()
        {
            var db = new ConnectDBShopDB();

            return(db.Query <NhaSanXuat>("SELECT * FROM NhaSanXuat WHERE TinhTrang = '0         '"));
        }