コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Note _note = new Note();

            if (this.IsEditMode == true)
            {
                _note = _db.GetNotesById(NotesId);
            }

            _note.Title       = txtTitle.Text;
            _note.Notes       = txtNotes.Text;
            _note.Description = txtDescription.Text;
            _note.CustomerId  = CustomerId;
            _note.CreatedDate = DateTime.Now;
            _note.databaseID  = databaseId;
            if (IsEditMode == true)
            {
                _db.SaveNote(_note);
                _db.SaveChanges();

                MessageBox.Show(this, "Contact Saved", "Note has been Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                _db.AddToNotes(_note);
                _db.SaveNote(_note);
                MessageBox.Show(this, "Note Saved", "Note has been Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            this.Close();
        }