Esempio n. 1
0
        // Method for deleting an existing monster from the database.
        private void DeleteSelectedNote(DataRowView row)
        {
            // Cancel method if blank space is selected.
            if (row == null)
            {
                return;
            }

            // Confirm deletion with the user.
            if (MessageBox.Show("Are you sure you want to delete this Note? (This is PERMANENT!)", "Warning!", MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Warning) == DialogResult.OK)
            {
                // Create note object from selected row.
                CampaignNote note = new CampaignNote();
                note.Id         = row.Row.Field <int>("Id");
                note.CampaignId = row.Row.Field <int>("CampaignId");
                note.Title      = row.Row.Field <string>("Title");
                note.Type       = row.Row.Field <string>("Type");
                note.DateAdded  = row.Row.Field <DateTime>("DateAdded").ToString();
                note.Note       = row.Row.Field <string>("Note");

                notesTableAdapter.Delete(note.Id, Campaign.Id, note.Title, note.Type, DateTime.Parse(note.DateAdded), note.Note);

                // Refresh monster data display.
                RefreshNoteData();
            }
            else
            {
                return;
            }
        }
Esempio n. 2
0
        // Method to save/add new note to the database.
        private void SaveNote(CampaignNote note)
        {
            // Different business logic if new player variable
            // is set to false or true.
            if (!_newNote && _currentNote != null)
            {
                notesTableAdapter.Update(_parentForm.Campaign.Id, note.Title, note.Type, DateTime.Parse(note.DateAdded), note.Note, _currentNote.Id, _currentNote.CampaignId,
                                         _currentNote.Title, _currentNote.Type, DateTime.Parse(_currentNote.DateAdded), _currentNote.Note);

                MessageBox.Show("Note updated!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (_newNote)
            {
                notesTableAdapter.Insert(_parentForm.Campaign.Id, note.Title, note.Type, DateTime.Parse(note.DateAdded), note.Note);

                MessageBox.Show("Note added to the database!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Unexpected error has occured!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Refresh player datagrid on parent form and close.
            _parentForm.RefreshNoteData();
            this.Close();
        }
Esempio n. 3
0
        // Adjusted Constructor that includes argument for parentForm.
        public FormNote(FormMain parentForm, CampaignNote selectedNote)
        {
            InitializeComponent();
            _parentForm = parentForm;

            // Pass selected player object to form.
            _currentNote = selectedNote;
        }
Esempio n. 4
0
        // Method for selecting and loading an existing note for
        // view or editing.
        private void GetSelectedNote(DataRowView row)
        {
            // Cancel method if blank space is selected.
            if (row == null)
            {
                return;
            }

            // Create note object from selected row.
            CampaignNote note = new CampaignNote();

            note.Id         = row.Row.Field <int>("Id");
            note.CampaignId = row.Row.Field <int>("CampaignId");
            note.Title      = row.Row.Field <string>("Title");
            note.Type       = row.Row.Field <string>("Type");
            note.DateAdded  = row.Row.Field <DateTime>("DateAdded").ToString();
            note.Note       = row.Row.Field <string>("Note");

            // Create a monster form with loaded data and display it.
            FormNote formNote = new FormNote(this, note);

            formNote.Show();
        }