private void CevapButton_Click(object sender, EventArgs e) { if (i == Sorular1.Length) { MessageBox.Show("Sınav Bitti"); TBLSINAV YeniSinavSonucları = new TBLSINAV(); YeniSinavSonucları.ToplamDoğru = DogruCevaplar; YeniSinavSonucları.ToplamYanlış = YanlisCevaplar; var OGRID = Context.TBLOGRENCİ.First(); YeniSinavSonucları.OgrenciID = OGRID.OgrenciID; Context.TBLSINAVs.Add(YeniSinavSonucları); Context.SaveChanges(); this.Close(); Application.Exit(); } SoruLabel.Text = Sorular1[i]; radioButtonASIKKI.Text = A1[i]; radioButtonB.Text = B1[i]; radioButtonC.Text = C1[i]; radioButtonD.Text = D1[i]; KacinicSoruLABEL.Text = (i + 1).ToString(); if (radioButtonASIKKI.Checked && dogrular[i] == radioButtonASIKKI.Text) { DogruCevaplar++; } else if (radioButtonB.Checked && dogrular[i] == radioButtonB.Text) { DogruCevaplar++; } else if (radioButtonC.Checked && dogrular[i] == radioButtonC.Text) { DogruCevaplar++; } else if (radioButtonD.Checked && dogrular[i] == radioButtonD.Text) { DogruCevaplar++; } else { YanlisCevaplar++; var KonuIDler = (from i in Context.TBLSORUs select i.KonuID).ToArray(); int konuıd = KonuIDler[i]; var GüncellenecekYanlisDegeri = (from i in Context.SınavGeçmişiTBL where i.KonuID == konuıd select i).Single(); GüncellenecekYanlisDegeri.YanlisSayisi = GüncellenecekYanlisDegeri.YanlisSayisi + 1; Context.SaveChanges(); } i++; }
private void buttonEkle_Click(object sender, EventArgs e) { TBLSORU Yeni = new TBLSORU(); Yeni.Soru = richTextBoxSORU.Text; Yeni.A = textBoxASIKKI.Text; Yeni.B = textBoxBSIKKI.Text; Yeni.C = textBoxCSIKKI.Text; Yeni.D = textBoxDSIKKI.Text; Yeni.KonuID = comboBox1.SelectedIndex; Yeni.DogruCevap = textBoxBSIKKI.Text; Context.TBLSORUs.Add(Yeni); Context.SaveChanges(); }