public IList<Core.Business.Meterial> GetAllMeterial() { IList<Core.Business.Meterial> meteriallist = new List<Core.Business.Meterial>(); SqlServerUtility sql = new SqlServerUtility(); SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllMeterial); if (reader != null) { while (reader.Read()) { Core.Business.Meterial meterial = new Core.Business.Meterial(); if (!reader.IsDBNull(0)) meterial.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) meterial.ISBN = reader.GetString(1); if (!reader.IsDBNull(2)) meterial.Name = reader.GetString(2); if (!reader.IsDBNull(3)) meterial.Publish = reader.GetString(3); if (!reader.IsDBNull(4)) meterial.MeterialCate = reader.GetString(4); if (!reader.IsDBNull(5)) meterial.Des = reader.GetString(5); if (!reader.IsDBNull(6)) meterial.Price = reader.GetDecimal(6); if (!reader.IsDBNull(7)) meterial.Vision = reader.GetInt32(7); meterial.MarkOld(); meteriallist.Add(meterial); } reader.Close(); } return meteriallist; }
public Meterial getByCode(string code) { SqlServerUtility sql = new SqlServerUtility(); sql.AddParameter("@code", SqlDbType.NVarChar, code); SqlDataReader reader = sql.ExecuteSqlReader(SqlSelectByCode); if (reader != null && !reader.IsClosed && reader.Read()) { Core.Business.Meterial meterial = new Core.Business.Meterial(); if (!reader.IsDBNull(0)) meterial.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) meterial.ISBN = reader.GetString(1); if (!reader.IsDBNull(2)) meterial.Name = reader.GetString(2); if (!reader.IsDBNull(3)) meterial.Publish = reader.GetString(3); if (!reader.IsDBNull(4)) meterial.MeterialCate = reader.GetString(4); if (!reader.IsDBNull(5)) meterial.Des = reader.GetString(5); if (!reader.IsDBNull(6)) meterial.Price = reader.GetDecimal(6); if (!reader.IsDBNull(7)) meterial.Vision = reader.GetInt32(7); reader.Close(); meterial.MarkOld(); return meterial; } else { if (reader != null && !reader.IsClosed) reader.Close(); return null; } }