Exemplo n.º 1
0
        public static Speciality Find(int id)
        {
            MySqlConnection conn = DB.Connection();

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

            cmd.CommandText = @"SELECT * FROM specialities WHERE id = (@searchId);";
            MySqlParameter searchId = new MySqlParameter();

            searchId.ParameterName = "@searchId";
            searchId.Value         = id;
            cmd.Parameters.Add(searchId);
            var    rdr            = cmd.ExecuteReader() as MySqlDataReader;
            int    SpecialityId   = 0;
            string SpecialityName = "";

            while (rdr.Read())
            {
                SpecialityId = rdr.GetInt32(0);

                Console.WriteLine(SpecialityId);

                SpecialityName = rdr.GetString(1);

                Console.WriteLine(SpecialityName);
            }
            Speciality newSpeciality = new Speciality(SpecialityName, SpecialityId);

            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(newSpeciality);
        }
Exemplo n.º 2
0
 public void Dispose()
 {
     Doctor.ClearAll();
     Patient.ClearAll();
     Speciality.ClearAll();
 }