示例#1
0
        /// <summary>
        /// This mehtod creates a connection in the database between two tables by entering medication instance table data
        /// </summary>
        /// <param name="instance">The <see cref="MedicationInstance"/> to insert into the database.</param>
        public void addmedicationInstance(MedicationInstance instance)
        {
            QueryBuilder b = new QueryBuilder();

            b.Insert(Tables.MEDICATIONINSTANCE_TABLE).Values
            (
                null,
                instance.PrescriptionId,
                instance.MedicationId,
                instance.Instruction

            );

            MySqlCommand cmd = new MySqlCommand(b.ToString(), dbCon.GetConnection());

            cmd.ExecuteNonQuery();
        }
示例#2
0
        /// <summary>
        /// This method returns a list of medications from the database
        /// Takes a querybuilder as arguement
        /// </summary>
        /// <param name="b">The <see cref="QueryBuilder"/> containing code to execute.</param>
        /// <returns>A <see cref="List{MedicationInstance}"/>.</returns>
        public List <MedicationInstance> GetMedicationID(QueryBuilder b)
        {
            MedicationInstance        a      = new MedicationInstance();
            List <MedicationInstance> result = new List <MedicationInstance>();
            MySqlCommand    query            = new MySqlCommand(b.ToString(), dbCon.GetConnection());
            MySqlDataReader reader           = query.ExecuteReader();

            while (reader.Read())
            {
                Tables.MedicationInstanceTable pt = Tables.MEDICATIONINSTANCE_TABLE;
                a.Id             = GetInt(reader[pt.ID.Name]);
                a.MedicationId   = GetInt(reader[pt.MedicationID.Name]);
                a.PrescriptionId = GetInt(reader[pt.PrescriptionID.Name]);
                a.Instruction    = GetString(reader[pt.Instructions.Name]);
                result.Add(a);
            }
            reader.Close();
            reader.Dispose();
            return(result);
        }