Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Feature needed = (Feature)dataGridView1.CurrentRow.DataBoundItem;
            var     mr     = MessageBox.Show("Remove Feature?", "", MessageBoxButtons.YesNo);

            if (mr == DialogResult.Yes)
            {
                int count = repo.CountByFeatureId(needed.Id);
                if (count > 0)
                {
                    var dr = MessageBox.Show("This feature has multiple requirements attached to it. Removing the feature will remove all requirements attached. Do you wish to Continue?", "Attention", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.Yes)
                    {
                        repo.RemoveByFeatureId(needed.Id);
                    }
                    else
                    {
                        this.Close();
                    }
                }
                string result = feat.Remove(needed);
                if (result == "")
                {
                    this.Close();
                }
                else
                {
                    MessageBox.Show(result, "Attention");
                }
            }
        }
        private void removeToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            FakeRequirementRepository requirementRepository = new FakeRequirementRepository();

            FormSelectFeature selectAFeature = new FormSelectFeature(currentProjectID);

            selectAFeature.ShowDialog();

            if (selectAFeature.featureId != -1)
            {
                DialogResult messageBoxResult = MessageBox.Show("Are you sure you want to remove: " + featureRepository.GetFeatureById(selectAFeature.featureId).Title, "Confirmation", MessageBoxButtons.YesNo);
                if (messageBoxResult == DialogResult.Yes)
                {
                    DialogResult messageBoxResultTwo = DialogResult.No;
                    if (requirementRepository.CountByFeatureId(selectAFeature.featureId) > 0)
                    {
                        messageBoxResultTwo = MessageBox.Show("There are one or more requirements associated with this feature These Requirements will be destoryed if you remove this feature. Are you sure you want to remove: " + featureRepository.GetFeatureById(selectAFeature.featureId).Title, "Confirmation", MessageBoxButtons.YesNo);
                    }

                    if (messageBoxResultTwo == DialogResult.Yes || requirementRepository.CountByFeatureId(selectAFeature.featureId) == 0)
                    {
                        featureRepository.Remove(featureRepository.GetFeatureById(selectAFeature.featureId));
                        requirementRepository.RemoveByFeatureId(selectAFeature.featureId);
                    }
                }
                else
                {
                }
            }
            selectAFeature.Dispose();
        }
Example #3
0
        private void removeToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            FormSelectFeature         formSelect                = new FormSelectFeature(selected_id);
            FakeFeatureRepository     fakeFeatureRepository     = new FakeFeatureRepository(selected_id);
            FakeRequiremnetRepository fakeRequiremnetRepository = new FakeRequiremnetRepository(selected_id);

            formSelect.ShowDialog();
            if (formSelect.DialogResult == DialogResult.OK)
            {
                Feature      tmp          = fakeFeatureRepository.GetFeatureByID(formSelect.selectedFeatureID);
                int          count        = fakeRequiremnetRepository.CountByFeatureID(formSelect.selectedFeatureID);
                string       del          = "Are you sure you want to delete " + tmp.Title;
                string       associated   = "There are one or more requirements associated with this feature. These requirements will be destroyed if you remove this feature. Are you sure you want to remove" + tmp.Title + "?";
                DialogResult dialogResult = MessageBox.Show(del, "Confirmation", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    if (count > 0)
                    {
                        DialogResult dialogResult2 = MessageBox.Show(associated, "Confirmation", MessageBoxButtons.YesNo);
                        if (dialogResult2 == DialogResult.Yes)
                        {
                            fakeFeatureRepository.Remove(tmp);
                            fakeRequiremnetRepository.RemoveByFeatureID(tmp.Id);
                        }
                        else
                        {
                            MessageBox.Show("Delete cancelled", "Attention");
                        }
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    MessageBox.Show("Delete cancelled", "Attention");
                }
            }
            formSelect.Dispose();
        }