예제 #1
0
 public void InitializePatientAnswer(DbAnswer answer)
 {
     if (isOpen)
     {
         string        values  = answer.ToSqlString();
         string        sql     = "insert into patient_answer (patient_id, question_id, answer) values (" + values + ")";
         SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
         command.ExecuteNonQuery();
     }
 }
예제 #2
0
        public List <DbAnswer> PrepareEmptyAnswers()
        {
            List <DbAnswer> answers = new List <DbAnswer>();
            DBHandler       conn    = new DBHandler();

            conn.InitializeConnection();
            List <DbQuestion> questions = conn.GetAllQuestions();

            conn.CloseConnection();
            for (int i = 0; i < questions.Count; i++)
            {
                DbAnswer tempAnsw = new DbAnswer("", PatientID, questions[i].Id);
                answers.Add(tempAnsw);
            }
            return(answers);
        }
예제 #3
0
        public List <DbAnswer> GetPatientAnswers(int patientId)
        {
            List <DbAnswer> answers = new List <DbAnswer>();

            if (isOpen)
            {
                string           sql     = "select * from patient_answer where patient_id = " + patientId;
                SQLiteCommand    command = new SQLiteCommand(sql, m_dbConnection);
                SQLiteDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    DbAnswer tempAnsw = new DbAnswer();
                    tempAnsw.Answer     = reader["answer"].ToString();
                    tempAnsw.QuestionId = int.Parse(reader["question_id"].ToString());
                    tempAnsw.PatientId  = int.Parse(reader["patient_id"].ToString());
                    answers.Add(tempAnsw);
                }
            }
            return(answers);
        }