示例#1
0
        private void FinishedButton_Click(object sender, EventArgs e)
        {
            if (ValidateTextBoxes())
            {
                // validated, pass back the data
                newLogToAdd.Topic       = topicComboBox.Text;
                newLogToAdd.StartTime   = DateTime.Parse(StartTimeBox.Text);
                newLogToAdd.EndTime     = DateTime.Parse(TimeFinishedBox.Text);
                newLogToAdd.StartDate   = DateTime.Parse(dateBox.Text);
                newLogToAdd.Description = descriptionBox.Text;

                //testing


                if (newLogToAdd.StartTime > newLogToAdd.EndTime)
                {
                    // if started before midnight and finished after
                    if (newLogToAdd.StartTime.Hour <= 23 && newLogToAdd.EndTime.Hour >= 0)
                    {
                        // The end time was after 12 O'clock so the date advanced 1 day
                        newLogToAdd.EndDate = newLogToAdd.StartDate.AddDays(1);

                        // If started before 12 am and finished after 12 am and less than start time

                        TimeSpan oneDay           = new TimeSpan(1, 0, 0, 0);
                        TimeSpan timeBeforeTwelve = oneDay.Subtract(newLogToAdd.StartTime.TimeOfDay);

                        TimeSpan tempTimeStudied = timeBeforeTwelve + newLogToAdd.EndTime.TimeOfDay;

                        newLogToAdd.TimeStudied = tempTimeStudied;
                    }
                }
                else
                {
                    newLogToAdd.TimeStudied = newLogToAdd.EndTime.Subtract(newLogToAdd.StartTime);
                    newLogToAdd.EndDate     = newLogToAdd.StartDate + newLogToAdd.EndTime.TimeOfDay;
                }
                // Add new log to StudyLogs
                LogData.StudyLogs.Add(newLogToAdd);
                newLogToAdd = new StudyLog();
            }
            else
            {
                this.DialogResult = DialogResult.None;
            }
        }
示例#2
0
        private void LogsDBView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            //If a filter is applied, display a message telling the user that deletion is diabled while a filter is applied
            if (IsFiltered)
            {
                StudyLog logToDelete = (StudyLog)(ObjectView <StudyLog>)e.Row.DataBoundItem;
                rowsToDelete.Add(logToDelete);
            }

            DialogResult deletePrompt;

            deletePrompt = MessageBox.Show($"Are you sure you want to delete this row?",
                                           "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (deletePrompt == DialogResult.Yes)
            {
                e.Cancel = false;
            }
            else
            {
                e.Cancel = true;
            }
        }
示例#3
0
        private void startButton_Click(object sender, EventArgs e)
        {
            if (topicComboBox.Text.Trim(' ') == string.Empty)
            {
                MessageBox.Show("Topic cannot be empty.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                StudyLog log = new StudyLog(
                    topicComboBox.Text,
                    DateTime.Parse(timeBox.Text),
                    DateTime.Parse(dateBox.Text),
                    descriptionBox.Text);
                // Pass log to Session Manager
                SessionManagerForm.NewStudyLog = log;


                this.Hide();
                SessionManagerForm.SessionManagerRef.Show();
                SessionManagerForm.SessionManagerRef.Location = this.Location;
                SessionManagerForm.SessionManagerRef.Focus();
            }
        }