Example #1
0
        private void Delit_Click(object sender, EventArgs e)
        {
            string          query7 = " DELETE FROM event where eventId ='" + evid + "'  ";
            MySqlConnection databaseConnection7 = new MySqlConnection(connectionString);
            MySqlCommand    commandDatabase7    = new MySqlCommand(query7, databaseConnection7);
            MySqlDataReader reader7;

            try
            {
                databaseConnection7.Open();

                commandDatabase7.ExecuteReader();
                MessageBox.Show("the event has ben Delited");
                this.Hide();
                showevent h1 = new showevent(clientid1);
                h1.Show();



                databaseConnection7.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                MessageBox.Show("Problem with Query");
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            showevent sh = new showevent(clientid1);

            sh.Show();
            this.Hide();
        }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            string date = eventdate.Value.ToString("yyyy-MM-dd");

            string name   = ename.Text;
            string adr    = addr.Text;
            string type   = typeboxx.Text;
            string tyid   = "";
            string imgc   = imagcat.Text;
            string imgcid = "";
            string dur    = duration.Text;
            string ndate  = DateTime.Now.ToString("yyyy-MM-dd");

            //-------------check if it is null and geting the type and imag size id------------------------------
            //-------------check if it is null and geting the type and imag size id------------------------------
            if (name == "" || adr == "" || dur == "")
            {
                MessageBox.Show("fill everyting plis");
            }
            else
            {
                string          connectionString     = "datasource=localhost;port=3306;username=root;password=;database=events;sslMode=none";
                string          query10              = "select * from imagcategory where categoryname ='" + imgc + "'";
                MySqlConnection databaseConnection10 = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase      = new MySqlCommand(query10, databaseConnection10);
                MySqlDataReader reader0;

                try
                {
                    databaseConnection10.Open();

                    reader0 = commandDatabase.ExecuteReader();

                    if (reader0.HasRows)
                    {
                        while (reader0.Read())
                        {
                            string m = reader0.GetString(0);
                            imgcid = m;
                        }
                    }
                    else
                    {
                        MessageBox.Show("No results found!");
                    }


                    databaseConnection10.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    MessageBox.Show("Problem with Query");
                }
                //===============================================================================

                string          query1 = "select * from eventtypes where typeName ='" + type + "'";
                MySqlConnection databaseConnection1 = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase1    = new MySqlCommand(query1, databaseConnection1);
                MySqlDataReader reader;

                try
                {
                    databaseConnection1.Open();

                    reader = commandDatabase1.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            string ty = reader.GetString(0);
                            tyid = ty;
                        }
                    }
                    else
                    {
                        MessageBox.Show("No results found!");
                    }


                    databaseConnection1.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    MessageBox.Show("Problem with Query");
                }
                //----------------------------------------------------------------------------------------------------------------------------------------------------------------
                string          query2 = "UPDATE event set name = '" + name + "',edate ='" + ndate + "',eventDate = '" + date + "',addres =' " + adr + "',type = '" + tyid + "',imgcategory='" + imgcid + "',durationInDays='" + dur + "' where eventId ='" + evid + "'  ";
                MySqlConnection databaseConnection2 = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase2    = new MySqlCommand(query2, databaseConnection2);
                MySqlDataReader reader2;

                try
                {
                    databaseConnection2.Open();

                    commandDatabase2.ExecuteReader();
                    MessageBox.Show("the event has ben changed");
                    this.Hide();
                    showevent h1 = new showevent(clientid1);
                    h1.Show();



                    databaseConnection2.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    MessageBox.Show("Problem with Query");
                }
            }
        }