Пример #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Activity_DAO activity = new Activity_DAO();

            listViewActivity.Clear();
            if (txtActivityID.Text == "" && comboBoxChange.Text == "")
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure that you wish to remove this activity?", "Remove validation", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    activity.ActivityRemover(int.Parse(comboBoxRemove.Text));
                    comboBoxChange.Items.Clear();
                    comboBoxRemove.Items.Clear();
                    DisplayActivityID();
                }
                else if (dialogResult == DialogResult.No)
                {
                }
                comboBoxRemove.ResetText();
            }
            else if (txtActivityID.Text != "" && comboBoxChange.Text == "")
            {
                SomerenLogic.Activity_Service activityService = new SomerenLogic.Activity_Service();
                List <Activity> activityList = activityService.GetActivities();
                bool            check        = false;
                foreach (var s in activityList)
                {
                    if (s.ActivityID == int.Parse(txtActivityID.Text))
                    {
                        MessageBox.Show("You can't add an activity with the same name");
                        break;
                    }
                    else
                    {
                        check = true;
                    }
                }
                if (check == true)
                {
                    activity.ActivityAdder(int.Parse(txtActivityID.Text), txtDescriptionAdd.Text, int.Parse(txtNOfStudentsAdd.Text), int.Parse(txtNOfSupervisorsAdd.Text));
                    txtActivityID.ResetText();
                    txtDescriptionAdd.ResetText();
                    txtNOfStudentsAdd.ResetText();
                    txtNOfSupervisorsAdd.ResetText();
                    comboBoxChange.Items.Clear();
                    comboBoxRemove.Items.Clear();
                    DisplayActivityID();
                }
                else if (check == false)
                {
                    txtActivityID.ResetText();
                    txtDescriptionAdd.ResetText();
                    txtNOfStudentsAdd.ResetText();
                    txtNOfSupervisorsAdd.ResetText();
                }
            }
            else if (comboBoxChange.Text != "")
            {
                activity.ActivityChanger(int.Parse(comboBoxChange.Text), txtDescriptionAdd.Text, int.Parse(txtNOfStudentsAdd.Text), int.Parse(txtNOfSupervisorsAdd.Text));
                comboBoxChange.ResetText();
                txtDescriptionAdd.ResetText();
                txtNOfStudentsAdd.ResetText();
                txtNOfSupervisorsAdd.ResetText();
            }
            DisplayListViewActivity();
        }