void AdatBetoltes() { string sql = @" SELECT id, nev, uzlet FROM ajandek ORDER BY nev "; var comm = this.conn.CreateCommand(); comm.CommandText = sql; using (var reader = comm.ExecuteReader()) { lstBx_ajandek.Items.Clear(); while (reader.Read()) { int id = reader.GetInt32("id"); string nev = reader.GetString("nev"); string uzlet; try { uzlet = reader.GetString("uzlet"); } catch (SqlNullValueException ex) { uzlet = null; } var ajandek = new Ajandek(id, nev, uzlet); lstBx_ajandek.Items.Add(ajandek); } } }
private void lstBx_ajandek_MouseDoubleClick(object sender, MouseEventArgs e) { if (lstBx_ajandek.SelectedItem != null) { bttn_felvesz.Text = "Módosít"; Ajandek a = (Ajandek)lstBx_ajandek.SelectedItem; txtBx_nev.Text = a.Nev; if (a.Uzlet == null) { txtBx_uzlet.Text = "Saját készítésű"; } else { txtBx_uzlet.Text = a.Uzlet; } } }