示例#1
0
        /// <summary>
        /// Adds a vitals record to the db.
        /// </summary>
        /// <param name="vitals">The vitals record to add</param>
        /// <returns>The vitals ID</returns>
        public static int AddVitals(Vitals vitals)
        {
            int vitalsID = -1;
            try
            {
                using (SqlConnection connection = HealthCareDBConnection.GetConnection())
                {
                    string insertStatement =
                        "INSERT Vitals " +
                        "(appointmentID, bloodPressure, bodyTemperature, pulse) " +
                        "VALUES (@AppointmentID, @BloodPressure, @BodyTemperature, @Pulse)";
                    using (SqlCommand insertCommand = new SqlCommand(insertStatement, connection))
                    {
                        insertCommand.Parameters.AddWithValue("@AppointmentID", vitals.AppointmentId);
                        insertCommand.Parameters.AddWithValue("@BloodPressure", vitals.BloodPressure);
                        insertCommand.Parameters.AddWithValue("@BodyTemperature", vitals.BodyTemperature);
                        insertCommand.Parameters.AddWithValue("@Pulse", vitals.Pulse);

                        connection.Open();
                        insertCommand.ExecuteNonQuery();

                        vitalsID = vitals.AppointmentId;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK);
            }

            return vitalsID;
        }
        /// <summary>
        /// Adds vitals records to the db.
        /// </summary>
        /// <param name="appID">The patients appointment id</param>
        /// <param name="bloodPress">The patients blood pressure</param>
        /// <param name="bodyTemp">The patients body temperature</param>
        /// <param name="pulse">The patients pulse</param>
        /// <returns>The id of the vitals records</returns>
        public static int AddVitals(int appID, String bloodPress, Decimal bodyTemp, Decimal pulse)
        {
            Vitals vit = new Vitals();

           vit.AppointmentId = appID;
           vit.BloodPressure = bloodPress;
           vit.BodyTemperature = bodyTemp;
           vit.Pulse = pulse;

            return AddVitals(vit);
        }
 /// <summary>
 /// Adds vitals records to the db.
 /// </summary>
 /// <param name="vitals">The vitals to add</param>
 /// <returns>The id of the vitals records</returns>
 public static int AddVitals(Vitals vitals)
 {
     return VitalsDB.AddVitals(vitals);
 }
示例#4
0
        /// <summary>
        /// Processes the checkup and adds it to the database.
        /// </summary>
        private void addButton_Click(object sender, EventArgs e)
        {
            //Validates required fields.
            if (Validator.AreAllPresent(controls) && Validator.IsDecimal(bodyTempTextBox) && Validator.IsDecimal(pulseTextBox))
            {
                newVitals = new Vitals();
                newVitals.AppointmentId = Convert.ToInt32(cbAppointmentID.SelectedValue);
                newVitals.BloodPressure = bloodPressureTextBox.Text;
                newVitals.BodyTemperature = Convert.ToDecimal(bodyTempTextBox.Text);
                newVitals.Pulse = Convert.ToDecimal(pulseTextBox.Text);

                int newVitalsID = VitalsController.AddVitals(newVitals);
                if (newVitalsID > -1)
                {
                    MessageBox.Show("Checkup vitals added.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearAllControls();
                }
                else
                {
                    MessageBox.Show("Checkup vitals not added.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }