Пример #1
0
        public HastaneeEntity IDyeGoreHastaneGetir(int hastaneID)
        {
            cmd = new SqlCommand("Select * From Hastaneler Where HastaneID = @HastaneID", conn);

            cmd.Parameters.AddWithValue("@HastaneID", hastaneID);

            HastaneeEntity currentHastane = null;

            try
            {
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();

                reader.Read();



                currentHastane = new HastaneeEntity()
                {
                    HastaneID  = (int)reader["HastaneID"],
                    HastaneAdi = reader["HastaneAdi"].ToString()
                };
                reader.Close();
                return(currentHastane);
            }
            catch
            {
                return(currentHastane);
            }
            finally
            {
                conn.Close();
            }
        }
Пример #2
0
        public int IsmeGoreHastaneGetir(string hastaneAd)
        {
            HastaneeEntity hastane = new HastaneeEntity();

            cmd = new SqlCommand("Select * From Hastaneler Where HastaneAdi=@hastaneAdi", conn);
            cmd.Parameters.AddWithValue("@hastaneAdi", hastaneAd);

            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            reader.Read();
            hastane.HastaneID = reader.GetInt32(0);

            reader.Close();
            return(hastane.HastaneID);
        }