Example #1
0
 public static void Them(string masanpham, string mataikhoan, int gia, int soluong, string tensanpham)
 {
     using (var sql = new MobileShopConnectionDB())
     {
         var x = sql.Query <GioHang>("select * from GioHang Where MaTaiKhoan = '" + mataikhoan + "'and MaSP ='" + masanpham + "'").ToList();
         if (x.Count() > 0)
         {
             //update so luong
             int a = (int)x.ElementAt(0).SoLuong + soluong;
             CapNhat(masanpham, mataikhoan, gia, a, tensanpham);
         }
         else
         {
             GioHang giohang = new GioHang()
             {
                 MaSP       = masanpham,
                 MaTaiKhoan = mataikhoan,
                 Gia        = gia,
                 SoLuong    = soluong,
                 TenSP      = tensanpham,
                 TongTien   = gia * soluong
             };
             sql.Insert(giohang);
         }
     }
 }
Example #2
0
 public static int TongTien(string mataikhoan)
 {
     using (var sql = new MobileShopConnectionDB())
     {
         return(sql.Query <int>("select sum(TongTien) from GioHang where MaTaiKhoan = '" + mataikhoan + "'").FirstOrDefault());
     }
 }
Example #3
0
 public static LoaiSP ChiTietViewModel(int?id)
 {
     using (var db = new MobileShopConnectionDB())
     {
         return(db.Query <MobileShopConnection.LoaiSP>("select * from LoaiSP where MaLoai = @0", id).FirstOrDefault());
     }
 }
Example #4
0
 public static IEnumerable <GioHang> DanhSach(string mataikhoan)
 {
     using (var sql = new MobileShopConnectionDB())
     {
         return(sql.Query <GioHang>("select * from GioHang where  MaTaiKhoan = '" + mataikhoan + "'"));
     }
 }
 public static IEnumerable <BinhLuan> DanhSach(String MaSP)
 {
     using (var sql = new MobileShopConnectionDB())
     {
         return(sql.Query <BinhLuan>(" select * from BinhLuan  where MaSP = @0 ORDER BY Ngay DESC", MaSP));
     }
 }
 public static IEnumerable <MobileShopConnection.v_GioHang> DanhSach(string MaTaiKhoan)
 {
     using (var db = new MobileShopConnectionDB())
     {
         return(db.Query <v_GioHang>("select * from v_GioHang where MaTaiKhoan=@0", MaTaiKhoan));
     }
 }
Example #7
0
 public static void Xoa(string masanpham, string mataikhoan)
 {
     using (var sql = new MobileShopConnectionDB())
     {
         var a = sql.Query <GioHang>("select * from GioHang Where MaTaiKhoan = '" + mataikhoan + "'and MaSP ='" + masanpham + "'").FirstOrDefault();
         sql.Delete(a);
     }
 }
Example #8
0
 public static void CapNhat(string masanpham, string mataikhoan, int gia, int soluong, string tensanpham)
 {
     using (var sql = new MobileShopConnectionDB())
     {
         GioHang giohang = new GioHang()
         {
             MaSP       = masanpham,
             MaTaiKhoan = mataikhoan,
             Gia        = gia,
             SoLuong    = soluong,
             TenSP      = tensanpham,
             TongTien   = gia * soluong
         };
         var tamp = sql.Query <GioHang>("select id from GioHang Where MaTaiKhoan = '" + mataikhoan + "'and MaSP ='" + masanpham + "'").FirstOrDefault();
         sql.Update(giohang, tamp.Id);
     }
 }
Example #9
0
        public static IEnumerable <SanPham> Search(string searchString)//, int page, int pageSize )
        {
            //var db = new MobileShopConnectionDB();
            //IQueryable<SanPham> model = db.SanPhams;
            ////IObs<SanPham> model = db.Query<SanPham>("select * from SanPham where TenSP Like '%" + searchString + "%'").ToList();
            ////var text = db.Query<SanPham>("select * from SanPham where TenSP Like '%" + searchString + "%'");

            //if (!string.IsNullOrEmpty(searchString))
            //{
            //    model = model.Where(x => x.TenSP.Contains(searchString) || x.MoTa.Contains(searchString)).OrderByDescending(x => x.MaSP);
            //    //text = text.Where(s => s.TenSP.Contains(searchString)).ToList();
            //}
            //return model.ToPagedList(page, pageSize);
            var db = new MobileShopConnectionDB();

            return(db.Query <SanPham>("Select * From SanPham Where TenSP like '%" + searchString + "%' or Ram like '%" + searchString + "%' or Gia like '%" + searchString + "%' or SoLuongBan like '%" + searchString + "%' or HeDieuHanh like '%" + searchString + "%' or BoNhoTrong like '%" + searchString + "%' or CameraTruoc like '%" + searchString + "%' or CameraSau like '%" + searchString + "%'  or TheNho like '%" + searchString + "%'"));
        }
Example #10
0
        public static IEnumerable <MobileShopConnection.LoaiSP> DanhSach()
        {
            var db = new MobileShopConnectionDB();

            return(db.Query <MobileShopConnection.LoaiSP>("select * from LoaiSP where BiXoa<>1"));
        }
Example #11
0
        public static IEnumerable <SanPham> DanhSachTOP10()
        {
            var sql = new MobileShopConnectionDB();

            return(sql.Query <SanPham>(" SELECT TOP 10  * FROM SanPham WHERE TinhTrang = 0 ORDER BY SoLuongBan DESC"));
        }
Example #12
0
        public static IEnumerable <SanPham> DanhSachSP()
        {
            var sql = new MobileShopConnectionDB();

            return(sql.Query <SanPham>("select * from SanPham "));
        }
Example #13
0
        //admin
        //them
        public static IEnumerable <NhaSanXuat> DanhSanhNSXAdmin()
        {
            var sql = new MobileShopConnectionDB();

            return(sql.Query <NhaSanXuat>("select * from NhaSanXuat "));
        }
Example #14
0
        public static IEnumerable <SanPham> ChiTietNSX(String id)
        {
            var sql = new MobileShopConnectionDB();

            return(sql.Query <SanPham>("select * from SanPham where MaNhaSX = '" + id + "'"));
        }
Example #15
0
        public static IEnumerable <NhaSanXuat> DanhSach()
        {
            var sql = new MobileShopConnectionDB();

            return(sql.Query <NhaSanXuat>("select *  from NhaSanXuat where TinhTrang = 0"));
        }
        public static IEnumerable <LoaiSP> DanhSach()
        {
            var sql = new MobileShopConnectionDB();

            return(sql.Query <LoaiSP>("select * from LoaiSP where TinhTrang = 0"));
        }
        ////admin
        ////them
        public static IEnumerable <LoaiSP> DanhSanhLSPAdmin()
        {
            var sql = new MobileShopConnectionDB();

            return(sql.Query <LoaiSP>("select * from LoaiSP "));
        }
Example #18
0
        public static IEnumerable <BinhLuan> DanhSach(int id)
        {
            var db = new MobileShopConnectionDB();

            return(db.Query <BinhLuan>("select * from BinhLuan where TinhTrang != 1 and MaSanPham=@0 order by ThoiGian desc", id));
        }
Example #19
0
        public static IEnumerable <MobileShopConnection.SanPham> DanhSach()
        {
            var db = new MobileShopConnectionDB();

            return(db.Query <MobileShopConnection.SanPham>("select * from SanPham where BiXoa != 1"));
        }