Beispiel #1
0
        public static List <Specialty> GetListOfSpecialties()
        {
            List <Specialty> allSpecialties = new List <Specialty> {
            };
            MySqlConnection conn            = DB.Connection();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM specialties;";
            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                Specialty newSpecialty = new Specialty();
                newSpecialty.SetId(rdr.GetInt32(0));
                newSpecialty.SetSpecialtyType(rdr.GetString(1));
                allSpecialties.Add(newSpecialty);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(allSpecialties);
        }
Beispiel #2
0
        public static Specialty Find(int id)
        {
            MySqlConnection conn = DB.Connection();

            conn.Open();
            var cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM `specialties` WHERE id = '" + id + "';";
            var       rdr            = cmd.ExecuteReader() as MySqlDataReader;
            Specialty foundSpecialty = new Specialty();

            while (rdr.Read())
            {
                int    stylistId            = rdr.GetInt32(0);
                string stylistSpecialtyType = rdr.GetString(1);
                foundSpecialty.SetId(stylistId);
                foundSpecialty.SetSpecialtyType(stylistSpecialtyType);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(foundSpecialty);
        }