Esempio n. 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            MatchItem matchNew = new MatchItem(
                txtTeam1.Text,
                txtTeam2.Text,
                MatchHelper.MergeDate(dtpDateBegin.Value, dtpTimeBegin.Value),
                (int)nudDuration.Value);

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

            string matchIntersects = MatchHelper.ToIntersectsString(matchProvider, matchNew);

            if (matchIntersects == string.Empty ||
                MessageBox.Show(Strings.IntersectAdd + matchIntersects, Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                matchProvider.Add(matchNew);

                matchProvider.Save();
                lstMatches.Items.Clear();
                matchProvider.Load();
                lstMatches.SetSelected(matchProvider.Count - 1, true);
            }
        }
Esempio n. 2
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);
                }
            }
        }
Esempio n. 3
0
        private void dtpBegin_ValueChanged(object sender, EventArgs e)
        {
            if (dtpDateBegin.Value < DateTime.Today)
            {
                dtpDateBegin.Value = DateTime.Today;
            }

            DateTime dateBegin = MatchHelper.MergeDate(dtpDateBegin.Value, dtpTimeBegin.Value);

            dtpDateBegin.Value = dateBegin;
            dtpTimeBegin.Value = dateBegin;
        }