База данных для хранения и обработки информации, которая требуется типичной психиатрической больнице, страница 22

                                       public static List<DbPunishmentHistoryEntry> GetAssignedPunishments(int historyId)

                                       {

                                                           List<DbPunishmentHistoryEntry> result = new List<DbPunishmentHistoryEntry>();

                                                           using (OracleConnection connection = GetConnection())

                                                           using (OracleCommand cmd = new OracleCommand("select * from GetPunishmentReport WHERE ИСТОРИЯ_ID=" + historyId, connection))

                                                           using (OracleDataReader reader = cmd.ExecuteReader())

                                                           {

                                                                               while (reader.Read())

                                                                               {

                                                                                                  DbPunishmentHistoryEntry entry = new DbPunishmentHistoryEntry();

                                                                                                  entry.Id = Convert.ToInt32(reader["ID"]);

                                                                                                  entry.Name = reader["НАЗВАНИЕ"] as string;

                                                                                                  entry.Reason = reader["ЗА_ЧТО"] as string;

                                                                                                  entry.Date = readNullableDate(reader["КОГДА"]);

                                                                                                  entry.Assigner = Convert.ToInt32(reader["НАЗНАЧИЛ_ID"]);

                                                                                                  entry.HistoryID = historyId; //Convert.ToInt32(reader["ИСТОРИЯ_ID"]);

                                                                                                  result.Add(entry);

                                                                               }

                                                           }

                                                           return result;

                                       }

                                       /// <summary>

                                       /// Назначение наказания

                                       /// </summary>

                                       /// <param name="entry"></param>

                                       public static DateTime AssignPunishment(DbPunishmentHistoryEntry entry)

                                       {

                                                           using (OracleConnection connection = GetConnection())

                                                           using (OracleCommand cmd = new OracleCommand("AssignPunishment", connection))

                                                           {

                                                                               cmd.CommandType = CommandType.StoredProcedure;

                                                                               cmd.Parameters.AddWithValue("pИСТОРИЯ_ID", entry.HistoryID);

                                                                               cmd.Parameters.AddWithValue("pНАКАЗАНИЕ_ID", entry.Id);

                                                                               cmd.Parameters.AddWithValue("pНАЗНАЧИЛ_ID", entry.Assigner);

                                                                               cmd.Parameters.AddWithValue("pЗА_ЧТО", entry.Reason);

                                                                               cmd.Parameters.Add("pКОГДА", OracleType.DateTime).Direction = ParameterDirection.Output;

                                                                               cmd.ExecuteNonQuery();

                                                                               return (DateTime)cmd.Parameters["pКОГДА"].Value;

                                                           }

                                       }

                                       /// <summary>

                                       /// Список лекарств, лечащих болезнь

                                       /// </summary>

                                       public static List<DbDrug> GetAllProperDrugs(int diseaseId)

                                       {

                                                           List<DbDrug> result = new List<DbDrug>();

                                                           using (OracleConnection connection = GetConnection())

                                                           using (OracleCommand cmd = new OracleCommand("select * from GetAllProperDrugs WHERE БОЛЕЗНЬ_ID=:БОЛЕЗНЬ_ID", connection))

                                                           {

                                                                               cmd.Parameters.AddWithValue(":БОЛЕЗНЬ_ID", diseaseId);

                                                                               using (OracleDataReader reader = cmd.ExecuteReader())

                                                                               {

                                                                                                  while (reader.Read())

                                                                                                  {

                                                                                                                      DbDrug entry = new DbDrug();