private void selFeatToRem_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("A feature must be selected", "Error !");
            }
            else
            {
                int             selectedIndex = this.dataGridView1.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow   = this.dataGridView1.Rows[selectedIndex];

                int    selectedFeatureId    = Convert.ToInt32(selectedRow.Cells["featureId"].Value);
                string selectedFeatureTitle = selectedRow.Cells["featTitle"].Value.ToString();

                Feature featureToRemove = new Feature();
                featureToRemove.id        = selectedFeatureId;
                featureToRemove.ProjectId = curProjectId;
                featureToRemove.Title     = selectedFeatureTitle;

                FakeRequirementRepository myReqs  = new FakeRequirementRepository();
                FakeFeatureRepository     myFeats = new FakeFeatureRepository();

                if (myReqs.CountByFeatureId(selectedFeatureId) > 0)
                {
                    DialogResult confirmation = MessageBox.Show(String.Format("There are one or more requirements associateed with this feature" +
                                                                              "These requirements will be destroyed if you remove this feature.Are you sure you want to remove : {0}", selectedFeatureTitle), "Confirmation", MessageBoxButtons.YesNo);

                    if (confirmation == DialogResult.Yes)
                    {
                        string success = myFeats.Remove(featureToRemove);


                        myReqs.RemoveByFeatureId(selectedFeatureId);
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }

                    /*else
                     * {
                     *  this.DialogResult = DialogResult.Cancel;
                     *
                     * }*/
                }
                else
                {
                    DialogResult confirmation = MessageBox.Show(String.Format("Are you sure you want to remove : {0}", selectedFeatureTitle), "Confirmation", MessageBoxButtons.YesNo);
                    if (confirmation == DialogResult.Yes)
                    {
                        myFeats.Remove(featureToRemove);
                        this.Close();
                    }
                }
            }
        }
Example #2
0
        private void SelectFeatureButton_Click(object sender, EventArgs e)
        {
            Feature modifyFeature = new Feature();

            foreach (DataGridViewRow row in FeatureList.SelectedRows)
            {
                modifyFeature.Id        = Int32.Parse(row.Cells[0].Value.ToString());
                modifyFeature.ProjectId = selectedProject;
                modifyFeature.Title     = row.Cells[1].Value.ToString();
            }

            if (operationType == 0)
            {
                FormCreateFeature modifyForm = new FormCreateFeature(formFeatureRepo, selectedProject, 1, modifyFeature);
                modifyForm.ShowDialog();
                modifyForm.Dispose();
                Dispose();
            }

            else if (operationType == 1)
            {
                DialogResult result = MessageBox.Show("Are you sure you want to remove: " + modifyFeature.Title + "?", "Confirmation", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    foreach (Requirement r in formRequirementRepo.GetAll(selectedProject))
                    {
                        if (r.FeatureId == modifyFeature.Id)
                        {
                            DialogResult confirmResult = MessageBox.Show("There are one or more requirements associated with this feature.\nThese requirements will be destroyed if you remove this feature.\nAre you sure you want to remove: " + modifyFeature.Title + "?", "Confirmation", MessageBoxButtons.YesNo);
                            if (confirmResult == DialogResult.Yes)
                            {
                                formFeatureRepo.Remove(modifyFeature);
                            }

                            Dispose();
                        }
                    }

                    formFeatureRepo.Remove(modifyFeature);
                    Dispose();
                }

                else
                {
                    MessageBox.Show("Remove canceled", "Attention", MessageBoxButtons.OK);
                    Dispose();
                }
            }
        }
        private void selectButton_Click(object sender, EventArgs e)
        {
            if (dataRemove.SelectedCells.Count < 0)
            {
                MessageBox.Show("A must be selected.", "Attention");
            }
            else
            {
                _selectID = dataRemove.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow = dataRemove.Rows[_selectID];
                int             sID         = Convert.ToInt32(selectedRow.Cells["ID"].Value);

                _selectID = sID;

                FakeFeatureRepository fake1 = new FakeFeatureRepository();
                Feature f2 = fake1.GetFeatureByID(_selectID);
                FakeRequirementRepository req = new FakeRequirementRepository();


                DialogResult result = MessageBox.Show("Are you sure you want to Remove:" + f2.Title, "Confirmation", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    DialogResult result2 = MessageBox.Show("There are Requirements associated with this Feature.\n" + "These Requirements will also be deleted.", "Confirmation", MessageBoxButtons.YesNo);
                    if (result2 == DialogResult.Yes)
                    {
                        string res = fake1.Remove(f2);
                        req.RemoveByFeatureID(_selectID);
                    }
                    else
                    {
                        MessageBox.Show("Remove Canceled", "Attention", MessageBoxButtons.OK);
                    }
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Remove Canceled", "Attention", MessageBoxButtons.OK);
                }
            }
        }