Esempio n. 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int selected = lstMatches.SelectedIndex;

            if (selected > -1 && selected < matchProvider.Count)
            {
                MatchItem matchUpdate = matchProvider[selected];
                matchUpdate.Team1     = txtTeam1.Text;
                matchUpdate.Team2     = txtTeam2.Text;
                matchUpdate.DateBegin = MatchHelper.MergeDate(dtpDateBegin.Value, dtpTimeBegin.Value);
                matchUpdate.Duration  = (int)nudDuration.Value;

                if (matchUpdate.DateBegin < DateTime.Now)
                {
                    MessageBox.Show(Strings.NotUpdate, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                string matchIntersects = MatchHelper.ToIntersectsString(matchProvider, matchUpdate);
                if (matchIntersects == string.Empty ||
                    MessageBox.Show(Strings.IntersectUpdate + matchIntersects, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    matchProvider.Save();
                    lstMatches.Items.Clear();
                    matchProvider.Load();
                    lstMatches.SetSelected(selected, true);
                }
            }
        }