private void buttonAnuleazaNota_Click(object sender, EventArgs e) { try { MedieSemestruBL med = new MedieSemestruBL(); NotaBL notaBL = new NotaBL(); int idNota = int.Parse(comboBoxListaNote.SelectedValue.ToString()); DataTable m = med.GetMedieSemIDuri(id_sem, id_elev, id_mat); int medie = 0; if (m != null) { medie = int.Parse(m.Rows[0]["medie_semstru"].ToString()); } if (medie == 0) { notaBL.DeleteNota(idNota); labelAnulareNota.Text = "Nota a fost stearsa cu succes!"; } else { labelAnulareNota.Text = "Nota nu poate fi stearsa pentru ca media e deja incheiata!"; } } catch (Exception exc) { labelAnulareNota.Text = "Media pentru datele dumneavoasta nu figureaza in baza de date, nota nu poate fi stearsa!"; } NotaBL notaBl = new NotaBL(); DataTable listaNote = notaBl.GetNoteByIDuri(id_elev, id_mat, id_sem); NotaForm nf = new NotaForm(); nf.setListaNote(listaNote); }
private void CalcMediePeSem_Click(object sender, EventArgs e) { // try // { int semID = int.Parse(comboBoxNotaSem.SelectedValue.ToString()); int elevID = int.Parse(comboBoxNotaElev.SelectedValue.ToString()); int materieID = int.Parse(comboBoxNotaMaterie.SelectedValue.ToString()); int clasaId = int.Parse(comboBoxNotaClasa.SelectedValue.ToString()); NotaBL notBL = new NotaBL(); ClasaBL clBl = new ClasaBL(); DataTable t = clBl.VerifTeza(materieID, clasaId); bool tezica = bool.Parse(t.Rows[0]["teza"].ToString()); DataTable note = notBL.GetNoteByIDuri1(elevID, materieID, semID); if (note.Rows.Count >= 3) { int medie = 0; int teza = 0; for (int i = 0; i < note.Rows.Count; i++) { //if (note.Rows.Rows[i]["nota"] != null) medie = medie + int.Parse(note.Rows[i]["nota"].ToString()); } //else //teza = int.Parse(note.Rows.Rows[i]["teza"].ToString()); medie = medie / note.Rows.Count; if (tezica) { t = notBL.GetTezaByIDuri(elevID, materieID, semID); teza = int.Parse(t.Rows[0]["teza"].ToString()); medie = (medie * 3 + teza) / 4; } MedieSemestruBL mdsem = new MedieSemestruBL(); mdsem.AddMedie(elevID, materieID, semID, medie); labelEroareNotaForm.Text = "Media este: " + medie.ToString(); } else { labelEroareNotaForm.Text = "Media nu poate fi calculata deoarece nu sunt minim 3 note!"; } //} // catch(Exception except) // { // labelEroareNotaForm.Text = "eroare"; // } }