public List <ItemInGioHang> loadSanPhamYeuThichDaXem(string function) { List <ItemInGioHang> listSP = new List <ItemInGioHang>(); string query = ""; if (function == "yeuthich") { query = "select sp.ma_sp, tensp, gia from dbo.sanpham sp, dbo.sanphamyeuthich yt where yt.ma_sp=sp.ma_sp and yt.idnguoimua= @id "; } else if (function == "daxem") { query = "select sp.ma_sp, tensp, gia from dbo.sanpham sp, dbo.sanphamdaxem yt " + "where yt.ma_sp=sp.ma_sp and yt.idnguoimua= @id order by yt.ma_sanphamdaxem desc "; } DataTable dataTable = Data.Instance.ExcuteQuery(query, new object[] { Account.Instance.id }); foreach (DataRow row in dataTable.Rows) { ItemInGioHang item = new ItemInGioHang(); item.SetItem(row["ma_sp"].ToString(), row["tensp"].ToString(), 1, Int32.Parse(row["gia"].ToString()), true); string sqlQuery1 = @"SELECT * FROM dbo.HinhAnh where ma_sp='" + row["ma_sp"].ToString() + "'"; DataTable dataTable1 = Data.Instance.ExcuteQuery(sqlQuery1); foreach (DataRow row1 in dataTable1.Rows) { item.Link_image.Add(row1["data"].ToString()); } listSP.Add(item); } return(listSP); }
public List <ItemInGioHang> loadDataSanPhamTrongGioNoPic() { List <ItemInGioHang> listSPTrongGio = new List <ItemInGioHang>(); string sqlQuery = "select * from dbo.sanpham sp left join dbo.sanphamgiohang gh on sp.ma_sp = gh.ma_sp" + " where idnguoimua= @id and gh.isSelect=1 "; DataTable dataTable = Data.Instance.ExcuteQuery(sqlQuery, new object[] { Account.Instance.id }); foreach (DataRow row in dataTable.Rows) { ItemInGioHang item = new ItemInGioHang(); item.SetItem(row["ma_sp"].ToString(), row["tensp"].ToString(), Int32.Parse(row["soluong_giohang"].ToString()), Int32.Parse(row["gia"].ToString()), bool.Parse(row["isSelect"].ToString())); listSPTrongGio.Add(item); } return(listSPTrongGio); }
public List <ItemInGioHang> loadSanPhamDangGiao(string trangthai) { List <ItemInGioHang> listSPTrongGio = new List <ItemInGioHang>(); string sqlQuery = "select distinct ma_sp, tensp, gia from dbo.cthd ct , dbo.hoadon hd, dbo.sanpham sp where ct.sohd=hd.sohd " + "and ct.trangthai= @trangthai and hd.id_ngmua= @id and sp.ma_sp = ct.masp"; DataTable dataTable = Data.Instance.ExcuteQuery(sqlQuery, new object[] { trangthai, Account.Instance.id }); foreach (DataRow row in dataTable.Rows) { ItemInGioHang item = new ItemInGioHang(); item.SetItem(row["ma_sp"].ToString(), row["tensp"].ToString(), 1, Int32.Parse(row["gia"].ToString()), true); string sqlQuery1 = @"SELECT * FROM dbo.HinhAnh where ma_sp='" + row["ma_sp"].ToString() + "'"; DataTable dataTable1 = Data.Instance.ExcuteQuery(sqlQuery1); foreach (DataRow row1 in dataTable1.Rows) { item.Link_image.Add(row1["data"].ToString()); } listSPTrongGio.Add(item); } return(listSPTrongGio); }
public List <ItemInGioHang> loadDataSanPhamTrongGio() { List <ItemInGioHang> listSPTrongGio = new List <ItemInGioHang>(); string sqlQuery = @"select * from dbo.sanpham sp left join dbo.sanphamgiohang gh on sp.ma_sp = gh.ma_sp where idnguoimua=( select id from dbo.account where username='******')"; DataTable dataTable = Data.Instance.ExcuteQuery(sqlQuery); foreach (DataRow row in dataTable.Rows) { ItemInGioHang item = new ItemInGioHang(); item.SetItem(row["ma_sp"].ToString(), row["tensp"].ToString(), Int32.Parse(row["soluong_giohang"].ToString()), Int32.Parse(row["gia"].ToString()), bool.Parse(row["isSelect"].ToString())); string sqlQuery1 = @"SELECT * FROM dbo.HinhAnh where ma_sp='" + row["ma_sp"].ToString() + "'"; DataTable dataTable1 = Data.Instance.ExcuteQuery(sqlQuery1); foreach (DataRow row1 in dataTable1.Rows) { item.Link_image.Add(row1["data"].ToString()); } listSPTrongGio.Add(item); } return(listSPTrongGio); }