private void userShowcomboBox_SelectedIndexChanged(object sender, EventArgs e) { userLendedBookslistBox.Items.Clear(); userUnLendedBookslistBox.Items.Clear(); //SELECT u.id_u, u.name, u.surname, u.tel, u.address, u.notes, l.name, l.postalcode databaseController dbc = new databaseController(); string selectedUser = userShowcomboBox.SelectedItem.ToString();//exception needs to be handled selectedUser = selectedUser.Trim(); string[] UserID = selectedUser.Split('|'); int id_u = Convert.ToInt32(UserID[0].Trim()); string name = UserID[1].Trim();//title string surname = UserID[2].Trim(); string tel = UserID[3].Trim(); string address = UserID[3].Trim(); string location_name = UserID[3].Trim(); string location_postalcode = UserID[3].Trim(); Locations lid = new Locations(0, location_name, ""); dbc.idLocations(lid); int location_id = 0; foreach (int k in dbc.idLocations(lid)) { location_id = k; } Users uid = new Users(0, name, surname, "", "", "", "", 0); dbc.idUsers(uid); int user_id = 0; foreach (int k in dbc.idUsers(uid)) { user_id = k; } Users u = new Users(id_u, name, surname, tel, address, "", "", location_id); Rents r = new Rents(0, 1, "", 0, id_u); dbc.ReadLendedBooks(r); foreach (string name1 in dbc.ReadLendedBooks(r)) { userLendedBookslistBox.Items.Add(name1); } userUnLendedBookslistBox.Items.Clear(); dbc.ReadUnlendedBooks(); foreach (string name1 in dbc.ReadUnlendedBooks()) { userUnLendedBookslistBox.Items.Add(name1); } userUnLendedBookslistBox.Items.Clear(); //OutputBooksOnRents_Lended(); OutputBooksOnRents_UnLended(); }