private async Task Binding() { var users = await _context.Users.ToListAsync(); userBindingSource.DataSource = new BindingListView <UI.Models.User>(list: users); UsersGridView.Refresh(); SoftwareGridView.Refresh(); }
/// <summary> /// Добавление пользователя /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void AddUserBtn_Click(object sender, EventArgs e) { var userAddForm = new UserAddForm(); var dialogResult = userAddForm.ShowDialog(); if (dialogResult == Yes) { await SetBinding(); UsersGridView.Refresh(); } }
/// <summary> /// Удаление пользователя /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void RemoveUserBtn_Click(object sender, EventArgs e) { if (UsersGridView.SelectedRows.Count > 0) { var id = (int)UsersGridView.SelectedRows[index : 0].Cells[index : 0].Value; var user = await _context.Users.FindAsync(id); _context.Users.Remove(entity: user); await _context.SaveChangesAsync(); await SetBinding(); UsersGridView.Refresh(); } }