Exemple #1
0
        private void butDeleteTrophy_Click(object sender, EventArgs e)
        {
            int trophyID = CurrentTrophyID;

            // Cannot delete if there are winners
            if ((int)tblWinnersTableAdapter.GetWinnerCountByTrophy(trophyID) > 0)
            {
                MessageBox.Show(this, "A trophy cannot be deleted if it has any winners.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Cannot delete if there are photos
            using (TrophyDataSetTableAdapters.tblPhotosTableAdapter adapter = new LDYC_Trophies.TrophyDataSetTableAdapters.tblPhotosTableAdapter()) {
                if ((int)adapter.GetPhotoCountByTrophy(trophyID) > 0)
                {
                    MessageBox.Show(this, "A trophy cannot be deleted if it has any photos.",
                                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            DialogResult res = MessageBox.Show(this, "Are you sure you want to delete this trophy?",
                                               Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.No)
            {
                return;
            }

            this.tblTrophiesBindingSource.RemoveCurrent();
            this.tblTrophiesTableAdapter.Update(this.trophyDataSet.tblTrophies);

            OnTrophyPositionChanged();
        }
Exemple #2
0
        private void butDeleteTrophy_Click(object sender, EventArgs e)
        {
            int trophyID = CurrentTrophyID;

              // Cannot delete if there are winners
              if ((int)tblWinnersTableAdapter.GetWinnerCountByTrophy(trophyID) > 0) {
            MessageBox.Show(this, "A trophy cannot be deleted if it has any winners.",
              Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
              }

              // Cannot delete if there are photos
              using (TrophyDataSetTableAdapters.tblPhotosTableAdapter adapter = new LDYC_Trophies.TrophyDataSetTableAdapters.tblPhotosTableAdapter()) {
            if ((int)adapter.GetPhotoCountByTrophy(trophyID) > 0) {
              MessageBox.Show(this, "A trophy cannot be deleted if it has any photos.",
            Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
              return;
            }
              }

              DialogResult res = MessageBox.Show(this, "Are you sure you want to delete this trophy?",
            Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
              if (res == DialogResult.No)
            return;

              this.tblTrophiesBindingSource.RemoveCurrent();
              this.tblTrophiesTableAdapter.Update(this.trophyDataSet.tblTrophies);

              OnTrophyPositionChanged();
        }