Пример #1
0
        private void buttonCANCEL_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("¿Are you sure you want to discard the note?", "Exit", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                resetText();

                ModifyNotes.modifyNote = false;
                ModifyNotes.resetNotes();

                this.Hide();
            }
        }
Пример #2
0
        private void buttonSAVE_Click(object sender, EventArgs e)
        {
            Note note = new Note();

            note.Title       = textboxTITLE.Text;
            note.Category    = textboxCATEGORY.Text;
            note.Description = textboxDESCRIPTION.Text;

            switch (comboboxIMPORTANCE.SelectedIndex)
            {
            case 0:
                note.Importance = "Low";
                break;

            case 1:
                note.Importance = "Medium";
                break;

            default:
                note.Importance = "High";
                break;
            }

            if (switchFAVOURITE.Value)
            {
                note.Favorite = 1;
            }
            else
            {
                note.Favorite = 0;
            }

            // If the user is modifying the note...
            if (ModifyNotes.modifyNote)
            {
                note.Id = Convert.ToInt32(textboxID.Text);

                // Sending data to modify the note.
                DB_Data.ModifyNote(note);

                // Send the message to the user.
                MessageBox.Show("Note modified!", "Modify note", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                // Sending data to create the note.
                DB_Data.CreateNote(Properties.Settings.Default.UserID, note);

                // Send the message to the user.
                MessageBox.Show("Note added!", "Create note", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            // Refreshing the datagridview.
            if (Application.OpenForms["FormSeeNotes"] != null)
            {
                (Application.OpenForms["FormSeeNotes"] as FormSeeNotes).updateNotes();
            }

            // Reset every possible thing to avoid bugs.
            resetText();

            ModifyNotes.modifyNote = false;
            ModifyNotes.resetNotes();

            // Hiding the form.
            this.Hide();
        }