예제 #1
0
        public void SaveNote(Note note)
        {
            if (note.NoteId == 0)
            {
                context.Notes.Add(note);
            }

            else
            {
                Note dbEntry = context.Notes.Find(note.NoteId);
                if (dbEntry != null)
                {
                    dbEntry.Date = note.Date;
                    dbEntry.NoteStart = note.NoteStart;
                    dbEntry.NoteFinish = note.NoteFinish;
                    dbEntry.NoteText = note.NoteText;
                }
            }

            context.SaveChanges();
        }
예제 #2
0
        private void Add_Event_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            Note eventNote = new Note();

            if (dtpDate.SelectedDate == null)
            {
                dtpDate.SelectedDate = DateTime.Today;
            }

            eventNote.Date = (DateTime)dtpDate.SelectedDate;
            eventNote.NoteStart = cboHoursEventStart.Text + ":" + cboMinutesEventStart.Text;
            eventNote.NoteFinish = cboHoursEventFinish.Text + ":" + cboMinutesEventFinish.Text;
            eventNote.NoteText = myNote.Note.Trim();
            _repository.SaveNote(eventNote);
            tbxNote.Text = "";

            dataGrid_load(dataGrid1, (DateTime)dtpDate.SelectedDate);
            popupAddEvent.IsOpen = false;
        }
예제 #3
0
        private void selection_note(object sender, SelectionChangedEventArgs e)
        {
            Note editNote = dataGrid1.SelectedItem as Note;
            if (editNote != null)
            {
                var editId = editNote.NoteId;
                responseOfDB = _repository.Get(editId);

                tbxNoteEdit.Text = responseOfDB.NoteText;
                dtpDate.DisplayDate = responseOfDB.Date;
                cboHoursEditStart.Text = responseOfDB.NoteStart.Substring(0, 2);
                cboMinutesEditStart.Text = responseOfDB.NoteStart.Substring(3);
                cboHoursEditFinish.Text = responseOfDB.NoteFinish.Substring(0, 2);
                cboMinutesEditFinish.Text = responseOfDB.NoteFinish.Substring(3);
            }
        }
예제 #4
0
        private void Edit_Event_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            Note edit = new Note();

            if (dtpDate.SelectedDate == null)
            {
                dtpDate.SelectedDate = DateTime.Today;
            }

            edit.Date = dtpDate.DisplayDate;
            edit.NoteId = responseOfDB.NoteId;
            edit.NoteStart = cboHoursEditStart.Text + ":" + cboMinutesEditStart.Text;
            edit.NoteFinish = cboHoursEditFinish.Text + ":" + cboMinutesEditFinish.Text;
            edit.NoteText = myNote.Note;
            _repository.SaveNote(edit);

            tbxNoteEdit.Text = "";
            dataGrid_load(dataGrid1, (DateTime)dtpDate.DisplayDate);
            popupEdit.IsOpen = false;
        }