public static TMSBookMaintance Get(System.Int64 bmMaintainceId) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSBookMaintance instance; instance = new TMSBookMaintance(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSBookMaintance_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, bmMaintainceId); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) { throw new ApplicationException("Could not get TMSBookMaintance ID:" + bmMaintainceId.ToString() + " from Database."); } // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom(ds.Tables[0].Rows[0]); return(instance); }
public static TMSBookMaintance[] Search(System.Int64?bmMaintainceId, System.Int64?bmBookDetailId, System.Int64?bmLibrarianId, System.Int64?bmDamageById, System.String bmTotalDamageCopies, System.String bmDamageAvailableCopies, System.String bmCostPerCopies, System.String bmTotalCost, System.String bmFor, System.String bmDamageType, System.String bmDamageByName, System.DateTime?bmDate, System.Int32?bmStatus) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSBookMaintance_SEARCH"; dbCommand = db.GetStoredProcCommand(sqlCommand, bmMaintainceId, bmBookDetailId, bmLibrarianId, bmDamageById, bmTotalDamageCopies, bmDamageAvailableCopies, bmCostPerCopies, bmTotalCost, bmFor, bmDamageType, bmDamageByName, bmDate, bmStatus); ds = db.ExecuteDataSet(dbCommand); ds.Tables[0].TableName = TABLE_NAME; return(TMSBookMaintance.MapFrom(ds)); }
public static TMSBookMaintance[] MapFrom(DataSet ds) { List <TMSBookMaintance> objects; // Initialise Collection. objects = new List <TMSBookMaintance>(); // Validation. if (ds == null) { throw new ApplicationException("Cannot map to dataset null."); } else if (ds.Tables[TABLE_NAME].Rows.Count == 0) { return(objects.ToArray()); } if (ds.Tables[TABLE_NAME] == null) { throw new ApplicationException("Cannot find table [dbo].[TMS_BookMaintance] in DataSet."); } if (ds.Tables[TABLE_NAME].Rows.Count < 1) { throw new ApplicationException("Table [dbo].[TMS_BookMaintance] is empty."); } // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSBookMaintance instance = new TMSBookMaintance(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return(objects.ToArray()); }
public static TMSBookMaintance[] MapFrom(DataSet ds) { List<TMSBookMaintance> objects; // Initialise Collection. objects = new List<TMSBookMaintance>(); // Validation. if (ds == null) throw new ApplicationException("Cannot map to dataset null."); else if (ds.Tables[TABLE_NAME].Rows.Count == 0) return objects.ToArray(); if (ds.Tables[TABLE_NAME] == null) throw new ApplicationException("Cannot find table [dbo].[TMS_BookMaintance] in DataSet."); if (ds.Tables[TABLE_NAME].Rows.Count < 1) throw new ApplicationException("Table [dbo].[TMS_BookMaintance] is empty."); // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSBookMaintance instance = new TMSBookMaintance(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return objects.ToArray(); }
public static TMSBookMaintance Get(System.Int64 bmMaintainceId) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSBookMaintance instance; instance = new TMSBookMaintance(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSBookMaintance_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, bmMaintainceId); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) throw new ApplicationException("Could not get TMSBookMaintance ID:" + bmMaintainceId.ToString()+ " from Database."); // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom( ds.Tables[0].Rows[0] ); return instance; }