public IList<Core.Business.Asset> GetAllAsset() { IList<Core.Business.Asset> assetlist = new List<Core.Business.Asset>(); SqlServerUtility sql = new SqlServerUtility(); SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllAsset); if (reader != null) { while (reader.Read()) { Core.Business.Asset asset = new Core.Business.Asset(); if (!reader.IsDBNull(0)) asset.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) asset.AssetType = reader.GetString(1); if (!reader.IsDBNull(2)) asset.AssetItemName = reader.GetString(2); if (!reader.IsDBNull(3)) asset.UnitValue = reader.GetDecimal(3); if (!reader.IsDBNull(4)) asset.PurchasingDate = reader.GetDateTime(4); if (!reader.IsDBNull(5)) asset.RegisterDate = reader.GetDateTime(5); if (!reader.IsDBNull(6)) asset.Num = reader.GetInt32(6); if (!reader.IsDBNull(7)) asset.TotalValue = reader.GetDecimal(7); asset.MarkOld(); assetlist.Add(asset); } reader.Close(); } return assetlist; }
public Core.Business.Asset Select(int id) { SqlServerUtility sql = new SqlServerUtility(); sql.AddParameter("@Id", SqlDbType.Int, id); SqlDataReader reader = sql.ExecuteSqlReader(SqlSelectAsset); if (reader != null && !reader.IsClosed && reader.Read()) { Core.Business.Asset asset = new Core.Business.Asset(); if (!reader.IsDBNull(0)) asset.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) asset.AssetType = reader.GetString(1); if (!reader.IsDBNull(2)) asset.AssetItemName = reader.GetString(2); if (!reader.IsDBNull(3)) asset.UnitValue = reader.GetDecimal(3); if (!reader.IsDBNull(4)) asset.PurchasingDate = reader.GetDateTime(4); if (!reader.IsDBNull(5)) asset.RegisterDate = reader.GetDateTime(5); if (!reader.IsDBNull(6)) asset.Num = reader.GetInt32(6); if (!reader.IsDBNull(7)) asset.TotalValue = reader.GetDecimal(7); reader.Close(); return asset; } else { if (reader != null && !reader.IsClosed) reader.Close(); return null; } }
public IList<Asset> SelectByNameandDate(DateTime beginDate, DateTime endDate, string AssetName) { IList<Core.Business.Asset> assetlist = new List<Core.Business.Asset>(); SqlServerUtility sql = new SqlServerUtility(); SqlDataReader reader; if (AssetName.Equals("")) { sql.AddParameter("@beginDate",SqlDbType.DateTime,beginDate); sql.AddParameter("@endDate",SqlDbType.DateTime,endDate); reader = sql.ExecuteSqlReader(SqlSelectByDateAsset); } else { sql.AddParameter("@beginDate", SqlDbType.DateTime, beginDate); sql.AddParameter("@endDate", SqlDbType.DateTime, endDate); sql.AddParameter("@AssetItemName",SqlDbType.NVarChar,AssetName); reader = sql.ExecuteSqlReader(SqlSelectByNameandDateAsset); } if (reader != null) { while (reader.Read()) { Core.Business.Asset asset = new Core.Business.Asset(); if (!reader.IsDBNull(0)) asset.Id = reader.GetInt32(0); if (!reader.IsDBNull(1)) asset.AssetType = reader.GetString(1); if (!reader.IsDBNull(2)) asset.AssetItemName = reader.GetString(2); if (!reader.IsDBNull(3)) asset.UnitValue = reader.GetDecimal(3); if (!reader.IsDBNull(4)) asset.PurchasingDate = reader.GetDateTime(4); if (!reader.IsDBNull(5)) asset.RegisterDate = reader.GetDateTime(5); if (!reader.IsDBNull(6)) asset.Num = reader.GetInt32(6); if (!reader.IsDBNull(7)) asset.TotalValue = reader.GetDecimal(7); asset.MarkOld(); assetlist.Add(asset); } reader.Close(); } return assetlist; }