Exemple #1
0
        private void lBVarosLista_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lBVarosLista.SelectedIndex > -1)
            {
                lBLatvanyosagLista.Items.Clear();
                gBVarosModosit.Visible = true;
                bVarosTorol.Visible    = true;
                Varos  varos = (Varos)lBVarosLista.SelectedItem;
                string sql   = @"
SELECT id, nev, leiras, ar, varos_id 
FROM latvanyossagok
WHERE varos_id = @varos_id
";
                var    comm  = this.conn.CreateCommand();
                comm.CommandText = sql;
                comm.Parameters.AddWithValue("@varos_id", varos.getId());
                using (var reader = comm.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        int    id      = reader.GetInt32("id");
                        string nev     = reader.GetString("nev");
                        string leiras  = reader.GetString("leiras");
                        int    ar      = reader.GetInt32("ar");
                        int    varosId = reader.GetInt32("varos_id");

                        Latvanyossag latvanyosag = new Latvanyossag(id, nev, leiras, ar, varosId);
                        lBLatvanyosagLista.Items.Add(latvanyosag);
                    }
                }
            }
        }
Exemple #2
0
        private void bVarosModosit_Click(object sender, EventArgs e)
        {
            if (lBVarosLista.SelectedIndex > -1)
            {
                string sql   = @"
UPDATE `varosok` 
SET `nev`= @nev,
`lakossag`= @lakossag
WHERE id`= @id,
";
                Varos  varos = (Varos)lBVarosLista.SelectedItem;
                var    comm  = this.conn.CreateCommand();
                comm.CommandText = sql;
                comm.Parameters.AddWithValue("@id", varos.getId());
                comm.Parameters.AddWithValue("@nev", tBVarosNevModosit.Text);
                comm.Parameters.AddWithValue("@lakossag", nUADVarosLakosagaModosit);
                comm.ExecuteNonQuery();
            }
            else
            {
                MessageBox.Show("nem választotad ki mit akarsz modositani.");
            }
            lBVarosLista.SelectedIndex = -1;
            gBVarosModosit.Visible     = false;
            bVarosTorol.Visible        = false;
        }