Beispiel #1
0
 private void button3_Click_1(object sender, EventArgs e)
 {
     if (user == null)
     {
         this.Hide();
         Form4 f1 = new Form4();
         f1.Show();
     }
     else
     {
         this.Hide();
         Form7 f1 = new Form7(user);
         f1.Show();
     }
 }
Beispiel #2
0
        void addorupdate(string query)
        {
            connection.Open();
            byte[] img = { };
            command = new MySqlCommand(query, connection);
            command.Parameters.AddWithValue("@id", value1);
            if (pictureBox1.ImageLocation != null)
            {
                MemoryStream ms = new MemoryStream();
                pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
                img = ms.ToArray();
            }
            command.Parameters.Add("@username", MySqlDbType.VarChar, 20);
            command.Parameters.Add("@title", MySqlDbType.VarChar, 30);
            command.Parameters.Add("@contents", MySqlDbType.LongText);
            command.Parameters.Add("@date", MySqlDbType.DateTime);
            command.Parameters.Add("@images", MySqlDbType.LongBlob);
            command.Parameters.Add("@type_blog", MySqlDbType.VarChar, 30);

            command.Parameters["@username"].Value = val;
            command.Parameters["@title"].Value    = textBox1.Text;
            command.Parameters["@contents"].Value = richTextBox1.Text;
            command.Parameters["@date"].Value     = now;
            if (pictureBox1.ImageLocation != null)
            {
                command.Parameters["@images"].Value = img;
            }
            else
            {
                command.Parameters["@images"].Value = null;
            }
            command.Parameters["@type_blog"].Value = value2;

            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Done");
                this.Close();
                Form7 f7 = new Form7(val);
                f7.Show();
            }

            connection.Close();
        }
Beispiel #3
0
        private void del_Click(object sender, EventArgs e)
        {
            MySqlConnection conn = new MySqlConnection("datasource = localhost; username=root;password=1234");

            conn.Open();
            MySqlCommand cmd = new MySqlCommand("delete from db.postdetails where postid=@id", conn);

            cmd.Parameters.AddWithValue("@id", comboBox1.SelectedItem);
            if (cmd.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Deleted");
                this.Hide();
                Form7 f = new Form7(val);
                f.Show();
            }
            else
            {
                MessageBox.Show("Error serving your request!");
            }
        }