private void btnMark_Click(object sender, RoutedEventArgs e) { var objSubject = new SubjectViewModel(); string studyName = string.Empty; string Performance = string.Empty; string status = string.Empty; int mark = 0; int verifyNum; try { bool isNumeric = int.TryParse(edtMark.Text, out verifyNum); studyName = (string)cmbSubjects.SelectedItem; var confirm = objSubject.getSubject(studyName, GetID); if (confirm != null) { if (isNumeric == true) { mark = Convert.ToInt16(edtMark.Text); if ((mark > 0) && (mark <= 100)) { if (mark > confirm.SbjMark) { Performance = "Better"; status = "Performing better than the goal mark of " + Convert.ToString(confirm.SbjMark); } else if (mark == confirm.SbjMark) { Performance = "Good"; status = "Performing good, the marks are equal of " + Convert.ToString(confirm.SbjMark); } else if (mark < confirm.SbjMark) { Performance = "Badly"; status = "Performing badly than the goal mark of " + Convert.ToString(confirm.SbjMark); } objSubject.UpdateSubject(studyName, mark, Performance, GetID); messageBox(status); } else { messageBox("Please specify a number between 0 and 100"); } } else { messageBox("Please specify a numeric obtained mark"); } } else { messageBox("Please select a subject"); } } catch (Exception ex) { messageBox("error " + ex.Message); } }
private void Button_Click(object sender, RoutedEventArgs e) { var studyStartTime = tmpStart.Time; var studyEndTime = studyStartTime + TimeSpan.FromSeconds(10); var studyStartTime1 = tmpEnd.Time; var studyEndTime1 = studyStartTime1 + TimeSpan.FromSeconds(10); time = studyEndTime1 - studyEndTime; var objStudy = new StudyViewModel(); string studyName = string.Empty; var objSubject = new SubjectViewModel(); string status = string.Empty; studyName = (string)cmbSubjects.SelectedItem; try { studyName = (string)cmbSubjects.SelectedItem; var confirm = objSubject.getSubject(studyName,GetID); if (confirm != null) { if (FutureTime()) { if (GreaterEndTime()) { objStudy.SetStudy(studyName, time.ToString(),GetID); timer.Start(); } else { status = "End time must be greater than the start time"; } } else { status = "Start time must be greater than the current time"; } } else { status = "Please select a subject to study"; } } catch (Exception ex) { messageBox("error " + ex.Message); } if (status != string.Empty) messageBox(status); }