Ejemplo n.º 1
0
        // Handles the Click event of the saveButton control
        // The instance containing the event data
        private void saveButton_Click(object sender, EventArgs e)
        {
            TimeDuration duration = (TimeDuration)lengthComboBox.Items[lengthComboBox.SelectedIndex];
            int          length   = (duration.Hours * 60) + duration.Minutes;
            TimeSpan     timespan = (TimeSpan)startTimeComboBox.Items[startTimeComboBox.SelectedIndex];

            day         = day.AddHours(timespan.TotalHours);
            appointment = new Appointment(day, length, subjectTextBox.Text, locationTextBox.Text);
            this.Close();
        }
Ejemplo n.º 2
0
        // Method responsible for lengthComboBox
        // creates an new instance of timeDuration
        // initialising components, modyfing the time view in dropdrown list by 30 minutes
        private void LoadDurations()
        {
            TimeDuration time = new TimeDuration();

            time.Minutes = 30;
            time.Hours   = 0;
            while (time.Hours <= 24)
            {
                lengthComboBox.Items.Add(time);
                if (time.Hours == 24)
                {
                    return;
                }
                time.Minutes = time.Minutes + 30;
            }
        }
        /// <summary>
        /// Handles the Click event of the saveButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void saveButton_Click(object sender, EventArgs e)
        {
            int numberOfOccurence = 0;

            if (occurenceTextBox.Text.Trim() != "")
            {
                try
                {
                    // Check for occurence
                    // Cant be 1 and more than a specific high number
                    numberOfOccurence = int.Parse(occurenceTextBox.Text);
                    if (numberOfOccurence > 999 || numberOfOccurence < 2)
                    {
                        MessageBox.Show("Please select a number between 2 and 999", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        occurenceTextBox.Text = "";
                        return;
                    }
                }
                catch
                {
                    // Cathing exception of error handling
                    MessageBox.Show("Please select a number between 2 and 999", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    occurenceTextBox.Text = "";
                }
            }
            TimeDuration duration = (TimeDuration)lengthComboBox.Items[lengthComboBox.SelectedIndex];
            int          length   = (duration.Hours * 60) + duration.Minutes;
            TimeSpan     timespan = (TimeSpan)startTimeComboBox.Items[startTimeComboBox.SelectedIndex];

            day = day.AddHours(timespan.TotalHours);
            RecurrenceFrequency type = (RecurrenceFrequency)frequencyComboBox.Items[frequencyComboBox.SelectedIndex];

            if (numberOfOccurence == 0)
            {
                return;
            }
            recurringAppointment = new RecurringAppointment(numberOfOccurence, type, day, length, subjectTextBox.Text, locationTextBox.Text);
            this.Close();
        }