Beispiel #1
0
        internal void NavigateSelection(EntryDisplay selection)
        {
            if (!this.IsCreate)
            {
                Entry nav = new Entry();
                foreach (var entry in EntryCollection)
                {
                    if (entry.Id == SelectedItem.Id)
                    {
                        nav = entry;
                    }
                }
                SQLAccess.Clear();
                SQLAccess.Procedure = "EntryCollectionByParentId";
                SQLAccess.Parameters.Add(@"@parentId", nav.ParentId);
                DataTable _entryCollection = SQLAccess.ExecuteProcedure();

                GenerateEntrCollectionyFromDataTable(_entryCollection);
                GenerateDisplayCollection(EntryCollection);
                Navigation.NavigationService.Navigate(new NewEntryView(Navigation, this));
                IsCreate = true;
            }
            else
            {
                Entry selected = new Entry();
                foreach (var entry in EntryCollection)
                {
                }
            }
        }
Beispiel #2
0
        internal void Add()
        {
            if (string.IsNullOrEmpty(Name))
            {
                Name = Header;
            }

            string _header   = Header;
            string _parentId = string.Empty;
            string _name     = string.Empty;
            string _comment  = Comment;

            DateTime _dateCompleted = DateTime.Now;

            DateCompleted = _dateCompleted;
            Entry        tmp        = null;
            EntryDisplay tmpDisplay = null;

            if (EntryCollection.Count > 0)
            {
                Header     = EntryCollection[0].Header;
                _parentId  = EntryCollection[0].ParentId;
                _name      = EntryCollection[0].Name;
                tmp        = new Entry(_name, _dateCompleted, _header, _comment, _parentId, Guid.NewGuid().ToString());
                tmpDisplay = new EntryDisplay(_dateCompleted.ToString("MM/dd/yyyy HH:mm"), FormatHeader(_header), tmp.Id);
            }
            else
            {
                tmp        = new Entry(Name, _dateCompleted, _header, _comment, model.ParentId, Guid.NewGuid().ToString());
                tmpDisplay = new EntryDisplay(_dateCompleted.ToString("MM/dd/yyyy HH:mm"), FormatHeader(_header), tmp.Id);
            }


            EntryDisplayCollection.Add(tmpDisplay);
            EntryCollection.Add(tmp);

            foreach (var entry in EntryCollection)
            {
                SQLAccess.Clear();
                SQLAccess.Procedure = "CreateEntry";
                SQLAccess.Parameters.Add(@"@name", entry.Name);
                SQLAccess.Parameters.Add(@"@header", entry.Header);
                SQLAccess.Parameters.Add(@"@comment", entry.Comment);
                SQLAccess.Parameters.Add(@"@dateCompleted", entry.DateCompleted);
                SQLAccess.Parameters.Add(@"@parentId", entry.ParentId);
                SQLAccess.Parameters.Add(@"@id", entry.Id);
                SQLAccess.Execute();
            }

            Clear();
        }
Beispiel #3
0
        public void Remove()
        {
            var   _display = EntryDisplayCollection.Single(x => x.Completed == SelectedItem.Completed) as EntryDisplay;
            Entry _entry   = EntryCollection.Single(x => x.Id == SelectedItem.Id) as Entry;

            EntryDisplayCollection.Remove(_display);
            EntryCollection.Remove(_entry);
            SelectedItem = null;
            //Add Removal logic to sql call
            SQLAccess.Clear();
            SQLAccess.Procedure = "RemoveEntry";
            SQLAccess.Parameters.Add(@"@id", _entry.Id);
            SQLAccess.Execute();
            Clear();
        }