private void taskAddButton_Click_1(object sender, EventArgs e) { if (taskNameText.Text == "" || taskDescText.Text == "" || taskContactsListDropDown.SelectedIndex == -1) { MessageBox.Show("Mandatory field(s) required.", "Add Status", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (!(taskOneoffRButton.Checked) && !(taskMonthlyRButton.Checked) && !(taskWeeklyRButton.Checked) && !(taskYearlyRButton.Checked) == true) { MessageBox.Show("Please select category.", "Add Status", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (taskOneoffRButton.Checked) { taskCategoryRButton = taskOneoffRButton.Text; } else if (taskMonthlyRButton.Checked) { taskCategoryRButton = taskMonthlyRButton.Text; } else if (taskWeeklyRButton.Checked) { taskCategoryRButton = taskWeeklyRButton.Text; } else if (taskYearlyRButton.Checked) { taskCategoryRButton = taskYearlyRButton.Text; } else { Console.WriteLine("Error in category selection."); } if (taskAdditionalText.Text == "" || taskAdditionalText.Text == null) { taskAdditionalText.Text = "N/A"; } else if (taskLocationText.Text == "" || taskLocationText.Text == null) { taskLocationText.Text = "N/A"; } else if (taskPriorityDropDown.Text == "" || taskPriorityDropDown.Text == null) { taskPriorityDropDown.Text = "None"; } else { cc.TaskName = taskNameText; cc.TaskDueDate = taskDueDateBox; cc.TaskTimeFrom = taskTimeFromTBox; cc.TaskTimeTo = taskTimeToTBox; cc.TaskLocation = taskLocationText; cc.TaskDescription = taskDescText; cc.TaskAdditionalNote = taskAdditionalText; cc.TaskPriorityLevel = taskPriorityDropDown; cc.TaskContact = taskContactsListDropDown; cc.TaskCategory = taskCategoryRButton; cc.TaskDataGridView = taskDataGridView; cc.addTask(); taskNameText.Text = ""; taskDueDateBox.Text = ""; taskTimeFromTBox.Text = ""; taskTimeToTBox.Text = ""; taskContactsListDropDown.Text = ""; taskLocationText.Text = ""; taskDescText.Text = ""; taskCategoryRButton = ""; taskAdditionalText.Text = ""; taskPriorityDropDown.Text = ""; } } }