/// <summary>
        /// Save new conference hall.
        /// </summary>
        /// <param name="ch">Conference hall for checking.</param>
        public static ConferenceHall TryToFindThisConferenceHall(ConferenceHall ch)
        {
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                SqlCommand command = connection.CreateCommand();
                StringBuilder query = new StringBuilder();

                query.AppendFormat("SELECT ch.* FROM ");
                query.AppendFormat(DBAttributesManager.GetDBTableName(typeof(ConferenceHall)) + " ch");
                query.Append(" ORDER BY ch.Name");

                command.CommandText = query.ToString();
                connection.Open();

                using (IDataReader reader = command.ExecuteReader())
                {
                    foreach (ConferenceHall confHall in GetAllConferenceHallsDataFromReader(reader))
                        if (confHall.Name.Contains(ch.Name) && confHall.OfficeID.Equals(ch.OfficeID)) //FIXME: бд вываливает всю строку длиной 255 символов
                            return confHall;
                    return null;
                }
            }
        }
 /// <summary>
 /// Returns conference hall from data reader.
 /// </summary>
 /// <param name="reader">Data reader.</param>
 /// <returns>Conference hall from data reader.</returns>
 private static ConferenceHall GetConferenceHallDataFromReader(IDataReader reader)
 {
     ConferenceHall details = new ConferenceHall();
     details.ID = (int)reader["ID"];
     details.Name = (string)reader["Name"];
     details.Description = reader["Description"] == DBNull.Value
                               ? null
                               : (string)reader["Description"];
     details.OfficeID = (int)reader["OfficeID"];
     return details;
 }
Example #3
0
        public XMLSerializableConferenceHall(ConferenceHall ch)
        {
            if ((ch == null)||(!ch.ID.HasValue))
                throw new ArgumentNullException("ch");

            this.ConferenceHallID = ch.ID.Value;
            this.Name = ch.Name;
            this.Description = ch.Description;
            this.OfficeID = ch.OfficeID;
            this.OfficeName = ch.OfficeName;
        }