示例#1
0
        public List <Config> Select(string cond)
        {
            List <Config> result = null;

            if (connection.State == ConnectionState.Open)
            {
                connection = new SqlConnection(connection.ConnectionString + "Password=itu");
            }
            connection.Open();
            using (SqlCommand cmd = connection.CreateCommand()) {
                string condition = "";
                if (cond != null)
                {
                    condition = " " + cond;
                }
                cmd.CommandText = "SELECT * FROM Config" + condition;
                using (SqlDataReader reader = cmd.ExecuteReader()) {
                    result = new List <Config>();
                    while (reader.Read())
                    {
                        Patient patient = new PatientDAO(connection).Select("WHERE id='" + reader["patient"] + "'").First();
                        Axe     axe     = null;
                        if (reader["axe"].ToString() != "")
                        {
                            axe = new AxeDAO(connection).Select("WHERE id='" + reader["axe"] + "'").First();
                        }
                        else if (reader["consultation"].ToString() != "")
                        {
                            axe = new AxeDAO(connection).SelectConsultation("WHERE id='" + reader["consultation"] + "'").First();
                        }
                        float valeur = float.Parse(reader["valeur"].ToString());

                        result.Add(new Config(patient, axe, valeur));
                    }
                }
            } connection.Close();

            return(result);
        }
示例#2
0
        public List <Config> SelectSimilaire(List <Similaire> similaires)
        {
            List <Config> result = new List <Config>();

            if (connection.State == ConnectionState.Open)
            {
                connection = new SqlConnection(connection.ConnectionString + "Password=itu");
            }
            connection.Open();
            using (SqlCommand cmd = connection.CreateCommand()) {
                cmd.CommandText = "SELECT * FROM Config " + this.PrepareCondition(similaires);
                //throw new ModelException(cmd.CommandText);
                using (SqlDataReader reader = cmd.ExecuteReader()) {
                    result = new List <Config>();
                    while (reader.Read())
                    {
                        Patient patient = new PatientDAO(connection).Select("WHERE id='" + reader["patient"] + "'").First();
                        Axe     axe     = null;
                        if (reader["axe"].ToString() != "")
                        {
                            axe = new AxeDAO(connection).Select("WHERE id='" + reader["axe"] + "'").First();
                        }
                        else if (reader["consultation"].ToString() != "")
                        {
                            axe = new AxeDAO(connection).SelectConsultation("WHERE id='" + reader["consultation"] + "'").First();
                        }
                        float valeur = float.Parse(reader["valeur"].ToString());

                        result.Add(new Config(patient, axe, valeur));
                    }
                    if (result.Count() != similaires.Count())
                    {
                        result = new List <Config>();
                    }
                }
            } connection.Close();

            return(result);
        }