コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: jh5g/Journal-IO-v2
        private void AddNewEntry() //formats info and turns it into entry object, then adds to list ??Does this add a reference to the object will this work
        {
            entry NewEntry = new entry();

            NewEntry.Entry           = NewEntryBox.Text;
            NewEntry.UnformattedDate = dateEntry.Text;
            NewEntry.Date            = DateTime.Parse(NewEntry.UnformattedDate, ukCulture.DateTimeFormat);
            bool   contained          = false;
            string entryContainedDate = "";

            foreach (entry entry in entries)
            {
                if (entry.Date == NewEntry.Date)
                {
                    contained          = true;
                    entryContainedDate = entry.UnformattedDate;
                }
            }
            if (contained)
            {
                Window1 window1 = new Window1("Do you want to overwrite this entry");
                if (window1.ShowDialog() == true)
                {
                    if (window1.DialogResult == true)
                    {
                        foreach (entry entry in entries.ToList <entry>())
                        {
                            if (entry.Date == NewEntry.Date)
                            {
                                entries.Remove(entry);
                            }
                        }
                        entries.Add(NewEntry);
                    }
                }
            }
            else
            {
                entries.Add(NewEntry);
            }
        }