void LoadForm() { UsersController uc = new UsersController(); users = uc.ShowAll(); usersDataGridView.Rows.Clear(); usersDataGridView.Columns.Clear(); usersDataGridView.Refresh(); //setup //columns usersDataGridView.Columns.Add("userId", "ID"); usersDataGridView.Columns.Add("name", "Name"); usersDataGridView.Columns.Add("username", "Username"); usersDataGridView.Columns["userId"].Visible = false; //rows if (users.Count > 0) { foreach (User user in users) { usersDataGridView.Rows.Add( user.id, user.name, user.username ); if (user.isAdmin) { usersDataGridView.Rows[usersDataGridView.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Yellow; } } } else { MessageBox.Show("No users are currently registered in the system. Please add a user!", "No User Found!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
public void Delete() { UsersController uc = new UsersController(); uc.Delete(id); }