private void buttonSave_Click(object sender, EventArgs e) { //Save student's grades int tempLevel = 0; if (searchUser != null) { for (int i = 0; i < 10; i++) { if (gradesList[i].Value > 80) { tempLevel = i + 2; //Find the highest passed propaideia i.e. if propaideia 6 quiz is passed the Level should be 7 and because "i" starts from zero, we increase it by 2 searchUser.StudentProgress.PropaideiaProgress[i] = Convert.ToInt32(gradesList[i].Value); } } if (gradesList[10].Value > 80) { searchUser.Level = 12; } else { searchUser.Level = tempLevel; } searchUser.StudentProgress.FinalExam = Convert.ToInt32(gradesList[10].Value); StudentMapper.Update(searchUser); MessageBox.Show("Οι βαθμοί του " + searchUser.Username + " έχουν ενημερωθεί!", "Επιτυχής ενημέρωση!", MessageBoxButtons.OK); } else { MessageBox.Show("Παρακαλούμε αναζητήστε πρώτα έναν μαθητή!", "Ειδοποίηση", MessageBoxButtons.OK); } }
public void TestCreateUpdateDeleteStudents() { //DBConnection.ConnectionString = "Server=(local)\\sqlexpress;Database=Students;Trusted_Connection=True;"; //DBConnection.Type = DBType.SQLServer; DBConnection.Type = DBType.MySQL; DBConnection.ConnectionString = "Server=localhost;Port=3306;Uid=root;Pwd=system32;Database=Students;CheckParameters=false;"; var newStudent = new Student("Superman", "Male", StudentType.High); var result = StudentMapper.Insert(newStudent); Assert.AreEqual(true, result); var savedStudent = StudentMapper.GetById(newStudent.Id); Assert.AreEqual("Superman", savedStudent.Name); savedStudent.Name = "Clark Kent"; StudentMapper.Update(savedStudent); var updatedStudent = StudentMapper.GetById(savedStudent.Id); Assert.AreEqual("Clark Kent", updatedStudent.Name); StudentMapper.Hide(updatedStudent.Id); var hiddenStudent = StudentMapper.GetById(updatedStudent.Id); Assert.AreEqual(false, hiddenStudent.Enabled); StudentMapper.Delete(hiddenStudent.Id); var deleteStudent = StudentMapper.GetById(hiddenStudent.Id); Assert.AreEqual(null, deleteStudent); }
public OperationResponse Update(Student student) { var response = new OperationResponse(); try { response.HasError = !StudentMapper.Update(student); } catch (Exception ex) { response.HasError = true; response.Message = ex.ToString(); } return(response); }
private void buttonResetAccount_Click(object sender, EventArgs e) { //After a warning, the student's progress is reset to 0 if (MessageBox.Show("Είστε βέβαιοι ότι θέλετε να επαναφέτε την πρόοδο του λογαριασμού σας?", "Επαναφορά προόδου;", MessageBoxButtons.YesNo) == DialogResult.Yes) { activeStudent.Level = 1; activeStudent.StudentProgress.FinalExam = 0; for (int i = 0; i < 10; i++) { activeStudent.StudentProgress.PropaideiaProgress[i] = 0; } StudentMapper.Update(activeStudent); MessageBox.Show("Ο λογαριασμός σας έχει επαναφερθεί! Θα μεταφερθείτε στην οθόνη σύνδεσης!", "Επαναφορά Λογαριασμού", MessageBoxButtons.OK); this.Hide(); LoginScreen loginForm = new LoginScreen(); loginForm.Show(); } }
private void buttonUpdateName_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(textBoxChangeName.Text) && !String.IsNullOrEmpty(textBoxChangeSurname.Text) && Regex.IsMatch(textBoxChangeName.Text, @"^[a-zA-Z]+$") && Regex.IsMatch(textBoxChangeSurname.Text, @"^[a-zA-Z]+$")) { //Change name and surname of a temp user and if StudentMapper. Update succeeds we replace the activeStudent with it Student tempStudent = activeStudent; tempStudent.Name = textBoxChangeName.Text; tempStudent.Surname = textBoxChangeSurname.Text; if (StudentMapper.Update(tempStudent)) { activeStudent = tempStudent; MessageBox.Show("Τα στοιχεία του λογαριασμού σας ενημερώθηκαν επιτυχώς!", "Ο λογαριασμός ενημερώθηκε επιτυχώς", MessageBoxButtons.OK); } else { MessageBox.Show("Η αλλαγή των στοιχείων του μαθητή απέτυχε!", "Σφάλμα", MessageBoxButtons.OK); } } else { MessageBox.Show("Παρακαλούμε πληκτρολογήστε ένα έγκυρο όνομα/επώνυμο!", "Ειδοποίηση", MessageBoxButtons.OK); } }
/// <summary> /// Reads from the user the ID and gets the student to edit/update and allows to save changes if any /// </summary> private static void EditStudent() { var student = GetStudent(); if (student != null) { Console.WriteLine("The current student data is: " + student.ToString()); bool changed = false; StudentType type = StudentType.Kinder; Console.WriteLine("Specify the student type (K)inder, (E)lementary, (H)igh, (U)niversity; introducing the letter enclosed in parenthesis and hitting enter or EMPTY if you want keep original: "); string answer = Console.ReadLine(); if (!string.IsNullOrEmpty(answer)) { answer = answer[0].ToString(); switch (answer) { case "K": break; case "E": type = StudentType.Elementary; break; case "H": type = StudentType.High; break; case "U": type = StudentType.University; break; } if (type != student.Type) { student.Type = type; changed = true; } } string name = string.Empty; Console.WriteLine("Please introduce the student's name or EMPTY if you want keep original: "); name = Console.ReadLine(); if (!string.IsNullOrEmpty(name) && name != student.Name) { student.Name = name; changed = true; } Console.WriteLine("Specify the student gender (M)ale, (F)emale; introducing the letter enclosed in parenthesis and hitting enter or EMPTY if you want keep original: "); string gender = string.Empty; gender = Console.ReadLine(); if (!string.IsNullOrEmpty(gender)) { gender = gender.Trim(); if (gender.Length > 0) { gender = gender[0].ToString().ToUpper(); } if ((gender == "M" || gender == "F") && gender != student.Gender[0].ToString()) { student.Gender = gender == "M" ? "Male" : "Female"; changed = true; } } if (changed) { student.UpdatedOn = DateTime.Now; if (StudentMapper.Update(student)) { ShowContinueMessage("The student was updated successfully."); } else { ShowContinueMessage("We found and error updating the student please review logs and try again."); } } else { ShowContinueMessage("You did not change any data on the student, so there is nothing to save."); } } }
private void endQuiz() { //hide every question questionPanelList[0].Visible = false; questionPanelList[0].Location = hideBlank; questionPanelList[1].Visible = false; questionPanelList[1].Location = hideMult; questionPanelList[2].Visible = false; questionPanelList[2].Location = hideTF; pictureBoxNext.Visible = false; panelResult.Visible = true; panelResult.Location = questionPoint; //Get results-grade quizManager.GradeQuiz(); grade = quizManager.QuizGrade; //Update UI based on results progressBarResult.Value = grade; labelResultGrade.Text = grade.ToString() + "/100"; if (currentNumber != 0) //Quiz { if (activeStudent.StudentProgress.PropaideiaProgress[currentNumber - 1] < grade) { activeStudent.StudentProgress.PropaideiaProgress[currentNumber - 1] = grade; } if (grade > 80) { buttonList[currentNumber - 1].Image = Resources.tick; toolTipMain.SetToolTip(buttonList[currentNumber - 1], "Έχει ολοκληρωθεί η προπαίδεια του " + currentNumber); if (!buttonList[currentNumber].Enabled) { buttonList[currentNumber].Image = Resources.unlock; toolTipMain.SetToolTip(buttonList[currentNumber], "Διαβάστε την προπαίδεια και όταν είστε έτοιμοι δοκιμάστε το τεστ!"); buttonList[currentNumber].Enabled = true; } labelResult.Text = "Συγχαρητήρια!!!\nΠέρασες το quiz με βαθμό: "; if (activeStudent.Level <= currentNumber) { activeStudent.Level = currentNumber + 1; } } else { labelResult.Text = "Δεν πέρασες το τεστ!\nΔιάβασε ξανά την προπαίδεια\nκαι ξαναδοκίμασε!"; } } else //Final Exam { activeStudent.StudentProgress.FinalExam = grade; if (grade > 80) { buttonList[10].Image = Resources.tick; buttonList[10].Enabled = true; labelResult.Text = "Συγχαρητήρια!!!\nΠέρασες την εξέταση με βαθμό: "; if (activeStudent.Level < 12) { activeStudent.Level = 12; } } } StudentMapper.Update(activeStudent); }