Beispiel #1
0
 public NewNonSportEntryForm(NonSportEntry entry) : this()
 {
     txtName.Text  = entry.Note;
     dtpFrom.Value = entry.Date.Value;
     dtpTo.Value   = entry.GetEndDate;
     comColorNames.SelectedIndex = comColorNames.Items.IndexOf(entry.DrawColor.Value.Name);
 }
Beispiel #2
0
        private void ButOkClick(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("Please enter a name", "No name entered", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return;
            }
            Entry = new NonSportEntry(dtpFrom.Value.Date, dtpTo.Value.Date, txtName.Text, labColor.BackColor);

            Close();
        }
        private void ShowNewEntryDialog(NonSportEntry entry = null)
        {
            var form = entry == null ? new NewNonSportEntryForm() : new NewNonSportEntryForm(entry);

            form.FormClosing += (ss, ee) =>
            {
                if (form.Entry == null)
                {
                    return;
                }
                AddEntry(form.Entry);
                Model.Instance.AddEntry(form.Entry);
            };
            form.Show();
        }
        private void AddEntry(NonSportEntry entry)
        {
            if (entry.DrawColor == null || entry.Date == null)
            {
                throw new Exception();
            }

            var index = 0;

            for (var i = 0; i < lisEntries.Items.Count; i++)
            {
                if (DateTime.Parse(lisEntries.Items[i].SubItems[2].Text) > entry.Date.Value)
                {
                    index = i;
                    break;
                }
            }

            lisEntries.Items.Insert(index, new ListViewItem(new[] { entry.Note ?? "ERROR: NOTE NOT SET", entry.DrawColor.Value.Name, entry.Date.Value.ToShortDateString(), entry.GetEndDate.ToShortDateString() })
            {
                BackColor = entry.DrawColor.Value
            });
        }