Exemple #1
0
        private void SecilenDersleriGetir()
        {
            int           ogrenciid = OgrenciIdBul();
            SqlConnection conn      = DbConncection.GetSqlConnection();
            var           cmd       = new SqlCommand();

            cmd.Connection = conn;
            conn.Open();

            cmd.CommandText = "SELECT COUNT(*) FROM Ahmet_SecilenDersler WHERE Ahmet_SecilenDersler.OgrenciId=@OgrenciId";
            cmd.Parameters.AddWithValue("@OgrenciId", ogrenciid);
            SqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            int kayitsayisi = reader.GetInt32(0);

            int[] dizi = new int[kayitsayisi];
            int   j    = 0;

            reader.Close();
            cmd.Parameters.Clear();
            cmd.CommandText = "SELECT DerslerId FROM Ahmet_SecilenDersler WHERE Ahmet_SecilenDersler.OgrenciId=@OgrenciId ";
            cmd.Parameters.AddWithValue("@OgrenciId", ogrenciid);

            //ConnectionState acikmi = conn.State;
            SqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                dizi[j] = rdr.GetInt32(0);
                j++;
            }
            rdr.Close();

            for (int i = 0; i < kayitsayisi; i++)
            {
                cmd.Parameters.Clear();
                cmd.CommandText = "SELECT DerslerId,DersAdi FROM Ahmet_Dersler WHERE Ahmet_Dersler.DerslerId=@DerslerId";
                cmd.Parameters.AddWithValue("@DerslerId", dizi[i]);
                SqlDataReader reader2 = cmd.ExecuteReader();
                while (reader2.Read())
                {
                    Dersler dersler = new Dersler();
                    {
                        dersler.DerslerId = reader2.GetInt32(0);
                        dersler.DersAdi   = reader2.GetString(1);
                    }
                    lsbSecilenDersler.Items.Add(dersler);
                }
                reader2.Close();
            }
            conn.Close();
        }
Exemple #2
0
        private void DerslerDoldur()
        {
            OgrenciTablo ogrencitablo = new OgrenciTablo();

            ogrencitablo.OgrenciNo = txtOgrenciNo.Text;
            int ogrenciIdsi  = OgrenciTablo.OgrenciIdBul(ogrencitablo);
            int OgretmenIdsi = OgretmenTablo.OgretmenIdBul2();

            SqlConnection conn = DbConncection.GetSqlConnection();
            var           cmd  = new SqlCommand();

            cmd.Connection = conn;
            conn.Open();
            cmd.CommandText = "SELECT Ahmet_Dersler.DerslerId,Ahmet_Dersler.DersAdi FROM Ahmet_Dersler INNER JOIN Ahmet_SecilenDersler ON Ahmet_Dersler.DerslerId = Ahmet_SecilenDersler.DerslerId where Ahmet_SecilenDersler.OgrenciId=@OgrenciId AND Ahmet_Dersler.OgretmenId=@OgretmenId  ";
            cmd.Parameters.AddWithValue("@OgrenciId", ogrenciIdsi);
            cmd.Parameters.AddWithValue("@OgretmenId", OgretmenIdsi);

            SqlDataReader reader = cmd.ExecuteReader();

            if (!reader.HasRows)
            {
                MessageBox.Show("Bu öğrenciye not verme yetkiniz yoktur");
            }
            else
            {
                while (reader.Read())
                {
                    Dersler dersler = new Dersler();
                    {
                        dersler.DerslerId = reader.GetInt32(0);
                        dersler.DersAdi   = reader.GetString(1);
                    }
                    cmbDersAdi.Items.Add(dersler);
                }
                cmbDersAdi.SelectedIndex = 0;
            }

            conn.Close();
        }
Exemple #3
0
        private void DersleriGetir()
        {
            int           bolumid = Bolum.BolumIdBul();
            int           sinif   = Bolum.SinifiBul();
            SqlConnection conn    = DbConncection.GetSqlConnection();

            var cmd = new SqlCommand();

            cmd.CommandText = "SELECT DerslerId,DersAdi FROM Ahmet_Dersler WHERE Ahmet_Dersler.BolumId=@BolumId and Ahmet_Dersler.Sinif=@Sinif ";
            cmd.Parameters.AddWithValue("@BolumId", bolumid);
            cmd.Parameters.AddWithValue("@Sinif", sinif);

            cmd.Connection = conn;
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Dersler dersler = new Dersler();
                {
                    dersler.DerslerId = reader.GetInt32(0);
                    dersler.DersAdi   = reader.GetString(1);
                }
                int a = 0;
                foreach (Dersler item in lsbSecilenDersler.Items)
                {
                    if (dersler.DerslerId == item.DerslerId)
                    {
                        a = 1;
                    }
                }
                if (a != 1)
                {
                    lsbTumDersler.Items.Add(dersler);
                }
            }
            conn.Close();
        }