Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Form3 f3 = new Form3(this);

            f3.label1.Visible = true;
            if (checkBox1.Checked)
            {
                try
                {
                    NewConnection.OpenConection();
                    f3.label1.Text = "Połączono z bazą danych";
                }
                catch (Exception ex)
                {
                    f3.label1.Text = "Nie można połączyć z bazą danych";
                }

                this.Hide();
                f3.ShowDialog();
                this.Show();
            }
            else
            {
                MessageBox.Show("Proszę najpierw połączyć się z bazą danych");
            }
        }
Exemple #2
0
        public void comboBox2_Click(object sender, EventArgs e)
        {
            comboBox2.Items.Clear();
            NewConnection.OpenConection();
            string        Query_ = "SELECT distinct PFamily FROM CPU";
            SqlDataReader dr     = NewConnection.DataReader(Query_);

            dr.Read();
            try
            {
                while (dr.Read())
                {
                    comboBox2.Items.Add((string)dr["PFamily"]);
                }
            }
            finally
            {
                // Always call Close when done reading.
                dr.Close();
            }


            if (comboBox1.Text == "Intel")
            {
                comboBox1.Items.Clear();
                comboBox2.Items.Clear();
                string        Query1 = "SELECT distinct PFamily FROM CPU WHERE (Producent = 'Intel')";
                SqlDataReader dr1    = NewConnection.DataReader(Query1);
                dr1.Read();
                try
                {
                    while (dr1.Read())
                    {
                        comboBox2.Items.Add((string)dr1["PFamily"]);
                    }
                }
                finally
                {
                    // Always call Close when done reading.
                    dr1.Close();
                }
            }
            else if (comboBox1.Text == "AMD")
            {
                comboBox1.Items.Clear();
                comboBox2.Items.Clear();
                string        Query2 = "SELECT distinct PFamily FROM CPU WHERE (Producent = 'AMD')";
                SqlDataReader dr2    = NewConnection.DataReader(Query2);
                dr2.Read();
                try
                {
                    while (dr2.Read())
                    {
                        comboBox2.Items.Add((string)dr2["PFamily"]);
                    }
                }
                finally
                {
                    // Always call Close when done reading.
                    dr2.Close();
                }
            }
        }