Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            NewNote Page = new NewNote();

            Page.Show();
        }
Esempio n. 2
0
        //responds to the click on the button
        void Button_MouseDown(object sender, EventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                ContextMenuStrip contexMenuStrip1 = new ContextMenuStrip();
                contexMenuStrip1.Items.Add("Delete ");
                button.ContextMenuStrip = contexMenuStrip1;


                //If there is a right click on th button context menu is displayed
                MouseEventArgs me = (MouseEventArgs)e;
                if (me.Button == MouseButtons.Right)
                {
                    contexMenuStrip1.Show();
                    contexMenuStrip1.ItemClicked += new ToolStripItemClickedEventHandler((sender1, e1) => contexMenuuu_ItemClicked(sender1, e1, button));
                }
                //If there is a left click on the button the note with the title of the button is shown
                else if (me.Button == MouseButtons.Left)
                {
                    this.Hide();
                    NewNote form = new NewNote();
                    form.Show();

                    string connectionString = "server=localhost;uid=root;pwd=;database=Baza";
                    using (MySqlConnection conn = new MySqlConnection(connectionString))
                    {
                        conn.Open();

                        String          q1     = "SELECT * FROM newnote WHERE Title = '" + button.Text + "'  ";
                        MySqlCommand    cmd    = new MySqlCommand(q1, conn);
                        MySqlDataReader reader = cmd.ExecuteReader();

                        form.SetTextBox(button.Text);
                        reader.Read();
                        form.setRichTextBox(reader.GetString(reader.GetOrdinal("Note")));

                        cmd.Cancel();
                        cmd.Connection.Close();
                        reader.Close();
                    }
                }
            }
        }