Пример #1
0
 private void acceptButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (!matchDateBox.MaskCompleted || !matchTimeBox.MaskCompleted || competitionID.SelectedItem == null)
         {
             MessageBox.Show("Please don't leave empty boxes");
             return;
         }
         if (MessageBox.Show("Are you sure, that you want to edit this match?", "Match Database", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             if (!connectionWithDatabase.isConnected())
             {
                 connectionWithDatabase.OpenConnection();
             }
             {
                 object[]        tab       = new object[2];
                 MaskedTextBox[] GoalsAway = { Goals1Away, Goals2Away, Goals3Away, Goals4Away, Goals5Away, Goals6Away, Goals7Away, Goals8Away, Goals9Away, Goals10Away, Goals11Away };
                 MaskedTextBox[] GoalsHome = { Goals1Home, Goals2Home, Goals3Home, Goals4Home, Goals5Home, Goals6Home, Goals7Home, Goals8Home, Goals9Home, Goals10Home, Goals11Home };
                 tab = connectionWithDatabase.returnIdOfTeams(editMatchListBox);
                 connectionWithDatabase.updateGoalsInMatch(editMatchListBox, GoalsAway, int.Parse(tab[1].ToString()));
                 connectionWithDatabase.updateGoalsInMatch(editMatchListBox, GoalsHome, int.Parse(tab[0].ToString()));
                 totalHome.Text = sumOfGoals(GoalsHome).ToString();
                 totalAway.Text = sumOfGoals(GoalsAway).ToString();
                 connectionWithDatabase.updateMatch(editMatchListBox, matchDateBox, matchTimeBox, competitionID, Winner(totalHome, totalAway));
             }
         }
     }
     catch (Exception es)
     {
         MessageBox.Show("Error 404 in adding Team. Check DataBaseConnection \r\n" + es.Message + "\r\n" + es.InnerException.Message);
     }
     finally
     {
         connectionWithDatabase.CloseConnection();
     }
 }