Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duyuru diger roller icin eklendi #26

Merged
merged 1 commit into from May 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 39 additions & 24 deletions Sukol/DuyuruPaneli.cs
Expand Up @@ -14,16 +14,35 @@ namespace Sukol
public partial class DuyuruPaneli : Form
{
public Kullanici k;
string sinif = "";
string sinif;
Veritabani db = new Veritabani();
public DuyuruPaneli(Kullanici k)
public DuyuruPaneli(Kullanici k, bool gorevli)
{
InitializeComponent();

this.k = k;

if (k.gorevli == null)
sinif = null;
if (!gorevli)
{
db.sorgu("SELECT sinif FROM ogrenciler WHERE kullanici_id=@kid");
db.parametreEkle("kid", k.id);
db.baslat();
OleDbDataReader reader = db.oku();

if (!reader.HasRows)
{
db.sorgu("SELECT sinif FROM ogretmenler WHERE kullanici_id=@kid");
db.parametreEkle("kid", k.id);
reader = db.oku();
}

while (reader.Read())
{
sinif = reader["sinif"].ToString();
comboBox_siniflar.Text = sinif;
LoadDuyurular(true);
}
db.kapat();
}

ShowDialog();
}
Expand All @@ -36,7 +55,7 @@ void LoadComboBox()
OleDbDataReader reader = db.oku();

if (!reader.HasRows)
MessageBox.Show("NULL2!");
MessageBox.Show("Sınıf yok");

while (reader.Read())
{
Expand All @@ -46,40 +65,36 @@ void LoadComboBox()
db.kapat();
}

void LoadDuyurular()
void LoadDuyurular(bool a)
{
if(sinif == null)
db.sorgu("SELECT kullanici_id, metin, tarih FROM duyurular WHERE sinif_ad=@sinif_adi");

if (sinif == null)
{
db.sorgu("SELECT (SELECT isim + \" \" + soyisim FROM kullanicilar WHERE kullanici_id=@kullanici_id) AS yazar_ad,"+
" metin, tarih FROM duyurular" +
" WHERE sinif_ad IN (SELECT sinif FROM ogrenciler WHERE kullanici_id=@kullanici_id)" +
" OR sinif_ad IN (SELECT sinif FROM ogretmenler WHERE kullanici_id=@kullanici_id)");
db.parametreEkle("kullanici_id", k.id);
db.parametreEkle("sinif_adi", comboBox_siniflar.Text);
}
else
{
db.sorgu("SELECT kullanici_id, metin, tarih FROM duyurular WHERE sinif_ad=@sinif_adi");
db.parametreEkle("sinif_adi", comboBox_siniflar.Text);
db.parametreEkle("sinif_adi", sinif);
comboBox_siniflar.Enabled = false;
button_duyuruEkle.Enabled = false;
}

db.baslat();
if (!a) db.baslat();

OleDbDataReader reader = db.oku();

while (reader.Read())
{
flowLayout_duyurular.Controls.Add(new DuyuruItem(reader[0].ToString(), reader[1].ToString(), reader[2].ToString()));
}

db.kapat();
if (!a) db.kapat();
}

private void DuyuruPaneli_Load(object sender, EventArgs e)
{
if(k.gorevli == null)
{

}
else
if (k.gorevli == null)
{
LoadComboBox();
}
Expand All @@ -88,14 +103,14 @@ private void DuyuruPaneli_Load(object sender, EventArgs e)
private void comboBox_siniflar_SelectedIndexChanged(object sender, EventArgs e)
{
flowLayout_duyurular.Controls.Clear();
LoadDuyurular();
LoadDuyurular(false);
}

private void button_duyuruEkle_Click(object sender, EventArgs e)
{
new DuyuruEkle(k, comboBox_siniflar.Text);
flowLayout_duyurular.Controls.Clear();
LoadDuyurular();
LoadDuyurular(false);
}
}
}
42 changes: 36 additions & 6 deletions Sukol/FormAna.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions Sukol/FormAna.cs
Expand Up @@ -43,9 +43,9 @@ public void kullaniciGiris(string isim, string soyisim, string profilfoto, bool
labelSoyIsimYazan.Visible = true;
label_roller.Visible = true;
string roller = "";
if (ogrenci) roller += "öğrenci,"; kullanici.ogrenci = this.ogrenci;
if (ogretmen) roller += "öğretmen,"; kullanici.ogretmen = this.ogretmen;
if (gorevli) roller += "görevli,"; kullanici.gorevli = this.gorevli;
if (ogrenci) roller += "öğrenci,";
if (ogretmen) roller += "öğretmen,";
if (gorevli) roller += "görevli,";
roller = roller.Remove(roller.Length - 1);
label_rollerYazan.Text = roller;
label_rollerYazan.Visible = true;
Expand Down Expand Up @@ -129,6 +129,11 @@ private void anaSayfaToolStripMenuItem_Click(object sender, EventArgs e)
panel_ana_sayfa.BringToFront();
}

private void öğretmenToolStripMenuItem_Click(object sender, EventArgs e)
{
panel_ogretmen.BringToFront();
}

private void görevliToolStripMenuItem_Click(object sender, EventArgs e)
{
panel_gorevli.BringToFront();
Expand Down Expand Up @@ -350,12 +355,17 @@ private void button_duraklat_Click(object sender, EventArgs e)

private void button_duyuruEkle_Click(object sender, EventArgs e)
{
new DuyuruPaneli(kullanici);
new DuyuruPaneli(kullanici, true);
}

private void button_ogrenci_duyuru_Click(object sender, EventArgs e)
{
new DuyuruPaneli(kullanici);
new DuyuruPaneli(kullanici, false);
}

private void button_ogretmen_duyurular_Click(object sender, EventArgs e)
{
new DuyuruPaneli(kullanici, false);
}
}
}