public List<DetailObject> GetDetailScroll() { List<DetailObject> ReturnObject = new List<DetailObject>(); sql = "select id,id_subcat,title,subtitle,Desc1,Desc2,created,img1,img2,img3,img4,img5,ScreenImg,show,offer,itemnum,itemprice from Detail where ScreenImg = 1 and show = 1 order by title "; initialize(); connection = new SqlConnection(connetionString); connection.Open(); command = new SqlCommand(sql, connection); dataReader = command.ExecuteReader(); while (dataReader.Read()) { DetailObject ReturnRecord = new DetailObject(); ReturnRecord.id = Convert.ToInt32(dataReader.GetValue(0)); ReturnRecord.id_subcat = Convert.ToInt32(dataReader.GetValue(1)); ReturnRecord.title = dataReader.GetValue(2).ToString(); ReturnRecord.subtitle = dataReader.GetValue(3).ToString(); ReturnRecord.Desc1 = dataReader.GetValue(4).ToString(); ReturnRecord.Desc2 = dataReader.GetValue(5).ToString(); ReturnRecord.created = Convert.ToDateTime(dataReader.GetValue(6)); ReturnRecord.img1 = dataReader.GetValue(7).ToString(); ReturnRecord.img2 = dataReader.GetValue(8).ToString(); ReturnRecord.img3 = dataReader.GetValue(9).ToString(); ReturnRecord.img4 = dataReader.GetValue(10).ToString(); ReturnRecord.img5 = dataReader.GetValue(11).ToString(); ReturnRecord.ScreenImg = Convert.ToInt32(dataReader.GetValue(12)); ReturnRecord.show = Convert.ToInt32(dataReader.GetValue(13)); ReturnRecord.offer = Convert.ToInt32(dataReader.GetValue(14)); ReturnRecord.itemnum = dataReader.GetValue(15).ToString(); ReturnRecord.itemprice = Convert.ToDecimal(dataReader.GetValue(16)); ReturnObject.Add(ReturnRecord); } dataReader.Close(); command.Dispose(); connection.Close(); return ReturnObject; }
public DetailObject GetDetail(string id) { int LocalId = Convert.ToInt32(id); DetailObject ReturnRecord = new DetailObject(); sql = "select id,id_subcat,title,subtitle,Desc1,Desc2,created,img1,img2,img3,img4,img5,ScreenImg,show,offer,itemnum,itemprice from Detail where id = @id order by title "; initialize(); connection = new SqlConnection(connetionString); connection.Open(); command = new SqlCommand(sql, connection); command.Parameters.Add(new SqlParameter("id", LocalId)); dataReader = command.ExecuteReader(); if (dataReader.Read()) { ReturnRecord.id = Convert.ToInt32(dataReader.GetValue(0)); ReturnRecord.id_subcat = Convert.ToInt32(dataReader.GetValue(1)); ReturnRecord.title = dataReader.GetValue(2).ToString(); ReturnRecord.subtitle = dataReader.GetValue(3).ToString(); ReturnRecord.Desc1 = dataReader.GetValue(4).ToString(); ReturnRecord.Desc2 = dataReader.GetValue(5).ToString(); ReturnRecord.created = Convert.ToDateTime(dataReader.GetValue(6)); ReturnRecord.img1 = dataReader.GetValue(7).ToString(); ReturnRecord.img2 = dataReader.GetValue(8).ToString(); ReturnRecord.img3 = dataReader.GetValue(9).ToString(); ReturnRecord.img4 = dataReader.GetValue(10).ToString(); ReturnRecord.img5 = dataReader.GetValue(11).ToString(); ReturnRecord.ScreenImg = Convert.ToInt32(dataReader.GetValue(12)); ReturnRecord.show = Convert.ToInt32(dataReader.GetValue(13)); ReturnRecord.offer = Convert.ToInt32(dataReader.GetValue(14)); ReturnRecord.itemnum = dataReader.GetValue(15).ToString(); ReturnRecord.itemprice = Convert.ToDecimal(dataReader.GetValue(16)); } dataReader.Close(); command.Dispose(); connection.Close(); return ReturnRecord; }