Esempio n. 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int    ID         = int.Parse(txtID.Text.Trim());
            String Title      = txtTitle.Text.Trim();
            String Creator    = txtCreator.Text.Trim();
            String Content    = txtContent.Text.Trim();
            String Date       = txtDate.Text.Trim();
            bool   IsSharable = cbSharable.Checked;

            gearhostNote.Note newNote = new gearhostNote.Note()
            {
                ID         = ID,
                Title      = Title,
                Creator    = Creator,
                Content    = Content,
                Date       = Date,
                IsSharable = IsSharable
            };
            bool result = service.Update(newNote);

            if (result)
            {
                notes = service.GetAllNotes();
                dataGridView1.DataSource = notes;
            }
            else
            {
                MessageBox.Show("Sorry!!!");
            }
        }
Esempio n. 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int    ID         = int.Parse(txtID.Text.Trim());
            String Title      = txtTitle.Text.Trim();
            String Creator    = txtCreator.Text.Trim();
            String Content    = txtContent.Text.Trim();
            String Date       = txtDate.Text.Trim();
            bool   IsSharable = cbSharable.Checked;

            gearhostNote.Note newNote = new gearhostNote.Note()
            {
                ID         = ID,
                Title      = Title,
                Creator    = Creator,
                Content    = Content,
                Date       = Date,
                IsSharable = IsSharable
            };
            DialogResult r;

            r = MessageBox.Show("Do you want to delete this item?", "Warnings",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2);
            if (r == DialogResult.Yes)
            {
                bool note = service.Delete(ID);
                if (note)
                {
                    notes = service.GetAllNotes();
                    dataGridView1.DataSource = notes;
                }
                else
                {
                    MessageBox.Show("Sorry!!!");
                }
            }
            else
            {
                return;
            }
        }