Ejemplo n.º 1
0
        //Hiển thị chi tiết sản phẩm
        public DataSet ChiTietSanPham(SanPham sp)
        {
            string         sql;
            TonKho         TonKho  = new TonKho();
            TonKhoService1 _TonKho = new TonKhoService1();

            TonKho.SP_ID = sp.SP_ID;
            List <TonKho> ListTK = _TonKho.TimKiemTonKho_SPID(TonKho);

            if (ListTK.Count > 0)
            {
                sql = "select sp.SP_ID,TenSP,sp.NhaSX_ID,TenNhaSX,CPU,RAM,HDD,BaoHanh,Hinh,DonGia,MoTa,SoLuongTon,ThoiGian"
                      + " from SanPham sp, NhaSX nsx, (select top 1 * from TonKho where SP_ID=@SP_ID order by ThoiGian desc) as tk"
                      + " where sp.NhaSX_ID = nsx.NhaSX_ID and sp.SP_ID=tk.SP_ID";
            }
            else
            {
                sql = "select sp.SP_ID,TenSP,sp.NhaSX_ID,TenNhaSX,CPU,RAM,HDD,BaoHanh,Hinh,DonGia,MoTa,SoLuongTon=0"
                      + " from SanPham sp, NhaSX nsx"
                      + " where sp.NhaSX_ID = nsx.NhaSX_ID and SP_ID=@SP_ID";
            }
            SqlParameter spid = new SqlParameter("@SP_ID", sp.SP_ID);
            DataSet      ds   = SqlDatabase.ExecuteQueryWithDataSet(sql, CommandType.Text, spid);

            return(ds);
        }
 //Hiển thị chi tiết sản phẩm
 public DataSet ChiTietSanPham(SanPham sp)
 {
     string sql;
     TonKho TonKho = new TonKho();
     TonKhoService1 _TonKho = new TonKhoService1();
     TonKho.SP_ID = sp.SP_ID;
     List<TonKho> ListTK = _TonKho.TimKiemTonKho_SPID(TonKho);
     if (ListTK.Count > 0)
     {
         sql = "select sp.SP_ID,TenSP,sp.NhaSX_ID,TenNhaSX,CPU,RAM,HDD,BaoHanh,Hinh,DonGia,MoTa,SoLuongTon,ThoiGian"
                     + " from SanPham sp, NhaSX nsx, (select top 1 * from TonKho where SP_ID=@SP_ID order by ThoiGian desc) as tk"
                     + " where sp.NhaSX_ID = nsx.NhaSX_ID and sp.SP_ID=tk.SP_ID";
     }
     else
     {
         sql = "select sp.SP_ID,TenSP,sp.NhaSX_ID,TenNhaSX,CPU,RAM,HDD,BaoHanh,Hinh,DonGia,MoTa,SoLuongTon=0"
                     + " from SanPham sp, NhaSX nsx"
                     + " where sp.NhaSX_ID = nsx.NhaSX_ID and SP_ID=@SP_ID";
     }
     SqlParameter spid = new SqlParameter("@SP_ID", sp.SP_ID);
     DataSet ds = SqlDatabase.ExecuteQueryWithDataSet(sql, CommandType.Text, spid);
     return ds;
 }