Beispiel #1
0
        private void Button5_Click(object sender, EventArgs e)
        {
            double sum = 0;

            listBox3.Items.Clear();
            myConnection = new OleDbConnection(connectString);
            myConnection.Open();
            string          isvedimas = "SELECT Pavadinimas, Kaina, Apmokejimo_busena FROM Krepselis ORDER BY ID;";
            OleDbCommand    command   = new OleDbCommand(isvedimas, myConnection);
            int             m         = 0;
            OleDbDataReader reader    = command.ExecuteReader();

            listBox3.Items.Clear();
            while (reader.Read())
            {
                listBox3.Items.Add(reader[0].ToString() + " " + reader[1].ToString() + " " + reader[2].ToString());

                if (n == m)
                {
                    K[m] = new Krep();
                    K[m].SetPav(reader[0].ToString());
                    K[m].SetKaina(Convert.ToDouble(reader[1]));
                    K[m].SetBus(reader[2].ToString());
                }
                sum = sum + K[m].GetKaina();
                m++;
            }
            n           = m;
            label1.Text = "Bendra suma: " + sum.ToString();
            reader.Close();
            myConnection.Close();
        }
Beispiel #2
0
        public Krepselis()
        {
            InitializeComponent();
            myConnection = new OleDbConnection(connectString);
            myConnection.Open();
            string          isvedimas = "SELECT Pavadinimas, Kaina, Apmokejimo_busena FROM Krepselis ORDER BY ID;";
            OleDbCommand    command   = new OleDbCommand(isvedimas, myConnection);
            OleDbDataReader reader    = command.ExecuteReader();

            n = 0;
            while (reader.Read())
            {
                K[n] = new Krep();
                K[n].SetPav(reader[0].ToString());
                K[n].SetKaina(Convert.ToDouble(reader[1]));
                K[n].SetBus(reader[2].ToString());
                sum = sum + K[n].GetKaina();
                n++;
            }

            reader.Close();
            myConnection.Close();
            label1.Text = "Bendra suma: " + sum.ToString();
        }