示例#1
0
    /// <summary>
    /// Creates the data for Patient Medication
    /// </summary>
    /// <param name="newPatientMedication"></param>
    /// <returns></returns>
    public static Int32 Insert(BCPatientMedicationDAL newPatientMedication)
    {
        //Edit(newPatientTreatment);
        string sql =
            "INSERT INTO patientTreatment " +
            "(patientTreatmentId,din,dose,frequency,frencyPeriod,exactMinMax) " +
            "VALUES(" + newPatientMedication.patientMedicationId + ",'" + newPatientMedication.din + "'," +
            newPatientMedication.dose + "," + newPatientMedication.frequency + ",'" +
            newPatientMedication.frequencyPeriod + "','" + newPatientMedication.exactMinMax + "');";


        SqlCommand patientCommand = new SqlCommand(sql, patientConnection);

        try
        {
            patientConnection.Open();
            patientCommand.ExecuteNonQuery();
            patientCommand.CommandText = "SELECT @@identity";
            return(Convert.ToInt32(patientCommand.ExecuteScalar()));
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            patientConnection.Close();
        }
    }
示例#2
0
    public static string Valadate(BCPatientMedicationDAL newPM)
    {
        string errorMessage = "";

        if ((newPM.exactMinMax == "n/a" && newPM.frequency <= 0) ||
            (newPM.exactMinMax != "n/a" && newPM.frequency == 0))
        {
            errorMessage += "exact/min/max dosn't match with frequency";
        }
        return(errorMessage);
    }
示例#3
0
    public static Int32 Edit(BCPatientMedicationDAL newPatientMedication)
    {
        string errorMessage = Valadate(newPatientMedication);

        if (errorMessage != "")
        {
            throw new System.ArgumentException(errorMessage);
        }

        string sql =
            "UPDATE patientMedication " +
            "SET " +//din = '" + newPatientMedication.din + "'," +
            "dose = '" + newPatientMedication.dose + "', " +
            "frequency = " + newPatientMedication.frequency + ", " +
            "frequencyPeriod = '" + newPatientMedication.frequencyPeriod + "', " +
            "exactMinMax = '" + newPatientMedication.exactMinMax + "' " +
            "WHERE patientTreatmentId = " + newPatientMedication.PatientTreatmentId + ";";

        SqlCommand patientCommand = new SqlCommand(sql, patientConnection);

        try
        {
            patientConnection.Open();
            patientCommand.ExecuteNonQuery();
            //patientCommand.CommandText = "SELECT @@identity";
            return(Convert.ToInt32(patientCommand.ExecuteScalar()));
            //return 0;
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            patientConnection.Close();
        }
    }
示例#4
0
 /// <summary>
 /// Deletes patient medication feild based on patient medication id
 /// </summary>
 /// <param name="patientMedication">patient medication id</param>
 public static void Delete(BCPatientMedicationDAL patientMedication)
 {
     Delete(patientMedication.patientMedicationId);
 }