Beispiel #1
0
        private void ok_Click(object sender, EventArgs e)
        {
            string MyConnectionString = "Server=localhost;Database=EMS;Uid=root;Pwd='';";
            MySqlConnection connection = new MySqlConnection(MyConnectionString);

            connection.Open();
            MySqlCommand cmd = connection.CreateCommand();
            cmd.CommandText = "INSERT INTO serviceprovider(service_provider,postbox,street,city,country) VALUES(@service_provider,@postbox,@street,@city,@country)";
            cmd.Parameters.AddWithValue("@service_provider", id.Text);
            cmd.Parameters.AddWithValue("@postbox", pobox.Text.ToString());
            cmd.Parameters.AddWithValue("@street", street.Text.ToString());
            cmd.Parameters.AddWithValue("@city", city.Text.ToString());
            cmd.Parameters.AddWithValue("@country", country.Text.ToString());

            cmd.ExecuteNonQuery();

            id.Text = "";
            pobox.Text = "";
            street.Text = "";
            city.Text = "";
            country.Text = "";
            email.Text = "";
            connection.Close();
            Login.warning ww = new Login.warning("'Service Provider Successfully Added!", this);
            ww.Show();
        }
Beispiel #2
0
        private void save_Click(object sender, EventArgs e)
        {
            String MyConnectionString = "Server=localhost;Database=EMS;Uid=root;Pwd='';";
            MySqlConnection connection = new MySqlConnection(MyConnectionString);

            connection.Open();
            MySqlCommand cmd = connection.CreateCommand();
            cmd.CommandText = "INSERT INTO agent(service_provider,agent_id,agent_name,telephone) VALUES(@service_provider,@agent_id,@agent_name,@telephone)";
            cmd.Parameters.AddWithValue("@id", id.Text);

            cmd.Parameters.AddWithValue("@service_provider", service.SelectedItem.ToString());
            cmd.Parameters.AddWithValue("@agent_id", id.Text.ToString());
            cmd.Parameters.AddWithValue("@agent_name", name.Text.ToString());
            cmd.Parameters.AddWithValue("@telephone", tp.Text.ToString());

            cmd.ExecuteNonQuery();
            connection.Close();

            id.Text = "";
            name.Text = "";
            tp.Text = "";

            Login.warning ww = new Login.warning("Agent Successfully Added!", this);
            ww.Show();
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string MyConnectionString = "Server=localhost;Database=EMS;Uid=root;Pwd='';";
            MySqlConnection connection = new MySqlConnection(MyConnectionString);

            connection.Open();
            MySqlCommand cmd = connection.CreateCommand();
            cmd.CommandText = "INSERT INTO location(location_id,name,longitude,latitude,altitude,street,city,country) VALUES(@id,@name,@long,@lati,@alti,@street,@city,@country)";
            cmd.Parameters.AddWithValue("@id", id.Text);
            cmd.Parameters.AddWithValue("@name", name.Text.ToString());
            cmd.Parameters.AddWithValue("@long", float.Parse(longitude.Text.ToString()));
            cmd.Parameters.AddWithValue("@lati", float.Parse(latitude.Text.ToString()));
            cmd.Parameters.AddWithValue("@alti", float.Parse(altitude.Text.ToString()));
            cmd.Parameters.AddWithValue("@street", street.Text.ToString());
            cmd.Parameters.AddWithValue("@city", city.Text);
            cmd.Parameters.AddWithValue("@country","SRI LANKA");

            cmd.ExecuteNonQuery();
            connection.Close();

            longitude.Text = "";
            latitude.Text = "";
            altitude.Text = "";
            name.Text = "";
            id.Text = "";
            street.Text = "";
            city.Text = "";
            Login.warning ww = new Login.warning("User Successfully Added!", this);
            ww.Show();
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            string MyConnectionString = "Server=localhost;Database=EMS;Uid=root;Pwd='';";
            MySqlConnection connection = new MySqlConnection(MyConnectionString);

            connection.Open();
            MySqlCommand cmd = connection.CreateCommand();
            MySqlCommand cmd2 = connection.CreateCommand();
            MySqlCommand cmd3 = connection.CreateCommand();
            cmd.CommandText = "INSERT INTO sensor(sensor_id,sensor_type,contract_id,refresh_time,sensor_status) VALUES(@sensor,@type,@cont,@time,@status)";
            cmd.Parameters.AddWithValue("@sensor", id.Text);
            cmd.Parameters.AddWithValue("@type", type.SelectedItem.ToString());
            cmd.Parameters.AddWithValue("@cont",contract.Text.ToString());
            DateTime time = Convert.ToDateTime(refreshtime.Text);
            cmd.Parameters.AddWithValue("@time", time);
            if (contract.Text != null)
            {
                cmd.Parameters.AddWithValue("@status", true);
            }else{
                cmd.Parameters.AddWithValue("@status", true);
            }
            cmd.ExecuteNonQuery();
            connection.Close();
            if (contract.Text != null)
            {

                cmd2.CommandText = "INSERT INTO contract(contract_id,sensor_id,established_date,expire_date,agent_id,Service_provider) VALUES(@contract_id,@sensor_id,@established_date,@expire_date,@agent_id,@Service_provider)";
                cmd2.Parameters.AddWithValue("@contract_id", contract.Text.ToString());
                cmd2.Parameters.AddWithValue("@sensor_id", id.Text.ToString());
                string date1 = establised.Text;
                string date2 = establised.Text;

                DateTime dt1 = Convert.ToDateTime(date1);
                DateTime dt2 = Convert.ToDateTime(date2);

                cmd2.Parameters.AddWithValue("@established_date", dt1.ToString());
                cmd2.Parameters.AddWithValue("@expire_date", dt2.ToString());
                cmd2.Parameters.AddWithValue("@agent_id", agent.SelectedItem.ToString());
                cmd2.Parameters.AddWithValue("@Service_provider", service.SelectedItem.ToString());
                connection.Open();
                cmd2.ExecuteNonQuery();
                connection.Close();

            }

            Login.warning ww = new Login.warning("Sensor Successfully Added!", this);
            ww.Show();
        }
Beispiel #5
0
        private void ok_Click(object sender, EventArgs e)
        {
            string MyConnectionString = "Server=localhost;Database=EMS;Uid=root;Pwd='';";
            MySqlConnection connection = new MySqlConnection(MyConnectionString);
            MySqlCommand cmd = connection.CreateCommand();
            MySqlDataReader rdr = null;

            connection.Open();

            cmd.CommandText = "SELECT username from users where username=@name";
            cmd.Parameters.AddWithValue("@name", name.Text.ToString());
            rdr = cmd.ExecuteReader();
            if (rdr.Read())
            {
                name.Text = "";
                psword.Text = "";
                psword1.Text = "";
                Login.warning ww = new Login.warning("Invalid Username!",this);
                ww.Show();

            }

            else
            {
                connection.Close();
                connection.Open();
                MySqlCommand cmd1 = connection.CreateCommand();
                cmd1.CommandText = "INSERT INTO users(username,hashcode,privilage_level) VALUES(@name1,@code,@level)";
                cmd1.Parameters.AddWithValue("@name1", name.Text.ToString());
                if (psword.Text.ToString() == psword1.Text.ToString())
                {
                    cmd1.Parameters.AddWithValue("@code", psword.Text.ToString());
                   // cmd1.Parameters.AddWithValue("@level", 3);
                    if (privililage.SelectedItem.ToString() == "High")
                    {
                        cmd1.Parameters.AddWithValue("@level", 1);
                    }
                    else if (privililage.SelectedItem.ToString() == "Medium")
                    {
                        cmd1.Parameters.AddWithValue("@level", 2);
                    }
                    else
                    {
                        cmd1.Parameters.AddWithValue("@level", 3);
                    }
                   cmd1.ExecuteNonQuery();

                    connection.Close();

                    name.Text = "";
                    psword.Text = "";
                    psword1.Text = "";
                    Login.warning ww = new Login.warning("User Successfully Added!", this);
                    ww.Show();

                }
                else
                {
                    psword.Text = "";
                    psword1.Text = "";
                    Login.warning ww2 = new Login.warning("Password Do Not Match!",this);
                    ww2.Show();

                }

            }
        }