示例#1
0
        private async Task Binding()
        {
            var users = await _context.Users.ToListAsync();

            userBindingSource.DataSource = new BindingListView <UI.Models.User>(list: users);
            UsersGridView.Refresh();
            SoftwareGridView.Refresh();
        }
示例#2
0
        /// <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();
            }
        }
示例#3
0
        /// <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();
            }
        }