public ShowRepairers(int urzadzenie_id) { InitializeComponent(); using (MainDB.InzynierkaDBEntities db = new MainDB.InzynierkaDBEntities()) { string query = "SELECT s.imie+' '+s.nazwisko AS 'Serwisanci' FROM Serwisant s " + "INNER JOIN GrupaNaprawcza gn ON gn.serwisant_id = s.serwisant_id " + "WHERE gn.urzadzenie_id = " + urzadzenie_id + ";"; DataTable dt = SQL.DoQuery(query); List <string> list = new List <string>(); foreach (DataRow dr in dt.Rows) { list.Add(dr[0].ToString()); } lboxRepairers.DataSource = list; } }
private void GetDataFromDB() { List <string> allrepairers; using (MainDB.InzynierkaDBEntities db = new MainDB.InzynierkaDBEntities()) { allrepairers = db.Serwisant.Select(x => x.imie + " " + x.nazwisko).ToList(); } foreach (string a in allrepairers) { lbToChoose.Items.Add(a); } lbToChoose.Update(); foreach (string a in lbChosen.Items) { lbToChoose.Items.Remove(a); } lbToChoose.Update(); }