コード例 #1
0
 private void buttonSetSeasonMain_Click(object sender, EventArgs e)
 {
     // check to see if the form is open
     if ((Application.OpenForms["FormSetUpSeason"] as FormSetUpSeason) != null)
     {
         // if it is then select the right form
         foreach (Form form in Application.OpenForms)
         {
             if (form.Name == "FormSetUpSeason")
             {
                 // activate it
                 form.Activate();
                 if (form.WindowState == FormWindowState.Minimized)
                 {
                     form.WindowState = FormWindowState.Normal;
                 }
             }
         }
     }
     else
     {
         // otherwise create a new instance of the form and show it
         FormSetUpSeason formSetUpSeason = new FormSetUpSeason();
         formSetUpSeason.Show();
     }
 }
コード例 #2
0
        private void buttonSubmitNewSeason_Click(object sender, EventArgs e)
        {
            if (textBoxSeasonNameSeason.Text == "")
            {
                MessageBox.Show("You must enter a Season Name.");
                return;
            }

            form = new FormSetUpSeason();

            try
            {
                SeasonsDBDataSet.Seasons1_5Row   newSeasonRow1    = seasonsDBDataSet.Seasons1_5.NewSeasons1_5Row();
                SeasonsDBDataSet.Seasons6_10Row  newSeasonRow2    = seasonsDBDataSet.Seasons6_10.NewSeasons6_10Row();
                SeasonsDBDataSet.Seasons11_17Row newSeasonRow3    = seasonsDBDataSet.Seasons11_17.NewSeasons11_17Row();
                AccountingDataSet.AccountingRow  newAccountingRow = accountingDataSet.Accounting.NewAccountingRow();
                newAccountingRow.SeasonName = textBoxSeasonNameSeason.Text;
                newSeasonRow1.SeasonName    = textBoxSeasonNameSeason.Text;
                newSeasonRow2.SeasonName    = textBoxSeasonNameSeason.Text;
                newSeasonRow3.SeasonName    = textBoxSeasonNameSeason.Text;
                FormSetUpSeason.SetSelectedSeason(newSeasonRow1, newSeasonRow2, newSeasonRow3);
                form.SetSeason(newSeasonRow1);
                seasonsDBDataSet.Seasons1_5.Rows.Add(newSeasonRow1);
                seasonsDBDataSet.Seasons6_10.Rows.Add(newSeasonRow2);
                seasonsDBDataSet.Seasons11_17.Rows.Add(newSeasonRow3);
                accountingDataSet.Accounting.Rows.Add(newAccountingRow);

                // make all of the players inactive for the new season if check box is checked
                if (checkBoxMakePlayersInactive.Checked == true)
                {
                    foreach (PlayersDBDataSet.PlayersRow player in playersDBDataSet.Players)
                    {
                        player.IsActive = false;
                    }
                }

                // reset all of the players wins, winnings and picks for the new season if check box is checked
                if (checkBoxResetPlayerPicks.Checked == true)
                {
                    Cursor.Current = Cursors.WaitCursor;

                    foreach (PlayersDBDataSet.PlayersRow player in playersDBDataSet.Players)
                    {
                        player.PlayerTotalWins      = 0;
                        player.PlayerCurrentWins    = 0;
                        player.PlayerTotalWinnings  = 0;
                        player.WinsWeek01           = 0;
                        player.WinsWeek02           = 0;
                        player.WinsWeek03           = 0;
                        player.WinsWeek04           = 0;
                        player.WinsWeek05           = 0;
                        player.WinsWeek06           = 0;
                        player.WinsWeek07           = 0;
                        player.WinsWeek08           = 0;
                        player.WinsWeek09           = 0;
                        player.WinsWeek10           = 0;
                        player.WinsWeek11           = 0;
                        player.WinsWeek12           = 0;
                        player.WinsWeek13           = 0;
                        player.WinsWeek14           = 0;
                        player.WinsWeek15           = 0;
                        player.WinsWeek16           = 0;
                        player.WinsWeek17           = 0;
                        player.PicksWeek01          = "";
                        player.PicksWeek02          = "";
                        player.PicksWeek03          = "";
                        player.PicksWeek04          = "";
                        player.PicksWeek05          = "";
                        player.PicksWeek06          = "";
                        player.PicksWeek07          = "";
                        player.PicksWeek08          = "";
                        player.PicksWeek09          = "";
                        player.PicksWeek10          = "";
                        player.PicksWeek11          = "";
                        player.PicksWeek12          = "";
                        player.PicksWeek13          = "";
                        player.PicksWeek14          = "";
                        player.PicksWeek15          = "";
                        player.PicksWeek16          = "";
                        player.PicksWeek17          = "";
                        player.PlayerWinningsWeek01 = 0;
                        player.PlayerWinningsWeek02 = 0;
                        player.PlayerWinningsWeek03 = 0;
                        player.PlayerWinningsWeek04 = 0;
                        player.PlayerWinningsWeek05 = 0;
                        player.PlayerWinningsWeek06 = 0;
                        player.PlayerWinningsWeek07 = 0;
                        player.PlayerWinningsWeek08 = 0;
                        player.PlayerWinningsWeek09 = 0;
                        player.PlayerWinningsWeek10 = 0;
                        player.PlayerWinningsWeek11 = 0;
                        player.PlayerWinningsWeek12 = 0;
                        player.PlayerWinningsWeek13 = 0;
                        player.PlayerWinningsWeek14 = 0;
                        player.PlayerWinningsWeek15 = 0;
                        player.PlayerWinningsWeek16 = 0;
                        player.PlayerWinningsWeek17 = 0;
                        player.Pick01 = "";
                        player.Pick02 = "";
                        player.Pick03 = "";
                        player.Pick04 = "";
                        player.Pick05 = "";
                        player.Pick06 = "";
                        player.Pick07 = "";
                        player.Pick08 = "";
                        player.Pick09 = "";
                        player.Pick10 = "";
                        player.Pick11 = "";
                        player.Pick12 = "";
                        player.Pick13 = "";
                        player.Pick14 = "";
                        player.Pick15 = "";
                        player.Pick16 = "";
                        player.Pick17 = "";
                        player.Pick18 = "";
                        player.Pick19 = "";
                        player.Pick20 = "";
                    }

                    Cursor.Current = Cursors.Default;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            this.Validate();
            this.seasons1_5BindingSource.EndEdit();
            this.seasons6_10BindingSource.EndEdit();
            this.seasons11_17BindingSource.EndEdit();
            this.playersBindingSource.EndEdit();
            this.accountingBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.seasonsDBDataSet);
            this.tableAdapterManager1.UpdateAll(this.accountingDataSet);
            this.tableAdapterManager2.UpdateAll(this.playersDBDataSet);

            // new way to get a form that is already open. Time to go replace all of the ShowDiag() code so
            // can have multiple windows open but no duplicates.
            foreach (Form forms in Application.OpenForms)
            {
                if (forms.Name == "FormSetUpSeason")
                {
                    form = forms as FormSetUpSeason;
                    form.ClearForm();
                    form.UpdateForm();
                    form.UpdateSeasonList();
                }
            }

            this.Close();
        }