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();
        }
Пример #2
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");
                }
            }
        }