public CommonHouse getRelatedCommonHouse() { if (!isValid(new List<string>() { "prID", "vName", "vBoundary", "vInUse" })) return null; string sqlCommand = String.Format("select chID from CommonHouse where vID={0}", vID); Sql sql = new Sql(); SqlDataReader reader = sql.selectCommonHouseIDByVID(sqlCommand); if (reader.HasRows) { reader.Read(); int commonHouseID = Int32.Parse(reader[0].ToString()); CommonHouse commonHouse = new CommonHouse(); commonHouse.id = commonHouseID; commonHouse.select(); return commonHouse; } else { return null; } }
public CommonHouse selectRelatedCommonHouse() { if (!isValid(new List<string>() { "prName", "pID" })) return null; CommonHouse commonHouse = new CommonHouse(); string sqlCommand = String.Format("select chID from CommonHouse where prID={0}", prID); Sql sql = new Sql(); int chID = sql.selectCommonHouseIDByPrID(sqlCommand); if (chID == -1) return null; commonHouse.id = chID; commonHouse.select(); return commonHouse; }