Beispiel #1
0
 public OgrenciDersleriForm(Ogrenci ogrenci)
 {
     InitializeComponent();
     _ogrenci = ogrenci;
     UIDegerleriniVer();
     DersGetir();
     SecilenDersiGetir();
 }
Beispiel #2
0
        public static List<OgrenciDersleri> OgrenciDersGetir(Ogrenci ogrenci)
        {
            List<OgrenciDersleri> ogrenciDersleri = new List<OgrenciDersleri>();
            MySqlConnection connection=null;
            try
            {
                string connectionString="SERVER=localhost;DATABASE=OgrenciYonetimSistemi; UID=root;PASSWORD=hy050491;";
                 connection = new MySqlConnection(connectionString);
                connection.Open();
                string query = "SELECT * FROM OgrenciDersleri";

                MySqlCommand cmd = new MySqlCommand(query, connection);
                MySqlDataReader reader= cmd.ExecuteReader();

                while (reader.Read())
                {
                    OgrenciDersleri ogreciDers = new OgrenciDersleri();
                    ogreciDers.Id = Convert.ToInt32(reader["Id"]);

                    ogreciDers.Ogrenci = new Ogrenci();
                    ogreciDers.Ogrenci.Id = Convert.ToInt32(reader["Ogrenci"]);
                    ogreciDers.Ders = new Ders();

                    ogreciDers.Ders.Id = Convert.ToInt32(reader["Ders"]);

                    string studentQuery = "SELECT * FROM Ogrenci WHERE Id = '" + ogreciDers.Ogrenci.Id + "'";

                    MySqlCommand cmdStudent = new MySqlCommand(query, connection);
                    MySqlDataReader readerStudent = cmd.ExecuteReader();
                    while (readerStudent.Read())
                    {
                        ogreciDers.Ogrenci.Adi = readerStudent["Adi"].ToString();
                        ogreciDers.Ogrenci.Soyadi = readerStudent["Soyadi"].ToString();
                    }

                    ogrenciDersleri.Add(ogreciDers);
                }
                connection.Close();
                    DataTable table = new DataTable();
                    table.Load(reader);
                    for (int i = 0; i < table.Rows.Count; i++)
                {
                    string adi = table.Rows[i]["Id"].ToString();
                }
                //DersBilgileriDoldur(ogrenciDersleri);
            }
            catch (Exception ex)
            {

            }
            finally
            {
                connection.Close();
            }
            return ogrenciDersleri;
        }
Beispiel #3
0
        private void button1_Click_2(object sender, EventArgs e)
        {
            secilenOgrenci = dgvOgrenciler.SelectedRows[0].DataBoundItem as Ogrenci;
            if (secilenOgrenci != null)
            {
                OgrenciDersleriForm ogrencidersleri = new OgrenciDersleriForm(secilenOgrenci);

                ogrencidersleri.ShowDialog();
            }
        }
Beispiel #4
0
        public void Ekle()
        {
            Ogrenci ogrenci = new Ogrenci();

            ogrenci.Adi = txtAdi.Text.Trim();
            ogrenci.Soyadi = txtSoyadi.Text.Trim();
            OgrenciBL.OgrenciEkle(ogrenci);

            OgrencileriGetir();
        }
Beispiel #5
0
        public static bool OgrenciSil(Ogrenci ogrenci)
        {
            bool eklendi = false;
            MySqlConnection connection = null;
            try
            {
                string connectionString = "SERVER=localhost;DATABASE=OgrenciYonetimSistemi; UID=root;PASSWORD=hy050491;";

                connection = new MySqlConnection(connectionString);

                connection.Open();
                string query = "DELETE FROM Ogrenci WHERE Id='" + ogrenci.Id + "'";

                //create command and assign the query and connection from the constructor
                MySqlCommand cmd = new MySqlCommand(query, connection);

                int sonucDeger = cmd.ExecuteNonQuery();
                if (sonucDeger > 0)
                    eklendi = true;

            }
            catch (Exception ex)
            {
                eklendi = false;
            }
            finally
            {
                connection.Close();
            }
            return eklendi;
        }
Beispiel #6
0
        public static List<Ogrenci> OgrencileriGetir()
        {
            List<Ogrenci> ogrenciler = new List<Ogrenci>();
            MySqlConnection connection=null;
            try
            {
                string connectionString="SERVER=localhost;DATABASE=OgrenciYonetimSistemi; UID=root;PASSWORD=hy050491;";
                 connection = new MySqlConnection(connectionString);

                connection.Open();
                string query = "SELECT * FROM Ogrenci";

                MySqlCommand cmd = new MySqlCommand(query, connection);
                MySqlDataReader reader= cmd.ExecuteReader();

                while (reader.Read())
                {
                    Ogrenci ogrenci = new Ogrenci();
                    ogrenci.Id=Convert.ToInt32(reader["Id"]);
                    ogrenci.Adi=reader["Adi"].ToString();
                    ogrenci.Soyadi = reader["Soyadi"].ToString();

                    ogrenciler.Add(ogrenci);
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                connection.Close();
            }
            return ogrenciler;
        }
Beispiel #7
0
        private void dgvOgrenciler_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            secilenOgrenci = dgvOgrenciler.SelectedRows[0].DataBoundItem as Ogrenci;

            if (secilenOgrenci != null)
            {
                txtAdi.Text = secilenOgrenci.Adi;
                txtSoyadi.Text = secilenOgrenci.Soyadi;
            }
        }
Beispiel #8
0
 private void dgvOgrenciler_MouseClick(object sender, MouseEventArgs e)
 {
     secilenOgrenci = dgvOgrenciler.SelectedRows[0].DataBoundItem as Ogrenci;
 }