コード例 #1
0
        public void log()
        {
            String          username           = user.Text;
            String          password           = pass.Text;
            string          connectionString   = "datasource=localhost;port=3306;username=root;password=;database=events;sslMode=none";
            string          query              = "SELECT * FROM workers where userName ='******' and passWord =  '******'";
            MySqlConnection databaseConnection = new MySqlConnection(connectionString);
            MySqlCommand    commandDatabase    = new MySqlCommand(query, databaseConnection);


            MySqlDataReader reader;

            try
            {
                databaseConnection.Open();

                reader = commandDatabase.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        string id = reader.GetInt32(0).ToString();

                        home f1 = new home(id);
                        f1.Show();
                        this.Hide();
                    }
                }
                else
                {
                    MessageBox.Show("No results found!");
                }


                databaseConnection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                MessageBox.Show("Problem with Query");
            }
        }
コード例 #2
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------------------------------
            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");
                }
                //----------------------------------------------------------------------------------------------------------------------------------------------------------------
                MessageBox.Show(tyid);
                string          query2 = "INSERT INTO event (name,edate,eventDate,addres,type,imgcategory,durationInDays) VALUES ('" + name + "','" + ndate + "','" + date + "',' " + adr + "'," + tyid + ",'" + imgcid + "','" + dur + "')";
                MySqlConnection databaseConnection2 = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase2    = new MySqlCommand(query2, databaseConnection2);
                MySqlDataReader reader2;
                ;
                try
                {
                    databaseConnection2.Open();

                    commandDatabase2.ExecuteReader();
                    MessageBox.Show("the event was created");
                    this.Hide();
                    home h1 = new home(clientid1);
                    h1.Show();



                    databaseConnection2.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    MessageBox.Show("Problem with Query");
                }
            }
        }
コード例 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (name.Text != "" || surname.Text != "" || email.Text != "" || username.Text != "" || password.Text != "")
            {
                string          query10              = "select * from job where jobName ='" + jobbox.Text + "'";
                string          connectionString     = "datasource=localhost;port=3306;username=root;password=;database=events;sslMode=none";
                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);
                            jobid = m;
                        }
                    }
                    else
                    {
                        MessageBox.Show("No results found!");
                    }


                    databaseConnection10.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    MessageBox.Show("Problem with Query");
                }
                string date = dob.Value.ToString("yyyy-MM-dd");

                string          query2 = "INSERT INTO workers (name,surname,dateOfBirth,email,jobid,username,password) VALUES ('" + name.Text + "','" + surname.Text + "','" + date + "','" + email.Text + "',' " + jobid + "','" + username.Text + "','" + password.Text + "')";
                MySqlConnection databaseConnection2 = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase2    = new MySqlCommand(query2, databaseConnection2);
                MySqlDataReader reader2;

                try
                {
                    databaseConnection2.Open();

                    commandDatabase2.ExecuteReader();
                    MessageBox.Show("the event was created");
                    this.Hide();
                    home h1 = new home(clientid1);
                    h1.Show();



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