Exemplo n.º 1
0
        private void btnGetir_Click(object sender, EventArgs e)
        {
            cMusteri m = new cMusteri();
            List<cMusteri> liste = m.MusterileriGetir();

            dgvMusteriler.DataSource = liste;
        }
Exemplo n.º 2
0
        public List<cMusteri> MusterileriGetir()
        {
            List<cMusteri> list = new List<cMusteri>();
            SqlConnection conn = new SqlConnection("Data Source=WISSEN245\\MSSQL2012; Initial Catalog = VideoMarket; uid=sa; pwd=12345t");

            SqlCommand comm = new SqlCommand("Select * from Musteriler", conn);

            if (conn.State == ConnectionState.Closed)
                conn.Open();

            SqlDataReader dr;

            try
            {
                dr = comm.ExecuteReader();
                while (dr.Read())
                {
                    cMusteri m = new cMusteri();
                    m._musteriNo = Convert.ToInt32(dr["MusteriNo"]);
                    m._musteriAd = Convert.ToString(dr["MusteriAd"]);
                    m._musteriSoyad = Convert.ToString(dr["MusteriSoyad"]);
                    m._telefon = Convert.ToString(dr["Telefon"]);
                    m._adres = Convert.ToString(dr["Adres"]);
                    m._silindi = Convert.ToBoolean(dr["Silindi"]);
                    list.Add(m);
                }
                dr.Close();
            }
            catch (SqlException ex)
            {
                string hata = ex.Message;
            }
            finally
            {
                conn.Close();
            }
            return list;
        }