Example #1
0
        public void editTask_Click(object sender, EventArgs e)
        {
            try
            {
                edittedTask = currentTasks[taskList.SelectedIndex];
                int editIndex = taskList.SelectedIndex;

                newTask = new NewTask(this);
                newTask.TaskName.Text = edittedTask.Name;
                newTask.taskTime.Value = Convert.ToDateTime(edittedTask.Date);
                newTask.HourBox.Text = Convert.ToString(edittedTask.Date.Hour);
                newTask.MinuteBox.Text = Convert.ToString(edittedTask.Date.Minute);
                newTask.Location.Text = edittedTask.Location;
                newTask.Details.Text = edittedTask.Details;
                newTask.Alarm.Text = edittedTask.Alarm.ToString();

                newTask.editing = true;
                this.Hide();
                newTask.Show();

                allTasks.Remove(edittedTask);
                currentTasks.Remove(edittedTask);
                taskList.Items.RemoveAt(editIndex);
            }
            catch { }
        }
Example #2
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (this.editing)
            {
                task = parent.edittedTask;
                parent.addTask();
                this.editing = false;
                this.parent.Show();
            }

            else
                parent.Show();
        }
Example #3
0
        private void addTask_Click(object sender, EventArgs e)
        {
            //set task name
            if (TaskName.Text.Length == 0)
                taskName = "New Task";
            else
                taskName = TaskName.Text;

            date = taskTime.Value;
            location = Location.Text;
            details = Details.Text;

            // This block checks the input of the alarm time,
            // displays a message if any error in the input is found
            bool isNum = int.TryParse(Alarm.Text, out alarmTime);

            if (String.IsNullOrEmpty(Alarm.Text))
                alarmTime = 0;
            else if (!isNum)
            {
                MessageBox.Show("Invalid alarm integer entered");
                return;
            }
            else if (alarmTime < 0)
            {
                MessageBox.Show("Invalid alarm integer entered (minutes must be > 0)");
                return;
            }

            // This block checks the input of hour, displays a message if any error
            // in the input is found.
            isNum = int.TryParse(HourBox.Text, out hour);

            if (String.IsNullOrEmpty(HourBox.Text))
            {
                MessageBox.Show("Hour must have a value");
                return;
            }
            else if (!isNum)
            {
                MessageBox.Show("Invalid hour integer entered");
                return;
            }
            else if (hour < 1 || hour > 12)
            {
                MessageBox.Show("Hour must be an integer greater than 0 and less than or equal to 12 ");
                return;
            }

            // This block checks the input of minute, displays a message if any error
            // in the input is found.
            isNum = int.TryParse(MinuteBox.Text, out minute);

            if (String.IsNullOrEmpty(MinuteBox.Text))
            {
                MessageBox.Show("Minute must have a value");
                return;
            }
            else if (!isNum)
            {
                MessageBox.Show("Invalid minute integer entered");
                return;
            }
            else if (minute < 0 || minute >= 60)
            {
                MessageBox.Show("Minute must be an integer greater than or equal to 0 and less than 60.");
                return;
            }

            if (PMradio.Checked == true && hour < 12)
                hour += 12;

            task = new Task(taskName, new DateTime(date.Year, date.Month, date.Day,
                        hour, minute, 0), location, details, alarmTime);

            this.parent.Show();
            this.parent.addTask();
            this.Hide();
        }