Beispiel #1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            Database duombaze = new Database();

            string       querry    = "SELECT * FROM `motociklas`";
            MySqlCommand myCommand = new MySqlCommand(querry, duombaze.myDatabase);

            duombaze.Open(); //prisijungus prie db ja atidaro
            var reader = myCommand.ExecuteReader();

            while (reader.Read())
            {
                NaujiM Mocas = new NaujiM();
                Mocas.gamintojas = reader["Gamintojas"].ToString();
                Mocas.modelis    = reader["Modelis"].ToString();
                Mocas.tipas      = reader["Tipas"].ToString();
                Mocas.metai      = Convert.ToInt32(reader["Metai"]);
                Mocas.kaina      = Convert.ToInt32(reader["Kaina"]);
                Mocas.spalva     = reader["Spalva"].ToString();
                Mocas.kubatura   = Convert.ToInt32(reader["Kubatura"]);
                Mocas.rida       = Convert.ToInt32(reader["Rida"]);
                NMList.Add(Mocas);
            }
            NMList.Sort();

            comboBox1.DataSource     = NMList;
            comboBox3.DataSource     = NMList;
            comboBox4.DataSource     = NMList;
            comboBox5.DataSource     = NMList;
            comboBox6.DataSource     = NMList;
            comboBox7.DataSource     = NMList;
            comboBox8.DataSource     = NMList;
            comboBox10.DataSource    = NMList;
            comboBox11.DataSource    = NMList;
            comboBox1.DisplayMember  = "pilnasPavadinimas";
            comboBox3.DisplayMember  = "tipas";
            comboBox4.DisplayMember  = "gamintojas";
            comboBox5.DisplayMember  = "modelis";
            comboBox6.DisplayMember  = "metai";
            comboBox7.DisplayMember  = "spalva";
            comboBox8.DisplayMember  = "kubatura";
            comboBox10.DisplayMember = "rida";
            comboBox11.DisplayMember = "kaina";

            //kad užkrovus db, neišmestų pirmo liste ir jo charakteristikų
            comboBox1.SelectedIndex  = -1;
            comboBox3.SelectedIndex  = -1;
            comboBox4.SelectedIndex  = -1;
            comboBox5.SelectedIndex  = -1;
            comboBox6.SelectedIndex  = -1;
            comboBox7.SelectedIndex  = -1;
            comboBox8.SelectedIndex  = -1;
            comboBox10.SelectedIndex = -1;
            comboBox11.SelectedIndex = -1;
            duombaze.Close();
        }
Beispiel #2
0
        private void Button5_Click(object sender, EventArgs e) //nuskaitymas
        {
            Database duombaze = new Database();

            string       querry    = "SELECT * FROM `motociklas`";
            MySqlCommand myCommand = new MySqlCommand(querry, duombaze.myDatabase);

            duombaze.Open(); //prisijungus prie db ja atidaro
            var reader = myCommand.ExecuteReader();

            while (reader.Read())
            {
                NaujiM Mocas = new NaujiM();
                Mocas.gamintojas = reader["Gamintojas"].ToString();
                Mocas.modelis    = reader["Modelis"].ToString();
                Mocas.tipas      = reader["Tipas"].ToString();
                Mocas.metai      = Convert.ToInt32(reader["Metai"]);
                Mocas.kaina      = Convert.ToInt32(reader["Kaina"]);
                Mocas.spalva     = reader["Spalva"].ToString();
                Mocas.kubatura   = Convert.ToInt32(reader["Kubatura"]);
                Mocas.rida       = Convert.ToInt32(reader["Rida"]);
                motoRedagavimui.Add(Mocas);
            }
            motoRedagavimui.Sort();

            comboBox1.DataSource  = motoRedagavimui;
            comboBox2.DataSource  = motoRedagavimui;
            comboBox9.DataSource  = motoRedagavimui;
            comboBox12.DataSource = motoRedagavimui;

            comboBox1.DisplayMember  = "pilnasPavadinimas";
            comboBox2.DisplayMember  = "pilnasPavadinimas";
            comboBox9.DisplayMember  = "Gamintojas";
            comboBox12.DisplayMember = "Modelis";

            comboBox1.SelectedIndex  = -1;
            comboBox2.SelectedIndex  = -1;
            comboBox9.SelectedIndex  = -1;
            comboBox12.SelectedIndex = -1;

            duombaze.Close();
        }