Пример #1
0
            public ObservableCollection<SubjectViewModel> GetAllSubjects(int CurrentID)
            {
                subjects = new ObservableCollection<SubjectViewModel>();
                using (var db = new SQLite.SQLiteConnection(app.dbPath))
                {
                    var q = db.Query<Subject>("select * from subject where MemID = "+CurrentID+" ");
                    foreach (var _subject in q)
                    {
                        var subject = new SubjectViewModel()
                        {
                            Id = _subject.Id,
                            SbjName = _subject.SbjName,
                            SbjMark = _subject.SbjMark,
                            ObtainMark = _subject.ObtainMark,
                            Performance = _subject.Performance,

                        };
                        subjects.Add(subject);
                    }
                }
                return subjects;
            }
Пример #2
0
        private void btnAddSubject_Click(object sender, RoutedEventArgs e)
        {
            var objSubject = new SubjectViewModel();

            string sbjName = string.Empty;
            int sbjMark = 0;
            int verifyNum;
            string status = string.Empty;

            try
            {
                bool isNumeric = int.TryParse(txbGoalMark.Text, out verifyNum);

                if (isNumeric == true)
                {
                    sbjName = txbSubject.Text;
                    sbjMark = Convert.ToInt16(txbGoalMark.Text);

                    if (!sbjName.Equals(""))
                    {
                        if ((sbjMark >= 50) && (sbjMark <= 100))
                        {
                            if (verifyDuplication(sbjName) != true)
                            {
                                
                                objSubject.SetSubject(sbjName, sbjMark, GetID);
                                status = "Successfully added" + "\n" + sbjName + " with a goal mark of " + sbjMark;
                                lstOutput.Items.Add("Name: " + sbjName + "\nGoal mark of: " + sbjMark);

                                txbSubject.Text = "";
                                txbGoalMark.Text = "";

                            }
                            else
                            {
                                status = "Subject name already exist. \nPlease choose another name.";
                            }
                        }
                        else
                        {
                            status  = "Please specify the goal mark between 50 and 100.";

                        }
                    }
                    else
                    {
                        status  = "Please fill the subject name";
                    }
                }
                else
                {
                    status = "Please enter a numeric number on the goal mark.";
                }
            }
            catch (Exception ex)
            {
                messageBox("error " + ex.Message);
            }

            if (status != string.Empty)
                messageBox(status);
        }
Пример #3
0
        private void btnClear_Click(object sender, RoutedEventArgs e)
        {
            var objSubject = new SubjectViewModel();
            var objReminder = new ReminderViewModel();
            var objStudy = new StudyViewModel();
            string output = (string)cmbOutput.SelectedItem;
            string table = string.Empty;

            try
            {
                if (output == "Progress")
                {
                    lsvOutput.Items.Clear();
                    objSubject.RemoveSubject(GetID);

                }
                else if (output == "Reminders")
                {
                    lsvOutput.Items.Clear();
                    objReminder.RemoveReminder(GetID);
                }
                else if (output == "StudyTime")
                {
                    lsvOutput.Items.Clear();
                    objStudy.RemoveStudy(GetID);
                }
                btnClear.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                if (output == "Progress")
                    table = "Subjects";
                else if (output == "Reminders")
                    table = "Reminders";
                else if (output == "StudyTime")
                    table = "StudyTimes";

                messageBox("error " + ex.Message + "\nPlease add " + table);
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        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);

        }