示例#1
0
        public static List<SanPham> LayDanhSachSanPhamLoadMoreNoiBat(int page)
        {
            int totalPerPay = 4;
            List<SanPham> list = new List<SanPham>();
            int startLiMit = totalPerPay * page;

            string query = String.Format("SELECT SP.MaSP, SP.TenSP, SP.GiaMoi, SP.GiaCu, SP.HinhSP, SP.MaHSX  FROm SanPham As SP, DonHang as DH, ChiTietDonHang as CTDH	WHERE SP.MaSP = CTDH.MaSP and DH.ID = CTDH.MaDH and DH.TinhTrang LIKE N'Chưa thanh toán' ORDER BY NgayThemSP DESC OFFSET " + startLiMit + " ROWS FETCH NEXT " + totalPerPay + " ROWS ONLY");
            string qur = String.Format("");
            try
            {
                conn.Open();
                command.CommandText = query;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    string masp = reader.GetString(0);
                    string tensp = reader.GetString(1);
                    Int64 giamoi = reader.GetInt64(2);
                    Int64 giacu = reader.GetInt64(3);
                    string hinhsp = reader.GetString(4);
                    string hangsx = reader.GetString(5);
                    SanPham sp = new SanPham(masp, tensp, giamoi, giacu, hinhsp, hangsx);
                    list.Add(sp);
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                conn.Close();
            }

            return list;
        }
示例#2
0
        public static List<SanPham> LayDanhSachSanPhamTheoMaDM(int madm)
        {
            List<SanPham> list = new List<SanPham>();
            string query = String.Format("SELECT MaSP, TenSP, GiaMoi, GiaCu, HinhSP, MaHSX FROM SanPham WHERE MaDM = " + madm + " and Status = 1 ORDER BY NgayThemSP DESC OFFSET 0 ROWS FETCH NEXT 4 ROWS ONLY ");

            try
            {
                conn.Open();
                command.CommandText = query;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    string masp = reader.GetString(0);
                    string tensp = reader.GetString(1);
                    Int64 giamoi = reader.GetInt64(2);
                    Int64 giacu = reader.GetInt64(3);
                    string hinhsp = reader.GetString(4);
                    string hangsx = reader.GetString(5);
                    SanPham sp = new SanPham(masp, tensp, giamoi, giacu, hinhsp, hangsx);
                    list.Add(sp);
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                conn.Close();
            }

            return list;
        }
示例#3
0
        public static List<SanPham> LayDanhSachSanPhamLoadMoreMoiNhat(int page)
        {
            int totalPerPay = 4;
            List<SanPham> list = new List<SanPham>();
            int startLiMit = totalPerPay * page;

            string query = String.Format("SELECT MaSP, TenSP, GiaMoi, GiaCu, HinhSP, MaHSX FROM SanPham WHERE Status = 1 ORDER BY NgayThemSP DESC OFFSET " + startLiMit + " ROWS FETCH NEXT " + totalPerPay + " ROWS ONLY");
            string qur = String.Format("");
            try
            {
                conn.Open();
                command.CommandText = query;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    string masp = reader.GetString(0);
                    string tensp = reader.GetString(1);
                    Int64 giamoi = reader.GetInt64(2);
                    Int64 giacu = reader.GetInt64(3);
                    string hinhsp = reader.GetString(4);
                    string hangsx = reader.GetString(5);
                    SanPham sp = new SanPham(masp, tensp, giamoi, giacu, hinhsp, hangsx);
                    list.Add(sp);
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                conn.Close();
            }

            return list;
        }
示例#4
0
        public static ArrayList LayDanhSachSanPham()
        {
            ArrayList list = new ArrayList();

            string query = String.Format("SELECT SP.MaSP, SP.TenSP, SP.GiaCu, SP.GiaMoi,  HSX.TenHSX, DM.TenDM ,SP.HinhSP, SP.MoTa, SP.TinhTrang FROM SanPham As SP, HangSanXuat as HSX, DanhMuc as DM WHERE SP.MaHSX = HSX.MaHSX and SP.MaDM = DM.MaDM and SP.Status = 1 Order by NgayThemSP desc");

            try
            {
                conn.Open();
                command.CommandText = query;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    string masp = reader.GetString(0);
                    string tensp = reader.GetString(1);
                    Int64 giamoi = reader.GetInt64(2);
                    Int64 giacu = reader.GetInt64(3);
                    string hangsx = reader.GetString(4);
                    string madm = reader.GetString(5);
                    string hinhsp = reader.GetString(6);
                    string mota = reader.GetString(7);
                    string res = mota.GetLast(20);
                    string tinhtrang = reader.GetString(8);
                    SanPham sp = new SanPham(masp, tensp, giamoi, giacu, hangsx, madm, hinhsp, res, tinhtrang);
                    list.Add(sp);
                }
            }
            finally
            {
                conn.Close();
            }

            return list;
        }
示例#5
0
        public static SanPham LaySanPhamTheoMa(String masanpham)
        {
            SanPham sp = null;
            string query = String.Format("SELECT SP.MaSP, SP.TenSP, SP.GiaCu, SP.GiaMoi, HSX.TenHSX, SP.MoTa, SP.TinhTrang, CTSP.SKU, CTSP.Model, CTSP.ManHinh, CTSP.TrongLuong, CTSP.MauSac, CTSP.BoNhoTrong, CTSP.BoNhoNgoai, CTSP.Camera, CTSP.HeDieuHanh, CTSP.LoaiPin, CTSP.CongKetNoi, CTSP.BaoHanh, SP.HinhSP, CTSP.CPU, CTSP.KichThuocManHinh, HSP.HinhAnh1, HSP.HinhAnh2, HSP.HinhAnh3, SP.MaDM FROM SanPham As SP, ChiTietSanPham as CTSP, HangSanXuat as HSX, HinhSanPham as HSP WHERE SP.MaSP = CTSP.MaSP and SP.MaHSX = HSX.MaHSX and SP.MaSP = HSP.MaSP and SP.MaSP = '" + masanpham + "'  and STT = 1");

            try
            {
                conn.Open();
                command.CommandText = query;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    sp = new SanPham();
                    sp.MaSP = reader.GetString(0);
                    sp.TenSP = reader.GetString(1);
                    sp.GiaCu = reader.GetInt64(2);
                    sp.GiaMoi = reader.GetInt64(3);
                    sp.HangSX = reader.GetString(4);
                    sp.MoTa = reader.GetString(5);
                    sp.TinhTrang = reader.GetString(6);
                    sp.SKU = reader.GetString(7);
                    sp.Model = reader.GetString(8);
                    sp.ManHinh = reader.GetString(9);
                    sp.TrongLuong = reader.GetString(10);
                    sp.MauSac = reader.GetString(11);
                    sp.BoNhoTrong = reader.GetString(12);
                    sp.BoNhoNgoai = reader.GetString(13);
                    sp.Camera = reader.GetString(14);
                    sp.HeDieuHanh = reader.GetString(15);
                    sp.LoaiPin = reader.GetString(16);
                    sp.CongKetNoi = reader.GetString(17);
                    sp.BaoHanh = reader.GetString(18);
                    sp.HinhSP = reader.GetString(19);
                    sp.CPU = reader.GetString(20);
                    sp.KichThuocManHinh = reader.GetString(21);
                    sp.HinhSP1 = reader.GetString(22);
                    sp.HinhSP2 = reader.GetString(23);
                    sp.HinhSP3 = reader.GetString(24);
                    sp.MaDM = reader.GetString(25);
                    return sp;
                }
            }
            finally
            {
                conn.Close();
            }

            return null;
        }
示例#6
0
        public static ArrayList LayDanhSachSanPhamTheoTuKhoaDanhMuc(String keyword, String madanhmuc)
        {
            ArrayList list = new ArrayList();
            string query = String.Format("SELECT MaSP, TenSP, GiaMoi, GiaCu, HinhSP, MaHSX FROM SanPham, DanhMuc WHERE SanPham.MaDM = DanhMuc.MaDM and SanPham.TenSP LIKE '%" + keyword + "%' and DanhMuc.MaDM = '" + madanhmuc + "'");

            try
            {
                conn.Open();
                command.CommandText = query;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    string masp = reader.GetString(0);
                    string tensp = reader.GetString(1);
                    Int64 giamoi = reader.GetInt64(2);
                    Int64 giacu = reader.GetInt64(3);
                    string hinhsp = reader.GetString(4);
                    string hangsx = reader.GetString(5);
                    SanPham sp = new SanPham(masp, tensp, giamoi, giacu, hinhsp, hangsx);
                    list.Add(sp);
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                conn.Close();
            }

            return list;
        }
示例#7
0
        public static ArrayList LayDanhSachSanPhamTheoTuKhoa(String keyword)
        {
            ArrayList list = new ArrayList();
            string query = String.Format("SELECT SanPham.MaSP, SanPham.TenSP, SanPham.GiaMoi, SanPham.GiaCu, SanPham.HinhSP, SanPham.MaHSX, ChiTietSanPham.Model, ChiTietSanPham.ManHinh, ChiTietSanPham.Camera, ChiTietSanPham.HeDieuHanh, ChiTietSanPham.ManHinh, ChiTietSanPham.LoaiPin, ChiTietSanPham.BoNhoTrong, SanPham.TinhTrang FROM SanPham, ChiTietSanPham WHERE SanPham.MaSP = ChiTietSanPham.MaSP and (SanPham.TenSP LIKE '%" + keyword + "%' OR SanPham.MaHSX LIKE '%" + keyword + "%')");

            try
            {
                conn.Open();
                command.CommandText = query;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    string masp = reader.GetString(0);
                    string tensp = reader.GetString(1);
                    Int64 giamoi = reader.GetInt64(2);
                    Int64 giacu = reader.GetInt64(3);
                    string hinhsp = reader.GetString(4);
                    string hangsx = reader.GetString(5);
                    SanPham sp = new SanPham(masp, tensp, giamoi, giacu, hinhsp, hangsx);
                    list.Add(sp);
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                conn.Close();
            }

            return list;
        }